@bsv/overlay 0.3.1 → 0.4.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.
Files changed (75) hide show
  1. package/dist/cjs/package.json +2 -2
  2. package/dist/cjs/src/Engine.js +15 -14
  3. package/dist/cjs/src/Engine.js.map +1 -1
  4. package/dist/cjs/src/GASP/GASP.js +283 -0
  5. package/dist/cjs/src/GASP/GASP.js.map +1 -0
  6. package/dist/cjs/src/GASP/OverlayGASPStorage.js +1 -1
  7. package/dist/cjs/src/GASP/OverlayGASPStorage.js.map +1 -1
  8. package/dist/cjs/tsconfig.cjs.tsbuildinfo +1 -1
  9. package/dist/esm/src/Engine.js +15 -14
  10. package/dist/esm/src/Engine.js.map +1 -1
  11. package/dist/esm/src/GASP/GASP.js +288 -0
  12. package/dist/esm/src/GASP/GASP.js.map +1 -0
  13. package/dist/esm/src/GASP/OverlayGASPStorage.js +2 -2
  14. package/dist/esm/src/GASP/OverlayGASPStorage.js.map +1 -1
  15. package/dist/esm/tsconfig.esm.tsbuildinfo +1 -1
  16. package/dist/types/src/Engine.d.ts +2 -1
  17. package/dist/types/src/Engine.d.ts.map +1 -1
  18. package/dist/types/src/GASP/GASP.d.ts +218 -0
  19. package/dist/types/src/GASP/GASP.d.ts.map +1 -0
  20. package/dist/types/src/LookupFormula.d.ts +4 -0
  21. package/dist/types/src/LookupFormula.d.ts.map +1 -1
  22. package/dist/types/src/LookupService.d.ts +6 -2
  23. package/dist/types/src/LookupService.d.ts.map +1 -1
  24. package/dist/types/src/TopicManager.d.ts +2 -2
  25. package/dist/types/src/TopicManager.d.ts.map +1 -1
  26. package/dist/types/tsconfig.types.tsbuildinfo +1 -1
  27. package/package.json +2 -2
  28. package/src/Engine.ts +16 -17
  29. package/src/GASP/OverlayGASPStorage.ts +2 -2
  30. package/src/LookupFormula.ts +5 -0
  31. package/src/LookupService.ts +5 -1
  32. package/src/TopicManager.ts +2 -2
  33. package/src/__tests/Engine.test.ts +1 -1
  34. package/dist/cjs/src/AdmittanceInstructions.js +0 -3
  35. package/dist/cjs/src/AdmittanceInstructions.js.map +0 -1
  36. package/dist/cjs/src/LookupAnswer.js +0 -3
  37. package/dist/cjs/src/LookupAnswer.js.map +0 -1
  38. package/dist/cjs/src/LookupQuestion.js +0 -3
  39. package/dist/cjs/src/LookupQuestion.js.map +0 -1
  40. package/dist/cjs/src/SHIPAdvertisement.js +0 -3
  41. package/dist/cjs/src/SHIPAdvertisement.js.map +0 -1
  42. package/dist/cjs/src/SLAPAdvertisement.js +0 -3
  43. package/dist/cjs/src/SLAPAdvertisement.js.map +0 -1
  44. package/dist/cjs/src/STEAK.js +0 -3
  45. package/dist/cjs/src/STEAK.js.map +0 -1
  46. package/dist/cjs/src/TaggedBEEF.js +0 -3
  47. package/dist/cjs/src/TaggedBEEF.js.map +0 -1
  48. package/dist/esm/src/AdmittanceInstructions.js +0 -2
  49. package/dist/esm/src/AdmittanceInstructions.js.map +0 -1
  50. package/dist/esm/src/LookupAnswer.js +0 -2
  51. package/dist/esm/src/LookupAnswer.js.map +0 -1
  52. package/dist/esm/src/LookupQuestion.js +0 -2
  53. package/dist/esm/src/LookupQuestion.js.map +0 -1
  54. package/dist/esm/src/SHIPAdvertisement.js +0 -2
  55. package/dist/esm/src/SHIPAdvertisement.js.map +0 -1
  56. package/dist/esm/src/SLAPAdvertisement.js +0 -2
  57. package/dist/esm/src/SLAPAdvertisement.js.map +0 -1
  58. package/dist/esm/src/STEAK.js +0 -2
  59. package/dist/esm/src/STEAK.js.map +0 -1
  60. package/dist/esm/src/TaggedBEEF.js +0 -2
  61. package/dist/esm/src/TaggedBEEF.js.map +0 -1
  62. package/dist/types/src/AdmittanceInstructions.d.ts +0 -14
  63. package/dist/types/src/AdmittanceInstructions.d.ts.map +0 -1
  64. package/dist/types/src/LookupAnswer.d.ts +0 -15
  65. package/dist/types/src/LookupAnswer.d.ts.map +0 -1
  66. package/dist/types/src/LookupQuestion.d.ts +0 -15
  67. package/dist/types/src/LookupQuestion.d.ts.map +0 -1
  68. package/dist/types/src/SHIPAdvertisement.d.ts +0 -9
  69. package/dist/types/src/SHIPAdvertisement.d.ts.map +0 -1
  70. package/dist/types/src/SLAPAdvertisement.d.ts +0 -9
  71. package/dist/types/src/SLAPAdvertisement.d.ts.map +0 -1
  72. package/dist/types/src/STEAK.d.ts +0 -10
  73. package/dist/types/src/STEAK.d.ts.map +0 -1
  74. package/dist/types/src/TaggedBEEF.d.ts +0 -11
  75. package/dist/types/src/TaggedBEEF.d.ts.map +0 -1
