@cofhe/sdk 1.0.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/core/acps.ts +64 -23
- package/core/client.ts +32 -1
- package/core/clientTypes.ts +22 -1
- package/core/test/acpsPrepare.test.ts +77 -0
- package/dist/acps.d.cts +4 -358
- package/dist/acps.d.ts +4 -358
- package/dist/{chunk-O2ITEUEU.js → chunk-2EO4JSR7.js} +63 -21
- package/dist/{clientTypes-b1pOxOUE.d.ts → clientTypes-CnslFzxB.d.ts} +38 -2
- package/dist/{clientTypes-IO6b5Um8.d.cts → clientTypes-RXwLVWou.d.cts} +38 -2
- package/dist/core.cjs +62 -20
- package/dist/core.d.cts +3 -3
- package/dist/core.d.ts +3 -3
- package/dist/core.js +1 -1
- package/dist/node.cjs +62 -20
- package/dist/node.d.cts +2 -2
- package/dist/node.d.ts +2 -2
- package/dist/node.js +1 -1
- package/dist/{onchain-utils-CgOslubH.d.ts → onchain-utils-Ns56cBm0.d.cts} +356 -2
- package/dist/{onchain-utils-CgOslubH.d.cts → onchain-utils-Ns56cBm0.d.ts} +356 -2
- package/dist/web.cjs +62 -20
- package/dist/web.d.cts +2 -2
- package/dist/web.d.ts +2 -2
- package/dist/web.js +1 -1
- package/package.json +3 -3
package/dist/acps.d.ts
CHANGED
|
@@ -1,364 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export {
|
|
3
|
-
import {
|
|
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.js';
|
|
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.js';
|
|
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,
|
|
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 };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { hardhat as hardhat$1 } from './chunk-UKQAJK4N.js';
|
|
2
|
-
import { acpStore, clearAclServedAddresses, getAclServedAddresses, computeShareId, ACPUtils, getTaskManagerAddress, verifyShareLabels, decodeShareMetadata, shareAppKey,
|
|
2
|
+
import { acpStore, clearAclServedAddresses, getAclServedAddresses, computeShareId, ACP_SHARE_REGISTRY_ABI, ACPUtils, getTaskManagerAddress, verifyShareLabels, decodeShareMetadata, shareAppKey, readShare, readSharesFor, toChainShare, ACP_REVOKER_ABI, decodeShareAppKey, encodeShareMetadata } from './chunk-3L2IVPMI.js';
|
|
3
3
|
import { sleep, getPublicClientChainID, getWalletClientAccount, validateBigIntInRange, toBigIntOrThrow, hexToBytes, toHexString, FheUintUTypes } from './chunk-WJGTPW7K.js';
|
|
4
4
|
import { TFHE_RS_KEY_VERSION, CofheError, TFHE_RS_ZK_MAX_BITS, TFHE_RS_SAFE_SERIALIZATION_SIZE_LIMIT, MOCKS_THRESHOLD_NETWORK_ADDRESS, MOCKS_DECRYPT_RESULT_SIGNER_PRIVATE_KEY, MOCKS_ZK_VERIFIER_SIGNER_PRIVATE_KEY, MOCKS_ZK_VERIFIER_ADDRESS } from './chunk-J23FYAI2.js';
|
|
5
5
|
import { createStore } from 'zustand/vanilla';
|
|
@@ -1409,23 +1409,25 @@ var getBlockRevokerData = async (publicClient) => {
|
|
|
1409
1409
|
}
|
|
1410
1410
|
return revokerData;
|
|
1411
1411
|
};
|
|
1412
|
-
var
|
|
1412
|
+
var prepareRevokeACP = (acp) => {
|
|
1413
1413
|
if (acp.revokerContract === zeroAddress || acp.revokerData === 0) {
|
|
1414
1414
|
throw new Error("ACP is not revocable: it has no revoker (revokerContract/revokerData unset)");
|
|
1415
1415
|
}
|
|
1416
|
+
return {
|
|
1417
|
+
address: acp.revokerContract,
|
|
1418
|
+
abi: ACP_REVOKER_ABI,
|
|
1419
|
+
functionName: "revokeSingle",
|
|
1420
|
+
args: [BigInt(acp.revokerData)]
|
|
1421
|
+
};
|
|
1422
|
+
};
|
|
1423
|
+
var revokeACP = async (acp, walletClient) => {
|
|
1424
|
+
const write = prepareRevokeACP(acp);
|
|
1416
1425
|
if (walletClient.account == null)
|
|
1417
1426
|
throw new Error("Missing walletClient account");
|
|
1418
1427
|
if (walletClient.account.address.toLowerCase() !== acp.issuer.toLowerCase()) {
|
|
1419
1428
|
throw new Error("Only the acp issuer can revoke it");
|
|
1420
1429
|
}
|
|
1421
|
-
return walletClient.writeContract({
|
|
1422
|
-
address: acp.revokerContract,
|
|
1423
|
-
abi: ACP_REVOKER_ABI,
|
|
1424
|
-
functionName: "revokeSingle",
|
|
1425
|
-
args: [BigInt(acp.revokerData)],
|
|
1426
|
-
account: walletClient.account,
|
|
1427
|
-
chain: walletClient.chain
|
|
1428
|
-
});
|
|
1430
|
+
return walletClient.writeContract({ ...write, account: walletClient.account, chain: walletClient.chain });
|
|
1429
1431
|
};
|
|
1430
1432
|
var revokeAllACPs = async (walletClient, publicClient, revokerContract) => {
|
|
1431
1433
|
if (walletClient.account == null)
|
|
@@ -1476,28 +1478,36 @@ var metadataOf = (acp, { labels, metadata, appKey }) => {
|
|
|
1476
1478
|
}
|
|
1477
1479
|
return encodeShareMetadata(labels, { issuer: acp.issuer, appKey });
|
|
1478
1480
|
};
|
|
1479
|
-
var
|
|
1481
|
+
var prepareShareOnChain = (acp, registry, options = {}) => {
|
|
1480
1482
|
if (acp.type !== "sharing") {
|
|
1481
1483
|
throw new Error(`Cannot share a '${acp.type}' ACP on-chain \u2014 only 'sharing' ACPs are shareable.`);
|
|
1482
1484
|
}
|
|
1483
1485
|
if (acp.issuerSignature === "0x") {
|
|
1484
1486
|
throw new Error("Cannot share an unsigned sharing ACP \u2014 sign it first.");
|
|
1485
1487
|
}
|
|
1488
|
+
return {
|
|
1489
|
+
write: {
|
|
1490
|
+
address: registry,
|
|
1491
|
+
abi: ACP_SHARE_REGISTRY_ABI,
|
|
1492
|
+
functionName: "share",
|
|
1493
|
+
args: [toChainShare(acp), metadataOf(acp, options)]
|
|
1494
|
+
},
|
|
1495
|
+
shareId: computeShareId(acp)
|
|
1496
|
+
};
|
|
1497
|
+
};
|
|
1498
|
+
var shareOnChain = async (acp, walletClient, registry, options = {}) => {
|
|
1499
|
+
const { write, shareId } = prepareShareOnChain(acp, registry, options);
|
|
1486
1500
|
if (walletClient.account == null)
|
|
1487
1501
|
throw new Error("Missing walletClient account");
|
|
1488
1502
|
if (walletClient.account.address.toLowerCase() !== acp.issuer.toLowerCase()) {
|
|
1489
1503
|
throw new Error("Only the ACP issuer can share it on-chain");
|
|
1490
1504
|
}
|
|
1491
|
-
const metadata = metadataOf(acp, options);
|
|
1492
1505
|
const txHash = await walletClient.writeContract({
|
|
1493
|
-
|
|
1494
|
-
abi: ACP_SHARE_REGISTRY_ABI,
|
|
1495
|
-
functionName: "share",
|
|
1496
|
-
args: [toChainShare(acp), metadata],
|
|
1506
|
+
...write,
|
|
1497
1507
|
account: walletClient.account,
|
|
1498
1508
|
chain: walletClient.chain ?? null
|
|
1499
1509
|
});
|
|
1500
|
-
return { txHash, shareId
|
|
1510
|
+
return { txHash, shareId };
|
|
1501
1511
|
};
|
|
1502
1512
|
var toIncomingShare = ({ shareId, share: s, metadata }) => ({
|
|
1503
1513
|
shareId,
|
|
@@ -1532,14 +1542,17 @@ var importFromChain = async (share, publicClient, walletClient, importOptions =
|
|
|
1532
1542
|
const { shareId: _shareId, appKey: _appKey, ...options } = share;
|
|
1533
1543
|
return importShared({ ...options, type: "sharing" }, publicClient, walletClient, importOptions);
|
|
1534
1544
|
};
|
|
1545
|
+
var prepareRemoveShare = (shareId, registry) => ({
|
|
1546
|
+
address: registry,
|
|
1547
|
+
abi: ACP_SHARE_REGISTRY_ABI,
|
|
1548
|
+
functionName: "removeShare",
|
|
1549
|
+
args: [shareId]
|
|
1550
|
+
});
|
|
1535
1551
|
var removeShareOnChain = async (shareId, walletClient, registry) => {
|
|
1536
1552
|
if (walletClient.account == null)
|
|
1537
1553
|
throw new Error("Missing walletClient account");
|
|
1538
1554
|
return walletClient.writeContract({
|
|
1539
|
-
|
|
1540
|
-
abi: ACP_SHARE_REGISTRY_ABI,
|
|
1541
|
-
functionName: "removeShare",
|
|
1542
|
-
args: [shareId],
|
|
1555
|
+
...prepareRemoveShare(shareId, registry),
|
|
1543
1556
|
account: walletClient.account,
|
|
1544
1557
|
chain: walletClient.chain ?? null
|
|
1545
1558
|
});
|
|
@@ -1566,14 +1579,17 @@ var acps = {
|
|
|
1566
1579
|
selectActiveACP,
|
|
1567
1580
|
removeActiveACP,
|
|
1568
1581
|
revokeACP,
|
|
1582
|
+
prepareRevokeACP,
|
|
1569
1583
|
revokeAllACPs,
|
|
1570
1584
|
isACPRevoked,
|
|
1571
1585
|
checkAccess,
|
|
1572
1586
|
shareOnChain,
|
|
1587
|
+
prepareShareOnChain,
|
|
1573
1588
|
getIncomingShares,
|
|
1574
1589
|
getShareFromChain,
|
|
1575
1590
|
importFromChain,
|
|
1576
1591
|
removeShareOnChain,
|
|
1592
|
+
prepareRemoveShare,
|
|
1577
1593
|
computeShareId,
|
|
1578
1594
|
applyACPDefaultsFromChain,
|
|
1579
1595
|
getAclServedAddresses,
|
|
@@ -3356,6 +3372,12 @@ function createCofheClientBase(opts) {
|
|
|
3356
3372
|
});
|
|
3357
3373
|
}
|
|
3358
3374
|
};
|
|
3375
|
+
const _requireIssuer = (acp, what) => {
|
|
3376
|
+
const sender = connectStore.getState().walletClient?.account?.address;
|
|
3377
|
+
if (sender == null || sender.toLowerCase() !== acp.issuer.toLowerCase()) {
|
|
3378
|
+
throw new Error(`Only the acp issuer can ${what}`);
|
|
3379
|
+
}
|
|
3380
|
+
};
|
|
3359
3381
|
async function connect(publicClient, walletClient) {
|
|
3360
3382
|
const state = connectStore.getState();
|
|
3361
3383
|
if (state.connected && state.publicClient === publicClient && state.walletClient === walletClient)
|
|
@@ -3523,6 +3545,11 @@ function createCofheClientBase(opts) {
|
|
|
3523
3545
|
const { walletClient } = connectStore.getState();
|
|
3524
3546
|
return acps.revokeACP(acp, walletClient);
|
|
3525
3547
|
},
|
|
3548
|
+
prepareRevokeACP: (acp) => {
|
|
3549
|
+
_requireConnected();
|
|
3550
|
+
_requireIssuer(acp, "revoke it");
|
|
3551
|
+
return acps.prepareRevokeACP(acp);
|
|
3552
|
+
},
|
|
3526
3553
|
revokeAllACPs: async (revokerContract) => {
|
|
3527
3554
|
_requireConnected();
|
|
3528
3555
|
const { publicClient, walletClient } = connectStore.getState();
|
|
@@ -3546,6 +3573,21 @@ function createCofheClientBase(opts) {
|
|
|
3546
3573
|
const sharingRegistry = await _resolveSharingRegistry(publicClient, chainId);
|
|
3547
3574
|
return acps.shareOnChain(acp, walletClient, sharingRegistry, { ...withAppKey(), ...options });
|
|
3548
3575
|
},
|
|
3576
|
+
prepareShareOnChain: async (acp, options) => {
|
|
3577
|
+
_requireConnected();
|
|
3578
|
+
_requireIssuer(acp, "share it on-chain");
|
|
3579
|
+
const { publicClient } = connectStore.getState();
|
|
3580
|
+
const chainId = await publicClient.getChainId();
|
|
3581
|
+
const sharingRegistry = await _resolveSharingRegistry(publicClient, chainId);
|
|
3582
|
+
return acps.prepareShareOnChain(acp, sharingRegistry, { ...withAppKey(), ...options });
|
|
3583
|
+
},
|
|
3584
|
+
prepareRemoveShare: async (shareId) => {
|
|
3585
|
+
_requireConnected();
|
|
3586
|
+
const { publicClient } = connectStore.getState();
|
|
3587
|
+
const chainId = await publicClient.getChainId();
|
|
3588
|
+
const sharingRegistry = await _resolveSharingRegistry(publicClient, chainId);
|
|
3589
|
+
return acps.prepareRemoveShare(shareId, sharingRegistry);
|
|
3590
|
+
},
|
|
3549
3591
|
getIncomingShares: async () => {
|
|
3550
3592
|
_requireConnected();
|
|
3551
3593
|
const { publicClient, walletClient } = connectStore.getState();
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { WalletClient, PublicClient, Hex } from 'viem';
|
|
1
|
+
import { WalletClient, PublicClient, Hex, ContractFunctionParameters } from 'viem';
|
|
2
2
|
import { C as CofheChain } from './types-C07FK-cL.js';
|
|
3
3
|
import { z } from 'zod';
|
|
4
|
-
import { A as ACP, k as EIP712Domain, C as CreateSelfACPOptions,
|
|
4
|
+
import { A as ACP, k as EIP712Domain, C as CreateSelfACPOptions, $ as SelfACP, g as CreateSharingACPOptions, a0 as SharingACP, I as ImportSharedACPOptions, a1 as RecipientACP, a5 as ACPHashFields, f as SerializedACP, t as ACP_REVOKER_ABI, a4 as ACPAccessStatus, S as ShareLabel, v as ACP_SHARE_REGISTRY_ABI, j as IncomingShare, p as AclServedAddresses, L as LabelledShare, Q as ShareLabelVerifyMode, R as ShareLabelCheck, l as ACPUtils } from './onchain-utils-Ns56cBm0.js';
|
|
5
5
|
import { StoreApi } from 'zustand/vanilla';
|
|
6
6
|
|
|
7
7
|
type TfheInitializer = () => Promise<boolean>;
|
|
@@ -1031,6 +1031,21 @@ type ImportSharedOptions = ImportActivationOptions & {
|
|
|
1031
1031
|
*/
|
|
1032
1032
|
name?: string;
|
|
1033
1033
|
};
|
|
1034
|
+
/**
|
|
1035
|
+
* Revoke a single acp on-chain via its revoker contract.
|
|
1036
|
+
* Only the acp's issuer can revoke it (enforced by the revoker: revocations
|
|
1037
|
+
* are keyed by msg.sender). The acp stays in local storage — on-chain
|
|
1038
|
+
* validation will reject it from the next block onwards.
|
|
1039
|
+
*
|
|
1040
|
+
* @returns the revocation transaction hash
|
|
1041
|
+
*/
|
|
1042
|
+
/**
|
|
1043
|
+
* A registry or revoker write built but not sent: what a simulation or `writeContract` takes,
|
|
1044
|
+
* minus the sender. For a caller that sends through its own path (simulate first, record the
|
|
1045
|
+
* transaction) instead of the plain `writeContract` the senders below do.
|
|
1046
|
+
*/
|
|
1047
|
+
type ShareRegistryWrite<functionName extends 'share' | 'removeShare'> = ContractFunctionParameters<typeof ACP_SHARE_REGISTRY_ABI, 'nonpayable', functionName>;
|
|
1048
|
+
type RevokerWrite = ContractFunctionParameters<typeof ACP_REVOKER_ABI, 'nonpayable', 'revokeSingle'>;
|
|
1034
1049
|
/**
|
|
1035
1050
|
* What `shareOnChain` posts with a share: the labels of its handles (one per handle, in order;
|
|
1036
1051
|
* encoded with `encodeShareMetadata`), or an already encoded metadata blob. Written once, with the
|
|
@@ -1191,6 +1206,7 @@ declare const acps: {
|
|
|
1191
1206
|
selectActiveACP: (chainId: number, account: string, hash: string) => void;
|
|
1192
1207
|
removeActiveACP: (chainId: number, account: string) => Promise<void>;
|
|
1193
1208
|
revokeACP: (acp: ACP, walletClient: WalletClient) => Promise<Hex>;
|
|
1209
|
+
prepareRevokeACP: (acp: ACP) => RevokerWrite;
|
|
1194
1210
|
revokeAllACPs: (walletClient: WalletClient, publicClient: PublicClient, revokerContract?: Hex) => Promise<Hex>;
|
|
1195
1211
|
isACPRevoked: (acp: ACP, publicClient: PublicClient) => Promise<boolean>;
|
|
1196
1212
|
checkAccess: (acp: ACP, publicClient: PublicClient, handle?: bigint | Hex) => Promise<ACPAccessStatus>;
|
|
@@ -1198,12 +1214,17 @@ declare const acps: {
|
|
|
1198
1214
|
txHash: Hex;
|
|
1199
1215
|
shareId: Hex;
|
|
1200
1216
|
}>;
|
|
1217
|
+
prepareShareOnChain: (acp: ACP, registry: Hex, options?: ShareOnChainOptions) => {
|
|
1218
|
+
write: ShareRegistryWrite<"share">;
|
|
1219
|
+
shareId: Hex;
|
|
1220
|
+
};
|
|
1201
1221
|
getIncomingShares: (publicClient: PublicClient, registry: Hex, recipient: Hex, { appKey }?: {
|
|
1202
1222
|
appKey?: Hex;
|
|
1203
1223
|
}) => Promise<IncomingShare[]>;
|
|
1204
1224
|
getShareFromChain: (publicClient: PublicClient, registry: Hex, shareId: Hex) => Promise<IncomingShare | null>;
|
|
1205
1225
|
importFromChain: (share: IncomingShare, publicClient: PublicClient, walletClient: WalletClient, importOptions?: ImportSharedOptions) => Promise<RecipientACP>;
|
|
1206
1226
|
removeShareOnChain: (shareId: Hex, walletClient: WalletClient, registry: Hex) => Promise<Hex>;
|
|
1227
|
+
prepareRemoveShare: (shareId: Hex, registry: Hex) => ShareRegistryWrite<"removeShare">;
|
|
1207
1228
|
computeShareId: (acp: ACP) => Hex;
|
|
1208
1229
|
applyACPDefaultsFromChain: <T extends {
|
|
1209
1230
|
revokerData?: number;
|
|
@@ -1286,6 +1307,11 @@ type CofheClientACPs = {
|
|
|
1286
1307
|
removeACP: (hash: string, chainId?: number, account?: string) => void;
|
|
1287
1308
|
removeActiveACP: (chainId?: number, account?: string) => void;
|
|
1288
1309
|
revokeACP: (acp: ACP) => Promise<`0x${string}`>;
|
|
1310
|
+
/**
|
|
1311
|
+
* The revoker write `revokeACP` sends, built but not sent — for an app that sends through its own
|
|
1312
|
+
* path (a simulation first, a transaction store). Issuer only; throws for an acp without a revoker.
|
|
1313
|
+
*/
|
|
1314
|
+
prepareRevokeACP: (acp: ACP) => RevokerWrite;
|
|
1289
1315
|
revokeAllACPs: (revokerContract?: `0x${string}`) => Promise<`0x${string}`>;
|
|
1290
1316
|
isACPRevoked: (acp: ACP) => Promise<boolean>;
|
|
1291
1317
|
/**
|
|
@@ -1303,6 +1329,16 @@ type CofheClientACPs = {
|
|
|
1303
1329
|
txHash: `0x${string}`;
|
|
1304
1330
|
shareId: `0x${string}`;
|
|
1305
1331
|
}>;
|
|
1332
|
+
/**
|
|
1333
|
+
* The registry write `shareOnChain` sends and the share id it gets, built but not sent — for an
|
|
1334
|
+
* app that sends through its own path (a simulation first, a transaction store). Issuer only.
|
|
1335
|
+
*/
|
|
1336
|
+
prepareShareOnChain: (acp: ACP, options?: ShareOnChainOptions) => Promise<{
|
|
1337
|
+
write: ShareRegistryWrite<'share'>;
|
|
1338
|
+
shareId: `0x${string}`;
|
|
1339
|
+
}>;
|
|
1340
|
+
/** The registry write `dismissShare` / `cancelShare` sends, built but not sent. */
|
|
1341
|
+
prepareRemoveShare: (shareId: `0x${string}`) => Promise<ShareRegistryWrite<'removeShare'>>;
|
|
1306
1342
|
/** Importable shares addressed to the connected account (unexpired, not revoked), with their metadata. */
|
|
1307
1343
|
getIncomingShares: () => Promise<IncomingShare[]>;
|
|
1308
1344
|
/** One share by id, as posted; null when unknown or removed. */
|