Skip to content

Commit 307e16b

Browse files
fixup! feat(input-selection): add large first input selection strategy
1 parent b7cffc0 commit 307e16b

File tree

2 files changed

+24
-24
lines changed

2 files changed

+24
-24
lines changed

packages/input-selection/src/GreedySelection/util.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,7 @@ export const splitChangeAndComputeFee = async (
318318
fee
319319
);
320320

321-
// If the newly computed fee is higher than tha available balance for change,
321+
// If the newly computed fee is higher than the available balance for change,
322322
// but there are unallocated native assets, return the assets as change with 0n coins.
323323
if (adjustedChangeOutputs.fee >= changeLovelace) {
324324
const result = {

packages/input-selection/src/LargeFirstSelection/LargeFirstInputSelector.ts

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ export interface LargeFirstSelectorProps {
5959
/**
6060
* Input selector that implements a "large-first" strategy.
6161
*
62-
* This strategy selects the largest UTXOs per asset, one asset at a time, until the requirements
62+
* This strategy selects the largest UTxOs per asset, one asset at a time, until the requirements
6363
* of all assets in the outputs + fees and implicit values are satisfied.
6464
*/
6565
export class LargeFirstSelector implements InputSelector {
@@ -72,11 +72,11 @@ export class LargeFirstSelector implements InputSelector {
7272

7373
/**
7474
* Selects inputs using a large-first strategy:
75-
* Selects largest UTXOs per asset until target is met
76-
* Then selects largest UTxOs by ADA
75+
* Selects largest UTxOs per asset until target is met
76+
* Then selects largest UTxOs by Ada
7777
* Then iteratively adds more UTxOs if needed to cover fees
7878
*
79-
* @param params Input selection parameters (available UTXOs, outputs, constraints, etc.)
79+
* @param params Input selection parameters (available UTxOs, outputs, constraints, etc.)
8080
* @returns A complete selection including inputs, outputs, change, and fee.
8181
* @throws {InputSelectionError} If the selection cannot satisfy the outputs and fees.
8282
*/
@@ -197,7 +197,7 @@ export class LargeFirstSelector implements InputSelector {
197197
* Minting and burning are treated as negative or positive contributions to input balance,
198198
* and are subtracted from the output requirements.
199199
*
200-
* @param inputs The full set of selected UTXOs (including pre-selected).
200+
* @param inputs The full set of selected UTxOs (including pre-selected).
201201
* @param outputs The transaction outputs.
202202
* @param implicitValue Optional implicit values including deposits, withdrawals, and minting.
203203
* @returns An object with:
@@ -235,12 +235,12 @@ export class LargeFirstSelector implements InputSelector {
235235
}
236236

237237
/**
238-
* Selects the largest UTXOs per required asset until each target amount is fulfilled.
238+
* Selects the largest UTxOs per required asset until each target amount is fulfilled.
239239
*
240240
* @param requiredAssets The asset quantities required by the transaction outputs.
241-
* @param allAvailable All available UTXOs (including preselected ones).
242-
* @param preSelected The UTXOs already selected for the transaction.
243-
* @returns A set of selected UTXOs covering the asset requirements.
241+
* @param allAvailable All available UTxOs (including preselected ones).
242+
* @param preSelected The UTxOs already selected for the transaction.
243+
* @returns A set of selected UTxOs covering the asset requirements.
244244
* @throws {InputSelectionError} If any asset cannot be sufficiently fulfilled.
245245
*/
246246
#selectAssets(
@@ -270,13 +270,13 @@ export class LargeFirstSelector implements InputSelector {
270270
}
271271

272272
/**
273-
* Selects UTXOs (largest ADA first) until the total Lovelace covers the target amount.
273+
* Selects UTxOs (largest Ada first) until the total Lovelace covers the target amount.
274274
*
275275
* @param target The required amount of Lovelace.
276-
* @param allAvailable All available UTXOs.
277-
* @param selected The current set of already selected UTXOs.
276+
* @param allAvailable All available UTxOs.
277+
* @param selected The current set of already selected UTxOs.
278278
* @param implicitCoinInput The implicit coin input amount.
279-
* @returns A new set including the original selected UTXOs plus any added for ADA coverage.
279+
* @returns A new set including the original selected UTxOs plus any added for Ada coverage.
280280
* @throws {InputSelectionError} If the Lovelace requirement cannot be fulfilled.
281281
*/
282282
#selectLovelace(
@@ -311,26 +311,26 @@ export class LargeFirstSelector implements InputSelector {
311311
}
312312

313313
/**
314-
* Computes the UTXOs that were not selected, given the original list and selected set.
314+
* Computes the UTxOs that were not selected, given the original list and selected set.
315315
*
316-
* @param original The original list of available UTXOs (excluding preselected).
317-
* @param used The set of selected UTXOs.
318-
* @returns A new set of UTXOs that were not consumed in the transaction.
316+
* @param original The original list of available UTxOs (excluding preselected).
317+
* @param used The set of selected UTxOs.
318+
* @returns A new set of UTxOs that were not consumed in the transaction.
319319
*/
320320
#computeRemainingUtxo(original: Cardano.Utxo[], used: Set<Cardano.Utxo>): Set<Cardano.Utxo> {
321321
const usedTxIns = new Set([...used].map(([txIn]) => txIn));
322322
return new Set(original.filter(([txIn]) => !usedTxIns.has(txIn)));
323323
}
324324

325325
/**
326-
* Select additional UTXOs until the fee and min-ADA requirements are
326+
* Select additional UTxOs until the fee and min-Ada requirements are
327327
* satisfied, then build the final change outputs.
328328
*
329-
* @param initialInputs The UTXOs already chosen for assets and/or pre-selected by the wallet.
329+
* @param initialInputs The UTxOs already chosen for assets and/or pre-selected by the wallet.
330330
* @param outputs The explicit transaction outputs.
331-
* @param allAvailable Every UTXO the wallet can spend (pre-selected ∪ utxo).
332-
* @param requiredAssets Aggregate asset requirements computed from `outputs` + burn. Used for fee/ADA expansion.
333-
* @param constraints Network / wallet selection constraints (min-ADA, fee estimator, bundle size, limit…).
331+
* @param allAvailable Every UTxO the wallet can spend (pre-selected ∪ utxo).
332+
* @param requiredAssets Aggregate asset requirements computed from `outputs` + burn. Used for fee/Ada expansion.
333+
* @param constraints Network / wallet selection constraints (min-Ada, fee estimator, bundle size, limit…).
334334
* @param changeAddressResolver Callback that assigns addresses (or further splits) for the provisional change bundles returned by the fee engine.
335335
* @param implicitValue Optional implicit components (deposits, withdrawals, mint or burn)
336336
* @returns An object containing Set of all inputs that will appear in the tx body, minimum fee returned by the cost model and an Array of change outputs.
@@ -347,7 +347,7 @@ export class LargeFirstSelector implements InputSelector {
347347
const utxoSelectedArr = [...initialInputs];
348348
const utxoRemainingArr = allAvailable
349349
.filter((u) => !initialInputs.has(u))
350-
.sort(([, a], [, b]) => sortByCoins(a, b)); // ADA-descending
350+
.sort(([, a], [, b]) => sortByCoins(a, b)); // Ada-descending
351351

352352
const outputValues = toValues([...outputs]);
353353

0 commit comments

Comments
 (0)