Skip to content

Commit

Permalink
remove checks
Browse files Browse the repository at this point in the history
  • Loading branch information
jonator committed May 31, 2024
1 parent ba8b626 commit 8273e87
Showing 1 changed file with 8 additions and 20 deletions.
28 changes: 8 additions & 20 deletions packages/tx/src/gas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -360,8 +360,6 @@ export async function getGasFeeAmount({
// Check if this balance is not enough to pay the fee, if so skip.
if (new Dec(feeAmount).gt(new Dec(spentFeeBalance.amount))) continue;

const isLastFeeBalance =
spentFeeBalance.denom === spentFeeBalances.slice(-1)[0].denom;
const spentAmount =
coinsSpent.find(({ denom }) => denom === spentFeeBalance.denom)?.amount ||
"0";
Expand All @@ -370,24 +368,14 @@ export async function getGasFeeAmount({
new Dec(spentFeeBalance.amount)
);

if (isLastFeeBalance && isBalanceNeededForTx) {
// the coins spent in this transaction exceeds the amount needed for fee
return [
{
amount: feeAmount,
denom: spentFeeBalance.denom,
isNeededForTx: true,
},
];
} else if (!isBalanceNeededForTx) {
return [
{
amount: feeAmount,
denom: spentFeeBalance.denom,
},
];
}

// the coins spent in this transaction exceeds the amount needed for fee
return [
{
amount: feeAmount,
denom: spentFeeBalance.denom,
isNeededForTx: isBalanceNeededForTx,
},
];
// keep trying with other balances
}

Expand Down

0 comments on commit 8273e87

Please sign in to comment.