@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.
- package/dist/cjs/package.json +2 -2
- package/dist/cjs/src/Engine.js +15 -14
- package/dist/cjs/src/Engine.js.map +1 -1
- package/dist/cjs/src/GASP/GASP.js +283 -0
- package/dist/cjs/src/GASP/GASP.js.map +1 -0
- package/dist/cjs/src/GASP/OverlayGASPStorage.js +1 -1
- package/dist/cjs/src/GASP/OverlayGASPStorage.js.map +1 -1
- package/dist/cjs/tsconfig.cjs.tsbuildinfo +1 -1
- package/dist/esm/src/Engine.js +15 -14
- package/dist/esm/src/Engine.js.map +1 -1
- package/dist/esm/src/GASP/GASP.js +288 -0
- package/dist/esm/src/GASP/GASP.js.map +1 -0
- package/dist/esm/src/GASP/OverlayGASPStorage.js +2 -2
- package/dist/esm/src/GASP/OverlayGASPStorage.js.map +1 -1
- package/dist/esm/tsconfig.esm.tsbuildinfo +1 -1
- package/dist/types/src/Engine.d.ts +2 -1
- package/dist/types/src/Engine.d.ts.map +1 -1
- package/dist/types/src/GASP/GASP.d.ts +218 -0
- package/dist/types/src/GASP/GASP.d.ts.map +1 -0
- package/dist/types/src/LookupFormula.d.ts +4 -0
- package/dist/types/src/LookupFormula.d.ts.map +1 -1
- package/dist/types/src/LookupService.d.ts +6 -2
- package/dist/types/src/LookupService.d.ts.map +1 -1
- package/dist/types/src/TopicManager.d.ts +2 -2
- package/dist/types/src/TopicManager.d.ts.map +1 -1
- package/dist/types/tsconfig.types.tsbuildinfo +1 -1
- package/package.json +2 -2
- package/src/Engine.ts +16 -17
- package/src/GASP/OverlayGASPStorage.ts +2 -2
- package/src/LookupFormula.ts +5 -0
- package/src/LookupService.ts +5 -1
- package/src/TopicManager.ts +2 -2
- package/src/__tests/Engine.test.ts +1 -1
- package/dist/cjs/src/AdmittanceInstructions.js +0 -3
- package/dist/cjs/src/AdmittanceInstructions.js.map +0 -1
- package/dist/cjs/src/LookupAnswer.js +0 -3
- package/dist/cjs/src/LookupAnswer.js.map +0 -1
- package/dist/cjs/src/LookupQuestion.js +0 -3
- package/dist/cjs/src/LookupQuestion.js.map +0 -1
- package/dist/cjs/src/SHIPAdvertisement.js +0 -3
- package/dist/cjs/src/SHIPAdvertisement.js.map +0 -1
- package/dist/cjs/src/SLAPAdvertisement.js +0 -3
- package/dist/cjs/src/SLAPAdvertisement.js.map +0 -1
- package/dist/cjs/src/STEAK.js +0 -3
- package/dist/cjs/src/STEAK.js.map +0 -1
- package/dist/cjs/src/TaggedBEEF.js +0 -3
- package/dist/cjs/src/TaggedBEEF.js.map +0 -1
- package/dist/esm/src/AdmittanceInstructions.js +0 -2
- package/dist/esm/src/AdmittanceInstructions.js.map +0 -1
- package/dist/esm/src/LookupAnswer.js +0 -2
- package/dist/esm/src/LookupAnswer.js.map +0 -1
- package/dist/esm/src/LookupQuestion.js +0 -2
- package/dist/esm/src/LookupQuestion.js.map +0 -1
- package/dist/esm/src/SHIPAdvertisement.js +0 -2
- package/dist/esm/src/SHIPAdvertisement.js.map +0 -1
- package/dist/esm/src/SLAPAdvertisement.js +0 -2
- package/dist/esm/src/SLAPAdvertisement.js.map +0 -1
- package/dist/esm/src/STEAK.js +0 -2
- package/dist/esm/src/STEAK.js.map +0 -1
- package/dist/esm/src/TaggedBEEF.js +0 -2
- package/dist/esm/src/TaggedBEEF.js.map +0 -1
- package/dist/types/src/AdmittanceInstructions.d.ts +0 -14
- package/dist/types/src/AdmittanceInstructions.d.ts.map +0 -1
- package/dist/types/src/LookupAnswer.d.ts +0 -15
- package/dist/types/src/LookupAnswer.d.ts.map +0 -1
- package/dist/types/src/LookupQuestion.d.ts +0 -15
- package/dist/types/src/LookupQuestion.d.ts.map +0 -1
- package/dist/types/src/SHIPAdvertisement.d.ts +0 -9
- package/dist/types/src/SHIPAdvertisement.d.ts.map +0 -1
- package/dist/types/src/SLAPAdvertisement.d.ts +0 -9
- package/dist/types/src/SLAPAdvertisement.d.ts.map +0 -1
- package/dist/types/src/STEAK.d.ts +0 -10
- package/dist/types/src/STEAK.d.ts.map +0 -1
- package/dist/types/src/TaggedBEEF.d.ts +0 -11
- package/dist/types/src/TaggedBEEF.d.ts.map +0 -1
package/src/LookupFormula.ts
CHANGED
|
@@ -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
|
}>
|
package/src/LookupService.ts
CHANGED
|
@@ -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<
|
|
128
|
+
lookup: (question: LookupQuestion) => Promise<LookupFormula>
|
|
125
129
|
|
|
126
130
|
/* -------------------------------------------------------------------------
|
|
127
131
|
* Documentation helpers
|
package/src/TopicManager.ts
CHANGED
|
@@ -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 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"AdmittanceInstructions.js","sourceRoot":"","sources":["../../../src/AdmittanceInstructions.ts"],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"LookupAnswer.js","sourceRoot":"","sources":["../../../src/LookupAnswer.ts"],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"LookupQuestion.js","sourceRoot":"","sources":["../../../src/LookupQuestion.ts"],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"SHIPAdvertisement.js","sourceRoot":"","sources":["../../../src/SHIPAdvertisement.ts"],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"SLAPAdvertisement.js","sourceRoot":"","sources":["../../../src/SLAPAdvertisement.ts"],"names":[],"mappings":""}
|
package/dist/cjs/src/STEAK.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"STEAK.js","sourceRoot":"","sources":["../../../src/STEAK.ts"],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"TaggedBEEF.js","sourceRoot":"","sources":["../../../src/TaggedBEEF.ts"],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"AdmittanceInstructions.js","sourceRoot":"","sources":["../../../src/AdmittanceInstructions.ts"],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"LookupAnswer.js","sourceRoot":"","sources":["../../../src/LookupAnswer.ts"],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"LookupQuestion.js","sourceRoot":"","sources":["../../../src/LookupQuestion.ts"],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"SHIPAdvertisement.js","sourceRoot":"","sources":["../../../src/SHIPAdvertisement.ts"],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"SLAPAdvertisement.js","sourceRoot":"","sources":["../../../src/SLAPAdvertisement.ts"],"names":[],"mappings":""}
|
package/dist/esm/src/STEAK.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"STEAK.js","sourceRoot":"","sources":["../../../src/STEAK.ts"],"names":[],"mappings":""}
|
|
@@ -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 +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 +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"}
|