@bsv/wallet-toolbox 1.1.16 → 1.1.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bsv/wallet-toolbox",
3
- "version": "1.1.16",
3
+ "version": "1.1.18",
4
4
  "description": "BRC100 conforming wallet, wallet storage and wallet signer components",
5
5
  "main": "./out/src/index.js",
6
6
  "types": "./out/src/index.d.ts",
package/src/Wallet.ts CHANGED
@@ -663,6 +663,14 @@ export class Wallet implements WalletInterface, ProtoWallet {
663
663
  this.beef.mergeBeefFromParty(this.storageParty, r.tx)
664
664
  }
665
665
 
666
+ if (
667
+ !vargs.options.acceptDelayedBroadcast &&
668
+ r.sendWithResults &&
669
+ r.sendWithResults.length === 1 &&
670
+ r.sendWithResults[0].status === 'failed'
671
+ )
672
+ throw new sdk.WERR_BROADCAST_UNAVAILABLE()
673
+
666
674
  return r
667
675
  }
668
676
 
@@ -677,6 +685,15 @@ export class Wallet implements WalletInterface, ProtoWallet {
677
685
  sdk.validateSignActionArgs
678
686
  )
679
687
  const r = await signAction(this, auth, vargs)
688
+
689
+ if (
690
+ !vargs.options.acceptDelayedBroadcast &&
691
+ r.sendWithResults &&
692
+ r.sendWithResults.length === 1 &&
693
+ r.sendWithResults[0].status === 'failed'
694
+ )
695
+ throw new sdk.WERR_BROADCAST_UNAVAILABLE()
696
+
680
697
  return r
681
698
  }
682
699
 
@@ -35,6 +35,18 @@ export class WERR_INVALID_OPERATION extends WalletError {
35
35
  }
36
36
  }
37
37
 
38
+ /**
39
+ * Unable to broadcast transaction at this time.
40
+ */
41
+ export class WERR_BROADCAST_UNAVAILABLE extends WalletError {
42
+ constructor(message?: string) {
43
+ super(
44
+ 'WERR_BROADCAST_UNAVAILABLE',
45
+ `Unable to broadcast transaction at this time.`
46
+ )
47
+ }
48
+ }
49
+
38
50
  /**
39
51
  * The ${parameter} parameter is invalid.
40
52
  *
@@ -12,7 +12,8 @@ import {
12
12
  ListCertificatesResult,
13
13
  TrustSelf,
14
14
  RelinquishCertificateArgs,
15
- RelinquishOutputArgs
15
+ RelinquishOutputArgs,
16
+ AbortActionArgs
16
17
  } from '@bsv/sdk'
17
18
  import {
18
19
  asArray,
@@ -177,12 +178,29 @@ export abstract class StorageProvider
177
178
 
178
179
  async abortAction(
179
180
  auth: sdk.AuthId,
180
- args: Partial<TableTransaction>
181
+ args: AbortActionArgs
181
182
  ): Promise<AbortActionResult> {
183
+ if (!auth.userId)
184
+ throw new sdk.WERR_INVALID_PARAMETER('auth.userId', 'valid')
185
+
182
186
  const r = await this.transaction(async trx => {
183
- const tx = verifyOneOrNone(
184
- await this.findTransactions({ partial: args, noRawTx: true, trx })
187
+ let tx = verifyOneOrNone(
188
+ await this.findTransactions({
189
+ partial: { reference: args.reference, userId: auth.userId },
190
+ noRawTx: true,
191
+ trx
192
+ })
185
193
  )
194
+ if (!tx && args.reference.length === 64) {
195
+ // reference may also be a txid
196
+ tx = verifyOneOrNone(
197
+ await this.findTransactions({
198
+ partial: { txid: args.reference, userId: auth.userId },
199
+ noRawTx: true,
200
+ trx
201
+ })
202
+ )
203
+ }
186
204
  const unAbortableStatus: sdk.TransactionStatus[] = [
187
205
  'completed',
188
206
  'failed',