Skip to content

Commit 470beeb

Browse files
authored
Merge pull request #6 from hyperweb-io/examples
Examples
2 parents 07b70ec + 5256203 commit 470beeb

File tree

6 files changed

+30
-13
lines changed

6 files changed

+30
-13
lines changed

examples/ibc-asset-list/hooks/useTx.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@ import { toast, ToastShape } from '@interchain-ui/react';
55
import { useChain } from '@interchain-kit/react';
66
import { TxRaw } from 'osmo-query/dist/codegen/cosmos/tx/v1beta1/tx';
77
import { assetLists } from '@chain-registry/v2';
8+
import {
9+
toConverters,
10+
toEncoders,
11+
} from '@interchainjs/cosmos/utils';
12+
import { MsgTransfer } from 'interchainjs/ibc/applications/transfer/v1/tx';
813

914
interface Msg {
1015
typeUrl: string;
@@ -47,12 +52,14 @@ export const useTx = (chainName: string) => {
4752
amount: [
4853
{
4954
denom: denomUnit?.denom!,
50-
amount: (BigInt(10 ** (denomUnit?.exponent || 6)) / 100n).toString()
55+
amount: (BigInt(10 ** (denomUnit?.exponent || 6)) / 10n).toString()
5156
}
5257
],
53-
gas: '200000'
58+
gas: '800000'
5459
}
5560
client = await getSigningClient();
61+
client.addEncoders(toEncoders(MsgTransfer))
62+
client.addConverters(toConverters(MsgTransfer))
5663
signed = await client.sign(address, msgs, fee, '');
5764
} catch (e: any) {
5865
console.error(e);
@@ -74,7 +81,7 @@ export const useTx = (chainName: string) => {
7481
if (options.onSuccess) options.onSuccess();
7582
return options.toast?.title || TxStatus.Successful;
7683
} else {
77-
console.error(data?.rawLog);
84+
console.error(data);
7885
return {
7986
message: TxStatus.Failed,
8087
toastType: 'error',

examples/ibc-asset-list/pages/_app.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,13 @@ function CreateCosmosApp({ Component, pageProps }: AppProps) {
3131
assetLists={assetLists}
3232
wallets={[keplrWallet, leapWallet]}
3333
signerOptions={{}}
34+
endpointOptions={{
35+
endpoints: {
36+
'osmosis': {
37+
rpc: ['https://rpc.osmosis.zone'],
38+
},
39+
},
40+
}}
3441
>
3542
<QueryClientProvider client={queryClient}>
3643
<main id="main" className={themeClass}>

examples/stake-tokens/components/staking/DelegateModal.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,10 +134,10 @@ export const DelegateModal = ({
134134
amount: [
135135
{
136136
denom: denomUnit?.denom!,
137-
amount: (BigInt(10 ** (denomUnit?.exponent || 6)) / 100n).toString()
137+
amount: (BigInt(10 ** (denomUnit?.exponent || 6)) / 10n).toString()
138138
}
139139
],
140-
gas: '200000'
140+
gas: '800000'
141141
}
142142
const feeAmount = new BigNumber(fee.amount[0].amount).shiftedBy(-exp);
143143
const balanceAfterFee = new BigNumber(balance)

examples/stake-tokens/components/staking/Overview.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,8 @@ const Overview = ({
6565
<Box mb={{ mobile: '$8', tablet: '$12' }}>
6666
<StakingAssetHeader
6767
imgSrc={
68-
coin.logo_URIs?.png ||
69-
coin.logo_URIs?.svg ||
68+
coin.logoURIs?.png ||
69+
coin.logoURIs?.svg ||
7070
''
7171
}
7272
symbol={coin.symbol}

examples/stake-tokens/hooks/useTx.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@ import { StdFee } from '@interchainjs/cosmos-types/types';
44
import { isDeliverTxSuccess } from '@interchainjs/cosmos/utils/asserts'
55
import { useToast, type CustomToast } from './useToast';
66
import { assetLists } from '@chain-registry/v2';
7-
import { toEncoders } from '@interchainjs/cosmos/utils'
8-
import { MsgDelegate, MsgUndelegate } from 'interchainjs/cosmos/staking/v1beta1/tx'
7+
import { toEncoders, toConverters } from '@interchainjs/cosmos/utils'
8+
import { MsgDelegate, MsgUndelegate, MsgBeginRedelegate } from 'interchainjs/cosmos/staking/v1beta1/tx'
9+
import { MsgWithdrawDelegatorReward } from 'interchainjs/cosmos/distribution/v1beta1/tx'
910

1011
const txRaw = cosmos.tx.v1beta1.TxRaw;
1112

@@ -55,13 +56,14 @@ export const useTx = (chainName: string) => {
5556
amount: [
5657
{
5758
denom: denomUnit?.denom!,
58-
amount: (BigInt(10 ** (denomUnit?.exponent || 6)) / 100n).toString()
59+
amount: (BigInt(10 ** (denomUnit?.exponent || 6)) / 10n).toString()
5960
}
6061
],
61-
gas: '200000'
62+
gas: '800000'
6263
}
6364
client = await getSigningClient();
64-
client.addEncoders(toEncoders(MsgDelegate, MsgUndelegate))
65+
client.addEncoders(toEncoders(MsgDelegate, MsgUndelegate, MsgBeginRedelegate, MsgWithdrawDelegatorReward))
66+
client.addConverters(toConverters(MsgDelegate, MsgUndelegate, MsgBeginRedelegate, MsgWithdrawDelegatorReward))
6567
signed = await client.sign(address, msgs, fee, '');
6668
} catch (e: any) {
6769
console.error(e);

examples/vote-proposal/hooks/useTx.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { useChain } from '@interchain-kit/react';
33
import { assetLists } from '@chain-registry/v2'
44
import { DeliverTxResponse, StdFee } from '@interchainjs/cosmos-types/types'
55
import { isDeliverTxSuccess } from '@interchainjs/cosmos/utils/asserts'
6-
import { toEncoders } from '@interchainjs/cosmos/utils'
6+
import { toEncoders, toConverters } from '@interchainjs/cosmos/utils'
77
import { MsgVote } from 'interchainjs/cosmos/gov/v1beta1/tx'
88

99
export type Msg = {
@@ -75,6 +75,7 @@ export function useTx(chainName: string) {
7575
}
7676
const client = await getSigningClient();
7777
client.addEncoders(toEncoders(MsgVote))
78+
client.addConverters(toConverters(MsgVote))
7879
console.log('msgs', msgs)
7980
const signed = await client.sign(address, msgs, fee, '');
8081

0 commit comments

Comments
 (0)