@@ -23,4 +23,9 @@ export type LookupFormula = Array<{
23
23
  * If not provided, no historical information will be included with the Lookup Answer, except that which may incidentally be required to fully anchor the Lookup Answer to the blockchain.
24
24
  */
25
25
  history?: ((beef: number[], outputIndex: number, currentDepth: number) => Promise<boolean>) | number
26
+
27
+ /**
28
+ * Context for the UTXO, derived from the off-chain values.
29
+ */
30
+ context?: number[]
26
31
  }>
@@ -18,12 +18,14 @@ export type OutputAdmittedByTopic =
18
18
  topic: string // topic into which it was admitted
19
19
  satoshis: number // value of the output
20
20
  lockingScript: Script // script in this output
21
+ offChainValues?: number[] // off-chain values associated with the output
21
22
  }
22
23
  | { // «whole-tx» mode
23
24
  mode: 'whole-tx'
24
25
  atomicBEEF: number[] // whole transaction (Atomic BEEF)
25
26
  outputIndex: number
26
27
  topic: string
28
+ offChainValues?: number[]
27
29
  }
28
30
 
29
31
  /* ---------------------------------------------------------------------------
@@ -52,6 +54,7 @@ export type OutputSpent =
52
54
  inputIndex: number
53
55
  unlockingScript: Script
54
56
  sequenceNumber: number
57
+ offChainValues?: number[]
55
58
  }
56
59
  | { // «whole-tx» – full spending TX
57
60
  mode: 'whole-tx'
@@ -59,6 +62,7 @@ export type OutputSpent =
59
62
  outputIndex: number
60
63
  topic: string
61
64
  spendingAtomicBEEF: number[]
65
+ offChainValues?: number[]
62
66
  }
63
67
 
64
68
  /* ---------------------------------------------------------------------------
@@ -121,7 +125,7 @@ export interface LookupService {
121
125
  /* -------------------------------------------------------------------------
122
126
  * Query API
123
127
  * ----------------------------------------------------------------------- */
124
- lookup: (question: LookupQuestion) => Promise<LookupAnswer | LookupFormula>
128
+ lookup: (question: LookupQuestion) => Promise<LookupFormula>
125
129
 
126
130
  /* -------------------------------------------------------------------------
127
131
  * Documentation helpers
@@ -9,13 +9,13 @@ export interface TopicManager {
9
9
  * Accepts the transaction in BEEF format and an array of those input indices which spend previously-admitted outputs from the same topic.
10
10
  * The transaction's BEEF structure will always contain the transactions associated with previous coins for reference (if any), regardless of whether the current transaction was directly proven.
11
11
  */
12
- identifyAdmissibleOutputs: (beef: number[], previousCoins: number[]) => Promise<AdmittanceInstructions>
12
+ identifyAdmissibleOutputs: (beef: number[], previousCoins: number[], offChainValues?: number[]) => Promise<AdmittanceInstructions>
13
13
 
14
14
  /**
15
15
  * Identifies and returns the inputs needed to anchor any topical outputs from this transaction to their associated previous history.
16
16
  * @throws - if there are no potentially valid topical outputs in this transaction
17
17
  */
18
- identifyNeededInputs?: (beef: number[]) => Promise<Array<{ txid: string, outputIndex: number }>>
18
+ identifyNeededInputs?: (beef: number[], offChainValues?: number[]) => Promise<Array<{ txid: string, outputIndex: number }>>
19
19
 
