Skip to content

Commit 29c58fd

Browse files
committed
cleanup "dojo"s, fix INSUFFICIENT_FUNDS
1 parent f390d4f commit 29c58fd

File tree

5 files changed

+14
-18
lines changed

5 files changed

+14
-18
lines changed

src/sdk/WalletError.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ export class WalletError extends Error implements WalletErrorObject {
5656
/**
5757
* Recovers all public fields from WalletError derived error classes and relevant Error derived errors.
5858
*
59-
* Critical client data fields are preserved across HTTP DojoExpress / DojoExpressClient encoding.
6059
*/
6160
static fromUnknown(err: unknown): WalletError {
6261
// eslint-disable-next-line @typescript-eslint/no-explicit-any

src/storage/StorageProvider.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ export abstract class StorageProvider
217217

218218
/**
219219
* Given an array of transaction txids with current ProvenTxReq ready-to-share status,
220-
* lookup their DojoProvenTxReqApi req records.
220+
* lookup their ProvenTxReqApi req records.
221221
* For the txids with reqs and status still ready to send construct a single merged beef.
222222
*
223223
* @param txids
@@ -408,9 +408,6 @@ export abstract class StorageProvider
408408
*
409409
* For 'status' of 'failed', attempts to make outputs previously allocated as inputs to this transaction usable again.
410410
*
411-
* @throws ERR_DOJO_COMPLETED_TX if current status is 'completed' and new status is not 'completed.
412-
* @throws ERR_DOJO_PROVEN_TX if transaction has proof or provenTxId and new status is not 'completed'.
413-
*
414411
* @param status
415412
* @param transactionId
416413
* @param userId

src/storage/methods/createAction.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -711,7 +711,7 @@ async function validateRequiredInputs(
711711
}
712712

713713
async function validateNoSendChange(
714-
dojo: StorageProvider,
714+
storage: StorageProvider,
715715
userId: number,
716716
vargs: sdk.ValidCreateActionArgs,
717717
changeBasket: table.OutputBasket
@@ -725,7 +725,7 @@ async function validateNoSendChange(
725725
if (noSendChange && noSendChange.length > 0) {
726726
for (const op of noSendChange) {
727727
const output = verifyOneOrNone(
728-
await dojo.findOutputs({
728+
await storage.findOutputs({
729729
partial: { userId, txid: op.txid, vout: op.vout }
730730
})
731731
)
@@ -754,7 +754,7 @@ async function validateNoSendChange(
754754
}
755755

756756
async function fundNewTransactionSdk(
757-
dojo: StorageProvider,
757+
storage: StorageProvider,
758758
userId: number,
759759
vargs: sdk.ValidCreateActionArgs,
760760
ctx: CreateTransactionSdkContext
@@ -796,7 +796,7 @@ async function fundNewTransactionSdk(
796796
const o = noSendChange.pop()!
797797
outputs[o.outputId!] = o
798798
// allocate the output in storage, noSendChange is by definition spendable false and part of noSpend transaction batch.
799-
await dojo.updateOutput(o.outputId!, {
799+
await storage.updateOutput(o.outputId!, {
800800
spendable: false,
801801
spentBy: ctx.transactionId
802802
})
@@ -810,7 +810,7 @@ async function fundNewTransactionSdk(
810810
}
811811

812812
const basketId = ctx.changeBasket.basketId!
813-
const o = await dojo.allocateChangeInput(
813+
const o = await storage.allocateChangeInput(
814814
userId,
815815
basketId,
816816
targetSatoshis,
@@ -833,7 +833,7 @@ async function fundNewTransactionSdk(
833833
noSendChange.push(nsco)
834834
return
835835
}
836-
await dojo.updateOutput(outputId, {
836+
await storage.updateOutput(outputId, {
837837
spendable: true,
838838
spentBy: undefined
839839
})
@@ -910,7 +910,7 @@ function trimInputBeef(
910910
}
911911

912912
async function mergeAllocatedChangeBeefs(
913-
dojo: StorageProvider,
913+
storage: StorageProvider,
914914
userId: number,
915915
vargs: sdk.ValidCreateActionArgs,
916916
allocatedChange: table.Output[],
@@ -931,7 +931,7 @@ async function mergeAllocatedChangeBeefs(
931931
!beef.findTxid(o.txid!) &&
932932
!vargs.options.knownTxids.find(txid => txid === o.txid)
933933
) {
934-
await dojo.getBeefForTransaction(o.txid!, options)
934+
await storage.getBeefForTransaction(o.txid!, options)
935935
}
936936
}
937937
return trimInputBeef(beef, vargs)

src/storage/methods/generateChange.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,7 @@ export async function generateChangeSdk(
331331
return r
332332
} catch (eu: unknown) {
333333
const e = sdk.WalletError.fromUnknown(eu)
334-
if (e.code === 'ERR_DOJO_NOT_SUFFICIENT_FUNDS') throw eu
334+
if (e.code === 'WERR_INSUFFICIENT_FUNDS') throw eu
335335

336336
// Capture the params in cloud run log which has a 100k text length limit per line.
337337
// logGenerateChangeSdkParams(params, eu)

src/storage/schema/tables/ProvenTxReq.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,12 @@ export interface ProvenTxReq extends ProvenTxReqDynamics {
2121
batch?: string
2222
/**
2323
* JSON string of processing history.
24-
* Parses to `DojoProvenTxReqHistoryApi`.
24+
* Parses to `ProvenTxReqHistoryApi`.
2525
*/
2626
history: string
2727
/**
2828
* JSON string of data to drive notifications when this request completes.
29-
* Parses to `DojoProvenTxReqNotifyApi`.
29+
* Parses to `ProvenTxReqNotifyApi`.
3030
*/
3131
notify: string
3232
rawTx: number[]
@@ -54,12 +54,12 @@ export interface ProvenTxReqDynamics extends sdk.EntityTimeStamp {
5454
batch?: string
5555
/**
5656
* JSON string of processing history.
57-
* Parses to `DojoProvenTxReqHistoryApi`.
57+
* Parses to `ProvenTxReqHistoryApi`.
5858
*/
5959
history: string
6060
/**
6161
* JSON string of data to drive notifications when this request completes.
62-
* Parses to `DojoProvenTxReqNotifyApi`.
62+
* Parses to `ProvenTxReqNotifyApi`.
6363
*/
6464
notify: string
6565
}

0 commit comments

Comments
 (0)