Deploy All SEDA Contracts #12
Workflow file for this run
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
on: | |
workflow_dispatch: | |
inputs: | |
network: | |
type: choice | |
options: | |
- devnet | |
- testnet | |
password: | |
required: true | |
name: Deploy All SEDA Contracts | |
jobs: | |
check_pass: | |
name: Check password | |
runs-on: ubuntu-latest | |
outputs: | |
is_allowed: ${{ steps.check.outputs.is_allowed }} | |
steps: | |
- id: check | |
run: | | |
password=${{ secrets.CI_PASSWORD }} | |
if [[ "${{ github.event.inputs.password }}" == "${password}" ]]; then | |
echo "is_allowed=true" >> $GITHUB_OUTPUT | |
else | |
echo "is_allowed=false" >> $GITHUB_OUTPUT | |
fi | |
deploys: | |
needs: [check_pass] | |
if: ${{ needs.check_pass.outputs.is_allowed == 'true' }} | |
name: Deploy | |
environment: | |
name: ${{ github.event.inputs.network }} | |
runs-on: ubuntu-latest | |
steps: | |
- name: Set Environment Variables | |
run: | | |
echo "Setting environment variables for network" | |
echo "NODE_URL=${{ secrets.NODE_URL }}" >> $GITHUB_ENV | |
echo "DEV_ACCOUNT=${{ secrets.DEV_ACCOUNT }}" >> $GITHUB_ENV | |
echo "KEYRING_FILE_ID=${{ secrets.KEYRING_FILE_ID }}" >> $GITHUB_ENV | |
echo "CHAIN_ID=seda-${{ github.event.inputs.network }}" >> $GITHUB_ENV | |
echo "MNEMONIC=${{ secrets.MNEMONIC }}" >> $GITHUB_ENV | |
- name: Checkout sources | |
uses: actions/checkout@v3 | |
- name: Install stable toolchain | |
uses: dtolnay/rust-toolchain@stable | |
with: | |
toolchain: 1.65.0 | |
target: wasm32-unknown-unknown | |
- name: Compile optimized WASM contracts | |
run: | | |
docker run --rm -v $GITHUB_WORKSPACE:/code \ | |
--mount type=volume,source=contract_cache,target=/code/target \ | |
--mount type=volume,source=registry_cache,target=/usr/local/cargo/registry \ | |
cosmwasm/rust-optimizer:0.14.0 | |
- name: Download sedad binary | |
uses: jaxxstorm/[email protected] | |
with: | |
extension-matching: disable | |
repo: sedaprotocol/seda-chain | |
platform: sedad | |
- name: Move sedad to current directory | |
run: | | |
cp /opt/hostedtoolcache/sedaprotocol/seda-chain/latest/linux-x64/sedad . | |
- name: Import key | |
env: | |
MNEMONIC: ${{ env.MNEMONIC }} | |
run: | | |
sudo apt-get install -y expect | |
output=$(expect -c " | |
spawn ./sedad keys add dev_account --recover --keyring-backend test --keyring-dir . | |
expect { | |
\"> Enter your bip39 mnemonic\" { | |
send \"$MNEMONIC\r\" | |
} | |
timeout { | |
send_user \"Timed out waiting for enter mnemonic prompt\r\" | |
exit 1 | |
} | |
} | |
expect eof | |
") | |
echo "$output" | |
# PROXY CONTRACT | |
- name: Store Proxy on chain | |
env: | |
DEV_ACCOUNT: ${{ env.DEV_ACCOUNT }} | |
CHAIN_ID: ${{ env.CHAIN_ID }} | |
id: store-proxy | |
run: | | |
nodeUrl=${{ env.NODE_URL }} | |
devAccount=${{ env.DEV_ACCOUNT }} | |
chainId=${{ env.CHAIN_ID }} | |
OUTPUT="$(./sedad tx wasm store ./artifacts/proxy_contract.wasm --node ${nodeUrl} --from ${devAccount} --keyring-dir . --keyring-backend test --chain-id=${chainId} --gas-prices 0.1aseda --gas auto --gas-adjustment 1.3 -y --output json)" | |
TXHASH=$(echo $OUTPUT | jq -r '.txhash') | |
echo "Store transaction is $TXHASH" | |
echo "proxy_store_tx_hash=$TXHASH" >> $GITHUB_ENV | |
- name: Wait for the transaction to be included in a block | |
run: sleep 12 | |
- name: Find the Proxy code ID | |
id: query-proxy | |
run: | | |
nodeUrl=${{ env.NODE_URL }} | |
OUTPUT="$(./sedad query tx ${{ env.proxy_store_tx_hash }} --node ${nodeUrl} --output json)" | |
CODE_ID=$(echo "$OUTPUT" | jq -r '.logs[].events[] | select(.type=="store_code") | .attributes[] | select(.key=="code_id") | .value') | |
echo "Code ID is $CODE_ID" | |
echo "proxy_code_id=$CODE_ID" >> $GITHUB_ENV | |
- name: Instantiate Proxy | |
env: | |
DEV_ACCOUNT: ${{ env.DEV_ACCOUNT }} | |
CHAIN_ID: ${{ env.CHAIN_ID }} | |
id: instantiate-proxy | |
run: | | |
nodeUrl=${{ env.NODE_URL }} | |
devAccount=${{ env.DEV_ACCOUNT }} | |
chainId=${{ env.CHAIN_ID }} | |
OUTPUT=$(./sedad tx wasm instantiate ${{ env.proxy_code_id }} '{"token":"aseda"}' --no-admin --from ${devAccount} --node ${nodeUrl} --keyring-dir . --keyring-backend test --chain-id=${chainId} --label proxy${{ env.proxy_code_id }} --gas-prices 0.1aseda --gas auto --gas-adjustment 1.3 -y --output json) | |
TXHASH=$(echo "$OUTPUT" | jq -r '.txhash') | |
echo "Instantiate transaction is $TXHASH" | |
echo "proxy_instantiate_tx_hash=$TXHASH" >> $GITHUB_ENV | |
- name: Wait for the transaction to be included in a block | |
run: sleep 12 | |
- name: Find the Proxy address | |
run: | | |
nodeUrl=${{ env.NODE_URL }} | |
OUTPUT="$(./sedad query tx ${{ env.proxy_instantiate_tx_hash }} --node ${nodeUrl} --output json)" | |
CONTRACT_ADDRESS=$(echo "$OUTPUT" | jq -r '.logs[].events[] | select(.type=="instantiate") | .attributes[] | select(.key=="_contract_address") | .value') | |
echo "Contract address is $CONTRACT_ADDRESS" | |
echo "proxy_address=$CONTRACT_ADDRESS" >> $GITHUB_ENV | |
# DATAREQUESTS CONTRACT | |
- name: Store DataRequests on chain | |
env: | |
DEV_ACCOUNT: ${{ env.DEV_ACCOUNT }} | |
CHAIN_ID: ${{ env.CHAIN_ID }} | |
id: store-dr | |
run: | | |
nodeUrl=${{ env.NODE_URL }} | |
devAccount=${{ env.DEV_ACCOUNT }} | |
chainId=${{ env.CHAIN_ID }} | |
OUTPUT="$(./sedad tx wasm store ./artifacts/data_requests.wasm --node ${nodeUrl} --from ${devAccount} --keyring-dir . --keyring-backend test --chain-id=${chainId} --gas-prices 0.1aseda --gas auto --gas-adjustment 1.3 -y --output json)" | |
TXHASH=$(echo $OUTPUT | jq -r '.txhash') | |
echo "Store transaction is $TXHASH" | |
echo "dr_store_tx_hash=$TXHASH" >> $GITHUB_ENV | |
- name: Wait for the transaction to be included in a block | |
run: sleep 12 | |
- name: Find the DataRequests code ID | |
id: query-dr | |
run: | | |
nodeUrl=${{ env.NODE_URL }} | |
OUTPUT="$(./sedad query tx ${{ env.dr_store_tx_hash }} --node ${nodeUrl} --output json)" | |
CODE_ID=$(echo "$OUTPUT" | jq -r '.logs[].events[] | select(.type=="store_code") | .attributes[] | select(.key=="code_id") | .value') | |
echo "Code ID is $CODE_ID" | |
echo "dr_code_id=$CODE_ID" >> $GITHUB_ENV | |
- name: Instantiate DataRequests | |
env: | |
DEV_ACCOUNT: ${{ env.DEV_ACCOUNT }} | |
CHAIN_ID: ${{ env.CHAIN_ID }} | |
id: instantiate-dr | |
run: | | |
nodeUrl=${{ env.NODE_URL }} | |
devAccount=${{ env.DEV_ACCOUNT }} | |
chainId=${{ env.CHAIN_ID }} | |
OUTPUT=$(./sedad tx wasm instantiate ${{ env.dr_code_id }} '{"token":"aseda", "proxy": ${{ toJSON(env.proxy_address) }} }' --no-admin --from ${devAccount} --node ${nodeUrl} --keyring-dir . --keyring-backend test --chain-id=${chainId} --label dr${{ env.dr_code_id }} --gas-prices 0.1aseda --gas auto --gas-adjustment 1.3 -y --output json) | |
TXHASH=$(echo "$OUTPUT" | jq -r '.txhash') | |
echo "Instantiate transaction is $TXHASH" | |
echo "dr_instantiate_tx_hash=$TXHASH" >> $GITHUB_ENV | |
- name: Wait for the transaction to be included in a block | |
run: sleep 12 | |
- name: Find the DataRequests address | |
run: | | |
nodeUrl=${{ env.NODE_URL }} | |
OUTPUT="$(./sedad query tx ${{ env.dr_instantiate_tx_hash }} --node ${nodeUrl} --output json)" | |
CONTRACT_ADDRESS=$(echo "$OUTPUT" | jq -r '.logs[].events[] | select(.type=="instantiate") | .attributes[] | select(.key=="_contract_address") | .value') | |
echo "Contract address is $CONTRACT_ADDRESS" | |
echo "dr_address=$CONTRACT_ADDRESS" >> $GITHUB_ENV | |
# STAKING CONTRACT | |
- name: Store Staking on chain | |
env: | |
DEV_ACCOUNT: ${{ env.DEV_ACCOUNT }} | |
CHAIN_ID: ${{ env.CHAIN_ID }} | |
id: store-staking | |
run: | | |
nodeUrl=${{ env.NODE_URL }} | |
devAccount=${{ env.DEV_ACCOUNT }} | |
chainId=${{ env.CHAIN_ID }} | |
OUTPUT="$(./sedad tx wasm store ./artifacts/staking.wasm --node ${nodeUrl} --from ${devAccount} --keyring-dir . --keyring-backend test --chain-id=${chainId} --gas-prices 0.1aseda --gas auto --gas-adjustment 1.3 -y --output json)" | |
TXHASH=$(echo $OUTPUT | jq -r '.txhash') | |
echo "Store transaction is $TXHASH" | |
echo "staking_store_tx_hash=$TXHASH" >> $GITHUB_ENV | |
- name: Wait for the transaction to be included in a block | |
run: sleep 12 | |
- name: Find the Staking code ID | |
id: query-staking | |
run: | | |
nodeUrl=${{ env.NODE_URL }} | |
OUTPUT="$(./sedad query tx ${{ env.staking_store_tx_hash }} --node ${nodeUrl} --output json)" | |
CODE_ID=$(echo "$OUTPUT" | jq -r '.logs[].events[] | select(.type=="store_code") | .attributes[] | select(.key=="code_id") | .value') | |
echo "Code ID is $CODE_ID" | |
echo "staking_code_id=$CODE_ID" >> $GITHUB_ENV | |
- name: Instantiate Staking | |
env: | |
DEV_ACCOUNT: ${{ env.DEV_ACCOUNT }} | |
CHAIN_ID: ${{ env.CHAIN_ID }} | |
id: instantiate-staking | |
run: | | |
nodeUrl=${{ env.NODE_URL }} | |
devAccount=${{ env.DEV_ACCOUNT }} | |
chainId=${{ env.CHAIN_ID }} | |
OUTPUT=$(./sedad tx wasm instantiate ${{ env.staking_code_id }} '{"token":"aseda", "proxy": ${{ toJSON(env.proxy_address) }} }' --no-admin --from ${devAccount} --node ${nodeUrl} --keyring-dir . --keyring-backend test --chain-id=${chainId} --label staking${{ env.staking_code_id }} --gas-prices 0.1aseda --gas auto --gas-adjustment 1.3 -y --output json) | |
TXHASH=$(echo "$OUTPUT" | jq -r '.txhash') | |
echo "Instantiate transaction is $TXHASH" | |
echo "staking_instantiate_tx_hash=$TXHASH" >> $GITHUB_ENV | |
- name: Wait for the transaction to be included in a block | |
run: sleep 12 | |
- name: Find the Staking address | |
run: | | |
nodeUrl=${{ env.NODE_URL }} | |
OUTPUT="$(./sedad query tx ${{ env.staking_instantiate_tx_hash }} --node ${nodeUrl} --output json)" | |
CONTRACT_ADDRESS=$(echo "$OUTPUT" | jq -r '.logs[].events[] | select(.type=="instantiate") | .attributes[] | select(.key=="_contract_address") | .value') | |
echo "Contract address is $CONTRACT_ADDRESS" | |
echo "staking_address=$CONTRACT_ADDRESS" >> $GITHUB_ENV | |
# SETUP CROSS-DEPENDENCIES | |
- name: Set DataRequests on Proxy | |
run: | | |
nodeUrl=${{ env.NODE_URL }} | |
chainId=${{ env.CHAIN_ID }} | |
OUTPUT="$(./sedad tx wasm execute ${{ env.proxy_address }} '{"set_data_requests":{"contract": ${{ toJSON(env.dr_address) }} }}' --from ${{ env.DEV_ACCOUNT }} --node ${nodeUrl} --keyring-dir . --keyring-backend test --chain-id=${chainId} --gas-prices 0.1aseda --gas auto --gas-adjustment 1.3 -y --output json)" | |
TXHASH=$(echo "$OUTPUT" | jq -r '.txhash') | |
echo "SetDataRequests transaction is $TXHASH" | |
- name: Wait for the transaction to be included in a block | |
run: sleep 12 | |
- name: Set Staking on Proxy | |
run: | | |
nodeUrl=${{ env.NODE_URL }} | |
chainId=${{ env.CHAIN_ID }} | |
OUTPUT="$(./sedad tx wasm execute ${{ env.proxy_address }} '{"set_staking":{"contract": ${{ toJSON(env.staking_address) }} }}' --from ${{ env.DEV_ACCOUNT }} --node ${nodeUrl} --keyring-dir . --keyring-backend test --chain-id=${chainId} --gas-prices 0.1aseda --gas auto --gas-adjustment 1.3 -y --output json)" | |
TXHASH=$(echo "$OUTPUT" | jq -r '.txhash') | |
echo "SetStaking transaction is $TXHASH" | |
# ECHO CONTRACT ADDRESSES | |
- name: Output contract addresses | |
run: | | |
echo "Proxy: ${{ env.proxy_address }}" | |
echo "DataRequests: ${{ env.dr_address }}" | |
echo "Staking: ${{ env.staking_address }}" |