20
20
  /**
21
21
  * Returns a Markdown-formatted documentation string for the topic manager.
@@ -534,7 +534,7 @@ describe('BSV Overlay Services Engine', () => {
534
534
  beef: exampleBeef,
535
535
  topics: ['Hello']
536
536
  })
537
- expect(engine.managers.Hello.identifyAdmissibleOutputs).toHaveBeenCalledWith(exampleBeef, [0])
537
+ expect(engine.managers.Hello.identifyAdmissibleOutputs).toHaveBeenCalledWith(exampleBeef, [0], undefined)
538
538
  })
539
539
  describe('When previous UTXOs were retained by the topic manager', () => {
540
540
  it('Notifies all lookup services about the output being spent (not deleted, see the comment about this in deleteUTXODeep)', async () => {
@@ -1,3 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=AdmittanceInstructions.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"AdmittanceInstructions.js","sourceRoot":"","sources":["../../../src/AdmittanceInstructions.ts"],"names":[],"mappings":""}
@@ -1,3 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=LookupAnswer.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"LookupAnswer.js","sourceRoot":"","sources":["../../../src/LookupAnswer.ts"],"names":[],"mappings":""}
@@ -1,3 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=LookupQuestion.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"LookupQuestion.js","sourceRoot":"","sources":["../../../src/LookupQuestion.ts"],"names":[],"mappings":""}
@@ -1,3 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=SHIPAdvertisement.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"SHIPAdvertisement.js","sourceRoot":"","sources":["../../../src/SHIPAdvertisement.ts"],"names":[],"mappings":""}
@@ -1,3 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=SLAPAdvertisement.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"SLAPAdvertisement.js","sourceRoot":"","sources":["../../../src/SLAPAdvertisement.ts"],"names":[],"mappings":""}
@@ -1,3 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=STEAK.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"STEAK.js","sourceRoot":"","sources":["../../../src/STEAK.ts"],"names":[],"mappings":""}
@@ -1,3 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=TaggedBEEF.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"TaggedBEEF.js","sourceRoot":"","sources":["../../../src/TaggedBEEF.ts"],"names":[],"mappings":""}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=AdmittanceInstructions.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"AdmittanceInstructions.js","sourceRoot":"","sources":["../../../src/AdmittanceInstructions.ts"],"names":[],"mappings":""}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=LookupAnswer.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"LookupAnswer.js","sourceRoot":"","sources":["../../../src/LookupAnswer.ts"],"names":[],"mappings":""}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=LookupQuestion.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"LookupQuestion.js","sourceRoot":"","sources":["../../../src/LookupQuestion.ts"],"names":[],"mappings":""}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=SHIPAdvertisement.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"SHIPAdvertisement.js","sourceRoot":"","sources":["../../../src/SHIPAdvertisement.ts"],"names":[],"mappings":""}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=SLAPAdvertisement.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"SLAPAdvertisement.js","sourceRoot":"","sources":["../../../src/SLAPAdvertisement.ts"],"names":[],"mappings":""}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=STEAK.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"STEAK.js","sourceRoot":"","sources":["../../../src/STEAK.ts"],"names":[],"mappings":""}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=TaggedBEEF.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"TaggedBEEF.js","sourceRoot":"","sources":["../../../src/TaggedBEEF.ts"],"names":[],"mappings":""}
@@ -1,14 +0,0 @@
1
- /**
2
- * Instructs the Overlay Services Engine about which outputs to admit and which previous outputs to retain. Returned by a Topic Manager.
3
- */
4
- export type AdmittanceInstructions = {
5
- /**
6
- * The indices of all admissable outputs into the managed topic from the provided transaction.
7
- */
8
- outputsToAdmit: number[];
9
- /**
10
- * The indices of all inputs from the provided transaction which spend previously-admitted outputs that should be retained for historical record-keeping.
11
- */
12
- coinsToRetain: number[];
13
- };
14
- //# sourceMappingURL=AdmittanceInstructions.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"AdmittanceInstructions.d.ts","sourceRoot":"","sources":["../../../src/AdmittanceInstructions.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,MAAM,sBAAsB,GAAG;IACnC;;OAEG;IACH,cAAc,EAAE,MAAM,EAAE,CAAA;IAExB;;OAEG;IACH,aAAa,EAAE,MAAM,EAAE,CAAA;CACxB,CAAA"}
@@ -1,15 +0,0 @@
1
- /**
2
- * How the Overlay Services Engine responds to a Lookup Question.
3
- * It may comprise either an output list or a freeform response from the Lookup Service.
4
- */
5
- export type LookupAnswer = {
6
- type: 'output-list';
7
- outputs: Array<{
8
- beef: number[];
9
- outputIndex: number;
10
- }>;
11
- } | {
12
- type: 'freeform';
13
- result: unknown;
14
- };
15
- //# sourceMappingURL=LookupAnswer.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"LookupAnswer.d.ts","sourceRoot":"","sources":["../../../src/LookupAnswer.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,MAAM,YAAY,GAAG;IACzB,IAAI,EAAE,aAAa,CAAA;IACnB,OAAO,EAAE,KAAK,CAAC;QACb,IAAI,EAAE,MAAM,EAAE,CAAA;QACd,WAAW,EAAE,MAAM,CAAA;KACpB,CAAC,CAAA;CACH,GAAG;IACF,IAAI,EAAE,UAAU,CAAA;IAChB,MAAM,EAAE,OAAO,CAAA;CAChB,CAAA"}
@@ -1,15 +0,0 @@
1
- /**
2
- * The question asked to the Overlay Services Engine when a consumer of state wishes to look up information.
3
- */
4
- export type LookupQuestion = {
5
- /**
6
- * The identifier for a Lookup Service which the person asking the question wishes to use.
7
- */
8
- service: string;
9
- /**
10
- * The query which will be forwarded to the Lookup Service.
11
- * Its type depends on that prescribed by the Lookup Service employed.
12
- */
13
- query: unknown;
14
- };
15
- //# sourceMappingURL=LookupQuestion.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"LookupQuestion.d.ts","sourceRoot":"","sources":["../../../src/LookupQuestion.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG;IAC3B;;OAEG;IACH,OAAO,EAAE,MAAM,CAAA;IAEf;;;OAGG;IACH,KAAK,EAAE,OAAO,CAAA;CACf,CAAA"}
@@ -1,9 +0,0 @@
1
- export interface SHIPAdvertisement {
2
- protocol: 'SHIP';
3
- identityKey: string;
4
- domain: string;
5
- topic: string;
6
- beef?: number[];
7
- outputIndex?: number;
8
- }
9
- //# sourceMappingURL=SHIPAdvertisement.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"SHIPAdvertisement.d.ts","sourceRoot":"","sources":["../../../src/SHIPAdvertisement.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,iBAAiB;IAChC,QAAQ,EAAE,MAAM,CAAA;IAChB,WAAW,EAAE,MAAM,CAAA;IACnB,MAAM,EAAE,MAAM,CAAA;IACd,KAAK,EAAE,MAAM,CAAA;IACb,IAAI,CAAC,EAAE,MAAM,EAAE,CAAA;IACf,WAAW,CAAC,EAAE,MAAM,CAAA;CACrB"}
@@ -1,9 +0,0 @@
1
- export interface SLAPAdvertisement {
2
- protocol: 'SLAP';
3
- identityKey: string;
4
- domain: string;
5
- service: string;
6
- beef?: number[];
7
- outputIndex?: number;
8
- }
9
- //# sourceMappingURL=SLAPAdvertisement.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"SLAPAdvertisement.d.ts","sourceRoot":"","sources":["../../../src/SLAPAdvertisement.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,iBAAiB;IAChC,QAAQ,EAAE,MAAM,CAAA;IAChB,WAAW,EAAE,MAAM,CAAA;IACnB,MAAM,EAAE,MAAM,CAAA;IACd,OAAO,EAAE,MAAM,CAAA;IACf,IAAI,CAAC,EAAE,MAAM,EAAE,CAAA;IACf,WAAW,CAAC,EAAE,MAAM,CAAA;CACrB"}
@@ -1,10 +0,0 @@
1
- import { AdmittanceInstructions } from './AdmittanceInstructions.js';
2
- /**
3
- * Submitted Transaction Execution AcKnowledgment
4
- *
5
- * @description
6
- * Comprises the topics where a transaction was submitted, and for each one, the output indices for the UTXOs newly admitted into the topics, and the coins retained.
7
- * An object whose keys are topic names and whose values are topical admittance instructions denoting the state of the submitted transaction with respect to the associated topic.
8
- */
9
- export type STEAK = Record<string, AdmittanceInstructions>;
10
- //# sourceMappingURL=STEAK.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"STEAK.d.ts","sourceRoot":"","sources":["../../../src/STEAK.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAA;AAEpE;;;;;;GAMG;AACH,MAAM,MAAM,KAAK,GAAG,MAAM,CAAC,MAAM,EAAE,sBAAsB,CAAC,CAAA"}
@@ -1,11 +0,0 @@
1
- /**
2
- * Tagged BEEF
3
- *
4
- * @description
5
- * Tagged BEEF ([Background Evaluation Extended Format](https://brc.dev/62)) structure. Comprises a transaction, its SPV information, and the overlay topics where its inclusion is requested.
6
- */
7
- export type TaggedBEEF = {
8
- beef: number[];
9
- topics: string[];
10
- };
11
- //# sourceMappingURL=TaggedBEEF.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"TaggedBEEF.d.ts","sourceRoot":"","sources":["../../../src/TaggedBEEF.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,MAAM,UAAU,GAAG;IACvB,IAAI,EAAE,MAAM,EAAE,CAAA;IACd,MAAM,EAAE,MAAM,EAAE,CAAA;CACjB,CAAA"}