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
7 changes: 7 additions & 0 deletions modules/sdk-coin-flrp/src/lib/ImportInPTxBuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions modules/sdk-coin-flrp/test/unit/lib/importInPTxBuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
Expand Down
4 changes: 2 additions & 2 deletions modules/statics/src/networks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down