Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: check withdraw fee in Swap, callMulti example, universal NFT/FT #229

Open
wants to merge 19 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions .github/workflows/slither.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,6 @@ jobs:
file: "call.sarif"
- project: "examples/swap"
file: "swap.sarif"
- project: "examples/nft"
file: "nft.sarif"
- project: "examples/token"
file: "token.sarif"
permissions:
contents: read
security-events: write
Expand Down
8 changes: 5 additions & 3 deletions examples/call/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"@typescript-eslint/eslint-plugin": "^5.59.9",
"@typescript-eslint/parser": "^5.59.9",
"@zetachain/localnet": "4.0.0-rc6",
"@zetachain/toolkit": "13.0.0-rc7",
"@zetachain/toolkit": "13.0.0-rc12",
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codebase verification

Version inconsistency detected in example projects

The @zetachain/toolkit package has inconsistent versions across examples:

  • Version 13.0.0-rc12: hello, swap, call
  • Version 13.0.0-rc8: nft, token

Consider updating all examples to use the latest release candidate version 13.0.0-rc12 for consistency.

🔗 Analysis chain

Ensure version consistency across example projects.

The changes introduce multiple release candidate dependencies:

  • Updating @zetachain/toolkit to 13.0.0-rc12
  • Adding @zetachain/networks at 10.0.0-rc4
  • Adding @zetachain/protocol-contracts-solana at 2.0.0-rc1

Run this script to verify version consistency across all example projects:

Also applies to: 60-62

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check version consistency across example projects

# Find all package.json files in example directories
echo "Checking ZetaChain package versions across all examples:"
for pkg in "@zetachain/toolkit" "@zetachain/networks" "@zetachain/protocol-contracts" "@zetachain/protocol-contracts-solana"; do
  echo -e "\nVersions of $pkg:"
  fd --type f "package.json" examples/ --exec jq -r \
    --arg pkg "$pkg" \
    'if .dependencies[$pkg] then "  " + . + ": " + .dependencies[$pkg] elif .devDependencies[$pkg] then "  " + . + ": " + .devDependencies[$pkg] else empty end'
done

Length of output: 3335


Script:

#!/bin/bash
# Description: Check version consistency with corrected jq query

echo "Checking ZetaChain package versions across all examples:"
for pkg in "@zetachain/toolkit" "@zetachain/networks" "@zetachain/protocol-contracts" "@zetachain/protocol-contracts-solana"; do
  echo -e "\nVersions of $pkg:"
  fd --type f "package.json" examples/ --exec sh -c "echo -n '  {}:' && jq -r '.dependencies[\"$pkg\"] // .devDependencies[\"$pkg\"] // \"not found\"' {}"
done

Length of output: 2613

"axios": "^1.3.6",
"chai": "^4.2.0",
"dotenv": "^16.0.3",
Expand Down Expand Up @@ -57,6 +57,8 @@
"@solana-developers/helpers": "^2.4.0",
"@solana/spl-memo": "^0.2.5",
"@solana/web3.js": "^1.95.8",
"@zetachain/protocol-contracts": "11.0.0-rc3"
"@zetachain/networks": "10.0.0-rc4",
"@zetachain/protocol-contracts": "11.0.0-rc3",
"@zetachain/protocol-contracts-solana": "2.0.0-rc1"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codebase verification

Remove or document unused Solana dependency

The @zetachain/protocol-contracts-solana dependency appears to be unused in the codebase. Either:

  • Remove the dependency if it's not needed
  • Document its intended usage and implement the Solana integration
🔗 Analysis chain

Verify Solana contract integration requirements.

The addition of @zetachain/protocol-contracts-solana suggests new Solana integration capabilities. Ensure this dependency is required and properly documented in the project's README.

Run this script to check for Solana-related configuration and documentation:

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for Solana configuration and documentation

# Check for Solana configuration files
echo "Checking for Solana configuration files:"
fd -e yaml -e json "solana" examples/call/

# Check for Solana documentation
echo -e "\nChecking for Solana documentation:"
rg -i "solana" examples/call/README.md || echo "No Solana documentation found in README"

Length of output: 346


Script:

#!/bin/bash
# Check for imports and usage of Solana contracts
echo "Checking for Solana contract imports and usage:"
rg -i "@zetachain/protocol-contracts-solana" examples/call/ -A 2

echo -e "\nChecking for Solana-related code patterns:"
rg -i "solana" examples/call/ --type ts --type js --type tsx --type jsx

