1
1
import { useChain } from '@interchain-kit/react' ;
2
- import { getSigningJsdClient , jsd } from 'hyperwebjs' ;
2
+ import { hyperweb , getSigningHyperwebClient } from 'hyperwebjs' ;
3
3
import { executeContract } from '@interchainjs/react/cosmwasm/wasm/v1/tx.rpc.func' ;
4
4
import { StdFee } from '@interchainjs/react/types' ;
5
5
import { Coin } from '@interchainjs/react/cosmos/base/v1beta1/coin' ;
6
6
7
7
import { toUint8Array } from '@/utils' ;
8
8
9
9
import { useHandleTx } from './useHandleTx' ;
10
- import { useCustomSigningClient , useRpcEndpoint } from '../common' ;
10
+ import { useRpcEndpoint } from '../common' ;
11
11
12
12
interface ExecuteTxParams {
13
13
address : string ;
@@ -29,7 +29,6 @@ interface ExecuteJsdTxParams {
29
29
}
30
30
31
31
export const useExecuteContractTx = ( chainName : string ) => {
32
- const { data : signingClient } = useCustomSigningClient ( ) ;
33
32
const { data : rpcEndpoint } = useRpcEndpoint ( chainName ) ;
34
33
const { chain, wallet } = useChain ( chainName ) ;
35
34
const handleTx = useHandleTx ( chainName ) ;
@@ -45,23 +44,9 @@ export const useExecuteContractTx = (chainName: string) => {
45
44
} : ExecuteTxParams ) => {
46
45
await handleTx ( {
47
46
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.'
63
49
) ;
64
- return res ;
65
50
} ,
66
51
onTxSucceed,
67
52
onTxFailed,
@@ -76,13 +61,6 @@ export const useExecuteContractTx = (chainName: string) => {
76
61
onTxFailed = ( ) => { } ,
77
62
onTxSucceed = ( ) => { } ,
78
63
} : ExecuteJsdTxParams ) => {
79
- const msg = jsd . jsd . MessageComposer . fromPartial . eval ( {
80
- creator : address ,
81
- index : BigInt ( contractIndex ) ,
82
- fnName,
83
- arg,
84
- } ) ;
85
-
86
64
const fee = { amount : [ ] , gas : '550000' } ;
87
65
88
66
await handleTx ( {
@@ -91,22 +69,31 @@ export const useExecuteContractTx = (chainName: string) => {
91
69
throw new Error ( 'RPC endpoint is not available' ) ;
92
70
}
93
71
94
- // Try using the raw Keplr amino signer directly
95
72
const chainId = chain . chainId ?? '' ;
96
- const keplrAminoSigner = (
97
- window as any
98
- ) . keplr ?. getOfflineSignerOnlyAmino ( chainId ) ;
99
73
100
- if ( ! keplrAminoSigner ) {
74
+ if ( ! ( window as any ) . keplr ) {
101
75
throw new Error ( 'Keplr wallet not available' ) ;
102
76
}
103
77
104
- const signingClient = await getSigningJsdClient ( {
78
+ // Create signing client using hyperwebjs 1.1.1
79
+ const signingClient = await getSigningHyperwebClient ( {
105
80
rpcEndpoint,
106
- signer : keplrAminoSigner as any ,
81
+ signer : ( window as any ) . keplr . getOfflineSigner ( chainId ) ,
107
82
} ) ;
108
83
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 ;
110
97
} ,
111
98
onTxSucceed,
112
99
onTxFailed,
0 commit comments