11import { useChain } from '@interchain-kit/react' ;
2- import { getSigningJsdClient , jsd } from 'hyperwebjs' ;
2+ import { hyperweb , getSigningHyperwebClient } from 'hyperwebjs' ;
33import { executeContract } from '@interchainjs/react/cosmwasm/wasm/v1/tx.rpc.func' ;
44import { StdFee } from '@interchainjs/react/types' ;
55import { Coin } from '@interchainjs/react/cosmos/base/v1beta1/coin' ;
66
77import { toUint8Array } from '@/utils' ;
88
99import { useHandleTx } from './useHandleTx' ;
10- import { useCustomSigningClient , useRpcEndpoint } from '../common' ;
10+ import { useRpcEndpoint } from '../common' ;
1111
1212interface ExecuteTxParams {
1313 address : string ;
@@ -29,7 +29,6 @@ interface ExecuteJsdTxParams {
2929}
3030
3131export 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,
0 commit comments