Length of output: 1163

}
}
}
6 changes: 3 additions & 3 deletions examples/call/tasks/connectedCall.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,13 @@ task(
.addOptionalParam(
"txOptionsGasPrice",
"The gas price for the transaction",
10000000000,
20000000000,
types.int
)
.addOptionalParam(
"txOptionsGasLimit",
"The gas limit for the transaction",
7000000,
500000,
types.int
)
.addFlag("callOnRevert", "Whether to call on revert")
Expand All @@ -94,7 +94,7 @@ task(
.addOptionalParam(
"onRevertGasLimit",
"The gas limit for the revert transaction",
7000000,
500000,
types.int
)
.addParam("name", "The name of the contract", "Connected")
Expand Down
6 changes: 3 additions & 3 deletions examples/call/tasks/connectedDeposit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,13 @@ task("connected-deposit", "Deposit tokens to ZetaChain", main)
.addOptionalParam(
"txOptionsGasPrice",
"The gas price for the transaction",
10000000000,
20000000000,
types.int
)
.addOptionalParam(
"txOptionsGasLimit",
"The gas limit for the transaction",
7000000,
500000,
types.int
)
.addFlag("callOnRevert", "Whether to call on revert")
Expand All @@ -87,7 +87,7 @@ task("connected-deposit", "Deposit tokens to ZetaChain", main)
.addOptionalParam(
"onRevertGasLimit",
"The gas limit for the revert transaction",
7000000,
500000,
types.int
)
.addOptionalParam("erc20", "The address of the ERC20 token to deposit")
Expand Down
6 changes: 3 additions & 3 deletions examples/call/tasks/connectedDepositAndCall.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,13 +103,13 @@ task(
.addOptionalParam(
"txOptionsGasPrice",
"The gas price for the transaction",
10000000000,
20000000000,
types.int
)
.addOptionalParam(
"txOptionsGasLimit",
"The gas limit for the transaction",
7000000,
500000,
types.int
)
.addFlag("callOnRevert", "Whether to call on revert")
Expand All @@ -126,7 +126,7 @@ task(
.addOptionalParam(
"onRevertGasLimit",
"The gas limit for the revert transaction",
7000000,
500000,
types.int
)
.addParam("amount", "The amount of tokens to deposit")
Expand Down
8 changes: 4 additions & 4 deletions examples/call/tasks/universalCall.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,13 +93,13 @@ task(
.addOptionalParam(
"txOptionsGasPrice",
"The gas price for the transaction",
10000000000,
20000000000,
types.int
)
.addOptionalParam(
"txOptionsGasLimit",
"The gas limit for the transaction",
7000000,
500000,
types.int
)
.addFlag("callOnRevert", "Whether to call on revert")
Expand All @@ -116,14 +116,14 @@ task(
.addOptionalParam(
"onRevertGasLimit",
"The gas limit for the revert transaction",
7000000,
50000,
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Inconsistent onRevertGasLimit value

The onRevertGasLimit is set to 50000, while other files use 500000. This appears to be inconsistent and might be insufficient for revert operations.

Apply this fix to maintain consistency:

-    50000,
+    500000,
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
50000,
500000,

types.int
)
.addFlag("callOptionsIsArbitraryCall", "Call any function")
.addOptionalParam(
"callOptionsGasLimit",
"The gas limit for the call",
7000000,
500000,
types.int
)
.addParam("function", `Function to call (example: "hello(string)")`)
Expand Down
6 changes: 3 additions & 3 deletions examples/call/tasks/universalWithdraw.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,13 @@ task("universal-withdraw", "Withdraw ZRC-20", main)
.addOptionalParam(
"txOptionsGasPrice",
"The gas price for the transaction",
10000000000,
20000000000,
types.int
)
.addOptionalParam(
"txOptionsGasLimit",
"The gas limit for the transaction",
7000000,
500000,
types.int
)
.addFlag("callOnRevert", "Whether to call on revert")
Expand All @@ -86,7 +86,7 @@ task("universal-withdraw", "Withdraw ZRC-20", main)
.addOptionalParam(
"onRevertGasLimit",
"The gas limit for the revert transaction",
7000000,
500000,
types.int
)
.addParam("name", "The name of the contract", "Universal")
Expand Down
8 changes: 4 additions & 4 deletions examples/call/tasks/universalWithdrawAndCall.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,13 +124,13 @@ task(
.addOptionalParam(
"txOptionsGasPrice",
"The gas price for the transaction",
10000000000,
20000000000,
types.int
)
.addOptionalParam(
"txOptionsGasLimit",
"The gas limit for the transaction",
7000000,
500000,
types.int
)
.addFlag("callOnRevert", "Whether to call on revert")
Expand All @@ -147,14 +147,14 @@ task(
.addOptionalParam(
"onRevertGasLimit",
"The gas limit for the revert transaction",
7000000,
500000,
types.int
)
.addFlag("callOptionsIsArbitraryCall", "Call any function")
.addOptionalParam(
"callOptionsGasLimit",
"The gas limit for the call",
7000000,
500000,
types.int
)
.addOptionalParam("function", `Function to call (example: "hello(string)")`)
Expand Down
Loading
Loading