From 0cb569532a1868f7992e60babb323a7ebc4bea1c Mon Sep 17 00:00:00 2001 From: Kashif Jamil Date: Mon, 29 Dec 2025 23:29:00 +0530 Subject: [PATCH] fix(sdk-coin-flrp): fix flrp import to P fee value Ticket: WIN-8461 --- modules/sdk-coin-flrp/src/lib/ImportInPTxBuilder.ts | 7 +++++++ modules/sdk-coin-flrp/test/unit/lib/importInPTxBuilder.ts | 4 ++-- modules/statics/src/networks.ts | 4 ++-- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/modules/sdk-coin-flrp/src/lib/ImportInPTxBuilder.ts b/modules/sdk-coin-flrp/src/lib/ImportInPTxBuilder.ts index 73e102facc..bebffc97a5 100644 --- a/modules/sdk-coin-flrp/src/lib/ImportInPTxBuilder.ts +++ b/modules/sdk-coin-flrp/src/lib/ImportInPTxBuilder.ts @@ -132,6 +132,13 @@ export class ImportInPTxBuilder extends AtomicTransactionBuilder { // Calculate fee from transaction fee settings const fee = BigInt(this.transaction.fee.fee); + + // Validate that totalAmount is sufficient to cover the fee (matching AVAX validation) + // This ensures we don't create transactions with insufficient funds + if (totalAmount < fee) { + throw new BuildTransactionError(`Utxo outputs get ${totalAmount.toString()} and ${fee.toString()} is required`); + } + const outputAmount = totalAmount - fee; // Create the output for P-chain (TransferableOutput with TransferOutput) diff --git a/modules/sdk-coin-flrp/test/unit/lib/importInPTxBuilder.ts b/modules/sdk-coin-flrp/test/unit/lib/importInPTxBuilder.ts index 117e5c7c73..24d967ef87 100644 --- a/modules/sdk-coin-flrp/test/unit/lib/importInPTxBuilder.ts +++ b/modules/sdk-coin-flrp/test/unit/lib/importInPTxBuilder.ts @@ -13,9 +13,9 @@ describe('Flrp Import In P Tx Builder', () => { describe('default fee', () => { const FIXED_FEE = (coinConfig.network as FlareNetwork).txFee; - it('should set fixedFee (1000000) by default in constructor', () => { + it('should set fixedFee (1261000) by default in constructor', () => { const txBuilder = factory.getImportInPBuilder(); - // The fixedFee should be set from network.txFee = '1000000' + // The fixedFee should be set from network.txFee = '1261000' const transaction = (txBuilder as any).transaction; transaction._fee.fee.should.equal(FIXED_FEE); }); diff --git a/modules/statics/src/networks.ts b/modules/statics/src/networks.ts index c15a6981ad..cd8b84092c 100644 --- a/modules/statics/src/networks.ts +++ b/modules/statics/src/networks.ts @@ -1942,7 +1942,7 @@ export class FlareP extends Mainnet implements FlareNetwork { hrp = 'flare'; alias = 'P'; vm = 'platformvm'; - txFee = '1000000'; // defaults + txFee = '1261000'; // FLR P-chain import requires higher fee than base txFee maxImportFee = '10000000'; // defaults createSubnetTx = '100000000'; // defaults createChainTx = '100000000'; // defaults @@ -1969,7 +1969,7 @@ export class FlarePTestnet extends Testnet implements FlareNetwork { alias = 'P'; assetId = 'fxMAKpBQQpFedrUhWMsDYfCUJxdUw4mneTczKBzNg3rc2JUub'; vm = 'platformvm'; - txFee = '1000000'; // defaults + txFee = '1261000'; // FLR P-chain import requires higher fee than base txFee maxImportFee = '10000000'; // defaults createSubnetTx = '100000000'; // defaults createChainTx = '100000000'; // defaults