Skip to content

Commit 9c952b0

Browse files
committed
Merge branch 'vite-react-issue' into vite-react
2 parents c566375 + 5da66a4 commit 9c952b0

File tree

3 files changed

+106
-60
lines changed

3 files changed

+106
-60
lines changed

examples/vite-react/package.json

+3-4
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",
@@ -41,4 +40,4 @@
4140
"vite": "^5.4.2"
4241
},
4342
"packageManager": "[email protected]"
44-
}
43+
}

examples/vite-react/src/App.tsx

+17-19
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,16 @@ 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-
REST_ENDPOINT,
2726
DENOM,
2827
DENOM_DISPLAY,
2928
DECIMAL,
29+
RPC_ENDPOINT,
3030
} from './utils/constants';
3131
import { chain as cosmoshubChain, assetList as cosmoshubAssetList } from '@chain-registry/v2/mainnet/cosmoshub'
3232
import { WalletManager } from '@interchain-kit/core'
3333
import { keplrWallet } from '@interchain-kit/keplr-extension'
3434
import { createSend } from "interchainjs/cosmos/bank/v1beta1/tx.rpc.func";
35+
import { createGetBalance } from "interchainjs/cosmos/bank/v1beta1/query.rpc.func";
3536

3637
function App() {
3738
const [address, setAddress] = useState('');
@@ -56,7 +57,15 @@ function App() {
5657
const walletManager = await WalletManager.create(
5758
[cosmoshubChain],
5859
[cosmoshubAssetList],
59-
[keplrWallet]
60+
[keplrWallet],
61+
{},
62+
{
63+
endpoints: {
64+
cosmoshub: {
65+
rpc: [RPC_ENDPOINT],
66+
},
67+
}
68+
}
6069
)
6170
setWalletManager(walletManager)
6271
})()
@@ -67,23 +76,12 @@ function App() {
6776
queryFn: async () => {
6877
if (!address) return null;
6978
try {
70-
const response = await fetch(
71-
`${REST_ENDPOINT}/cosmos/bank/v1beta1/balances/${address}`
72-
);
73-
if (!response.ok) {
74-
throw new Error('Failed to fetch balance');
75-
}
76-
const data = await response.json();
77-
// Log the response to see what we're getting
78-
console.log('Balance response:', data);
79-
if (!data.balances) {
80-
return 0;
81-
}
82-
const atomBalance = data.balances.find((b: any) => b.denom === DENOM);
83-
if (!atomBalance) {
84-
return 0;
85-
}
86-
return Number(atomBalance.amount) / Math.pow(10, DECIMAL);
79+
const balanceQuery = createGetBalance(RPC_ENDPOINT);
80+
const { balance: atomBalance } = await balanceQuery({
81+
address,
82+
denom: DENOM,
83+
});
84+
return Number(atomBalance?.amount || 0) / Math.pow(10, DECIMAL);
8785
} catch (error) {
8886
console.error('Error fetching balance:', error);
8987
toast({

yarn.lock

+86-37
Original file line numberDiff line numberDiff line change
@@ -4237,6 +4237,40 @@ __metadata:
42374237
languageName: unknown
42384238
linkType: soft
42394239

4240+
"@hyperweb/vite-react@workspace:examples/vite-react":
4241+
version: 0.0.0-use.local
4242+
resolution: "@hyperweb/vite-react@workspace:examples/vite-react"
4243+
dependencies:
4244+
"@chain-registry/v2": "npm:^1.71.71"
4245+
"@chakra-ui/icons": "npm:^2.1.1"
4246+
"@chakra-ui/react": "npm:^2.8.2"
4247+
"@emotion/react": "npm:^11.11.4"
4248+
"@emotion/styled": "npm:^11.11.0"
4249+
"@esbuild-plugins/node-globals-polyfill": "npm:^0.2.3"
4250+
"@eslint/js": "npm:^9.9.1"
4251+
"@hookform/resolvers": "npm:^3.3.4"
4252+
"@interchain-kit/core": "npm:0.2.206"
4253+
"@interchain-kit/keplr-extension": "npm:0.2.206"
4254+
"@tanstack/react-query": "npm:5.68.0"
4255+
"@types/react": "npm:^18.3.5"
4256+
"@types/react-dom": "npm:^18.3.0"
4257+
"@vitejs/plugin-react": "npm:^4.3.1"
4258+
buffer: "npm:^6.0.3"
4259+
eslint: "npm:^9.9.1"
4260+
eslint-plugin-react-hooks: "npm:^5.1.0-rc.0"
4261+
eslint-plugin-react-refresh: "npm:^0.4.11"
4262+
framer-motion: "npm:^11.0.8"
4263+
globals: "npm:^15.9.0"
4264+
react: "npm:^18.3.1"
4265+
react-dom: "npm:^18.3.1"
4266+
react-hook-form: "npm:^7.51.0"
4267+
typescript: "npm:^5.5.3"
4268+
typescript-eslint: "npm:^8.3.0"
4269+
vite: "npm:^5.4.2"
4270+
zod: "npm:^3.22.4"
4271+
languageName: unknown
4272+
linkType: soft
4273+
42404274
"@hyperweb/vote-proposal@workspace:examples/vote-proposal":
42414275
version: 0.0.0-use.local
42424276
resolution: "@hyperweb/vote-proposal@workspace:examples/vote-proposal"
@@ -4375,7 +4409,7 @@ __metadata:
43754409
languageName: node
43764410
linkType: hard
43774411

4378-
"@interchain-kit/core@npm:0.2.205, @interchain-kit/core@npm:^0.2.1, @interchain-kit/core@npm:^0.2.205":
4412+
"@interchain-kit/core@npm:0.2.205, @interchain-kit/core@npm:^0.2.1":
43794413
version: 0.2.205
43804414
resolution: "@interchain-kit/core@npm:0.2.205"
43814415
dependencies:
@@ -4399,6 +4433,30 @@ __metadata:
43994433
languageName: node
44004434
linkType: hard
44014435

4436+
"@interchain-kit/core@npm:0.2.206":
4437+
version: 0.2.206
4438+
resolution: "@interchain-kit/core@npm:0.2.206"
4439+
dependencies:
4440+
"@chain-registry/v2": "npm:^1.71.71"
4441+
"@chain-registry/v2-keplr": "npm:^0.0.72"
4442+
"@chain-registry/v2-types": "npm:^0.53.40"
4443+
"@interchainjs/cosmos": "npm:1.9.16"
4444+
"@interchainjs/cosmos-types": "npm:1.9.16"
4445+
"@ledgerhq/hw-app-cosmos": "npm:^6.30.4"
4446+
"@ledgerhq/hw-transport": "npm:^6.31.4"
4447+
"@ledgerhq/hw-transport-webhid": "npm:^6.30.0"
4448+
"@ledgerhq/hw-transport-webusb": "npm:^6.29.4"
4449+
"@walletconnect/sign-client": "npm:^2.17.3"
4450+
"@walletconnect/types": "npm:^2.17.3"
4451+
axios: "npm:^1.7.9"
4452+
bowser: "npm:^2.11.0"
4453+
buffer: "npm:^6.0.3"
4454+
interchainjs: "npm:1.9.16"
4455+
long: "npm:^5.2.3"
4456+
checksum: 10c0/4dc297dd507b68eeb0c12ee10fab95c45f173519897027a6adb2c5ea8e5b3ab4f73d00623b12bb51ec901aad4162cd5e042c5924b45bf12a592dc0726608e823
4457+
languageName: node
4458+
linkType: hard
4459+
44024460
"@interchain-kit/core@npm:^0.0.1-beta.62, @interchain-kit/core@npm:^0.0.1-beta.64":
44034461
version: 0.0.1-beta.64
44044462
resolution: "@interchain-kit/core@npm:0.0.1-beta.64"
@@ -4453,7 +4511,7 @@ __metadata:
44534511
languageName: node
44544512
linkType: hard
44554513

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":
4514+
"@interchain-kit/keplr-extension@npm:0.2.205, @interchain-kit/keplr-extension@npm:^0.2.1":
44574515
version: 0.2.205
44584516
resolution: "@interchain-kit/keplr-extension@npm:0.2.205"
44594517
dependencies:
@@ -4463,6 +4521,16 @@ __metadata:
44634521
languageName: node
44644522
linkType: hard
44654523

4524+
"@interchain-kit/keplr-extension@npm:0.2.206":
4525+
version: 0.2.206
4526+
resolution: "@interchain-kit/keplr-extension@npm:0.2.206"
4527+
dependencies:
4528+
"@interchain-kit/core": "npm:0.2.206"
4529+
"@keplr-wallet/provider-extension": "npm:^0.12.102"
4530+
checksum: 10c0/3ecf3dac4435699d2a0bf8d7162ef72dce335e44f9516cd39c73dff64f890cedbb28cdb5bd1882c300ecbcfb58426228ac5c5dd4204a3292b10cee3296ac49fc
4531+
languageName: node
4532+
linkType: hard
4533+
44664534
"@interchain-kit/keplr-extension@npm:^0.0.1-beta.62":
44674535
version: 0.0.1-beta.64
44684536
resolution: "@interchain-kit/keplr-extension@npm:0.0.1-beta.64"
@@ -17399,6 +17467,22 @@ __metadata:
1739917467
languageName: node
1740017468
linkType: hard
1740117469

17470+
"interchainjs@npm:1.9.16":
17471+
version: 1.9.16
17472+
resolution: "interchainjs@npm:1.9.16"
17473+
dependencies:
17474+
"@interchainjs/cosmos": "npm:1.9.16"
17475+
"@interchainjs/cosmos-types": "npm:1.9.16"
17476+
"@interchainjs/encoding": "npm:1.9.16"
17477+
"@interchainjs/pubkey": "npm:1.9.16"
17478+
"@interchainjs/types": "npm:1.9.16"
17479+
"@interchainjs/utils": "npm:1.9.16"
17480+
"@noble/hashes": "npm:^1.3.1"
17481+
decimal.js: "npm:^10.4.3"
17482+
checksum: 10c0/33a719b17bbe64f8eaadeee3fe800ae509e99e329b46583655b2db315de3a0fd9392e4ff1f577dd58f3558eb79924bbdef344c24ed23fe33ab26f04713e5df26
17483+
languageName: node
17484+
linkType: hard
17485+
1740217486
"interchainjs@npm:1.9.3":
1740317487
version: 1.9.3
1740417488
resolution: "interchainjs@npm:1.9.3"
@@ -24973,41 +25057,6 @@ __metadata:
2497325057
languageName: node
2497425058
linkType: hard
2497525059

24976-
"vite-react@workspace:examples/vite-react":
24977-
version: 0.0.0-use.local
24978-
resolution: "vite-react@workspace:examples/vite-react"
24979-
dependencies:
24980-
"@chain-registry/v2": "npm:^1.71.71"
24981-
"@chakra-ui/icons": "npm:^2.1.1"
24982-
"@chakra-ui/react": "npm:^2.8.2"
24983-
"@emotion/react": "npm:^11.11.4"
24984-
"@emotion/styled": "npm:^11.11.0"
24985-
"@esbuild-plugins/node-globals-polyfill": "npm:^0.2.3"
24986-
"@eslint/js": "npm:^9.9.1"
24987-
"@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"
24991-
"@tanstack/react-query": "npm:5.68.0"
24992-
"@types/react": "npm:^18.3.5"
24993-
"@types/react-dom": "npm:^18.3.0"
24994-
"@vitejs/plugin-react": "npm:^4.3.1"
24995-
buffer: "npm:^6.0.3"
24996-
eslint: "npm:^9.9.1"
24997-
eslint-plugin-react-hooks: "npm:^5.1.0-rc.0"
24998-
eslint-plugin-react-refresh: "npm:^0.4.11"
24999-
framer-motion: "npm:^11.0.8"
25000-
globals: "npm:^15.9.0"
25001-
react: "npm:^18.3.1"
25002-
react-dom: "npm:^18.3.1"
25003-
react-hook-form: "npm:^7.51.0"
25004-
typescript: "npm:^5.5.3"
25005-
typescript-eslint: "npm:^8.3.0"
25006-
vite: "npm:^5.4.2"
25007-
zod: "npm:^3.22.4"
25008-
languageName: unknown
25009-
linkType: soft
25010-
2501125060
"vite@npm:^5.4.2":
2501225061
version: 5.4.14
2501325062
resolution: "vite@npm:5.4.14"

0 commit comments

Comments
 (0)