Skip to content

Commit

Permalink
chore(scripts): use wait-tx utility instead of shell sleep
Browse files Browse the repository at this point in the history
  • Loading branch information
Thomasvdam committed Jan 20, 2025
1 parent 390e6a0 commit ab4da1b
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 20 deletions.
1 change: 0 additions & 1 deletion app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,6 @@ import (
"github.com/sedaprotocol/seda-chain/app/keepers"
appparams "github.com/sedaprotocol/seda-chain/app/params"
"github.com/sedaprotocol/seda-chain/app/utils"

// Used in cosmos-sdk when registering the route for swagger docs.
_ "github.com/sedaprotocol/seda-chain/client/docs/statik"
"github.com/sedaprotocol/seda-chain/cmd/sedad/gentx"
Expand Down
3 changes: 1 addition & 2 deletions cmd/sedad/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ import (
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/config"
"github.com/cosmos/cosmos-sdk/client/debug"
"github.com/cosmos/cosmos-sdk/client/flags"
sdkflags "github.com/cosmos/cosmos-sdk/client/flags"
"github.com/cosmos/cosmos-sdk/client/keys"
"github.com/cosmos/cosmos-sdk/client/rpc"
Expand Down Expand Up @@ -81,7 +80,7 @@ func NewRootCmd() *cobra.Command {
0,
simtestutil.AppOptionsMap{
// taken from simtestutil.NewAppOptionsWithFlagHome(tempDir())
flags.FlagHome: tempDir(),
sdkflags.FlagHome: tempDir(),
utils.FlagAllowUnencryptedSedaKeys: "true",
}, tempDir(),
baseapp.SetChainID("tempchainid"),
Expand Down
48 changes: 32 additions & 16 deletions scripts/deploy_contracts.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,25 @@ RPC_URL=http://127.0.0.1:26657
BIN=$(git rev-parse --show-toplevel)/build/sedad
CONTRACT_WASM=$(git rev-parse --show-toplevel)/testutil/testwasms/seda_contract.wasm
VOTING_PERIOD=30 # seconds
DEV_ACCOUNT=$($BIN keys show satoshi --keyring-backend test -a) # for sending wasm-storage txs
DEV_ACCOUNT=$($BIN keys show thomas --keyring-backend test -a) # for sending wasm-storage txs
VOTE_ACCOUNT=$($BIN keys show satoshi --keyring-backend test -a) # for sending vote txs


echo "Deploying core contract"

OUTPUT="$($BIN tx wasm store $CONTRACT_WASM --node $RPC_URL --from $DEV_ACCOUNT --keyring-backend test --gas-prices 100000000000aseda --gas auto --gas-adjustment 1.3 -y --output json --chain-id $CHAIN_ID)"
TXHASH=$(echo $OUTPUT | jq -r '.txhash')

sleep 10
OUTPUT="$(
$BIN tx wasm store $CONTRACT_WASM \
--node $RPC_URL \
--chain-id $CHAIN_ID \
--from $DEV_ACCOUNT \
--keyring-backend test \
--gas-prices 100000000000aseda \
--gas auto \
--gas-adjustment 1.3 \
-y --output json \
| $BIN query wait-tx --node $RPC_URL --output json\
)"

OUTPUT="$($BIN query tx $TXHASH --node $RPC_URL --output json)"
CORE_CODE_ID=$(echo "$OUTPUT" | jq -r '.events[] | select(.type=="store_code") | .attributes[] | select(.key=="code_id") | .value')

echo "Instantiating core contract on code id $CORE_CODE_ID"
Expand All @@ -29,19 +36,28 @@ OUTPUT=$($BIN tx wasm-storage submit-proposal instantiate-core-contract $CORE_CO
--admin $DEV_ACCOUNT \
--label core$CORE_CODE_ID \
--title 'Core Contract' --summary 'Instantiates and registers core contract' --deposit 10000000aseda \
--from $DEV_ACCOUNT --keyring-backend test \
--node $RPC_URL \
--gas-prices 100000000000aseda --gas auto --gas-adjustment 1.5 \
--output json --chain-id $CHAIN_ID -y)
TXHASH=$(echo "$OUTPUT" | jq -r '.txhash')
--chain-id $CHAIN_ID \
--from $DEV_ACCOUNT \
--keyring-backend test \
--gas-prices 100000000000aseda \
--gas auto \
--gas-adjustment 1.5 \
-y --output json \
| $BIN query wait-tx --node $RPC_URL --output json\
)

sleep 10

PROPOSAL_ID="$($BIN query tx $TXHASH --output json | jq '.events[] | select(.type == "submit_proposal") | .attributes[] | select(.key == "proposal_id") | .value' | sed 's/^"\(.*\)"$/\1/')"
PROPOSAL_ID="$(echo "$OUTPUT" | jq '.events[] | select(.type == "submit_proposal") | .attributes[] | select(.key == "proposal_id") | .value' | sed 's/^"\(.*\)"$/\1/')"
$BIN tx gov vote $PROPOSAL_ID yes \
--from $VOTE_ACCOUNT --keyring-backend test \
--gas-prices 100000000000aseda --gas auto --gas-adjustment 1.6 \
--chain-id $CHAIN_ID -y
--node $RPC_URL \
--chain-id $CHAIN_ID \
--from $VOTE_ACCOUNT \
--keyring-backend test \
--gas-prices 100000000000aseda \
--gas auto \
--gas-adjustment 1.6 \
-y \
| $BIN query wait-tx --node $RPC_URL --output json

sleep $VOTING_PERIOD

Expand Down
1 change: 0 additions & 1 deletion x/pubkey/client/cli/keyfile.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,6 @@ func getSEDAKeysEncryptionKey(cmd *cobra.Command, encryptionKey string) (string,
}

if noEncryptionFlag {
cmd.Println("not encrypting the generated SEDA key file")
return "", nil
}

Expand Down
3 changes: 3 additions & 0 deletions x/pubkey/client/cli/tx_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,9 @@ func (s *CLITestSuite) SetupSuite() {
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync),
fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin("seda", sdkmath.NewInt(10))).String()),
fmt.Sprintf("--%s=%s", flags.FlagFrom, account.String()),
// Generating a new encryption key or manually setting the encryption key
// requires user interaction, so we disable it here for testing
fmt.Sprintf("--%s", cli.FlagNoEncryption),
}
}

Expand Down

0 comments on commit ab4da1b

Please sign in to comment.