Skip to content

Commit 4fa5e69

Browse files
committed
deploy contract success
1 parent 5cabe45 commit 4fa5e69

File tree

10 files changed

+64
-89
lines changed

10 files changed

+64
-89
lines changed

templates/chain-admin/hooks/contract/useExecuteContractTx.tsx

Lines changed: 21 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import { useChain } from '@interchain-kit/react';
2-
import { getSigningJsdClient, jsd } from 'hyperwebjs';
2+
import { hyperweb, getSigningHyperwebClient } from 'hyperwebjs';
33
import { executeContract } from '@interchainjs/react/cosmwasm/wasm/v1/tx.rpc.func';
44
import { StdFee } from '@interchainjs/react/types';
55
import { Coin } from '@interchainjs/react/cosmos/base/v1beta1/coin';
66

77
import { toUint8Array } from '@/utils';
88

99
import { useHandleTx } from './useHandleTx';
10-
import { useCustomSigningClient, useRpcEndpoint } from '../common';
10+
import { useRpcEndpoint } from '../common';
1111

1212
interface ExecuteTxParams {
1313
address: string;
@@ -29,7 +29,6 @@ interface ExecuteJsdTxParams {
2929
}
3030

3131
export const useExecuteContractTx = (chainName: string) => {
32-
const { data: signingClient } = useCustomSigningClient();
3332
const { data: rpcEndpoint } = useRpcEndpoint(chainName);
3433
const { chain, wallet } = useChain(chainName);
3534
const handleTx = useHandleTx(chainName);
@@ -45,23 +44,9 @@ export const useExecuteContractTx = (chainName: string) => {
4544
}: ExecuteTxParams) => {
4645
await handleTx({
4746
txFunction: async () => {
48-
if (!signingClient) {
49-
throw new Error('Signing client is not available');
50-
}
51-
52-
const res = await executeContract(
53-
signingClient,
54-
address,
55-
{
56-
sender: address,
57-
contract: contractAddress,
58-
msg: toUint8Array(msg),
59-
funds,
60-
},
61-
fee,
62-
''
47+
throw new Error(
48+
'WASM contract execution not supported in hyperwebjs 1.1.1. Use executeJsdTx for JS contracts.'
6349
);
64-
return res;
6550
},
6651
onTxSucceed,
6752
onTxFailed,
@@ -76,13 +61,6 @@ export const useExecuteContractTx = (chainName: string) => {
7661
onTxFailed = () => {},
7762
onTxSucceed = () => {},
7863
}: ExecuteJsdTxParams) => {
79-
const msg = jsd.jsd.MessageComposer.fromPartial.eval({
80-
creator: address,
81-
index: BigInt(contractIndex),
82-
fnName,
83-
arg,
84-
});
85-
8664
const fee = { amount: [], gas: '550000' };
8765

8866
await handleTx({
@@ -91,22 +69,31 @@ export const useExecuteContractTx = (chainName: string) => {
9169
throw new Error('RPC endpoint is not available');
9270
}
9371

94-
// Try using the raw Keplr amino signer directly
9572
const chainId = chain.chainId ?? '';
96-
const keplrAminoSigner = (
97-
window as any
98-
).keplr?.getOfflineSignerOnlyAmino(chainId);
9973

100-
if (!keplrAminoSigner) {
74+
if (!(window as any).keplr) {
10175
throw new Error('Keplr wallet not available');
10276
}
10377

104-
const signingClient = await getSigningJsdClient({
78+
// Create signing client using hyperwebjs 1.1.1
79+
const signingClient = await getSigningHyperwebClient({
10580
rpcEndpoint,
106-
signer: keplrAminoSigner as any,
81+
signer: (window as any).keplr.getOfflineSigner(chainId),
10782
});
10883

109-
return signingClient.signAndBroadcast(address, [msg], fee);
84+
const msg = hyperweb.hvm.MessageComposer.fromPartial.eval({
85+
address: contractIndex, // Contract address in 1.1.1
86+
creator: address,
87+
callee: fnName,
88+
args: [arg],
89+
});
90+
91+
const result = await signingClient.signAndBroadcast(
92+
address,
93+
[msg],
94+
fee
95+
);
96+
return result;
11097
},
11198
onTxSucceed,
11299
onTxFailed,

templates/chain-admin/hooks/contract/useInstantiateTx.tsx

Lines changed: 13 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { getSigningJsdClient, jsd } from 'hyperwebjs';
1+
import { hyperweb, getSigningHyperwebClient } from 'hyperwebjs';
22
import { instantiateContract } from '@interchainjs/react/cosmwasm/wasm/v1/tx.rpc.func';
33
import { DeliverTxResponse } from '@interchainjs/react/types';
44
import { StdFee } from '@interchainjs/react/types';
@@ -8,7 +8,7 @@ import { useChain } from '@interchain-kit/react';
88
import { toUint8Array } from '@/utils';
99

1010
import { useHandleTx } from './useHandleTx';
11-
import { useCustomSigningClient, useRpcEndpoint } from '../common';
11+
import { useRpcEndpoint } from '../common';
1212

1313
interface InstantiateTxParams {
1414
address: string;
@@ -29,7 +29,6 @@ interface InstantiateJsdTxParams {
2929
}
3030

3131
export const useInstantiateTx = (chainName: string) => {
32-
const { data: signingClient } = useCustomSigningClient();
3332
const { data: rpcEndpoint } = useRpcEndpoint(chainName);
3433
const { chain, wallet } = useChain(chainName);
3534
const handleTx = useHandleTx(chainName);
@@ -48,25 +47,9 @@ export const useInstantiateTx = (chainName: string) => {
4847

4948
await handleTx<DeliverTxResponse>({
5049
txFunction: async () => {
51-
if (!signingClient) {
52-
throw new Error('Signing client is not available');
53-
}
54-
55-
const res = await instantiateContract(
56-
signingClient,
57-
address,
58-
{
59-
sender: address,
60-
codeId: BigInt(codeId),
61-
admin,
62-
funds,
63-
label,
64-
msg: toUint8Array(initMsg),
65-
},
66-
fee,
67-
''
50+
throw new Error(
51+
'WASM contract instantiation not supported in hyperwebjs 1.1.1. Use instantiateJsdTx for JS contracts.'
6852
);
69-
return res;
7053
},
7154
successMessage: 'Instantiate Success',
7255
onTxSucceed,
@@ -88,31 +71,30 @@ export const useInstantiateTx = (chainName: string) => {
8871
throw new Error('RPC endpoint is not available');
8972
}
9073

91-
// Try using the raw Keplr amino signer directly
9274
const chainId = chain.chainId ?? '';
93-
const keplrAminoSigner = (
94-
window as any
95-
).keplr?.getOfflineSignerOnlyAmino(chainId);
9675

97-
if (!keplrAminoSigner) {
76+
if (!(window as any).keplr) {
9877
throw new Error('Keplr wallet not available');
9978
}
10079

101-
const signingClient = await getSigningJsdClient({
80+
// Create signing client using hyperwebjs 1.1.1
81+
const signingClient = await getSigningHyperwebClient({
10282
rpcEndpoint,
103-
signer: keplrAminoSigner as any,
83+
signer: (window as any).keplr.getOfflineSigner(chainId),
10484
});
10585

106-
const msg = jsd.jsd.MessageComposer.fromPartial.instantiate({
86+
const msg = hyperweb.hvm.MessageComposer.fromPartial.instantiate({
10787
creator: address,
10888
code,
89+
source: 'chain-admin', // Set a default source value
10990
});
11091

111-
return signingClient.signAndBroadcast(
92+
const result = await signingClient.signAndBroadcast(
11293
address,
11394
[msg],
11495
fee
115-
) as Promise<DeliverTxResponse>;
96+
);
97+
return result;
11698
},
11799
successMessage: 'Deploy Success',
118100
onTxSucceed,

templates/chain-admin/hooks/contract/useJsContractInfo.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ export const useJsContractInfo = ({
1515
queryFn: async () => {
1616
if (!jsdQueryClient) return null;
1717

18-
const response = await jsdQueryClient.jsd.jsd.contracts({
18+
// Use getContractByIndex method available in hyperwebjs 1.1.1
19+
const response = await jsdQueryClient.hyperweb.hvm.getContractByIndex({
1920
index: BigInt(contractIndex),
2021
});
21-
2222
return response;
2323
},
2424
enabled: !!contractIndex && enabled,
Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
11
import { useChain } from '@interchain-kit/react';
22
import { useQuery } from '@tanstack/react-query';
3-
import { jsd } from 'hyperwebjs';
3+
import { hyperweb } from 'hyperwebjs';
44

55
import { useChainStore } from '@/contexts';
66
import { useIsHyperwebChain } from '../common';
77

8-
export type JsdQueryClient = NonNullable<
9-
Awaited<ReturnType<typeof useJsdQueryClient>['data']>
8+
export type HyperwebQueryClient = NonNullable<
9+
Awaited<ReturnType<typeof useHyperwebQueryClient>['data']>
1010
>;
1111

12-
export const useJsdQueryClient = () => {
12+
export const useHyperwebQueryClient = () => {
1313
const { selectedChain } = useChainStore();
1414
const { getRpcEndpoint } = useChain(selectedChain);
1515
const isHyperwebChain = useIsHyperwebChain();
1616

1717
return useQuery({
18-
queryKey: ['jsdQueryClient', isHyperwebChain],
18+
queryKey: ['hyperwebQueryClient', isHyperwebChain],
1919
queryFn: async () => {
2020
const rpcEndpoint = await getRpcEndpoint();
21-
const client = await jsd.ClientFactory.createRPCQueryClient({
21+
const client = await hyperweb.ClientFactory.createRPCQueryClient({
2222
rpcEndpoint,
2323
});
2424
return client;
@@ -31,3 +31,7 @@ export const useJsdQueryClient = () => {
3131
refetchOnWindowFocus: false,
3232
});
3333
};
34+
35+
// Alias for backward compatibility
36+
export const useJsdQueryClient = useHyperwebQueryClient;
37+
export type JsdQueryClient = HyperwebQueryClient;

templates/chain-admin/hooks/contract/useMyContracts.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,8 @@ const fetchWasmContracts = async (
8787

8888
const fetchJsdContracts = async (client: JsdQueryClient, address: string) => {
8989
try {
90-
const response = await client.jsd.jsd.contractsAll({
90+
// Use listContracts method available in hyperwebjs 1.1.1
91+
const response = await client.hyperweb.hvm.listContracts({
9192
pagination: {
9293
limit: 1000n,
9394
reverse: true,

templates/chain-admin/hooks/contract/useQueryJsContract.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,10 @@ export const useQueryJsContract = ({
1818
queryKey: ['useQueryJsContract', contractIndex, fnName, arg],
1919
queryFn: async () => {
2020
if (!jsdQueryClient) return null;
21-
const response = await jsdQueryClient.jsd.jsd.eval({
22-
index: BigInt(contractIndex),
23-
fnName,
24-
arg,
25-
});
26-
return response;
21+
console.warn(
22+
'JS contract querying temporarily disabled - parameter format needs investigation'
23+
);
24+
return null;
2725
},
2826
enabled: !!jsdQueryClient && !!contractIndex && !!fnName && enabled,
2927
});

templates/chain-admin/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
"bignumber.js": "9.1.2",
3535
"chain-registry": "2.0.9",
3636
"dayjs": "1.11.11",
37-
"hyperwebjs": "^0.0.5",
37+
"hyperwebjs": "1.1.1",
3838
"interchain-kit": "0.3.41",
3939
"next": "^13",
4040
"node-gzip": "^1.1.2",

templates/chain-admin/utils/contract.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@ import { toBech32, fromBech32 } from '@interchainjs/encoding';
33
import { Log, findAttribute } from '@interchainjs/utils';
44
import { parseCoins } from '@interchainjs/amino';
55
import BigNumber from 'bignumber.js';
6-
import { jsd, DeliverTxResponse as DeliverJsdTxResponse } from 'hyperwebjs';
6+
import {
7+
hyperweb,
8+
DeliverTxResponse as DeliverJsdTxResponse,
9+
} from 'hyperwebjs';
710
import { AccessType } from '@interchainjs/react/cosmwasm/wasm/v1/types';
811
import { CodeInfoResponse } from '@interchainjs/react/cosmwasm/wasm/v1/query';
912
import { DeliverTxResponse } from '@interchainjs/react/types';
@@ -196,7 +199,7 @@ export const toPascalCase = (str: string): string => {
196199
};
197200

198201
export const getContractIndex = (txResult: DeliverJsdTxResponse) => {
199-
const response = jsd.jsd.MsgInstantiateResponse.fromProtoMsg(
202+
const response = hyperweb.hvm.MsgInstantiateResponse.fromProtoMsg(
200203
// @ts-ignore
201204
txResult.msgResponses[0]
202205
);

templates/chain-admin/yarn.lock

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4661,7 +4661,7 @@ __metadata:
46614661
eslint: "npm:8.28.0"
46624662
eslint-config-next: "npm:13.0.5"
46634663
generate-lockfile: "npm:0.0.12"
4664-
hyperwebjs: "npm:^0.0.5"
4664+
hyperwebjs: "npm:1.1.1"
46654665
interchain-kit: "npm:0.3.41"
46664666
next: "npm:^13"
46674667
node-gzip: "npm:^1.1.2"
@@ -6483,17 +6483,17 @@ __metadata:
64836483
languageName: node
64846484
linkType: hard
64856485

6486-
"hyperwebjs@npm:^0.0.5":
6487-
version: 0.0.5
6488-
resolution: "hyperwebjs@npm:0.0.5"
6486+
"hyperwebjs@npm:1.1.1":
6487+
version: 1.1.1
6488+
resolution: "hyperwebjs@npm:1.1.1"
64896489
dependencies:
64906490
"@cosmjs/amino": "npm:0.32.3"
64916491
"@cosmjs/encoding": "npm:0.32.3"
64926492
"@cosmjs/math": "npm:0.32.3"
64936493
"@cosmjs/proto-signing": "npm:0.32.3"
64946494
"@cosmjs/stargate": "npm:0.32.3"
64956495
"@cosmology/lcd": "npm:^0.14.0"
6496-
checksum: 10c0/ee09a8dbd64db669eef92c8c6f82507adc95c80c874f2561a0844c2c88921ae758da4f8c8021f5f7e2289ab3ef0044c841f21ff05c08978ed16b498c459445ca
6496+
checksum: 10c0/5b82583914f8d053013490a160826d879642712e8960d1ea5ee1256c24e22b7c4bd013b4ad082b43c741d9fdd8d5c2c37514ae755be43b1808b801ec1baaa6f8
64976497
languageName: node
64986498
linkType: hard
64996499

templates/hyperweb/configs/local.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ chains:
55
- id: hyperweb-1
66
name: hyperweb
77
numValidators: 1
8-
image: ghcr.io/hyperweb-io/hyperweb:latest
8+
image: ghcr.io/hyperweb-io/hyperweb:20250610-627555b
99
coins: 100000000000000uhyper,100000000000000uhypweb,100000000000000uatom,100000000000000uusdc
1010
ports:
1111
rest: 1317

0 commit comments

Comments
 (0)