@bsv/sdk 1.3.22 → 1.3.24

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.
@@ -262,7 +262,7 @@ Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](
262
262
  | [HTTPSOverlayLookupFacilitator](#class-httpsoverlaylookupfacilitator) |
263
263
  | [LookupResolver](#class-lookupresolver) |
264
264
  | [OverlayAdminTokenTemplate](#class-overlayadmintokentemplate) |
265
- | [SHIPCast](#class-shipcast) |
265
+ | [SHIPBroadcaster](#class-shipbroadcaster) |
266
266
 
267
267
  Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Enums](#enums), [Variables](#variables)
268
268
 
@@ -430,12 +430,12 @@ Argument Details
430
430
  Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Enums](#enums), [Variables](#variables)
431
431
 
432
432
  ---
433
- ### Class: SHIPCast
433
+ ### Class: SHIPBroadcaster
434
434
 
435
435
  Represents a SHIP transaction broadcaster.
436
436
 
437
437
  ```ts
438
- export default class SHIPCast implements Broadcaster {
438
+ export default class SHIPBroadcaster implements Broadcaster {
439
439
  constructor(topics: string[], config?: SHIPBroadcasterConfig)
440
440
  async broadcast(tx: Transaction): Promise<BroadcastResponse | BroadcastFailure>
441
441
  }
package/docs/script.md CHANGED
@@ -211,11 +211,12 @@ Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](
211
211
  ```ts
212
212
  export default class PushDrop implements ScriptTemplate {
213
213
  wallet: WalletInterface;
214
+ originator?: string;
214
215
  static decode(script: LockingScript): {
215
216
  lockingPublicKey: PublicKey;
216
217
  fields: number[][];
217
218
  }
218
- constructor(wallet: WalletInterface)
219
+ constructor(wallet: WalletInterface, originator?: string)
219
220
  async lock(fields: number[][], protocolID: [
220
221
  SecurityLevel,
221
222
  string
@@ -237,7 +238,7 @@ See also: [LockingScript](./script.md#class-lockingscript), [PublicKey](./primit
237
238
  Constructs a new instance of the PushDrop class.
238
239
 
239
240
  ```ts
240
- constructor(wallet: WalletInterface)
241
+ constructor(wallet: WalletInterface, originator?: string)
241
242
  ```
242
243
  See also: [WalletInterface](./wallet.md#interface-walletinterface)
243
244
 
@@ -245,6 +246,8 @@ Argument Details
245
246
 
246
247
  + **wallet**
247
248
  + The wallet interface used for creating signatures and accessing public keys.
249
+ + **originator**
250
+ + — The originator to use with Wallet requests
248
251
 
249
252
  #### Method decode
250
253
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bsv/sdk",
3
- "version": "1.3.22",
3
+ "version": "1.3.24",
4
4
  "type": "module",
5
5
  "description": "BSV Blockchain Software Development Kit",
6
6
  "main": "dist/cjs/mod.js",
@@ -1,4 +1,3 @@
1
- // @ts-nocheck
2
1
  import {
3
2
  Transaction,
4
3
  BroadcastResponse,
@@ -60,10 +59,7 @@ export interface SHIPBroadcasterConfig {
60
59
  /** Determines which topics (all, any, or a specific list) must be present within STEAK received from at least one host for the broadcast to be considered a success. */
61
60
  requireAcknowledgmentFromAnyHostForTopics?: 'all' | 'any' | string[]
62
61
  /** Determines a mapping whose keys are specific hosts and whose values are the topics (all, any, or a specific list) that must be present within the STEAK received by the given hosts, in order for the broadcast to be considered a success. */
63
- requireAcknowledgmentFromSpecificHostsForTopics?: Record<
64
- string,
65
- 'all' | 'any' | string[]
66
- >
62
+ requireAcknowledgmentFromSpecificHostsForTopics?: Record<string, 'all' | 'any' | string[]>
67
63
  }
68
64
 
69
65
  /** Facilitates transaction broadcasts that return STEAK. */
@@ -73,8 +69,7 @@ export interface OverlayBroadcastFacilitator {
73
69
 
74
70
  const MAX_SHIP_QUERY_TIMEOUT = 1000
75
71
 
76
- export class HTTPSOverlayBroadcastFacilitator
77
- implements OverlayBroadcastFacilitator {
72
+ export class HTTPSOverlayBroadcastFacilitator implements OverlayBroadcastFacilitator {
78
73
  httpClient: typeof fetch
79
74
 
80
75
  constructor (httpClient = fetch) {
@@ -106,24 +101,13 @@ implements OverlayBroadcastFacilitator {
106
101
  /**
107
102
  * Represents a SHIP transaction broadcaster.
108
103
  */
109
- export default class SHIPCast implements Broadcaster {
104
+ export default class SHIPBroadcaster implements Broadcaster {
110
105
  private readonly topics: string[]
111
106
  private readonly facilitator: OverlayBroadcastFacilitator
112
107
  private readonly resolver: LookupResolver
113
- private readonly requireAcknowledgmentFromAllHostsForTopics:
114
- | 'all'
115
- | 'any'
116
- | string[]
117
-
118
- private readonly requireAcknowledgmentFromAnyHostForTopics:
119
- | 'all'
120
- | 'any'
121
- | string[]
122
-
123
- private readonly requireAcknowledgmentFromSpecificHostsForTopics: Record<
124
- string,
125
- 'all' | 'any' | string[]
126
- >
108
+ private readonly requireAcknowledgmentFromAllHostsForTopics: | 'all' | 'any' | string[]
109
+ private readonly requireAcknowledgmentFromAnyHostForTopics: | 'all' | 'any' | string[]
110
+ private readonly requireAcknowledgmentFromSpecificHostsForTopics: Record<string, 'all' | 'any' | string[]>
127
111
 
128
112
  /**
129
113
  * Constructs an instance of the SHIP broadcaster.
@@ -145,7 +129,7 @@ export default class SHIPCast implements Broadcaster {
145
129
  requireAcknowledgmentFromAllHostsForTopics,
146
130
  requireAcknowledgmentFromAnyHostForTopics,
147
131
  requireAcknowledgmentFromSpecificHostsForTopics
148
- } = config ?? defaultConfig
132
+ } = config ?? {}
149
133
  this.facilitator = facilitator ?? new HTTPSOverlayBroadcastFacilitator()
150
134
  this.resolver = resolver ?? new LookupResolver()
151
135
  this.requireAcknowledgmentFromAllHostsForTopics =
@@ -215,14 +199,14 @@ export default class SHIPCast implements Broadcaster {
215
199
 
216
200
  for (const result of successfulHosts) {
217
201
  const host = result.host
218
- const steak = result.steak
202
+ const steak = result.steak as STEAK
219
203
 
220
204
  const acknowledgedTopics = new Set<string>()
221
205
 
222
206
  for (const [topic, instructions] of Object.entries(steak)) {
223
207
  const outputsToAdmit = instructions.outputsToAdmit
224
208
  const coinsToRetain = instructions.coinsToRetain
225
- const coinsRemoved = instructions.coinsRemoved
209
+ const coinsRemoved = instructions.coinsRemoved as number[]
226
210
 
227
211
  if (
228
212
  outputsToAdmit?.length > 0 ||
@@ -57,6 +57,7 @@ const createMinimallyEncodedScriptChunk = (
57
57
 
58
58
  export default class PushDrop implements ScriptTemplate {
59
59
  wallet: WalletInterface
60
+ originator?: string
60
61
 
61
62
  /**
62
63
  * Decodes a PushDrop script back into its token fields and the locking public key. If a signature was present, it will be the last field returned.
@@ -105,9 +106,11 @@ export default class PushDrop implements ScriptTemplate {
105
106
  * Constructs a new instance of the PushDrop class.
106
107
  *
107
108
  * @param {WalletInterface} wallet - The wallet interface used for creating signatures and accessing public keys.
109
+ * @param {string} originator — The originator to use with Wallet requests
108
110
  */
109
- constructor(wallet: WalletInterface) {
111
+ constructor(wallet: WalletInterface, originator?: string) {
110
112
  this.wallet = wallet
113
+ this.originator = originator
111
114
  }
112
115
 
113
116
  /**
@@ -135,7 +138,7 @@ export default class PushDrop implements ScriptTemplate {
135
138
  keyID,
136
139
  counterparty,
137
140
  forSelf
138
- })
141
+ }, this.originator)
139
142
  const lockChunks: Array<{ op: number, data?: number[] }> = []
140
143
  const pushDropChunks: Array<{ op: number, data?: number[] }> = []
141
144
  lockChunks.push({
@@ -150,7 +153,7 @@ export default class PushDrop implements ScriptTemplate {
150
153
  protocolID,
151
154
  keyID,
152
155
  counterparty
153
- })
156
+ }, this.originator)
154
157
  fields.push(signature)
155
158
  }
156
159
  for (const field of fields) {
@@ -263,7 +266,7 @@ export default class PushDrop implements ScriptTemplate {
263
266
  protocolID,
264
267
  keyID,
265
268
  counterparty
266
- })
269
+ }, this.originator)
267
270
  const signature = Signature.fromDER([...bareSignature])
268
271
  const txSignature = new TransactionSignature(
269
272
  signature.r,