-
Notifications
You must be signed in to change notification settings - Fork 4
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?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,3 +11,5 @@ out/ | |
|
|
||
| # Dotenv file | ||
| .env | ||
|
|
||
| .DS_Store | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| ################################################################################ | ||
| # Localhost setup | ||
| ################################################################################ | ||
|
|
||
| # Network | ||
| ETH_URL=http://localhost:8545 | ||
| INJ_URL=http://localhost:26657 | ||
| GRPC_URL=localhost:9900 | ||
| CHAIN_ID=injective-1 | ||
|
|
||
|
|
||
| # User | ||
| 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 | ||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,25 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| all: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| add-keys: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ./scripts/import-cli-key.sh | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ./scripts/import-cast-key.sh | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| deploy-erc20: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ./scripts/deploy-erc20.sh | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| deploy-erc20-mintburn: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ./scripts/deploy-erc20-mintburn.sh | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| mint-erc20: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ./scripts/mint-erc20.sh | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| balance1-cast: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ./scripts/erc20-balance-user1.sh | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| balance1-cli: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ./scripts/cli-balances-user1.sh | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| deploy-wasm: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ./scripts/deploy-wasm.sh | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| .PHONY: all add-keys deploy-erc20 balance1-cast balance1-cli deploy-wasm | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+1
to
+25
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Ensure all targets are declared phony. Apply this diff: -.PHONY: all add-keys deploy-erc20 balance1-cast balance1-cli deploy-wasm
+.PHONY: all add-keys deploy-erc20 deploy-erc20-mintburn mint-erc20 balance1-cast balance1-cli deploy-wasm📝 Committable suggestion
Suggested change
🧰 Tools🪛 checkmake (0.2.2)[warning] 25-25: Missing required phony target "clean" (minphony) [warning] 25-25: Missing required phony target "test" (minphony) 🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| ## ERC20 MTS Workshop | ||
|
|
||
| This workshop shows MTS (Multi-VM Token Standard) and how to use it to create a token that is representable in multiple VMs. | ||
|
|
||
| ### Prerequisites | ||
|
|
||
| - [Injective CLI](https://docs.injective.network/docs/getting-started/cli) | ||
| - [Foundry](https://book.getfoundry.sh/getting-started/installation) | ||
|
|
||
| ### Running the workshop | ||
|
|
||
| 1. Create a new ERC20 token | ||
| 2. Mint tokens to a user | ||
| 3. Check balances via CLI | ||
| 4. Check balances via Foundry cast | ||
| 5. Interact with WASM contract | ||
| 6. Query WASM contract state | ||
|
|
||
| ### Conclusion | ||
|
|
||
| We've created an ERC20 tokens that is represented at the same address in both the EVM and WASM VMs, also native state. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| #!/bin/sh | ||
|
|
||
| echo "Getting Injective address and converting to Ethereum address:" | ||
|
|
||
|
Comment on lines
+1
to
+4
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Add usage check for command-line arguments. if [ $# -lt 1 ]; then
echo "Usage: $0 <key-name>" >&2
exit 1
fi🤖 Prompt for AI Agents |
||
| # Get the address from keys show command | ||
| INJ_ADDRESS=$(injectived keys show $1 --keyring-backend=test -a) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Quote variable expansions in command invocations. -INJ_ADDRESS=$(injectived keys show $1 --keyring-backend=test -a)
+INJ_ADDRESS=$(injectived keys show "$1" --keyring-backend=test -a)
-ETH_ADDRESS=0x$(injectived keys parse $INJ_ADDRESS --output json | jq -r '.bytes')
+ETH_ADDRESS=0x$(injectived keys parse "$INJ_ADDRESS" --output json | jq -r '.bytes')Also applies to: 12-12 🤖 Prompt for AI Agents |
||
|
|
||
| # Display the Injective address | ||
| echo "\t* Injective address: $INJ_ADDRESS" | ||
|
|
||
| # Parse the Injective address to get the Ethereum address | ||
| ETH_ADDRESS=0x$(injectived keys parse $INJ_ADDRESS --output json | jq -r '.bytes') | ||
|
|
||
| # Display the Ethereum address | ||
| echo "\t* Ethereum address: $ETH_ADDRESS" | ||
|
|
||
| echo "" | ||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,15 @@ | ||||||
| #!/bin/sh | ||||||
|
|
||||||
| source .local.env | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Use POSIX-compatible syntax for sourcing environment variables. - source .local.env
+ . .local.env📝 Committable suggestion
Suggested change
🧰 Tools🪛 Shellcheck (0.10.0)[warning] 3-3: In POSIX sh, 'source' in place of '.' is undefined. (SC3046) 🤖 Prompt for AI Agents |
||||||
|
|
||||||
| echo "Checking balance of user1..." | ||||||
|
|
||||||
| USER_INJ_ADDRESS=$(injectived keys show $USER --keyring-backend=test -a) | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Quote variable expansions in commands. - USER_INJ_ADDRESS=$(injectived keys show $USER --keyring-backend=test -a)
+ USER_INJ_ADDRESS=$(injectived keys show "$USER" --keyring-backend=test -a)🤖 Prompt for AI Agents |
||||||
|
|
||||||
| echo "\n### RUNNING ###" | ||||||
| echo injectived q bank balances $USER_INJ_ADDRESS --chain-id $CHAIN_ID --node $INJ_URL | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Add keyring-backend and quote variables when querying balances. - echo injectived q bank balances $USER_INJ_ADDRESS --chain-id $CHAIN_ID --node $INJ_URL
+ echo injectived q bank balances "$USER_INJ_ADDRESS" --chain-id "$CHAIN_ID" --node "$INJ_URL" --keyring-backend=test
- injectived q bank balances $USER_INJ_ADDRESS --chain-id $CHAIN_ID --node $INJ_URL
+ injectived q bank balances "$USER_INJ_ADDRESS" --chain-id "$CHAIN_ID" --node "$INJ_URL" --keyring-backend=testAlso applies to: 13-13 🤖 Prompt for AI Agents |
||||||
| echo "###############\n" | ||||||
|
|
||||||
| injectived q bank balances $USER_INJ_ADDRESS --chain-id $CHAIN_ID --node $INJ_URL | ||||||
|
|
||||||
| echo "" | ||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| #!/bin/sh | ||
|
|
||
| source .local.env | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Use POSIX-compatible syntax for sourcing the environment file. - 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 |
||
|
|
||
| echo "Checking balance of user2..." | ||
|
|
||
| if [ -z "$USER_INJ_ADDRESS" ]; then | ||
| echo "⚠️ Error: USER_INJ_ADDRESS env variable is not set" | ||
| exit 1 | ||
| fi | ||
|
|
||
| echo "\n### RUNNING ###" | ||
| echo injectived q bank balances $1 --chain-id $CHAIN_ID --node $INJ_URL --keyring-backend=test | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use the environment variable - echo injectived q bank balances $1 --chain-id $CHAIN_ID --node $INJ_URL --keyring-backend=test
+ echo injectived q bank balances "$USER_INJ_ADDRESS" --chain-id "$CHAIN_ID" --node "$INJ_URL" --keyring-backend=test
- injectived q bank balances $1 --chain-id $CHAIN_ID --node $INJ_URL --keyring-backend=test
+ injectived q bank balances "$USER_INJ_ADDRESS" --chain-id "$CHAIN_ID" --node "$INJ_URL" --keyring-backend=testEnsure Also applies to: 16-16 🤖 Prompt for AI Agents |
||
| echo "###############\n" | ||
|
|
||
| injectived q bank balances $1 --chain-id $CHAIN_ID --node $INJ_URL --keyring-backend=test | ||
|
|
||
| echo "" | ||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,26 @@ | ||||||||||||||||||||||
| #!/bin/sh | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| echo "Getting denom..." | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| source .local.env | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
|
Comment on lines
+1
to
+6
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Switch to Bash for advanced syntax. -#!/bin/sh
+#!/usr/bin/env bashor refactor to POSIX-compatible syntax. 📝 Committable suggestion
Suggested change
🧰 Tools🪛 Shellcheck (0.10.0)[warning] 5-5: In POSIX sh, 'source' in place of '.' is undefined. (SC3046) 🤖 Prompt for AI Agents |
||||||||||||||||||||||
| # Check if an argument was provided | ||||||||||||||||||||||
| if [ -z "$1" ]; then | ||||||||||||||||||||||
| echo "⚠️ Error: No denom specified" | ||||||||||||||||||||||
| echo "Usage: $0 <denom>" | ||||||||||||||||||||||
| exit 1 | ||||||||||||||||||||||
| fi | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| # Check if denom starts with erc20: prefix | ||||||||||||||||||||||
| if [[ "$1" != erc20:* ]]; then | ||||||||||||||||||||||
| echo "⚠️ Error: Denom must start with 'erc20:' prefix" | ||||||||||||||||||||||
| echo "Usage: $0 erc20:<contract_address>" | ||||||||||||||||||||||
| exit 1 | ||||||||||||||||||||||
| fi | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| echo "\n### QUERYING DENOM ###" | ||||||||||||||||||||||
| echo injectived q bank denom-metadata $1 \ | ||||||||||||||||||||||
| --node $INJ_URL | ||||||||||||||||||||||
| echo "######################\n" | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| injectived q bank denom-metadata $1 --node $INJ_URL | ||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,7 @@ | ||||||
| #!/bin/sh | ||||||
|
|
||||||
| source .local.env | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Use POSIX-compatible syntax for sourcing environment variables. - source .local.env
+ . .local.env📝 Committable suggestion
Suggested change
🧰 Tools🪛 Shellcheck (0.10.0)[warning] 3-3: In POSIX sh, 'source' in place of '.' is undefined. (SC3046) 🤖 Prompt for AI Agents |
||||||
|
|
||||||
| injectived keys $* --keyring-backend=test | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Quote positional parameters to preserve whitespace. - injectived keys $* --keyring-backend=test
+ injectived keys "$@" --keyring-backend=test📝 Committable suggestion
Suggested change
🧰 Tools🪛 Shellcheck (0.10.0)[warning] 5-5: Use "$@" (with quotes) to prevent whitespace problems. (SC2048) 🤖 Prompt for AI Agents |
||||||
|
|
||||||
| echo "" | ||||||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,7 @@ | ||||||
| #!/bin/sh | ||||||
|
|
||||||
| source .local.env | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Use POSIX-compatible sourcing Replace - source .local.env
+ . .local.env📝 Committable suggestion
Suggested change
🧰 Tools🪛 Shellcheck (0.10.0)[warning] 3-3: In POSIX sh, 'source' in place of '.' is undefined. (SC3046) 🤖 Prompt for AI Agents |
||||||
|
|
||||||
| injectived q $* --node $INJ_URL | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Quote positional parameters Use - injectived q $* --node $INJ_URL
+ injectived q "$@" --node "$INJ_URL"📝 Committable suggestion
Suggested change
🧰 Tools🪛 Shellcheck (0.10.0)[warning] 5-5: Use "$@" (with quotes) to prevent whitespace problems. (SC2048) 🤖 Prompt for AI Agents |
||||||
|
|
||||||
| echo "" | ||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| #!/bin/sh | ||
|
|
||
| source .local.env | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Use POSIX-compatible sourcing Replace - 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 |
||
|
|
||
| injectived tx $* --keyring-backend=test --chain-id $CHAIN_ID --node $INJ_URL --gas=auto --gas-adjustment=1.3 --gas-prices=10inj | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Quote positional parameters Use - injectived tx $* --keyring-backend=test --chain-id $CHAIN_ID --node $INJ_URL --gas=auto --gas-adjustment=1.3 --gas-prices=10inj
+ injectived tx "$@" --keyring-backend=test --chain-id "$CHAIN_ID" --node "$INJ_URL" --gas=auto --gas-adjustment=1.3 --gas-prices=10inj🧰 Tools🪛 Shellcheck (0.10.0)[warning] 5-5: Use "$@" (with quotes) to prevent whitespace problems. (SC2048) 🤖 Prompt for AI Agents |
||
|
|
||
| echo "" | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| #!/bin/sh | ||
|
|
||
| source .local.env | ||
| source scripts/foundry-util.sh | ||
|
Comment on lines
+3
to
+4
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Use POSIX-compatible dot for sourcing - source .local.env
- source scripts/foundry-util.sh
+ . .local.env
+ . scripts/foundry-util.sh🧰 Tools🪛 Shellcheck (0.10.0)[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) 🤖 Prompt for AI Agents |
||
|
|
||
| echo "Deploying ERC20 token..." | ||
|
|
||
| USER_INJ_ADDRESS=$(injectived keys show $USER --keyring-backend=test -a) | ||
| USER_ETH_ADDRESS=0x$(injectived keys parse $USER_INJ_ADDRESS --output json | jq -r '.bytes') | ||
|
|
||
| echo "Injective address: $USER_INJ_ADDRESS" | ||
| echo "Ethereum address (owner): $USER_ETH_ADDRESS" | ||
|
|
||
| echo "\n### RUNNING ###" | ||
| echo forge create src/MintBurnBankERC20.sol:MintBurnBankERC20 \ | ||
| -r $ETH_URL \ | ||
| --account $USER \ | ||
| --password $USER_PWD \ | ||
| --broadcast \ | ||
| --value 1000000000000000000 \ | ||
| --gas-limit 10000000 \ | ||
| --gas-price 10 \ | ||
| --legacy \ | ||
| -vvvv \ | ||
| --json \ | ||
| --constructor-args $USER_ETH_ADDRESS "TestMeme" "MEME" "18" | ||
| echo "###############\n" | ||
|
|
||
| create_res=$(forge create src/MintBurnBankERC20.sol:MintBurnBankERC20 \ | ||
| -r $ETH_URL \ | ||
| --account $USER \ | ||
| --password $USER_PWD \ | ||
| --broadcast \ | ||
| --value 1000000000000000000 \ | ||
| --gas-limit 10000000 \ | ||
| --gas-price 10 \ | ||
| --legacy \ | ||
| -vvvv \ | ||
| --json \ | ||
| --constructor-args $USER_ETH_ADDRESS "TestMeme" "MEME" "18") | ||
| if [ $? -ne 0 ]; then | ||
| exit 1 | ||
| fi | ||
| check_foundry_result "$create_res" | ||
|
|
||
| contract_eth_address=$(echo $create_res | jq -r '.deployedTo') | ||
| echo "ERC20 address: $contract_eth_address" | ||
| echo "" | ||
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,42 @@ | ||||||||||
| #!/bin/sh | ||||||||||
|
|
||||||||||
| source .local.env | ||||||||||
| source scripts/foundry-util.sh | ||||||||||
|
Comment on lines
+3
to
+4
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Use POSIX-compatible dot for sourcing - source .local.env
- source scripts/foundry-util.sh
+ . .local.env
+ . scripts/foundry-util.sh📝 Committable suggestion
Suggested change
🧰 Tools🪛 Shellcheck (0.10.0)[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) 🤖 Prompt for AI Agents |
||||||||||
|
|
||||||||||
| echo "Deploying ERC20 token..." | ||||||||||
|
|
||||||||||
| echo "\n### RUNNING ###" | ||||||||||
| echo forge create src/FixedSupplyBankERC20.sol:FixedSupplyBankERC20 \ | ||||||||||
| -r $ETH_URL \ | ||||||||||
| --account $USER \ | ||||||||||
| --password $USER_PWD \ | ||||||||||
| --broadcast \ | ||||||||||
| --gas-limit 10000000 \ | ||||||||||
| --gas-price 10 \ | ||||||||||
| --value 1000000000000000000 \ | ||||||||||
| --legacy \ | ||||||||||
| -vvvv \ | ||||||||||
| --json \ | ||||||||||
| --constructor-args "TestMeme" "MEME" "18" "1000000000000000000000000000" | ||||||||||
| echo "###############\n" | ||||||||||
|
|
||||||||||
| create_res=$(forge create src/FixedSupplyBankERC20.sol:FixedSupplyBankERC20 \ | ||||||||||
| -r $ETH_URL \ | ||||||||||
| --account $USER \ | ||||||||||
| --password $USER_PWD \ | ||||||||||
| --broadcast \ | ||||||||||
| --gas-limit 10000000 \ | ||||||||||
| --gas-price 10 \ | ||||||||||
| --value 1000000000000000000 \ | ||||||||||
| --legacy \ | ||||||||||
| -vvvv \ | ||||||||||
| --json \ | ||||||||||
| --constructor-args "TestMeme" "MEME" "18" "1000000000000000000000000000") | ||||||||||
| if [ $? -ne 0 ]; then | ||||||||||
| exit 1 | ||||||||||
| fi | ||||||||||
| check_foundry_result "$create_res" | ||||||||||
|
|
||||||||||
| contract_eth_address=$(echo $create_res | jq -r '.deployedTo') | ||||||||||
| echo "ERC20 address: $contract_eth_address" | ||||||||||
| echo "" | ||||||||||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,133 @@ | ||||||||||||||||||
| #!/bin/sh | ||||||||||||||||||
|
|
||||||||||||||||||
| source .local.env | ||||||||||||||||||
|
|
||||||||||||||||||
|
Comment on lines
+1
to
+4
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Shebang & sourcing are inconsistent – decide on Bash or strict POSIX
-#!/bin/sh
-source .local.env
+#!/usr/bin/env bash
+set -euo pipefail
+. .local.env # POSIX-portable “source”or make the script strictly POSIX ( 📝 Committable suggestion
Suggested change
🧰 Tools🪛 Shellcheck (0.10.0)[warning] 3-3: In POSIX sh, 'source' in place of '.' is undefined. (SC3046) 🤖 Prompt for AI Agents |
||||||||||||||||||
| echo "Deploying and instantiating WASM contract..." | ||||||||||||||||||
|
|
||||||||||||||||||
| # Get the user's address | ||||||||||||||||||
| USER_ADDRESS=$(injectived keys show $USER --keyring-backend=test -a) | ||||||||||||||||||
|
|
||||||||||||||||||
|
Comment on lines
+8
to
+9
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||
| echo "\n### RUNNING WASM STORE ###" | ||||||||||||||||||
| echo injectived tx wasm store wasm/counter.wasm \ | ||||||||||||||||||
| --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" | ||||||||||||||||||
|
|
||||||||||||||||||
| store_res=$(injectived tx wasm store wasm/counter.wasm \ | ||||||||||||||||||
| --from $USER \ | ||||||||||||||||||
| --chain-id $CHAIN_ID \ | ||||||||||||||||||
| --node $INJ_URL \ | ||||||||||||||||||
| --gas-prices 500000000inj \ | ||||||||||||||||||
| --gas auto \ | ||||||||||||||||||
| --gas-adjustment 1.3 \ | ||||||||||||||||||
| --broadcast-mode sync \ | ||||||||||||||||||
| --keyring-backend test \ | ||||||||||||||||||
| -y --output json) | ||||||||||||||||||
| if [ $? -ne 0 ]; then | ||||||||||||||||||
| echo "Failed to store WASM contract" | ||||||||||||||||||
| exit 1 | ||||||||||||||||||
| fi | ||||||||||||||||||
|
|
||||||||||||||||||
| # Extract txhash from store transaction response | ||||||||||||||||||
| TXHASH=$(echo $store_res | jq -r '.txhash') | ||||||||||||||||||
| echo "Transaction hash: $TXHASH" | ||||||||||||||||||
|
|
||||||||||||||||||
| sleep 3 | ||||||||||||||||||
|
|
||||||||||||||||||
| echo "\n### QUERYING TRANSACTION ###" | ||||||||||||||||||
| echo injectived q tx $TXHASH \ | ||||||||||||||||||
| --node $INJ_URL \ | ||||||||||||||||||
| --chain-id $CHAIN_ID \ | ||||||||||||||||||
| --output json | ||||||||||||||||||
| echo "########################\n" | ||||||||||||||||||
|
|
||||||||||||||||||
| # Query the transaction to get the actual results | ||||||||||||||||||
| tx_result=$(injectived q tx $TXHASH \ | ||||||||||||||||||
| --node $INJ_URL \ | ||||||||||||||||||
| --chain-id $CHAIN_ID \ | ||||||||||||||||||
| --output json) | ||||||||||||||||||
| if [ $? -ne 0 ]; then | ||||||||||||||||||
| echo "Failed to query transaction" | ||||||||||||||||||
| exit 1 | ||||||||||||||||||
| fi | ||||||||||||||||||
|
|
||||||||||||||||||
| # Update store_res with the full transaction result | ||||||||||||||||||
| 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" | ||||||||||||||||||
|
|
||||||||||||||||||
|
Comment on lines
+63
to
+68
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Gracefully abort when If if [ -z "$CODE_ID" ]; then
echo "❌ Unable to extract code_id from transaction."
exit 1
fiRepeat for Also applies to: 130-133 🤖 Prompt for AI Agents |
||||||||||||||||||
| sleep 2 | ||||||||||||||||||
|
|
||||||||||||||||||
| echo "\n### RUNNING WASM INSTANTIATE ###" | ||||||||||||||||||
| echo injectived tx wasm instantiate $CODE_ID '{"count":0}' \ | ||||||||||||||||||
| --label "counter-1.0.0" \ | ||||||||||||||||||
| --admin $USER_ADDRESS \ | ||||||||||||||||||
| --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" | ||||||||||||||||||
|
|
||||||||||||||||||
| instantiate_res=$(injectived tx wasm instantiate $CODE_ID '{"count":0}' \ | ||||||||||||||||||
| --label "counter-1.0.0" \ | ||||||||||||||||||
| --admin $USER_ADDRESS \ | ||||||||||||||||||
| --from $USER \ | ||||||||||||||||||
| --chain-id $CHAIN_ID \ | ||||||||||||||||||
| --node $INJ_URL \ | ||||||||||||||||||
| --gas-prices 500000000inj \ | ||||||||||||||||||
| --gas auto \ | ||||||||||||||||||
| --gas-adjustment 1.3 \ | ||||||||||||||||||
| --broadcast-mode sync \ | ||||||||||||||||||
| --keyring-backend test \ | ||||||||||||||||||
| -y --output json) | ||||||||||||||||||
| if [ $? -ne 0 ]; then | ||||||||||||||||||
| echo "Failed to instantiate WASM contract" | ||||||||||||||||||
| exit 1 | ||||||||||||||||||
| fi | ||||||||||||||||||
|
|
||||||||||||||||||
| # Extract txhash from instantiate transaction response | ||||||||||||||||||
| TXHASH=$(echo $instantiate_res | jq -r '.txhash') | ||||||||||||||||||
| echo "Transaction hash: $TXHASH" | ||||||||||||||||||
|
|
||||||||||||||||||
| sleep 3 | ||||||||||||||||||
|
|
||||||||||||||||||
| echo "\n### QUERYING TRANSACTION ###" | ||||||||||||||||||
| echo injectived q tx $TXHASH \ | ||||||||||||||||||
| --node $INJ_URL \ | ||||||||||||||||||
| --chain-id $CHAIN_ID \ | ||||||||||||||||||
| --output json | ||||||||||||||||||
| echo "########################\n" | ||||||||||||||||||
|
|
||||||||||||||||||
| # Query the transaction to get the actual results | ||||||||||||||||||
| tx_result=$(injectived q tx $TXHASH \ | ||||||||||||||||||
| --node $INJ_URL \ | ||||||||||||||||||
| --chain-id $CHAIN_ID \ | ||||||||||||||||||
| --output json) | ||||||||||||||||||
| if [ $? -ne 0 ]; then | ||||||||||||||||||
| echo "Failed to query transaction" | ||||||||||||||||||
| exit 1 | ||||||||||||||||||
| fi | ||||||||||||||||||
|
|
||||||||||||||||||
| # Update instantiate_res with the full transaction result | ||||||||||||||||||
| instantiate_res=$tx_result | ||||||||||||||||||
|
|
||||||||||||||||||
| # Extract contract address from instantiation response | ||||||||||||||||||
| CONTRACT_ADDRESS=$(echo $instantiate_res | jq -r '.events[] | select(.type=="instantiate") | .attributes[] | select(.key=="_contract_address") | .value') | ||||||||||||||||||
| echo "Contract address: $CONTRACT_ADDRESS" | ||||||||||||||||||
| echo "" | ||||||||||||||||||
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.envfrom the repo, add it to.gitignore, and provide a template such as.local.env.exampleinstead.🤖 Prompt for AI Agents