@sig-net/midnight 0.13.0 → 0.15.0
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/README.md +39 -12
- package/dist/ecdsa-attestation.d.ts +29 -1
- package/dist/ecdsa-attestation.d.ts.map +1 -1
- package/dist/ecdsa-attestation.js +55 -0
- package/dist/ecdsa-attestation.js.map +1 -1
- package/dist/managed/compiler/contract-info.json +12 -8
- package/dist/managed/compiler/contract-manifest.json +8 -8
- package/dist/managed/contract/index.d.ts +10 -10
- package/dist/managed/contract/index.js +92 -84
- package/dist/managed/contract/index.js.map +1 -1
- package/dist/signature-requests-state-reader.d.ts +6 -5
- package/dist/signature-requests-state-reader.d.ts.map +1 -1
- package/dist/signature-requests-state-reader.js +17 -16
- package/dist/signature-requests-state-reader.js.map +1 -1
- package/dist/signature-state-reading.d.ts +17 -25
- package/dist/signature-state-reading.d.ts.map +1 -1
- package/dist/signature-state-reading.js +37 -57
- package/dist/signature-state-reading.js.map +1 -1
- package/dist/signet-contract-state-reader.d.ts +24 -18
- package/dist/signet-contract-state-reader.d.ts.map +1 -1
- package/dist/signet-contract-state-reader.js +42 -32
- package/dist/signet-contract-state-reader.js.map +1 -1
- package/dist/signet-request-resolver.d.ts +1 -1
- package/dist/signet-request-resolver.js +2 -2
- package/dist/signet-request-resolver.js.map +1 -1
- package/dist/signet-request-response-reader.d.ts +39 -14
- package/dist/signet-request-response-reader.d.ts.map +1 -1
- package/dist/signet-request-response-reader.js +38 -10
- package/dist/signet-request-response-reader.js.map +1 -1
- package/package.json +2 -2
- package/src/Signet.compact +102 -70
|
@@ -2,17 +2,17 @@
|
|
|
2
2
|
// request ledger fields out of a contract's raw state WITHOUT the compiled
|
|
3
3
|
// contract. This is how the MPC monitor consumes signet contracts: it has only
|
|
4
4
|
// a contract address, queries raw state from the indexer
|
|
5
|
-
// (queryContractState(address).data), and decodes by ledger
|
|
5
|
+
// (queryContractState(address).data), and decodes by ledger-tree PATH.
|
|
6
6
|
// A contract is free to place its request index at any field: the caller
|
|
7
|
-
// supplies the
|
|
8
|
-
// notification's
|
|
9
|
-
// The compiled contract's generated ledger()
|
|
7
|
+
// supplies the resolved path, which the discovery path learns from the
|
|
8
|
+
// notification's requestsPath (sourced from the caller's contract-info.json).
|
|
9
|
+
// The compiled contract's generated ledger() follows exactly this path internally.
|
|
10
10
|
// The record descriptors themselves are the parameterised twins in
|
|
11
11
|
// signet-requests.ts. The generic tree walk and shared base descriptors live
|
|
12
12
|
// in signature-state-reading.ts.
|
|
13
13
|
import { calculateRequestId, signBidirectionalEventDescriptor, } from "./signet-evtype2tx-requests.js";
|
|
14
14
|
import { requestIdHex, } from "./signet-requests.js";
|
|
15
|
-
import { requestIdType,
|
|
15
|
+
import { requestIdType, signetFieldNodeByPath, u64, } from "./signature-state-reading.js";
|
|
16
16
|
/**
|
|
17
17
|
* Aligned-value entry count of an event record EXCLUDING the capacity-scaled
|
|
18
18
|
* vectors: sender (1) + requestNonce (1) + keyVersion (1) + path (1) +
|
|
@@ -115,16 +115,16 @@ function decodeSignBidirectionalEvent(atoms, expectedRequestId) {
|
|
|
115
115
|
*
|
|
116
116
|
* @param raw - Raw contract state, e.g. `queryContractState(address).data`
|
|
117
117
|
* from the indexer or `ctx.currentQueryContext.state` from the simulator.
|
|
118
|
-
* @param
|
|
119
|
-
* @param
|
|
118
|
+
* @param requestsIndexPath - Resolved ledger-tree path of the request index.
|
|
119
|
+
* @param noncePath - Resolved ledger-tree path of the request counter.
|
|
120
120
|
* @returns The decoded {@link SignetRequestsLedger}.
|
|
121
121
|
* @throws Error if a field is missing, has the wrong state-value shape, or a
|
|
122
122
|
* record matches no capacity split.
|
|
123
123
|
*/
|
|
124
|
-
export function readSignetRequestsLedgerFromState(raw,
|
|
125
|
-
const map =
|
|
124
|
+
export function readSignetRequestsLedgerFromState(raw, requestsIndexPath, noncePath) {
|
|
125
|
+
const map = signetFieldNodeByPath(raw, requestsIndexPath).asMap();
|
|
126
126
|
if (map === undefined) {
|
|
127
|
-
throw new Error(`Ledger field ${
|
|
127
|
+
throw new Error(`Ledger field at path ${JSON.stringify(requestsIndexPath)} is not a Map`);
|
|
128
128
|
}
|
|
129
129
|
const requestsIndex = new Map();
|
|
130
130
|
for (const key of map.keys()) {
|
|
@@ -135,9 +135,9 @@ export function readSignetRequestsLedgerFromState(raw, requestsIndexField, nonce
|
|
|
135
135
|
continue;
|
|
136
136
|
requestsIndex.set(requestId, decodeSignBidirectionalEvent(cell.value, requestId));
|
|
137
137
|
}
|
|
138
|
-
const nonceCell =
|
|
138
|
+
const nonceCell = signetFieldNodeByPath(raw, noncePath).asCell();
|
|
139
139
|
if (nonceCell === undefined) {
|
|
140
|
-
throw new Error(`Ledger field ${
|
|
140
|
+
throw new Error(`Ledger field at path ${JSON.stringify(noncePath)} is not a Cell`);
|
|
141
141
|
}
|
|
142
142
|
const nonce = u64.fromValue([...nonceCell.value]);
|
|
143
143
|
return { nonce, requestsIndex };
|
|
@@ -163,17 +163,18 @@ export function readSignetRequestsLedgerFromState(raw, requestsIndexField, nonce
|
|
|
163
163
|
* fieldIndex, …).requestsIndex.get(requestId)`.
|
|
164
164
|
*
|
|
165
165
|
* @param raw - Raw contract state, e.g. `queryContractState(address).data`.
|
|
166
|
-
* @param
|
|
166
|
+
* @param requestsPath - Resolved ledger-tree path of the request index in
|
|
167
|
+
* `raw`, as the notification carries it.
|
|
167
168
|
* @param requestId - The request id to look up.
|
|
168
169
|
* @returns The stored request record, or `undefined` when it is not a member.
|
|
169
170
|
*/
|
|
170
|
-
export function lookupSignetRequestAt(raw,
|
|
171
|
+
export function lookupSignetRequestAt(raw, requestsPath, requestId) {
|
|
171
172
|
let node;
|
|
172
173
|
try {
|
|
173
|
-
node =
|
|
174
|
+
node = signetFieldNodeByPath(raw, requestsPath);
|
|
174
175
|
}
|
|
175
176
|
catch {
|
|
176
|
-
return undefined; //
|
|
177
|
+
return undefined; // path out of range for this contract
|
|
177
178
|
}
|
|
178
179
|
const map = node.asMap();
|
|
179
180
|
if (map === undefined) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"signature-requests-state-reader.js","sourceRoot":"","sources":["../src/signature-requests-state-reader.ts"],"names":[],"mappings":"AAAA,gFAAgF;AAChF,2EAA2E;AAC3E,+EAA+E;AAC/E,yDAAyD;AACzD,
|
|
1
|
+
{"version":3,"file":"signature-requests-state-reader.js","sourceRoot":"","sources":["../src/signature-requests-state-reader.ts"],"names":[],"mappings":"AAAA,gFAAgF;AAChF,2EAA2E;AAC3E,+EAA+E;AAC/E,yDAAyD;AACzD,uEAAuE;AACvE,yEAAyE;AACzE,uEAAuE;AACvE,8EAA8E;AAC9E,mFAAmF;AACnF,mEAAmE;AACnE,6EAA6E;AAC7E,iCAAiC;AAIjC,OAAO,EACL,kBAAkB,EAClB,gCAAgC,GACjC,MAAM,gCAAgC,CAAC;AACxC,OAAO,EACL,YAAY,GAIb,MAAM,sBAAsB,CAAC;AAK9B,OAAO,EACL,aAAa,EACb,qBAAqB,EACrB,GAAG,GAEJ,MAAM,8BAA8B,CAAC;AAEtC;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,MAAM,yBAAyB,GAAG,EAAE,CAAC;AAE5C;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,SAAS,4BAA4B,CACnC,KAAmB,EACnB,iBAA+B;IAE/B,MAAM,QAAQ,GAAG,KAAK,CAAC,MAAM,GAAG,yBAAyB,CAAC;IAC1D,IAAI,QAAQ,GAAG,CAAC,EAAE,CAAC;QACjB,MAAM,IAAI,KAAK,CACb,sBAAsB,KAAK,CAAC,MAAM,iCAAiC;YACjE,GAAG,yBAAyB,wBAAwB,CACvD,CAAC;IACJ,CAAC;IACD,MAAM,wBAAwB,GAAI,KAAK,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAgB,CAAC,MAAM,CAAC;IAChF,MAAM,uBAAuB,GAAI,KAAK,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,C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AC;YACvB,OAAO,SAAS,CAAC;QACnB,CAAC;QACD,IAAI,CAAC;YACH,OAAO,4BAA4B,CAAC,IAAI,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC;QAC7D,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,SAAS,CAAC,CAAC,gDAAgD;QACpE,CAAC;IACH,CAAC;IACD,OAAO,SAAS,CAAC,CAAC,2BAA2B;AAC/C,CAAC"}
|
|
@@ -19,33 +19,25 @@ export type RawContractState = StateValue | {
|
|
|
19
19
|
state: StateValue;
|
|
20
20
|
};
|
|
21
21
|
/**
|
|
22
|
-
*
|
|
23
|
-
* MPC-perspective primitive
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
22
|
+
* Follow a resolved ledger-tree path to its node in raw state: the
|
|
23
|
+
* MPC-perspective primitive, given only a contract's raw state and the path a
|
|
24
|
+
* notification carries. It walks the path node for node, exactly as the
|
|
25
|
+
* compiled `ledger()` accessor does, and never inspects array widths or
|
|
26
|
+
* re-derives the compiler's chunk structure.
|
|
27
27
|
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
* become [1, 15x15] one level deeper. Every chunk on the rightmost spine
|
|
35
|
-
* is therefore always FULL (exactly {@link CHUNK_ARITY} entries).
|
|
36
|
-
*
|
|
37
|
-
* Chunk detection walks that rightmost spine: each consecutive
|
|
38
|
-
* arity-{@link CHUNK_ARITY} array is one chunk level to flatten. This never
|
|
39
|
-
* misreads a field node as a chunk, because no ledger ADT stores an
|
|
40
|
-
* arity-15 array at field level; in particular a `List` (array-typed, like
|
|
41
|
-
* a chunk) is a fixed THREE-slot cons node. The one theoretical blind spot
|
|
42
|
-
* is a future ADT whose field node is an arity-15 array sitting exactly at
|
|
43
|
-
* the last declared field of a contract.
|
|
28
|
+
* The path is the value compactc records for a field in the client's own
|
|
29
|
+
* `contract-info.json` (`"index"`): a single-element path (`[4]`) for a flat
|
|
30
|
+
* contract's field, a longer one (`[1, 14]`) once a contract declares more
|
|
31
|
+
* than 15 fields and the compiler stores them in a chunk tree. Because the
|
|
32
|
+
* consumer is told the path rather than guessing it, no field whose own value
|
|
33
|
+
* is an array can be mistaken for a compiler chunk.
|
|
44
34
|
*
|
|
45
35
|
* @param raw - Raw contract state from the indexer or simulator.
|
|
46
|
-
* @param
|
|
47
|
-
*
|
|
48
|
-
* @
|
|
36
|
+
* @param path - Resolved chunk-tree path in declaration order, from the
|
|
37
|
+
* notification (which sources it from the client's `contract-info.json`).
|
|
38
|
+
* @returns The `StateValue` node at the end of the path.
|
|
39
|
+
* @throws Error if `path` is empty, steps into a non-array, or an index is out
|
|
40
|
+
* of range.
|
|
49
41
|
*/
|
|
50
|
-
export declare function
|
|
42
|
+
export declare function signetFieldNodeByPath(raw: RawContractState, path: readonly number[]): StateValue;
|
|
51
43
|
//# sourceMappingURL=signature-state-reading.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"signature-state-reading.d.ts","sourceRoot":"","sources":["../src/signature-state-reading.ts"],"names":[],"mappings":"AAQA,OAAO,EACL,gBAAgB,EAChB,0BAA0B,EAC1B,KAAK,WAAW,EAChB,KAAK,UAAU,EAChB,MAAM,iCAAiC,CAAC;AAEzC,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAOtD,qEAAqE;AACrE,eAAO,MAAM,GAAG,4BAA2D,CAAC;AAE5E,4CAA4C;AAC5C,eAAO,MAAM,OAAO,kBAA2B,CAAC;AAEhD;;;;GAIG;AACH,eAAO,MAAM,aAAa,EAAE,WAAW,CAAC,SAAS,CAAW,CAAC;AAI7D;;;;GAIG;AACH,MAAM,MAAM,gBAAgB,GAAG,UAAU,GAAG;IAAE,KAAK,EAAE,UAAU,CAAA;CAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"signature-state-reading.d.ts","sourceRoot":"","sources":["../src/signature-state-reading.ts"],"names":[],"mappings":"AAQA,OAAO,EACL,gBAAgB,EAChB,0BAA0B,EAC1B,KAAK,WAAW,EAChB,KAAK,UAAU,EAChB,MAAM,iCAAiC,CAAC;AAEzC,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAOtD,qEAAqE;AACrE,eAAO,MAAM,GAAG,4BAA2D,CAAC;AAE5E,4CAA4C;AAC5C,eAAO,MAAM,OAAO,kBAA2B,CAAC;AAEhD;;;;GAIG;AACH,eAAO,MAAM,aAAa,EAAE,WAAW,CAAC,SAAS,CAAW,CAAC;AAI7D;;;;GAIG;AACH,MAAM,MAAM,gBAAgB,GAAG,UAAU,GAAG;IAAE,KAAK,EAAE,UAAU,CAAA;CAAE,CAAC;AAWlE;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,qBAAqB,CACnC,GAAG,EAAE,gBAAgB,EACrB,IAAI,EAAE,SAAS,MAAM,EAAE,GACtB,UAAU,CAwBZ"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
// Common signet raw-state reading, shared by the request and response readers
|
|
2
2
|
// (signature-requests-state-reader.ts, signet-contract-state-reader.ts).
|
|
3
3
|
// This is the MPC-/client-style path: decode a contract's ledger fields out of
|
|
4
|
-
// its raw state WITHOUT the compiled contract,
|
|
5
|
-
//
|
|
6
|
-
//
|
|
4
|
+
// its raw state WITHOUT the compiled contract, following a resolved ledger-tree
|
|
5
|
+
// path. Here live the generic path walk (RawContractState,
|
|
6
|
+
// signetFieldNodeByPath) and the base type descriptors both readers share; each
|
|
7
7
|
// reader adds only the descriptors for its own layout.
|
|
8
8
|
import { CompactTypeBytes, CompactTypeUnsignedInteger, } from "@midnight-ntwrk/compact-runtime";
|
|
9
9
|
import {} from "./signet-requests.js";
|
|
@@ -29,65 +29,45 @@ export const requestIdType = bytes32;
|
|
|
29
29
|
*/
|
|
30
30
|
const unwrap = (raw) => "state" in raw ? raw.state : raw;
|
|
31
31
|
/**
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* Resolve a flat ledger field index to its node in the raw state tree: the
|
|
39
|
-
* MPC-perspective primitive: given only a contract's raw state and a field
|
|
40
|
-
* number (e.g. the `requestsIndexField` a notification names), return that
|
|
41
|
-
* field's block of stored state, regardless of what field types sit before
|
|
42
|
-
* or after it.
|
|
43
|
-
*
|
|
44
|
-
* Layout, as compactc emits it (probed on 4/15/16/20/226-field contracts;
|
|
45
|
-
* the generated `ledger()` reader indexes with exactly these paths):
|
|
46
|
-
* - Up to {@link CHUNK_ARITY} fields: the root array holds the fields
|
|
47
|
-
* directly, field n at `root[n]`.
|
|
48
|
-
* - More fields: a depth-uniform tree of chunk arrays, filled REMAINDER
|
|
49
|
-
* FIRST: 16 fields become chunks of [1, 15], 20 become [5, 15], 226
|
|
50
|
-
* become [1, 15x15] one level deeper. Every chunk on the rightmost spine
|
|
51
|
-
* is therefore always FULL (exactly {@link CHUNK_ARITY} entries).
|
|
32
|
+
* Follow a resolved ledger-tree path to its node in raw state: the
|
|
33
|
+
* MPC-perspective primitive, given only a contract's raw state and the path a
|
|
34
|
+
* notification carries. It walks the path node for node, exactly as the
|
|
35
|
+
* compiled `ledger()` accessor does, and never inspects array widths or
|
|
36
|
+
* re-derives the compiler's chunk structure.
|
|
52
37
|
*
|
|
53
|
-
*
|
|
54
|
-
*
|
|
55
|
-
*
|
|
56
|
-
*
|
|
57
|
-
*
|
|
58
|
-
* is
|
|
59
|
-
* the last declared field of a contract.
|
|
38
|
+
* The path is the value compactc records for a field in the client's own
|
|
39
|
+
* `contract-info.json` (`"index"`): a single-element path (`[4]`) for a flat
|
|
40
|
+
* contract's field, a longer one (`[1, 14]`) once a contract declares more
|
|
41
|
+
* than 15 fields and the compiler stores them in a chunk tree. Because the
|
|
42
|
+
* consumer is told the path rather than guessing it, no field whose own value
|
|
43
|
+
* is an array can be mistaken for a compiler chunk.
|
|
60
44
|
*
|
|
61
45
|
* @param raw - Raw contract state from the indexer or simulator.
|
|
62
|
-
* @param
|
|
63
|
-
*
|
|
64
|
-
* @
|
|
46
|
+
* @param path - Resolved chunk-tree path in declaration order, from the
|
|
47
|
+
* notification (which sources it from the client's `contract-info.json`).
|
|
48
|
+
* @returns The `StateValue` node at the end of the path.
|
|
49
|
+
* @throws Error if `path` is empty, steps into a non-array, or an index is out
|
|
50
|
+
* of range.
|
|
65
51
|
*/
|
|
66
|
-
export function
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
if (flatIndex === 0)
|
|
70
|
-
return root;
|
|
71
|
-
throw new Error(`Field index ${flatIndex} out of range: root is a leaf`);
|
|
72
|
-
}
|
|
73
|
-
let fields = root.asArray() ?? [];
|
|
74
|
-
// Count chunk levels below the root along the rightmost spine: chunks on
|
|
75
|
-
// it are always full, field nodes never have CHUNK_ARITY entries.
|
|
76
|
-
let chunkLevels = 0;
|
|
77
|
-
let spine = fields[fields.length - 1];
|
|
78
|
-
while (spine !== undefined &&
|
|
79
|
-
spine.type() === "array" &&
|
|
80
|
-
(spine.asArray()?.length ?? 0) === CHUNK_ARITY) {
|
|
81
|
-
chunkLevels += 1;
|
|
82
|
-
const children = spine.asArray() ?? [];
|
|
83
|
-
spine = children[children.length - 1];
|
|
84
|
-
}
|
|
85
|
-
for (let level = 0; level < chunkLevels; level += 1) {
|
|
86
|
-
fields = fields.flatMap((chunk) => chunk.asArray() ?? []);
|
|
52
|
+
export function signetFieldNodeByPath(raw, path) {
|
|
53
|
+
if (path.length === 0) {
|
|
54
|
+
throw new Error("Ledger field path is empty");
|
|
87
55
|
}
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
56
|
+
let node = unwrap(raw);
|
|
57
|
+
for (const [level, index] of path.entries()) {
|
|
58
|
+
if (node.type() !== "array") {
|
|
59
|
+
// A one-field contract stores its field as the bare (non-array) root,
|
|
60
|
+
// addressable only as the whole state at a final [0]; the compiled
|
|
61
|
+
// accessor reads it the same way.
|
|
62
|
+
if (index === 0 && level === path.length - 1)
|
|
63
|
+
return node;
|
|
64
|
+
throw new Error(`Ledger field path ${JSON.stringify(path)} steps into a non-array at level ${level}`);
|
|
65
|
+
}
|
|
66
|
+
const next = (node.asArray() ?? [])[index];
|
|
67
|
+
if (next === undefined) {
|
|
68
|
+
throw new Error(`Ledger field path ${JSON.stringify(path)} index ${index} out of range at level ${level}`);
|
|
69
|
+
}
|
|
70
|
+
node = next;
|
|
91
71
|
}
|
|
92
72
|
return node;
|
|
93
73
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"signature-state-reading.js","sourceRoot":"","sources":["../src/signature-state-reading.ts"],"names":[],"mappings":"AAAA,8EAA8E;AAC9E,yEAAyE;AACzE,+EAA+E;AAC/E
|
|
1
|
+
{"version":3,"file":"signature-state-reading.js","sourceRoot":"","sources":["../src/signature-state-reading.ts"],"names":[],"mappings":"AAAA,8EAA8E;AAC9E,yEAAyE;AACzE,+EAA+E;AAC/E,gFAAgF;AAChF,2DAA2D;AAC3D,gFAAgF;AAChF,uDAAuD;AAEvD,OAAO,EACL,gBAAgB,EAChB,0BAA0B,GAG3B,MAAM,iCAAiC,CAAC;AAEzC,OAAO,EAAkB,MAAM,sBAAsB,CAAC;AAEtD,yCAAyC;AACzC,8EAA8E;AAC9E,+EAA+E;AAC/E,mCAAmC;AAEnC,qEAAqE;AACrE,MAAM,CAAC,MAAM,GAAG,GAAG,IAAI,0BAA0B,CAAC,qBAAqB,EAAE,CAAC,CAAC,CAAC;AAE5E,4CAA4C;AAC5C,MAAM,CAAC,MAAM,OAAO,GAAG,IAAI,gBAAgB,CAAC,EAAE,CAAC,CAAC;AAEhD;;;;GAIG;AACH,MAAM,CAAC,MAAM,aAAa,GAA2B,OAAO,CAAC;AAW7D;;;;;GAKG;AACH,MAAM,MAAM,GAAG,CAAC,GAAqB,EAAc,EAAE,CACnD,OAAO,IAAI,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC;AAEnC;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,UAAU,qBAAqB,CACnC,GAAqB,EACrB,IAAuB;IAEvB,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACtB,MAAM,IAAI,KAAK,CAAC,4BAA4B,CAAC,CAAC;IAChD,CAAC;IACD,IAAI,IAAI,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC;IACvB,KAAK,MAAM,CAAC,KAAK,EAAE,KAAK,CAAC,IAAI,IAAI,CAAC,OAAO,EAAE,EAAE,CAAC;QAC5C,IAAI,IAAI,CAAC,IAAI,EAAE,KAAK,OAAO,EAAE,CAAC;YAC5B,sEAAsE;YACtE,mEAAmE;YACnE,kCAAkC;YAClC,IAAI,KAAK,KAAK,CAAC,IAAI,KAAK,KAAK,IAAI,CAAC,MAAM,GAAG,CAAC;gBAAE,OAAO,IAAI,CAAC;YAC1D,MAAM,IAAI,KAAK,CACb,qBAAqB,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,oCAAoC,KAAK,EAAE,CACrF,CAAC;QACJ,CAAC;QACD,MAAM,IAAI,GAAG,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC;QAC3C,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;YACvB,MAAM,IAAI,KAAK,CACb,qBAAqB,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,UAAU,KAAK,0BAA0B,KAAK,EAAE,CAC1F,CAAC;QACJ,CAAC;QACD,IAAI,GAAG,IAAI,CAAC;IACd,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC"}
|
|
@@ -58,17 +58,17 @@ export interface SignatureRespondedEvent {
|
|
|
58
58
|
export declare const signatureRespondedEventType: CompactType<SignatureRespondedEvent>;
|
|
59
59
|
/**
|
|
60
60
|
* The MPC's respond-bidirectional attestation of a request's remote EVM
|
|
61
|
-
* execution (Compact `RespondBidirectionalEvent`): the
|
|
62
|
-
* `keccak256(requestId || serializedOutput)
|
|
63
|
-
*
|
|
64
|
-
* digest (`calculateSignetAttestationDigest`) and
|
|
65
|
-
*
|
|
66
|
-
*
|
|
67
|
-
* (in-circuit via
|
|
61
|
+
* execution (Compact `RespondBidirectionalEvent`): the ECDSA signature over
|
|
62
|
+
* the attestation digest `keccak256(requestId || serializedOutput)`. Both the
|
|
63
|
+
* digest and the output travel off chain: readers fetch the output, recompute
|
|
64
|
+
* the digest (`calculateSignetAttestationDigest`) and verify the signature
|
|
65
|
+
* over it. Stored UNVERIFIED by the signet contract, so that signature check
|
|
66
|
+
* against the expected MPC response key is the only thing separating a
|
|
67
|
+
* genuine post from garbage (in-circuit via
|
|
68
|
+
* `verifyRespondBidirectionalEvent`, off chain via
|
|
69
|
+
* {@link verifyRespondBidirectionalSignature}).
|
|
68
70
|
*/
|
|
69
71
|
export interface RespondBidirectionalEvent {
|
|
70
|
-
/** The signed attestation digest: `keccak256(requestId || serializedOutput)`. */
|
|
71
|
-
attestationDigest: Uint8Array;
|
|
72
72
|
/** ECDSA signature over the attestation digest. */
|
|
73
73
|
signature: MpcSignature;
|
|
74
74
|
}
|
|
@@ -91,8 +91,8 @@ export interface SignetMapKey {
|
|
|
91
91
|
*/
|
|
92
92
|
export declare const signetMapKeyType: CompactType<SignetMapKey>;
|
|
93
93
|
/**
|
|
94
|
-
* Hand-composed descriptor for {@link RespondBidirectionalEvent}
|
|
95
|
-
*
|
|
94
|
+
* Hand-composed descriptor for {@link RespondBidirectionalEvent}: the single
|
|
95
|
+
* {@link MpcSignature} field, matching the Compact struct.
|
|
96
96
|
*/
|
|
97
97
|
export declare const respondBidirectionalEventType: CompactType<RespondBidirectionalEvent>;
|
|
98
98
|
/**
|
|
@@ -130,11 +130,13 @@ export interface SignBidirectionalNotification {
|
|
|
130
130
|
*/
|
|
131
131
|
callerAddress: string;
|
|
132
132
|
/**
|
|
133
|
-
*
|
|
134
|
-
* {@link callerAddress}
|
|
135
|
-
*
|
|
133
|
+
* Resolved ledger-tree path of the `SignBidirectionalEventMap` in
|
|
134
|
+
* {@link callerAddress}, as compactc records it in that contract's
|
|
135
|
+
* `contract-info.json` (`"index"`): `[4]` for a flat contract's field 4,
|
|
136
|
+
* `[1, 14]` once chunking applies. The reader follows it node for node
|
|
137
|
+
* (see {@link signetFieldNodeByPath}) and never assumes a layout.
|
|
136
138
|
*/
|
|
137
|
-
|
|
139
|
+
requestsPath: number[];
|
|
138
140
|
}
|
|
139
141
|
/**
|
|
140
142
|
* Unpack a stored {@link SignBidirectionalNotificationRecord}'s payload by
|
|
@@ -142,14 +144,18 @@ export interface SignBidirectionalNotification {
|
|
|
142
144
|
* `constructSignBidirectionalEventNotificationV1` circuit (byte plumbing
|
|
143
145
|
* only: the pack↔decode lockstep is pinned by the state-reader unit test that
|
|
144
146
|
* round-trips through the real circuit). V1 layout:
|
|
145
|
-
* callerAddress (32) ++
|
|
147
|
+
* callerAddress (32) ++ requestsPathDepth (1) ++ requestsPath (4) ++ zero
|
|
148
|
+
* padding (91), where only the first `requestsPathDepth` path bytes are
|
|
149
|
+
* meaningful.
|
|
146
150
|
*
|
|
147
151
|
* Fails closed on an unrecognised `version`: a future payload layout adds a
|
|
148
152
|
* branch here rather than silently misinterpreting bytes under the V1 offsets.
|
|
149
153
|
*
|
|
150
154
|
* @param record - The raw on-ledger record.
|
|
151
|
-
* @returns The decoded
|
|
152
|
-
*
|
|
155
|
+
* @returns The decoded notification, its `requestsPath` trimmed to the
|
|
156
|
+
* declared depth.
|
|
157
|
+
* @throws Error if the record's `version` is not one this decoder understands,
|
|
158
|
+
* or its `requestsPathDepth` is zero or exceeds {@link MAX_LEDGER_PATH_DEPTH}.
|
|
153
159
|
*/
|
|
154
160
|
export declare function decodeSignBidirectionalNotification(record: SignBidirectionalNotificationRecord): SignBidirectionalNotification;
|
|
155
161
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"signet-contract-state-reader.d.ts","sourceRoot":"","sources":["../src/signet-contract-state-reader.ts"],"names":[],"mappings":"AAiBA,OAAO,EAGL,KAAK,WAAW,EACjB,MAAM,iCAAiC,CAAC;AAEzC,OAAO,EAGL,KAAK,SAAS,EACd,KAAK,YAAY,EAClB,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EAIL,KAAK,gBAAgB,EACtB,MAAM,8BAA8B,CAAC;AAEtC,8EAA8E;AAC9E,eAAO,MAAM,uDAAuD,IAAI,CAAC;AAEzE,sEAAsE;AACtE,eAAO,MAAM,+CAA+C,IAAI,CAAC;AAEjE,2EAA2E;AAC3E,eAAO,MAAM,yBAAyB,IAAI,CAAC;AAE3C,wEAAwE;AACxE,eAAO,MAAM,iBAAiB,IAAI,CAAC;AAEnC,uFAAuF;AACvF,eAAO,MAAM,uCAAuC,IAAI,CAAC;AAEzD,+EAA+E;AAC/E,eAAO,MAAM,+BAA+B,IAAI,CAAC;AAajD;;;;GAIG;AACH,MAAM,WAAW,WAAW;IAC1B,6CAA6C;IAC7C,CAAC,EAAE,UAAU,CAAC;IACd,6CAA6C;IAC7C,CAAC,EAAE,UAAU,CAAC;CACf;AAED;;;;;;;;GAQG;AACH,MAAM,WAAW,YAAY;IAC3B,qCAAqC;IACrC,IAAI,EAAE,WAAW,CAAC;IAClB,+CAA+C;IAC/C,CAAC,EAAE,UAAU,CAAC;IACd,2CAA2C;IAC3C,UAAU,EAAE,MAAM,CAAC;CACpB;AA2CD;;;;;GAKG;AACH,MAAM,WAAW,uBAAuB;IACtC,0EAA0E;IAC1E,SAAS,EAAE,YAAY,CAAC;CACzB;AAED;;;GAGG;AACH,eAAO,MAAM,2BAA2B,EAAE,WAAW,CAAC,uBAAuB,CAuB5E,CAAC;AAEF
|
|
1
|
+
{"version":3,"file":"signet-contract-state-reader.d.ts","sourceRoot":"","sources":["../src/signet-contract-state-reader.ts"],"names":[],"mappings":"AAiBA,OAAO,EAGL,KAAK,WAAW,EACjB,MAAM,iCAAiC,CAAC;AAEzC,O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WAAW,oBAAoB;IACnC,gEAAgE;IAChE,4CAA4C,EAAE,kBAAkB,CAAC;IACjE;;;OAGG;IACH,qCAAqC,EAAE,kCAAkC,CAAC;IAC1E,6DAA6D;IAC7D,iBAAiB,EAAE,kBAAkB,CAAC;IACtC,mFAAmF;IACnF,UAAU,EAAE,sBAAsB,CAAC;IACnC,yEAAyE;IACzE,8BAA8B,EAAE,kBAAkB,CAAC;IACnD,0FAA0F;IAC1F,uBAAuB,EAAE,yBAAyB,CAAC;CACpD;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,iCAAiC,CAC/C,GAAG,EAAE,gBAAgB,GACpB,oBAAoB,CA2BtB"}
|
|
@@ -12,11 +12,11 @@
|
|
|
12
12
|
// field 5: respondBidirectionalMap (Map<SignetMapKey, RespondBidirectionalEvent>)
|
|
13
13
|
// Every store is an unauthenticated append-only log keyed by
|
|
14
14
|
// (requestId, count): verification is the reader's job. The generic
|
|
15
|
-
// state-tree walk (RawContractState,
|
|
15
|
+
// state-tree walk (RawContractState, signetFieldNodeByPath) and the shared base
|
|
16
16
|
// descriptors live in signature-state-reading.ts.
|
|
17
17
|
import { CompactTypeBytes, CompactTypeUnsignedInteger, } from "@midnight-ntwrk/compact-runtime";
|
|
18
18
|
import { bytesToHex, requestIdHex, } from "./signet-requests.js";
|
|
19
|
-
import { requestIdType,
|
|
19
|
+
import { requestIdType, signetFieldNodeByPath, u64, } from "./signature-state-reading.js";
|
|
20
20
|
/** Signet contract layout: the notification counter map is ledger field 0. */
|
|
21
21
|
export const SIGN_BIDIRECTIONAL_EVENT_NOTIFICATION_COUNTER_MAP_FIELD = 0;
|
|
22
22
|
/** Signet contract layout: the notification map is ledger field 1. */
|
|
@@ -138,39 +138,31 @@ export const signetMapKeyType = {
|
|
|
138
138
|
},
|
|
139
139
|
};
|
|
140
140
|
/**
|
|
141
|
-
* Hand-composed descriptor for {@link RespondBidirectionalEvent}
|
|
142
|
-
*
|
|
141
|
+
* Hand-composed descriptor for {@link RespondBidirectionalEvent}: the single
|
|
142
|
+
* {@link MpcSignature} field, matching the Compact struct.
|
|
143
143
|
*/
|
|
144
144
|
export const respondBidirectionalEventType = {
|
|
145
|
-
/** @returns
|
|
145
|
+
/** @returns Alignment of the struct's single signature field. */
|
|
146
146
|
alignment() {
|
|
147
|
-
return
|
|
148
|
-
.alignment()
|
|
149
|
-
.concat(mpcSignatureType.alignment());
|
|
147
|
+
return mpcSignatureType.alignment();
|
|
150
148
|
},
|
|
151
149
|
/**
|
|
152
|
-
* Decode one response record from an aligned value
|
|
153
|
-
* by field.
|
|
150
|
+
* Decode one response record from an aligned value.
|
|
154
151
|
*
|
|
155
152
|
* @param value - Mutable aligned value cursor: pass a copy.
|
|
156
153
|
* @returns The decoded record.
|
|
157
154
|
*/
|
|
158
155
|
fromValue(value) {
|
|
159
|
-
return {
|
|
160
|
-
attestationDigest: bytes32.fromValue(value),
|
|
161
|
-
signature: mpcSignatureType.fromValue(value),
|
|
162
|
-
};
|
|
156
|
+
return { signature: mpcSignatureType.fromValue(value) };
|
|
163
157
|
},
|
|
164
158
|
/**
|
|
165
159
|
* Encode a response record into its aligned on-ledger representation.
|
|
166
160
|
*
|
|
167
161
|
* @param record - The record to encode.
|
|
168
|
-
* @returns The aligned value
|
|
162
|
+
* @returns The aligned value.
|
|
169
163
|
*/
|
|
170
164
|
toValue(record) {
|
|
171
|
-
return
|
|
172
|
-
.toValue(record.attestationDigest)
|
|
173
|
-
.concat(mpcSignatureType.toValue(record.signature));
|
|
165
|
+
return mpcSignatureType.toValue(record.signature);
|
|
174
166
|
},
|
|
175
167
|
};
|
|
176
168
|
/** Descriptor for the notification's packed V1 payload (`Bytes<128>`). */
|
|
@@ -211,8 +203,16 @@ export const signBidirectionalNotificationType = {
|
|
|
211
203
|
};
|
|
212
204
|
/** Offset of the V1 `callerAddress` in the packed payload (`Bytes<32>` at the front). */
|
|
213
205
|
const NOTIFICATION_CALLER_ADDRESS_OFFSET = 0;
|
|
214
|
-
/** Offset of the V1 `
|
|
215
|
-
const
|
|
206
|
+
/** Offset of the V1 `requestsPathDepth` (after the 32 callerAddress bytes). */
|
|
207
|
+
const NOTIFICATION_PATH_DEPTH_OFFSET = 32;
|
|
208
|
+
/** Offset of the V1 `requestsPath` bytes (after the 1-byte depth). */
|
|
209
|
+
const NOTIFICATION_PATH_OFFSET = 33;
|
|
210
|
+
/**
|
|
211
|
+
* Maximum ledger-tree path depth the V1 payload carries, matching the
|
|
212
|
+
* `Vector<4, Uint<8>>` the `constructSignBidirectionalEventNotificationV1`
|
|
213
|
+
* circuit packs. Depth 1 addresses up to 15 fields, depth 4 up to 15^4.
|
|
214
|
+
*/
|
|
215
|
+
const MAX_LEDGER_PATH_DEPTH = 4;
|
|
216
216
|
/** The only payload interpretation {@link decodeSignBidirectionalNotification} understands today. */
|
|
217
217
|
const SUPPORTED_NOTIFICATION_VERSION = 1n;
|
|
218
218
|
/**
|
|
@@ -221,30 +221,37 @@ const SUPPORTED_NOTIFICATION_VERSION = 1n;
|
|
|
221
221
|
* `constructSignBidirectionalEventNotificationV1` circuit (byte plumbing
|
|
222
222
|
* only: the pack↔decode lockstep is pinned by the state-reader unit test that
|
|
223
223
|
* round-trips through the real circuit). V1 layout:
|
|
224
|
-
* callerAddress (32) ++
|
|
224
|
+
* callerAddress (32) ++ requestsPathDepth (1) ++ requestsPath (4) ++ zero
|
|
225
|
+
* padding (91), where only the first `requestsPathDepth` path bytes are
|
|
226
|
+
* meaningful.
|
|
225
227
|
*
|
|
226
228
|
* Fails closed on an unrecognised `version`: a future payload layout adds a
|
|
227
229
|
* branch here rather than silently misinterpreting bytes under the V1 offsets.
|
|
228
230
|
*
|
|
229
231
|
* @param record - The raw on-ledger record.
|
|
230
|
-
* @returns The decoded
|
|
231
|
-
*
|
|
232
|
+
* @returns The decoded notification, its `requestsPath` trimmed to the
|
|
233
|
+
* declared depth.
|
|
234
|
+
* @throws Error if the record's `version` is not one this decoder understands,
|
|
235
|
+
* or its `requestsPathDepth` is zero or exceeds {@link MAX_LEDGER_PATH_DEPTH}.
|
|
232
236
|
*/
|
|
233
237
|
export function decodeSignBidirectionalNotification(record) {
|
|
234
238
|
if (record.version !== SUPPORTED_NOTIFICATION_VERSION) {
|
|
235
239
|
throw new Error(`SignBidirectionalEventNotification version ${record.version} is not supported ` +
|
|
236
240
|
`(this decoder understands version ${SUPPORTED_NOTIFICATION_VERSION})`);
|
|
237
241
|
}
|
|
238
|
-
const callerAddress = bytesToHex(record.payload.slice(NOTIFICATION_CALLER_ADDRESS_OFFSET,
|
|
239
|
-
const
|
|
240
|
-
if (
|
|
241
|
-
throw new Error(`SignBidirectionalEventNotification
|
|
242
|
-
`
|
|
242
|
+
const callerAddress = bytesToHex(record.payload.slice(NOTIFICATION_CALLER_ADDRESS_OFFSET, NOTIFICATION_PATH_DEPTH_OFFSET));
|
|
243
|
+
const depth = record.payload[NOTIFICATION_PATH_DEPTH_OFFSET];
|
|
244
|
+
if (depth === undefined || depth < 1 || depth > MAX_LEDGER_PATH_DEPTH) {
|
|
245
|
+
throw new Error(`SignBidirectionalEventNotification requestsPathDepth ${depth} is out of range ` +
|
|
246
|
+
`(expected 1 to ${MAX_LEDGER_PATH_DEPTH})`);
|
|
243
247
|
}
|
|
248
|
+
// payload is a re-padded Bytes<128> and depth is bounded to MAX_LEDGER_PATH_DEPTH
|
|
249
|
+
// above, so this slice always yields exactly `depth` bytes.
|
|
250
|
+
const requestsPath = Array.from(record.payload.slice(NOTIFICATION_PATH_OFFSET, NOTIFICATION_PATH_OFFSET + depth));
|
|
244
251
|
return {
|
|
245
252
|
version: Number(record.version),
|
|
246
253
|
callerAddress,
|
|
247
|
-
|
|
254
|
+
requestsPath,
|
|
248
255
|
};
|
|
249
256
|
}
|
|
250
257
|
/**
|
|
@@ -261,7 +268,8 @@ export function signetMapEntryKey(id, count) {
|
|
|
261
268
|
}
|
|
262
269
|
/** Decode a `Map<RequestId, Counter>` ledger field into a {@link SignetCounterIndex}. */
|
|
263
270
|
function readCounterMap(raw, field) {
|
|
264
|
-
|
|
271
|
+
// The central singleton is flat (6 fields), so a field number is a depth-1 path.
|
|
272
|
+
const counterMap = signetFieldNodeByPath(raw, [field]).asMap();
|
|
265
273
|
if (counterMap === undefined) {
|
|
266
274
|
throw new Error(`Ledger field ${field} is not a Map`);
|
|
267
275
|
}
|
|
@@ -279,7 +287,7 @@ function readCounterMap(raw, field) {
|
|
|
279
287
|
}
|
|
280
288
|
/** Decode a `Map<SignetMapKey, T>` ledger field into a string-keyed JS map. */
|
|
281
289
|
function readSignetKeyedMap(raw, field, valueType) {
|
|
282
|
-
const map =
|
|
290
|
+
const map = signetFieldNodeByPath(raw, [field]).asMap();
|
|
283
291
|
if (map === undefined) {
|
|
284
292
|
throw new Error(`Ledger field ${field} is not a Map`);
|
|
285
293
|
}
|
|
@@ -307,7 +315,9 @@ function readSignetKeyedMap(raw, field, valueType) {
|
|
|
307
315
|
* @throws Error if the field is missing or is not a Map.
|
|
308
316
|
*/
|
|
309
317
|
export function readSignBidirectionalNotificationIndexFromState(raw) {
|
|
310
|
-
const notificationMap =
|
|
318
|
+
const notificationMap = signetFieldNodeByPath(raw, [
|
|
319
|
+
SIGN_BIDIRECTIONAL_EVENT_NOTIFICATION_MAP_FIELD,
|
|
320
|
+
]).asMap();
|
|
311
321
|
if (notificationMap === undefined) {
|
|
312
322
|
throw new Error(`Ledger field ${SIGN_BIDIRECTIONAL_EVENT_NOTIFICATION_MAP_FIELD} is not a Map`);
|
|
313
323
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"signet-contract-state-reader.js","sourceRoot":"","sources":["../src/signet-contract-state-reader.ts"],"names":[],"mappings":"AAAA,6EAA6E;AAC7E,uEAAuE;AACvE,6EAA6E;AAC7E,oEAAoE;AACpE,2EAA2E;AAC3E,4BAA4B;AAC5B,oFAAoF;AACpF,qFAAqF;AACrF,yDAAyD;AACzD,qEAAqE;AACrE,sEAAsE;AACtE,oFAAoF;AACpF,6DAA6D;AAC7D,oEAAoE;AACpE,
|
|
1
|
+
{"version":3,"file":"signet-contract-state-reader.js","sourceRoot":"","sources":["../src/signet-contract-state-reader.ts"],"names":[],"mappings":"AAAA,6EAA6E;AAC7E,uEAAuE;AACvE,6EAA6E;AAC7E,oEAAoE;AACpE,2EAA2E;AAC3E,4BAA4B;AAC5B,oFAAoF;AACpF,qFAAqF;AACrF,yDAAyD;AACzD,qEAAqE;AACrE,sEAAsE;AACtE,oFAAoF;AACpF,6DAA6D;AAC7D,oEAAoE;AACpE,gFAAgF;AAChF,kDAAkD;AAElD,OAAO,EACL,gBAAgB,EAChB,0BAA0B,GAE3B,MAAM,iCAAiC,CAAC;AAEzC,OAAO,EACL,UAAU,EACV,YAAY,GAGb,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EACL,aAAa,EACb,qBAAqB,EACrB,GAAG,GAEJ,MAAM,8BAA8B,CAAC;AAEtC,8EAA8E;AAC9E,MAAM,CAAC,MAAM,uDAAuD,GAAG,CAAC,CAAC;AAEzE,sEAAsE;AACtE,MAAM,CAAC,MAAM,+CAA+C,GAAG,CAAC,CAAC;AAEjE,2EAA2E;AAC3E,MAAM,CAAC,MAAM,yBAAyB,GAAG,CAAC,CAAC;AAE3C,wEAAwE;AACxE,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,CAAC;AAEnC,uFAAuF;AACvF,MAAM,CAAC,MAAM,uCAAuC,GAAG,CAAC,CAAC;AAEzD,+EAA+E;AAC/E,MAAM,CAAC,MAAM,+BAA+B,GAAG,CAAC,CAAC;AAEjD,0EAA0E;AAC1E,kEAAkE;AAClE,6EAA6E;AAC7E,+DAA+D;AAE/D,yEAAyE;AACzE,MAAM,OAAO,GAAG,IAAI,gBAAgB,CAAC,EAAE,CAAC,CAAC;AAEzC,oEAAoE;AACpE,MAAM,EAAE,GAAG,IAAI,0BAA0B,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC;AAgCnD;;;GAGG;AACH,MAAM,gBAAgB,GAA8B;IAClD,+EA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AA2B,CAC5B;QACD,8BAA8B,EAAE,cAAc,CAC5C,GAAG,EACH,uCAAuC,CACxC;QACD,uBAAuB,EAAE,kBAAkB,CACzC,GAAG,EACH,+BAA+B,EAC/B,6BAA6B,CAC9B;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -46,7 +46,7 @@ export declare class SignetRequestResolver {
|
|
|
46
46
|
/**
|
|
47
47
|
* Resolve a notification to its authenticated request, or `undefined` when it
|
|
48
48
|
* cannot be trusted: the caller contract has no state, or `requestId` is not
|
|
49
|
-
* a member of the map at `
|
|
49
|
+
* a member of the map at `requestsPath` (forged, stale, wrong field,
|
|
50
50
|
* or not yet indexed — poll again). Never throws on an untrusted
|
|
51
51
|
* notification; a bad one is dropped, not surfaced as an error.
|
|
52
52
|
*
|
|
@@ -38,7 +38,7 @@ export class SignetRequestResolver {
|
|
|
38
38
|
/**
|
|
39
39
|
* Resolve a notification to its authenticated request, or `undefined` when it
|
|
40
40
|
* cannot be trusted: the caller contract has no state, or `requestId` is not
|
|
41
|
-
* a member of the map at `
|
|
41
|
+
* a member of the map at `requestsPath` (forged, stale, wrong field,
|
|
42
42
|
* or not yet indexed — poll again). Never throws on an untrusted
|
|
43
43
|
* notification; a bad one is dropped, not surfaced as an error.
|
|
44
44
|
*
|
|
@@ -62,7 +62,7 @@ export class SignetRequestResolver {
|
|
|
62
62
|
if (!state?.data) {
|
|
63
63
|
return undefined; // no state at the named caller — cannot authenticate
|
|
64
64
|
}
|
|
65
|
-
const request = lookupSignetRequestAt(state.data, notification.
|
|
65
|
+
const request = lookupSignetRequestAt(state.data, notification.requestsPath, requestId);
|
|
66
66
|
if (request === undefined) {
|
|
67
67
|
return undefined; // membership check failed — drop the notification
|
|
68
68
|
}
|