Skip to content

Commit

Permalink
Update the localnet and chain info to the osmosis v5
Browse files Browse the repository at this point in the history
  • Loading branch information
Thunnini committed Dec 13, 2021
1 parent e55ab0d commit 2e1d9e4
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 14 deletions.
7 changes: 5 additions & 2 deletions localnet/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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]}' - \
Expand All @@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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}',
},
{
Expand Down
32 changes: 21 additions & 11 deletions src/stores/test-env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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[] = [
{
Expand Down Expand Up @@ -56,7 +57,7 @@ export const TestChainInfos: ChainInfoWithExplorer[] = [
coinDecimals: 6,
},
],
features: ['stargate'],
features: ['stargate', 'no-legacy-stdTx', 'ibc-go'],
explorerUrlToTx: '',
},
];
Expand All @@ -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');
Expand All @@ -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.
Expand Down

0 comments on commit 2e1d9e4

Please sign in to comment.