@cofhe/sdk 0.8.0 → 1.0.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/CHANGELOG.md +51 -0
- package/acps/acp.ts +25 -6
- package/acps/index.ts +20 -15
- package/acps/onchain-utils.ts +15 -10
- package/acps/registry.ts +166 -8
- package/acps/sealing.ts +31 -5
- package/acps/share-metadata/appKey.ts +8 -0
- package/acps/share-metadata/decode.ts +120 -0
- package/acps/share-metadata/describe.ts +198 -0
- package/acps/share-metadata/encode.ts +147 -0
- package/acps/share-metadata/erc7984.ts +26 -0
- package/acps/share-metadata/index.ts +9 -0
- package/acps/share-metadata/layout.ts +69 -0
- package/acps/share-metadata/presets.ts +116 -0
- package/acps/share-metadata/schema.ts +47 -0
- package/acps/share-metadata/test/codec.test.ts +140 -0
- package/acps/share-metadata/test/describe.test.ts +112 -0
- package/acps/share-metadata/test/fixtures.ts +157 -0
- package/acps/share-metadata/test/live.test.ts +56 -0
- package/acps/share-metadata/test/presets.test.ts +119 -0
- package/acps/share-metadata/test/verify.test.ts +144 -0
- package/acps/share-metadata/verify.ts +155 -0
- package/acps/store.ts +48 -18
- package/acps/test/aclServedAddresses.test.ts +65 -0
- package/acps/test/acp.test.ts +102 -7
- package/acps/test/localstorage.test.ts +28 -1
- package/acps/test/registry.test.ts +144 -0
- package/acps/test/sealing.test.ts +74 -0
- package/acps/test/store.test.ts +71 -0
- package/acps/test/utils.test.ts +63 -0
- package/acps/test/validation.test.ts +0 -4
- package/acps/types.ts +43 -6
- package/acps/utils.ts +15 -2
- package/acps/validation.ts +3 -1
- package/core/acps.ts +123 -74
- package/core/client.ts +33 -7
- package/core/clientTypes.ts +25 -7
- package/core/config.ts +8 -0
- package/core/decrypt/apiError.ts +4 -1
- package/core/decrypt/verifyDecryptResult.ts +4 -1
- package/core/encrypt/cofheMocksZkVerifySign.ts +19 -2
- package/core/test/acpDefaults.test.ts +108 -19
- package/core/test/acpStoreAccountCase.test.ts +80 -0
- package/core/test/acps.test.ts +38 -3
- package/core/test/apiError.test.ts +8 -0
- package/core/test/appKeyConfig.test.ts +94 -0
- package/core/test/config.test.ts +8 -0
- package/core/test/decryptBuilders.test.ts +110 -2
- package/core/test/incomingShares.test.ts +84 -0
- package/core/test/mocksEncryptRange.test.ts +90 -0
- package/core/test/utils.test.ts +128 -0
- package/core/test/verifyDecryptResult.test.ts +51 -0
- package/core/utils.ts +16 -9
- package/dist/acps.cjs +796 -132
- package/dist/acps.d.cts +367 -35
- package/dist/acps.d.ts +367 -35
- package/dist/acps.js +2 -2
- package/dist/{chunk-UJYOBHYA.js → chunk-3L2IVPMI.js} +688 -203
- package/dist/chunk-J23FYAI2.js +174 -0
- package/dist/{chunk-GGI7Y6AW.js → chunk-O2ITEUEU.js} +110 -269
- package/dist/chunk-WJGTPW7K.js +228 -0
- package/dist/{clientTypes-D3aIXmUp.d.cts → clientTypes-IO6b5Um8.d.cts} +61 -21
- package/dist/{clientTypes-5YPPR16m.d.ts → clientTypes-b1pOxOUE.d.ts} +61 -21
- package/dist/core.cjs +3115 -2584
- package/dist/core.d.cts +6 -3
- package/dist/core.d.ts +6 -3
- package/dist/core.js +4 -3
- package/dist/node.cjs +3001 -2470
- package/dist/node.d.cts +2 -2
- package/dist/node.d.ts +2 -2
- package/dist/node.js +18 -17
- package/dist/{onchain-utils-CUAK8glx.d.cts → onchain-utils-CgOslubH.d.cts} +139 -15
- package/dist/{onchain-utils-CUAK8glx.d.ts → onchain-utils-CgOslubH.d.ts} +139 -15
- package/dist/web.cjs +3011 -2487
- package/dist/web.d.cts +2 -2
- package/dist/web.d.ts +2 -2
- package/dist/web.js +4 -10
- package/dist/zkProve.worker.cjs +14 -7
- package/dist/zkProve.worker.js +2 -8
- package/node/index.ts +1 -10
- package/node/storage.ts +18 -7
- package/node/test/storage-permissions.test.ts +40 -0
- package/package.json +4 -4
- package/web/index.ts +1 -10
- package/web/test/threadPoolBenchHelper.ts +1 -7
- package/web/zkProve.worker.ts +1 -10
- package/dist/chunk-NMKMCAI3.js +0 -14
package/dist/acps.d.ts
CHANGED
|
@@ -1,14 +1,20 @@
|
|
|
1
|
-
import { A as ACP, V as ValidationResult,
|
|
2
|
-
export {
|
|
3
|
-
import { Hex, AbiParameterToPrimitiveType } from 'viem';
|
|
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-CgOslubH.js';
|
|
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-CgOslubH.js';
|
|
3
|
+
import { Hex, AbiParameterToPrimitiveType, Address, PublicClient, 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
8
|
/**
|
|
9
9
|
* The on-chain sharing pieces: the share registry and revoker ABIs, the registry payload of a
|
|
10
|
-
* sharing ACP and its share id
|
|
11
|
-
* transaction path and still agree with the registry
|
|
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.
|
|
12
18
|
*/
|
|
13
19
|
declare const ACP_REVOKER_ABI: readonly [{
|
|
14
20
|
readonly name: "revokeSingle";
|
|
@@ -81,6 +87,9 @@ declare const ACP_SHARE_REGISTRY_ABI: readonly [{
|
|
|
81
87
|
readonly name: "recipientSignature";
|
|
82
88
|
}];
|
|
83
89
|
readonly name: "acp";
|
|
90
|
+
}, {
|
|
91
|
+
readonly type: "bytes";
|
|
92
|
+
readonly name: "metadata";
|
|
84
93
|
}];
|
|
85
94
|
readonly outputs: readonly [{
|
|
86
95
|
readonly type: "bytes32";
|
|
@@ -103,6 +112,9 @@ declare const ACP_SHARE_REGISTRY_ABI: readonly [{
|
|
|
103
112
|
readonly name: "recipient";
|
|
104
113
|
}];
|
|
105
114
|
readonly outputs: readonly [{
|
|
115
|
+
readonly type: "bytes32[]";
|
|
116
|
+
readonly name: "shareIds";
|
|
117
|
+
}, {
|
|
106
118
|
readonly type: "tuple[]";
|
|
107
119
|
readonly components: readonly [{
|
|
108
120
|
readonly type: "address";
|
|
@@ -114,33 +126,49 @@ declare const ACP_SHARE_REGISTRY_ABI: readonly [{
|
|
|
114
126
|
readonly type: "address";
|
|
115
127
|
readonly name: "recipient";
|
|
116
128
|
}, {
|
|
117
|
-
readonly type: "
|
|
118
|
-
readonly name: "
|
|
129
|
+
readonly type: "uint64";
|
|
130
|
+
readonly name: "blockNumber";
|
|
119
131
|
}, {
|
|
120
132
|
readonly type: "address";
|
|
121
133
|
readonly name: "revokerContract";
|
|
122
134
|
}, {
|
|
123
|
-
readonly type: "
|
|
124
|
-
readonly name: "
|
|
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";
|
|
125
153
|
}, {
|
|
126
|
-
readonly type: "
|
|
127
|
-
readonly name: "
|
|
154
|
+
readonly type: "uint64";
|
|
155
|
+
readonly name: "expiration";
|
|
128
156
|
}, {
|
|
129
|
-
readonly type: "
|
|
130
|
-
readonly name: "
|
|
157
|
+
readonly type: "address";
|
|
158
|
+
readonly name: "recipient";
|
|
131
159
|
}, {
|
|
132
|
-
readonly type: "
|
|
133
|
-
readonly name: "
|
|
160
|
+
readonly type: "uint64";
|
|
161
|
+
readonly name: "blockNumber";
|
|
134
162
|
}, {
|
|
135
|
-
readonly type: "
|
|
136
|
-
readonly name: "
|
|
163
|
+
readonly type: "address";
|
|
164
|
+
readonly name: "revokerContract";
|
|
137
165
|
}, {
|
|
138
|
-
readonly type: "
|
|
139
|
-
readonly name: "
|
|
166
|
+
readonly type: "uint256";
|
|
167
|
+
readonly name: "revokerData";
|
|
140
168
|
}];
|
|
141
169
|
}];
|
|
142
170
|
}, {
|
|
143
|
-
readonly name: "
|
|
171
|
+
readonly name: "isShareValid";
|
|
144
172
|
readonly type: "function";
|
|
145
173
|
readonly stateMutability: "view";
|
|
146
174
|
readonly inputs: readonly [{
|
|
@@ -148,6 +176,24 @@ declare const ACP_SHARE_REGISTRY_ABI: readonly [{
|
|
|
148
176
|
readonly name: "shareId";
|
|
149
177
|
}];
|
|
150
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
|
+
}, {
|
|
151
197
|
readonly type: "tuple";
|
|
152
198
|
readonly components: readonly [{
|
|
153
199
|
readonly type: "address";
|
|
@@ -183,17 +229,26 @@ declare const ACP_SHARE_REGISTRY_ABI: readonly [{
|
|
|
183
229
|
readonly type: "bytes";
|
|
184
230
|
readonly name: "recipientSignature";
|
|
185
231
|
}];
|
|
232
|
+
readonly name: "acp";
|
|
233
|
+
}, {
|
|
234
|
+
readonly type: "bytes";
|
|
235
|
+
readonly name: "metadata";
|
|
186
236
|
}];
|
|
187
237
|
}, {
|
|
188
|
-
readonly name: "
|
|
189
|
-
readonly type: "
|
|
190
|
-
readonly stateMutability: "view";
|
|
238
|
+
readonly name: "ShareRemoved";
|
|
239
|
+
readonly type: "event";
|
|
191
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
|
+
}, {
|
|
192
249
|
readonly type: "bytes32";
|
|
193
250
|
readonly name: "shareId";
|
|
194
|
-
|
|
195
|
-
readonly outputs: readonly [{
|
|
196
|
-
readonly type: "bool";
|
|
251
|
+
readonly indexed: true;
|
|
197
252
|
}];
|
|
198
253
|
}];
|
|
199
254
|
declare const ACP_SHARE_TUPLE_ABI: readonly [{
|
|
@@ -249,8 +304,279 @@ declare const toChainShare: (acp: ACP) => {
|
|
|
249
304
|
};
|
|
250
305
|
/** Mirrors the registry's `keccak256(abi.encode(acp))` share id. */
|
|
251
306
|
declare const computeShareId: (acp: ACP) => Hex;
|
|
252
|
-
/** The share id of a registry payload as read back from `
|
|
253
|
-
declare const shareIdOfChainShare: (share:
|
|
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
|
+
/**
|
|
363
|
+
* Byte layout of a share metadata blob, version 3. Integers are big-endian; sizes in bytes.
|
|
364
|
+
*
|
|
365
|
+
* blob = version (1)
|
|
366
|
+
* | contract count (1) | contracts (20 each)
|
|
367
|
+
* | selector count (1) | selectors (4 each) function selectors, and event
|
|
368
|
+
* selectors (first 4 bytes of topic0)
|
|
369
|
+
* | transaction count (1) | transactions (6 each: block 4, tx index 2)
|
|
370
|
+
* | entries, one per ctHash, in the order of acp.handles
|
|
371
|
+
* | app key, optional: 0x01 | key (32) keccak256 of the name of the app the
|
|
372
|
+
* share is for; absent when the blob ends
|
|
373
|
+
*
|
|
374
|
+
* stored value = 0x00 | contract (1) | selector (1) | block (4) | args 8 bytes or more
|
|
375
|
+
* event value = 0x01 | contract (1) | transaction (1) | log index (2) | selector (1) 6 bytes
|
|
376
|
+
* unlabelled = 0xff 1 byte
|
|
377
|
+
*
|
|
378
|
+
* args = 0x00 no arguments, return word 0
|
|
379
|
+
* | 0x01 one argument, the share issuer, return word 0
|
|
380
|
+
* | 0xff | return word (1) | count (1) | argument, count times
|
|
381
|
+
* argument = 0x00 | word (32) a literal ABI word
|
|
382
|
+
* | 0x01 the share issuer
|
|
383
|
+
*
|
|
384
|
+
* Contracts, selectors and transactions are listed once; entries refer to them by position.
|
|
385
|
+
* The log index is block-wide, as RPC nodes return it.
|
|
386
|
+
*/
|
|
387
|
+
declare const LAYOUT_VERSION = 3;
|
|
388
|
+
|
|
389
|
+
/**
|
|
390
|
+
* Encodes the labels of a share into a version 3 blob: one label per ctHash, in the order of
|
|
391
|
+
* `acp.handles`. The contracts, selectors and transactions the labels name are listed once each,
|
|
392
|
+
* in order of first use; function and event selectors share one list. Throws on a value that does
|
|
393
|
+
* not fit its field (more than 255 contracts, a block past uint32, ...). Given the share `issuer`, a
|
|
394
|
+
* stored-value argument equal to their address is stored as "the issuer" instead of the address.
|
|
395
|
+
* Given an `appKey` (`shareAppKey(app)`), it closes the blob, so the app can tell its shares apart.
|
|
396
|
+
*/
|
|
397
|
+
declare const encodeShareMetadata: (labels: readonly ShareLabel[], { issuer, appKey }?: {
|
|
398
|
+
issuer?: Address;
|
|
399
|
+
appKey?: Hex;
|
|
400
|
+
}) => Hex;
|
|
401
|
+
|
|
402
|
+
/** The two things a blob holds: one label per ctHash, and the app key when the share names an app. */
|
|
403
|
+
type DecodedShareMetadata = {
|
|
404
|
+
labels: ShareLabel[];
|
|
405
|
+
appKey: Hex | undefined;
|
|
406
|
+
};
|
|
407
|
+
/**
|
|
408
|
+
* Decodes a version 3 blob: one label per ctHash, in the order of `acp.handles`, and the app key
|
|
409
|
+
* when there is one. The exact inverse of `encodeShareMetadata`. Throws on another version, an
|
|
410
|
+
* unknown kind, code or tag, a position outside its list, and unless the blob holds exactly one
|
|
411
|
+
* entry per ctHash.
|
|
412
|
+
*/
|
|
413
|
+
declare const decodeShareMetadataFull: (blob: Hex, handles: readonly Hex[]) => DecodedShareMetadata;
|
|
414
|
+
/** The labels of a blob, one per ctHash in the order of `acp.handles` (see `decodeShareMetadataFull`). */
|
|
415
|
+
declare const decodeShareMetadata: (blob: Hex, handles: readonly Hex[]) => ShareLabel[];
|
|
416
|
+
/** The app key a share was posted with, or undefined: for a share without metadata, or without a key. */
|
|
417
|
+
declare const decodeShareAppKey: (metadata: Hex | undefined, handles: readonly Hex[]) => Hex | undefined;
|
|
418
|
+
|
|
419
|
+
/** A parameter as the ABI names it. `name` is absent when the ABI leaves it unnamed. */
|
|
420
|
+
type ShareLabelParam = {
|
|
421
|
+
name?: string;
|
|
422
|
+
type: string;
|
|
423
|
+
indexed?: boolean;
|
|
424
|
+
};
|
|
425
|
+
/** One argument of a stored-value read, decoded with the function's input type when the ABI has one. */
|
|
426
|
+
type ShareLabelArg = ShareLabelParam & {
|
|
427
|
+
/** The argument stands for the share issuer. */
|
|
428
|
+
isIssuer: boolean;
|
|
429
|
+
/** The 32-byte ABI word, or undefined for an issuer argument when no issuer was given. */
|
|
430
|
+
raw: Hex | undefined;
|
|
431
|
+
/** The decoded value (an address, a bigint, ...), or the raw word when there is no ABI type for it. */
|
|
432
|
+
value: unknown;
|
|
433
|
+
};
|
|
434
|
+
type DescriptionBase = {
|
|
435
|
+
/** Position of the ctHash in `acp.handles`. */
|
|
436
|
+
index: number;
|
|
437
|
+
handle: Hex;
|
|
438
|
+
};
|
|
439
|
+
type StoredValueDescription = DescriptionBase & {
|
|
440
|
+
kind: 'stored';
|
|
441
|
+
label: StoredValueLabel;
|
|
442
|
+
contract: Address;
|
|
443
|
+
block: bigint;
|
|
444
|
+
selector: Hex;
|
|
445
|
+
/** The view function, or null when the ABI of the contract is missing or has no function with this selector. */
|
|
446
|
+
function: {
|
|
447
|
+
name: string;
|
|
448
|
+
signature: string;
|
|
449
|
+
inputs: ShareLabelParam[];
|
|
450
|
+
} | null;
|
|
451
|
+
args: ShareLabelArg[];
|
|
452
|
+
/** The returned field that holds the ctHash, when the ABI names the outputs. */
|
|
453
|
+
output: ShareLabelParam | null;
|
|
454
|
+
};
|
|
455
|
+
type EventValueDescription = DescriptionBase & {
|
|
456
|
+
kind: 'event';
|
|
457
|
+
label: EventValueLabel;
|
|
458
|
+
contract: Address;
|
|
459
|
+
block: bigint;
|
|
460
|
+
txIndex: number;
|
|
461
|
+
logIndex: number;
|
|
462
|
+
selector: Hex;
|
|
463
|
+
/**
|
|
464
|
+
* The event, or null when the ABI of the contract is missing or has no event with this selector.
|
|
465
|
+
* Parameter values are not in the label; they come with the log fetched to verify it.
|
|
466
|
+
*/
|
|
467
|
+
event: {
|
|
468
|
+
name: string;
|
|
469
|
+
signature: string;
|
|
470
|
+
inputs: ShareLabelParam[];
|
|
471
|
+
} | null;
|
|
472
|
+
};
|
|
473
|
+
type UnlabelledDescription = DescriptionBase & {
|
|
474
|
+
kind: 'unlabelled';
|
|
475
|
+
label: ShareLabel & {
|
|
476
|
+
kind: 'unlabelled';
|
|
477
|
+
};
|
|
478
|
+
};
|
|
479
|
+
type ShareLabelDescription = StoredValueDescription | EventValueDescription | UnlabelledDescription;
|
|
480
|
+
/** ABIs by contract address; addresses compare case-insensitively. */
|
|
481
|
+
type ShareLabelAbis = Readonly<Record<Address, Abi>>;
|
|
482
|
+
/**
|
|
483
|
+
* Turns decoded labels into structured, human-readable items, one per ctHash in the order of
|
|
484
|
+
* `handles`: the function name and decoded arguments of a stored value, the event name and
|
|
485
|
+
* parameters of an event value. A contract without an ABI, or a selector its ABI doesn't have,
|
|
486
|
+
* leaves the item in raw form (`function` / `event` null); this never throws. `issuer` (the share
|
|
487
|
+
* issuer) fills in the arguments that stand for it.
|
|
488
|
+
*/
|
|
489
|
+
declare const describeShareLabels: (labels: readonly ShareLabel[], handles: readonly Hex[], abis?: ShareLabelAbis, options?: {
|
|
490
|
+
issuer?: Address;
|
|
491
|
+
}) => ShareLabelDescription[];
|
|
492
|
+
/**
|
|
493
|
+
* Decodes a share's metadata blob and describes it: `decodeShareMetadata` then
|
|
494
|
+
* `describeShareLabels`, with the share's issuer filling in the arguments that stand for it. The
|
|
495
|
+
* share is one read from the registry or an acp imported from exported JSON. Null for a share
|
|
496
|
+
* without labels (no metadata, or `0x`). Throws only when the blob itself is malformed; missing
|
|
497
|
+
* ABIs leave items in raw form.
|
|
498
|
+
*/
|
|
499
|
+
declare const describeShareMetadata: (share: LabelledShare, abis?: ShareLabelAbis) => ShareLabelDescription[] | null;
|
|
500
|
+
|
|
501
|
+
/**
|
|
502
|
+
* Builders for labels. The format knows nothing about tokens: a balance is the value a view
|
|
503
|
+
* function returned, a transfer amount the value of one event.
|
|
504
|
+
*/
|
|
505
|
+
type ViewFunctionLabelOptions<abi extends Abi, functionName extends ContractFunctionName<abi, 'pure' | 'view'>> = {
|
|
506
|
+
contract: Address;
|
|
507
|
+
abi: abi;
|
|
508
|
+
functionName: functionName;
|
|
509
|
+
/**
|
|
510
|
+
* The arguments of the call, static ABI types only. One equal to the share issuer's address
|
|
511
|
+
* (your own, when you share your balance) is stored as "the issuer" when the labels are encoded.
|
|
512
|
+
*/
|
|
513
|
+
args?: ContractFunctionArgs<abi, 'pure' | 'view', functionName>;
|
|
514
|
+
/** Block the value was read at (on Arbitrum: the L2 block number). */
|
|
515
|
+
block: bigint;
|
|
516
|
+
/** Which 32-byte word of the return data is the ctHash; 0 (the default) for a single return value. */
|
|
517
|
+
returnWord?: number;
|
|
518
|
+
};
|
|
519
|
+
/**
|
|
520
|
+
* The label of a value a view function returned at a block, built from the contract's ABI: the
|
|
521
|
+
* function's selector, and each argument ABI-encoded to its word. Throws when the ABI has no such
|
|
522
|
+
* function, the arity is off, or an argument is not one static word.
|
|
523
|
+
*/
|
|
524
|
+
declare const viewFunctionLabel: <const abi extends Abi, functionName extends ContractFunctionName<abi, "pure" | "view">>(options: ViewFunctionLabelOptions<abi, functionName>) => StoredValueLabel;
|
|
525
|
+
/**
|
|
526
|
+
* The label of a value carried by a log, as viem returns it from `getLogs` / `getContractEvents`:
|
|
527
|
+
* its contract, block, transaction and log index, and its event selector. Throws for a pending log.
|
|
528
|
+
*/
|
|
529
|
+
declare const eventLogLabel: (log: Pick<Log, "address" | "blockNumber" | "transactionIndex" | "logIndex" | "topics">) => EventValueLabel;
|
|
530
|
+
/** The label of a ctHash the issuer chooses not to describe. */
|
|
531
|
+
declare const UNLABELLED: ShareLabel;
|
|
532
|
+
|
|
533
|
+
/**
|
|
534
|
+
* The parts of ERC-7984 (confidential tokens) that share labels most often point at: the balance
|
|
535
|
+
* read and the transfer event. One definition for the SDK's label presets and for apps, with
|
|
536
|
+
* `internalType` kept so `@cofhe/abi` recognises the encrypted values.
|
|
537
|
+
*/
|
|
538
|
+
declare const ERC7984_ABI: readonly [{
|
|
539
|
+
readonly type: "function";
|
|
540
|
+
readonly name: "confidentialBalanceOf";
|
|
541
|
+
readonly stateMutability: "view";
|
|
542
|
+
readonly inputs: readonly [{
|
|
543
|
+
readonly name: "account";
|
|
544
|
+
readonly type: "address";
|
|
545
|
+
readonly internalType: "address";
|
|
546
|
+
}];
|
|
547
|
+
readonly outputs: readonly [{
|
|
548
|
+
readonly name: "";
|
|
549
|
+
readonly type: "bytes32";
|
|
550
|
+
readonly internalType: "euint64";
|
|
551
|
+
}];
|
|
552
|
+
}, {
|
|
553
|
+
readonly type: "event";
|
|
554
|
+
readonly name: "ConfidentialTransfer";
|
|
555
|
+
readonly anonymous: false;
|
|
556
|
+
readonly inputs: readonly [{
|
|
557
|
+
readonly name: "from";
|
|
558
|
+
readonly type: "address";
|
|
559
|
+
readonly indexed: true;
|
|
560
|
+
readonly internalType: "address";
|
|
561
|
+
}, {
|
|
562
|
+
readonly name: "to";
|
|
563
|
+
readonly type: "address";
|
|
564
|
+
readonly indexed: true;
|
|
565
|
+
readonly internalType: "address";
|
|
566
|
+
}, {
|
|
567
|
+
readonly name: "amount";
|
|
568
|
+
readonly type: "bytes32";
|
|
569
|
+
readonly indexed: true;
|
|
570
|
+
readonly internalType: "euint64";
|
|
571
|
+
}];
|
|
572
|
+
}];
|
|
573
|
+
|
|
574
|
+
/**
|
|
575
|
+
* The key an app marks its shares with: keccak256 of its name, e.g. `shareAppKey('explorer.fhenix.io')`.
|
|
576
|
+
* A client configured with `acp: { app }` puts it on every share it creates and lists only the
|
|
577
|
+
* shares that carry it; the name itself is never on-chain.
|
|
578
|
+
*/
|
|
579
|
+
declare const shareAppKey: (app: string) => Hex;
|
|
254
580
|
|
|
255
581
|
declare const addressSchema: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
|
|
256
582
|
declare const addressNotZeroSchema: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
|
|
@@ -325,6 +651,7 @@ declare const SelfACPValidator: z.ZodObject<{
|
|
|
325
651
|
handles: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodType<`0x${string}`, unknown, z.core.$ZodTypeInternals<`0x${string}`, unknown>>>>>;
|
|
326
652
|
issuerSignature: z.ZodDefault<z.ZodOptional<z.ZodCustom<`0x${string}`, `0x${string}`>>>;
|
|
327
653
|
recipientSignature: z.ZodDefault<z.ZodOptional<z.ZodCustom<`0x${string}`, `0x${string}`>>>;
|
|
654
|
+
metadata: z.ZodOptional<z.ZodCustom<`0x${string}`, `0x${string}`>>;
|
|
328
655
|
sealingPrivateKey: z.ZodOptional<z.ZodString>;
|
|
329
656
|
sealingKey: z.ZodOptional<z.ZodString>;
|
|
330
657
|
}, z.core.$strip>;
|
|
@@ -393,6 +720,7 @@ declare const SharingACPValidator: z.ZodObject<{
|
|
|
393
720
|
handles: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodType<`0x${string}`, unknown, z.core.$ZodTypeInternals<`0x${string}`, unknown>>>>>;
|
|
394
721
|
issuerSignature: z.ZodDefault<z.ZodOptional<z.ZodCustom<`0x${string}`, `0x${string}`>>>;
|
|
395
722
|
recipientSignature: z.ZodDefault<z.ZodOptional<z.ZodCustom<`0x${string}`, `0x${string}`>>>;
|
|
723
|
+
metadata: z.ZodOptional<z.ZodCustom<`0x${string}`, `0x${string}`>>;
|
|
396
724
|
sealingPrivateKey: z.ZodOptional<z.ZodString>;
|
|
397
725
|
sealingKey: z.ZodOptional<z.ZodString>;
|
|
398
726
|
}, z.core.$strip>;
|
|
@@ -403,7 +731,6 @@ declare const ImportACPOptionsValidator: z.ZodPipe<z.ZodObject<{
|
|
|
403
731
|
type: z.ZodDefault<z.ZodOptional<z.ZodLiteral<"recipient">>>;
|
|
404
732
|
issuer: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
|
|
405
733
|
recipient: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
|
|
406
|
-
name: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
407
734
|
expiration: z.ZodInt;
|
|
408
735
|
revokerData: z.ZodDefault<z.ZodOptional<z.ZodInt>>;
|
|
409
736
|
revokerContract: z.ZodDefault<z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>>>;
|
|
@@ -412,11 +739,11 @@ declare const ImportACPOptionsValidator: z.ZodPipe<z.ZodObject<{
|
|
|
412
739
|
handles: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodType<`0x${string}`, unknown, z.core.$ZodTypeInternals<`0x${string}`, unknown>>>>>;
|
|
413
740
|
issuerSignature: z.ZodCustom<`0x${string}`, `0x${string}`>;
|
|
414
741
|
recipientSignature: z.ZodDefault<z.ZodOptional<z.ZodCustom<`0x${string}`, `0x${string}`>>>;
|
|
742
|
+
metadata: z.ZodPipe<z.ZodOptional<z.ZodCustom<`0x${string}`, `0x${string}`>>, z.ZodTransform<`0x${string}` | undefined, `0x${string}` | undefined>>;
|
|
415
743
|
}, z.core.$strip>, z.ZodTransform<{
|
|
416
744
|
type: "recipient";
|
|
417
745
|
issuer: `0x${string}`;
|
|
418
746
|
recipient: `0x${string}`;
|
|
419
|
-
name: string;
|
|
420
747
|
expiration: number;
|
|
421
748
|
revokerData: number;
|
|
422
749
|
revokerContract: `0x${string}`;
|
|
@@ -424,6 +751,7 @@ declare const ImportACPOptionsValidator: z.ZodPipe<z.ZodObject<{
|
|
|
424
751
|
handles: `0x${string}`[];
|
|
425
752
|
issuerSignature: `0x${string}`;
|
|
426
753
|
recipientSignature: `0x${string}`;
|
|
754
|
+
metadata: `0x${string}` | undefined;
|
|
427
755
|
scope?: number | undefined;
|
|
428
756
|
} & {
|
|
429
757
|
scope: number;
|
|
@@ -431,7 +759,6 @@ declare const ImportACPOptionsValidator: z.ZodPipe<z.ZodObject<{
|
|
|
431
759
|
type: "recipient";
|
|
432
760
|
issuer: `0x${string}`;
|
|
433
761
|
recipient: `0x${string}`;
|
|
434
|
-
name: string;
|
|
435
762
|
expiration: number;
|
|
436
763
|
revokerData: number;
|
|
437
764
|
revokerContract: `0x${string}`;
|
|
@@ -439,6 +766,7 @@ declare const ImportACPOptionsValidator: z.ZodPipe<z.ZodObject<{
|
|
|
439
766
|
handles: `0x${string}`[];
|
|
440
767
|
issuerSignature: `0x${string}`;
|
|
441
768
|
recipientSignature: `0x${string}`;
|
|
769
|
+
metadata: `0x${string}` | undefined;
|
|
442
770
|
scope?: number | undefined;
|
|
443
771
|
}>>;
|
|
444
772
|
/**
|
|
@@ -461,6 +789,7 @@ declare const ImportACPValidator: z.ZodObject<{
|
|
|
461
789
|
handles: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodType<`0x${string}`, unknown, z.core.$ZodTypeInternals<`0x${string}`, unknown>>>>>;
|
|
462
790
|
issuerSignature: z.ZodDefault<z.ZodOptional<z.ZodCustom<`0x${string}`, `0x${string}`>>>;
|
|
463
791
|
recipientSignature: z.ZodDefault<z.ZodOptional<z.ZodCustom<`0x${string}`, `0x${string}`>>>;
|
|
792
|
+
metadata: z.ZodOptional<z.ZodCustom<`0x${string}`, `0x${string}`>>;
|
|
464
793
|
sealingPrivateKey: z.ZodOptional<z.ZodString>;
|
|
465
794
|
sealingKey: z.ZodOptional<z.ZodString>;
|
|
466
795
|
}, z.core.$strip>;
|
|
@@ -509,7 +838,6 @@ declare const validateImportACPOptions: (options: any) => {
|
|
|
509
838
|
type: "recipient";
|
|
510
839
|
issuer: `0x${string}`;
|
|
511
840
|
recipient: `0x${string}`;
|
|
512
|
-
name: string;
|
|
513
841
|
expiration: number;
|
|
514
842
|
revokerData: number;
|
|
515
843
|
revokerContract: `0x${string}`;
|
|
@@ -517,6 +845,7 @@ declare const validateImportACPOptions: (options: any) => {
|
|
|
517
845
|
handles: `0x${string}`[];
|
|
518
846
|
issuerSignature: `0x${string}`;
|
|
519
847
|
recipientSignature: `0x${string}`;
|
|
848
|
+
metadata: `0x${string}` | undefined;
|
|
520
849
|
scope?: number | undefined;
|
|
521
850
|
} & {
|
|
522
851
|
scope: number;
|
|
@@ -537,6 +866,7 @@ declare const validateSelfACP: (acp: any) => {
|
|
|
537
866
|
handles: `0x${string}`[];
|
|
538
867
|
issuerSignature: `0x${string}`;
|
|
539
868
|
recipientSignature: `0x${string}`;
|
|
869
|
+
metadata?: `0x${string}` | undefined;
|
|
540
870
|
sealingPrivateKey?: string | undefined;
|
|
541
871
|
sealingKey?: string | undefined;
|
|
542
872
|
};
|
|
@@ -556,6 +886,7 @@ declare const validateSharingACP: (acp: any) => {
|
|
|
556
886
|
handles: `0x${string}`[];
|
|
557
887
|
issuerSignature: `0x${string}`;
|
|
558
888
|
recipientSignature: `0x${string}`;
|
|
889
|
+
metadata?: `0x${string}` | undefined;
|
|
559
890
|
sealingPrivateKey?: string | undefined;
|
|
560
891
|
sealingKey?: string | undefined;
|
|
561
892
|
};
|
|
@@ -575,6 +906,7 @@ declare const validateImportACP: (acp: any) => {
|
|
|
575
906
|
handles: `0x${string}`[];
|
|
576
907
|
issuerSignature: `0x${string}`;
|
|
577
908
|
recipientSignature: `0x${string}`;
|
|
909
|
+
metadata?: `0x${string}` | undefined;
|
|
578
910
|
sealingPrivateKey?: string | undefined;
|
|
579
911
|
sealingKey?: string | undefined;
|
|
580
912
|
};
|
|
@@ -638,8 +970,8 @@ declare const ACPSignatureAllFields: readonly [{
|
|
|
638
970
|
}];
|
|
639
971
|
type ACPSignatureFieldOption = (typeof ACPSignatureAllFields)[number]['name'];
|
|
640
972
|
declare const SignatureTypes: {
|
|
641
|
-
readonly ACPIssuerSelf: ("
|
|
642
|
-
readonly ACPIssuerShared: ("
|
|
973
|
+
readonly ACPIssuerSelf: ("issuer" | "recipient" | "expiration" | "revokerData" | "revokerContract" | "scope" | "contracts" | "handles" | "sealingKey")[];
|
|
974
|
+
readonly ACPIssuerShared: ("issuer" | "recipient" | "expiration" | "revokerData" | "revokerContract" | "scope" | "contracts" | "handles")[];
|
|
643
975
|
readonly ACPRecipient: ("sealingKey" | "issuerSignature")[];
|
|
644
976
|
};
|
|
645
977
|
/**
|
|
@@ -724,4 +1056,4 @@ declare const acpStore: {
|
|
|
724
1056
|
resetStore: () => void;
|
|
725
1057
|
};
|
|
726
1058
|
|
|
727
|
-
export { ACP, ACPPublic, ACPSignaturePrimaryType, ACP_REVOKER_ABI, ACP_SHARE_REGISTRY_ABI, ACP_SHARE_TUPLE_ABI, ACP_STORE_DEFAULTS, EIP712Message, EIP712Types, ImportACPOptionsValidator, ImportACPValidator, SelfACPOptionsValidator, SelfACPValidator, SerializedACP, SharingACPOptionsValidator, SharingACPValidator, SignatureTypes, SignatureUtils, ValidationResult, ValidationUtils, _acpStore, acpStore, addressNotZeroSchema, addressSchema, bytesNotEmptySchema, bytesSchema, clearStaleStore, computeShareId, contractsSchema, getACP, getACPs, getActiveACP, getActiveACPHash, getSignatureTypesAndMessage, handlesSchema, removeACP, removeActiveACPHash, resetStore, setACP, setActiveACPHash, shareIdOfChainShare, toChainShare, validateImportACP, validateImportACPOptions, validateSelfACP, validateSelfACPOptions, validateSharingACP, validateSharingACPOptions };
|
|
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 };
|
package/dist/acps.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { ACPScope, ACPUtils, ACP_REVOKER_ABI, ACP_SHARE_REGISTRY_ABI, ACP_SHARE_TUPLE_ABI, ACP_STORE_DEFAULTS, GenerateSealingKey, ImportACPOptionsValidator, ImportACPValidator, SelfACPOptionsValidator, SelfACPValidator, SharingACPOptionsValidator, SharingACPValidator, SignatureTypes, SignatureUtils, ValidationUtils, _acpStore, acpStore, addressNotZeroSchema, addressSchema, bytesNotEmptySchema, bytesSchema, clearAclServedAddresses, clearStaleStore, computeShareId, contractsSchema, getACP, getACPs, getAclAddress, getAclServedAddresses, getActiveACP, getActiveACPHash, getSignatureTypesAndMessage, handlesSchema, removeACP, removeActiveACPHash, resetStore, seal, setACP, setActiveACPHash, shareIdOfChainShare, toChainShare, unsealWithPrivateKey, validateImportACP, validateImportACPOptions, validateSelfACP, validateSelfACPOptions, validateSharingACP, validateSharingACPOptions } from './chunk-
|
|
2
|
-
import './chunk-
|
|
1
|
+
export { ACPScope, ACPUtils, ACP_REVOKER_ABI, ACP_SHARE_REGISTRY_ABI, ACP_SHARE_TUPLE_ABI, ACP_STORE_DEFAULTS, ERC7984_ABI, GenerateSealingKey, ImportACPOptionsValidator, ImportACPValidator, LAYOUT_VERSION as SHARE_METADATA_VERSION, SelfACPOptionsValidator, SelfACPValidator, SharingACPOptionsValidator, SharingACPValidator, SignatureTypes, SignatureUtils, UNLABELLED, ValidationUtils, _acpStore, acpStore, addressNotZeroSchema, addressSchema, bytesNotEmptySchema, bytesSchema, clearAclServedAddresses, clearStaleStore, computeShareId, contractsSchema, decodeShareAppKey, decodeShareMetadata, decodeShareMetadataFull, describeShareLabels, describeShareMetadata, encodeShareMetadata, eventLogLabel, getACP, getACPs, getAclAddress, getAclServedAddresses, getActiveACP, getActiveACPHash, getSignatureTypesAndMessage, handlesSchema, readPostedShares, readShare, readSharesFor, removeACP, removeActiveACPHash, resetStore, seal, setACP, setActiveACPHash, shareAppKey, shareIdOfChainShare, toChainShare, unsealWithPrivateKey, validateImportACP, validateImportACPOptions, validateSelfACP, validateSelfACPOptions, validateSharingACP, validateSharingACPOptions, verifyShareLabel, verifyShareLabels, viewFunctionLabel } from './chunk-3L2IVPMI.js';
|
|
2
|
+
import './chunk-J23FYAI2.js';
|