Skip to content

Commit 82f5c6f

Browse files
authored
Merge pull request #7818 from BitGo/WIN-8461-3
fix(sdk-coin-flr): update import transaction fee calculation to use network configuration
2 parents 14f4801 + f56a155 commit 82f5c6f

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

modules/sdk-coin-flr/src/flr.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -384,8 +384,12 @@ export class Flr extends AbstractEthLikeNewCoins {
384384
if (!_.isNil(originalParams)) {
385385
const { recipients } = originalParams;
386386

387+
// Get the P-chain import fee from network configuration
388+
const flrpCoin = coins.get(this.getFlrP());
389+
const importTxFee = (flrpCoin.network as any).txFee || '1000000';
390+
387391
// Then validate that the tx params actually equal the requested params to nano flr plus import tx fee.
388-
const originalAmount = new BigNumber(recipients[0].amount).div(1e9).plus(1e6).toFixed(0);
392+
const originalAmount = new BigNumber(recipients[0].amount).div(1e9).plus(importTxFee).toFixed(0);
389393
const originalDestination: string | undefined = recipients[0].address;
390394
const hopAmount = explainHopExportTx.outputAmount;
391395
const hopDestination = explainHopExportTx.outputs[0].address;

modules/sdk-coin-flr/test/unit/flr.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -606,8 +606,9 @@ describe('flr', function () {
606606
const hopDestinationAddress =
607607
'P-costwo15msvr27szvhhpmah0c38gcml7vm29xjh7tcek8~P-costwo1cwrdtrgf4xh80ncu7palrjw7gn4mpj0n4dxghh~P-costwo1zt9n96hey4fsvnde35n3k4kt5pu7c784dzewzd';
608608
const hopAddress = '0x28A05933dC76e4e6c25f35D5c9b2A58769700E76';
609-
const importTxFee = 1e6;
610-
const amount = 49000000000000000;
609+
const importTxFee = 1261000; // Updated to match FlarePTestnet txFee
610+
// Adjusted amount to work backwards from hop amount (50000000): 50000000 - 1261000 = 48739000 nanoFLR
611+
const amount = 48739000000000000;
611612
const txParams = {
612613
recipients: [{ amount, address: hopDestinationAddress }],
613614
wallet: wallet,
@@ -825,7 +826,7 @@ describe('flr', function () {
825826
recipients: [
826827
{
827828
address: 'P-costwo1different~P-costwo1address~P-costwo1here',
828-
amount: '49000000000000000',
829+
amount: '48739000000000000',
829830
},
830831
],
831832
};

0 commit comments

Comments
 (0)