@sig-net/midnight 0.14.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 +26 -5
- package/dist/managed/compiler/contract-info.json +12 -1
- package/dist/managed/compiler/contract-manifest.json +8 -8
- package/dist/managed/contract/index.d.ts +8 -6
- package/dist/managed/contract/index.js +76 -60
- 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 +13 -7
- package/dist/signet-contract-state-reader.d.ts.map +1 -1
- package/dist/signet-contract-state-reader.js +34 -16
- 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 +8 -7
- package/dist/signet-request-response-reader.d.ts.map +1 -1
- package/dist/signet-request-response-reader.js +4 -4
- package/dist/signet-request-response-reader.js.map +1 -1
- package/package.json +2 -2
- package/src/Signet.compact +47 -7
|
@@ -47,13 +47,13 @@ export class SignetRequestResponseReader {
|
|
|
47
47
|
}
|
|
48
48
|
/**
|
|
49
49
|
* Fetch the request record for `requestId` from the requester contract's
|
|
50
|
-
* request index (at the configured `
|
|
50
|
+
* request index (at the configured `requesterRequestsPath`). Cached
|
|
51
51
|
* after the first fetch.
|
|
52
52
|
*
|
|
53
53
|
* @param requestId - The request id to look up.
|
|
54
54
|
* @returns The stored request record.
|
|
55
55
|
* @throws Error when the requester contract has no state or holds no
|
|
56
|
-
* request under `requestId` at the configured index
|
|
56
|
+
* request under `requestId` at the configured index path.
|
|
57
57
|
*/
|
|
58
58
|
async getSignatureRequest(requestId) {
|
|
59
59
|
const cached = this.requestCache.get(requestId);
|
|
@@ -61,10 +61,10 @@ export class SignetRequestResponseReader {
|
|
|
61
61
|
return cached;
|
|
62
62
|
}
|
|
63
63
|
const raw = await this.queryRawState(this.config.requesterContractAddress, "requester");
|
|
64
|
-
const request = lookupSignetRequestAt(raw, this.config.
|
|
64
|
+
const request = lookupSignetRequestAt(raw, this.config.requesterRequestsPath, requestId);
|
|
65
65
|
if (request === undefined) {
|
|
66
66
|
throw new Error(`request ${requestId} is not on the requester contract's ledger ` +
|
|
67
|
-
`(request index at
|
|
67
|
+
`(request index at path ${JSON.stringify(this.config.requesterRequestsPath)}): was it submitted?`);
|
|
68
68
|
}
|
|
69
69
|
this.requestCache.set(requestId, request);
|
|
70
70
|
return request;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"signet-request-response-reader.js","sourceRoot":"","sources":["../src/signet-request-response-reader.ts"],"names":[],"mappings":"AAAA,4EAA4E;AAC5E,8EAA8E;AAC9E,0EAA0E;AAC1E,uBAAuB;AACvB,yEAAyE;AACzE,2EAA2E;AAC3E,uEAAuE;AACvE,mEAAmE;AACnE,2EAA2E;AAC3E,iCAAiC;AAKjC,OAAO,EAAE,qBAAqB,EAAE,MAAM,sCAAsC,CAAC;AAC7E,OAAO,EACL,iCAAiC,EACjC,iBAAiB,GAGlB,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EAAE,8BAA8B,EAAE,MAAM,sCAAsC,CAAC;AACtF,OAAO,EACL,mCAAmC,GAEpC,MAAM,wBAAwB,CAAC;AAEhC,OAAO,EACL,4CAA4C,EAC5C,8CAA8C,GAC/C,MAAM,gCAAgC,CAAC;AACxC,OAAO,EACL,cAAc,GAGf,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"signet-request-response-reader.js","sourceRoot":"","sources":["../src/signet-request-response-reader.ts"],"names":[],"mappings":"A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CAAC;gBAC3B,MAAM,IAAI,KAAK,CACb,0CAA0C,KAAK,gBAAgB,SAAS,GAAG;oBACzE,+BAA+B,UAAU,gCAAgC,CAC5E,CAAC;YACJ,CAAC;YACD,SAAS,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAC3B,CAAC;QACD,OAAO,SAAS,CAAC;IACnB,CAAC;IAED;;;;;;;;;;;;;;;;;;;;;;OAsBG;IACH,KAAK,CAAC,oCAAoC,CACxC,SAAuB,EACvB,gBAA4B,EAC5B,cAA8B;QAE9B,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,6BAA6B,CAAC,SAAS,CAAC,CAAC;QACnE,OAAO,MAAM,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE,CAC3B,mCAAmC,CACjC,cAAc,CAAC,SAAS,CAAC,EACzB,gBAAgB,EAChB,KAAK,EACL,cAAc,CACf,CACF,CAAC;IACJ,CAAC;CACF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sig-net/midnight",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.15.0",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/sig-net/midnight-integration",
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"@midnight-ntwrk/compact-runtime": "0.18.0-rc.1",
|
|
41
41
|
"@midnight-ntwrk/midnight-js-types": "5.0.0-beta.4",
|
|
42
42
|
"@noble/curves": "^2.2.0",
|
|
43
|
-
"@sig-net/midnight-serde": "^0.
|
|
43
|
+
"@sig-net/midnight-serde": "^0.15.0",
|
|
44
44
|
"ethers": "^6.17.0"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
package/src/Signet.compact
CHANGED
|
@@ -209,22 +209,62 @@ module Signet {
|
|
|
209
209
|
// Notification delivered by client contracts via cross contract call to Signet singleton
|
|
210
210
|
// (via SignetSigner interface) to notify the MPC of a SignBidirectionalEvent.
|
|
211
211
|
export struct SignBidirectionalEventNotification {
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
212
|
+
// Notification payload layout version.
|
|
213
|
+
// Curent Layout Version: 1 (see constructSignBidirectionalEventNotificationV1)
|
|
214
|
+
version: Uint<8>;
|
|
215
|
+
// Payload containing serialised notification payload.
|
|
216
|
+
payload: Bytes<128>;
|
|
215
217
|
}
|
|
216
218
|
|
|
217
|
-
// Construction helper for the V1 SignBidirectionalEventNotification
|
|
219
|
+
// Construction helper for the V1 SignBidirectionalEventNotification.
|
|
220
|
+
//
|
|
221
|
+
// The payload is a pointer for the MPC. It names the contract that holds the
|
|
222
|
+
// SignBidirectionalEventMap (callerAddress) and the position of that map in the
|
|
223
|
+
// contract's raw on-chain state (requestsPathDepth + requestsPath). The MPC
|
|
224
|
+
// follows the path through the raw state tree to read the authenticated
|
|
225
|
+
// request, without the caller's compiled contract.
|
|
226
|
+
//
|
|
227
|
+
// Why a path: compactc packs a contract's public ledger fields into a tree of
|
|
228
|
+
// state values whose array nodes hold at most 15 entries (the compiler's
|
|
229
|
+
// maximum-ledger-segment-length). A contract with 15 or fewer ledger fields
|
|
230
|
+
// keeps each field directly in the root array, so field N sits at path [N]
|
|
231
|
+
// (depth 1). Past 15 fields the compiler splits the declaration list into
|
|
232
|
+
// segments of at most 15, remainder segment first, and the root array holds
|
|
233
|
+
// the segments. Each split adds one level to the tree and one entry to every
|
|
234
|
+
// field's path. Example: 20 fields split into segments of 5 and 15, so
|
|
235
|
+
// fields 0..4 sit at [0, 0]..[0, 4] and fields 5..19 sit at
|
|
236
|
+
// [1, 0]..[1, 14] (depth 2).
|
|
237
|
+
//
|
|
238
|
+
// How to determine the values: read the path from your contract's compiled
|
|
239
|
+
// artifacts, do not derive it by hand. The compiler records each field's
|
|
240
|
+
// resolved path as its "index" in managed/<contract>/compiler/contract-info.json
|
|
241
|
+
// (a bare number N means path [N]). The generated
|
|
242
|
+
// managed/<contract>/contract/index.js accessors walk the same indices, for
|
|
243
|
+
// example state.asArray()[1].asArray()[14] for a map recorded at [1, 14].
|
|
244
|
+
// Set requestsPathDepth to the number of path entries and requestsPath to
|
|
245
|
+
// the path itself, zero padded to 4 entries: [1, 14] becomes depth 2 and
|
|
246
|
+
// path [1, 14, 0, 0].
|
|
218
247
|
export pure circuit constructSignBidirectionalEventNotificationV1(
|
|
219
248
|
// Address of the client contract that stores and notifies of this SignBidirectionalEvent.
|
|
220
249
|
// Set with kernel.self(). MUST match sender in associated SignBidirectionalEvent.
|
|
221
250
|
callerAddress: ContractAddress,
|
|
222
|
-
|
|
251
|
+
// Number of meaningful entries in requestsPath: 1 for a flat (15 or fewer
|
|
252
|
+
// field) contract, one more per chunk level after that (max 4).
|
|
253
|
+
requestsPathDepth: Uint<8>,
|
|
254
|
+
// Resolved ledger-tree path of the caller's SignBidirectionalEventMap, from
|
|
255
|
+
// its contract-info.json "index". Entries at and beyond requestsPathDepth
|
|
256
|
+
// are zero.
|
|
257
|
+
requestsPath: Vector<4, Uint<8>>
|
|
223
258
|
): SignBidirectionalEventNotification {
|
|
224
259
|
return SignBidirectionalEventNotification {
|
|
225
260
|
version: 1,
|
|
226
|
-
// 128 = 32 + 1 +
|
|
227
|
-
payload: Bytes[
|
|
261
|
+
// 128 = 32 + 1 + 4 + 91
|
|
262
|
+
payload: Bytes[
|
|
263
|
+
...callerAddress.bytes,
|
|
264
|
+
requestsPathDepth,
|
|
265
|
+
requestsPath[0], requestsPath[1], requestsPath[2], requestsPath[3],
|
|
266
|
+
...default<Bytes<91>>
|
|
267
|
+
]
|
|
228
268
|
};
|
|
229
269
|
}
|
|
230
270
|
|