1313 with :
1414 profile : minimal
1515 toolchain : stable
16- - name : Build
16+ - name : Build
1717 run : |
1818 cargo build --verbose
1919 working-directory : .
@@ -29,15 +29,15 @@ jobs:
2929 with :
3030 profile : minimal
3131 toolchain : stable
32- - name : test
32+ - name : test
3333 run : |
3434 cargo test --verbose
3535 working-directory : .
3636 devnet :
3737 # needs: test
3838 name : deploy on devnet
3939 runs-on : ubuntu-latest
40- if : github.ref == 'refs/heads/main'
40+ if : github.ref == 'refs/heads/main'
4141 environment : devnet
4242 steps :
4343 - uses : actions/checkout@v4
@@ -53,55 +53,52 @@ jobs:
5353 toolchain : stable
5454 - name : Compile
5555 run : |
56- getNewVersionBYContract(){
56+ getNewVersionBYContract(){
5757
58- local contractAddress=$1
58+ local contractAddress=$1
5959
60- ELYSD=./elysd
61- local json=$($ELYSD q --output json --node "${{vars.NODE}}" wasm contract-state smart "$contractAddress" '{ "version": {} }')
62- local VERSION=$(echo $json | jq -r ".data.version")
63-
64- # Extract the major, minor, and patch versions
65- local version_parts=(${VERSION//./ })
66- local major=${version_parts[0]}
67- local minor=${version_parts[1]}
68- local patch=${version_parts[2]}
60+ ELYSD=./elysd
61+ local json=$($ELYSD q --output json --node "${{vars.NODE}}" wasm contract-state smart "$contractAddress" '{ "version": {} }')
62+ local VERSION=$(echo $json | jq -r ".data.version")
63+
64+ # Extract the major, minor, and patch versions
65+ local version_parts=(${VERSION//./ })
66+ local major=${version_parts[0]}
67+ local minor=${version_parts[1]}
68+ local patch=${version_parts[2]}
6969
70- # Increment the minor version
71- local minor=$((minor + 1))
70+ # Increment the minor version
71+ local minor=$((minor + 1))
7272
73- # Update the version string
74- VERSION="$major.$minor.$patch"
73+ # Update the version string
74+ VERSION="$major.$minor.$patch"
7575
76- echo $VERSION
77- }
76+ echo $VERSION
77+ }
7878
79- accountHistoryContractVersion=$(getNewVersionBYContract ${{vars.AH_CONTRACT_ADDRESS}})
80- tradeShieldContractVersion=$(getNewVersionBYContract ${{vars.TS_CONTRACT_ADDRESS}})
81- financialSnapshotContractVersion=$(getNewVersionBYContract ${{vars.FS_CONTRACT_ADDRESS}})
79+ tradeShieldContractVersion=$(getNewVersionBYContract ${{vars.TS_CONTRACT_ADDRESS}})
80+ financialSnapshotContractVersion=$(getNewVersionBYContract ${{vars.FS_CONTRACT_ADDRESS}})
8281
83- echo "new accountHistoryContractVersion: $accountHistoryContractVersion"
84- echo "new tradeShieldContractVersion: $tradeShieldContractVersion"
85- echo "new financialSnapshotContractVersion: $financialSnapshotContractVersion"
82+ echo "new tradeShieldContractVersion: $tradeShieldContractVersion"
83+ echo "new financialSnapshotContractVersion: $financialSnapshotContractVersion"
8684
87- sed -i "s/^version = .*/version = \"$accountHistoryContractVersion\"/" contracts/account-history-contract/Cargo.toml
88- sed -i "s/^version = .*/version = \"$tradeShieldContractVersion\"/" contracts/trade-shield-contract/Cargo.toml
89- sed -i "s/^version = .*/version = \"$financialSnapshotContractVersion\"/" contracts/financial-snapshot-contract/Cargo.toml
90- cargo update
91-
92- docker run --rm -v "$(pwd)":/code \
93- --mount type=volume,source="$(basename "$(pwd)")_cache",target=/target \
94- --mount type=volume,source=registry_cache,target=/usr/local/cargo/registry \
95- cosmwasm/workspace-optimizer:0.14.0
85+ sed -i "s/^version = .*/version = \"$tradeShieldContractVersion\"/" contracts/trade-shield-contract/Cargo.toml
86+ sed -i "s/^version = .*/version = \"$financialSnapshotContractVersion\"/" contracts/financial-snapshot-contract/Cargo.toml
87+ cargo update
88+
89+ docker run --rm -v "$(pwd)":/code \
90+ --mount type=volume,source="$(basename "$(pwd)")_cache",target=/target \
91+ --mount type=volume,source=registry_cache,target=/usr/local/cargo/registry \
92+ cosmwasm/workspace-optimizer:0.14.0
9693 - name : Deploy
97- run : |
94+ run : |
9895 # helper functions
9996 extract_txhash() { awk -F 'txhash: ' '/txhash:/{print $2; exit}'; }
10097 extract_code_id() { awk -F 'key: code_id|value: ' '/key: code_id/ { getline; gsub(/"/, "", $2); print $2; exit }'; }
10198 extract_contract_address() { awk -F 'key: _contract_address|value: ' '/key: _contract_address/ { getline; gsub(/"/, "", $2); print $2; exit }'; }
10299 extract_account_number() { awk -F 'account_number: ' '/account_number:/ { gsub(/"/, "", $2); print $2 + 0; exit; }'; }
103100 extract_sequence() { awk -F 'sequence: ' '/sequence:/ { gsub(/"/, "", $2); print $2 + 0; exit; }'; }
104-
101+
105102 ELYSD=./elysd
106103
107104 wait_for_tx() {
@@ -127,7 +124,7 @@ jobs:
127124
128125 # contract addresses enviroment variables
129126
130-
127+
131128 # set elysd config
132129 $ELYSD config keyring-backend test
133130 $ELYSD config node $NODE
@@ -156,11 +153,9 @@ jobs:
156153 ##contracts
157154 FS_CONTRACT_ADDRESS=${{vars.FS_CONTRACT_ADDRESS}}
158155 TS_CONTRACT_ADDRESS=${{vars.TS_CONTRACT_ADDRESS}}
159- AH_CONTRACT_ADDRESS=${{vars.AH_CONTRACT_ADDRESS}}
160156
161157 printf "FS_CONTRACT_ADDRESS=%s\n" "$FS_CONTRACT_ADDRESS"
162158 printf "TS_CONTRACT_ADDRESS=%s\n" "$TS_CONTRACT_ADDRESS"
163- printf "AH_CONTRACT_ADDRESS=%s\n" "$AH_CONTRACT_ADDRESS"
164159
165160 # store and init/migrate financial snapshot contract
166161 txhash=$(echo "${{ secrets.PASSPHRASE_MALLORCA }}" | $ELYSD tx wasm store $OPTIONS --sequence $(($sequence + 1)) artifacts/financial_snapshot_contract.wasm | extract_txhash)
@@ -169,7 +164,7 @@ jobs:
169164 wait_for_tx $txhash
170165 codeid=$($ELYSD q tx $txhash --node $NODE | extract_code_id)
171166 echo "fs code id: $codeid"
172-
167+
173168 if [ "$FS_CONTRACT_ADDRESS" != "empty" ]; then
174169 txhash=$( echo "${{ secrets.PASSPHRASE_MALLORCA }}" | $ELYSD tx wasm migrate $OPTIONS --sequence $(($sequence + 2)) $FS_CONTRACT_ADDRESS $codeid '{}' | extract_txhash)
175170 echo "fs migrate txhash: $txhash"
@@ -192,58 +187,21 @@ jobs:
192187 echo "ts code id: $codeid"
193188
194189 if [ "$TS_CONTRACT_ADDRESS" != "empty" ]; then
195- txhash=$(echo "${{ secrets.PASSPHRASE_MALLORCA }}" | $ELYSD tx wasm migrate $OPTIONS --sequence $(($sequence + 4)) $TS_CONTRACT_ADDRESS $codeid '{
196- " account_history_address " : " '" $AH_CONTRACT_ADDRESS"'"
197- }' | extract_txhash)
190+ txhash=$(echo "${{ secrets.PASSPHRASE_MALLORCA }}" | $ELYSD tx wasm migrate $OPTIONS --sequence $(($sequence + 4)) $TS_CONTRACT_ADDRESS $codeid '{}' | extract_txhash)
198191 echo "ts migrate txhash: $txhash"
199192 else
200193 # set localnet AH deterministic address as param
201- txhash=$(echo "${{ secrets.PASSPHRASE_MALLORCA }}" | $ELYSD tx wasm init $OPTIONS --sequence $(($sequence + 4)) --label "ts" --admin $NAME $codeid '{
202- " account_history_address " : " elys17p9rzwnnfxcjp32un9ug7yhhzgtkhvl9jfksztgw5uh69wac2pgs98tvuy"
203- }' | extract_txhash)
194+ txhash=$(echo "${{ secrets.PASSPHRASE_MALLORCA }}" | $ELYSD tx wasm init $OPTIONS --sequence $(($sequence + 4)) --label "ts" --admin $NAME $codeid '{}' | extract_txhash)
204195 echo "ts init txhash: $txhash"
205196 fi
206197 exit_if_tx_is_empty $txhash
207198 wait_for_tx $txhash
208199 export ts_contract_address=$($ELYSD q tx $txhash --node $NODE | extract_contract_address)
209200 echo "ts_contract_address: $ts_contract_address"
210201
211- # store and init/migrate account history contract
212- txhash=$(echo "${{ secrets.PASSPHRASE_MALLORCA }}" | $ELYSD tx wasm store artifacts/account_history_contract.wasm $OPTIONS --sequence $(($sequence + 5)) | extract_txhash)
213-
214- echo "ah store txhash : $txhash"
215- exit_if_tx_is_empty $txhash
216- wait_for_tx $txhash
217-
218- codeid=$($ELYSD q tx $txhash --node $NODE | extract_code_id)
219- echo "ah code id : $codeid"
220-
221- if [ "$AH_CONTRACT_ADDRESS" != "empty" ]; then
222- txhash=$(echo "${{ secrets.PASSPHRASE_MALLORCA }}" | $ELYSD tx wasm migrate $OPTIONS --sequence $(($sequence + 6)) $AH_CONTRACT_ADDRESS $codeid '{
223- " trade_shield_address " : " '" $TS_CONTRACT_ADDRESS"'",
224- " limit " : 1
225- }' | extract_txhash)
226- echo "ah migrate txhash : $txhash"
227- else
228- txhash=$(echo "${{ secrets.PASSPHRASE_MALLORCA }}" | $ELYSD tx wasm init $OPTIONS --sequence $(($sequence + 6)) --label "ah" --admin $NAME $codeid '{
229- " limit " : 300,
230- " expiration " : {
231- " at_time " : " 604800000000000"
232- },
233- " trade_shield_address " : " '" $ts_contract_address"'"
234- }' | extract_txhash)
235- echo "ah init txhash : $txhash"
236- fi
237-
238- exit_if_tx_is_empty $txhash
239- wait_for_tx $txhash
240- ah_contract_address=$($ELYSD q tx $txhash --node $NODE | extract_contract_address)
241- echo "ah_contract_address : $ah_contract_address"
242-
243202 # print environment variables to set
244203 printf "\nset those environment variables to use the contracts:\n\n"
245204 printf "export NODE=%s\n" "$NODE"
246205 printf "export NAME=%s\n" "$NAME"
247206 printf "export FS_CONTRACT_ADDRESS=%s\n" "$fs_contract_address"
248207 printf "export TS_CONTRACT_ADDRESS=%s\n" "$ts_contract_address"
249- printf "export AH_CONTRACT_ADDRESS=%s\n" "$ah_contract_address"
0 commit comments