@bsv/sdk 1.5.1 → 1.5.3
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/dist/cjs/package.json +1 -1
- package/dist/cjs/src/transaction/Beef.js +17 -0
- package/dist/cjs/src/transaction/Beef.js.map +1 -1
- package/dist/cjs/src/wallet/WalletClient.js +3 -2
- package/dist/cjs/src/wallet/WalletClient.js.map +1 -1
- package/dist/cjs/tsconfig.cjs.tsbuildinfo +1 -1
- package/dist/esm/src/transaction/Beef.js +17 -0
- package/dist/esm/src/transaction/Beef.js.map +1 -1
- package/dist/esm/src/wallet/WalletClient.js +3 -2
- package/dist/esm/src/wallet/WalletClient.js.map +1 -1
- package/dist/esm/tsconfig.esm.tsbuildinfo +1 -1
- package/dist/types/src/transaction/Beef.d.ts +21 -1
- package/dist/types/src/transaction/Beef.d.ts.map +1 -1
- package/dist/types/src/wallet/WalletClient.d.ts +1 -1
- package/dist/types/src/wallet/WalletClient.d.ts.map +1 -1
- package/dist/types/tsconfig.types.tsbuildinfo +1 -1
- package/dist/umd/bundle.js +1 -1
- package/docs/transaction.md +34 -0
- package/docs/wallet.md +1 -1
- package/package.json +1 -1
- package/src/transaction/Beef.ts +18 -1
- package/src/wallet/WalletClient.ts +3 -2
package/docs/transaction.md
CHANGED
|
@@ -573,6 +573,10 @@ export class Beef {
|
|
|
573
573
|
mergeBeef(beef: number[] | Beef): void
|
|
574
574
|
isValid(allowTxidOnly?: boolean): boolean
|
|
575
575
|
async verify(chainTracker: ChainTracker, allowTxidOnly?: boolean): Promise<boolean>
|
|
576
|
+
verifyValid(allowTxidOnly?: boolean): {
|
|
577
|
+
valid: boolean;
|
|
578
|
+
roots: Record<number, string>;
|
|
579
|
+
}
|
|
576
580
|
toWriter(writer: Writer): void
|
|
577
581
|
toBinary(): number[]
|
|
578
582
|
toBinaryAtomic(txid: string): number[]
|
|
@@ -950,6 +954,36 @@ Argument Details
|
|
|
950
954
|
+ **allowTxidOnly**
|
|
951
955
|
+ optional. If true, transaction txid is assumed valid
|
|
952
956
|
|
|
957
|
+
#### Method verifyValid
|
|
958
|
+
|
|
959
|
+
Sorts `txs` and confirms validity of transaction data contained in beef
|
|
960
|
+
by validating structure of this beef.
|
|
961
|
+
|
|
962
|
+
Returns block heights and merkle root values to be confirmed by a chaintracker.
|
|
963
|
+
|
|
964
|
+
Validity requirements:
|
|
965
|
+
1. No 'known' txids, unless `allowTxidOnly` is true.
|
|
966
|
+
2. All transactions have bumps or their inputs chain back to bumps (or are known).
|
|
967
|
+
3. Order of transactions satisfies dependencies before dependents.
|
|
968
|
+
4. No transactions with duplicate txids.
|
|
969
|
+
|
|
970
|
+
```ts
|
|
971
|
+
verifyValid(allowTxidOnly?: boolean): {
|
|
972
|
+
valid: boolean;
|
|
973
|
+
roots: Record<number, string>;
|
|
974
|
+
}
|
|
975
|
+
```
|
|
976
|
+
|
|
977
|
+
Returns
|
|
978
|
+
|
|
979
|
+
`valid` is true iff this Beef is structuraly valid.
|
|
980
|
+
`roots` is a record where keys are block heights and values are the corresponding merkle roots to be validated.
|
|
981
|
+
|
|
982
|
+
Argument Details
|
|
983
|
+
|
|
984
|
+
+ **allowTxidOnly**
|
|
985
|
+
+ optional. If true, transaction txid is assumed valid
|
|
986
|
+
|
|
953
987
|
Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Enums](#enums), [Variables](#variables)
|
|
954
988
|
|
|
955
989
|
---
|
package/docs/wallet.md
CHANGED
|
@@ -2610,7 +2610,7 @@ The SDK is how applications communicate with wallets over a communications subst
|
|
|
2610
2610
|
export default class WalletClient implements WalletInterface {
|
|
2611
2611
|
public substrate: "auto" | WalletInterface;
|
|
2612
2612
|
originator?: OriginatorDomainNameStringUnder250Bytes;
|
|
2613
|
-
constructor(substrate: "auto" | "Cicada" | "XDM" | "window.CWI" | "json-api" | WalletInterface = "auto", originator?: OriginatorDomainNameStringUnder250Bytes)
|
|
2613
|
+
constructor(substrate: "auto" | "Cicada" | "XDM" | "window.CWI" | "json-api" | "react-native" | WalletInterface = "auto", originator?: OriginatorDomainNameStringUnder250Bytes)
|
|
2614
2614
|
async connectToSubstrate(): Promise<void>
|
|
2615
2615
|
async createAction(args: CreateActionArgs): Promise<CreateActionResult>
|
|
2616
2616
|
async signAction(args: SignActionArgs): Promise<SignActionResult>
|
package/package.json
CHANGED
package/src/transaction/Beef.ts
CHANGED
|
@@ -391,7 +391,24 @@ export class Beef {
|
|
|
391
391
|
return true
|
|
392
392
|
}
|
|
393
393
|
|
|
394
|
-
|
|
394
|
+
/**
|
|
395
|
+
* Sorts `txs` and confirms validity of transaction data contained in beef
|
|
396
|
+
* by validating structure of this beef.
|
|
397
|
+
*
|
|
398
|
+
* Returns block heights and merkle root values to be confirmed by a chaintracker.
|
|
399
|
+
*
|
|
400
|
+
* Validity requirements:
|
|
401
|
+
* 1. No 'known' txids, unless `allowTxidOnly` is true.
|
|
402
|
+
* 2. All transactions have bumps or their inputs chain back to bumps (or are known).
|
|
403
|
+
* 3. Order of transactions satisfies dependencies before dependents.
|
|
404
|
+
* 4. No transactions with duplicate txids.
|
|
405
|
+
*
|
|
406
|
+
* @param allowTxidOnly optional. If true, transaction txid is assumed valid
|
|
407
|
+
* @returns {{valid: boolean, roots: Record<number, string>}}
|
|
408
|
+
* `valid` is true iff this Beef is structuraly valid.
|
|
409
|
+
* `roots` is a record where keys are block heights and values are the corresponding merkle roots to be validated.
|
|
410
|
+
*/
|
|
411
|
+
verifyValid (allowTxidOnly?: boolean): {
|
|
395
412
|
valid: boolean
|
|
396
413
|
roots: Record<number, string>
|
|
397
414
|
} {
|
|
@@ -57,6 +57,7 @@ export default class WalletClient implements WalletInterface {
|
|
|
57
57
|
| 'XDM'
|
|
58
58
|
| 'window.CWI'
|
|
59
59
|
| 'json-api'
|
|
60
|
+
| 'react-native'
|
|
60
61
|
| WalletInterface = 'auto',
|
|
61
62
|
originator?: OriginatorDomainNameStringUnder250Bytes
|
|
62
63
|
) {
|
|
@@ -66,6 +67,7 @@ export default class WalletClient implements WalletInterface {
|
|
|
66
67
|
if (substrate === 'window.CWI') substrate = new WindowCWISubstrate()
|
|
67
68
|
if (substrate === 'XDM') substrate = new XDMSubstrate()
|
|
68
69
|
if (substrate === 'json-api') substrate = new HTTPWalletJSON(originator)
|
|
70
|
+
if (substrate === 'react-native') substrate = new ReactNativeWebView(originator)
|
|
69
71
|
this.substrate = substrate
|
|
70
72
|
this.originator = originator
|
|
71
73
|
}
|
|
@@ -92,7 +94,6 @@ export default class WalletClient implements WalletInterface {
|
|
|
92
94
|
}
|
|
93
95
|
}
|
|
94
96
|
try {
|
|
95
|
-
console.log('Connecting to substrate...')
|
|
96
97
|
sub = new WindowCWISubstrate()
|
|
97
98
|
await checkSub()
|
|
98
99
|
this.substrate = sub
|
|
@@ -109,7 +110,7 @@ export default class WalletClient implements WalletInterface {
|
|
|
109
110
|
await checkSub()
|
|
110
111
|
this.substrate = sub
|
|
111
112
|
} catch (e) {
|
|
112
|
-
// HTTP
|
|
113
|
+
// HTTP Wire failed, attempt the next...
|
|
113
114
|
try {
|
|
114
115
|
sub = new HTTPWalletJSON(this.originator)
|
|
115
116
|
await checkSub()
|