@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/docs/client.md +34 -19
- package/docs/storage.md +2 -2
- package/docs/wallet.md +34 -19
- package/out/src/Wallet.d.ts.map +1 -1
- package/out/src/Wallet.js +10 -0
- package/out/src/Wallet.js.map +1 -1
- package/out/src/sdk/WERR_errors.d.ts +6 -0
- package/out/src/sdk/WERR_errors.d.ts.map +1 -1
- package/out/src/sdk/WERR_errors.js +10 -1
- package/out/src/sdk/WERR_errors.js.map +1 -1
- package/out/src/storage/StorageProvider.d.ts +3 -3
- package/out/src/storage/StorageProvider.d.ts.map +1 -1
- package/out/src/storage/StorageProvider.js +15 -1
- package/out/src/storage/StorageProvider.js.map +1 -1
- package/out/tsconfig.all.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/Wallet.ts +17 -0
- package/src/sdk/WERR_errors.ts +12 -0
- package/src/storage/StorageProvider.ts +22 -4
package/package.json
CHANGED
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
|
|
package/src/sdk/WERR_errors.ts
CHANGED
|
@@ -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:
|
|
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
|
-
|
|
184
|
-
await this.findTransactions({
|
|
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',
|