@cofhe/sdk 1.0.0-alpha.0 → 1.1.0-alpha.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/dist/acps.cjs CHANGED
@@ -66,6 +66,100 @@ function isBigIntOrNumber(value) {
66
66
  }
67
67
  }
68
68
 
69
+ // core/error.ts
70
+ var CofheError = class _CofheError extends Error {
71
+ code;
72
+ cause;
73
+ hint;
74
+ context;
75
+ apiErrorCode;
76
+ constructor({ code, message, cause, hint, context, apiErrorCode }) {
77
+ const fullMessage = cause ? `${message} | Caused by: ${cause.message}` : message;
78
+ super(fullMessage);
79
+ this.name = "CofheError";
80
+ this.code = code;
81
+ this.cause = cause;
82
+ this.hint = hint;
83
+ this.context = context;
84
+ this.apiErrorCode = apiErrorCode;
85
+ if (Error.captureStackTrace) {
86
+ Error.captureStackTrace(this, _CofheError);
87
+ }
88
+ }
89
+ /**
90
+ * Creates a CofheError from an unknown error
91
+ * If the error is a CofheError, it is returned unchanged, else a new CofheError is created
92
+ * If a wrapperError is provided, it is used to create the new CofheError, else a default is used
93
+ */
94
+ static fromError(error, wrapperError) {
95
+ if (isCofheError(error))
96
+ return error;
97
+ const cause = error instanceof Error ? error : new Error(`${error}`);
98
+ return new _CofheError({
99
+ code: wrapperError?.code ?? "INTERNAL_ERROR" /* InternalError */,
100
+ message: wrapperError?.message ?? "An internal error occurred",
101
+ hint: wrapperError?.hint,
102
+ context: wrapperError?.context,
103
+ apiErrorCode: wrapperError?.apiErrorCode,
104
+ cause
105
+ });
106
+ }
107
+ /**
108
+ * Serializes the error to JSON string with proper handling of Error objects
109
+ */
110
+ serialize() {
111
+ return bigintSafeJsonStringify({
112
+ name: this.name,
113
+ code: this.code,
114
+ message: this.message,
115
+ hint: this.hint,
116
+ context: this.context,
117
+ apiErrorCode: this.apiErrorCode,
118
+ cause: this.cause ? {
119
+ name: this.cause.name,
120
+ message: this.cause.message,
121
+ stack: this.cause.stack
122
+ } : void 0,
123
+ stack: this.stack
124
+ });
125
+ }
126
+ /**
127
+ * Returns a human-readable string representation of the error
128
+ */
129
+ toString() {
130
+ const codeSuffix = this.apiErrorCode ? ` (api: ${this.apiErrorCode})` : "";
131
+ const parts = [`${this.name} [${this.code}]${codeSuffix}: ${this.message}`];
132
+ if (this.hint) {
133
+ parts.push(`Hint: ${this.hint}`);
134
+ }
135
+ if (this.context && Object.keys(this.context).length > 0) {
136
+ parts.push(`Context: ${bigintSafeJsonStringify(this.context)}`);
137
+ }
138
+ if (this.stack) {
139
+ parts.push(`
140
+ Stack trace:`);
141
+ parts.push(this.stack);
142
+ }
143
+ if (this.cause) {
144
+ parts.push(`
145
+ Caused by: ${this.cause.name}: ${this.cause.message}`);
146
+ if (this.cause.stack) {
147
+ parts.push(this.cause.stack);
148
+ }
149
+ }
150
+ return parts.join("\n");
151
+ }
152
+ };
153
+ var bigintSafeJsonStringify = (value) => {
154
+ return JSON.stringify(value, (key, value2) => {
155
+ if (typeof value2 === "bigint") {
156
+ return `${value2}n`;
157
+ }
158
+ return value2;
159
+ });
160
+ };
161
+ var isCofheError = (error) => error instanceof CofheError;
162
+
69
163
  // acps/sealing.ts
