-
Notifications
You must be signed in to change notification settings - Fork 3
feat: add ERC20 MTS workshop again #16
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
base: master
Are you sure you want to change the base?
Conversation
WalkthroughA new ERC20 MTS workshop directory was introduced, containing scripts, configuration files, and documentation for deploying and interacting with ERC20 tokens and WASM contracts on the Injective blockchain. The additions include shell scripts for key management, contract deployment, balance queries, and token minting, along with a Rust source file defining CosmWasm contract message types. The Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant CLI/Foundry
participant Injective Node
participant WASM Contract
User->>CLI/Foundry: Run deployment/import/mint/balance script
CLI/Foundry->>Injective Node: Send transaction or query (deploy, mint, query balance)
Injective Node->>CLI/Foundry: Return result (contract address, balance, etc.)
CLI/Foundry-->>User: Output result
User->>CLI/Foundry: Deploy WASM contract
CLI/Foundry->>Injective Node: Store and instantiate WASM contract
Injective Node->>CLI/Foundry: Return code_id and contract address
CLI/Foundry-->>User: Output WASM contract address
User->>CLI/Foundry: Interact with WASM contract (increment/query)
CLI/Foundry->>Injective Node: Execute/query WASM contract
Injective Node->>WASM Contract: Handle execution/query
WASM Contract-->>Injective Node: Return execution/query result
Injective Node-->>CLI/Foundry: Return result
CLI/Foundry-->>User: Output result
Poem
✨ Finishing Touches
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 31
🧹 Nitpick comments (26)
workshops/erc20-mts/scripts/import-cast-key.sh (1)
1-2: Validate required environment variables.
Add guards to fail fast ifUSER,USER_PWD, orUSER_MNEMONICare unset.: "${USER:?Environment variable USER is required.}" : "${USER_PWD:?Environment variable USER_PWD is required.}" : "${USER_MNEMONIC:?Environment variable USER_MNEMONIC is required.}"workshops/erc20-mts/scripts/cli-address.sh (1)
9-9: Useprintffor consistent escape-sequence handling.
echomay not interpret backslashes portably.- echo "\t* Injective address: $INJ_ADDRESS" + printf '\t* Injective address: %s\n' "$INJ_ADDRESS" - echo "\t* Ethereum address: $ETH_ADDRESS" + printf '\t* Ethereum address: %s\n' "$ETH_ADDRESS"Also applies to: 15-15
workshops/erc20-mts/scripts/cli-balances-user2.sh (1)
12-14: Useprintffor newlines and consistent formatting.
echo "\n..."prints literal\n; switch toprintf.- echo "\n### RUNNING ###" + printf '\n### RUNNING ###\n' - echo "###############\n" + printf '###############\n\n'workshops/erc20-mts/scripts/cli-balances-user1.sh (1)
9-12: Useprintffor formatting with newlines.
Replaceecho "\n...withprintfto handle escapes portably.- echo "\n### RUNNING ###" + printf '\n### RUNNING ###\n' ... - echo "###############\n" + printf '###############\n\n'workshops/erc20-mts/README.md (2)
12-18: Use explicit markdown for numbered steps.
Consider adding a blank line before the list and ensuring the ordered list is consistently formatted for clarity.
19-22: Fix grammatical error in conclusion.
Change "We've created an ERC20 tokens" to "We've created an ERC20 token" to maintain singular agreement.workshops/erc20-mts/scripts/erc20-balance-user2.sh (1)
12-14: Avoid literal\ninecho.
echo "\n### RUNNING ###"will print\nliterally. Useprintforecho -efor newlines:-echo "\n### RUNNING ###" +printf "\n### RUNNING ###\n"workshops/erc20-mts/scripts/cli-denom.sh (2)
15-19: Replace[[ ]]with POSIX checks.
[[ "$1" != erc20:* ]]is Bash-only. For POSIX compliance, use:-if [[ "$1" != erc20:* ]]; then - echo "⚠️ Error: Denom must start with 'erc20:' prefix" - exit 1 -fi +case "$1" in + erc20:*) ;; + *) + echo "⚠️ Error: Denom must start with 'erc20:' prefix" + exit 1 + ;; +esac🧰 Tools
🪛 Shellcheck (0.10.0)
[warning] 15-15: In POSIX sh, [[ ]] is undefined.
(SC3010)
21-27: Avoid printing literal newline escapes.
Useprintffor formatted output instead ofecho "\n...":-echo "\n### QUERYING DENOM ###" +printf "\n### QUERYING DENOM ###\n"workshops/erc20-mts/scripts/wasm-query-counter.sh (2)
10-11: Avoid using the generic$USERvariable.
Overwriting or relying on$USERcan conflict with the shell’s username variable. Consider a more specific name (e.g.,INJ_KEY_NAME) in.local.env.
14-21: Replace literal\nin echo statements.
Useprintffor newlines to ensure correct formatting:-echo "\n### QUERYING COUNT ###" +printf "\n### QUERYING COUNT ###\n"workshops/erc20-mts/scripts/deploy-erc20-mintburn.sh (2)
14-27: Print newlines portably
Plainechowon’t interpret\nby default. Useprintffor consistent newline handling.- echo "\n### RUNNING ###" + printf "\n### RUNNING ###\n" ... - echo "###############\n" + printf "###############\n"
29-43: Improve error handling withset -eand remove manual checks
You perform explicit$?checks afterforge create. Consider addingset -euo pipefailat the top to exit on any failure and drop the manualif [ $? -ne 0 ]block.+# At top, after shebang: +set -euo pipefailworkshops/erc20-mts/scripts/import-cli-key.sh (2)
7-10: Quote variables in external commands
Unquoted$USERand$USER_MNEMONICmay break if they contain spaces or special chars.- if injectived keys list --keyring-backend=test | grep -q $USER; then + if injectived keys list --keyring-backend=test | grep -q "$USER"; then ... - echo "$USER_MNEMONIC" | injectived keys add $USER --recover --keyring-backend=test + echo "$USER_MNEMONIC" | injectived keys add "$USER" --recover --keyring-backend=test
17-28: Consider fail-fast on errors
This script lacksset -e. If anyinjectivedcall fails, the flow continues. Addingset -euo pipefailat the top will stop on errors and catch unset variables.workshops/erc20-mts/scripts/mint-erc20.sh (2)
35-45: Useprintfinstead of literal\ninecho
To render new lines reliably, switch toprintf.- echo "\n### RUNNING ###" + printf "\n### RUNNING ###\n" ... - echo "###############\n" + printf "###############\n"
47-56: Redundant manual exit due toset -e
You haveset -eat the top, so the manual$?check aftercast sendis unnecessary. You can safely remove lines 56–59.workshops/erc20-mts/scripts/deploy-erc20.sh (2)
8-21: Print commands with proper newlines
Replaceecho "\n…"withprintffor consistent newline rendering.- echo "\n### RUNNING ###" + printf "\n### RUNNING ###\n" ... - echo "###############\n" + printf "###############\n"
23-34: Considerset -euo pipefailand clean up error checks
Adding strict mode will automatically abort on failure, eliminating the need for manual exit code checks.workshops/erc20-mts/scripts/erc20-balance-user1.sh (2)
19-21: Render newlines reliably
echo "\n…"won’t interpret\n. Preferprintf.- echo "\n### RUNNING ###" + printf "\n### RUNNING ###\n"
20-21: Avoid quoting the pipe in echo
The literal|is quoted in theechocommand and won’t reflect the actual pipeline. Remove the quotes around|.- echo cast call $ERC20_ADDRESS "balanceOf(address)" $USER_ETH_ADDRESS "|" xargs cast decode-abi "balanceOf(address)(uint256)" + echo cast call "$ERC20_ADDRESS" "balanceOf(address)" "$USER_ETH_ADDRESS" | xargs cast decode-abi "balanceOf(address)(uint256)"workshops/erc20-mts/scripts/deploy-wasm.sh (1)
10-22:echo "\n…"prints the literal “\n” – useprintffor newlinesPOSIX
echodoes not interpret back-slash escapes. Replace:-echo "\n### RUNNING WASM STORE ###" +printf '\n### RUNNING WASM STORE ###\n'Same pattern for the other banner blocks to keep output readable across shells.
Also applies to: 45-51, 71-85, 110-116
workshops/erc20-mts/scripts/wasm-tx-increment.sh (2)
10-11:USER_INJ_ADDRESSis computed but never usedDrop it or use it; keeping unused vars clutters the script and misleads readers.
-USER_INJ_ADDRESS=$(injectived keys show $USER --keyring-backend=test -a) +# USER_INJ_ADDRESS is available if you need to reference the sender later🧰 Tools
🪛 Shellcheck (0.10.0)
[warning] 10-10: USER_INJ_ADDRESS appears unused. Verify use (or export if used externally).
(SC2034)
13-17: Parameter validation: also verify ERC20 denom formatThe usage string suggests
<value>erc20:<contract_address>. A simple regex guard prevents malformed denominations:if ! printf '%s\n' "$1" | grep -Eq '^[0-9]+erc20:[a-z0-9]{40,}$'; then echo "❌ Invalid denom format: $1" exit 1 fiworkshops/erc20-mts/wasm/counter_msg.rs (2)
37-49: Minor typo in documentation comment
Weather an ack is a success→Whether an ack is a success.- /// Weather an ack is a success of failure according to the transfer spec + /// Whether an ack is a success or failure according to the transfer spec
18-23: Consider omittingAddrfrom query parameters for public stateRequiring the caller to supply an
AddrforGetCount/GetTotalFundsis unusual when the contract can derive the address fromenv.message.sender(for execute) or simply maintain a global counter. If this is intentional (e.g., querying another user’s balance) ignore, otherwise rethink the API to keep queries minimal.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (3)
.DS_Storeis excluded by!**/.DS_Storelib/.DS_Storeis excluded by!**/.DS_Storeworkshops/erc20-mts/wasm/counter.wasmis excluded by!**/*.wasm
📒 Files selected for processing (23)
.gitignore(1 hunks)workshops/erc20-mts/.local.env(1 hunks)workshops/erc20-mts/Makefile(1 hunks)workshops/erc20-mts/README.md(1 hunks)workshops/erc20-mts/scripts/cli-address.sh(1 hunks)workshops/erc20-mts/scripts/cli-balances-user1.sh(1 hunks)workshops/erc20-mts/scripts/cli-balances-user2.sh(1 hunks)workshops/erc20-mts/scripts/cli-denom.sh(1 hunks)workshops/erc20-mts/scripts/cli-keys.sh(1 hunks)workshops/erc20-mts/scripts/cli-q.sh(1 hunks)workshops/erc20-mts/scripts/cli-tx.sh(1 hunks)workshops/erc20-mts/scripts/deploy-erc20-mintburn.sh(1 hunks)workshops/erc20-mts/scripts/deploy-erc20.sh(1 hunks)workshops/erc20-mts/scripts/deploy-wasm.sh(1 hunks)workshops/erc20-mts/scripts/erc20-balance-user1.sh(1 hunks)workshops/erc20-mts/scripts/erc20-balance-user2.sh(1 hunks)workshops/erc20-mts/scripts/foundry-util.sh(1 hunks)workshops/erc20-mts/scripts/import-cast-key.sh(1 hunks)workshops/erc20-mts/scripts/import-cli-key.sh(1 hunks)workshops/erc20-mts/scripts/mint-erc20.sh(1 hunks)workshops/erc20-mts/scripts/wasm-query-counter.sh(1 hunks)workshops/erc20-mts/scripts/wasm-tx-increment.sh(1 hunks)workshops/erc20-mts/wasm/counter_msg.rs(1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (3)
workshops/erc20-mts/scripts/mint-erc20.sh (1)
workshops/erc20-mts/scripts/foundry-util.sh (1)
check_foundry_result(6-20)
workshops/erc20-mts/scripts/deploy-erc20-mintburn.sh (1)
workshops/erc20-mts/scripts/foundry-util.sh (1)
check_foundry_result(6-20)
workshops/erc20-mts/scripts/deploy-erc20.sh (1)
workshops/erc20-mts/scripts/foundry-util.sh (1)
check_foundry_result(6-20)
🪛 Shellcheck (0.10.0)
workshops/erc20-mts/scripts/cli-q.sh
[warning] 3-3: In POSIX sh, 'source' in place of '.' is undefined.
(SC3046)
[warning] 5-5: Use "$@" (with quotes) to prevent whitespace problems.
(SC2048)
workshops/erc20-mts/scripts/cli-tx.sh
[warning] 3-3: In POSIX sh, 'source' in place of '.' is undefined.
(SC3046)
[warning] 5-5: Use "$@" (with quotes) to prevent whitespace problems.
(SC2048)
workshops/erc20-mts/scripts/import-cast-key.sh
[warning] 3-3: In POSIX sh, 'source' in place of '.' is undefined.
(SC3046)
workshops/erc20-mts/scripts/cli-balances-user1.sh
[warning] 3-3: In POSIX sh, 'source' in place of '.' is undefined.
(SC3046)
workshops/erc20-mts/scripts/foundry-util.sh
[warning] 3-3: In POSIX sh, 'source' in place of '.' is undefined.
(SC3046)
workshops/erc20-mts/scripts/cli-keys.sh
[warning] 3-3: In POSIX sh, 'source' in place of '.' is undefined.
(SC3046)
[warning] 5-5: Use "$@" (with quotes) to prevent whitespace problems.
(SC2048)
workshops/erc20-mts/scripts/cli-balances-user2.sh
[warning] 3-3: In POSIX sh, 'source' in place of '.' is undefined.
(SC3046)
workshops/erc20-mts/scripts/wasm-query-counter.sh
[warning] 3-3: In POSIX sh, 'source' in place of '.' is undefined.
(SC3046)
workshops/erc20-mts/scripts/mint-erc20.sh
[warning] 5-5: In POSIX sh, 'source' in place of '.' is undefined.
(SC3046)
[warning] 6-6: In POSIX sh, 'source' in place of '.' is undefined.
(SC3046)
workshops/erc20-mts/scripts/cli-denom.sh
[warning] 5-5: In POSIX sh, 'source' in place of '.' is undefined.
(SC3046)
[warning] 15-15: In POSIX sh, [[ ]] is undefined.
(SC3010)
workshops/erc20-mts/scripts/erc20-balance-user2.sh
[warning] 3-3: In POSIX sh, 'source' in place of '.' is undefined.
(SC3046)
workshops/erc20-mts/scripts/deploy-erc20-mintburn.sh
[warning] 3-3: In POSIX sh, 'source' in place of '.' is undefined.
(SC3046)
[warning] 4-4: In POSIX sh, 'source' in place of '.' is undefined.
(SC3046)
workshops/erc20-mts/scripts/import-cli-key.sh
[warning] 3-3: In POSIX sh, 'source' in place of '.' is undefined.
(SC3046)
workshops/erc20-mts/scripts/erc20-balance-user1.sh
[warning] 3-3: In POSIX sh, 'source' in place of '.' is undefined.
(SC3046)
workshops/erc20-mts/scripts/deploy-erc20.sh
[warning] 3-3: In POSIX sh, 'source' in place of '.' is undefined.
(SC3046)
[warning] 4-4: In POSIX sh, 'source' in place of '.' is undefined.
(SC3046)
workshops/erc20-mts/scripts/deploy-wasm.sh
[warning] 3-3: In POSIX sh, 'source' in place of '.' is undefined.
(SC3046)
workshops/erc20-mts/scripts/wasm-tx-increment.sh
[warning] 3-3: In POSIX sh, 'source' in place of '.' is undefined.
(SC3046)
[warning] 10-10: USER_INJ_ADDRESS appears unused. Verify use (or export if used externally).
(SC2034)
🪛 checkmake (0.2.2)
workshops/erc20-mts/Makefile
[warning] 25-25: Missing required phony target "clean"
(minphony)
[warning] 25-25: Missing required phony target "test"
(minphony)
🔇 Additional comments (8)
.gitignore (1)
15-15: Ignore macOS system filesAdding
.DS_Storeprevents committing macOS finder metadata and keeps the repository clean.workshops/erc20-mts/README.md (1)
1-9: README is clear and well-structured.
The workshop overview and prerequisites are concise, and the documentation links are accurate.workshops/erc20-mts/scripts/deploy-erc20-mintburn.sh (1)
44-48: Deployment result parsing looks solid
You correctly validate the Foundry result and extractdeployedTo. No further changes needed here.workshops/erc20-mts/scripts/import-cli-key.sh (1)
18-27: Addressing key parsing and output
Retrieving and displaying both Injective and Ethereum addresses is clear and correct.workshops/erc20-mts/scripts/mint-erc20.sh (1)
61-64: Mint logic and result validation are correct
The call tocheck_foundry_resultand final status message align with expectations.workshops/erc20-mts/scripts/deploy-erc20.sh (1)
38-42: Deployment result parsing is correct
Extracting and printingdeployedToviajqis implemented properly.workshops/erc20-mts/scripts/erc20-balance-user1.sh (1)
23-26: Balance check logic is sound
You validateERC20_ADDRESSand correctly decode the ABI-encoded balance.workshops/erc20-mts/scripts/wasm-tx-increment.sh (1)
75-83: Guard against missingcodefield in tx result
jq -r '.code'returnsnullif the field is absent; comparison with"0"then fails. Safer:TX_CODE=$(echo "$tx_result" | jq -r '.code // 0')
| USER=user1 | ||
| USER_MNEMONIC="copper push brief egg scan entry inform record adjust fossil boss egg comic alien upon aspect dry avoid interest fury window hint race symptom" | ||
| USER_PWD=12345678 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sensitive information committed
This file includes a full wallet mnemonic and password in version control. Remove .local.env from the repo, add it to .gitignore, and provide a template such as .local.env.example instead.
🤖 Prompt for AI Agents
In workshops/erc20-mts/.local.env around lines 13 to 15, sensitive information
like the wallet mnemonic and password is committed to version control. Remove
the .local.env file from the repository, add .local.env to the .gitignore file
to prevent future commits, and create a .local.env.example template file with
placeholder values for users to fill in their own credentials.
| @@ -0,0 +1,20 @@ | |||
| #!/bin/sh | |||
|
|
|||
| source .local.env | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Use POSIX-compatible sourcing
In POSIX sh, source is undefined. Replace it with dot sourcing:
- source .local.env
+ . .local.env🧰 Tools
🪛 Shellcheck (0.10.0)
[warning] 3-3: In POSIX sh, 'source' in place of '.' is undefined.
(SC3046)
🤖 Prompt for AI Agents
In workshops/erc20-mts/scripts/foundry-util.sh at line 3, replace the use of
'source .local.env' with '. .local.env' to ensure POSIX-compatible sourcing, as
'source' is not defined in POSIX sh.
| @@ -0,0 +1,7 @@ | |||
| #!/bin/sh | |||
|
|
|||
| source .local.env | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Use POSIX-compatible sourcing
Replace source .local.env with:
- source .local.env
+ . .local.env📝 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.
| source .local.env | |
| . .local.env |
🧰 Tools
🪛 Shellcheck (0.10.0)
[warning] 3-3: In POSIX sh, 'source' in place of '.' is undefined.
(SC3046)
🤖 Prompt for AI Agents
In workshops/erc20-mts/scripts/cli-q.sh at line 3, replace the non-POSIX `source
.local.env` command with the POSIX-compatible `. .local.env` syntax to ensure
the script runs correctly in all POSIX-compliant shells.
|
|
||
| source .local.env | ||
|
|
||
| injectived q $* --node $INJ_URL |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Quote positional parameters
Use "$@" instead of $* to preserve arguments with spaces, and quote $INJ_URL:
- injectived q $* --node $INJ_URL
+ injectived q "$@" --node "$INJ_URL"📝 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.
| injectived q $* --node $INJ_URL | |
| injectived q "$@" --node "$INJ_URL" |
🧰 Tools
🪛 Shellcheck (0.10.0)
[warning] 5-5: Use "$@" (with quotes) to prevent whitespace problems.
(SC2048)
🤖 Prompt for AI Agents
In workshops/erc20-mts/scripts/cli-q.sh at line 5, replace the unquoted
positional parameters $* with "$@" to correctly preserve arguments containing
spaces, and also quote the $INJ_URL variable to handle any spaces or special
characters safely. This ensures all arguments are passed accurately to the
injectived command.
| @@ -0,0 +1,7 @@ | |||
| #!/bin/sh | |||
|
|
|||
| source .local.env | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Use POSIX-compatible sourcing
Replace source .local.env with:
- source .local.env
+ . .local.env🧰 Tools
🪛 Shellcheck (0.10.0)
[warning] 3-3: In POSIX sh, 'source' in place of '.' is undefined.
(SC3046)
🤖 Prompt for AI Agents
In workshops/erc20-mts/scripts/cli-tx.sh at line 3, replace the
non-POSIX-compliant `source .local.env` command with the POSIX-compatible `.
.local.env` syntax to ensure compatibility across different shell environments.
| store_res=$tx_result | ||
|
|
||
| # Extract code ID from transaction response | ||
| CODE_ID=$(echo $store_res | jq -r '.events[] | select(.type=="store_code") | .attributes[] | select(.key=="code_id") | .value') | ||
| echo "Contract Code ID: $CODE_ID" | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Gracefully abort when CODE_ID / CONTRACT_ADDRESS is empty
If jq fails to locate the attribute the variables become empty strings, leading to confusing downstream errors. Add a guard:
if [ -z "$CODE_ID" ]; then
echo "❌ Unable to extract code_id from transaction."
exit 1
fiRepeat for CONTRACT_ADDRESS.
Also applies to: 130-133
🤖 Prompt for AI Agents
In workshops/erc20-mts/scripts/deploy-wasm.sh around lines 63 to 68, add a check
after extracting CODE_ID to verify if it is empty. If CODE_ID is empty, print an
error message and exit the script with a non-zero status to prevent confusing
downstream errors. Similarly, add the same kind of check for CONTRACT_ADDRESS
around lines 130 to 133 to ensure the script aborts gracefully if
CONTRACT_ADDRESS is not found.
| #!/bin/sh | ||
|
|
||
| source .local.env | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Shebang & sourcing are inconsistent – decide on Bash or strict POSIX
source is a Bash-ism but the shebang points to /bin/sh. Either:
-#!/bin/sh
-source .local.env
+#!/usr/bin/env bash
+set -euo pipefail
+. .local.env # POSIX-portable “source”or make the script strictly POSIX (. instead of source, avoid Bash-only flags).
Fail-fast flags (set -euo pipefail) are strongly recommended.
📝 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.
| #!/bin/sh | |
| source .local.env | |
| #!/usr/bin/env bash | |
| set -euo pipefail | |
| . .local.env # POSIX-portable “source” | |
| # …rest of your script… |
🧰 Tools
🪛 Shellcheck (0.10.0)
[warning] 3-3: In POSIX sh, 'source' in place of '.' is undefined.
(SC3046)
🤖 Prompt for AI Agents
In workshops/erc20-mts/scripts/deploy-wasm.sh at lines 1 to 4, the script uses a
shebang for /bin/sh but employs the Bash-specific 'source' command. To fix this,
either change the shebang to /bin/bash to match the use of 'source', or replace
'source' with the POSIX-compliant '.' command and avoid any Bash-only features.
Additionally, add fail-fast flags like 'set -euo pipefail' near the top of the
script to improve robustness.
| USER_ADDRESS=$(injectived keys show $USER --keyring-backend=test -a) | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Quote variable expansions to avoid word-splitting & injection
Examples:
-USER_ADDRESS=$(injectived keys show $USER --keyring-backend=test -a)
+USER_ADDRESS=$(injectived keys show "$USER" --keyring-backend=test -a)Apply the same to every $USER, $CHAIN_ID, $INJ_URL, $CODE_ID, $TXHASH, etc.
📝 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.
| USER_ADDRESS=$(injectived keys show $USER --keyring-backend=test -a) | |
| USER_ADDRESS=$(injectived keys show "$USER" --keyring-backend=test -a) |
🤖 Prompt for AI Agents
In workshops/erc20-mts/scripts/deploy-wasm.sh around lines 8 to 9, variable
expansions like $USER should be quoted to prevent word-splitting and potential
injection issues. Update all instances of variables such as $USER, $CHAIN_ID,
$INJ_URL, $CODE_ID, $TXHASH, etc., by enclosing them in double quotes, for
example, change $USER to "$USER".
| echo "\n### EXECUTING INCREMENT ###" | ||
| echo injectived tx wasm execute $WASM_CONTRACT '{"increment":{}}' \ | ||
| --amount $1 \ | ||
| --from $USER \ | ||
| --chain-id $CHAIN_ID \ | ||
| --node $INJ_URL \ | ||
| --gas-prices 500000000inj \ | ||
| --gas auto \ | ||
| --gas-adjustment 1.3 \ | ||
| --broadcast-mode sync \ | ||
| --keyring-backend test \ | ||
| --output json \ | ||
| -y | ||
| echo "########################\n" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Quote variable expansions & use printf instead of echo "\n"
Same concerns as in deploy-wasm.sh. Quote $WASM_CONTRACT, $USER, $CHAIN_ID, $INJ_URL, and $1. Replace banner echoes with printf.
Also applies to: 36-46, 58-63
🤖 Prompt for AI Agents
In workshops/erc20-mts/scripts/wasm-tx-increment.sh around lines 21 to 34, the
variable expansions like $WASM_CONTRACT, $USER, $CHAIN_ID, $INJ_URL, and $1 are
unquoted which can cause word splitting or globbing issues. Quote all these
variables to ensure safe expansion. Also, replace echo statements that print
newlines (e.g., echo "\n### EXECUTING INCREMENT ###") with printf commands for
consistent and portable newline handling. Apply the same quoting and printf
replacements to lines 36-46 and 58-63 as well.
| #!/bin/sh | ||
|
|
||
| source .local.env | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Same Bash / POSIX mismatch & missing fail-fast flags
See previous script: pick Bash or pure POSIX. If Bash is fine:
-#!/bin/sh
-source .local.env
+#!/usr/bin/env bash
+set -euo pipefail
+. .local.env📝 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.
| #!/bin/sh | |
| source .local.env | |
| #!/usr/bin/env bash | |
| set -euo pipefail | |
| . .local.env |
🧰 Tools
🪛 Shellcheck (0.10.0)
[warning] 3-3: In POSIX sh, 'source' in place of '.' is undefined.
(SC3046)
🤖 Prompt for AI Agents
In workshops/erc20-mts/scripts/wasm-tx-increment.sh at lines 1 to 4, the script
uses a shebang for sh but may include Bash-specific syntax, causing POSIX
compatibility issues. Decide whether to use Bash or pure POSIX shell. If Bash is
acceptable, change the shebang to #!/bin/bash and add fail-fast flags like set
-euo pipefail at the start to ensure the script exits on errors and undefined
variables.
Moved and distilled the changes from #11
Summary by CodeRabbit
New Features
Documentation
Chores
.gitignoreto exclude.DS_Storefiles.