Skip to content

Commit

Permalink
Merge pull request #6 from hyperweb-io/examples
Browse files Browse the repository at this point in the history
Examples
  • Loading branch information
sdqede authored Jan 26, 2025
2 parents 07b70ec + 5256203 commit 470beeb
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 13 deletions.
13 changes: 10 additions & 3 deletions examples/ibc-asset-list/hooks/useTx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ import { toast, ToastShape } from '@interchain-ui/react';
import { useChain } from '@interchain-kit/react';
import { TxRaw } from 'osmo-query/dist/codegen/cosmos/tx/v1beta1/tx';
import { assetLists } from '@chain-registry/v2';
import {
toConverters,
toEncoders,
} from '@interchainjs/cosmos/utils';
import { MsgTransfer } from 'interchainjs/ibc/applications/transfer/v1/tx';

interface Msg {
typeUrl: string;
Expand Down Expand Up @@ -47,12 +52,14 @@ export const useTx = (chainName: string) => {
amount: [
{
denom: denomUnit?.denom!,
amount: (BigInt(10 ** (denomUnit?.exponent || 6)) / 100n).toString()
amount: (BigInt(10 ** (denomUnit?.exponent || 6)) / 10n).toString()
}
],
gas: '200000'
gas: '800000'
}
client = await getSigningClient();
client.addEncoders(toEncoders(MsgTransfer))
client.addConverters(toConverters(MsgTransfer))
signed = await client.sign(address, msgs, fee, '');
} catch (e: any) {
console.error(e);
Expand All @@ -74,7 +81,7 @@ export const useTx = (chainName: string) => {
if (options.onSuccess) options.onSuccess();
return options.toast?.title || TxStatus.Successful;
} else {
console.error(data?.rawLog);
console.error(data);
return {
message: TxStatus.Failed,
toastType: 'error',
Expand Down
7 changes: 7 additions & 0 deletions examples/ibc-asset-list/pages/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,13 @@ function CreateCosmosApp({ Component, pageProps }: AppProps) {
assetLists={assetLists}
wallets={[keplrWallet, leapWallet]}
signerOptions={{}}
endpointOptions={{
endpoints: {
'osmosis': {
rpc: ['https://rpc.osmosis.zone'],
},
},
}}
>
<QueryClientProvider client={queryClient}>
<main id="main" className={themeClass}>
Expand Down
4 changes: 2 additions & 2 deletions examples/stake-tokens/components/staking/DelegateModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -134,10 +134,10 @@ export const DelegateModal = ({
amount: [
{
denom: denomUnit?.denom!,
amount: (BigInt(10 ** (denomUnit?.exponent || 6)) / 100n).toString()
amount: (BigInt(10 ** (denomUnit?.exponent || 6)) / 10n).toString()
}
],
gas: '200000'
gas: '800000'
}
const feeAmount = new BigNumber(fee.amount[0].amount).shiftedBy(-exp);
const balanceAfterFee = new BigNumber(balance)
Expand Down
4 changes: 2 additions & 2 deletions examples/stake-tokens/components/staking/Overview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ const Overview = ({
<Box mb={{ mobile: '$8', tablet: '$12' }}>
<StakingAssetHeader
imgSrc={
coin.logo_URIs?.png ||
coin.logo_URIs?.svg ||
coin.logoURIs?.png ||
coin.logoURIs?.svg ||
''
}
symbol={coin.symbol}
Expand Down
12 changes: 7 additions & 5 deletions examples/stake-tokens/hooks/useTx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ import { StdFee } from '@interchainjs/cosmos-types/types';
import { isDeliverTxSuccess } from '@interchainjs/cosmos/utils/asserts'
import { useToast, type CustomToast } from './useToast';
import { assetLists } from '@chain-registry/v2';
import { toEncoders } from '@interchainjs/cosmos/utils'
import { MsgDelegate, MsgUndelegate } from 'interchainjs/cosmos/staking/v1beta1/tx'
import { toEncoders, toConverters } from '@interchainjs/cosmos/utils'
import { MsgDelegate, MsgUndelegate, MsgBeginRedelegate } from 'interchainjs/cosmos/staking/v1beta1/tx'
import { MsgWithdrawDelegatorReward } from 'interchainjs/cosmos/distribution/v1beta1/tx'

const txRaw = cosmos.tx.v1beta1.TxRaw;

Expand Down Expand Up @@ -55,13 +56,14 @@ export const useTx = (chainName: string) => {
amount: [
{
denom: denomUnit?.denom!,
amount: (BigInt(10 ** (denomUnit?.exponent || 6)) / 100n).toString()
amount: (BigInt(10 ** (denomUnit?.exponent || 6)) / 10n).toString()
}
],
gas: '200000'
gas: '800000'
}
client = await getSigningClient();
client.addEncoders(toEncoders(MsgDelegate, MsgUndelegate))
client.addEncoders(toEncoders(MsgDelegate, MsgUndelegate, MsgBeginRedelegate, MsgWithdrawDelegatorReward))
client.addConverters(toConverters(MsgDelegate, MsgUndelegate, MsgBeginRedelegate, MsgWithdrawDelegatorReward))
signed = await client.sign(address, msgs, fee, '');
} catch (e: any) {
console.error(e);
Expand Down
3 changes: 2 additions & 1 deletion examples/vote-proposal/hooks/useTx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { useChain } from '@interchain-kit/react';
import { assetLists } from '@chain-registry/v2'
import { DeliverTxResponse, StdFee } from '@interchainjs/cosmos-types/types'
import { isDeliverTxSuccess } from '@interchainjs/cosmos/utils/asserts'
import { toEncoders } from '@interchainjs/cosmos/utils'
import { toEncoders, toConverters } from '@interchainjs/cosmos/utils'
import { MsgVote } from 'interchainjs/cosmos/gov/v1beta1/tx'

export type Msg = {
Expand Down Expand Up @@ -75,6 +75,7 @@ export function useTx(chainName: string) {
}
const client = await getSigningClient();
client.addEncoders(toEncoders(MsgVote))
client.addConverters(toConverters(MsgVote))
console.log('msgs', msgs)
const signed = await client.sign(address, msgs, fee, '');

Expand Down

0 comments on commit 470beeb

Please sign in to comment.