@bsv/sdk 1.4.13 → 1.4.17
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/mod.js +1 -0
- package/dist/cjs/mod.js.map +1 -1
- package/dist/cjs/package.json +9 -9
- package/dist/cjs/src/auth/clients/AuthFetch.js +2 -0
- package/dist/cjs/src/auth/clients/AuthFetch.js.map +1 -1
- package/dist/cjs/src/auth/transports/SimplifiedFetchTransport.js +2 -15
- package/dist/cjs/src/auth/transports/SimplifiedFetchTransport.js.map +1 -1
- package/dist/cjs/src/kvstore/LocalKVStore.js +268 -0
- package/dist/cjs/src/kvstore/LocalKVStore.js.map +1 -0
- package/dist/cjs/src/kvstore/index.js +9 -0
- package/dist/cjs/src/kvstore/index.js.map +1 -0
- package/dist/cjs/tsconfig.cjs.tsbuildinfo +1 -1
- package/dist/esm/mod.js +1 -0
- package/dist/esm/mod.js.map +1 -1
- package/dist/esm/src/auth/clients/AuthFetch.js +2 -0
- package/dist/esm/src/auth/clients/AuthFetch.js.map +1 -1
- package/dist/esm/src/auth/transports/SimplifiedFetchTransport.js +2 -15
- package/dist/esm/src/auth/transports/SimplifiedFetchTransport.js.map +1 -1
- package/dist/esm/src/kvstore/LocalKVStore.js +263 -0
- package/dist/esm/src/kvstore/LocalKVStore.js.map +1 -0
- package/dist/esm/src/kvstore/index.js +2 -0
- package/dist/esm/src/kvstore/index.js.map +1 -0
- package/dist/esm/tsconfig.esm.tsbuildinfo +1 -1
- package/dist/types/mod.d.ts +1 -0
- package/dist/types/mod.d.ts.map +1 -1
- package/dist/types/src/auth/clients/AuthFetch.d.ts.map +1 -1
- package/dist/types/src/auth/transports/SimplifiedFetchTransport.d.ts.map +1 -1
- package/dist/types/src/kvstore/LocalKVStore.d.ts +79 -0
- package/dist/types/src/kvstore/LocalKVStore.d.ts.map +1 -0
- package/dist/types/src/kvstore/index.d.ts +2 -0
- package/dist/types/src/kvstore/index.d.ts.map +1 -0
- package/dist/types/tsconfig.types.tsbuildinfo +1 -1
- package/dist/umd/bundle.js +1 -1
- package/docs/identity.md +225 -0
- package/docs/kvstore.md +132 -0
- package/docs/registry.md +383 -0
- package/docs/transaction.md +3 -3
- package/mod.ts +2 -1
- package/package.json +19 -9
- package/src/auth/clients/AuthFetch.ts +2 -0
- package/src/auth/transports/SimplifiedFetchTransport.ts +2 -16
- package/src/kvstore/LocalKVStore.ts +282 -0
- package/src/kvstore/__tests/LocalKVStore.test.ts +703 -0
- package/src/kvstore/index.ts +1 -0
- package/docs/wallet-substrates.md +0 -1194
package/docs/registry.md
ADDED
|
@@ -0,0 +1,383 @@
|
|
|
1
|
+
# API
|
|
2
|
+
|
|
3
|
+
Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Enums](#enums), [Variables](#variables)
|
|
4
|
+
|
|
5
|
+
## Interfaces
|
|
6
|
+
|
|
7
|
+
| |
|
|
8
|
+
| --- |
|
|
9
|
+
| [BasketDefinitionData](#interface-basketdefinitiondata) |
|
|
10
|
+
| [BasketQuery](#interface-basketquery) |
|
|
11
|
+
| [CertificateDefinitionData](#interface-certificatedefinitiondata) |
|
|
12
|
+
| [CertificateFieldDescriptor](#interface-certificatefielddescriptor) |
|
|
13
|
+
| [CertificateQuery](#interface-certificatequery) |
|
|
14
|
+
| [ProtocolDefinitionData](#interface-protocoldefinitiondata) |
|
|
15
|
+
| [ProtocolQuery](#interface-protocolquery) |
|
|
16
|
+
| [RegistryQueryMapping](#interface-registryquerymapping) |
|
|
17
|
+
| [TokenData](#interface-tokendata) |
|
|
18
|
+
|
|
19
|
+
Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Enums](#enums), [Variables](#variables)
|
|
20
|
+
|
|
21
|
+
---
|
|
22
|
+
|
|
23
|
+
### Interface: BasketDefinitionData
|
|
24
|
+
|
|
25
|
+
Registry data for a Basket-style record.
|
|
26
|
+
|
|
27
|
+
```ts
|
|
28
|
+
export interface BasketDefinitionData {
|
|
29
|
+
definitionType: "basket";
|
|
30
|
+
basketID: string;
|
|
31
|
+
name: string;
|
|
32
|
+
iconURL: string;
|
|
33
|
+
description: string;
|
|
34
|
+
documentationURL: string;
|
|
35
|
+
registryOperator?: PubKeyHex;
|
|
36
|
+
}
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
See also: [PubKeyHex](./wallet.md#type-pubkeyhex)
|
|
40
|
+
|
|
41
|
+
Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Enums](#enums), [Variables](#variables)
|
|
42
|
+
|
|
43
|
+
---
|
|
44
|
+
### Interface: BasketQuery
|
|
45
|
+
|
|
46
|
+
When searching for basket definitions, we can filter by:
|
|
47
|
+
- basketID
|
|
48
|
+
- registryOperators
|
|
49
|
+
- name
|
|
50
|
+
|
|
51
|
+
```ts
|
|
52
|
+
export interface BasketQuery {
|
|
53
|
+
basketID?: string;
|
|
54
|
+
registryOperators?: string[];
|
|
55
|
+
name?: string;
|
|
56
|
+
}
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Enums](#enums), [Variables](#variables)
|
|
60
|
+
|
|
61
|
+
---
|
|
62
|
+
### Interface: CertificateDefinitionData
|
|
63
|
+
|
|
64
|
+
Registry data for a Certificate-style record.
|
|
65
|
+
|
|
66
|
+
```ts
|
|
67
|
+
export interface CertificateDefinitionData {
|
|
68
|
+
definitionType: "certificate";
|
|
69
|
+
type: string;
|
|
70
|
+
name: string;
|
|
71
|
+
iconURL: string;
|
|
72
|
+
description: string;
|
|
73
|
+
documentationURL: string;
|
|
74
|
+
fields: Record<string, CertificateFieldDescriptor>;
|
|
75
|
+
registryOperator?: PubKeyHex;
|
|
76
|
+
}
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
See also: [CertificateFieldDescriptor](./registry.md#interface-certificatefielddescriptor), [PubKeyHex](./wallet.md#type-pubkeyhex)
|
|
80
|
+
|
|
81
|
+
Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Enums](#enums), [Variables](#variables)
|
|
82
|
+
|
|
83
|
+
---
|
|
84
|
+
### Interface: CertificateFieldDescriptor
|
|
85
|
+
|
|
86
|
+
Describes a re-usable structure for certificate fields (used by CertMap).
|
|
87
|
+
|
|
88
|
+
```ts
|
|
89
|
+
export interface CertificateFieldDescriptor {
|
|
90
|
+
friendlyName: string;
|
|
91
|
+
description: string;
|
|
92
|
+
type: "text" | "imageURL" | "other";
|
|
93
|
+
fieldIcon: string;
|
|
94
|
+
}
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Enums](#enums), [Variables](#variables)
|
|
98
|
+
|
|
99
|
+
---
|
|
100
|
+
### Interface: CertificateQuery
|
|
101
|
+
|
|
102
|
+
When searching for certificate definitions, we can filter by:
|
|
103
|
+
- type
|
|
104
|
+
- name
|
|
105
|
+
- registryOperators
|
|
106
|
+
|
|
107
|
+
```ts
|
|
108
|
+
export interface CertificateQuery {
|
|
109
|
+
type?: string;
|
|
110
|
+
name?: string;
|
|
111
|
+
registryOperators?: string[];
|
|
112
|
+
}
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Enums](#enums), [Variables](#variables)
|
|
116
|
+
|
|
117
|
+
---
|
|
118
|
+
### Interface: ProtocolDefinitionData
|
|
119
|
+
|
|
120
|
+
Registry data for a Protocol-style record.
|
|
121
|
+
|
|
122
|
+
```ts
|
|
123
|
+
export interface ProtocolDefinitionData {
|
|
124
|
+
definitionType: "protocol";
|
|
125
|
+
protocolID: WalletProtocol;
|
|
126
|
+
name: string;
|
|
127
|
+
iconURL: string;
|
|
128
|
+
description: string;
|
|
129
|
+
documentationURL: string;
|
|
130
|
+
registryOperator?: PubKeyHex;
|
|
131
|
+
}
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
See also: [PubKeyHex](./wallet.md#type-pubkeyhex), [WalletProtocol](./wallet.md#type-walletprotocol)
|
|
135
|
+
|
|
136
|
+
Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Enums](#enums), [Variables](#variables)
|
|
137
|
+
|
|
138
|
+
---
|
|
139
|
+
### Interface: ProtocolQuery
|
|
140
|
+
|
|
141
|
+
When searching for protocol definitions, we can filter by:
|
|
142
|
+
- name
|
|
143
|
+
- registryOperators
|
|
144
|
+
- protocolID
|
|
145
|
+
|
|
146
|
+
```ts
|
|
147
|
+
export interface ProtocolQuery {
|
|
148
|
+
name?: string;
|
|
149
|
+
registryOperators?: string[];
|
|
150
|
+
protocolID?: WalletProtocol;
|
|
151
|
+
}
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
See also: [WalletProtocol](./wallet.md#type-walletprotocol)
|
|
155
|
+
|
|
156
|
+
Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Enums](#enums), [Variables](#variables)
|
|
157
|
+
|
|
158
|
+
---
|
|
159
|
+
### Interface: RegistryQueryMapping
|
|
160
|
+
|
|
161
|
+
A lookup-service mapping of queries by each definition type.
|
|
162
|
+
|
|
163
|
+
```ts
|
|
164
|
+
export interface RegistryQueryMapping {
|
|
165
|
+
basket: BasketQuery;
|
|
166
|
+
protocol: ProtocolQuery;
|
|
167
|
+
certificate: CertificateQuery;
|
|
168
|
+
}
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
See also: [BasketQuery](./registry.md#interface-basketquery), [CertificateQuery](./registry.md#interface-certificatequery), [ProtocolQuery](./registry.md#interface-protocolquery)
|
|
172
|
+
|
|
173
|
+
Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Enums](#enums), [Variables](#variables)
|
|
174
|
+
|
|
175
|
+
---
|
|
176
|
+
### Interface: TokenData
|
|
177
|
+
|
|
178
|
+
Common info for the on-chain token/UTXO that points to a registry entry.
|
|
179
|
+
|
|
180
|
+
```ts
|
|
181
|
+
export interface TokenData {
|
|
182
|
+
txid: string;
|
|
183
|
+
outputIndex: number;
|
|
184
|
+
satoshis: number;
|
|
185
|
+
lockingScript: string;
|
|
186
|
+
beef: BEEF;
|
|
187
|
+
}
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
See also: [BEEF](./wallet.md#type-beef)
|
|
191
|
+
|
|
192
|
+
Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Enums](#enums), [Variables](#variables)
|
|
193
|
+
|
|
194
|
+
---
|
|
195
|
+
## Classes
|
|
196
|
+
|
|
197
|
+
### Class: RegistryClient
|
|
198
|
+
|
|
199
|
+
RegistryClient manages on-chain registry definitions for three types:
|
|
200
|
+
- basket (basket-based items)
|
|
201
|
+
- protocol (protocol-based items)
|
|
202
|
+
- certificate (certificate-based items)
|
|
203
|
+
|
|
204
|
+
It provides methods to:
|
|
205
|
+
- Register new definitions using pushdrop-based UTXOs.
|
|
206
|
+
- Resolve existing definitions using a lookup service.
|
|
207
|
+
- List registry entries associated with the operator's wallet.
|
|
208
|
+
- Revoke an existing registry entry by spending its UTXO.
|
|
209
|
+
|
|
210
|
+
Registry operators use this client to establish and manage
|
|
211
|
+
canonical references for baskets, protocols, and certificate types.
|
|
212
|
+
|
|
213
|
+
```ts
|
|
214
|
+
export class RegistryClient {
|
|
215
|
+
constructor(private readonly wallet: WalletInterface = new WalletClient())
|
|
216
|
+
async registerDefinition(data: DefinitionData): Promise<BroadcastResponse | BroadcastFailure>
|
|
217
|
+
async resolve<T extends DefinitionType>(definitionType: T, query: RegistryQueryMapping[T]): Promise<DefinitionData[]>
|
|
218
|
+
async listOwnRegistryEntries(definitionType: DefinitionType): Promise<RegistryRecord[]>
|
|
219
|
+
async revokeOwnRegistryEntry(registryRecord: RegistryRecord): Promise<BroadcastResponse | BroadcastFailure>
|
|
220
|
+
}
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
See also: [BroadcastFailure](./transaction.md#interface-broadcastfailure), [BroadcastResponse](./transaction.md#interface-broadcastresponse), [DefinitionData](./registry.md#type-definitiondata), [DefinitionType](./registry.md#type-definitiontype), [RegistryQueryMapping](./registry.md#interface-registryquerymapping), [RegistryRecord](./registry.md#type-registryrecord), [WalletClient](./wallet.md#class-walletclient), [WalletInterface](./wallet.md#interface-walletinterface)
|
|
224
|
+
|
|
225
|
+
#### Method listOwnRegistryEntries
|
|
226
|
+
|
|
227
|
+
Lists the registry operator's published definitions for the given type.
|
|
228
|
+
|
|
229
|
+
Returns parsed registry records including transaction details such as txid, outputIndex, satoshis, and the locking script.
|
|
230
|
+
|
|
231
|
+
```ts
|
|
232
|
+
async listOwnRegistryEntries(definitionType: DefinitionType): Promise<RegistryRecord[]>
|
|
233
|
+
```
|
|
234
|
+
See also: [DefinitionType](./registry.md#type-definitiontype), [RegistryRecord](./registry.md#type-registryrecord)
|
|
235
|
+
|
|
236
|
+
Returns
|
|
237
|
+
|
|
238
|
+
A promise that resolves to an array of RegistryRecord objects.
|
|
239
|
+
|
|
240
|
+
Argument Details
|
|
241
|
+
|
|
242
|
+
+ **definitionType**
|
|
243
|
+
+ The type of registry definition to list ('basket', 'protocol', or 'certificate').
|
|
244
|
+
|
|
245
|
+
#### Method registerDefinition
|
|
246
|
+
|
|
247
|
+
Publishes a new on-chain definition for baskets, protocols, or certificates.
|
|
248
|
+
The definition data is encoded in a pushdrop-based UTXO.
|
|
249
|
+
|
|
250
|
+
Registry operators (i.e., identity key owners) can create these definitions
|
|
251
|
+
to establish canonical references for basket IDs, protocol specs, or certificate schemas.
|
|
252
|
+
|
|
253
|
+
```ts
|
|
254
|
+
async registerDefinition(data: DefinitionData): Promise<BroadcastResponse | BroadcastFailure>
|
|
255
|
+
```
|
|
256
|
+
See also: [BroadcastFailure](./transaction.md#interface-broadcastfailure), [BroadcastResponse](./transaction.md#interface-broadcastresponse), [DefinitionData](./registry.md#type-definitiondata)
|
|
257
|
+
|
|
258
|
+
Returns
|
|
259
|
+
|
|
260
|
+
A promise with the broadcast result or failure.
|
|
261
|
+
|
|
262
|
+
Argument Details
|
|
263
|
+
|
|
264
|
+
+ **data**
|
|
265
|
+
+ Structured information about a 'basket', 'protocol', or 'certificate'.
|
|
266
|
+
|
|
267
|
+
#### Method resolve
|
|
268
|
+
|
|
269
|
+
Resolves registrant tokens of a particular type using a lookup service.
|
|
270
|
+
|
|
271
|
+
The query object shape depends on the registry type:
|
|
272
|
+
- For "basket", the query is of type BasketMapQuery:
|
|
273
|
+
{ basketID?: string; name?: string; registryOperators?: string[]; }
|
|
274
|
+
- For "protocol", the query is of type ProtoMapQuery:
|
|
275
|
+
{ name?: string; registryOperators?: string[]; protocolID?: WalletProtocol; }
|
|
276
|
+
- For "certificate", the query is of type CertMapQuery:
|
|
277
|
+
{ type?: string; name?: string; registryOperators?: string[]; }
|
|
278
|
+
|
|
279
|
+
```ts
|
|
280
|
+
async resolve<T extends DefinitionType>(definitionType: T, query: RegistryQueryMapping[T]): Promise<DefinitionData[]>
|
|
281
|
+
```
|
|
282
|
+
See also: [DefinitionData](./registry.md#type-definitiondata), [DefinitionType](./registry.md#type-definitiontype), [RegistryQueryMapping](./registry.md#interface-registryquerymapping)
|
|
283
|
+
|
|
284
|
+
Returns
|
|
285
|
+
|
|
286
|
+
A promise that resolves to an array of matching registry records.
|
|
287
|
+
|
|
288
|
+
Argument Details
|
|
289
|
+
|
|
290
|
+
+ **definitionType**
|
|
291
|
+
+ The registry type, which can be 'basket', 'protocol', or 'certificate'.
|
|
292
|
+
+ **query**
|
|
293
|
+
+ The query object used to filter registry records, whose shape is determined by the registry type.
|
|
294
|
+
|
|
295
|
+
#### Method revokeOwnRegistryEntry
|
|
296
|
+
|
|
297
|
+
Revokes a registry record by spending its associated UTXO.
|
|
298
|
+
|
|
299
|
+
```ts
|
|
300
|
+
async revokeOwnRegistryEntry(registryRecord: RegistryRecord): Promise<BroadcastResponse | BroadcastFailure>
|
|
301
|
+
```
|
|
302
|
+
See also: [BroadcastFailure](./transaction.md#interface-broadcastfailure), [BroadcastResponse](./transaction.md#interface-broadcastresponse), [RegistryRecord](./registry.md#type-registryrecord)
|
|
303
|
+
|
|
304
|
+
Returns
|
|
305
|
+
|
|
306
|
+
Broadcast success/failure.
|
|
307
|
+
|
|
308
|
+
Argument Details
|
|
309
|
+
|
|
310
|
+
+ **registryRecord**
|
|
311
|
+
+ Must have valid txid, outputIndex, and lockingScript.
|
|
312
|
+
|
|
313
|
+
Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Enums](#enums), [Variables](#variables)
|
|
314
|
+
|
|
315
|
+
---
|
|
316
|
+
## Functions
|
|
317
|
+
|
|
318
|
+
### Function: deserializeWalletProtocol
|
|
319
|
+
|
|
320
|
+
```ts
|
|
321
|
+
export function deserializeWalletProtocol(str: string): WalletProtocol
|
|
322
|
+
```
|
|
323
|
+
|
|
324
|
+
See also: [WalletProtocol](./wallet.md#type-walletprotocol)
|
|
325
|
+
|
|
326
|
+
Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Enums](#enums), [Variables](#variables)
|
|
327
|
+
|
|
328
|
+
---
|
|
329
|
+
## Types
|
|
330
|
+
|
|
331
|
+
| |
|
|
332
|
+
| --- |
|
|
333
|
+
| [DefinitionData](#type-definitiondata) |
|
|
334
|
+
| [DefinitionType](#type-definitiontype) |
|
|
335
|
+
| [RegistryRecord](#type-registryrecord) |
|
|
336
|
+
|
|
337
|
+
Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Enums](#enums), [Variables](#variables)
|
|
338
|
+
|
|
339
|
+
---
|
|
340
|
+
|
|
341
|
+
### Type: DefinitionData
|
|
342
|
+
|
|
343
|
+
Union of all possible definition data objects.
|
|
344
|
+
|
|
345
|
+
```ts
|
|
346
|
+
export type DefinitionData = BasketDefinitionData | ProtocolDefinitionData | CertificateDefinitionData
|
|
347
|
+
```
|
|
348
|
+
|
|
349
|
+
See also: [BasketDefinitionData](./registry.md#interface-basketdefinitiondata), [CertificateDefinitionData](./registry.md#interface-certificatedefinitiondata), [ProtocolDefinitionData](./registry.md#interface-protocoldefinitiondata)
|
|
350
|
+
|
|
351
|
+
Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Enums](#enums), [Variables](#variables)
|
|
352
|
+
|
|
353
|
+
---
|
|
354
|
+
### Type: DefinitionType
|
|
355
|
+
|
|
356
|
+
We unify the registry “type” to these three strings everywhere:
|
|
357
|
+
'basket' | 'protocol' | 'certificate'
|
|
358
|
+
|
|
359
|
+
```ts
|
|
360
|
+
export type DefinitionType = "basket" | "protocol" | "certificate"
|
|
361
|
+
```
|
|
362
|
+
|
|
363
|
+
Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Enums](#enums), [Variables](#variables)
|
|
364
|
+
|
|
365
|
+
---
|
|
366
|
+
### Type: RegistryRecord
|
|
367
|
+
|
|
368
|
+
A registry record is a combination of the typed definition data
|
|
369
|
+
plus the on-chain token data for the UTXO holding it.
|
|
370
|
+
|
|
371
|
+
```ts
|
|
372
|
+
export type RegistryRecord = DefinitionData & TokenData
|
|
373
|
+
```
|
|
374
|
+
|
|
375
|
+
See also: [DefinitionData](./registry.md#type-definitiondata), [TokenData](./registry.md#interface-tokendata)
|
|
376
|
+
|
|
377
|
+
Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Enums](#enums), [Variables](#variables)
|
|
378
|
+
|
|
379
|
+
---
|
|
380
|
+
## Enums
|
|
381
|
+
|
|
382
|
+
## Variables
|
|
383
|
+
|
package/docs/transaction.md
CHANGED
|
@@ -1477,7 +1477,7 @@ export default class Transaction {
|
|
|
1477
1477
|
addOutput(output: TransactionOutput): void
|
|
1478
1478
|
addP2PKHOutput(address: number[] | string, satoshis?: number): void
|
|
1479
1479
|
updateMetadata(metadata: Record<string, any>): void
|
|
1480
|
-
async fee(modelOrFee: FeeModel | number = new SatoshisPerKilobyte(
|
|
1480
|
+
async fee(modelOrFee: FeeModel | number = new SatoshisPerKilobyte(1), changeDistribution: "equal" | "random" = "equal"): Promise<void>
|
|
1481
1481
|
getFee(): number
|
|
1482
1482
|
async sign(): Promise<void>
|
|
1483
1483
|
async broadcast(broadcaster: Broadcaster = defaultBroadcaster()): Promise<BroadcastResponse | BroadcastFailure>
|
|
@@ -1567,11 +1567,11 @@ Argument Details
|
|
|
1567
1567
|
#### Method fee
|
|
1568
1568
|
|
|
1569
1569
|
Computes fees prior to signing.
|
|
1570
|
-
If no fee model is provided, uses a SatoshisPerKilobyte fee model that pays
|
|
1570
|
+
If no fee model is provided, uses a SatoshisPerKilobyte fee model that pays 1 sat/kb.
|
|
1571
1571
|
If fee is a number, the transaction uses that value as fee.
|
|
1572
1572
|
|
|
1573
1573
|
```ts
|
|
1574
|
-
async fee(modelOrFee: FeeModel | number = new SatoshisPerKilobyte(
|
|
1574
|
+
async fee(modelOrFee: FeeModel | number = new SatoshisPerKilobyte(1), changeDistribution: "equal" | "random" = "equal"): Promise<void>
|
|
1575
1575
|
```
|
|
1576
1576
|
See also: [FeeModel](./transaction.md#interface-feemodel), [SatoshisPerKilobyte](./transaction.md#class-satoshisperkilobyte)
|
|
1577
1577
|
|
package/mod.ts
CHANGED
|
@@ -15,4 +15,5 @@ export * from './src/auth/index.js'
|
|
|
15
15
|
export * from './src/overlay-tools/index.js'
|
|
16
16
|
export * from './src/storage/index.js'
|
|
17
17
|
export * from './src/identity/index.js'
|
|
18
|
-
export * from './src/registry/index.js'
|
|
18
|
+
export * from './src/registry/index.js'
|
|
19
|
+
export * from './src/kvstore/index.js'
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bsv/sdk",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.17",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "BSV Blockchain Software Development Kit",
|
|
6
6
|
"main": "dist/cjs/mod.js",
|
|
@@ -194,6 +194,16 @@
|
|
|
194
194
|
"require": "./dist/cjs/src/storage/*.js",
|
|
195
195
|
"types": "./dist/types/src/storage/*.d.ts"
|
|
196
196
|
},
|
|
197
|
+
"./kvstore": {
|
|
198
|
+
"import": "./dist/esm/src/kvstore/index.js",
|
|
199
|
+
"require": "./dist/cjs/src/kvstore/index.js",
|
|
200
|
+
"types": "./dist/types/src/kvstore/index.d.ts"
|
|
201
|
+
},
|
|
202
|
+
"./kvstore/*": {
|
|
203
|
+
"import": "./dist/esm/src/kvstore/*.js",
|
|
204
|
+
"require": "./dist/cjs/src/kvstore/*.js",
|
|
205
|
+
"types": "./dist/types/src/kvstore/*.d.ts"
|
|
206
|
+
},
|
|
197
207
|
"./umd": {
|
|
198
208
|
"import": "./dist/umd/bundle.js"
|
|
199
209
|
}
|
|
@@ -229,23 +239,23 @@
|
|
|
229
239
|
},
|
|
230
240
|
"homepage": "https://github.com/bitcoin-sv/ts-sdk#readme",
|
|
231
241
|
"devDependencies": {
|
|
232
|
-
"@eslint/js": "^9.
|
|
242
|
+
"@eslint/js": "^9.23.0",
|
|
233
243
|
"@jest/globals": "^29.7.0",
|
|
234
244
|
"@types/jest": "^29.5.14",
|
|
235
245
|
"@types/node": "^22.13.14",
|
|
236
|
-
"eslint": "^
|
|
237
|
-
"globals": "^
|
|
246
|
+
"eslint": "^9.23.0",
|
|
247
|
+
"globals": "^16.0.0",
|
|
238
248
|
"jest": "^29.7.0",
|
|
239
249
|
"jest-environment-jsdom": "^29.7.0",
|
|
240
|
-
"ts-jest": "^29.
|
|
241
|
-
"ts-loader": "^9.5.
|
|
250
|
+
"ts-jest": "^29.3.1",
|
|
251
|
+
"ts-loader": "^9.5.2",
|
|
242
252
|
"ts-standard": "^12.0.2",
|
|
243
253
|
"ts2md": "^0.2.8",
|
|
244
254
|
"tsconfig-to-dual-package": "^1.2.0",
|
|
245
255
|
"typescript": "5.1",
|
|
246
|
-
"typescript-eslint": "^8.
|
|
247
|
-
"webpack": "^5.
|
|
248
|
-
"webpack-cli": "^
|
|
256
|
+
"typescript-eslint": "^8.29.0",
|
|
257
|
+
"webpack": "^5.98.0",
|
|
258
|
+
"webpack-cli": "^6.0.1"
|
|
249
259
|
},
|
|
250
260
|
"ts-standard": {
|
|
251
261
|
"project": "tsconfig.eslint.json",
|
|
@@ -222,11 +222,13 @@ export class AuthFetch {
|
|
|
222
222
|
config.retryCounter ??= 3
|
|
223
223
|
const response = await this.fetch(url, config)
|
|
224
224
|
resolve(response)
|
|
225
|
+
return
|
|
225
226
|
}
|
|
226
227
|
if (error.message.includes('HTTP server failed to authenticate')) {
|
|
227
228
|
try {
|
|
228
229
|
const response = await this.handleFetchAndValidate(url, config, peerToUse)
|
|
229
230
|
resolve(response)
|
|
231
|
+
return
|
|
230
232
|
} catch (fetchError) {
|
|
231
233
|
reject(fetchError)
|
|
232
234
|
}
|
|
@@ -126,23 +126,9 @@ export class SimplifiedFetchTransport implements Transport {
|
|
|
126
126
|
})
|
|
127
127
|
|
|
128
128
|
// Check for an acceptable status
|
|
129
|
-
if (!
|
|
129
|
+
if (response.status === 500 && !response.headers.get('x-bsv-auth-request-id')) {
|
|
130
130
|
// Try parsing JSON error
|
|
131
|
-
|
|
132
|
-
try {
|
|
133
|
-
errorInfo = await response.json();
|
|
134
|
-
} catch {
|
|
135
|
-
// Fallback to text if JSON parse fails
|
|
136
|
-
const text = await response.text().catch(() => '');
|
|
137
|
-
throw new Error(`HTTP ${response.status} - ${text || 'Unknown error'}`);
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
// If we find a known { status: 'error', code, description } structure
|
|
141
|
-
if (errorInfo?.status === 'error' && typeof errorInfo.description === 'string') {
|
|
142
|
-
const msg = `HTTP ${response.status} - ${errorInfo.description}`;
|
|
143
|
-
throw new Error(errorInfo.code ? `${msg} (code: ${errorInfo.code})` : msg);
|
|
144
|
-
}
|
|
145
|
-
|
|
131
|
+
const errorInfo = await response.json()
|
|
146
132
|
// Otherwise just throw whatever we got
|
|
147
133
|
throw new Error(`HTTP ${response.status} - ${JSON.stringify(errorInfo)}`);
|
|
148
134
|
}
|