From 2e1d9e40c27d957f68837f230edf1962b2117be7 Mon Sep 17 00:00:00 2001 From: Thunnini Date: Mon, 13 Dec 2021 17:52:49 +0900 Subject: [PATCH] Update the localnet and chain info to the osmosis v5 --- localnet/Dockerfile | 7 +++++-- src/config.ts | 2 +- src/stores/test-env.ts | 32 +++++++++++++++++++++----------- 3 files changed, 27 insertions(+), 14 deletions(-) diff --git a/localnet/Dockerfile b/localnet/Dockerfile index 4ef39a7b92..183bc89d4a 100644 --- a/localnet/Dockerfile +++ b/localnet/Dockerfile @@ -17,7 +17,7 @@ RUN git clone https://github.com/osmosis-labs/osmosis WORKDIR /osmosis # Change the commit hash if you want. -RUN git fetch && git checkout v1.0.0 +RUN git fetch && git checkout v5.0.0 # Build daemon. RUN make build @@ -31,6 +31,8 @@ RUN yq eval 'del(.app_state.epochs.epochs.[1])' ~/.osmosisd/config/genesis.json | yq eval '.app_state.epochs.epochs.[0].identifier = "hour"' - \ | yq eval '.app_state.epochs.epochs.[0].epoch_counting_started = true' - \ | yq eval '.app_state.epochs.epochs.[0].duration = "3600s"' - \ + | yq eval '.app_state.poolincentives.distr_info.total_weight = "0"' - \ + | yq eval '.app_state.poolincentives.distr_info.records = []' - \ | yq eval '.app_state.claim.module_account_balance.denom = "uosmo"' - \ | yq eval '.app_state.claim.module_account_balance.amount = "100000000"' - \ | yq eval '.app_state.claim.claim_records += {"address":"osmo1ymk637a7wljvt4w7q9lnrw95mg9sr37yatxd9h", "initial_claimable_amount": [{"denom":"uosmo","amount":"100000000"}], "action_completed": [false,false,false,false]}' - \ @@ -41,6 +43,7 @@ RUN mv ~/.osmosisd/config/genesis.tmp.json ~/.osmosisd/config/genesis.json RUN sed -i 's#tcp://127.0.0.1:26657#tcp://0.0.0.0:26657#g' ~/.osmosisd/config/config.toml RUN sed -i 's/cors_allowed_origins = \[\]/cors_allowed_origins = \["*"\]/g' ~/.osmosisd/config/config.toml RUN sed -i 's/timeout_commit = "5s"/timeout_commit = "1s"/g' ~/.osmosisd/config/config.toml +RUN sed -i 's/seeds = ".*"/seeds = ""/g' ~/.osmosisd/config/config.toml RUN sed -i 's/"stake"/"uosmo"/g' ~/.osmosisd/config/genesis.json RUN sed -i 's/pruning = "default"/pruning = "nothing"/g' ~/.osmosisd/config/app.toml RUN sed -i 's/enable = false/enable = true/g' ~/.osmosisd/config/app.toml @@ -51,7 +54,7 @@ RUN sed -i 's/enabled-unsafe-cors = false/enabled-unsafe-cors = true/g' ~/.osmos RUN sed -i 's/"distr_epoch_identifier": "week"/"distr_epoch_identifier": "hour"/g' ~/.osmosisd/config/genesis.json RUN sed -i 's/"epoch_identifier": "week"/"epoch_identifier": "hour"/g' ~/.osmosisd/config/genesis.json # 꽤 요상한 방식이지만 distr record를 등록하려면 gov를 통과시켜야 하지만 이걸 실행시키기 어렵기 때문에 일단 제네시스에서부터 3개의 팟을 인센티바이즈 해버린다. -RUN sed -i 's/"distr_info": null/"distr_info": {"total_weight":"600","records":[{"gauge_id":"1","weight":"100"},{"gauge_id":"2","weight":"200"},{"gauge_id":"3","weight":"300"}]}/g' ~/.osmosisd/config/genesis.json +# RUN sed -i 's/"distr_info": null/"distr_info": {"total_weight":"600","records":[{"gauge_id":"1","weight":"100"},{"gauge_id":"2","weight":"200"},{"gauge_id":"3","weight":"300"}]}/g' ~/.osmosisd/config/genesis.json RUN echo "high gain deposit chuckle hundred regular exist approve peanut enjoy comfort ride" | ./osmosisd keys add val --recover --keyring-backend test RUN echo "health nest provide snow total tissue intact loyal cargo must credit wrist" | ./osmosisd keys add local1 --recover --keyring-backend test diff --git a/src/config.ts b/src/config.ts index d6ef8b1c08..155368eb76 100644 --- a/src/config.ts +++ b/src/config.ts @@ -593,7 +593,7 @@ export const EmbedChainInfos: ChainInfoWithExplorer[] = [ coinImageUrl: window.location.origin + '/public/assets/tokens/osmosis.svg', }, ], - features: ['stargate', 'ibc-transfer'], + features: ['stargate', 'ibc-transfer', 'no-legacy-stdTx', 'ibc-go'], explorerUrlToTx: 'https://www.mintscan.io/osmosis/txs/{txHash}', }, { diff --git a/src/stores/test-env.ts b/src/stores/test-env.ts index c9b62926fc..b4b82d35c2 100644 --- a/src/stores/test-env.ts +++ b/src/stores/test-env.ts @@ -11,6 +11,7 @@ import Axios from 'axios'; import WebSocket from 'ws'; import { exec } from 'child_process'; import { Bech32Address } from '@keplr-wallet/cosmos'; +import { Buffer } from 'buffer/'; export const TestChainInfos: ChainInfoWithExplorer[] = [ { @@ -56,7 +57,7 @@ export const TestChainInfos: ChainInfoWithExplorer[] = [ coinDecimals: 6, }, ], - features: ['stargate'], + features: ['stargate', 'no-legacy-stdTx', 'ibc-go'], explorerUrlToTx: '', }, ]; @@ -68,7 +69,7 @@ export class RootStore { constructor() { const mockKeplr = new MockKeplr( - async (chainId: string, tx: StdTx) => { + async (chainId: string, tx: StdTx | Uint8Array) => { const chainInfo = TestChainInfos.find(info => info.chainId === chainId); if (!chainInfo) { throw new Error('Unknown chain info'); @@ -80,19 +81,28 @@ export class RootStore { }, }); - const params = { - tx, - // Force to send as "block" mode - mode: 'block', - }; + const isProtoTx = Buffer.isBuffer(tx) || tx instanceof Uint8Array; + + const params = isProtoTx + ? { + tx_bytes: Buffer.from(tx as any).toString('base64'), + mode: 'BROADCAST_MODE_BLOCK', + } + : { + tx, + mode: 'block', + }; try { - const result = await restInstance.post('/txs', params); - if (result.data.code != null && result.data.code !== 0) { - throw new Error(result.data['raw_log']); + const result = await restInstance.post(isProtoTx ? '/cosmos/tx/v1beta1/txs' : '/txs', params); + + const txResponse = isProtoTx ? result.data['tx_response'] : result.data; + + if (txResponse.code != null && txResponse.code !== 0) { + throw new Error(txResponse['raw_log']); } - return Buffer.from(result.data.txhash, 'hex'); + return Buffer.from(txResponse.txhash, 'hex'); } finally { // Sending the other tx right after the response is fetched makes the other tx be failed sometimes, // because actually the increased sequence is commited after the block is fully processed.