From 21ed5dc230dc440f8e4ab055228adc067229861b Mon Sep 17 00:00:00 2001 From: javiersuweijie Date: Wed, 28 Aug 2024 20:41:36 +0800 Subject: [PATCH] fix: tax for multi msgsend tx --- eth/src/Relayer.ts | 15 ++++++++------- eth/src/Shuttle.ts | 1 + 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/eth/src/Relayer.ts b/eth/src/Relayer.ts index 61505cd..389d10d 100644 --- a/eth/src/Relayer.ts +++ b/eth/src/Relayer.ts @@ -81,7 +81,7 @@ export class Relayer { monitoringDatas: MonitoringData[], sequence: number ): Promise { - let amount, denom; + let tax: Coins = new Coins([]); const msgs: Msg[] = monitoringDatas.reduce( (msgs: Msg[], data: MonitoringData) => { const fromAddr = this.Wallet.key.accAddress; @@ -96,12 +96,16 @@ export class Relayer { return msgs; } - amount = data.amount.slice(0, data.amount.length - 12); + const amount = data.amount.slice(0, data.amount.length - 12); const info = data.terraAssetInfo; if (info.denom) { - denom = info.denom; - + const denom = info.denom; + tax = tax.add( + new Coins([new Coin(denom, amount)]) + .mul(TERRA_TAX_RATE) + .toIntCeilCoins() + ); msgs.push(new MsgSend(fromAddr, toAddr, [new Coin(denom, amount)])); } else if (info.contract_address && !info.is_eth_asset) { const contract_address = info.contract_address; @@ -155,9 +159,6 @@ export class Relayer { let fees = Coins.fromString(TERRA_GAS_PRICE) .mul(TERRA_SEND_GAS) .toIntCeilCoins(); - const tax = new Coins([new Coin(denom, amount)]) - .mul(TERRA_TAX_RATE) - .toIntCeilCoins(); fees = fees.add(tax); const tx = await this.Wallet.createAndSignTx({ diff --git a/eth/src/Shuttle.ts b/eth/src/Shuttle.ts index f072238..f4d69eb 100644 --- a/eth/src/Shuttle.ts +++ b/eth/src/Shuttle.ts @@ -273,6 +273,7 @@ class Shuttle { if (tx === null) { if (now - relayData.createdAt > 1000 * 60) { + console.log('[re-submit tx]', relayData.tx, relayData.txHash); // tx not found in the block for a minute, await this.relayer.relay(Tx.fromData(JSON.parse(relayData.tx)));