-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: example contracts fee:
stake
→ untrn
- Loading branch information
Showing
10 changed files
with
343 additions
and
184 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
#![warn(clippy::unwrap_used, clippy::expect_used)] | ||
|
||
pub mod contract; | ||
pub mod msg; | ||
pub mod state; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
use schemars::JsonSchema; | ||
use serde::{Deserialize, Serialize}; | ||
|
||
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)] | ||
pub struct InstantiateMsg {} | ||
|
||
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)] | ||
#[serde(rename_all = "snake_case")] | ||
pub enum ExecuteMsg { | ||
Send { | ||
channel: String, | ||
to: String, | ||
denom: String, | ||
amount: u128, | ||
timeout_height: Option<u64>, | ||
}, | ||
} | ||
|
||
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)] | ||
pub struct MigrateMsg {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,72 @@ | ||
CONTRACT=../artifacts/ibc_transfer.wasm | ||
CHAINID=test-1 | ||
NEUTRON_DIR=${NEUTRON_DIR:-../../neutron} | ||
HOME=${NEUTRON_DIR}/data/test-1/ | ||
HOME2=${NEUTRON_DIR}/data/test-2/ | ||
KEY=demowallet1 | ||
ADMIN=neutron1m9l358xunhhwds0568za49mzhvuxx9ux8xafx2 | ||
BIN=neutrond | ||
|
||
RES=$(${BIN} tx wasm store ${CONTRACT} --from ${KEY} --gas 50000000 --chain-id ${CHAINID} --broadcast-mode=block --gas-prices 0.0025stake -y --output json --keyring-backend test --home ${HOME} --node tcp://127.0.0.1:16657) | ||
TRANSFER_CONTRACT_CODE_ID=$(echo $RES | jq -r '.logs[0].events[1].attributes[0].value') | ||
echo $RES | ||
echo $TRANSFER_CONTRACT_CODE_ID | ||
|
||
INIT_TRANSFER_CONTRACT='{}' | ||
|
||
RES=$(${BIN} tx wasm instantiate $TRANSFER_CONTRACT_CODE_ID "$INIT_TRANSFER_CONTRACT" --from ${KEY} --admin ${ADMIN} -y --chain-id ${CHAINID} --output json --broadcast-mode=block --label "init" --keyring-backend test --gas-prices 0.0025stake --home ${HOME} --node tcp://127.0.0.1:16657) | ||
echo $RES | ||
TRANSFER_CONTRACT_ADDRESS=$(echo $RES | jq -r '.logs[0].events[0].attributes[0].value') | ||
echo $TRANSFER_CONTRACT_ADDRESS | ||
|
||
${BIN} tx bank send demowallet1 ${TRANSFER_CONTRACT_ADDRESS} 10000stake --chain-id ${CHAINID} --home ${HOME} --node tcp://localhost:16657 --keyring-backend test -y --gas-prices 0.0025stake --broadcast-mode=block | ||
|
||
|
||
echo "Tranfer coins from test-1 to test-2" | ||
RES=$(${BIN} tx wasm execute $TRANSFER_CONTRACT_ADDRESS \ | ||
'{"send":{"to":"cosmos17dtl0mjt3t77kpuhg2edqzjpszulwhgzuj9ljs","amount":"1000", "denom": "stake", "channel": "channel-0"}}' \ | ||
--from ${KEY} -y \ | ||
--chain-id ${CHAINID} \ | ||
--output json \ | ||
--broadcast-mode=block \ | ||
--gas-prices 0.0025stake \ | ||
--gas 1000000 \ | ||
--keyring-backend test \ | ||
--home ${HOME} \ | ||
--node tcp://127.0.0.1:16657) | ||
echo $RES | jq | ||
#!/usr/bin/env bash | ||
|
||
# http://redsymbol.net/articles/unofficial-bash-strict-mode/ | ||
set -euo pipefail | ||
IFS=$'\n\t' | ||
|
||
CONTRACT_PATH="../artifacts/ibc_transfer.wasm" | ||
CHAIN_ID="test-1" | ||
NEUTRON_DIR="${NEUTRON_DIR:-../../neutron}" | ||
HOME="$NEUTRON_DIR/data/test-1/" | ||
KEY="demowallet1" | ||
ADMIN="neutron1m9l358xunhhwds0568za49mzhvuxx9ux8xafx2" | ||
BIN="neutrond" | ||
GAIA_BIN="gaiad" | ||
NODE="tcp://127.0.0.1:16657" | ||
|
||
code_id="$("$BIN" tx wasm store "$CONTRACT_PATH" \ | ||
--from "$KEY" -y --chain-id "$CHAIN_ID" \ | ||
--gas 50000000 --gas-prices 0.0025untrn \ | ||
--broadcast-mode=block --keyring-backend=test \ | ||
--output json --home "$HOME" --node "$NODE" \ | ||
| jq -r '.logs[0].events[] | select(.type == "store_code").attributes[] | select(.key == "code_id").value')" | ||
echo "Code ID: $code_id" | ||
|
||
contract_address="$("$BIN" tx wasm instantiate "$code_id" '{}' \ | ||
--from ${KEY} --admin ${ADMIN} -y --chain-id "$CHAIN_ID" \ | ||
--output json --broadcast-mode=block --label "init" \ | ||
--keyring-backend=test --gas-prices 0.0025untrn \ | ||
--home "$HOME" --node "$NODE" \ | ||
| jq -r '.logs[0].events[] | select(.type == "instantiate").attributes[] | select(.key == "_contract_address").value')" | ||
echo "Contract address: $contract_address" | ||
|
||
tx_result="$("$BIN" tx bank send demowallet1 "$contract_address" 20000untrn \ | ||
-y --chain-id "$CHAIN_ID" --home "$HOME" --node "$NODE" \ | ||
--keyring-backend=test --gas-prices 0.0025untrn --output json \ | ||
--broadcast-mode=block)" | ||
code="$(echo "$tx_result" | jq '.code')" | ||
if [[ ! "$code" -eq 0 ]]; then | ||
echo "Failed to send money to contract: $(echo "$tx_result" | jq '.raw_log')" && exit 1 | ||
fi | ||
echo "Sent money to contract to pay fees" | ||
|
||
msg='{"send":{ | ||
"to": "cosmos17dtl0mjt3t77kpuhg2edqzjpszulwhgzuj9ljs", | ||
"amount": "1000", | ||
"denom": "untrn", | ||
"channel": "channel-0" | ||
}}' | ||
tx_result="$("$BIN" tx wasm execute "$contract_address" "$msg" \ | ||
--from ${KEY} -y --chain-id ${CHAIN_ID} --output json \ | ||
--broadcast-mode=block --gas-prices 0.0025untrn --gas 1000000 \ | ||
--keyring-backend test --home "$HOME" --node "$NODE")" | ||
code="$(echo "$tx_result" | jq '.code')" | ||
if [[ ! "$code" -eq 0 ]]; then | ||
echo "Failed to execute contract: $(echo "$tx_result" | jq '.raw_log')" && exit 1 | ||
fi | ||
|
||
echo "Waiting 20 seconds for IBC transfer to complete…" | ||
# shellcheck disable=SC2034 | ||
for i in $(seq 20); do | ||
sleep 1 | ||
echo -n . | ||
done | ||
echo " done" | ||
|
||
echo | ||
echo "cosmos17dtl0mjt3t77kpuhg2edqzjpszulwhgzuj9ljs should have 3000untrn now:" | ||
"$GAIA_BIN" query bank balances "cosmos17dtl0mjt3t77kpuhg2edqzjpszulwhgzuj9ljs" \ | ||
--node tcp://localhost:26657 --output json | jq '.balances' | ||
|
||
echo | ||
echo "If you see more than 3000untrn, you have already run this test several times before" |
Oops, something went wrong.