Skip to content

Commit

Permalink
import bytesToBool from toolkit
Browse files Browse the repository at this point in the history
  • Loading branch information
lukema95 committed Jun 20, 2024
1 parent 276be9c commit a0610c9
Show file tree
Hide file tree
Showing 4 changed files with 1,503 additions and 1,650 deletions.
11 changes: 1 addition & 10 deletions omnichain/swap/contracts/SwapToAnyToken.sol
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ contract SwapToAnyToken is zContract, OnlySystem {
params.target = BytesHelperLib.bytesToAddress(message, 0);
params.to = abi.encodePacked(BytesHelperLib.bytesToAddress(message, 20));
if (message.length >= 41) {
params.withdraw = bytesToBool(message, 40);
params.withdraw = BytesHelperLib.bytesToBool(message, 40);
}
} else {
(address targetToken, bytes memory recipient, bool withdrawFlag) = abi.decode(
Expand Down Expand Up @@ -82,13 +82,4 @@ contract SwapToAnyToken is zContract, OnlySystem {
IWETH9(params.target).transfer(address(uint160(bytes20(params.to))), outputAmount);
}
}

function bytesToBool(bytes calldata data, uint256 offset)
internal
pure
returns (bool)
{
require(offset < data.length, "Offset is out of bounds");
return uint8(data[offset]) != 0;
}
}
2 changes: 1 addition & 1 deletion omnichain/swap/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"@types/node": ">=12.0.0",
"@typescript-eslint/eslint-plugin": "^5.59.9",
"@typescript-eslint/parser": "^5.59.9",
"@zetachain/toolkit": "9.0.0",
"@zetachain/toolkit": "10.0.0",
"axios": "^1.3.6",
"chai": "^4.2.0",
"dotenv": "^16.0.3",
Expand Down
Loading

0 comments on commit a0610c9

Please sign in to comment.