@bsv/sdk 1.6.0 → 1.6.1

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/sdk",
3
- "version": "1.6.0",
3
+ "version": "1.6.1",
4
4
  "type": "module",
5
5
  "description": "BSV Blockchain Software Development Kit",
6
6
  "main": "dist/cjs/mod.js",
@@ -27,12 +27,9 @@ export type LookupAnswer =
27
27
  outputs: Array<{
28
28
  beef: number[]
29
29
  outputIndex: number
30
+ context?: number[]
30
31
  }>
31
32
  }
32
- | {
33
- type: 'freeform'
34
- result: unknown
35
- }
36
33
 
37
34
  /** Default SLAP trackers */
38
35
  export const DEFAULT_SLAP_TRACKERS: string[] = [
@@ -200,11 +197,6 @@ export default class LookupResolver {
200
197
  }
201
198
 
202
199
  // Process the successful responses
203
- if (successfulResponses[0].type === 'freeform') {
204
- // Return the first freeform response
205
- return successfulResponses[0]
206
- }
207
-
208
200
  // Aggregate outputs from all successful responses
209
201
  const outputs = new Map<string, { beef: number[], outputIndex: number }>()
210
202
 
@@ -16,6 +16,7 @@ import OverlayAdminTokenTemplate from './OverlayAdminTokenTemplate.js'
16
16
  export interface TaggedBEEF {
17
17
  beef: number[]
18
18
  topics: string[]
19
+ offChainValues?: number[]
19
20
  }
20
21
 
21
22
  /**
@@ -86,7 +87,6 @@ export class HTTPSOverlayBroadcastFacilitator implements OverlayBroadcastFacilit
86
87
  }
87
88
 
88
89
  async send (url: string, taggedBEEF: TaggedBEEF): Promise<STEAK> {
89
- console.log(url)
90
90
  if (!url.startsWith('https:') && !this.allowHTTP) {
91
91
  throw new Error(
92
92
  'HTTPS facilitator can only use URLs that start with "https:"'
@@ -164,7 +164,6 @@ export default class TopicBroadcaster implements Broadcaster {
164
164
  )
165
165
  }
166
166
  const interestedHosts = await this.findInterestedHosts()
167
- console.log(interestedHosts)
168
167
  if (Object.keys(interestedHosts).length === 0) {
169
168
  return {
170
169
  status: 'error',
@@ -620,118 +620,6 @@ describe('LookupResolver', () => {
620
620
  ])
621
621
  })
622
622
 
623
- it('should handle hosts returning different response types', async () => {
624
- const slapHostKey1 = new PrivateKey(42)
625
- const slapWallet1 = new CompletedProtoWallet(slapHostKey1)
626
- const slapLib1 = new OverlayAdminTokenTemplate(slapWallet1)
627
- const slapScript1 = await slapLib1.lock(
628
- 'SLAP',
629
- 'https://slaphost1.com',
630
- 'ls_foo'
631
- )
632
- const slapTx1 = new Transaction(
633
- 1,
634
- [],
635
- [
636
- {
637
- lockingScript: slapScript1,
638
- satoshis: 1
639
- }
640
- ],
641
- 0
642
- )
643
-
644
- const slapHostKey2 = new PrivateKey(43)
645
- const slapWallet2 = new CompletedProtoWallet(slapHostKey2)
646
- const slapLib2 = new OverlayAdminTokenTemplate(slapWallet2)
647
- const slapScript2 = await slapLib2.lock(
648
- 'SLAP',
649
- 'https://slaphost2.com',
650
- 'ls_foo'
651
- )
652
- const slapTx2 = new Transaction(
653
- 1,
654
- [],
655
- [
656
- {
657
- lockingScript: slapScript2,
658
- satoshis: 1
659
- }
660
- ],
661
- 0
662
- )
663
-
664
- // SLAP tracker returns two hosts
665
- mockFacilitator.lookup.mockReturnValueOnce({
666
- type: 'output-list',
667
- outputs: [
668
- { outputIndex: 0, beef: slapTx1.toBEEF() },
669
- { outputIndex: 0, beef: slapTx2.toBEEF() }
670
- ]
671
- })
672
-
673
- // First host returns 'freeform' response
674
- mockFacilitator.lookup.mockReturnValueOnce({
675
- type: 'freeform',
676
- result: { message: 'Freeform response from host1' }
677
- })
678
-
679
- // Second host returns 'output-list' response
680
- mockFacilitator.lookup.mockReturnValueOnce({
681
- type: 'output-list',
682
- outputs: [{ beef: sampleBeef3, outputIndex: 0 }]
683
- })
684
-
685
- const r = new LookupResolver({
686
- facilitator: mockFacilitator,
687
- slapTrackers: ['https://mock.slap']
688
- })
689
-
690
- const res = await r.query({
691
- service: 'ls_foo',
692
- query: { test: 1 }
693
- })
694
-
695
- // Since the first response is 'freeform', it should return that response
696
- expect(res).toEqual({
697
- type: 'freeform',
698
- result: { message: 'Freeform response from host1' }
699
- })
700
-
701
- expect(mockFacilitator.lookup.mock.calls).toEqual([
702
- [
703
- 'https://mock.slap',
704
- {
705
- service: 'ls_slap',
706
- query: {
707
- service: 'ls_foo'
708
- }
709
- },
710
- 5000
711
- ],
712
- [
713
- 'https://slaphost1.com',
714
- {
715
- service: 'ls_foo',
716
- query: {
717
- test: 1
718
- }
719
- },
720
- undefined
721
- ],
722
- [
723
- 'https://slaphost2.com',
724
- {
725
- service: 'ls_foo',
726
- query: {
727
- test: 1
728
- }
729
- },
730
- undefined
731
- ]
732
- ])
733
- })
734
-
735
623
  it('should ignore freeform responses when first response is output-list', async () => {
736
624
  const slapHostKey1 = new PrivateKey(42)
737
625
  const slapWallet1 = new CompletedProtoWallet(slapHostKey1)