From ef80a858787f158d7361ee26a67d33ec36e9e25c Mon Sep 17 00:00:00 2001 From: Eric Taylor Date: Tue, 17 Dec 2024 11:32:19 -0700 Subject: [PATCH] fix: update insufficent funds for fee error (#944) --- .../etna-builder/spend-reducers/handleFeeAndChange.test.ts | 2 +- .../pvm/etna-builder/spend-reducers/handleFeeAndChange.ts | 3 ++- .../etna-builder/spend-reducers/useSpendableLockedUTXOs.ts | 5 +++++ 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/vms/pvm/etna-builder/spend-reducers/handleFeeAndChange.test.ts b/src/vms/pvm/etna-builder/spend-reducers/handleFeeAndChange.test.ts index 3a6d5ef11..a0a314bb6 100644 --- a/src/vms/pvm/etna-builder/spend-reducers/handleFeeAndChange.test.ts +++ b/src/vms/pvm/etna-builder/spend-reducers/handleFeeAndChange.test.ts @@ -22,7 +22,7 @@ describe('handleFeeAndChange', () => { testContext, ), ).toThrow( - `Insufficient funds: provided UTXOs need 4 more nAVAX (asset id: ${testContext.avaxAssetID})`, + `Insufficient funds: provided UTXOs need 4 more unlocked nAVAX (asset id: ${testContext.avaxAssetID}) to cover fee.`, ); }); diff --git a/src/vms/pvm/etna-builder/spend-reducers/handleFeeAndChange.ts b/src/vms/pvm/etna-builder/spend-reducers/handleFeeAndChange.ts index 5ad15ff49..b4e47d1b2 100644 --- a/src/vms/pvm/etna-builder/spend-reducers/handleFeeAndChange.ts +++ b/src/vms/pvm/etna-builder/spend-reducers/handleFeeAndChange.ts @@ -19,11 +19,12 @@ const canPayFeeAndNeedsChange = ( context: Context, ): boolean => { // Not enough funds to pay the fee. + // NOTE: Time locked UTXOs can not be used to pay fees. if (excessAVAX < requiredFee) { throw new Error( `Insufficient funds: provided UTXOs need ${ requiredFee - excessAVAX - } more nAVAX (asset id: ${context.avaxAssetID})`, + } more unlocked nAVAX (asset id: ${context.avaxAssetID}) to cover fee.`, ); } diff --git a/src/vms/pvm/etna-builder/spend-reducers/useSpendableLockedUTXOs.ts b/src/vms/pvm/etna-builder/spend-reducers/useSpendableLockedUTXOs.ts index c2df41916..421be0ef4 100644 --- a/src/vms/pvm/etna-builder/spend-reducers/useSpendableLockedUTXOs.ts +++ b/src/vms/pvm/etna-builder/spend-reducers/useSpendableLockedUTXOs.ts @@ -50,6 +50,11 @@ export const getUsableUTXOsFilter = return true; }; +/** + * Reducer function that is responsible for spending UTXOs that are locked and stakeable. + * + * NOTE: Time locked UTXOs can not be used to pay fees. + */ export const useSpendableLockedUTXOs: SpendReducerFunction = ( state, spendHelper,