Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: handle exceeding maximum inputs when funding a transaction #2822

Merged
merged 23 commits into from
Aug 7, 2024
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
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
5 changes: 5 additions & 0 deletions .changeset/honest-fishes-mix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@fuel-ts/account": patch
---
mvares marked this conversation as resolved.
Show resolved Hide resolved

chore: handle exceeding maximum inputs when funding a transaction
13 changes: 13 additions & 0 deletions packages/account/src/account.ts
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,19 @@
async fund<T extends TransactionRequest>(request: T, params: EstimatedTxParams): Promise<T> {
const { addedSignatures, estimatedPredicates, requiredQuantities, updateMaxFee } = params;

const {
consensusParameters: {
txParameters: { maxInputs },
},
} = this.provider.getChain();

if (bn(request.inputs.length) > maxInputs) {
mvares marked this conversation as resolved.
Show resolved Hide resolved
mvares marked this conversation as resolved.
Show resolved Hide resolved
throw new FuelError(
ErrorCode.MAX_INPUTS_EXCEEDED,
'The transaction exceeds the maximum allowed number of inputs for funding.'
);
}

const fee = request.maxFee;
const baseAssetId = this.provider.getBaseAssetId();
const requiredInBaseAsset =
Expand Down
1 change: 1 addition & 0 deletions packages/errors/src/error-codes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ export enum ErrorCode {
DUPLICATED_POLICY = 'duplicated-policy',
TRANSACTION_SQUEEZED_OUT = 'transaction-squeezed-out',
CONTRACT_SIZE_EXCEEDS_LIMIT = 'contract-size-exceeds-limit',
MAX_INPUTS_EXCEEDED = 'max-inputs-exceeded',
mvares marked this conversation as resolved.
Show resolved Hide resolved

// receipt
INVALID_RECEIPT_TYPE = 'invalid-receipt-type',
Expand Down
Loading