Skip to content

Commit 0cb5695

Browse files
committed
fix(sdk-coin-flrp): fix flrp import to P fee value
Ticket: WIN-8461
1 parent 6bcfcb9 commit 0cb5695

File tree

3 files changed

+11
-4
lines changed

3 files changed

+11
-4
lines changed

modules/sdk-coin-flrp/src/lib/ImportInPTxBuilder.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,13 @@ export class ImportInPTxBuilder extends AtomicTransactionBuilder {
132132

133133
// Calculate fee from transaction fee settings
134134
const fee = BigInt(this.transaction.fee.fee);
135+
136+
// Validate that totalAmount is sufficient to cover the fee (matching AVAX validation)
137+
// This ensures we don't create transactions with insufficient funds
138+
if (totalAmount < fee) {
139+
throw new BuildTransactionError(`Utxo outputs get ${totalAmount.toString()} and ${fee.toString()} is required`);
140+
}
141+
135142
const outputAmount = totalAmount - fee;
136143

137144
// Create the output for P-chain (TransferableOutput with TransferOutput)

modules/sdk-coin-flrp/test/unit/lib/importInPTxBuilder.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ describe('Flrp Import In P Tx Builder', () => {
1313
describe('default fee', () => {
1414
const FIXED_FEE = (coinConfig.network as FlareNetwork).txFee;
1515

16-
it('should set fixedFee (1000000) by default in constructor', () => {
16+
it('should set fixedFee (1261000) by default in constructor', () => {
1717
const txBuilder = factory.getImportInPBuilder();
18-
// The fixedFee should be set from network.txFee = '1000000'
18+
// The fixedFee should be set from network.txFee = '1261000'
1919
const transaction = (txBuilder as any).transaction;
2020
transaction._fee.fee.should.equal(FIXED_FEE);
2121
});

modules/statics/src/networks.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1942,7 +1942,7 @@ export class FlareP extends Mainnet implements FlareNetwork {
19421942
hrp = 'flare';
19431943
alias = 'P';
19441944
vm = 'platformvm';
1945-
txFee = '1000000'; // defaults
1945+
txFee = '1261000'; // FLR P-chain import requires higher fee than base txFee
19461946
maxImportFee = '10000000'; // defaults
19471947
createSubnetTx = '100000000'; // defaults
19481948
createChainTx = '100000000'; // defaults
@@ -1969,7 +1969,7 @@ export class FlarePTestnet extends Testnet implements FlareNetwork {
19691969
alias = 'P';
19701970
assetId = 'fxMAKpBQQpFedrUhWMsDYfCUJxdUw4mneTczKBzNg3rc2JUub';
19711971
vm = 'platformvm';
1972-
txFee = '1000000'; // defaults
1972+
txFee = '1261000'; // FLR P-chain import requires higher fee than base txFee
19731973
maxImportFee = '10000000'; // defaults
19741974
createSubnetTx = '100000000'; // defaults
19751975
createChainTx = '100000000'; // defaults

0 commit comments

Comments
 (0)