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

Commit 8f6f8ca

Browse files
fix: remove remaining deps to ah data (#439)
1 parent 5f6da20 commit 8f6f8ca

File tree

70 files changed

+48
-617
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

70 files changed

+48
-617
lines changed

.github/workflows/pipeline.yml

Lines changed: 38 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
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"
Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
use cosmwasm_schema::cw_serde;
22

33
#[cw_serde]
4-
pub struct InstantiateMsg {
5-
pub account_history_address: Option<String>,
6-
}
4+
pub struct InstantiateMsg {}
Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
use cosmwasm_schema::cw_serde;
22

33
#[cw_serde]
4-
pub struct MigrateMsg {
5-
pub account_history_address: Option<String>,
6-
}
4+
pub struct MigrateMsg {}

bindings/src/trade_shield/states/account_history_address.rs

Lines changed: 0 additions & 3 deletions
This file was deleted.

bindings/src/trade_shield/states/mod.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
1-
mod account_history_address;
21
mod limit_order;
32
mod number_of_order;
43
mod params;
54
mod perpetual_order;
65
mod reply_info;
76
mod spot_order;
87

9-
pub use account_history_address::ACCOUNT_HISTORY_ADDRESS;
108
pub use limit_order::LIMIT_PROCESS_ORDER;
119
pub use number_of_order::{NUMBER_OF_EXECUTED_ORDER, NUMBER_OF_PENDING_ORDER};
1210
pub use params::{

contracts/trade-shield-contract/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,10 @@ Optionally, use `-v` to display the node logs.
7070
Run the following command to store the contract on the chain:
7171

7272
```sh
73-
elysd tx wasm store path/to/account_history_contract.wasm --from=treasury --keyring-backend=test --chain-id=elystestnet-1 --gas=auto --gas-adjustment=1.3 -y -b=sync
73+
elysd tx wasm store path/to/trade_shield_contract.wasm --from=treasury --keyring-backend=test --chain-id=elystestnet-1 --gas=auto --gas-adjustment=1.3 -y -b=sync
7474
```
7575

76-
Ensure to replace `path/to/account_history_contract.wasm` with the actual path to the downloaded contract.
76+
Ensure to replace `path/to/trade_shield_contract.wasm` with the actual path to the downloaded contract.
7777

7878
7. Instantiate Contract
7979
Execute the command below to instantiate the contract on the Elys network:

contracts/trade-shield-contract/src/entry_point/instantiate.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ pub fn instantiate(
1717
set_contract_version(deps.storage, CONTRACT_NAME, CONTRACT_VERSION)?;
1818
MAX_REPLY_ID.save(deps.storage, &0)?;
1919
SPOT_ORDER_MAX_ID.save(deps.storage, &0)?;
20-
ACCOUNT_HISTORY_ADDRESS.save(deps.storage, &msg.account_history_address)?;
2120

2221
let admin = "elys16xffmfa6k45j340cx5zyp66lqvuw62a0neaa7w".to_string();
2322
PARAMS_ADMIN.save(deps.storage, &admin)?;

contracts/trade-shield-contract/src/entry_point/migrate.rs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,8 @@ use cw2::set_contract_version;
66
use elys_bindings::trade_shield::{
77
msg::MigrateMsg,
88
states::{
9-
ACCOUNT_HISTORY_ADDRESS, LEVERAGE_ENABLED, LIMIT_PROCESS_ORDER, MARKET_ORDER_ENABLED,
10-
PARAMS_ADMIN, PERPETUAL_ENABLED, PROCESS_ORDERS_ENABLED, REWARD_ENABLED, STAKE_ENABLED,
11-
SWAP_ENABLED,
9+
LEVERAGE_ENABLED, LIMIT_PROCESS_ORDER, MARKET_ORDER_ENABLED, PARAMS_ADMIN,
10+
PERPETUAL_ENABLED, PROCESS_ORDERS_ENABLED, REWARD_ENABLED, STAKE_ENABLED, SWAP_ENABLED,
1211
},
1312
};
1413
use semver::Version;
@@ -19,10 +18,6 @@ pub fn migrate(
1918
_env: Env,
2019
msg: MigrateMsg,
2120
) -> StdResult<Response<ElysMsg>> {
22-
if msg.account_history_address.is_some() {
23-
ACCOUNT_HISTORY_ADDRESS.save(deps.storage, &msg.account_history_address)?;
24-
}
25-
2621
let admin = "elys16xffmfa6k45j340cx5zyp66lqvuw62a0neaa7w".to_string();
2722
PARAMS_ADMIN.save(deps.storage, &admin)?;
2823

contracts/trade-shield-contract/src/tests/cancel_perpetual_order/not_found.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ fn not_found() {
77

88
// Create a mock message to instantiate the contract with no initial orders.
99
let instantiate_msg = InstantiateMockMsg {
10-
account_history_address: None,
1110
spot_orders: vec![],
1211
perpetual_orders: vec![],
1312
};

contracts/trade-shield-contract/src/tests/cancel_perpetual_order/succesful_cancel_an_order.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ fn succesful_cancel_an_order() {
1010

1111
// Create a mock message to instantiate the contract with no initial orders.
1212
let instantiate_msg = InstantiateMockMsg {
13-
account_history_address: None,
1413
spot_orders: vec![],
1514
perpetual_orders: vec![PerpetualOrder::new_open(
1615
"user",

0 commit comments

Comments
 (0)