Skip to content

Commit 89ab467

Browse files
authoredFeb 18, 2025··
Merge pull request #19 from hyperweb-io/package-removals
ibc transaction success
2 parents 4d54092 + 7f22844 commit 89ab467

File tree

13 files changed

+432
-168
lines changed

13 files changed

+432
-168
lines changed
 

‎examples/ibc-asset-list/components/asset-list/DropdownTransferModal.tsx

+14-13
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ import {
77
import { useChainWallet } from '@interchain-kit/react';
88
import { chains } from '@chain-registry/v2'
99
import BigNumber from 'bignumber.js';
10-
import { ibc } from 'osmo-query';
1110
import { StdFee } from '@interchainjs/cosmos-types/types';
1211
import { KeplrWalletName } from '@/config';
1312
import { useDisclosure, useChainUtils, useTx, useBalance } from '@/hooks';
1413
import { truncDecimals } from '@/utils';
14+
import { MsgTransfer } from 'interchainjs/ibc/applications/transfer/v1/tx';
1515

1616
import {
1717
PrettyAsset,
@@ -21,8 +21,6 @@ import {
2121
Unpacked,
2222
} from './types';
2323

24-
const { transfer } = ibc.applications.transfer.v1.MessageComposer.withTypeUrl;
25-
2624
const ZERO_AMOUNT = '0';
2725

2826
interface OverviewTransferWrapperProps {
@@ -156,16 +154,19 @@ const OverviewTransferWrapper = (
156154
const stamp = Date.now();
157155
const timeoutInNanos = (stamp + 1.2e6) * 1e6;
158156

159-
const msg = transfer({
160-
sourcePort,
161-
sourceChannel,
162-
sender: sourceAddress,
163-
receiver: destAddress,
164-
token,
165-
// @ts-ignore
166-
timeoutHeight: undefined,
167-
timeoutTimestamp: BigInt(timeoutInNanos),
168-
});
157+
const msg = {
158+
typeUrl: MsgTransfer.typeUrl,
159+
value: MsgTransfer.fromPartial({
160+
sourcePort,
161+
sourceChannel,
162+
token,
163+
sender: sourceAddress,
164+
receiver: destAddress,
165+
timeoutHeight: undefined,
166+
timeoutTimestamp: BigInt(timeoutInNanos),
167+
memo: '',
168+
}),
169+
}
169170

170171
await tx([msg], {
171172
fee,

‎examples/ibc-asset-list/components/asset-list/RowTransferModal.tsx

+27-24
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,9 @@ import BigNumber from 'bignumber.js';
55
import { StdFee } from '@interchainjs/cosmos-types/types';
66
import { useDisclosure, useChainUtils, useBalance, useTx } from '@/hooks';
77
import { KeplrWalletName } from '@/config';
8-
import { ibc } from 'osmo-query';
98
import { chains } from '@chain-registry/v2'
10-
119
import { PriceHash, TransferInfo, Transfer } from './types';
12-
13-
const { transfer } = ibc.applications.transfer.v1.MessageComposer.withTypeUrl;
10+
import { MsgTransfer } from 'interchainjs/ibc/applications/transfer/v1/tx';
1411

1512
interface IProps {
1613
prices: PriceHash;
@@ -128,16 +125,19 @@ const TransferModalBody = (
128125
const stamp = Date.now();
129126
const timeoutInNanos = (stamp + 1.2e6) * 1e6;
130127

131-
const msg = transfer({
132-
sourcePort,
133-
sourceChannel,
134-
sender: sourceAddress,
135-
receiver: destAddress,
136-
token,
137-
// @ts-ignore
138-
timeoutHeight: undefined,
139-
timeoutTimestamp: BigInt(timeoutInNanos),
140-
});
128+
const msg = {
129+
typeUrl: MsgTransfer.typeUrl,
130+
value: MsgTransfer.fromPartial({
131+
sourcePort,
132+
sourceChannel,
133+
token,
134+
sender: sourceAddress,
135+
receiver: destAddress,
136+
timeoutHeight: undefined,
137+
timeoutTimestamp: BigInt(timeoutInNanos),
138+
memo: '',
139+
}),
140+
}
141141

142142
await tx([msg], {
143143
fee,
@@ -196,16 +196,19 @@ const TransferModalBody = (
196196
const stamp = Date.now();
197197
const timeoutInNanos = (stamp + 1.2e6) * 1e6;
198198

199-
const msg = transfer({
200-
sourcePort,
201-
sourceChannel,
202-
sender: sourceAddress,
203-
receiver: destAddress,
204-
token,
205-
// @ts-ignore
206-
timeoutHeight: undefined,
207-
timeoutTimestamp: BigInt(timeoutInNanos),
208-
});
199+
const msg = {
200+
typeUrl: MsgTransfer.typeUrl,
201+
value: MsgTransfer.fromPartial({
202+
sourcePort,
203+
sourceChannel,
204+
token,
205+
sender: sourceAddress,
206+
receiver: destAddress,
207+
timeoutHeight: undefined,
208+
timeoutTimestamp: BigInt(timeoutInNanos),
209+
memo: '',
210+
}),
211+
}
209212

210213
await tx([msg], {
211214
fee,
+1-31
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,5 @@
11
import { assetLists as assets } from '@chain-registry/v2';
22
import { AssetList, Asset } from '@chain-registry/v2-types';
3-
import { GeneratedType } from '@interchainjs/cosmos-types/types';
4-
import { Registry } from '@cosmjs/proto-signing';
5-
import { AminoTypes } from '@cosmjs/stargate';
6-
import {
7-
cosmosAminoConverters,
8-
cosmosProtoRegistry,
9-
cosmwasmAminoConverters,
10-
cosmwasmProtoRegistry,
11-
ibcProtoRegistry,
12-
ibcAminoConverters,
13-
osmosisAminoConverters,
14-
osmosisProtoRegistry,
15-
} from 'osmo-query';
163

174
export const defaultChainName = 'osmosis';
185
export const KeplrWalletName = 'keplr-extension';
@@ -23,21 +10,4 @@ export const chainassets: AssetList = assets.find(
2310

2411
export const coin: Asset = chainassets.assets.find(
2512
(asset) => asset.base === 'uosmo'
26-
) as Asset;
27-
28-
const protoRegistry: ReadonlyArray<[string, GeneratedType]> = [
29-
...cosmosProtoRegistry,
30-
...cosmwasmProtoRegistry,
31-
...ibcProtoRegistry,
32-
...osmosisProtoRegistry,
33-
];
34-
35-
const aminoConverters = {
36-
...cosmosAminoConverters,
37-
...cosmwasmAminoConverters,
38-
...ibcAminoConverters,
39-
...osmosisAminoConverters,
40-
};
41-
42-
export const registry = new Registry(protoRegistry);
43-
export const aminoTypes = new AminoTypes(aminoConverters);
13+
) as Asset;

‎examples/ibc-asset-list/hooks/queries/useQueryHooks.ts

+10-2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
11
import { useChain } from '@interchain-kit/react';
2-
import { useRpcEndpoint, useRpcClient, createRpcQueryHooks } from 'osmo-query';
2+
import { createRpcQueryHooks } from 'osmo-query';
3+
import { useRpcClient } from 'interchain-react/react-query';
4+
import { useRpcEndpoint } from 'interchain-react/react-query'
5+
import { defaultContext } from '@tanstack/react-query';
36

47
export const useQueryHooks = (chainName: string, extraKey?: string) => {
58
const { address, getRpcEndpoint } = useChain(chainName);
69

710
const rpcEndpointQuery = useRpcEndpoint({
811
getter: getRpcEndpoint,
912
options: {
13+
context: defaultContext,
1014
enabled: !!address,
1115
staleTime: Infinity,
1216
queryKeyHashFn: (queryKey) => {
@@ -17,8 +21,12 @@ export const useQueryHooks = (chainName: string, extraKey?: string) => {
1721
});
1822

1923
const rpcClientQuery = useRpcClient({
20-
rpcEndpoint: rpcEndpointQuery.data || '',
24+
// rpcEndpoint: rpcEndpointQuery.data || '',
25+
clientResolver: {
26+
rpcEndpoint: rpcEndpointQuery.data,
27+
},
2128
options: {
29+
context: defaultContext,
2230
enabled: !!address && !!rpcEndpointQuery.data,
2331
staleTime: Infinity,
2432
queryKeyHashFn: (queryKey) => {

‎examples/ibc-asset-list/hooks/queries/useTotalAssets.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { useEffect, useMemo } from 'react';
66
import { useChainUtils } from '../useChainUtils';
77
import { usePrices } from './usePrices';
88
import { defaultChainName as osmoChainName } from '@/config';
9-
import { Pool } from 'osmo-query/dist/codegen/osmosis/gamm/pool-models/balancer/balancerPool';
9+
import { Pool } from '@/types/pool-models';
1010
import { convertGammTokenToDollarValue } from '@/utils';
1111
import { useQueryHooks } from './useQueryHooks';
1212

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

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
1-
import { cosmos } from 'osmo-query';
21
import { StdFee } from '@interchainjs/cosmos-types/types';
32
import { isDeliverTxSuccess } from '@interchainjs/cosmos/utils/asserts';
43
import { toast, ToastShape } from '@interchain-ui/react';
54
import { useChain } from '@interchain-kit/react';
6-
import { TxRaw } from 'osmo-query/dist/codegen/cosmos/tx/v1beta1/tx';
75
import { assetLists } from '@chain-registry/v2';
86
import {
97
toConverters,
108
toEncoders,
119
} from '@interchainjs/cosmos/utils';
1210
import { MsgTransfer } from 'interchainjs/ibc/applications/transfer/v1/tx';
11+
import { TxRaw } from '@interchainjs/cosmos-types/cosmos/tx/v1beta1/tx'
1312

1413
interface Msg {
1514
typeUrl: string;
@@ -28,7 +27,7 @@ export enum TxStatus {
2827
Broadcasting = 'Transaction Broadcasting',
2928
}
3029

31-
const txRaw = cosmos.tx.v1beta1.TxRaw;
30+
const txRaw = TxRaw;
3231

3332
export const useTx = (chainName: string) => {
3433
const { address, getSigningClient } =

‎examples/ibc-asset-list/package.json

+5-4
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@
2323
"@cosmjs/stargate": "^0.32.3",
2424
"@emotion/react": "11.10.6",
2525
"@emotion/styled": "11.10.6",
26-
"@interchain-kit/core": "0.0.1-beta.62",
27-
"@interchain-kit/keplr-extension": "0.0.1-beta.62",
28-
"@interchain-kit/leap-extension": "0.0.1-beta.62",
29-
"@interchain-kit/react": "0.0.1-beta.62",
26+
"@interchain-kit/core": "0.2.203",
27+
"@interchain-kit/keplr-extension": "0.2.203",
28+
"@interchain-kit/leap-extension": "0.2.203",
29+
"@interchain-kit/react": "0.2.203",
3030
"@interchain-ui/react": "1.26.0",
3131
"@interchain-ui/react-no-ssr": "^0.1.6",
3232
"@interchainjs/cosmos": "1.8.2",
@@ -37,6 +37,7 @@
3737
"chain-registry": "^1.69.32",
3838
"fast-fuzzy": "1.12.0",
3939
"framer-motion": "9.0.7",
40+
"interchain-react": "1.7.3",
4041
"match-sorter": "^6.3.3",
4142
"next": "^13",
4243
"osmo-query": "16.5.1",
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
import { Coin } from '@interchainjs/cosmos-types/types';
2+
3+
export interface Pool {
4+
$typeUrl?: string;
5+
address: string;
6+
id: bigint;
7+
poolParams: PoolParams;
8+
/**
9+
* This string specifies who will govern the pool in the future.
10+
* Valid forms of this are:
11+
* {token name},{duration}
12+
* {duration}
13+
* where {token name} if specified is the token which determines the
14+
* governor, and if not specified is the LP token for this pool.duration is
15+
* a time specified as 0w,1w,2w, etc. which specifies how long the token
16+
* would need to be locked up to count in governance. 0w means no lockup.
17+
* TODO: Further improve these docs
18+
*/
19+
futurePoolGovernor: string;
20+
/** sum of all LP tokens sent out */
21+
totalShares: Coin;
22+
/**
23+
* These are assumed to be sorted by denomiation.
24+
* They contain the pool asset and the information about the weight
25+
*/
26+
poolAssets: PoolAsset[];
27+
/** sum of all non-normalized pool weights */
28+
totalWeight: string;
29+
}
30+
31+
interface PoolParams {
32+
swapFee: string;
33+
/**
34+
* N.B.: exit fee is disabled during pool creation in x/poolmanager. While old
35+
* pools can maintain a non-zero fee. No new pool can be created with non-zero
36+
* fee anymore
37+
*/
38+
exitFee: string;
39+
smoothWeightChangeParams?: SmoothWeightChangeParams;
40+
}
41+
42+
interface SmoothWeightChangeParams {
43+
/**
44+
* The start time for beginning the weight change.
45+
* If a parameter change / pool instantiation leaves this blank,
46+
* it should be generated by the state_machine as the current time.
47+
*/
48+
startTime: Date;
49+
/** Duration for the weights to change over */
50+
duration: Duration;
51+
/**
52+
* The initial pool weights. These are copied from the pool's settings
53+
* at the time of weight change instantiation.
54+
* The amount PoolAsset.token.amount field is ignored if present,
55+
* future type refactorings should just have a type with the denom & weight
56+
* here.
57+
*/
58+
initialPoolWeights: PoolAsset[];
59+
/**
60+
* The target pool weights. The pool weights will change linearly with respect
61+
* to time between start_time, and start_time + duration. The amount
62+
* PoolAsset.token.amount field is ignored if present, future type
63+
* refactorings should just have a type with the denom & weight here.
64+
*/
65+
targetPoolWeights: PoolAsset[];
66+
}
67+
68+
interface Duration {
69+
/**
70+
* Signed seconds of the span of time. Must be from -315,576,000,000
71+
* to +315,576,000,000 inclusive. Note: these bounds are computed from:
72+
* 60 sec/min * 60 min/hr * 24 hr/day * 365.25 days/year * 10000 years
73+
*/
74+
seconds: bigint;
75+
/**
76+
* Signed fractions of a second at nanosecond resolution of the span
77+
* of time. Durations less than one second are represented with a 0
78+
* `seconds` field and a positive or negative `nanos` field. For durations
79+
* of one second or more, a non-zero value for the `nanos` field must be
80+
* of the same sign as the `seconds` field. Must be from -999,999,999
81+
* to +999,999,999 inclusive.
82+
*/
83+
nanos: number;
84+
}
85+
86+
interface PoolAsset {
87+
/**
88+
* Coins we are talking about,
89+
* the denomination must be unique amongst all PoolAssets for this pool.
90+
*/
91+
token: Coin;
92+
/** Weight that is not normalized. This weight must be less than 2^50 */
93+
weight: string;
94+
}

‎examples/ibc-asset-list/utils/pool.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { Pool } from 'osmo-query/dist/codegen/osmosis/gamm/pool-models/balancer/balancerPool';
2-
import { Coin } from 'osmo-query/dist/codegen/cosmos/base/v1beta1/coin';
1+
import { Pool } from '@/types/pool-models';
2+
import { Coin } from 'interchainjs/types';
33
import {
44
PriceHash,
55
CoinValue,

‎examples/ibc-asset-list/utils/types.ts

+2-18
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
import { DenomUnit } from '@chain-registry/v2-types';
2-
import { Duration } from 'osmo-query/dist/codegen/google/protobuf/duration';
3-
import { Gauge } from 'osmo-query/dist/codegen/osmosis/incentives/gauge';
4-
import { SuperfluidAsset } from 'osmo-query/dist/codegen/osmosis/superfluid/superfluid';
5-
import { Coin } from 'osmo-query/dist/codegen/cosmos/base/v1beta1/coin';
6-
import { Pool } from 'osmo-query/dist/codegen/osmosis/gamm/pool-models/balancer/balancerPool';
2+
import { Coin } from 'interchainjs/types';
3+
import { Pool } from '@/types/pool-models';
74

85
export type CoinDenom = DenomUnit['denom'];
96

@@ -55,19 +52,6 @@ export interface PoolPretty extends Pool {
5552
poolAssetsPretty: PoolAssetPretty[];
5653
}
5754

58-
export interface CalcPoolAprsParams {
59-
activeGauges: Gauge[];
60-
pool: Pool;
61-
prices: PriceHash;
62-
superfluidPools: SuperfluidAsset[];
63-
aprSuperfluid: string | number;
64-
lockupDurations: Duration[];
65-
volume7d: string | number;
66-
swapFee: string | number;
67-
lockup?: string;
68-
includeNonPerpetual?: boolean;
69-
}
70-
7155
export interface Trade {
7256
sell: Coin;
7357
buy: Coin;

‎examples/ibc-asset-list/yarn.lock

+270-66
Large diffs are not rendered by default.

‎examples/stake-tokens/hooks/useTx.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { cosmos } from 'interchain-query';
21
import { useChain } from '@interchain-kit/react';
32
import { StdFee } from '@interchainjs/cosmos-types/types';
43
import { isDeliverTxSuccess } from '@interchainjs/cosmos/utils/asserts'
@@ -7,8 +6,9 @@ import { assetLists } from '@chain-registry/v2';
76
import { toEncoders, toConverters } from '@interchainjs/cosmos/utils'
87
import { MsgDelegate, MsgUndelegate, MsgBeginRedelegate } from 'interchainjs/cosmos/staking/v1beta1/tx'
98
import { MsgWithdrawDelegatorReward } from 'interchainjs/cosmos/distribution/v1beta1/tx'
9+
import { TxRaw } from '@interchainjs/cosmos-types/cosmos/tx/v1beta1/tx'
1010

11-
const txRaw = cosmos.tx.v1beta1.TxRaw;
11+
const txRaw = TxRaw;
1212

1313
interface Msg {
1414
typeUrl: string;

‎examples/vote-proposal/hooks/useTx.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
import { cosmos } from 'interchain-query';
21
import { useChain } from '@interchain-kit/react';
32
import { assetLists } from '@chain-registry/v2'
43
import { DeliverTxResponse, StdFee } from '@interchainjs/cosmos-types/types'
54
import { isDeliverTxSuccess } from '@interchainjs/cosmos/utils/asserts'
65
import { toEncoders, toConverters } from '@interchainjs/cosmos/utils'
76
import { MsgVote } from 'interchainjs/cosmos/gov/v1beta1/tx'
7+
import { TxRaw } from '@interchainjs/cosmos-types/cosmos/tx/v1beta1/tx'
88

99
export type Msg = {
1010
typeUrl: string;
@@ -63,7 +63,7 @@ export function useTx(chainName: string) {
6363
}
6464

6565
try {
66-
const txRaw = cosmos.tx.v1beta1.TxRaw;
66+
const txRaw = TxRaw;
6767
const fee = {
6868
amount: [
6969
{

0 commit comments

Comments
 (0)
Please sign in to comment.