diff --git a/modules/sdk-coin-flr/src/flr.ts b/modules/sdk-coin-flr/src/flr.ts index 4961932fc0..1915a740d3 100644 --- a/modules/sdk-coin-flr/src/flr.ts +++ b/modules/sdk-coin-flr/src/flr.ts @@ -384,8 +384,12 @@ export class Flr extends AbstractEthLikeNewCoins { if (!_.isNil(originalParams)) { const { recipients } = originalParams; + // Get the P-chain import fee from network configuration + const flrpCoin = coins.get(this.getFlrP()); + const importTxFee = (flrpCoin.network as any).txFee || '1000000'; + // Then validate that the tx params actually equal the requested params to nano flr plus import tx fee. - const originalAmount = new BigNumber(recipients[0].amount).div(1e9).plus(1e6).toFixed(0); + const originalAmount = new BigNumber(recipients[0].amount).div(1e9).plus(importTxFee).toFixed(0); const originalDestination: string | undefined = recipients[0].address; const hopAmount = explainHopExportTx.outputAmount; const hopDestination = explainHopExportTx.outputs[0].address; diff --git a/modules/sdk-coin-flr/test/unit/flr.ts b/modules/sdk-coin-flr/test/unit/flr.ts index 69fc40a37f..e05256f5da 100644 --- a/modules/sdk-coin-flr/test/unit/flr.ts +++ b/modules/sdk-coin-flr/test/unit/flr.ts @@ -606,8 +606,9 @@ describe('flr', function () { const hopDestinationAddress = 'P-costwo15msvr27szvhhpmah0c38gcml7vm29xjh7tcek8~P-costwo1cwrdtrgf4xh80ncu7palrjw7gn4mpj0n4dxghh~P-costwo1zt9n96hey4fsvnde35n3k4kt5pu7c784dzewzd'; const hopAddress = '0x28A05933dC76e4e6c25f35D5c9b2A58769700E76'; - const importTxFee = 1e6; - const amount = 49000000000000000; + const importTxFee = 1261000; // Updated to match FlarePTestnet txFee + // Adjusted amount to work backwards from hop amount (50000000): 50000000 - 1261000 = 48739000 nanoFLR + const amount = 48739000000000000; const txParams = { recipients: [{ amount, address: hopDestinationAddress }], wallet: wallet, @@ -825,7 +826,7 @@ describe('flr', function () { recipients: [ { address: 'P-costwo1different~P-costwo1address~P-costwo1here', - amount: '49000000000000000', + amount: '48739000000000000', }, ], };