@zama-fhe/sdk 3.0.0-alpha.2 → 3.0.0-alpha.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +207 -122
- package/dist/cjs/build.cjs +2 -0
- package/dist/cjs/build.cjs.map +1 -0
- package/dist/cjs/chains/index.cjs +1 -0
- package/dist/cjs/chains.cjs +2 -0
- package/dist/cjs/chains.cjs.map +1 -0
- package/dist/cjs/cleartext/index.cjs +1 -1
- package/dist/cjs/eip1193-subscribe.cjs +1 -1
- package/dist/cjs/eip1193-subscribe.cjs.map +1 -1
- package/dist/cjs/encryption.cjs +2 -0
- package/dist/cjs/encryption.cjs.map +1 -0
- package/dist/cjs/ethers/index.cjs +1 -1
- package/dist/cjs/ethers/index.cjs.map +1 -1
- package/dist/cjs/index.cjs +73 -73
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/query/index.cjs +1 -1
- package/dist/cjs/query/index.cjs.map +1 -1
- package/dist/cjs/readonly-token.cjs +1 -1
- package/dist/cjs/readonly-token.cjs.map +1 -1
- package/dist/cjs/relayer-cleartext.cjs +2 -0
- package/dist/cjs/relayer-cleartext.cjs.map +1 -0
- package/dist/cjs/relayer-sdk.worker.js +71 -71
- package/dist/cjs/relayer.cjs +1 -1
- package/dist/cjs/relayer.cjs.map +1 -1
- package/dist/cjs/viem/index.cjs +1 -1
- package/dist/cjs/viem/index.cjs.map +1 -1
- package/dist/cjs/wrappers-registry.cjs +1 -1
- package/dist/cjs/wrappers-registry.cjs.map +1 -1
- package/dist/esm/{assertions-BARApuMj.js → assertions-CfqI3AJv.js} +1 -1
- package/dist/esm/{assertions-BARApuMj.js.map → assertions-CfqI3AJv.js.map} +1 -1
- package/dist/esm/build-CvenCk6R.js +2 -0
- package/dist/esm/build-CvenCk6R.js.map +1 -0
- package/dist/esm/chains/index.d.ts +3 -0
- package/dist/esm/chains/index.js +1 -0
- package/dist/esm/chains-aHmrozPh.js +2 -0
- package/dist/esm/chains-aHmrozPh.js.map +1 -0
- package/dist/esm/cleartext/index.d.ts +2 -86
- package/dist/esm/cleartext/index.js +1 -1
- package/dist/esm/cleartext-BHu6-LCv.d.ts +19 -0
- package/dist/esm/cleartext-I-etE_7S.js +2 -0
- package/dist/esm/cleartext-I-etE_7S.js.map +1 -0
- package/dist/esm/eip1193-subscribe-CcotSOIm.js +2 -0
- package/dist/esm/eip1193-subscribe-CcotSOIm.js.map +1 -0
- package/dist/esm/{encryption-CmIPBcfP.js → encryption-YS-Kb7qm.js} +2 -2
- package/dist/esm/{encryption-CmIPBcfP.js.map → encryption-YS-Kb7qm.js.map} +1 -1
- package/dist/esm/ethers/index.d.ts +53 -8
- package/dist/esm/ethers/index.js +1 -1
- package/dist/esm/ethers/index.js.map +1 -1
- package/dist/esm/{hex-D_B-zoId.js → hex-BZVTzEK6.js} +2 -2
- package/dist/esm/{hex-D_B-zoId.js.map → hex-BZVTzEK6.js.map} +1 -1
- package/dist/esm/{relayer-utils-iSPis4x-.d.ts → index-BTY0MxOt.d.ts} +50 -23
- package/dist/esm/{onchain-events-2VNiL78c.d.ts → index-BdyljG1F.d.ts} +387 -1505
- package/dist/esm/index.d.ts +61 -93
- package/dist/esm/index.js +73 -73
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/memory-storage-CFXqXUcm.js +2 -0
- package/dist/esm/memory-storage-CFXqXUcm.js.map +1 -0
- package/dist/esm/node/index.d.ts +88 -110
- package/dist/esm/node/index.js +1 -1
- package/dist/esm/node/index.js.map +1 -1
- package/dist/esm/node/relayer-sdk.node-worker.js +1 -1
- package/dist/esm/node/relayer-sdk.node-worker.js.map +1 -1
- package/dist/esm/query/index.d.ts +40 -50
- package/dist/esm/query/index.js +1 -1
- package/dist/esm/query/index.js.map +1 -1
- package/dist/esm/readonly-token-DCLOYhws.js +2 -0
- package/dist/esm/readonly-token-DCLOYhws.js.map +1 -0
- package/dist/esm/{relayer-C6u3eOlN.js → relayer-7Hd00A6X.js} +2 -2
- package/dist/esm/relayer-7Hd00A6X.js.map +1 -0
- package/dist/esm/{relayer-sdk.types-CGfXwKcB.d.ts → relayer-cleartext-DJkSUlZ2.d.ts} +263 -106
- package/dist/esm/relayer-cleartext-SZCM9wTx.js +2 -0
- package/dist/esm/relayer-cleartext-SZCM9wTx.js.map +1 -0
- package/dist/esm/relayer-sdk.worker.js +71 -71
- package/dist/esm/types-C1S426x4.d.ts +48 -0
- package/dist/esm/types-CVyJHEya.d.ts +14 -0
- package/dist/esm/types-DePjTTbo.d.ts +30 -0
- package/dist/esm/types-FY7ciI37.d.ts +615 -0
- package/dist/esm/viem/index.d.ts +39 -11
- package/dist/esm/viem/index.js +1 -1
- package/dist/esm/viem/index.js.map +1 -1
- package/dist/esm/wrappers-registry-CXNs4eR0.js +2 -0
- package/dist/esm/wrappers-registry-CXNs4eR0.js.map +1 -0
- package/package.json +17 -3
- package/dist/cjs/cleartext.cjs +0 -2
- package/dist/cjs/cleartext.cjs.map +0 -1
- package/dist/esm/cleartext-Cs28cTsa.js +0 -2
- package/dist/esm/cleartext-Cs28cTsa.js.map +0 -1
- package/dist/esm/eip1193-subscribe-Cl_wlVuQ.js +0 -2
- package/dist/esm/eip1193-subscribe-Cl_wlVuQ.js.map +0 -1
- package/dist/esm/memory-storage-F8xjMzVy.js +0 -2
- package/dist/esm/memory-storage-F8xjMzVy.js.map +0 -1
- package/dist/esm/readonly-token-D4GjTj0q.js +0 -2
- package/dist/esm/readonly-token-D4GjTj0q.js.map +0 -1
- package/dist/esm/relayer-C6u3eOlN.js.map +0 -1
- package/dist/esm/relayer-sdk-DPqytEbO.d.ts +0 -44
- package/dist/esm/relayer-utils-BeoTNDM4.js +0 -2
- package/dist/esm/relayer-utils-BeoTNDM4.js.map +0 -1
- package/dist/esm/wrappers-registry-ydyySM9g.js +0 -2
- package/dist/esm/wrappers-registry-ydyySM9g.js.map +0 -1
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
(function() {
|
|
2
2
|
//#region src/utils/assertions.ts
|
|
3
|
-
function assertNonNullable(value, context) {
|
|
4
|
-
if (value === null || value === void 0) throw new TypeError(`${context} must not be null or undefined`);
|
|
5
|
-
}
|
|
6
3
|
function assertObject(value, context) {
|
|
7
4
|
if (typeof value !== "object" || value === null || Array.isArray(value)) throw new TypeError(`${context} must be an object, got ${typeof value}`);
|
|
8
5
|
}
|
|
@@ -63,19 +60,46 @@
|
|
|
63
60
|
}
|
|
64
61
|
//#endregion
|
|
65
62
|
//#region src/worker/relayer-sdk.worker.ts
|
|
66
|
-
|
|
63
|
+
const instances = /* @__PURE__ */ new Map();
|
|
64
|
+
const pending = /* @__PURE__ */ new Map();
|
|
65
|
+
const configs = /* @__PURE__ */ new Map();
|
|
66
|
+
/** Convert an FheChain to the FhevmInstanceConfig shape expected by createInstance. */
|
|
67
|
+
function toInstanceConfig(chain) {
|
|
68
|
+
return {
|
|
69
|
+
...chain,
|
|
70
|
+
chainId: chain.id
|
|
71
|
+
};
|
|
72
|
+
}
|
|
67
73
|
let sdkGlobal = null;
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
+
/**
|
|
75
|
+
* Get or lazily create an FhevmInstance for the given chain.
|
|
76
|
+
*/
|
|
77
|
+
async function getInstance(chainId) {
|
|
78
|
+
const existing = instances.get(chainId);
|
|
79
|
+
if (existing) return existing;
|
|
80
|
+
const inflight = pending.get(chainId);
|
|
81
|
+
if (inflight) return inflight;
|
|
82
|
+
const config = configs.get(chainId);
|
|
83
|
+
if (!config) throw new Error(`No config for chain ${chainId}. Available: [${[...configs.keys()].join(", ")}]`);
|
|
84
|
+
if (!sdkGlobal) throw new Error("Relayer SDK is not initialized. Call INIT first.");
|
|
85
|
+
const promise = sdkGlobal.createInstance({
|
|
86
|
+
...toInstanceConfig(config),
|
|
87
|
+
batchRpcCalls: false
|
|
88
|
+
}).then((instance) => {
|
|
89
|
+
instances.set(chainId, instance);
|
|
90
|
+
pending.delete(chainId);
|
|
91
|
+
return instance;
|
|
92
|
+
}).catch((err) => {
|
|
93
|
+
pending.delete(chainId);
|
|
94
|
+
throw err;
|
|
95
|
+
});
|
|
96
|
+
pending.set(chainId, promise);
|
|
97
|
+
return promise;
|
|
74
98
|
}
|
|
75
99
|
function unreachableFheType(_) {
|
|
76
100
|
throw new Error("Unsupported FHE type");
|
|
77
101
|
}
|
|
78
|
-
|
|
102
|
+
const relayerUrls = /* @__PURE__ */ new Set();
|
|
79
103
|
let csrfTokenBase = "";
|
|
80
104
|
const CSRF_HEADER_NAME = "x-csrf-token";
|
|
81
105
|
const MUTATING_METHODS = new Set([
|
|
@@ -85,6 +109,12 @@
|
|
|
85
109
|
"PATCH"
|
|
86
110
|
]);
|
|
87
111
|
/**
|
|
112
|
+
* Register relayer URLs from chain configs for fetch interception.
|
|
113
|
+
*/
|
|
114
|
+
function registerRelayerUrls(chainConfigs) {
|
|
115
|
+
for (const c of chainConfigs) if (c.relayerUrl) relayerUrls.add(c.relayerUrl);
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
88
118
|
* Send a success response back to the main thread.
|
|
89
119
|
* Optionally transfers ArrayBuffers for zero-copy performance.
|
|
90
120
|
*/
|
|
@@ -138,7 +168,7 @@
|
|
|
138
168
|
globalThis.fetch = async (input, init) => {
|
|
139
169
|
const url = typeof input === "string" ? input : input instanceof URL ? input.href : input.url;
|
|
140
170
|
const method = init?.method?.toUpperCase() ?? "GET";
|
|
141
|
-
if (
|
|
171
|
+
if (relayerUrls.size > 0 && [...relayerUrls].some((base) => url.startsWith(base))) {
|
|
142
172
|
const headers = new Headers(init?.headers);
|
|
143
173
|
if (MUTATING_METHODS.has(method) && csrfTokenBase) headers.set(CSRF_HEADER_NAME, csrfTokenBase);
|
|
144
174
|
return originalFetch(input, {
|
|
@@ -193,24 +223,21 @@
|
|
|
193
223
|
}
|
|
194
224
|
}
|
|
195
225
|
/**
|
|
196
|
-
* Handle INIT request - load SDK and
|
|
226
|
+
* Handle INIT request - load SDK WASM and register chain configs (instances are lazy).
|
|
197
227
|
*/
|
|
198
228
|
async function handleInit(request) {
|
|
199
229
|
const { id, type, payload } = request;
|
|
200
|
-
const { cdnUrl, fhevmConfig, csrfToken, integrity, thread } = payload;
|
|
201
230
|
try {
|
|
202
|
-
|
|
231
|
+
if (payload.env !== "web") throw new Error(`Web worker received unexpected env: ${payload.env}`);
|
|
232
|
+
const { cdnUrl, csrfToken, integrity, thread } = payload;
|
|
203
233
|
csrfTokenBase = csrfToken;
|
|
204
234
|
setupFetchInterceptor();
|
|
205
235
|
await loadSdkScript(cdnUrl, integrity);
|
|
206
236
|
if (!self.relayerSDK) throw new Error("Failed to load relayerSDK from CDN");
|
|
207
237
|
sdkGlobal = self.relayerSDK;
|
|
208
238
|
await sdkGlobal.initSDK(thread !== null && thread !== void 0 ? { thread } : void 0);
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
batchRpcCalls: false
|
|
212
|
-
};
|
|
213
|
-
sdkInstance = await sdkGlobal.createInstance(config);
|
|
239
|
+
registerRelayerUrls(payload.chains);
|
|
240
|
+
for (const chain of payload.chains) configs.set(chain.id, chain);
|
|
214
241
|
sendSuccess(id, type, { initialized: true });
|
|
215
242
|
} catch (error) {
|
|
216
243
|
const message = error instanceof Error ? error.message : String(error);
|
|
@@ -262,8 +289,7 @@
|
|
|
262
289
|
const { id, type, payload } = request;
|
|
263
290
|
const { values, contractAddress, userAddress } = payload;
|
|
264
291
|
try {
|
|
265
|
-
|
|
266
|
-
const input = sdkInstance.createEncryptedInput(contractAddress, userAddress);
|
|
292
|
+
const input = (await getInstance(payload.chainId)).createEncryptedInput(contractAddress, userAddress);
|
|
267
293
|
for (const entry of values) addTypedValue(input, entry);
|
|
268
294
|
const encrypted = await input.encrypt();
|
|
269
295
|
sendSuccess(id, type, {
|
|
@@ -282,12 +308,12 @@
|
|
|
282
308
|
async function handleUserDecrypt(request) {
|
|
283
309
|
const { id, type, payload } = request;
|
|
284
310
|
try {
|
|
285
|
-
|
|
311
|
+
const instance = await getInstance(payload.chainId);
|
|
286
312
|
const handleContractPairs = payload.handles.map((handle) => ({
|
|
287
313
|
handle,
|
|
288
314
|
contractAddress: payload.contractAddress
|
|
289
315
|
}));
|
|
290
|
-
sendSuccess(id, type, { clearValues: await
|
|
316
|
+
sendSuccess(id, type, { clearValues: await instance.userDecrypt(handleContractPairs, unprefixHex(payload.privateKey), unprefixHex(payload.publicKey), payload.signature, payload.signedContractAddresses, payload.signerAddress, payload.startTimestamp, payload.durationDays) });
|
|
291
317
|
} catch (error) {
|
|
292
318
|
const message = error instanceof Error ? error.message : String(error);
|
|
293
319
|
const statusCode = extractHttpStatus(error);
|
|
@@ -316,8 +342,7 @@
|
|
|
316
342
|
async function handlePublicDecrypt(request) {
|
|
317
343
|
const { id, type, payload } = request;
|
|
318
344
|
try {
|
|
319
|
-
|
|
320
|
-
sendSuccess(id, type, { ...await sdkInstance.publicDecrypt(payload.handles) });
|
|
345
|
+
sendSuccess(id, type, { ...await (await getInstance(payload.chainId)).publicDecrypt(payload.handles) });
|
|
321
346
|
} catch (error) {
|
|
322
347
|
const message = error instanceof Error ? error.message : String(error);
|
|
323
348
|
console.error("[Worker] PublicDecrypt error:", message);
|
|
@@ -327,11 +352,10 @@
|
|
|
327
352
|
/**
|
|
328
353
|
* Handle GENERATE_KEYPAIR request.
|
|
329
354
|
*/
|
|
330
|
-
function handleGenerateKeypair(request) {
|
|
331
|
-
const { id, type } = request;
|
|
355
|
+
async function handleGenerateKeypair(request) {
|
|
356
|
+
const { id, type, payload } = request;
|
|
332
357
|
try {
|
|
333
|
-
|
|
334
|
-
const keypair = sdkInstance.generateKeypair();
|
|
358
|
+
const keypair = (await getInstance(payload.chainId)).generateKeypair();
|
|
335
359
|
sendSuccess(id, type, {
|
|
336
360
|
publicKey: prefixHex(keypair.publicKey),
|
|
337
361
|
privateKey: prefixHex(keypair.privateKey)
|
|
@@ -345,30 +369,10 @@
|
|
|
345
369
|
/**
|
|
346
370
|
* Handle CREATE_EIP712 request.
|
|
347
371
|
*/
|
|
348
|
-
function handleCreateEIP712(request) {
|
|
372
|
+
async function handleCreateEIP712(request) {
|
|
349
373
|
const { id, type, payload } = request;
|
|
350
374
|
try {
|
|
351
|
-
|
|
352
|
-
const eip712 = sdkInstance.createEIP712(unprefixHex(payload.publicKey), payload.contractAddresses, payload.startTimestamp, payload.durationDays);
|
|
353
|
-
sendSuccess(id, type, {
|
|
354
|
-
domain: {
|
|
355
|
-
name: eip712.domain.name,
|
|
356
|
-
version: eip712.domain.version,
|
|
357
|
-
chainId: Number(eip712.domain.chainId),
|
|
358
|
-
verifyingContract: eip712.domain.verifyingContract
|
|
359
|
-
},
|
|
360
|
-
types: { UserDecryptRequestVerification: eip712.types.UserDecryptRequestVerification.map((field) => ({
|
|
361
|
-
name: field.name,
|
|
362
|
-
type: field.type
|
|
363
|
-
})) },
|
|
364
|
-
message: {
|
|
365
|
-
publicKey: prefixHex(eip712.message.publicKey),
|
|
366
|
-
contractAddresses: [...eip712.message.contractAddresses],
|
|
367
|
-
startTimestamp: BigInt(eip712.message.startTimestamp),
|
|
368
|
-
durationDays: BigInt(eip712.message.durationDays),
|
|
369
|
-
extraData: prefixHex(eip712.message.extraData)
|
|
370
|
-
}
|
|
371
|
-
});
|
|
375
|
+
sendSuccess(id, type, (await getInstance(payload.chainId)).createEIP712(unprefixHex(payload.publicKey), payload.contractAddresses, payload.startTimestamp, payload.durationDays));
|
|
372
376
|
} catch (error) {
|
|
373
377
|
const message = error instanceof Error ? error.message : String(error);
|
|
374
378
|
console.error("[Worker] CreateEIP712 error:", message);
|
|
@@ -378,11 +382,10 @@
|
|
|
378
382
|
/**
|
|
379
383
|
* Handle CREATE_DELEGATED_EIP712 request.
|
|
380
384
|
*/
|
|
381
|
-
function handleCreateDelegatedEIP712(request) {
|
|
385
|
+
async function handleCreateDelegatedEIP712(request) {
|
|
382
386
|
const { id, type, payload } = request;
|
|
383
387
|
try {
|
|
384
|
-
|
|
385
|
-
sendSuccess(id, type, sdkInstance.createDelegatedUserDecryptEIP712(unprefixHex(payload.publicKey), payload.contractAddresses, payload.delegatorAddress, payload.startTimestamp, payload.durationDays));
|
|
388
|
+
sendSuccess(id, type, (await getInstance(payload.chainId)).createDelegatedUserDecryptEIP712(unprefixHex(payload.publicKey), payload.contractAddresses, payload.delegatorAddress, payload.startTimestamp, payload.durationDays));
|
|
386
389
|
} catch (error) {
|
|
387
390
|
const message = error instanceof Error ? error.message : String(error);
|
|
388
391
|
console.error("[Worker] CreateDelegatedEIP712 error:", message);
|
|
@@ -395,12 +398,12 @@
|
|
|
395
398
|
async function handleDelegatedUserDecrypt(request) {
|
|
396
399
|
const { id, type, payload } = request;
|
|
397
400
|
try {
|
|
398
|
-
|
|
401
|
+
const instance = await getInstance(payload.chainId);
|
|
399
402
|
const handleContractPairs = payload.handles.map((handle) => ({
|
|
400
403
|
handle,
|
|
401
404
|
contractAddress: payload.contractAddress
|
|
402
405
|
}));
|
|
403
|
-
sendSuccess(id, type, { clearValues: await
|
|
406
|
+
sendSuccess(id, type, { clearValues: await instance.delegatedUserDecrypt(handleContractPairs, unprefixHex(payload.privateKey), unprefixHex(payload.publicKey), payload.signature, payload.signedContractAddresses, payload.delegatorAddress, payload.delegateAddress, payload.startTimestamp, payload.durationDays) });
|
|
404
407
|
} catch (error) {
|
|
405
408
|
const message = error instanceof Error ? error.message : String(error);
|
|
406
409
|
const statusCode = extractHttpStatus(error);
|
|
@@ -414,8 +417,7 @@
|
|
|
414
417
|
async function handleRequestZKProofVerification(request) {
|
|
415
418
|
const { id, type, payload } = request;
|
|
416
419
|
try {
|
|
417
|
-
|
|
418
|
-
const result = await sdkInstance.requestZKProofVerification(payload.zkProof);
|
|
420
|
+
const result = await (await getInstance(payload.chainId)).requestZKProofVerification(payload.zkProof);
|
|
419
421
|
sendSuccess(id, type, result, [result.inputProof.buffer, ...result.handles.map((h) => h.buffer)]);
|
|
420
422
|
} catch (error) {
|
|
421
423
|
const message = error instanceof Error ? error.message : String(error);
|
|
@@ -426,11 +428,10 @@
|
|
|
426
428
|
/**
|
|
427
429
|
* Handle GET_PUBLIC_KEY request.
|
|
428
430
|
*/
|
|
429
|
-
function handleGetPublicKey(request) {
|
|
430
|
-
const { id, type } = request;
|
|
431
|
+
async function handleGetPublicKey(request) {
|
|
432
|
+
const { id, type, payload } = request;
|
|
431
433
|
try {
|
|
432
|
-
|
|
433
|
-
sendSuccess(id, type, { result: sdkInstance.getPublicKey() });
|
|
434
|
+
sendSuccess(id, type, { result: (await getInstance(payload.chainId)).getPublicKey() });
|
|
434
435
|
} catch (error) {
|
|
435
436
|
const message = error instanceof Error ? error.message : String(error);
|
|
436
437
|
console.error("[Worker] GetPublicKey error:", message);
|
|
@@ -440,11 +441,10 @@
|
|
|
440
441
|
/**
|
|
441
442
|
* Handle GET_PUBLIC_PARAMS request.
|
|
442
443
|
*/
|
|
443
|
-
function handleGetPublicParams(request) {
|
|
444
|
+
async function handleGetPublicParams(request) {
|
|
444
445
|
const { id, type, payload } = request;
|
|
445
446
|
try {
|
|
446
|
-
|
|
447
|
-
sendSuccess(id, type, { result: sdkInstance.getPublicParams(payload.bits) });
|
|
447
|
+
sendSuccess(id, type, { result: (await getInstance(payload.chainId)).getPublicParams(payload.bits) });
|
|
448
448
|
} catch (error) {
|
|
449
449
|
const message = error instanceof Error ? error.message : String(error);
|
|
450
450
|
console.error("[Worker] GetPublicParams error:", message);
|
|
@@ -482,13 +482,13 @@
|
|
|
482
482
|
await handlePublicDecrypt(request);
|
|
483
483
|
break;
|
|
484
484
|
case "GENERATE_KEYPAIR":
|
|
485
|
-
handleGenerateKeypair(request);
|
|
485
|
+
await handleGenerateKeypair(request);
|
|
486
486
|
break;
|
|
487
487
|
case "CREATE_EIP712":
|
|
488
|
-
handleCreateEIP712(request);
|
|
488
|
+
await handleCreateEIP712(request);
|
|
489
489
|
break;
|
|
490
490
|
case "CREATE_DELEGATED_EIP712":
|
|
491
|
-
handleCreateDelegatedEIP712(request);
|
|
491
|
+
await handleCreateDelegatedEIP712(request);
|
|
492
492
|
break;
|
|
493
493
|
case "DELEGATED_USER_DECRYPT":
|
|
494
494
|
await handleDelegatedUserDecrypt(request);
|
|
@@ -497,10 +497,10 @@
|
|
|
497
497
|
await handleRequestZKProofVerification(request);
|
|
498
498
|
break;
|
|
499
499
|
case "GET_PUBLIC_KEY":
|
|
500
|
-
handleGetPublicKey(request);
|
|
500
|
+
await handleGetPublicKey(request);
|
|
501
501
|
break;
|
|
502
502
|
case "GET_PUBLIC_PARAMS":
|
|
503
|
-
handleGetPublicParams(request);
|
|
503
|
+
await handleGetPublicParams(request);
|
|
504
504
|
break;
|
|
505
505
|
default: console.error("[Worker] Unknown request type:", request.type);
|
|
506
506
|
}
|
package/dist/cjs/relayer.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const e={SigningRejected:`SIGNING_REJECTED`,SigningFailed:`SIGNING_FAILED`,EncryptionFailed:`ENCRYPTION_FAILED`,DecryptionFailed:`DECRYPTION_FAILED`,ApprovalFailed:`APPROVAL_FAILED`,TransactionReverted:`TRANSACTION_REVERTED`,KeypairExpired:`KEYPAIR_EXPIRED`,InvalidKeypair:`INVALID_KEYPAIR`,NoCiphertext:`NO_CIPHERTEXT`,RelayerRequestFailed:`RELAYER_REQUEST_FAILED`,Configuration:`CONFIGURATION`,DelegationSelfNotAllowed:`DELEGATION_SELF_NOT_ALLOWED`,DelegationCooldown:`DELEGATION_COOLDOWN`,DelegationNotFound:`DELEGATION_NOT_FOUND`,DelegationExpired:`DELEGATION_EXPIRED`,InsufficientConfidentialBalance:`INSUFFICIENT_CONFIDENTIAL_BALANCE`,InsufficientERC20Balance:`INSUFFICIENT_ERC20_BALANCE`,BalanceCheckUnavailable:`BALANCE_CHECK_UNAVAILABLE`,ERC20ReadFailed:`ERC20_READ_FAILED`,DelegationExpiryUnchanged:`DELEGATION_EXPIRY_UNCHANGED`,DelegationDelegateEqualsContract:`DELEGATION_DELEGATE_EQUALS_CONTRACT`,DelegationContractIsSelf:`DELEGATION_CONTRACT_IS_SELF`,AclPaused:`ACL_PAUSED`,DelegationExpirationTooSoon:`DELEGATION_EXPIRATION_TOO_SOON`,DelegationNotPropagated:`DELEGATION_NOT_PROPAGATED`};var t=class extends Error{code;constructor(e,t,n){super(t,n),Object.setPrototypeOf(this,new.target.prototype),this.name=`ZamaError`,this.code=e}};function n(e,n){if(e instanceof t){let t=n[e.code];if(t)return t(e)}return n._?.(e)}var r=class extends t{
|
|
1
|
+
const e={SigningRejected:`SIGNING_REJECTED`,SigningFailed:`SIGNING_FAILED`,EncryptionFailed:`ENCRYPTION_FAILED`,DecryptionFailed:`DECRYPTION_FAILED`,ApprovalFailed:`APPROVAL_FAILED`,TransactionReverted:`TRANSACTION_REVERTED`,KeypairExpired:`KEYPAIR_EXPIRED`,InvalidKeypair:`INVALID_KEYPAIR`,NoCiphertext:`NO_CIPHERTEXT`,RelayerRequestFailed:`RELAYER_REQUEST_FAILED`,Configuration:`CONFIGURATION`,DelegationSelfNotAllowed:`DELEGATION_SELF_NOT_ALLOWED`,DelegationCooldown:`DELEGATION_COOLDOWN`,DelegationNotFound:`DELEGATION_NOT_FOUND`,DelegationExpired:`DELEGATION_EXPIRED`,InsufficientConfidentialBalance:`INSUFFICIENT_CONFIDENTIAL_BALANCE`,InsufficientERC20Balance:`INSUFFICIENT_ERC20_BALANCE`,BalanceCheckUnavailable:`BALANCE_CHECK_UNAVAILABLE`,ERC20ReadFailed:`ERC20_READ_FAILED`,DelegationExpiryUnchanged:`DELEGATION_EXPIRY_UNCHANGED`,DelegationDelegateEqualsContract:`DELEGATION_DELEGATE_EQUALS_CONTRACT`,DelegationContractIsSelf:`DELEGATION_CONTRACT_IS_SELF`,AclPaused:`ACL_PAUSED`,DelegationExpirationTooSoon:`DELEGATION_EXPIRATION_TOO_SOON`,DelegationNotPropagated:`DELEGATION_NOT_PROPAGATED`,ChainMismatch:`CHAIN_MISMATCH`};var t=class extends Error{code;constructor(e,t,n){super(t,n),Object.setPrototypeOf(this,new.target.prototype),this.name=`ZamaError`,this.code=e}};function n(e,n){if(e instanceof t){let t=n[e.code];if(t)return t(e)}return n._?.(e)}var r=class extends t{statusCode;constructor(t,n,r){super(e.RelayerRequestFailed,t,r),this.name=`RelayerRequestFailedError`,this.statusCode=n}},i=class extends t{constructor(t,n){super(e.Configuration,t,n),this.name=`ConfigurationError`}};Object.defineProperty(exports,`a`,{enumerable:!0,get:function(){return n}}),Object.defineProperty(exports,`i`,{enumerable:!0,get:function(){return e}}),Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return r}}),Object.defineProperty(exports,`r`,{enumerable:!0,get:function(){return t}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return i}});
|
|
2
2
|
//# sourceMappingURL=relayer.cjs.map
|
package/dist/cjs/relayer.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"relayer.cjs","names":[],"sources":["../../src/errors/base.ts","../../src/errors/
|
|
1
|
+
{"version":3,"file":"relayer.cjs","names":[],"sources":["../../src/errors/base.ts","../../src/errors/relayer.ts"],"sourcesContent":["/**\n * Typed error codes thrown by the SDK.\n * Use `error.code` or `instanceof` to programmatically handle specific failure modes.\n *\n * @example\n * ```ts\n * try {\n * await token.confidentialTransfer(\"0xTo\", 100n);\n * } catch (e) {\n * if (e instanceof SigningRejectedError) {\n * // User rejected the wallet signature\n * }\n * }\n * ```\n */\nexport const ZamaErrorCode = {\n /** User rejected the wallet signature prompt. */\n SigningRejected: \"SIGNING_REJECTED\",\n /** Wallet signature failed for a reason other than rejection. */\n SigningFailed: \"SIGNING_FAILED\",\n /** FHE encryption failed. */\n EncryptionFailed: \"ENCRYPTION_FAILED\",\n /** FHE decryption failed. */\n DecryptionFailed: \"DECRYPTION_FAILED\",\n /** ERC-20 approval transaction failed. */\n ApprovalFailed: \"APPROVAL_FAILED\",\n /** On-chain transaction reverted. */\n TransactionReverted: \"TRANSACTION_REVERTED\",\n /** FHE keypair has expired and needs regeneration. */\n KeypairExpired: \"KEYPAIR_EXPIRED\",\n /** Relayer rejected FHE keypair (stale, expired, or malformed). */\n InvalidKeypair: \"INVALID_KEYPAIR\",\n /** No FHE ciphertext exists for this account (never shielded). */\n NoCiphertext: \"NO_CIPHERTEXT\",\n /** Relayer HTTP request failed. */\n RelayerRequestFailed: \"RELAYER_REQUEST_FAILED\",\n /** SDK configuration is invalid (e.g. forbidden chain ID, unsupported type). */\n Configuration: \"CONFIGURATION\",\n /** Delegation cannot target self (delegate === msg.sender). */\n DelegationSelfNotAllowed: \"DELEGATION_SELF_NOT_ALLOWED\",\n /** Only one delegate/revoke per (delegator, delegate, contract) per block. */\n DelegationCooldown: \"DELEGATION_COOLDOWN\",\n /** No active delegation found for this (delegator, delegate, contract) tuple. */\n DelegationNotFound: \"DELEGATION_NOT_FOUND\",\n /** The delegation has expired. */\n DelegationExpired: \"DELEGATION_EXPIRED\",\n /** Confidential (cToken) balance is insufficient for the requested operation. */\n InsufficientConfidentialBalance: \"INSUFFICIENT_CONFIDENTIAL_BALANCE\",\n /** ERC-20 balance is insufficient for the requested shield amount. */\n InsufficientERC20Balance: \"INSUFFICIENT_ERC20_BALANCE\",\n /** Balance validation could not be performed (no cached credentials and decryption not possible). */\n BalanceCheckUnavailable: \"BALANCE_CHECK_UNAVAILABLE\",\n /** Public ERC-20 read (e.g. balanceOf) failed due to a network or contract error. */\n ERC20ReadFailed: \"ERC20_READ_FAILED\",\n /** The new expiration date equals the current one — no on-chain change needed. */\n DelegationExpiryUnchanged: \"DELEGATION_EXPIRY_UNCHANGED\",\n /** Delegate address cannot be the contract address. */\n DelegationDelegateEqualsContract: \"DELEGATION_DELEGATE_EQUALS_CONTRACT\",\n /** Contract address cannot be the sender address. */\n DelegationContractIsSelf: \"DELEGATION_CONTRACT_IS_SELF\",\n /** The ACL contract is paused. */\n AclPaused: \"ACL_PAUSED\",\n /** Expiration date is too soon (must be at least 1 hour in the future). */\n DelegationExpirationTooSoon: \"DELEGATION_EXPIRATION_TOO_SOON\",\n /** Delegation exists on-chain but hasn't propagated to the gateway yet. */\n DelegationNotPropagated: \"DELEGATION_NOT_PROPAGATED\",\n /** Signer and provider are connected to different chains. */\n ChainMismatch: \"CHAIN_MISMATCH\",\n} as const;\n\n/** Union of all {@link ZamaErrorCode} string values. */\nexport type ZamaErrorCode = (typeof ZamaErrorCode)[keyof typeof ZamaErrorCode];\n\n/**\n * Base error thrown by all SDK operations.\n * Carries a {@link ZamaErrorCode} for programmatic error handling.\n * Prefer catching specific subclasses (e.g. {@link EncryptionFailedError}).\n */\nexport class ZamaError extends Error {\n /** Machine-readable error code. */\n readonly code: ZamaErrorCode;\n\n constructor(code: ZamaErrorCode, message: string, options?: ErrorOptions) {\n super(message, options);\n Object.setPrototypeOf(this, new.target.prototype);\n this.name = \"ZamaError\";\n this.code = code;\n }\n}\n\n/**\n * Pattern-match on a {@link ZamaError} by its error code.\n * Falls through to the `_` wildcard handler if no specific handler matches.\n * Returns `undefined` if the error is not a `ZamaError` and no `_` handler is provided.\n *\n * @example\n * ```ts\n * matchZamaError(error, {\n * SIGNING_REJECTED: () => toast(\"Please approve in wallet\"),\n * TRANSACTION_REVERTED: (e) => toast(`Tx failed: ${e.message}`),\n * _: () => toast(\"Unknown error\"),\n * });\n * ```\n */\nexport function matchZamaError<R>(\n error: unknown,\n handlers: Partial<Record<ZamaErrorCode, (error: ZamaError) => R>> & {\n _?: (error: unknown) => R;\n },\n): R | undefined {\n if (error instanceof ZamaError) {\n const handler = handlers[error.code];\n if (handler) {\n return handler(error);\n }\n }\n return handlers._?.(error);\n}\n","import { ZamaError, ZamaErrorCode } from \"./base\";\n\n/** Relayer HTTP request failed. */\nexport class RelayerRequestFailedError extends ZamaError {\n /** HTTP status code from the relayer, if available. */\n readonly statusCode: number | undefined;\n\n constructor(message: string, statusCode?: number, options?: ErrorOptions) {\n super(ZamaErrorCode.RelayerRequestFailed, message, options);\n this.name = \"RelayerRequestFailedError\";\n this.statusCode = statusCode;\n }\n}\n\n/** SDK configuration is invalid (e.g. forbidden chain ID, unsupported type). */\nexport class ConfigurationError extends ZamaError {\n constructor(message: string, options?: ErrorOptions) {\n super(ZamaErrorCode.Configuration, message, options);\n this.name = \"ConfigurationError\";\n }\n}\n"],"mappings":"AAeA,MAAa,EAAgB,CAE3B,gBAAiB,mBAEjB,cAAe,iBAEf,iBAAkB,oBAElB,iBAAkB,oBAElB,eAAgB,kBAEhB,oBAAqB,uBAErB,eAAgB,kBAEhB,eAAgB,kBAEhB,aAAc,gBAEd,qBAAsB,yBAEtB,cAAe,gBAEf,yBAA0B,8BAE1B,mBAAoB,sBAEpB,mBAAoB,uBAEpB,kBAAmB,qBAEnB,gCAAiC,oCAEjC,yBAA0B,6BAE1B,wBAAyB,4BAEzB,gBAAiB,oBAEjB,0BAA2B,8BAE3B,iCAAkC,sCAElC,yBAA0B,8BAE1B,UAAW,aAEX,4BAA6B,iCAE7B,wBAAyB,4BAEzB,cAAe,iBAChB,CAUD,IAAa,EAAb,cAA+B,KAAM,CAEnC,KAEA,YAAY,EAAqB,EAAiB,EAAwB,CACxE,MAAM,EAAS,EAAQ,CACvB,OAAO,eAAe,KAAM,IAAI,OAAO,UAAU,CACjD,KAAK,KAAO,YACZ,KAAK,KAAO,IAkBhB,SAAgB,EACd,EACA,EAGe,CACf,GAAI,aAAiB,EAAW,CAC9B,IAAM,EAAU,EAAS,EAAM,MAC/B,GAAI,EACF,OAAO,EAAQ,EAAM,CAGzB,OAAO,EAAS,IAAI,EAAM,CCjH5B,IAAa,EAAb,cAA+C,CAAU,CAEvD,WAEA,YAAY,EAAiB,EAAqB,EAAwB,CACxE,MAAM,EAAc,qBAAsB,EAAS,EAAQ,CAC3D,KAAK,KAAO,4BACZ,KAAK,WAAa,IAKT,EAAb,cAAwC,CAAU,CAChD,YAAY,EAAiB,EAAwB,CACnD,MAAM,EAAc,cAAe,EAAS,EAAQ,CACpD,KAAK,KAAO"}
|
package/dist/cjs/viem/index.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`../wrappers-registry.cjs`),
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`../build.cjs`),t=require(`../wrappers-registry.cjs`),n=require(`../eip1193-subscribe.cjs`);let r=require(`viem`);var i=class{#e;constructor(e){this.#e=e.publicClient}async getChainId(){return this.#e.getChainId()}async readContract(e){return this.#e.readContract(e)}async waitForTransactionReceipt(e){return this.#e.waitForTransactionReceipt({hash:e})}async getBlockTimestamp(){return(await this.#e.getBlock()).timestamp}};function a(e){if(!(!e.account||!e.chain))return{address:(0,r.getAddress)(e.account.address),chainId:e.chain.id}}var o=class{#e;#t;constructor(e){this.#e=e.walletClient,this.#t=e.ethereum}#n(){if(!this.#e.account)throw TypeError(`WalletClient has no account`);return{walletClient:this.#e,account:this.#e.account}}async getChainId(){return this.#e.getChainId()}async getAddress(){return this.#n().account.address}async signTypedData(e){let{walletClient:t,account:n}=this.#n(),{EIP712Domain:r,...i}=e.types;return t.signTypedData({account:n,primaryType:e.primaryType,types:i,domain:e.domain,message:{...e.message,startTimestamp:BigInt(e.message.startTimestamp),durationDays:BigInt(e.message.durationDays)}})}async writeContract(e){let{walletClient:t,account:n}=this.#n();return t.writeContract({chain:t.chain,account:n,...e})}subscribe(e){return n.t({provider:this.#t,getInitialIdentity:()=>a(this.#e),onIdentityChange:e})}};function s(t){return e.t(new o({walletClient:t.walletClient,ethereum:t.ethereum}),new i({publicClient:t.publicClient}),t)}function c(e){if(!e.account)throw TypeError(`WalletClient has no account`);return e.account}function l(e,n,r){return e.readContract(t.v(n,r))}function u(e,n){return e.readContract(t.g(n))}function d(e,n,r){return e.readContract(t.p(n,r))}function f(e,n,r,i,a){return e.writeContract({chain:e.chain,account:c(e),...t.b(n,r,i,a)})}function p(e,n,r,i,a,o){return e.writeContract({chain:e.chain,account:c(e),...t.E(n,r,i,a,o)})}function m(e,n,r,i,a){return e.writeContract({chain:e.chain,account:c(e),...t.D(n,r,i,a)})}function h(e,n,r,i,a){return e.writeContract({chain:e.chain,account:c(e),...t.m(n,r,i,a)})}function g(e,n,r,i){return e.writeContract({chain:e.chain,account:c(e),...t.w(n,r,i)})}function _(e,n,r,i){return e.writeContract({chain:e.chain,account:c(e),...t._(n,r,i)})}function v(e,n){return e.readContract(t.i(n))}function y(e,n){return e.readContract(t.a(n))}function b(e,n,r,i){return e.readContract(t.o(n,r,i))}function x(e,n,r){return e.readContract(t.r(n,r))}function S(e,n,r){return e.readContract(t.t(n,r))}function C(e,n,r){return e.readContract(t.n(n,r))}function w(e,n,r){return e.readContract(t.s(n,r))}exports.ViemProvider=i,exports.ViemSigner=o,exports.createConfig=s,exports.readConfidentialBalanceOfContract=l,exports.readConfidentialTokenAddressContract=S,exports.readIsConfidentialTokenValidContract=w,exports.readSupportsInterfaceContract=d,exports.readTokenAddressContract=C,exports.readTokenPairContract=x,exports.readTokenPairsContract=v,exports.readTokenPairsLengthContract=y,exports.readTokenPairsSliceContract=b,exports.readUnderlyingTokenContract=u,exports.writeConfidentialTransferContract=f,exports.writeFinalizeUnwrapContract=h,exports.writeSetOperatorContract=g,exports.writeUnwrapContract=p,exports.writeUnwrapFromBalanceContract=m,exports.writeWrapContract=_;
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":["#walletClient","#publicClient","#ethereum","#requireWalletClient","#requireWalletAndAccount","eip1193Subscribe","confidentialBalanceOfContract","underlyingContract","supportsInterfaceContract","confidentialTransferContract","unwrapContract","unwrapFromBalanceContract","finalizeUnwrapContract","setOperatorContract","wrapContract","getTokenPairsContract","getTokenPairsLengthContract","getTokenPairsSliceContract","getTokenPairContract","getConfidentialTokenAddressContract","getTokenAddressContract","isConfidentialTokenValidContract"],"sources":["../../../src/viem/viem-signer.ts","../../../src/viem/contracts.ts"],"sourcesContent":["import type {\n Account,\n Abi,\n ContractFunctionArgs,\n ContractFunctionName,\n ContractFunctionReturnType,\n EIP1193Provider,\n PublicClient,\n WalletClient,\n Address,\n Hex,\n} from \"viem\";\nimport type { writeContract } from \"viem/actions\";\nimport type { EIP712TypedData } from \"../relayer/relayer-sdk.types\";\nimport type {\n GenericSigner,\n ReadContractConfig,\n SignerLifecycleCallbacks,\n TransactionReceipt,\n WriteContractConfig,\n} from \"../types\";\nimport { eip1193Subscribe } from \"../token/eip1193-subscribe\";\n\n/**\n * Configuration for {@link ViemSigner}.\n *\n * The optional `ethereum` field is needed for `subscribe()` (EIP-1193\n * `accountsChanged` / `disconnect` events). It cannot be auto-extracted from\n * `walletClient` because viem's `custom(ethereum)` transport captures the\n * provider in a closure and does **not** expose `on` / `removeListener` on\n * `walletClient.transport`.\n *\n * If you omit `ethereum`, `subscribe()` returns a no-op. For automatic\n * wallet lifecycle handling, consider using `WagmiSigner` instead.\n */\nexport interface ViemSignerConfig {\n /** Wallet client for signing and write operations. Optional — omit for read-only usage. */\n walletClient?: WalletClient;\n publicClient: PublicClient;\n ethereum?: EIP1193Provider;\n}\n\n/**\n * GenericSigner backed by viem.\n *\n * @param config - {@link ViemSignerConfig} with walletClient and publicClient\n */\nexport class ViemSigner implements GenericSigner {\n readonly #walletClient?: WalletClient;\n readonly #publicClient: PublicClient;\n readonly #ethereum?: EIP1193Provider;\n\n constructor(config: ViemSignerConfig) {\n this.#walletClient = config.walletClient;\n this.#publicClient = config.publicClient;\n this.#ethereum = config.ethereum;\n }\n\n #requireWalletClient(): WalletClient {\n if (!this.#walletClient) {\n throw new TypeError(\"No walletClient configured — read-only mode\");\n }\n return this.#walletClient;\n }\n\n #requireWalletAndAccount(): { walletClient: WalletClient; account: Account } {\n const walletClient = this.#requireWalletClient();\n if (!walletClient.account) {\n throw new TypeError(\"WalletClient has no account\");\n }\n return { walletClient, account: walletClient.account };\n }\n\n async getChainId(): Promise<number> {\n return this.#publicClient.getChainId();\n }\n\n async getAddress(): Promise<Address> {\n return this.#requireWalletAndAccount().account.address;\n }\n\n async signTypedData(typedData: EIP712TypedData): Promise<Hex> {\n const { walletClient, account } = this.#requireWalletAndAccount();\n const { EIP712Domain: _, ...sigTypes } = typedData.types;\n return walletClient.signTypedData({\n account,\n primaryType: Object.keys(sigTypes)[0]!,\n types: sigTypes,\n domain: typedData.domain,\n message: typedData.message,\n });\n }\n\n async writeContract<\n const TAbi extends Abi | readonly unknown[],\n TFunctionName extends ContractFunctionName<TAbi, \"nonpayable\" | \"payable\">,\n const TArgs extends ContractFunctionArgs<TAbi, \"nonpayable\" | \"payable\", TFunctionName>,\n >(config: WriteContractConfig<TAbi, TFunctionName, TArgs>): Promise<Hex> {\n const { walletClient, account } = this.#requireWalletAndAccount();\n return walletClient.writeContract({\n chain: walletClient.chain,\n account,\n ...config,\n } as Parameters<typeof writeContract>[1]);\n }\n\n async readContract<\n const TAbi extends Abi | readonly unknown[],\n TFunctionName extends ContractFunctionName<TAbi, \"pure\" | \"view\">,\n const TArgs extends ContractFunctionArgs<TAbi, \"pure\" | \"view\", TFunctionName>,\n >(\n config: ReadContractConfig<TAbi, TFunctionName, TArgs>,\n ): Promise<ContractFunctionReturnType<TAbi, \"pure\" | \"view\", TFunctionName, TArgs>> {\n return this.#publicClient.readContract(config);\n }\n\n async waitForTransactionReceipt(hash: Hex): Promise<TransactionReceipt> {\n return this.#publicClient.waitForTransactionReceipt({ hash });\n }\n\n async getBlockTimestamp(): Promise<bigint> {\n const block = await this.#publicClient.getBlock();\n return block.timestamp;\n }\n\n subscribe(callbacks: SignerLifecycleCallbacks): () => void {\n if (!this.#walletClient) {\n return () => {};\n }\n return eip1193Subscribe(this.#ethereum, () => this.getAddress(), callbacks);\n }\n}\n","import type { PublicClient, WalletClient, Address, Hex } from \"viem\";\nimport type { Handle } from \"../relayer/relayer-sdk.types\";\nimport {\n confidentialBalanceOfContract,\n confidentialTransferContract,\n finalizeUnwrapContract,\n setOperatorContract,\n supportsInterfaceContract,\n underlyingContract,\n unwrapContract,\n unwrapFromBalanceContract,\n wrapContract,\n getTokenPairsContract,\n getTokenPairsLengthContract,\n getTokenPairsSliceContract,\n getTokenPairContract,\n getConfidentialTokenAddressContract,\n getTokenAddressContract,\n isConfidentialTokenValidContract,\n} from \"../contracts\";\n\n// ── Helpers ────────────────────────────────────────────────\n\nfunction requireAccount(client: WalletClient) {\n if (!client.account) {\n throw new TypeError(\"WalletClient has no account\");\n }\n return client.account;\n}\n\n// ── Read helpers ────────────────────────────────────────────\n\nexport function readConfidentialBalanceOfContract(\n client: PublicClient,\n tokenAddress: Address,\n userAddress: Address,\n) {\n return client.readContract(confidentialBalanceOfContract(tokenAddress, userAddress));\n}\n\nexport function readUnderlyingTokenContract(client: PublicClient, wrapperAddress: Address) {\n return client.readContract(underlyingContract(wrapperAddress));\n}\n\nexport function readSupportsInterfaceContract(\n client: PublicClient,\n tokenAddress: Address,\n interfaceId: Address,\n) {\n return client.readContract(supportsInterfaceContract(tokenAddress, interfaceId));\n}\n\n// ── Write helpers ───────────────────────────────────────────\n\nexport function writeConfidentialTransferContract(\n client: WalletClient,\n tokenAddress: Address,\n to: Address,\n handle: Uint8Array,\n inputProof: Uint8Array,\n) {\n return client.writeContract({\n chain: client.chain,\n account: requireAccount(client),\n ...confidentialTransferContract(tokenAddress, to, handle, inputProof),\n });\n}\n\nexport function writeUnwrapContract(\n client: WalletClient,\n encryptedErc20: Address,\n from: Address,\n to: Address,\n encryptedAmount: Uint8Array,\n inputProof: Uint8Array,\n) {\n return client.writeContract({\n chain: client.chain,\n account: requireAccount(client),\n ...unwrapContract(encryptedErc20, from, to, encryptedAmount, inputProof),\n });\n}\n\nexport function writeUnwrapFromBalanceContract(\n client: WalletClient,\n encryptedErc20: Address,\n from: Address,\n to: Address,\n encryptedBalance: Handle,\n) {\n return client.writeContract({\n chain: client.chain,\n account: requireAccount(client),\n ...unwrapFromBalanceContract(encryptedErc20, from, to, encryptedBalance),\n });\n}\n\nexport function writeFinalizeUnwrapContract(\n client: WalletClient,\n wrapper: Address,\n unwrapRequestId: Handle,\n burntAmountCleartext: bigint,\n decryptionProof: Hex,\n) {\n return client.writeContract({\n chain: client.chain,\n account: requireAccount(client),\n ...finalizeUnwrapContract(wrapper, unwrapRequestId, burntAmountCleartext, decryptionProof),\n });\n}\n\nexport function writeSetOperatorContract(\n client: WalletClient,\n tokenAddress: Address,\n spender: Address,\n timestamp?: number,\n) {\n return client.writeContract({\n chain: client.chain,\n account: requireAccount(client),\n ...setOperatorContract(tokenAddress, spender, timestamp),\n });\n}\n\nexport function writeWrapContract(\n client: WalletClient,\n wrapperAddress: Address,\n to: Address,\n amount: bigint,\n) {\n return client.writeContract({\n chain: client.chain,\n account: requireAccount(client),\n ...wrapContract(wrapperAddress, to, amount),\n });\n}\n\n// ── Registry read helpers ──────────────────────────────────\n\nexport function readTokenPairsContract(client: PublicClient, registry: Address) {\n return client.readContract(getTokenPairsContract(registry));\n}\n\nexport function readTokenPairsLengthContract(client: PublicClient, registry: Address) {\n return client.readContract(getTokenPairsLengthContract(registry));\n}\n\nexport function readTokenPairsSliceContract(\n client: PublicClient,\n registry: Address,\n fromIndex: bigint,\n toIndex: bigint,\n) {\n return client.readContract(getTokenPairsSliceContract(registry, fromIndex, toIndex));\n}\n\nexport function readTokenPairContract(client: PublicClient, registry: Address, index: bigint) {\n return client.readContract(getTokenPairContract(registry, index));\n}\n\nexport function readConfidentialTokenAddressContract(\n client: PublicClient,\n registry: Address,\n tokenAddress: Address,\n) {\n return client.readContract(getConfidentialTokenAddressContract(registry, tokenAddress));\n}\n\nexport function readTokenAddressContract(\n client: PublicClient,\n registry: Address,\n confidentialTokenAddress: Address,\n) {\n return client.readContract(getTokenAddressContract(registry, confidentialTokenAddress));\n}\n\nexport function readIsConfidentialTokenValidContract(\n client: PublicClient,\n registry: Address,\n confidentialTokenAddress: Address,\n) {\n return client.readContract(isConfidentialTokenValidContract(registry, confidentialTokenAddress));\n}\n"],"mappings":"qJA+CA,IAAa,EAAb,KAA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EAAO,MACd,QAAS,EAAe,EAAO,CAC/B,GAAGC,EAAAA,EAAa,EAAgB,EAAI,EAAO,CAC5C,CAAC,CAKJ,SAAgB,EAAuB,EAAsB,EAAmB,CAC9E,OAAO,EAAO,aAAaC,EAAAA,EAAsB,EAAS,CAAC,CAG7D,SAAgB,EAA6B,EAAsB,EAAmB,CACpF,OAAO,EAAO,aAAaC,EAAAA,EAA4B,EAAS,CAAC,CAGnE,SAAgB,EACd,EACA,EACA,EACA,EACA,CACA,OAAO,EAAO,aAAaC,EAAAA,EAA2B,EAAU,EAAW,EAAQ,CAAC,CAGtF,SAAgB,EAAsB,EAAsB,EAAmB,EAAe,CAC5F,OAAO,EAAO,aAAaC,EAAAA,EAAqB,EAAU,EAAM,CAAC,CAGnE,SAAgB,EACd,EACA,EACA,EACA,CACA,OAAO,EAAO,aAAaC,EAAAA,EAAoC,EAAU,EAAa,CAAC,CAGzF,SAAgB,EACd,EACA,EACA,EACA,CACA,OAAO,EAAO,aAAaC,EAAAA,EAAwB,EAAU,EAAyB,CAAC,CAGzF,SAAgB,EACd,EACA,EACA,EACA,CACA,OAAO,EAAO,aAAaC,EAAAA,EAAiC,EAAU,EAAyB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["#publicClient","#walletClient","#ethereum","#requireAccount","eip1193Subscribe","buildZamaConfig","confidentialBalanceOfContract","underlyingContract","supportsInterfaceContract","confidentialTransferContract","unwrapContract","unwrapFromBalanceContract","finalizeUnwrapContract","setOperatorContract","wrapContract","getTokenPairsContract","getTokenPairsLengthContract","getTokenPairsSliceContract","getTokenPairContract","getConfidentialTokenAddressContract","getTokenAddressContract","isConfidentialTokenValidContract"],"sources":["../../../src/viem/viem-provider.ts","../../../src/viem/viem-signer.ts","../../../src/viem/config.ts","../../../src/viem/contracts.ts"],"sourcesContent":["import type {\n Abi,\n ContractFunctionArgs,\n ContractFunctionName,\n ContractFunctionReturnType,\n Hex,\n PublicClient,\n} from \"viem\";\nimport type { GenericProvider, ReadContractConfig, TransactionReceipt } from \"../types\";\n\n/** Configuration for {@link ViemProvider}. */\nexport interface ViemProviderConfig {\n /** A viem `PublicClient` backing all read operations. */\n publicClient: PublicClient;\n}\n\n/**\n * Read-only {@link GenericProvider} backed by a viem `PublicClient`.\n *\n * Use this for integrations that only need public chain reads — server\n * indexers, SSR, dashboards, explorers, or dApps before the user has\n * connected their wallet. Pair with a {@link ViemSigner} when wallet\n * authority is required; the two can share a transport or point at\n * independent RPCs.\n *\n * @example\n * ```ts\n * const publicClient = createPublicClient({ chain: sepolia, transport: http(ALCHEMY_URL) });\n * const provider = new ViemProvider({ publicClient });\n * ```\n */\nexport class ViemProvider implements GenericProvider {\n readonly #publicClient: PublicClient;\n\n constructor(config: ViemProviderConfig) {\n this.#publicClient = config.publicClient;\n }\n\n async getChainId(): Promise<number> {\n return this.#publicClient.getChainId();\n }\n\n async readContract<\n const TAbi extends Abi | readonly unknown[],\n TFunctionName extends ContractFunctionName<TAbi, \"pure\" | \"view\">,\n const TArgs extends ContractFunctionArgs<TAbi, \"pure\" | \"view\", TFunctionName>,\n >(\n config: ReadContractConfig<TAbi, TFunctionName, TArgs>,\n ): Promise<ContractFunctionReturnType<TAbi, \"pure\" | \"view\", TFunctionName, TArgs>> {\n return this.#publicClient.readContract(config);\n }\n\n async waitForTransactionReceipt(hash: Hex): Promise<TransactionReceipt> {\n return this.#publicClient.waitForTransactionReceipt({ hash });\n }\n\n async getBlockTimestamp(): Promise<bigint> {\n const block = await this.#publicClient.getBlock();\n return block.timestamp;\n }\n}\n","import type {\n Account,\n Abi,\n ContractFunctionArgs,\n ContractFunctionName,\n EIP1193Provider,\n WalletClient,\n Address,\n Hex,\n} from \"viem\";\nimport { getAddress } from \"viem\";\nimport type { writeContract } from \"viem/actions\";\nimport type { EIP712TypedData } from \"../relayer/relayer-sdk.types\";\nimport type {\n GenericSigner,\n SignerIdentity,\n SignerIdentityListener,\n WriteContractConfig,\n} from \"../types\";\nimport { eip1193Subscribe } from \"../signer/eip1193-subscribe\";\n\n/**\n * Configuration for {@link ViemSigner}.\n *\n * The optional `ethereum` field is needed for `subscribe()` (EIP-1193\n * `accountsChanged` / `disconnect` events). It cannot be auto-extracted from\n * `walletClient` because viem's `custom(ethereum)` transport captures the\n * provider in a closure and does **not** expose `on` / `removeListener` on\n * `walletClient.transport`.\n *\n * If you omit `ethereum`, `subscribe()` returns a no-op. For automatic\n * wallet lifecycle handling, consider using `WagmiSigner` instead.\n */\nexport interface ViemSignerConfig {\n /** Wallet client for signing and write operations. */\n walletClient: WalletClient;\n ethereum?: EIP1193Provider;\n}\n\nfunction identityFromWalletClient(walletClient: WalletClient): SignerIdentity | undefined {\n if (!walletClient.account || !walletClient.chain) {\n return undefined;\n }\n const address = getAddress(walletClient.account.address);\n return { address, chainId: walletClient.chain.id };\n}\n\nexport class ViemSigner implements GenericSigner {\n readonly #walletClient: WalletClient;\n readonly #ethereum?: EIP1193Provider;\n constructor(config: ViemSignerConfig) {\n this.#walletClient = config.walletClient;\n this.#ethereum = config.ethereum;\n }\n\n #requireAccount(): { walletClient: WalletClient; account: Account } {\n if (!this.#walletClient.account) {\n throw new TypeError(\"WalletClient has no account\");\n }\n return { walletClient: this.#walletClient, account: this.#walletClient.account };\n }\n\n async getChainId(): Promise<number> {\n return this.#walletClient.getChainId();\n }\n\n async getAddress(): Promise<Address> {\n return this.#requireAccount().account.address;\n }\n\n async signTypedData(typedData: EIP712TypedData): Promise<Hex> {\n const { walletClient, account } = this.#requireAccount();\n const { EIP712Domain: _, ...sigTypes } = typedData.types;\n return walletClient.signTypedData({\n account,\n primaryType: typedData.primaryType,\n types: sigTypes,\n domain: typedData.domain,\n message: {\n ...typedData.message,\n startTimestamp: BigInt(typedData.message.startTimestamp),\n durationDays: BigInt(typedData.message.durationDays),\n },\n // Cast: EIP712TypedData is a union; viem cannot correlate primaryType/types/message across union members, so the inferred `message` collapses to `never`.\n } as Parameters<typeof walletClient.signTypedData>[0]);\n }\n\n async writeContract<\n const TAbi extends Abi | readonly unknown[],\n TFunctionName extends ContractFunctionName<TAbi, \"nonpayable\" | \"payable\">,\n const TArgs extends ContractFunctionArgs<TAbi, \"nonpayable\" | \"payable\", TFunctionName>,\n >(config: WriteContractConfig<TAbi, TFunctionName, TArgs>): Promise<Hex> {\n const { walletClient, account } = this.#requireAccount();\n return walletClient.writeContract({\n chain: walletClient.chain,\n account,\n ...config,\n } as Parameters<typeof writeContract>[1]);\n }\n\n subscribe(onIdentityChange: SignerIdentityListener): () => void {\n return eip1193Subscribe({\n provider: this.#ethereum,\n getInitialIdentity: () => identityFromWalletClient(this.#walletClient),\n onIdentityChange,\n });\n }\n}\n","import type { FheChain } from \"../chains\";\nimport type { ZamaConfig } from \"../config/types\";\nimport { buildZamaConfig } from \"../config/build\";\nimport { ViemProvider } from \"./viem-provider\";\nimport { ViemSigner } from \"./viem-signer\";\nimport type { ZamaConfigViem } from \"./types\";\n\n/** Create a {@link ZamaConfig} from viem clients. */\nexport function createConfig<const TChains extends readonly [FheChain, ...FheChain[]]>(\n params: ZamaConfigViem<TChains>,\n): ZamaConfig {\n const signer = new ViemSigner({\n walletClient: params.walletClient,\n ethereum: params.ethereum,\n });\n const provider = new ViemProvider({ publicClient: params.publicClient });\n return buildZamaConfig(signer, provider, params);\n}\n","import type { PublicClient, WalletClient, Address, Hex } from \"viem\";\nimport type { Handle } from \"../relayer/relayer-sdk.types\";\nimport {\n confidentialBalanceOfContract,\n confidentialTransferContract,\n finalizeUnwrapContract,\n setOperatorContract,\n supportsInterfaceContract,\n underlyingContract,\n unwrapContract,\n unwrapFromBalanceContract,\n wrapContract,\n getTokenPairsContract,\n getTokenPairsLengthContract,\n getTokenPairsSliceContract,\n getTokenPairContract,\n getConfidentialTokenAddressContract,\n getTokenAddressContract,\n isConfidentialTokenValidContract,\n} from \"../contracts\";\n\n// ── Helpers ────────────────────────────────────────────────\n\nfunction requireAccount(client: WalletClient) {\n if (!client.account) {\n throw new TypeError(\"WalletClient has no account\");\n }\n return client.account;\n}\n\n// ── Read helpers ────────────────────────────────────────────\n\nexport function readConfidentialBalanceOfContract(\n client: PublicClient,\n tokenAddress: Address,\n userAddress: Address,\n) {\n return client.readContract(confidentialBalanceOfContract(tokenAddress, userAddress));\n}\n\nexport function readUnderlyingTokenContract(client: PublicClient, wrapperAddress: Address) {\n return client.readContract(underlyingContract(wrapperAddress));\n}\n\nexport function readSupportsInterfaceContract(\n client: PublicClient,\n tokenAddress: Address,\n interfaceId: Address,\n) {\n return client.readContract(supportsInterfaceContract(tokenAddress, interfaceId));\n}\n\n// ── Write helpers ───────────────────────────────────────────\n\nexport function writeConfidentialTransferContract(\n client: WalletClient,\n tokenAddress: Address,\n to: Address,\n handle: Uint8Array,\n inputProof: Uint8Array,\n) {\n return client.writeContract({\n chain: client.chain,\n account: requireAccount(client),\n ...confidentialTransferContract(tokenAddress, to, handle, inputProof),\n });\n}\n\nexport function writeUnwrapContract(\n client: WalletClient,\n encryptedErc20: Address,\n from: Address,\n to: Address,\n encryptedAmount: Uint8Array,\n inputProof: Uint8Array,\n) {\n return client.writeContract({\n chain: client.chain,\n account: requireAccount(client),\n ...unwrapContract(encryptedErc20, from, to, encryptedAmount, inputProof),\n });\n}\n\nexport function writeUnwrapFromBalanceContract(\n client: WalletClient,\n encryptedErc20: Address,\n from: Address,\n to: Address,\n encryptedBalance: Handle,\n) {\n return client.writeContract({\n chain: client.chain,\n account: requireAccount(client),\n ...unwrapFromBalanceContract(encryptedErc20, from, to, encryptedBalance),\n });\n}\n\nexport function writeFinalizeUnwrapContract(\n client: WalletClient,\n wrapper: Address,\n unwrapRequestId: Handle,\n burntAmountCleartext: bigint,\n decryptionProof: Hex,\n) {\n return client.writeContract({\n chain: client.chain,\n account: requireAccount(client),\n ...finalizeUnwrapContract(wrapper, unwrapRequestId, burntAmountCleartext, decryptionProof),\n });\n}\n\nexport function writeSetOperatorContract(\n client: WalletClient,\n tokenAddress: Address,\n spender: Address,\n timestamp?: number,\n) {\n return client.writeContract({\n chain: client.chain,\n account: requireAccount(client),\n ...setOperatorContract(tokenAddress, spender, timestamp),\n });\n}\n\nexport function writeWrapContract(\n client: WalletClient,\n wrapperAddress: Address,\n to: Address,\n amount: bigint,\n) {\n return client.writeContract({\n chain: client.chain,\n account: requireAccount(client),\n ...wrapContract(wrapperAddress, to, amount),\n });\n}\n\n// ── Registry read helpers ──────────────────────────────────\n\nexport function readTokenPairsContract(client: PublicClient, registry: Address) {\n return client.readContract(getTokenPairsContract(registry));\n}\n\nexport function readTokenPairsLengthContract(client: PublicClient, registry: Address) {\n return client.readContract(getTokenPairsLengthContract(registry));\n}\n\nexport function readTokenPairsSliceContract(\n client: PublicClient,\n registry: Address,\n fromIndex: bigint,\n toIndex: bigint,\n) {\n return client.readContract(getTokenPairsSliceContract(registry, fromIndex, toIndex));\n}\n\nexport function readTokenPairContract(client: PublicClient, registry: Address, index: bigint) {\n return client.readContract(getTokenPairContract(registry, index));\n}\n\nexport function readConfidentialTokenAddressContract(\n client: PublicClient,\n registry: Address,\n tokenAddress: Address,\n) {\n return client.readContract(getConfidentialTokenAddressContract(registry, tokenAddress));\n}\n\nexport function readTokenAddressContract(\n client: PublicClient,\n registry: Address,\n confidentialTokenAddress: Address,\n) {\n return client.readContract(getTokenAddressContract(registry, confidentialTokenAddress));\n}\n\nexport function readIsConfidentialTokenValidContract(\n client: PublicClient,\n registry: Address,\n confidentialTokenAddress: Address,\n) {\n return client.readContract(isConfidentialTokenValidContract(registry, confidentialTokenAddress));\n}\n"],"mappings":"qMA+BA,IAAa,EAAb,KAAqD,CACnD,GAEA,YAAY,EAA4B,CACtC,MAAA,EAAqB,EAAO,aAG9B,MAAM,YAA8B,CAClC,OAAO,MAAA,EAAmB,YAAY,CAGxC,MAAM,aAKJ,EACkF,CAClF,OAAO,MAAA,EAAmB,aAAa,EAAO,CAGhD,MAAM,0BAA0B,EAAwC,CACtE,OAAO,MAAA,EAAmB,0BAA0B,CAAE,OAAM,CAAC,CAG/D,MAAM,mBAAqC,CAE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