Skip to content

Commit

Permalink
Merge pull request #106 from javiersuweijie/fix/classic-gas-tax
Browse files Browse the repository at this point in the history
fix: tax for multi msgsend tx
  • Loading branch information
tuky191 committed Aug 28, 2024
2 parents 47dcff2 + 21ed5dc commit fac9f53
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
15 changes: 8 additions & 7 deletions eth/src/Relayer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ export class Relayer {
monitoringDatas: MonitoringData[],
sequence: number
): Promise<RelayData | null> {
let amount, denom;
let tax: Coins = new Coins([]);
const msgs: Msg[] = monitoringDatas.reduce(
(msgs: Msg[], data: MonitoringData) => {
const fromAddr = this.Wallet.key.accAddress;
Expand All @@ -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;
Expand Down Expand Up @@ -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({
Expand Down
1 change: 1 addition & 0 deletions eth/src/Shuttle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)));

Expand Down

0 comments on commit fac9f53

Please sign in to comment.