Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion modules/sdk-coin-flr/src/flr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
7 changes: 4 additions & 3 deletions modules/sdk-coin-flr/test/unit/flr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -825,7 +826,7 @@ describe('flr', function () {
recipients: [
{
address: 'P-costwo1different~P-costwo1address~P-costwo1here',
amount: '49000000000000000',
amount: '48739000000000000',
},
],
};
Expand Down