Skip to content
This repository has been archived by the owner on Nov 15, 2024. It is now read-only.

Commit

Permalink
Merge branch 'main' into feat/add-missing-pool-info
Browse files Browse the repository at this point in the history
  • Loading branch information
cryptokage1996 authored Jul 19, 2024
2 parents ea481e3 + baa74a0 commit f432270
Show file tree
Hide file tree
Showing 221 changed files with 111 additions and 8,326 deletions.
137 changes: 34 additions & 103 deletions .github/workflows/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
with:
profile: minimal
toolchain: stable
- name: Build
- name: Build
run: |
cargo build --verbose
working-directory: .
Expand All @@ -29,15 +29,15 @@ jobs:
with:
profile: minimal
toolchain: stable
- name: test
- name: test
run: |
cargo test --verbose
working-directory: .
devnet:
#needs: test
name: deploy on devnet
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main'
if: github.ref == 'refs/heads/main'
environment: devnet
steps:
- uses: actions/checkout@v4
Expand All @@ -53,55 +53,49 @@ jobs:
toolchain: stable
- name: Compile
run: |
getNewVersionBYContract(){
getNewVersionBYContract(){
local contractAddress=$1
local contractAddress=$1
ELYSD=./elysd
local json=$($ELYSD q --output json --node "${{vars.NODE}}" wasm contract-state smart "$contractAddress" '{ "version": {} }')
local VERSION=$(echo $json | jq -r ".data.version")
# Extract the major, minor, and patch versions
local version_parts=(${VERSION//./ })
local major=${version_parts[0]}
local minor=${version_parts[1]}
local patch=${version_parts[2]}
ELYSD=./elysd
local json=$($ELYSD q --output json --node "${{vars.NODE}}" wasm contract-state smart "$contractAddress" '{ "version": {} }')
local VERSION=$(echo $json | jq -r ".data.version")
# Extract the major, minor, and patch versions
local version_parts=(${VERSION//./ })
local major=${version_parts[0]}
local minor=${version_parts[1]}
local patch=${version_parts[2]}
# Increment the minor version
local minor=$((minor + 1))
# Increment the minor version
local minor=$((minor + 1))
# Update the version string
VERSION="$major.$minor.$patch"
# Update the version string
VERSION="$major.$minor.$patch"
echo $VERSION
}
echo $VERSION
}
tradeShieldContractVersion=$(getNewVersionBYContract ${{vars.TS_CONTRACT_ADDRESS}})
accountHistoryContractVersion=$(getNewVersionBYContract ${{vars.AH_CONTRACT_ADDRESS}})
tradeShieldContractVersion=$(getNewVersionBYContract ${{vars.TS_CONTRACT_ADDRESS}})
financialSnapshotContractVersion=$(getNewVersionBYContract ${{vars.FS_CONTRACT_ADDRESS}})
echo "new tradeShieldContractVersion: $tradeShieldContractVersion"
echo "new accountHistoryContractVersion: $accountHistoryContractVersion"
echo "new tradeShieldContractVersion: $tradeShieldContractVersion"
echo "new financialSnapshotContractVersion: $financialSnapshotContractVersion"
sed -i "s/^version = .*/version = \"$tradeShieldContractVersion\"/" contracts/trade-shield-contract/Cargo.toml
cargo update
sed -i "s/^version = .*/version = \"$accountHistoryContractVersion\"/" contracts/account-history-contract/Cargo.toml
sed -i "s/^version = .*/version = \"$tradeShieldContractVersion\"/" contracts/trade-shield-contract/Cargo.toml
sed -i "s/^version = .*/version = \"$financialSnapshotContractVersion\"/" contracts/financial-snapshot-contract/Cargo.toml
cargo update
docker run --rm -v "$(pwd)":/code \
--mount type=volume,source="$(basename "$(pwd)")_cache",target=/target \
--mount type=volume,source=registry_cache,target=/usr/local/cargo/registry \
cosmwasm/workspace-optimizer:0.14.0
docker run --rm -v "$(pwd)":/code \
--mount type=volume,source="$(basename "$(pwd)")_cache",target=/target \
--mount type=volume,source=registry_cache,target=/usr/local/cargo/registry \
cosmwasm/workspace-optimizer:0.14.0
- name: Deploy
run: |
run: |
# helper functions
extract_txhash() { awk -F 'txhash: ' '/txhash:/{print $2; exit}'; }
extract_code_id() { awk -F 'key: code_id|value: ' '/key: code_id/ { getline; gsub(/"/, "", $2); print $2; exit }'; }
extract_contract_address() { awk -F 'key: _contract_address|value: ' '/key: _contract_address/ { getline; gsub(/"/, "", $2); print $2; exit }'; }
extract_account_number() { awk -F 'account_number: ' '/account_number:/ { gsub(/"/, "", $2); print $2 + 0; exit; }'; }
extract_sequence() { awk -F 'sequence: ' '/sequence:/ { gsub(/"/, "", $2); print $2 + 0; exit; }'; }
ELYSD=./elysd
wait_for_tx() {
Expand All @@ -127,7 +121,7 @@ jobs:
# contract addresses enviroment variables
# set elysd config
$ELYSD config keyring-backend test
$ELYSD config node $NODE
Expand All @@ -154,34 +148,9 @@ jobs:
OPTIONS="--from $NAME --node $NODE --chain-id ${{vars.CHAIN_ID}} --keyring-backend=test --gas auto --gas-adjustment 1.3 --fees 300000uelys -y --account-number $account_number -b async --log_level trace --trace"
##contracts
FS_CONTRACT_ADDRESS=${{vars.FS_CONTRACT_ADDRESS}}
TS_CONTRACT_ADDRESS=${{vars.TS_CONTRACT_ADDRESS}}
AH_CONTRACT_ADDRESS=${{vars.AH_CONTRACT_ADDRESS}}
printf "FS_CONTRACT_ADDRESS=%s\n" "$FS_CONTRACT_ADDRESS"
printf "TS_CONTRACT_ADDRESS=%s\n" "$TS_CONTRACT_ADDRESS"
printf "AH_CONTRACT_ADDRESS=%s\n" "$AH_CONTRACT_ADDRESS"

# store and init/migrate financial snapshot contract
txhash=$(echo "${{ secrets.PASSPHRASE_MALLORCA }}" | $ELYSD tx wasm store $OPTIONS --sequence $(($sequence + 1)) artifacts/financial_snapshot_contract.wasm | extract_txhash)
echo "fs store txhash: $txhash"
exit_if_tx_is_empty $txhash
wait_for_tx $txhash
codeid=$($ELYSD q tx $txhash --node $NODE | extract_code_id)
echo "fs code id: $codeid"

if [ "$FS_CONTRACT_ADDRESS" != "empty" ]; then
txhash=$( echo "${{ secrets.PASSPHRASE_MALLORCA }}" | $ELYSD tx wasm migrate $OPTIONS --sequence $(($sequence + 2)) $FS_CONTRACT_ADDRESS $codeid '{}' | extract_txhash)
echo "fs migrate txhash: $txhash"
else
txhash=$( echo "${{ secrets.PASSPHRASE_MALLORCA }}" | $ELYSD tx wasm init $OPTIONS --sequence $(($sequence + 2)) --label "fs" --admin $NAME $codeid '{}' | extract_txhash)
echo "fs init txhash: $txhash"
fi

exit_if_tx_is_empty $txhash
wait_for_tx $txhash
export fs_contract_address=$($ELYSD q tx $txhash --node $NODE | extract_contract_address)
echo "fs_contract_address: $fs_contract_address"
# store and init/migrate trade shield contract
txhash=$(echo "${{ secrets.PASSPHRASE_MALLORCA }}" | $ELYSD tx wasm store $OPTIONS --sequence $(($sequence + 3)) artifacts/trade_shield_contract.wasm | extract_txhash)
Expand All @@ -192,58 +161,20 @@ jobs:
echo "ts code id: $codeid"
if [ "$TS_CONTRACT_ADDRESS" != "empty" ]; then
txhash=$(echo "${{ secrets.PASSPHRASE_MALLORCA }}" | $ELYSD tx wasm migrate $OPTIONS --sequence $(($sequence + 4)) $TS_CONTRACT_ADDRESS $codeid '{
"account_history_address": "'"$AH_CONTRACT_ADDRESS"'"
}' | extract_txhash)
txhash=$(echo "${{ secrets.PASSPHRASE_MALLORCA }}" | $ELYSD tx wasm migrate $OPTIONS --sequence $(($sequence + 4)) $TS_CONTRACT_ADDRESS $codeid '{}' | extract_txhash)
echo "ts migrate txhash: $txhash"
else
# set localnet AH deterministic address as param
txhash=$(echo "${{ secrets.PASSPHRASE_MALLORCA }}" | $ELYSD tx wasm init $OPTIONS --sequence $(($sequence + 4)) --label "ts" --admin $NAME $codeid '{
"account_history_address": "elys17p9rzwnnfxcjp32un9ug7yhhzgtkhvl9jfksztgw5uh69wac2pgs98tvuy"
}' | extract_txhash)
txhash=$(echo "${{ secrets.PASSPHRASE_MALLORCA }}" | $ELYSD tx wasm init $OPTIONS --sequence $(($sequence + 4)) --label "ts" --admin $NAME $codeid '{}' | extract_txhash)
echo "ts init txhash: $txhash"
fi
exit_if_tx_is_empty $txhash
wait_for_tx $txhash
export ts_contract_address=$($ELYSD q tx $txhash --node $NODE | extract_contract_address)
echo "ts_contract_address: $ts_contract_address"
# store and init/migrate account history contract
txhash=$(echo "${{ secrets.PASSPHRASE_MALLORCA }}" | $ELYSD tx wasm store artifacts/account_history_contract.wasm $OPTIONS --sequence $(($sequence + 5)) | extract_txhash)

echo "ah store txhash: $txhash"
exit_if_tx_is_empty $txhash
wait_for_tx $txhash

codeid=$($ELYSD q tx $txhash --node $NODE | extract_code_id)
echo "ah code id: $codeid"

if [ "$AH_CONTRACT_ADDRESS" != "empty" ]; then
txhash=$(echo "${{ secrets.PASSPHRASE_MALLORCA }}" | $ELYSD tx wasm migrate $OPTIONS --sequence $(($sequence + 6)) $AH_CONTRACT_ADDRESS $codeid '{
"trade_shield_address": "'"$TS_CONTRACT_ADDRESS"'",
"limit": 1
}' | extract_txhash)
echo "ah migrate txhash: $txhash"
else
txhash=$(echo "${{ secrets.PASSPHRASE_MALLORCA }}" | $ELYSD tx wasm init $OPTIONS --sequence $(($sequence + 6)) --label "ah" --admin $NAME $codeid '{
"limit": 300,
"expiration": {
"at_time": "604800000000000"
},
"trade_shield_address": "'"$ts_contract_address"'"
}' | extract_txhash)
echo "ah init txhash: $txhash"
fi

exit_if_tx_is_empty $txhash
wait_for_tx $txhash
ah_contract_address=$($ELYSD q tx $txhash --node $NODE | extract_contract_address)
echo "ah_contract_address: $ah_contract_address"

# print environment variables to set
printf "\nset those environment variables to use the contracts:\n\n"
printf "export NODE=%s\n" "$NODE"
printf "export NAME=%s\n" "$NAME"
printf "export FS_CONTRACT_ADDRESS=%s\n" "$fs_contract_address"
printf "export TS_CONTRACT_ADDRESS=%s\n" "$ts_contract_address"
printf "export AH_CONTRACT_ADDRESS=%s\n" "$ah_contract_address"
68 changes: 0 additions & 68 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 2 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,32 +28,12 @@ This guide provides instructions on how to spin up a new localnet using the Elys

3. **Download the Latest TestNet Snapshot**

Get the latest TestNet snapshot available for the Elys network.

**Main branch**

Use the following command to download the latest TestNet snapshot that uses the changes from the `main` branch:
To get the latest TestNet snapshot available for the Elys network, use the following command to download the latest TestNet snapshot that uses the changes from the `main` branch:

```bash
rm -rf ~/.elys && curl -o - -L https://snapshots.elys.network/elys-snapshot-main.tar.lz4 | lz4 -c -d - | tar -x -C ~/
```

**Devnet branch**

Use the following command to download the latest TestNet snapshot that uses the changes from the `devnet` branch:

```bash
rm -rf ~/.elys && curl -o - -L https://snapshots.elys.network/elys-snapshot-devnet.tar.lz4 | lz4 -c -d - | tar -x -C ~/
```

**Develop branch**

Use the following command to download the latest TestNet snapshot that uses the changes from the `develop` branch:

```bash
rm -rf ~/.elys && curl -o - -L https://snapshots.elys.network/elys-snapshot-develop.tar.lz4 | lz4 -c -d - | tar -x -C ~/
```

4. **Spin Up the Localnet**

Use the command below to start the localnet:
Expand Down Expand Up @@ -95,12 +75,10 @@ After running `deploy.sh`, set the provided environment variables:
```bash
export NODE=tcp://localhost:26657
export NAME=validator
export FS_CONTRACT_ADDRESS=<FS_CONTRACT_ADDRESS>
export TS_CONTRACT_ADDRESS=<TS_CONTRACT_ADDRESS>
export AH_CONTRACT_ADDRESS=<AH_CONTRACT_ADDRESS>
```

Replace `<FS_CONTRACT_ADDRESS>`, `<TS_CONTRACT_ADDRESS>`, and `<AH_CONTRACT_ADDRESS>` with the actual contract addresses provided by the deployment script.
Replace `<TS_CONTRACT_ADDRESS>` with the actual contract addresses provided by the deployment script.

## Additional Configuration

Expand Down
2 changes: 0 additions & 2 deletions bindings/src/account_history/mod.rs

This file was deleted.

18 changes: 0 additions & 18 deletions bindings/src/account_history/msg/execute.rs

This file was deleted.

9 changes: 0 additions & 9 deletions bindings/src/account_history/msg/instantiate.rs

This file was deleted.

Loading

0 comments on commit f432270

Please sign in to comment.