70
164
  var KEY_HEX_LENGTH = 64;
71
165
  var GenerateSealingKey = () => {
@@ -93,9 +187,25 @@ var unsealWithPrivateKey = (privateKey, parsedData) => {
93
187
  const nonce = parsedData.nonce instanceof Uint8Array ? parsedData.nonce : new Uint8Array(parsedData.nonce);
94
188
  const ephemPublicKey = parsedData.public_key instanceof Uint8Array ? parsedData.public_key : new Uint8Array(parsedData.public_key);
95
189
  const dataToDecrypt = parsedData.data instanceof Uint8Array ? parsedData.data : new Uint8Array(parsedData.data);
96
- const decryptedMessage = nacl__default.default.box.open(dataToDecrypt, nonce, ephemPublicKey, fromHexString(privateKey));
190
+ let decryptedMessage;
191
+ let cause;
192
+ try {
193
+ decryptedMessage = nacl__default.default.box.open(dataToDecrypt, nonce, ephemPublicKey, fromHexString(privateKey));
194
+ } catch (e) {
195
+ decryptedMessage = null;
196
+ cause = e instanceof Error ? e : void 0;
197
+ }
97
198
  if (!decryptedMessage) {
98
- throw new Error("Failed to decrypt message");
199
+ throw new CofheError({
200
+ code: "SEAL_OUTPUT_FAILED" /* SealOutputFailed */,
201
+ message: "Failed to unseal decrypt response",
202
+ cause,
203
+ context: {
204
+ dataLength: dataToDecrypt.length,
205
+ nonceLength: nonce.length,
206
+ publicKeyLength: ephemPublicKey.length
207
+ }
208
+ });
99
209
  }
100
210
  return toBigInt(decryptedMessage);
101
211
  };
@@ -412,100 +522,6 @@ var COFHE_ADDRESS_BOOK_ADDRESS = "0xC0F4e00E531a2B086492Ae3DCC1515038307196b";
412
522
  var TASK_MANAGER_ID = 1n;
413
523
  BigInt(1 << 30);
414
524
 
415
- // core/error.ts
416
- var CofheError = class _CofheError extends Error {
417
- code;
418
- cause;
419
- hint;
420
- context;
421
- apiErrorCode;
422
- constructor({ code, message, cause, hint, context, apiErrorCode }) {
423
- const fullMessage = cause ? `${message} | Caused by: ${cause.message}` : message;
424
- super(fullMessage);
425
- this.name = "CofheError";
426
- this.code = code;
427
- this.cause = cause;
428
- this.hint = hint;
429
- this.context = context;
430
- this.apiErrorCode = apiErrorCode;
431
- if (Error.captureStackTrace) {
432
- Error.captureStackTrace(this, _CofheError);
433
- }
434
- }
435
- /**
436
- * Creates a CofheError from an unknown error
437
- * If the error is a CofheError, it is returned unchanged, else a new CofheError is created
438
- * If a wrapperError is provided, it is used to create the new CofheError, else a default is used
439
- */
440
- static fromError(error, wrapperError) {
441
- if (isCofheError(error))
442
- return error;
443
- const cause = error instanceof Error ? error : new Error(`${error}`);
444
- return new _CofheError({
445
- code: wrapperError?.code ?? "INTERNAL_ERROR" /* InternalError */,
446
- message: wrapperError?.message ?? "An internal error occurred",
447
- hint: wrapperError?.hint,
448
- context: wrapperError?.context,
449
- apiErrorCode: wrapperError?.apiErrorCode,
450
- cause
451
- });
452
- }
453
- /**
454
- * Serializes the error to JSON string with proper handling of Error objects
455
- */
456
- serialize() {
457
- return bigintSafeJsonStringify({
458
- name: this.name,
459
- code: this.code,
460
- message: this.message,
461
- hint: this.hint,
462
- context: this.context,
463
- apiErrorCode: this.apiErrorCode,
464
- cause: this.cause ? {
465
- name: this.cause.name,
466
- message: this.cause.message,
467
- stack: this.cause.stack
468
- } : void 0,
469
- stack: this.stack
470
- });
471
- }
472
- /**
473
- * Returns a human-readable string representation of the error
474
- */
475
- toString() {
476
- const codeSuffix = this.apiErrorCode ? ` (api: ${this.apiErrorCode})` : "";
477
- const parts = [`${this.name} [${this.code}]${codeSuffix}: ${this.message}`];
478
- if (this.hint) {
479
- parts.push(`Hint: ${this.hint}`);
480
- }
481
- if (this.context && Object.keys(this.context).length > 0) {
482
- parts.push(`Context: ${bigintSafeJsonStringify(this.context)}`);
483
- }
484
- if (this.stack) {
485
- parts.push(`
486
- Stack trace:`);
487
- parts.push(this.stack);
488
- }
489
- if (this.cause) {
490
- parts.push(`
491
- Caused by: ${this.cause.name}: ${this.cause.message}`);
492
- if (this.cause.stack) {
493
- parts.push(this.cause.stack);
494
- }
495
- }
496
- return parts.join("\n");
497
- }
498
- };
499
- var bigintSafeJsonStringify = (value) => {
500
- return JSON.stringify(value, (key, value2) => {
501
- if (typeof value2 === "bigint") {
502
- return `${value2}n`;
503
- }
504
- return value2;
505
- });
506
- };
507
- var isCofheError = (error) => error instanceof CofheError;
508
-
509
525
  // core/taskManager.ts
510
526
  var ADDRESS_BOOK_ABI = viem.parseAbi([
511
527
  "function getTm(uint256 id) view returns (address)",
@@ -813,15 +829,22 @@ var getAclServedAddresses = async (publicClient, chainId) => {
813
829
  } catch {
814
830
  return {};
815
831
  }
832
+ let transient = false;
833
+ const readServedAddress = (functionName) => publicClient.readContract({ address: aclAddress, abi: ACL_SERVED_ADDRESSES_ABI, functionName }).catch((err) => {
834
+ if (revertErrorName(err, ACL_SERVED_ADDRESSES_ABI) === void 0)
835
+ transient = true;
836
+ return void 0;
837
+ });
816
838
  const [defaultRevoker, shareRegistry] = await Promise.all([
817
- publicClient.readContract({ address: aclAddress, abi: ACL_SERVED_ADDRESSES_ABI, functionName: "defaultRevokerContract" }).catch(() => void 0),
818
- publicClient.readContract({ address: aclAddress, abi: ACL_SERVED_ADDRESSES_ABI, functionName: "shareRegistry" }).catch(() => void 0)
839
+ readServedAddress("defaultRevokerContract"),
840
+ readServedAddress("shareRegistry")
819
841
  ]);
820
842
  const resolved = {
821
843
  defaultRevoker: defaultRevoker != null && defaultRevoker !== viem.zeroAddress ? defaultRevoker : void 0,
822
844
  shareRegistry: shareRegistry != null && shareRegistry !== viem.zeroAddress ? shareRegistry : void 0
823
845
  };
824
- aclServedAddressesCache.set(chainId, resolved);
846
+ if (!transient)
847
+ aclServedAddressesCache.set(chainId, resolved);
825
848
  return resolved;
826
849
  };
827
850
 
package/dist/acps.d.cts CHANGED
@@ -1,364 +1,10 @@
1
- import { A as ACP, S as ShareLabel, a as StoredValueLabel, E as EventValueLabel, L as LabelledShare, V as ValidationResult, b as ACPPublic, c as ACPSignaturePrimaryType, d as EIP712Types, e as EIP712Message, f as SerializedACP } from './onchain-utils-D9Z33IP7.cjs';
2
- export { O as ACPAccessStatus, P as ACPHashFields, h as ACPMetadata, H as ACPOf, D as ACPPrivate, M as ACPScope, N as ACPScopeOptions, F as ACPType, l as ACPUtils, p as AclServedAddresses, C as CreateSelfACPOptions, g as CreateSharingACPOptions, k as EIP712Domain, B as EIP712Type, r as EthEncryptedData, Q as Expand, G as GenerateSealingKey, I as ImportACPOptions, I as ImportSharedACPOptions, j as IncomingShare, v as LabelVerification, R as RecipientACP, q as SealingKeyPair, J as SelfACP, C as SelfACPOptions, x as ShareLabelCheck, t as ShareLabelReadArg, w as ShareLabelVerifyMode, i as SharedACP, K as SharingACP, g as SharingACPOptions, U as UnlabelledLabel, o as clearAclServedAddresses, m as getAclAddress, n as getAclServedAddresses, s as seal, u as unsealWithPrivateKey, y as verifyShareLabel, z as verifyShareLabels } from './onchain-utils-D9Z33IP7.cjs';
3
- import { Hex, AbiParameterToPrimitiveType, Address, PublicClient, Abi, ContractFunctionName, ContractFunctionArgs, Log } from 'viem';
1
+ import { S as ShareLabel, a as StoredValueLabel, E as EventValueLabel, L as LabelledShare, A as ACP, V as ValidationResult, b as ACPPublic, c as ACPSignaturePrimaryType, d as EIP712Types, e as EIP712Message, f as SerializedACP } from './onchain-utils-Ns56cBm0.cjs';
2
+ export { a4 as ACPAccessStatus, a5 as ACPHashFields, h as ACPMetadata, _ as ACPOf, Y as ACPPrivate, a2 as ACPScope, a3 as ACPScopeOptions, Z as ACPType, l as ACPUtils, t as ACP_REVOKER_ABI, v as ACP_SHARE_REGISTRY_ABI, w as ACP_SHARE_TUPLE_ABI, p as AclServedAddresses, B as ChainShare, C as CreateSelfACPOptions, g as CreateSharingACPOptions, k as EIP712Domain, X as EIP712Type, r as EthEncryptedData, a6 as Expand, G as GenerateSealingKey, I as ImportACPOptions, I as ImportSharedACPOptions, j as IncomingShare, O as LabelVerification, P as PostedShare, F as PostedShares, a1 as RecipientACP, q as SealingKeyPair, $ as SelfACP, C as SelfACPOptions, D as ShareHeader, R as ShareLabelCheck, M as ShareLabelReadArg, Q as ShareLabelVerifyMode, i as SharedACP, a0 as SharingACP, g as SharingACPOptions, N as UnlabelledLabel, U as UnreadableShare, o as clearAclServedAddresses, y as computeShareId, m as getAclAddress, n as getAclServedAddresses, H as readPostedShares, K as readShare, J as readSharesFor, s as seal, z as shareIdOfChainShare, x as toChainShare, u as unsealWithPrivateKey, T as verifyShareLabel, W as verifyShareLabels } from './onchain-utils-Ns56cBm0.cjs';
3
+ import { Address, Hex, Abi, ContractFunctionName, ContractFunctionArgs, Log } from 'viem';
4
4
  import { z } from 'zod';
5
5
  import * as zustand_middleware from 'zustand/middleware';
6
6
  import * as zustand_vanilla from 'zustand/vanilla';
7
7
 
8
- /**
9
- * The on-chain sharing pieces: the share registry and revoker ABIs, the registry payload of a
10
- * sharing ACP and its share id, and the read of a share from its `Shared` event. Exported so an
11
- * app can send these writes through its own transaction path and still agree with the registry
12
- * on ids.
13
- *
14
- * The registry is pointer-based: storage keeps a share header (issuer, expiration, recipient,
15
- * revoker, and the block of its `Shared` event); the full payload and the metadata blob travel in
16
- * that event. A reader takes headers from `sharesFor` / `getShare` and fetches the events with one
17
- * single-block `getLogs` per block.
18
- */
19
- declare const ACP_REVOKER_ABI: readonly [{
20
- readonly name: "revokeSingle";
21
- readonly type: "function";
22
- readonly stateMutability: "nonpayable";
23
- readonly inputs: readonly [{
24
- readonly type: "uint256";
25
- readonly name: "id";
26
- }];
27
- readonly outputs: readonly [];
28
- }, {
29
- readonly name: "revokeAllExisting";
30
- readonly type: "function";
31
- readonly stateMutability: "nonpayable";
32
- readonly inputs: readonly [];
33
- readonly outputs: readonly [];
34
- }, {
35
- readonly name: "disabled";
36
- readonly type: "function";
37
- readonly stateMutability: "view";
38
- readonly inputs: readonly [{
39
- readonly type: "address";
40
- readonly name: "issuer";
41
- }, {
42
- readonly type: "uint256";
43
- readonly name: "id";
44
- }];
45
- readonly outputs: readonly [{
46
- readonly type: "bool";
47
- }];
48
- }];
49
- declare const ACP_SHARE_REGISTRY_ABI: readonly [{
50
- readonly name: "share";
51
- readonly type: "function";
52
- readonly stateMutability: "nonpayable";
53
- readonly inputs: readonly [{
54
- readonly type: "tuple";
55
- readonly components: readonly [{
56
- readonly type: "address";
57
- readonly name: "issuer";
58
- }, {
59
- readonly type: "uint64";
60
- readonly name: "expiration";
61
- }, {
62
- readonly type: "address";
63
- readonly name: "recipient";
64
- }, {
65
- readonly type: "uint256";
66
- readonly name: "revokerData";
67
- }, {
68
- readonly type: "address";
69
- readonly name: "revokerContract";
70
- }, {
71
- readonly type: "uint8";
72
- readonly name: "scope";
73
- }, {
74
- readonly type: "address[]";
75
- readonly name: "contracts";
76
- }, {
77
- readonly type: "bytes32[]";
78
- readonly name: "handles";
79
- }, {
80
- readonly type: "bytes32";
81
- readonly name: "sealingKey";
82
- }, {
83
- readonly type: "bytes";
84
- readonly name: "issuerSignature";
85
- }, {
86
- readonly type: "bytes";
87
- readonly name: "recipientSignature";
88
- }];
89
- readonly name: "acp";
90
- }, {
91
- readonly type: "bytes";
92
- readonly name: "metadata";
93
- }];
94
- readonly outputs: readonly [{
95
- readonly type: "bytes32";
96
- }];
97
- }, {
98
- readonly name: "removeShare";
99
- readonly type: "function";
100
- readonly stateMutability: "nonpayable";
101
- readonly inputs: readonly [{
102
- readonly type: "bytes32";
103
- readonly name: "shareId";
104
- }];
105
- readonly outputs: readonly [];
106
- }, {
107
- readonly name: "sharesFor";
108
- readonly type: "function";
109
- readonly stateMutability: "view";
110
- readonly inputs: readonly [{
111
- readonly type: "address";
112
- readonly name: "recipient";
113
- }];
114
- readonly outputs: readonly [{
115
- readonly type: "bytes32[]";
116
- readonly name: "shareIds";
117
- }, {
118
- readonly type: "tuple[]";
119
- readonly components: readonly [{
120
- readonly type: "address";
121
- readonly name: "issuer";
122
- }, {
123
- readonly type: "uint64";
124
- readonly name: "expiration";
125
- }, {
126
- readonly type: "address";
127
- readonly name: "recipient";
128
- }, {
129
- readonly type: "uint64";
130
- readonly name: "blockNumber";
131
- }, {
132
- readonly type: "address";
133
- readonly name: "revokerContract";
134
- }, {
135
- readonly type: "uint256";
136
- readonly name: "revokerData";
137
- }];
138
- readonly name: "headers";
139
- }];
140
- }, {
141
- readonly name: "getShare";
142
- readonly type: "function";
143
- readonly stateMutability: "view";
144
- readonly inputs: readonly [{
145
- readonly type: "bytes32";
146
- readonly name: "shareId";
147
- }];
148
- readonly outputs: readonly [{
149
- readonly type: "tuple";
150
- readonly components: readonly [{
151
- readonly type: "address";
152
- readonly name: "issuer";
153
- }, {
154
- readonly type: "uint64";
155
- readonly name: "expiration";
156
- }, {
157
- readonly type: "address";
158
- readonly name: "recipient";
159
- }, {
160
- readonly type: "uint64";
161
- readonly name: "blockNumber";
162
- }, {
163
- readonly type: "address";
164
- readonly name: "revokerContract";
165
- }, {
166
- readonly type: "uint256";
167
- readonly name: "revokerData";
168
- }];
169
- }];
170
- }, {
171
- readonly name: "isShareValid";
172
- readonly type: "function";
173
- readonly stateMutability: "view";
174
- readonly inputs: readonly [{
175
- readonly type: "bytes32";
176
- readonly name: "shareId";
177
- }];
178
- readonly outputs: readonly [{
179
- readonly type: "bool";
180
- }];
181
- }, {
182
- readonly name: "Shared";
183
- readonly type: "event";
184
- readonly inputs: readonly [{
185
- readonly type: "address";
186
- readonly name: "recipient";
187
- readonly indexed: true;
188
- }, {
189
- readonly type: "address";
190
- readonly name: "issuer";
191
- readonly indexed: true;
192
- }, {
193
- readonly type: "bytes32";
194
- readonly name: "shareId";
195
- readonly indexed: true;
196
- }, {
197
- readonly type: "tuple";
198
- readonly components: readonly [{
199
- readonly type: "address";
200
- readonly name: "issuer";
201
- }, {
202
- readonly type: "uint64";
203
- readonly name: "expiration";
204
- }, {
205
- readonly type: "address";
206
- readonly name: "recipient";
207
- }, {
208
- readonly type: "uint256";
209
- readonly name: "revokerData";
210
- }, {
211
- readonly type: "address";
212
- readonly name: "revokerContract";
213
- }, {
214
- readonly type: "uint8";
215
- readonly name: "scope";
216
- }, {
217
- readonly type: "address[]";
218
- readonly name: "contracts";
219
- }, {
220
- readonly type: "bytes32[]";
221
- readonly name: "handles";
222
- }, {
223
- readonly type: "bytes32";
224
- readonly name: "sealingKey";
225
- }, {
226
- readonly type: "bytes";
227
- readonly name: "issuerSignature";
228
- }, {
229
- readonly type: "bytes";
230
- readonly name: "recipientSignature";
231
- }];
232
- readonly name: "acp";
233
- }, {
234
- readonly type: "bytes";
235
- readonly name: "metadata";
236
- }];
237
- }, {
238
- readonly name: "ShareRemoved";
239
- readonly type: "event";
240
- readonly inputs: readonly [{
241
- readonly type: "address";
242
- readonly name: "recipient";
243
- readonly indexed: true;
244
- }, {
245
- readonly type: "address";
246
- readonly name: "issuer";
247
- readonly indexed: true;
248
- }, {
249
- readonly type: "bytes32";
250
- readonly name: "shareId";
251
- readonly indexed: true;
252
- }];
253
- }];
254
- declare const ACP_SHARE_TUPLE_ABI: readonly [{
255
- readonly type: "tuple";
256
- readonly components: readonly [{
257
- readonly name: "issuer";
258
- readonly type: "address";
259
- }, {
260
- readonly name: "expiration";
261
- readonly type: "uint64";
262
- }, {
263
- readonly name: "recipient";
264
- readonly type: "address";
265
- }, {
266
- readonly name: "revokerData";
267
- readonly type: "uint256";
268
- }, {
269
- readonly name: "revokerContract";
270
- readonly type: "address";
271
- }, {
272
- readonly name: "scope";
273
- readonly type: "uint8";
274
- }, {
275
- readonly name: "contracts";
276
- readonly type: "address[]";
277
- }, {
278
- readonly name: "handles";
279
- readonly type: "bytes32[]";
280
- }, {
281
- readonly name: "sealingKey";
282
- readonly type: "bytes32";
283
- }, {
284
- readonly name: "issuerSignature";
285
- readonly type: "bytes";
286
- }, {
287
- readonly name: "recipientSignature";
288
- readonly type: "bytes";
289
- }];
290
- }];
291
- /** The on-chain payload for a sharing ACP: recipient-side fields empty. */
292
- declare const toChainShare: (acp: ACP) => {
293
- expiration: bigint;
294
- revokerData: bigint;
295
- sealingKey: `0x${string}`;
296
- recipientSignature: Hex;
297
- issuer: Hex;
298
- recipient: Hex;
299
- revokerContract: Hex;
300
- scope: number;
301
- contracts: Hex[];
302
- handles: Hex[];
303
- issuerSignature: Hex;
304
- };
305
- /** Mirrors the registry's `keccak256(abi.encode(acp))` share id. */
306
- declare const computeShareId: (acp: ACP) => Hex;
307
- /** The share id of a registry payload as read back from a `Shared` event. */
308
- declare const shareIdOfChainShare: (share: ChainShare) => Hex;
309
- /** A registry payload, as decoded from a `Shared` event (or passed to `share`). */
310
- type ChainShare = AbiParameterToPrimitiveType<(typeof ACP_SHARE_TUPLE_ABI)[0]>;
311
- /** What the registry stores of a share: the fields it checks, and the block of its `Shared` event. */
312
- type ShareHeader = {
313
- issuer: Address;
314
- expiration: bigint;
315
- recipient: Address;
316
- /** Block of the `Shared` event (the L2 block on Arbitrum). */
317
- blockNumber: bigint;
318
- revokerContract: Address;
319
- revokerData: bigint;
320
- };
321
- /** A share as posted: its payload and the metadata blob that came with it (`0x` when none). */
322
- type PostedShare = {
323
- shareId: Hex;
324
- header: ShareHeader;
325
- share: ChainShare;
326
- metadata: Hex;
327
- };
328
- /** A share the registry lists but whose `Shared` event could not be read, and why. */
329
- type UnreadableShare = {
330
- shareId: Hex;
331
- header: ShareHeader;
332
- reason: string;
333
- };
334
- /** Shares read from their events, and those that could not be; each share is on its own. */
335
- type PostedShares = {
336
- posted: PostedShare[];
337
- unreadable: UnreadableShare[];
338
- };
339
- /**
340
- * Fetches the `Shared` events of shares from the blocks their headers name: one single-block
341
- * `getLogs` per distinct block, filtered by registry and share ids, so any node answers it. Returns
342
- * the shares in the order given; where a block holds several events for one share id, the last.
343
- * Never fails as a whole: a share whose block the node cannot serve yet, whose event is missing
344
- * from it, or whose event payload does not hash to its id is returned as `unreadable`, with the
345
- * reason, and the rest are posted as usual.
346
- */
347
- declare const readPostedShares: (publicClient: PublicClient, registry: Address, headers: readonly {
348
- shareId: Hex;
349
- header: ShareHeader;
350
- }[]) => Promise<PostedShares>;
351
- /**
352
- * The importable shares addressed to `recipient` (unexpired, not revoked), read from their events;
353
- * those whose event could not be read are listed apart, so one of them never hides the rest.
354
- */
355
- declare const readSharesFor: (publicClient: PublicClient, registry: Address, recipient: Address) => Promise<PostedShares>;
356
- /**
357
- * One share by id, read from its event; null when the registry has no such share (unknown or
358
- * removed). Throws, with the reason, when the registry lists it but its event could not be read.
359
- */
360
- declare const readShare: (publicClient: PublicClient, registry: Address, shareId: Hex) => Promise<PostedShare | null>;
361
-
362
8
  /**
363
9
  * Byte layout of a share metadata blob, version 3. Integers are big-endian; sizes in bytes.
364
10
  *
@@ -1056,4 +702,4 @@ declare const acpStore: {
1056
702
  resetStore: () => void;
1057
703
  };
1058
704
 
1059
- export { ACP, ACPPublic, ACPSignaturePrimaryType, ACP_REVOKER_ABI, ACP_SHARE_REGISTRY_ABI, ACP_SHARE_TUPLE_ABI, ACP_STORE_DEFAULTS, type ChainShare, type DecodedShareMetadata, EIP712Message, EIP712Types, ERC7984_ABI, type EventValueDescription, EventValueLabel, ImportACPOptionsValidator, ImportACPValidator, LabelledShare, type PostedShare, type PostedShares, LAYOUT_VERSION as SHARE_METADATA_VERSION, SelfACPOptionsValidator, SelfACPValidator, SerializedACP, type ShareHeader, ShareLabel, type ShareLabelAbis, type ShareLabelArg, type ShareLabelDescription, type ShareLabelParam, SharingACPOptionsValidator, SharingACPValidator, SignatureTypes, SignatureUtils, type StoredValueDescription, StoredValueLabel, UNLABELLED, type UnlabelledDescription, type UnreadableShare, ValidationResult, ValidationUtils, type ViewFunctionLabelOptions, _acpStore, acpStore, addressNotZeroSchema, addressSchema, bytesNotEmptySchema, bytesSchema, clearStaleStore, computeShareId, contractsSchema, decodeShareAppKey, decodeShareMetadata, decodeShareMetadataFull, describeShareLabels, describeShareMetadata, encodeShareMetadata, eventLogLabel, getACP, getACPs, getActiveACP, getActiveACPHash, getSignatureTypesAndMessage, handlesSchema, readPostedShares, readShare, readSharesFor, removeACP, removeActiveACPHash, resetStore, setACP, setActiveACPHash, shareAppKey, shareIdOfChainShare, toChainShare, validateImportACP, validateImportACPOptions, validateSelfACP, validateSelfACPOptions, validateSharingACP, validateSharingACPOptions, viewFunctionLabel };
705
+ export { ACP, ACPPublic, ACPSignaturePrimaryType, ACP_STORE_DEFAULTS, type DecodedShareMetadata, EIP712Message, EIP712Types, ERC7984_ABI, type EventValueDescription, EventValueLabel, ImportACPOptionsValidator, ImportACPValidator, LabelledShare, LAYOUT_VERSION as SHARE_METADATA_VERSION, SelfACPOptionsValidator, SelfACPValidator, SerializedACP, ShareLabel, type ShareLabelAbis, type ShareLabelArg, type ShareLabelDescription, type ShareLabelParam, SharingACPOptionsValidator, SharingACPValidator, SignatureTypes, SignatureUtils, type StoredValueDescription, StoredValueLabel, UNLABELLED, type UnlabelledDescription, ValidationResult, ValidationUtils, type ViewFunctionLabelOptions, _acpStore, acpStore, addressNotZeroSchema, addressSchema, bytesNotEmptySchema, bytesSchema, clearStaleStore, contractsSchema, decodeShareAppKey, decodeShareMetadata, decodeShareMetadataFull, describeShareLabels, describeShareMetadata, encodeShareMetadata, eventLogLabel, getACP, getACPs, getActiveACP, getActiveACPHash, getSignatureTypesAndMessage, handlesSchema, removeACP, removeActiveACPHash, resetStore, setACP, setActiveACPHash, shareAppKey, validateImportACP, validateImportACPOptions, validateSelfACP, validateSelfACPOptions, validateSharingACP, validateSharingACPOptions, viewFunctionLabel };