@@ -62,6 +62,7 @@ interface MsgBroadcasterWithPkOptions {
6262 useRest ?: boolean
6363 txTimeout ?: number // blocks to wait for tx to be included in a block
6464 gasBufferCoefficient ?: number
65+ txTimeoutOnFeeDelegation ?: boolean
6566}
6667
6768/**
@@ -83,6 +84,8 @@ export class MsgBroadcasterWithPk {
8384
8485 public simulateTx : boolean = false
8586
87+ public txTimeoutOnFeeDelegation : boolean = false
88+
8689 public useRest : boolean = false
8790
8891 public gasBufferCoefficient : number = 1.1
@@ -106,6 +109,8 @@ export class MsgBroadcasterWithPk {
106109 options . privateKey instanceof PrivateKey
107110 ? options . privateKey
108111 : PrivateKey . fromHex ( options . privateKey )
112+ this . txTimeoutOnFeeDelegation =
113+ options . txTimeoutOnFeeDelegation || this . txTimeoutOnFeeDelegation
109114 }
110115
111116 /**
@@ -141,7 +146,14 @@ export class MsgBroadcasterWithPk {
141146 * @returns {string } transaction hash
142147 */
143148 async broadcastWithFeeDelegation ( transaction : MsgBroadcasterTxOptions ) {
144- const { simulateTx, privateKey, ethereumChainId, endpoints } = this
149+ const {
150+ simulateTx,
151+ privateKey,
152+ ethereumChainId,
153+ endpoints,
154+ txTimeoutOnFeeDelegation,
155+ txTimeout,
156+ } = this
145157
146158 const ethereumWallet = this . privateKey . toHex ( )
147159
@@ -167,6 +179,19 @@ export class MsgBroadcasterWithPk {
167179 throw new GeneralException ( new Error ( 'Please provide ethereumChainId' ) )
168180 }
169181
182+ let timeoutHeight = undefined
183+
184+ if ( txTimeoutOnFeeDelegation ) {
185+ const latestBlock = await new ChainGrpcTendermintApi (
186+ endpoints . grpc ,
187+ ) . fetchLatestBlock ( )
188+ const latestHeight = latestBlock ! . header ! . height
189+
190+ timeoutHeight = new BigNumberInBase ( latestHeight )
191+ . plus ( txTimeout )
192+ . toNumber ( )
193+ }
194+
170195 const transactionApi = new IndexerGrpcWeb3GwApi ( endpoints . indexer )
171196 const txResponse = await transactionApi . prepareTxRequest ( {
172197 memo : tx . memo ,
@@ -175,6 +200,7 @@ export class MsgBroadcasterWithPk {
175200 chainId : ethereumChainId ,
176201 gasLimit : getGasPriceBasedOnMessage ( msgs ) ,
177202 estimateGas : simulateTx || false ,
203+ timeoutHeight,
178204 } )
179205
180206 const signature = await privateKey . signTypedData (
@@ -404,9 +430,7 @@ export class MsgBroadcasterWithPk {
404430 ) . fetchLatestBlock ( )
405431 const latestHeight = latestBlock ! . header ! . height
406432
407- return new BigNumberInBase ( latestHeight ) . plus (
408- txTimeout ,
409- )
433+ return new BigNumberInBase ( latestHeight ) . plus ( txTimeout )
410434 }
411435
412436 const latestBlock = await new ChainGrpcTendermintApi (
0 commit comments