Skip to content

Commit 5da66a4

Browse files
committed
upgrade interchain-kit and fix the balance fetching issue
1 parent 38f4421 commit 5da66a4

File tree

3 files changed

+63
-35
lines changed

3 files changed

+63
-35
lines changed

examples/vite-react/package.json

+2-3
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,8 @@
1515
"@emotion/react": "^11.11.4",
1616
"@emotion/styled": "^11.11.0",
1717
"@hookform/resolvers": "^3.3.4",
18-
"@interchain-kit/core": "^0.2.205",
19-
"@interchain-kit/keplr-extension": "^0.2.205",
20-
"@interchainjs/utils": "1.9.16",
18+
"@interchain-kit/core": "0.2.206",
19+
"@interchain-kit/keplr-extension": "0.2.206",
2120
"@tanstack/react-query": "5.68.0",
2221
"buffer": "^6.0.3",
2322
"framer-motion": "^11.0.8",

examples/vite-react/src/App.tsx

+7-27
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,11 @@ import { zodResolver } from '@hookform/resolvers/zod';
2323
import { useQuery, useMutation } from '@tanstack/react-query';
2424
import { transferFormSchema, type TransferFormData } from './utils/validation';
2525
import {
26-
CHAIN_ID,
2726
RPC_ENDPOINT,
28-
REST_ENDPOINT,
2927
DENOM,
3028
DENOM_DISPLAY,
3129
DECIMAL,
3230
} from './utils/constants';
33-
import { SigningStargateClient } from '@cosmjs/stargate';
3431
import { chain as cosmoshubChain, assetList as cosmoshubAssetList } from '@chain-registry/v2/mainnet/cosmoshub'
3532
import { WalletManager } from '@interchain-kit/core'
3633
import { keplrWallet } from '@interchain-kit/keplr-extension'
@@ -71,30 +68,13 @@ function App() {
7168
queryFn: async () => {
7269
if (!address) return null;
7370
try {
74-
// const balanceQuery = createGetBalance(RPC_ENDPOINT);
75-
// const { balance: atomBalance } = await balanceQuery({
76-
// address,
77-
// denom: DENOM,
78-
// });
79-
// return Number(atomBalance?.amount || 0) / Math.pow(10, DECIMAL);
80-
81-
const response = await fetch(
82-
`${REST_ENDPOINT}/cosmos/bank/v1beta1/balances/${address}`
83-
);
84-
if (!response.ok) {
85-
throw new Error('Failed to fetch balance');
86-
}
87-
const data = await response.json();
88-
// Log the response to see what we're getting
89-
console.log('Balance response:', data);
90-
if (!data.balances) {
91-
return 0;
92-
}
93-
const atomBalance = data.balances.find((b: any) => b.denom === DENOM);
94-
if (!atomBalance) {
95-
return 0;
96-
}
97-
return Number(atomBalance.amount) / Math.pow(10, DECIMAL);
71+
const balanceQuery = createGetBalance(RPC_ENDPOINT);
72+
console.log('balanceQuery', balanceQuery)
73+
const { balance: atomBalance } = await balanceQuery({
74+
address,
75+
denom: DENOM,
76+
});
77+
return Number(atomBalance?.amount || 0) / Math.pow(10, DECIMAL);
9878
} catch (error) {
9979
console.error('Error fetching balance:', error);
10080
toast({

yarn.lock

+54-5
Original file line numberDiff line numberDiff line change
@@ -4375,7 +4375,7 @@ __metadata:
43754375
languageName: node
43764376
linkType: hard
43774377

4378-
"@interchain-kit/core@npm:0.2.205, @interchain-kit/core@npm:^0.2.1, @interchain-kit/core@npm:^0.2.205":
4378+
"@interchain-kit/core@npm:0.2.205, @interchain-kit/core@npm:^0.2.1":
43794379
version: 0.2.205
43804380
resolution: "@interchain-kit/core@npm:0.2.205"
43814381
dependencies:
@@ -4399,6 +4399,30 @@ __metadata:
43994399
languageName: node
44004400
linkType: hard
44014401

4402+
"@interchain-kit/core@npm:0.2.206":
4403+
version: 0.2.206
4404+
resolution: "@interchain-kit/core@npm:0.2.206"
4405+
dependencies:
4406+
"@chain-registry/v2": "npm:^1.71.71"
4407+
"@chain-registry/v2-keplr": "npm:^0.0.72"
4408+
"@chain-registry/v2-types": "npm:^0.53.40"
4409+
"@interchainjs/cosmos": "npm:1.9.16"
4410+
"@interchainjs/cosmos-types": "npm:1.9.16"
4411+
"@ledgerhq/hw-app-cosmos": "npm:^6.30.4"
4412+
"@ledgerhq/hw-transport": "npm:^6.31.4"
4413+
"@ledgerhq/hw-transport-webhid": "npm:^6.30.0"
4414+
"@ledgerhq/hw-transport-webusb": "npm:^6.29.4"
4415+
"@walletconnect/sign-client": "npm:^2.17.3"
4416+
"@walletconnect/types": "npm:^2.17.3"
4417+
axios: "npm:^1.7.9"
4418+
bowser: "npm:^2.11.0"
4419+
buffer: "npm:^6.0.3"
4420+
interchainjs: "npm:1.9.16"
4421+
long: "npm:^5.2.3"
4422+
checksum: 10c0/4dc297dd507b68eeb0c12ee10fab95c45f173519897027a6adb2c5ea8e5b3ab4f73d00623b12bb51ec901aad4162cd5e042c5924b45bf12a592dc0726608e823
4423+
languageName: node
4424+
linkType: hard
4425+
44024426
"@interchain-kit/core@npm:^0.0.1-beta.62, @interchain-kit/core@npm:^0.0.1-beta.64":
44034427
version: 0.0.1-beta.64
44044428
resolution: "@interchain-kit/core@npm:0.0.1-beta.64"
@@ -4453,7 +4477,7 @@ __metadata:
44534477
languageName: node
44544478
linkType: hard
44554479

4456-
"@interchain-kit/keplr-extension@npm:0.2.205, @interchain-kit/keplr-extension@npm:^0.2.1, @interchain-kit/keplr-extension@npm:^0.2.205":
4480+
"@interchain-kit/keplr-extension@npm:0.2.205, @interchain-kit/keplr-extension@npm:^0.2.1":
44574481
version: 0.2.205
44584482
resolution: "@interchain-kit/keplr-extension@npm:0.2.205"
44594483
dependencies:
@@ -4463,6 +4487,16 @@ __metadata:
44634487
languageName: node
44644488
linkType: hard
44654489

4490+
"@interchain-kit/keplr-extension@npm:0.2.206":
4491+
version: 0.2.206
4492+
resolution: "@interchain-kit/keplr-extension@npm:0.2.206"
4493+
dependencies:
4494+
"@interchain-kit/core": "npm:0.2.206"
4495+
"@keplr-wallet/provider-extension": "npm:^0.12.102"
4496+
checksum: 10c0/3ecf3dac4435699d2a0bf8d7162ef72dce335e44f9516cd39c73dff64f890cedbb28cdb5bd1882c300ecbcfb58426228ac5c5dd4204a3292b10cee3296ac49fc
4497+
languageName: node
4498+
linkType: hard
4499+
44664500
"@interchain-kit/keplr-extension@npm:^0.0.1-beta.62":
44674501
version: 0.0.1-beta.64
44684502
resolution: "@interchain-kit/keplr-extension@npm:0.0.1-beta.64"
@@ -17399,6 +17433,22 @@ __metadata:
1739917433
languageName: node
1740017434
linkType: hard
1740117435

17436+
"interchainjs@npm:1.9.16":
17437+
version: 1.9.16
17438+
resolution: "interchainjs@npm:1.9.16"
17439+
dependencies:
17440+
"@interchainjs/cosmos": "npm:1.9.16"
17441+
"@interchainjs/cosmos-types": "npm:1.9.16"
17442+
"@interchainjs/encoding": "npm:1.9.16"
17443+
"@interchainjs/pubkey": "npm:1.9.16"
17444+
"@interchainjs/types": "npm:1.9.16"
17445+
"@interchainjs/utils": "npm:1.9.16"
17446+
"@noble/hashes": "npm:^1.3.1"
17447+
decimal.js: "npm:^10.4.3"
17448+
checksum: 10c0/33a719b17bbe64f8eaadeee3fe800ae509e99e329b46583655b2db315de3a0fd9392e4ff1f577dd58f3558eb79924bbdef344c24ed23fe33ab26f04713e5df26
17449+
languageName: node
17450+
linkType: hard
17451+
1740217452
"interchainjs@npm:1.9.3":
1740317453
version: 1.9.3
1740417454
resolution: "interchainjs@npm:1.9.3"
@@ -24985,9 +25035,8 @@ __metadata:
2498525035
"@esbuild-plugins/node-globals-polyfill": "npm:^0.2.3"
2498625036
"@eslint/js": "npm:^9.9.1"
2498725037
"@hookform/resolvers": "npm:^3.3.4"
24988-
"@interchain-kit/core": "npm:^0.2.205"
24989-
"@interchain-kit/keplr-extension": "npm:^0.2.205"
24990-
"@interchainjs/utils": "npm:1.9.16"
25038+
"@interchain-kit/core": "npm:0.2.206"
25039+
"@interchain-kit/keplr-extension": "npm:0.2.206"
2499125040
"@tanstack/react-query": "npm:5.68.0"
2499225041
"@types/react": "npm:^18.3.5"
2499325042
"@types/react-dom": "npm:^18.3.0"

0 commit comments

Comments
 (0)