@sig-net/midnight 0.0.6 → 0.0.8
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 +23 -20
- package/dist/constants.d.ts +4 -16
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +4 -16
- package/dist/constants.js.map +1 -1
- package/dist/ecdsa-attestation.d.ts +79 -0
- package/dist/ecdsa-attestation.d.ts.map +1 -0
- package/dist/ecdsa-attestation.js +140 -0
- package/dist/ecdsa-attestation.js.map +1 -0
- package/dist/epsilon-derivation.d.ts +60 -0
- package/dist/epsilon-derivation.d.ts.map +1 -1
- package/dist/epsilon-derivation.js +106 -5
- package/dist/epsilon-derivation.js.map +1 -1
- package/dist/index.d.ts +9 -7
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9 -7
- package/dist/index.js.map +1 -1
- package/dist/managed/compiler/contract-info.json +74 -52
- package/dist/managed/compiler/contract-manifest.json +8 -8
- package/dist/managed/contract/index.d.ts +38 -31
- package/dist/managed/contract/index.js +232 -382
- package/dist/managed/contract/index.js.map +1 -1
- package/dist/signature-requests-state-reader.d.ts +14 -13
- package/dist/signature-requests-state-reader.d.ts.map +1 -1
- package/dist/signature-requests-state-reader.js +31 -20
- package/dist/signature-requests-state-reader.js.map +1 -1
- package/dist/signature-response-verification.d.ts +5 -5
- package/dist/signature-response-verification.d.ts.map +1 -1
- package/dist/signature-response-verification.js +4 -4
- package/dist/signature-response-verification.js.map +1 -1
- package/dist/signet-contract-state-reader.d.ts +101 -112
- package/dist/signet-contract-state-reader.d.ts.map +1 -1
- package/dist/signet-contract-state-reader.js +123 -115
- package/dist/signet-contract-state-reader.js.map +1 -1
- package/dist/signet-request-feed.d.ts +4 -3
- package/dist/signet-request-feed.d.ts.map +1 -1
- package/dist/signet-request-feed.js +9 -8
- package/dist/signet-request-feed.js.map +1 -1
- package/dist/signet-request-resolver.d.ts +6 -4
- package/dist/signet-request-resolver.d.ts.map +1 -1
- package/dist/signet-request-resolver.js +8 -6
- package/dist/signet-request-resolver.js.map +1 -1
- package/dist/signet-request-response-reader.d.ts +21 -20
- package/dist/signet-request-response-reader.d.ts.map +1 -1
- package/dist/signet-request-response-reader.js +35 -23
- package/dist/signet-request-response-reader.js.map +1 -1
- package/dist/signet-requests.d.ts +93 -59
- package/dist/signet-requests.d.ts.map +1 -1
- package/dist/signet-requests.js +84 -67
- package/dist/signet-requests.js.map +1 -1
- package/package.json +2 -2
- package/src/Signet.compact +277 -425
- package/src/circuits.compact +22 -21
- package/dist/ecdsa.d.ts +0 -114
- package/dist/ecdsa.d.ts.map +0 -1
- package/dist/ecdsa.js +0 -145
- package/dist/ecdsa.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"signet-contract-state-reader.d.ts","sourceRoot":"","sources":["../src/signet-contract-state-reader.ts"],"names":[],"mappings":"
|
|
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,oFAAoF;AACpF,eAAO,MAAM,oCAAoC,IAAI,CAAC;AAEtD,4EAA4E;AAC5E,eAAO,MAAM,4BAA4B,IAAI,CAAC;AAE9C,uFAAuF;AACvF,eAAO,MAAM,uCAAuC,IAAI,CAAC;AAEzD,+EAA+E;AAC/E,eAAO,MAAM,+BAA+B,IAAI,CAAC;AAgBjD;;;;;GAKG;AACH,MAAM,WAAW,uBAAuB;IACtC,0CAA0C;IAC1C,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;;;;;;;;GAcG;AACH,wBAAgB,mCAAmC,CACjD,MAAM,EAAE,mCAAmC,GAC1C,6BAA6B,CAoB/B;AAED;;;;;;;GAOG;AACH,MAAM,MAAM,kCAAkC,GAAG,GAAG,CAClD,YAAY,EACZ,mCAAmC,CACpC,CAAC;AAEF;;;;GAIG;AACH,MAAM,MAAM,kBAAkB,GAAG,GAAG,CAAC,YAAY,EAAE,MAAM,CAAC,CAAC;AAE3D;;;;GAIG;AACH,MAAM,MAAM,sBAAsB,GAAG,GAAG,CAAC,MAAM,EAAE,uBAAuB,CAAC,CAAC;AAE1E;;;GAGG;AACH,MAAM,MAAM,yBAAyB,GAAG,GAAG,CAAC,MAAM,EAAE,yBAAyB,CAAC,CAAC;AAE/E;;;;;;;;GAQG;AACH,wBAAgB,iBAAiB,CAAC,EAAE,EAAE,YAAY,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAEzE;AA2CD;;;;;;;;;;;;GAYG;AACH,wBAAgB,+CAA+C,CAC7D,GAAG,EAAE,gBAAgB,GACpB,kCAAkC,CAyBpC;AAED;;;;;;GAMG;AACH,MAAM,WAAW,oBAAoB;IACnC,gEAAgE;IAChE,4CAA4C,EAAE,kBAAkB,CAAC;IACjE;;;OAGG;IACH,qCAAqC,EAAE,kCAAkC,CAAC;IAC1E,sEAAsE;IACtE,2BAA2B,EAAE,kBAAkB,CAAC;IAChD,uFAAuF;IACvF,oBAAoB,EAAE,sBAAsB,CAAC;IAC7C,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"}
|
|
@@ -2,41 +2,48 @@
|
|
|
2
2
|
// its ledger fields out of a contract's raw state WITHOUT the compiled
|
|
3
3
|
// contract, the mirror image of signature-requests-state-reader.ts. A poller
|
|
4
4
|
// has only the contract address, queries raw state from the indexer
|
|
5
|
-
// (queryContractState(address).data), and decodes by the signet contract
|
|
6
|
-
// layout
|
|
7
|
-
//
|
|
8
|
-
//
|
|
9
|
-
//
|
|
10
|
-
// (
|
|
11
|
-
//
|
|
5
|
+
// (queryContractState(address).data), and decodes by the signet contract's
|
|
6
|
+
// declaration-order layout:
|
|
7
|
+
// field 0: signBidirectionalEventNotificationCounterMap (Map<RequestId, Counter>)
|
|
8
|
+
// field 1: signBidirectionalEventNotificationMap (Map<SignetMapKey, Notification>)
|
|
9
|
+
// field 2: signatureResponseCounterMap (Map<RequestId, Counter>)
|
|
10
|
+
// field 3: signatureResponseMap (Map<SignetMapKey, SignatureRespondedEvent>)
|
|
11
|
+
// field 4: respondBidirectionalCounterMap (Map<RequestId, Counter>)
|
|
12
|
+
// field 5: respondBidirectionalMap (Map<SignetMapKey, RespondBidirectionalEvent>)
|
|
13
|
+
// Every store is an unauthenticated append-only log keyed by
|
|
14
|
+
// (requestId, count); verification is the reader's job. The generic
|
|
15
|
+
// state-tree walk (RawContractState, signetFieldNode) and the shared base
|
|
16
|
+
// descriptors live in signature-state-reading.ts.
|
|
12
17
|
import { CompactTypeBytes, CompactTypeUnsignedInteger, } from "@midnight-ntwrk/compact-runtime";
|
|
13
18
|
import { bytesToHex, requestIdHex, } from "./signet-requests.js";
|
|
14
19
|
import { requestIdType, signetFieldNode, u64, } from "./signature-state-reading.js";
|
|
15
|
-
/** Signet contract layout: the
|
|
16
|
-
export const
|
|
17
|
-
/** Signet contract layout: the
|
|
18
|
-
export const
|
|
19
|
-
/** Signet contract layout: the
|
|
20
|
-
export const
|
|
21
|
-
/** Signet contract layout: the
|
|
22
|
-
export const
|
|
23
|
-
/** Signet contract layout: the
|
|
24
|
-
export const
|
|
20
|
+
/** Signet contract layout: the notification counter map is ledger field 0. */
|
|
21
|
+
export const SIGN_BIDIRECTIONAL_EVENT_NOTIFICATION_COUNTER_MAP_FIELD = 0;
|
|
22
|
+
/** Signet contract layout: the notification map is ledger field 1. */
|
|
23
|
+
export const SIGN_BIDIRECTIONAL_EVENT_NOTIFICATION_MAP_FIELD = 1;
|
|
24
|
+
/** Signet contract layout: the signature response counter map is ledger field 2. */
|
|
25
|
+
export const SIGNATURE_RESPONSE_COUNTER_MAP_FIELD = 2;
|
|
26
|
+
/** Signet contract layout: the signature response map is ledger field 3. */
|
|
27
|
+
export const SIGNATURE_RESPONSE_MAP_FIELD = 3;
|
|
28
|
+
/** Signet contract layout: the respond-bidirectional counter map is ledger field 4. */
|
|
29
|
+
export const RESPOND_BIDIRECTIONAL_COUNTER_MAP_FIELD = 4;
|
|
30
|
+
/** Signet contract layout: the respond-bidirectional map is ledger field 5. */
|
|
31
|
+
export const RESPOND_BIDIRECTIONAL_MAP_FIELD = 5;
|
|
25
32
|
// ---- Type descriptors (must mirror Signet.compact field-for-field) ----
|
|
26
33
|
// As in the requests reader, fromValue consumes the aligned value
|
|
27
34
|
// sequentially, so field order and width here must match the Compact structs
|
|
28
35
|
// exactly — a mismatch is silent data corruption, not an error.
|
|
29
|
-
/** Descriptor for a
|
|
36
|
+
/** Descriptor for a 32-byte scalar / hash (`Bytes<32>`). */
|
|
30
37
|
const bytes32 = new CompactTypeBytes(32);
|
|
31
|
-
/** Descriptor for the
|
|
38
|
+
/** Descriptor for the response's serialized output (`Bytes<128>`). */
|
|
32
39
|
const bytes128 = new CompactTypeBytes(128);
|
|
33
40
|
/** Descriptor for a Compact `Uint<8>` (1-byte unsigned integer). */
|
|
34
41
|
const u8 = new CompactTypeUnsignedInteger(255n, 1);
|
|
35
42
|
/**
|
|
36
|
-
* Hand-composed descriptor for {@link
|
|
43
|
+
* Hand-composed descriptor for {@link SignatureRespondedEvent}. Field
|
|
37
44
|
* order (bigRx, bigRy, s, recoveryId) must match the Compact struct.
|
|
38
45
|
*/
|
|
39
|
-
export const
|
|
46
|
+
export const signatureRespondedEventType = {
|
|
40
47
|
/** @returns Compound alignment of the struct's fields in declaration order. */
|
|
41
48
|
alignment() {
|
|
42
49
|
return bytes32
|
|
@@ -75,11 +82,11 @@ export const signatureResponseType = {
|
|
|
75
82
|
},
|
|
76
83
|
};
|
|
77
84
|
/**
|
|
78
|
-
* Hand-composed descriptor for {@link
|
|
79
|
-
* the
|
|
80
|
-
* the Compact struct.
|
|
85
|
+
* Hand-composed descriptor for {@link SignetMapKey} — the map key of every
|
|
86
|
+
* posted-entry map in the signet contract. Field order (count, then
|
|
87
|
+
* requestId) must match the Compact struct.
|
|
81
88
|
*/
|
|
82
|
-
export const
|
|
89
|
+
export const signetMapKeyType = {
|
|
83
90
|
/** @returns Compound alignment of the struct's fields in declaration order. */
|
|
84
91
|
alignment() {
|
|
85
92
|
return u64.alignment().concat(requestIdType.alignment());
|
|
@@ -107,22 +114,22 @@ export const signetResponseKeyType = {
|
|
|
107
114
|
},
|
|
108
115
|
};
|
|
109
116
|
/**
|
|
110
|
-
* Hand-composed descriptor for {@link
|
|
111
|
-
* order (serializedOutput, outputLen,
|
|
112
|
-
* struct
|
|
113
|
-
* `Secp256k1Scalar`.
|
|
117
|
+
* Hand-composed descriptor for {@link RespondBidirectionalEvent}. Field
|
|
118
|
+
* order (serializedOutput, outputLen, r, s, recoveryId) must match the
|
|
119
|
+
* Compact struct.
|
|
114
120
|
*/
|
|
115
|
-
export const
|
|
121
|
+
export const respondBidirectionalEventType = {
|
|
116
122
|
/** @returns Compound alignment of the struct's fields in declaration order. */
|
|
117
123
|
alignment() {
|
|
118
124
|
return bytes128
|
|
119
125
|
.alignment()
|
|
120
126
|
.concat(u8.alignment())
|
|
121
127
|
.concat(bytes32.alignment())
|
|
122
|
-
.concat(bytes32.alignment())
|
|
128
|
+
.concat(bytes32.alignment())
|
|
129
|
+
.concat(u8.alignment());
|
|
123
130
|
},
|
|
124
131
|
/**
|
|
125
|
-
* Decode one
|
|
132
|
+
* Decode one response record from an aligned value, consuming it field
|
|
126
133
|
* by field.
|
|
127
134
|
*
|
|
128
135
|
* @param value - Mutable aligned value cursor; pass a copy.
|
|
@@ -132,12 +139,13 @@ export const respondBidirectionalType = {
|
|
|
132
139
|
return {
|
|
133
140
|
serializedOutput: bytes128.fromValue(value),
|
|
134
141
|
outputLen: u8.fromValue(value),
|
|
135
|
-
|
|
136
|
-
|
|
142
|
+
r: bytes32.fromValue(value),
|
|
143
|
+
s: bytes32.fromValue(value),
|
|
144
|
+
recoveryId: u8.fromValue(value),
|
|
137
145
|
};
|
|
138
146
|
},
|
|
139
147
|
/**
|
|
140
|
-
* Encode
|
|
148
|
+
* Encode a response record into its aligned on-ledger representation.
|
|
141
149
|
*
|
|
142
150
|
* @param record - The record to encode.
|
|
143
151
|
* @returns The aligned value, fields concatenated in declaration order.
|
|
@@ -146,12 +154,13 @@ export const respondBidirectionalType = {
|
|
|
146
154
|
return bytes128
|
|
147
155
|
.toValue(record.serializedOutput)
|
|
148
156
|
.concat(u8.toValue(record.outputLen))
|
|
149
|
-
.concat(bytes32.toValue(record.
|
|
150
|
-
.concat(bytes32.toValue(record.
|
|
157
|
+
.concat(bytes32.toValue(record.r))
|
|
158
|
+
.concat(bytes32.toValue(record.s))
|
|
159
|
+
.concat(u8.toValue(record.recoveryId));
|
|
151
160
|
},
|
|
152
161
|
};
|
|
153
|
-
/** Descriptor for the notification's packed V1 payload (`Bytes<
|
|
154
|
-
const
|
|
162
|
+
/** Descriptor for the notification's packed V1 payload (`Bytes<128>`). */
|
|
163
|
+
const bytes128Payload = new CompactTypeBytes(128);
|
|
155
164
|
/**
|
|
156
165
|
* Hand-composed descriptor for {@link SignBidirectionalNotificationRecord}.
|
|
157
166
|
* Field order (version, payload) must match the Compact struct.
|
|
@@ -159,7 +168,7 @@ const bytes65 = new CompactTypeBytes(65);
|
|
|
159
168
|
export const signBidirectionalNotificationType = {
|
|
160
169
|
/** @returns Compound alignment of the struct's fields in declaration order. */
|
|
161
170
|
alignment() {
|
|
162
|
-
return u8.alignment().concat(
|
|
171
|
+
return u8.alignment().concat(bytes128Payload.alignment());
|
|
163
172
|
},
|
|
164
173
|
/**
|
|
165
174
|
* Decode one notification record from an aligned value, consuming it
|
|
@@ -171,7 +180,7 @@ export const signBidirectionalNotificationType = {
|
|
|
171
180
|
fromValue(value) {
|
|
172
181
|
return {
|
|
173
182
|
version: u8.fromValue(value),
|
|
174
|
-
payload:
|
|
183
|
+
payload: bytes128Payload.fromValue(value),
|
|
175
184
|
};
|
|
176
185
|
},
|
|
177
186
|
/**
|
|
@@ -181,23 +190,24 @@ export const signBidirectionalNotificationType = {
|
|
|
181
190
|
* @returns The aligned value, fields concatenated in declaration order.
|
|
182
191
|
*/
|
|
183
192
|
toValue(record) {
|
|
184
|
-
return u8
|
|
193
|
+
return u8
|
|
194
|
+
.toValue(record.version)
|
|
195
|
+
.concat(bytes128Payload.toValue(record.payload));
|
|
185
196
|
},
|
|
186
197
|
};
|
|
187
198
|
/** Offset of the V1 `callerAddress` in the packed payload (`Bytes<32>` at the front). */
|
|
188
199
|
const NOTIFICATION_CALLER_ADDRESS_OFFSET = 0;
|
|
189
|
-
/** Offset of the V1 `
|
|
190
|
-
const
|
|
191
|
-
/** Offset of the V1 `requestsIndexField` (after callerAddress + requestId). */
|
|
192
|
-
const NOTIFICATION_REQUESTS_INDEX_FIELD_OFFSET = 64;
|
|
200
|
+
/** Offset of the V1 `requestsIndexField` (after the 32 callerAddress bytes). */
|
|
201
|
+
const NOTIFICATION_REQUESTS_INDEX_FIELD_OFFSET = 32;
|
|
193
202
|
/** The only payload interpretation {@link decodeSignBidirectionalNotification} understands today. */
|
|
194
203
|
const SUPPORTED_NOTIFICATION_VERSION = 1n;
|
|
195
204
|
/**
|
|
196
205
|
* Unpack a stored {@link SignBidirectionalNotificationRecord}'s payload by
|
|
197
206
|
* the fixed V1 offsets — the decode twin of the compiled
|
|
198
|
-
* `
|
|
199
|
-
* pack↔decode lockstep is pinned by the state-reader unit test that
|
|
200
|
-
* through the real circuit).
|
|
207
|
+
* `constructSignBidirectionalEventNotificationV1` circuit (byte plumbing
|
|
208
|
+
* only; the pack↔decode lockstep is pinned by the state-reader unit test that
|
|
209
|
+
* round-trips through the real circuit). V1 layout:
|
|
210
|
+
* callerAddress (32) ++ requestsIndexField (1) ++ zero padding (95).
|
|
201
211
|
*
|
|
202
212
|
* Fails closed on an unrecognised `version`: a future payload layout adds a
|
|
203
213
|
* branch here rather than silently misinterpreting bytes under the V1 offsets.
|
|
@@ -208,64 +218,104 @@ const SUPPORTED_NOTIFICATION_VERSION = 1n;
|
|
|
208
218
|
*/
|
|
209
219
|
export function decodeSignBidirectionalNotification(record) {
|
|
210
220
|
if (record.version !== SUPPORTED_NOTIFICATION_VERSION) {
|
|
211
|
-
throw new Error(`
|
|
221
|
+
throw new Error(`SignBidirectionalEventNotification version ${record.version} is not supported ` +
|
|
212
222
|
`(this decoder understands version ${SUPPORTED_NOTIFICATION_VERSION})`);
|
|
213
223
|
}
|
|
214
|
-
const callerAddress = bytesToHex(record.payload.slice(NOTIFICATION_CALLER_ADDRESS_OFFSET,
|
|
215
|
-
const requestId = requestIdHex(record.payload.slice(NOTIFICATION_REQUEST_ID_OFFSET, NOTIFICATION_REQUESTS_INDEX_FIELD_OFFSET));
|
|
224
|
+
const callerAddress = bytesToHex(record.payload.slice(NOTIFICATION_CALLER_ADDRESS_OFFSET, NOTIFICATION_REQUESTS_INDEX_FIELD_OFFSET));
|
|
216
225
|
const requestsIndexField = record.payload[NOTIFICATION_REQUESTS_INDEX_FIELD_OFFSET];
|
|
217
226
|
return {
|
|
218
227
|
version: Number(record.version),
|
|
219
228
|
callerAddress,
|
|
220
|
-
requestId,
|
|
221
229
|
requestsIndexField,
|
|
222
230
|
};
|
|
223
231
|
}
|
|
224
232
|
/**
|
|
225
|
-
* Build the
|
|
226
|
-
*
|
|
233
|
+
* Build the flattened JS map key for a `(requestId, count)` pair — the
|
|
234
|
+
* composite Compact {@link SignetMapKey} as a string so it works as a JS
|
|
227
235
|
* `Map` key.
|
|
228
236
|
*
|
|
229
|
-
* @param id - The request id the
|
|
237
|
+
* @param id - The request id the entry belongs to, in canonical hex form.
|
|
230
238
|
* @param count - 0-based post count within that request.
|
|
231
239
|
* @returns `"<hexRequestId>:<count>"`.
|
|
232
240
|
*/
|
|
233
|
-
export function
|
|
241
|
+
export function signetMapEntryKey(id, count) {
|
|
234
242
|
return `${id}:${count}`;
|
|
235
243
|
}
|
|
244
|
+
/** Decode a `Map<RequestId, Counter>` ledger field into a {@link SignetCounterIndex}. */
|
|
245
|
+
function readCounterMap(raw, field) {
|
|
246
|
+
const counterMap = signetFieldNode(raw, field).asMap();
|
|
247
|
+
if (counterMap === undefined) {
|
|
248
|
+
throw new Error(`Ledger field ${field} is not a Map`);
|
|
249
|
+
}
|
|
250
|
+
const index = new Map();
|
|
251
|
+
for (const key of counterMap.keys()) {
|
|
252
|
+
// fromValue consumes its input, so hand each descriptor a copy.
|
|
253
|
+
const requestId = requestIdType.fromValue([...key.value]);
|
|
254
|
+
// A Counter is stored as a plain u64 cell.
|
|
255
|
+
const cell = counterMap.get(key)?.asCell();
|
|
256
|
+
if (cell === undefined)
|
|
257
|
+
continue;
|
|
258
|
+
index.set(requestIdHex(requestId), u64.fromValue([...cell.value]));
|
|
259
|
+
}
|
|
260
|
+
return index;
|
|
261
|
+
}
|
|
262
|
+
/** Decode a `Map<SignetMapKey, T>` ledger field into a string-keyed JS map. */
|
|
263
|
+
function readSignetKeyedMap(raw, field, valueType) {
|
|
264
|
+
const map = signetFieldNode(raw, field).asMap();
|
|
265
|
+
if (map === undefined) {
|
|
266
|
+
throw new Error(`Ledger field ${field} is not a Map`);
|
|
267
|
+
}
|
|
268
|
+
const index = new Map();
|
|
269
|
+
for (const key of map.keys()) {
|
|
270
|
+
const mapKey = signetMapKeyType.fromValue([...key.value]);
|
|
271
|
+
const cell = map.get(key)?.asCell();
|
|
272
|
+
if (cell === undefined)
|
|
273
|
+
continue;
|
|
274
|
+
index.set(signetMapEntryKey(requestIdHex(mapKey.requestId), mapKey.count), valueType.fromValue([...cell.value]));
|
|
275
|
+
}
|
|
276
|
+
return index;
|
|
277
|
+
}
|
|
236
278
|
/**
|
|
237
279
|
* Read ONLY the notification registry (ledger field
|
|
238
|
-
* {@link
|
|
280
|
+
* {@link SIGN_BIDIRECTIONAL_EVENT_NOTIFICATION_MAP_FIELD}) out of raw signet
|
|
239
281
|
* contract state — the poll-loop primitive of {@link SignetRequestFeed},
|
|
240
|
-
* which cycles frequently and has no use for the response fields.
|
|
282
|
+
* which cycles frequently and has no use for the response fields. One record
|
|
283
|
+
* per request id (the count-0 post; see
|
|
284
|
+
* {@link SignBidirectionalNotificationIndex}).
|
|
241
285
|
*
|
|
242
286
|
* @param raw - Raw contract state, e.g. `queryContractState(address).data`
|
|
243
287
|
* from the indexer or `ctx.currentQueryContext.state` from the simulator.
|
|
244
|
-
* @returns The registry, keyed by the hex request id each
|
|
245
|
-
* registered under.
|
|
288
|
+
* @returns The registry, keyed by the hex request id of each entry's map key.
|
|
246
289
|
* @throws Error if the field is missing or is not a Map.
|
|
247
290
|
*/
|
|
248
291
|
export function readSignBidirectionalNotificationIndexFromState(raw) {
|
|
249
|
-
const notificationMap = signetFieldNode(raw,
|
|
292
|
+
const notificationMap = signetFieldNode(raw, SIGN_BIDIRECTIONAL_EVENT_NOTIFICATION_MAP_FIELD).asMap();
|
|
250
293
|
if (notificationMap === undefined) {
|
|
251
|
-
throw new Error(`Ledger field ${
|
|
294
|
+
throw new Error(`Ledger field ${SIGN_BIDIRECTIONAL_EVENT_NOTIFICATION_MAP_FIELD} is not a Map`);
|
|
252
295
|
}
|
|
253
296
|
const index = new Map();
|
|
297
|
+
const counts = new Map();
|
|
254
298
|
for (const key of notificationMap.keys()) {
|
|
255
299
|
// fromValue consumes its input, so hand each descriptor a copy.
|
|
256
|
-
const
|
|
300
|
+
const mapKey = signetMapKeyType.fromValue([...key.value]);
|
|
257
301
|
const cell = notificationMap.get(key)?.asCell();
|
|
258
302
|
if (cell === undefined)
|
|
259
303
|
continue;
|
|
260
|
-
|
|
304
|
+
const id = requestIdHex(mapKey.requestId);
|
|
305
|
+
const seen = counts.get(id);
|
|
306
|
+
// Keep the FIRST post (lowest count) per request id.
|
|
307
|
+
if (seen !== undefined && seen <= mapKey.count)
|
|
308
|
+
continue;
|
|
309
|
+
counts.set(id, mapKey.count);
|
|
310
|
+
index.set(id, signBidirectionalNotificationType.fromValue([...cell.value]));
|
|
261
311
|
}
|
|
262
312
|
return index;
|
|
263
313
|
}
|
|
264
314
|
/**
|
|
265
315
|
* MPC-/client-style read: parse the signet contract's ledger fields out of
|
|
266
316
|
* raw contract state by field position alone — no compiled contract, no
|
|
267
|
-
* generated `ledger()`, only the
|
|
268
|
-
*
|
|
317
|
+
* generated `ledger()`, only the declaration-order layout and the canonical
|
|
318
|
+
* descriptors above.
|
|
269
319
|
*
|
|
270
320
|
* @param raw - Raw contract state, e.g. `queryContractState(address).data`
|
|
271
321
|
* from the indexer or `ctx.currentQueryContext.state` from the simulator.
|
|
@@ -273,55 +323,13 @@ export function readSignBidirectionalNotificationIndexFromState(raw) {
|
|
|
273
323
|
* @throws Error if a field is missing or has the wrong state-value shape.
|
|
274
324
|
*/
|
|
275
325
|
export function readSignetContractLedgerFromState(raw) {
|
|
276
|
-
const counterMap = signetFieldNode(raw, SIGNATURE_RESPONSE_COUNTER_INDEX_FIELD).asMap();
|
|
277
|
-
if (counterMap === undefined) {
|
|
278
|
-
throw new Error(`Ledger field ${SIGNATURE_RESPONSE_COUNTER_INDEX_FIELD} is not a Map`);
|
|
279
|
-
}
|
|
280
|
-
const signatureResponseCounterIndex = new Map();
|
|
281
|
-
for (const key of counterMap.keys()) {
|
|
282
|
-
// fromValue consumes its input, so hand each descriptor a copy.
|
|
283
|
-
const requestId = requestIdType.fromValue([...key.value]);
|
|
284
|
-
// A Counter is stored as a plain u64 cell.
|
|
285
|
-
const cell = counterMap.get(key)?.asCell();
|
|
286
|
-
if (cell === undefined)
|
|
287
|
-
continue;
|
|
288
|
-
signatureResponseCounterIndex.set(requestIdHex(requestId), u64.fromValue([...cell.value]));
|
|
289
|
-
}
|
|
290
|
-
const responseMap = signetFieldNode(raw, SIGNATURE_RESPONSE_INDEX_FIELD).asMap();
|
|
291
|
-
if (responseMap === undefined) {
|
|
292
|
-
throw new Error(`Ledger field ${SIGNATURE_RESPONSE_INDEX_FIELD} is not a Map`);
|
|
293
|
-
}
|
|
294
|
-
const signatureResponseIndex = new Map();
|
|
295
|
-
for (const key of responseMap.keys()) {
|
|
296
|
-
const responseKey = signetResponseKeyType.fromValue([...key.value]);
|
|
297
|
-
const cell = responseMap.get(key)?.asCell();
|
|
298
|
-
if (cell === undefined)
|
|
299
|
-
continue;
|
|
300
|
-
signatureResponseIndex.set(signetResponseIndexKey(requestIdHex(responseKey.requestId), responseKey.count), signatureResponseType.fromValue([...cell.value]));
|
|
301
|
-
}
|
|
302
|
-
const respondBidirectionalMap = signetFieldNode(raw, RESPOND_BIDIRECTIONAL_INDEX_FIELD).asMap();
|
|
303
|
-
if (respondBidirectionalMap === undefined) {
|
|
304
|
-
throw new Error(`Ledger field ${RESPOND_BIDIRECTIONAL_INDEX_FIELD} is not a Map`);
|
|
305
|
-
}
|
|
306
|
-
const respondBidirectionalIndex = new Map();
|
|
307
|
-
for (const key of respondBidirectionalMap.keys()) {
|
|
308
|
-
const requestId = requestIdType.fromValue([...key.value]);
|
|
309
|
-
const cell = respondBidirectionalMap.get(key)?.asCell();
|
|
310
|
-
if (cell === undefined)
|
|
311
|
-
continue;
|
|
312
|
-
respondBidirectionalIndex.set(requestIdHex(requestId), respondBidirectionalType.fromValue([...cell.value]));
|
|
313
|
-
}
|
|
314
|
-
const hashCell = signetFieldNode(raw, MPC_PUB_KEY_HASH_FIELD).asCell();
|
|
315
|
-
if (hashCell === undefined) {
|
|
316
|
-
throw new Error(`Ledger field ${MPC_PUB_KEY_HASH_FIELD} is not a Cell`);
|
|
317
|
-
}
|
|
318
|
-
const mpcPubKeyHash = bytes32.fromValue([...hashCell.value]);
|
|
319
326
|
return {
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
327
|
+
signBidirectionalEventNotificationCounterMap: readCounterMap(raw, SIGN_BIDIRECTIONAL_EVENT_NOTIFICATION_COUNTER_MAP_FIELD),
|
|
328
|
+
signBidirectionalEventNotificationMap: readSignBidirectionalNotificationIndexFromState(raw),
|
|
329
|
+
signatureResponseCounterMap: readCounterMap(raw, SIGNATURE_RESPONSE_COUNTER_MAP_FIELD),
|
|
330
|
+
signatureResponseMap: readSignetKeyedMap(raw, SIGNATURE_RESPONSE_MAP_FIELD, signatureRespondedEventType),
|
|
331
|
+
respondBidirectionalCounterMap: readCounterMap(raw, RESPOND_BIDIRECTIONAL_COUNTER_MAP_FIELD),
|
|
332
|
+
respondBidirectionalMap: readSignetKeyedMap(raw, RESPOND_BIDIRECTIONAL_MAP_FIELD, respondBidirectionalEventType),
|
|
325
333
|
};
|
|
326
334
|
}
|
|
327
335
|
//# sourceMappingURL=signet-contract-state-reader.js.map
|
|
@@ -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,
|
|
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,mEAAmE;AACnE,+EAA+E;AAC/E,sEAAsE;AACtE,oFAAoF;AACpF,6DAA6D;AAC7D,oEAAoE;AACpE,0EAA0E;AAC1E,kDAAkD;AAElD,OAAO,EACL,gBAAgB,EAChB,0BAA0B,GAE3B,MAAM,iCAAiC,CAAC;AAEzC,OAAO,EACL,UAAU,EACV,YAAY,GAGb,MA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K,SAAS,IAAI,IAAI,IAAI,MAAM,CAAC,KAAK;YAAE,SAAS;QACzD,MAAM,CAAC,GAAG,CAAC,EAAE,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC;QAC7B,KAAK,CAAC,GAAG,CAAC,EAAE,EAAE,iCAAiC,CAAC,SAAS,CAAC,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IAC9E,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AA2BD;;;;;;;;;;GAUG;AACH,MAAM,UAAU,iCAAiC,CAC/C,GAAqB;IAErB,OAAO;QACL,4CAA4C,EAAE,cAAc,CAC1D,GAAG,EACH,uDAAuD,CACxD;QACD,qCAAqC,EACnC,+CAA+C,CAAC,GAAG,CAAC;QACtD,2BAA2B,EAAE,cAAc,CACzC,GAAG,EACH,oCAAoC,CACrC;QACD,oBAAoB,EAAE,kBAAkB,CACtC,GAAG,EACH,4BAA4B,EAC5B,2BAA2B,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"}
|
|
@@ -64,9 +64,10 @@ export declare class SignetRequestFeed {
|
|
|
64
64
|
* indexed yet is retried next cycle; undecodable or unsupported-version
|
|
65
65
|
* records are likewise skipped (and logged) without being marked.
|
|
66
66
|
*
|
|
67
|
-
* Dedupe and resolution key off the
|
|
68
|
-
*
|
|
69
|
-
*
|
|
67
|
+
* Dedupe and resolution key off the request id of the registry entry's map
|
|
68
|
+
* key (the V1 payload no longer carries one). The key is caller-supplied,
|
|
69
|
+
* so it confers no authority — the resolver's membership check against the
|
|
70
|
+
* named caller's own ledger is what authenticates it.
|
|
70
71
|
*
|
|
71
72
|
* @returns The newly-authenticated requests this cycle.
|
|
72
73
|
* @throws Error if the signet contract has no readable state at the
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"signet-request-feed.d.ts","sourceRoot":"","sources":["../src/signet-request-feed.ts"],"names":[],"mappings":"AAkBA,OAAO,EAEL,KAAK,qBAAqB,EAC3B,MAAM,8BAA8B,CAAC;AACtC,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,qCAAqC,CAAC;AACnF,OAAO,EAAkB,KAAK,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAEzE,6EAA6E;AAC7E,eAAO,MAAM,6BAA6B,OAAO,CAAC;AAElD,oDAAoD;AACpD,MAAM,WAAW,uBAAuB;IACtC,kFAAkF;IAClF,QAAQ,CAAC,qBAAqB,EAAE,MAAM,CAAC;IACvC;;;;OAIG;IACH,QAAQ,CAAC,MAAM,EAAE,uBAAuB,CAAC;IACzC;;;;OAIG;IACH,QAAQ,CAAC,cAAc,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC;IAC3C,0GAA0G;IAC1G,QAAQ,CAAC,cAAc,CAAC,EAAE,MAAM,CAAC;CAClC;AAED;;;;;;;GAOG;AACH,wBAAgB,kBAAkB,CAChC,EAAE,EAAE,MAAM,EACV,MAAM,CAAC,EAAE,WAAW,GACnB,OAAO,CAAC,IAAI,CAAC,CAaf;AAOD;;;;;;;GAOG;AACH,qBAAa,iBAAiB;IAC5B,OAAO,CAAC,QAAQ,CAAC,qBAAqB,CAAS;IAC/C,OAAO,CAAC,QAAQ,CAAC,MAAM,CAA0B;IACjD,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAwB;IACjD,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAC,CAAc;IAC9C,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAS;IAIxC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAA2B;IAEnD;;;OAGG;gBACS,MAAM,EAAE,uBAAuB;IAW3C,qFAAqF;IACrF,OAAO,CAAC,OAAO;IAOf
|
|
1
|
+
{"version":3,"file":"signet-request-feed.d.ts","sourceRoot":"","sources":["../src/signet-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AE,YAAY,GAAG,IAAI;IAIrC;;;;;;;;OAQG;IACI,QAAQ,CAAC,IAAI,CAAC,EAAE;QACrB,MAAM,CAAC,EAAE,WAAW,CAAC;KACtB,GAAG,qBAAqB,CAAC,qBAAqB,CAAC;CAQjD"}
|
|
@@ -90,9 +90,10 @@ export class SignetRequestFeed {
|
|
|
90
90
|
* indexed yet is retried next cycle; undecodable or unsupported-version
|
|
91
91
|
* records are likewise skipped (and logged) without being marked.
|
|
92
92
|
*
|
|
93
|
-
* Dedupe and resolution key off the
|
|
94
|
-
*
|
|
95
|
-
*
|
|
93
|
+
* Dedupe and resolution key off the request id of the registry entry's map
|
|
94
|
+
* key (the V1 payload no longer carries one). The key is caller-supplied,
|
|
95
|
+
* so it confers no authority — the resolver's membership check against the
|
|
96
|
+
* named caller's own ledger is what authenticates it.
|
|
96
97
|
*
|
|
97
98
|
* @returns The newly-authenticated requests this cycle.
|
|
98
99
|
* @throws Error if the signet contract has no readable state at the
|
|
@@ -106,24 +107,24 @@ export class SignetRequestFeed {
|
|
|
106
107
|
}
|
|
107
108
|
const registry = readSignBidirectionalNotificationIndexFromState(state.data);
|
|
108
109
|
const out = [];
|
|
109
|
-
for (const [
|
|
110
|
+
for (const [requestId, record] of [...registry.entries()].sort(([a], [b]) => (a < b ? -1 : a > b ? 1 : 0))) {
|
|
110
111
|
let notification;
|
|
111
112
|
try {
|
|
112
113
|
notification = decodeSignBidirectionalNotification(record);
|
|
113
114
|
}
|
|
114
115
|
catch (error) {
|
|
115
116
|
console.warn(`SignetRequestFeed: skipping undecodable notification ` +
|
|
116
|
-
`registered under ${
|
|
117
|
+
`registered under ${requestId}: ${String(error)}`);
|
|
117
118
|
continue;
|
|
118
119
|
}
|
|
119
|
-
if (this.yielded.has(
|
|
120
|
+
if (this.yielded.has(requestId))
|
|
120
121
|
continue;
|
|
121
122
|
if (!this.allowed(notification.callerAddress))
|
|
122
123
|
continue;
|
|
123
|
-
const resolved = await this.resolver.resolve(notification);
|
|
124
|
+
const resolved = await this.resolver.resolve(requestId, notification);
|
|
124
125
|
if (resolved === undefined)
|
|
125
126
|
continue;
|
|
126
|
-
this.yielded.add(
|
|
127
|
+
this.yielded.add(requestId);
|
|
127
128
|
out.push(resolved);
|
|
128
129
|
}
|
|
129
130
|
return out;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"signet-request-feed.js","sourceRoot":"","sources":["../src/signet-request-feed.ts"],"names":[],"mappings":"AAAA,4EAA4E;AAC5E,4EAA4E;AAC5E,6EAA6E;AAC7E,0EAA0E;AAC1E,4EAA4E;AAC5E,2EAA2E;AAC3E,wCAAwC;AACxC,EAAE;AACF,4EAA4E;AAC5E,4EAA4E;AAC5E,wEAAwE;AACxE,yDAAyD;AACzD,yCAAyC;AAEzC,OAAO,EACL,mCAAmC,EACnC,+CAA+C,GAChD,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EACL,qBAAqB,GAEtB,MAAM,8BAA8B,CAAC;AAEtC,OAAO,EAAE,cAAc,EAAqB,MAAM,sBAAsB,CAAC;AAEzE,6EAA6E;AAC7E,MAAM,CAAC,MAAM,6BAA6B,GAAG,IAAI,CAAC;AAsBlD;;;;;;;GAOG;AACH,MAAM,UAAU,kBAAkB,CAChC,EAAU,EACV,MAAoB;IAEpB,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;QAC7B,IAAI,MAAM,EAAE,OAAO;YAAE,OAAO,OAAO,EAAE,CAAC;QACtC,MAAM,KAAK,GAAG,UAAU,CAAC,GAAG,EAAE;YAC5B,MAAM,EAAE,mBAAmB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;YAC9C,OAAO,EAAE,CAAC;QACZ,CAAC,EAAE,EAAE,CAAC,CAAC;QACP,MAAM,OAAO,GAAG,GAAG,EAAE;YACnB,YAAY,CAAC,KAAK,CAAC,CAAC;YACpB,OAAO,EAAE,CAAC;QACZ,CAAC,CAAC;QACF,MAAM,EAAE,gBAAgB,CAAC,OAAO,E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AC,CAAC,QAAQ,CAAC,IAEf;QACC,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC;YAC9B,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,IAAI,EAAE,CAAC;YAChC,KAAK,MAAM,QAAQ,IAAI,KAAK;gBAAE,MAAM,QAAQ,CAAC;YAC7C,IAAI,IAAI,EAAE,MAAM,EAAE,OAAO;gBAAE,MAAM;YACjC,MAAM,kBAAkB,CAAC,IAAI,CAAC,cAAc,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC;QAC9D,CAAC;IACH,CAAC;CACF"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { SignBidirectionalNotification } from "./signet-contract-state-reader.ts";
|
|
2
2
|
import type { SignetPublicStateSource } from "./signet-request-response-reader.ts";
|
|
3
|
-
import type { RequestIdHex,
|
|
3
|
+
import type { RequestIdHex, SignBidirectionalEvent } from "./signet-requests.ts";
|
|
4
4
|
/**
|
|
5
5
|
* A {@link SignBidirectionalNotification} resolved to the authenticated
|
|
6
6
|
* request it refers to: the request record read from `callerAddress`'s own
|
|
@@ -16,7 +16,7 @@ export interface ResolvedSignetRequest {
|
|
|
16
16
|
/** The request id, confirmed to be a member of `callerAddress`'s index. */
|
|
17
17
|
requestId: RequestIdHex;
|
|
18
18
|
/** The authenticated request record to sign. */
|
|
19
|
-
request:
|
|
19
|
+
request: SignBidirectionalEvent;
|
|
20
20
|
}
|
|
21
21
|
/** Everything a {@link SignetRequestResolver} needs. */
|
|
22
22
|
export interface SignetRequestResolverConfig {
|
|
@@ -46,13 +46,15 @@ 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
|
|
49
|
+
* a member of the map at `requestsIndexField` (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
|
*
|
|
53
|
+
* @param requestId - The request id the notification was registered under
|
|
54
|
+
* (the registry map key — the V1 payload does not carry one).
|
|
53
55
|
* @param notification - The decoded notification.
|
|
54
56
|
* @returns The authenticated request, or `undefined` to drop the notification.
|
|
55
57
|
*/
|
|
56
|
-
resolve(notification: SignBidirectionalNotification): Promise<ResolvedSignetRequest | undefined>;
|
|
58
|
+
resolve(requestId: RequestIdHex, notification: SignBidirectionalNotification): Promise<ResolvedSignetRequest | undefined>;
|
|
57
59
|
}
|
|
58
60
|
//# sourceMappingURL=signet-request-resolver.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"signet-request-resolver.d.ts","sourceRoot":"","sources":["../src/signet-request-resolver.ts"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,mCAAmC,CAAC;AACvF,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,qCAAqC,CAAC;AACnF,OAAO,KAAK,EACV,YAAY,EACZ,
|
|
1
|
+
{"version":3,"file":"signet-request-resolver.d.ts","sourceRoot":"","sources":["../src/signet-request-resolver.ts"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,mCAAmC,CAAC;AACvF,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,qCAAqC,CAAC;AACnF,OAAO,KAAK,EACV,YAAY,EACZ,sBAAsB,EACvB,MAAM,sBAAsB,CAAC;AAE9B;;;;GAIG;AACH,MAAM,WAAW,qBAAqB;IACpC;;;;OAIG;IACH,aAAa,EAAE,MAAM,CAAC;IACtB,2EAA2E;IAC3E,SAAS,EAAE,YAAY,CAAC;IACxB,gDAAgD;IAChD,OAAO,EAAE,sBAAsB,CAAC;CACjC;AAED,wDAAwD;AACxD,MAAM,WAAW,2BAA2B;IAC1C,oFAAoF;IACpF,QAAQ,CAAC,MAAM,EAAE,uBAAuB,CAAC;CAC1C;AAED;;;;;;;;;;;;GAYG;AACH,qBAAa,qBAAqB;IAChC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAA0B;IAIjD,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAkD;IAEhF;;OAEG;gBACS,MAAM,EAAE,2BAA2B;IAI/C;;;;;;;;;;;OAWG;IACG,OAAO,CACX,SAAS,EAAE,YAAY,EACvB,YAAY,EAAE,6BAA6B,GAC1C,OAAO,CAAC,qBAAqB,GAAG,SAAS,CAAC;CA8B9C"}
|
|
@@ -38,15 +38,17 @@ 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
|
|
41
|
+
* a member of the map at `requestsIndexField` (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
|
*
|
|
45
|
+
* @param requestId - The request id the notification was registered under
|
|
46
|
+
* (the registry map key — the V1 payload does not carry one).
|
|
45
47
|
* @param notification - The decoded notification.
|
|
46
48
|
* @returns The authenticated request, or `undefined` to drop the notification.
|
|
47
49
|
*/
|
|
48
|
-
async resolve(notification) {
|
|
49
|
-
const cached = this.resolvedCache.get(
|
|
50
|
+
async resolve(requestId, notification) {
|
|
51
|
+
const cached = this.resolvedCache.get(requestId);
|
|
50
52
|
if (cached !== undefined) {
|
|
51
53
|
return cached;
|
|
52
54
|
}
|
|
@@ -60,16 +62,16 @@ export class SignetRequestResolver {
|
|
|
60
62
|
if (!state?.data) {
|
|
61
63
|
return undefined; // no state at the named caller — cannot authenticate
|
|
62
64
|
}
|
|
63
|
-
const request = lookupSignetRequestAt(state.data, notification.requestsIndexField,
|
|
65
|
+
const request = lookupSignetRequestAt(state.data, notification.requestsIndexField, requestId);
|
|
64
66
|
if (request === undefined) {
|
|
65
67
|
return undefined; // membership check failed — drop the notification
|
|
66
68
|
}
|
|
67
69
|
const resolved = {
|
|
68
70
|
callerAddress: notification.callerAddress,
|
|
69
|
-
requestId
|
|
71
|
+
requestId,
|
|
70
72
|
request,
|
|
71
73
|
};
|
|
72
|
-
this.resolvedCache.set(
|
|
74
|
+
this.resolvedCache.set(requestId, resolved);
|
|
73
75
|
return resolved;
|
|
74
76
|
}
|
|
75
77
|
}
|