@zama-fhe/sdk 3.0.1 → 3.1.0-alpha.2
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 +47 -797
- package/dist/cjs/assertions.cjs +2 -0
- package/dist/cjs/assertions.cjs.map +1 -0
- package/dist/cjs/base-signer.cjs +2 -0
- package/dist/cjs/base-signer.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 +1 -514
- 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/relayer-cleartext.cjs +2 -0
- package/dist/cjs/relayer-cleartext.cjs.map +1 -0
- package/dist/cjs/relayer-sdk.worker.js +75 -75
- package/dist/cjs/relayer.cjs +1 -1
- package/dist/cjs/relayer.cjs.map +1 -1
- package/dist/cjs/token.cjs +2 -0
- package/dist/cjs/token.cjs.map +1 -0
- package/dist/cjs/validation.cjs +2 -0
- package/dist/cjs/validation.cjs.map +1 -0
- package/dist/cjs/viem/index.cjs +1 -1
- package/dist/cjs/viem/index.cjs.map +1 -1
- package/dist/cjs/web/index.cjs +515 -0
- package/dist/cjs/web/index.cjs.map +1 -0
- package/dist/cjs/wrappers-registry.cjs +1 -1
- package/dist/cjs/wrappers-registry.cjs.map +1 -1
- package/dist/esm/assertions-qxjXTeNw.js +2 -0
- package/dist/esm/{assertions-BARApuMj.js.map → assertions-qxjXTeNw.js.map} +1 -1
- package/dist/esm/base-signer-BKI5njAs.js +2 -0
- package/dist/esm/base-signer-BKI5njAs.js.map +1 -0
- package/dist/esm/base-signer-pKDrNMlE.d.ts +63 -0
- package/dist/esm/chains/index.d.ts +3 -0
- package/dist/esm/chains/index.js +1 -0
- package/dist/esm/chains-DKasII-S.js +2 -0
- package/dist/esm/chains-DKasII-S.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-Hw0ScIRR.d.ts +19 -0
- package/dist/esm/cleartext-xzeh3Frj.js +2 -0
- package/dist/esm/cleartext-xzeh3Frj.js.map +1 -0
- package/dist/esm/eip1193-subscribe-B7nvT1Mp.js +2 -0
- package/dist/esm/eip1193-subscribe-B7nvT1Mp.js.map +1 -0
- package/dist/esm/{encryption-CmIPBcfP.js → encryption-xcQIQ9NP.js} +2 -2
- package/dist/esm/{encryption-CmIPBcfP.js.map → encryption-xcQIQ9NP.js.map} +1 -1
- package/dist/esm/{error-B6H-mBAh.js → error-BRHDbi2m.js} +1 -1
- package/dist/esm/{error-B6H-mBAh.js.map → error-BRHDbi2m.js.map} +1 -1
- package/dist/esm/ethers/index.d.ts +62 -16
- 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-BgMi2Yfs.js} +2 -2
- package/dist/esm/{hex-D_B-zoId.js.map → hex-BgMi2Yfs.js.map} +1 -1
- package/dist/esm/{activity-CUYnGNME.d.ts → index-BFGqQkab.d.ts} +1613 -2472
- package/dist/esm/{relayer-utils-iSPis4x-.d.ts → index-BYVFG3L9.d.ts} +50 -23
- package/dist/esm/index.d.ts +19 -101
- package/dist/esm/index.js +1 -514
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/indexeddb-storage-D2L6iKfO.js +2 -0
- package/dist/esm/indexeddb-storage-D2L6iKfO.js.map +1 -0
- package/dist/esm/memory-storage-CV60XJrC.js +2 -0
- package/dist/esm/memory-storage-CV60XJrC.js.map +1 -0
- package/dist/esm/node/index.d.ts +92 -131
- 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 +83 -157
- package/dist/esm/query/index.js +1 -1
- package/dist/esm/query/index.js.map +1 -1
- package/dist/esm/relayer-BP6EyPUy.js +2 -0
- package/dist/esm/relayer-BP6EyPUy.js.map +1 -0
- package/dist/esm/relayer-cleartext-CCaAhwgH.js +2 -0
- package/dist/esm/relayer-cleartext-CCaAhwgH.js.map +1 -0
- package/dist/esm/relayer-cleartext-C_5NGHjw.d.ts +702 -0
- package/dist/esm/relayer-sdk.worker.js +75 -75
- package/dist/esm/token-DTgVBH31.js +2 -0
- package/dist/esm/token-DTgVBH31.js.map +1 -0
- package/dist/esm/types-CC0Mp18i.d.ts +652 -0
- package/dist/esm/types-CKtFhknu.d.ts +14 -0
- package/dist/esm/types-DSq1YR39.d.ts +30 -0
- package/dist/esm/types-qTxGTfOc.d.ts +48 -0
- package/dist/esm/validation-D2VCFYWj.js +2 -0
- package/dist/esm/validation-D2VCFYWj.js.map +1 -0
- package/dist/esm/viem/index.d.ts +41 -16
- package/dist/esm/viem/index.js +1 -1
- package/dist/esm/viem/index.js.map +1 -1
- package/dist/esm/web/index.d.ts +21 -0
- package/dist/esm/web/index.js +515 -0
- package/dist/esm/web/index.js.map +1 -0
- package/dist/esm/worker.base-client-pErLQy-p.js +2 -0
- package/dist/esm/worker.base-client-pErLQy-p.js.map +1 -0
- package/dist/esm/wrappers-registry-BNxAZZWS.js +2 -0
- package/dist/esm/wrappers-registry-BNxAZZWS.js.map +1 -0
- package/package.json +33 -6
- package/dist/cjs/activity.cjs +0 -2
- package/dist/cjs/activity.cjs.map +0 -1
- package/dist/cjs/cleartext.cjs +0 -2
- package/dist/cjs/cleartext.cjs.map +0 -1
- package/dist/esm/activity-BAFx7EMt.js +0 -2
- package/dist/esm/activity-BAFx7EMt.js.map +0 -1
- package/dist/esm/assertions-BARApuMj.js +0 -2
- 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/relayer-C6u3eOlN.js +0 -2
- package/dist/esm/relayer-C6u3eOlN.js.map +0 -1
- package/dist/esm/relayer-sdk-DPqytEbO.d.ts +0 -44
- package/dist/esm/relayer-sdk.types-CGfXwKcB.d.ts +0 -528
- package/dist/esm/relayer-utils-BeoTNDM4.js +0 -2
- package/dist/esm/relayer-utils-BeoTNDM4.js.map +0 -1
- package/dist/esm/wrappers-registry-Ckwd2j6g.js +0 -2
- package/dist/esm/wrappers-registry-Ckwd2j6g.js.map +0 -1
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { a as EncryptParams, l as PublicDecryptResult, n as DelegatedUserDecryptParams, o as EncryptResult, p as UserDecryptParams, r as EIP712TypedData, s as Handle, t as ClearValueType } from "./relayer-sdk.types-CGfXwKcB.js";
|
|
2
|
-
import { Address, Hex } from "viem";
|
|
3
|
-
import { InputProofBytesType, KeypairType, KmsDelegatedUserDecryptEIP712Type, ZKProofLike } from "@zama-fhe/relayer-sdk/bundle";
|
|
4
|
-
|
|
5
|
-
//#region src/relayer/relayer-sdk.d.ts
|
|
6
|
-
/**
|
|
7
|
-
* Interface for FHE relayer operations.
|
|
8
|
-
* Implemented by `RelayerWeb` (browser, via Web Worker + WASM) and `RelayerNode` (Node.js, direct).
|
|
9
|
-
*/
|
|
10
|
-
interface RelayerSDK {
|
|
11
|
-
/** Generate an FHE keypair (public + private key). */
|
|
12
|
-
generateKeypair(): Promise<KeypairType<Hex>>;
|
|
13
|
-
/** Create EIP-712 typed data for signing an FHE decrypt credential. */
|
|
14
|
-
createEIP712(publicKey: Hex, contractAddresses: Address[], startTimestamp: number, durationDays?: number): Promise<EIP712TypedData>;
|
|
15
|
-
/** Encrypt plaintext values into FHE ciphertexts. */
|
|
16
|
-
encrypt(params: EncryptParams): Promise<EncryptResult>;
|
|
17
|
-
/** Decrypt FHE ciphertext handles using the user's own credentials. */
|
|
18
|
-
userDecrypt(params: UserDecryptParams): Promise<Readonly<Record<Handle, ClearValueType>>>;
|
|
19
|
-
/** Decrypt FHE handles using the network public key (no credential needed). */
|
|
20
|
-
publicDecrypt(handles: Handle[]): Promise<PublicDecryptResult>;
|
|
21
|
-
/** Create EIP-712 typed data for a delegated user decrypt credential. */
|
|
22
|
-
createDelegatedUserDecryptEIP712(publicKey: Hex, contractAddresses: Address[], delegatorAddress: Address, startTimestamp: number, durationDays?: number): Promise<KmsDelegatedUserDecryptEIP712Type>;
|
|
23
|
-
/** Decrypt FHE handles using delegated user credentials. */
|
|
24
|
-
delegatedUserDecrypt(params: DelegatedUserDecryptParams): Promise<Readonly<Record<Handle, ClearValueType>>>;
|
|
25
|
-
/** Submit a ZK proof for on-chain verification. */
|
|
26
|
-
requestZKProofVerification(zkProof: ZKProofLike): Promise<InputProofBytesType>;
|
|
27
|
-
/** Fetch the FHE network public key. Returns `null` if not available. */
|
|
28
|
-
getPublicKey(): Promise<{
|
|
29
|
-
publicKeyId: string;
|
|
30
|
-
publicKey: Uint8Array;
|
|
31
|
-
} | null>;
|
|
32
|
-
/** Fetch FHE public parameters for a given bit size. Returns `null` if not available. */
|
|
33
|
-
getPublicParams(bits: number): Promise<{
|
|
34
|
-
publicParams: Uint8Array;
|
|
35
|
-
publicParamsId: string;
|
|
36
|
-
} | null>;
|
|
37
|
-
/** Return the ACL contract address for the current chain. */
|
|
38
|
-
getAclAddress(): Promise<Address>;
|
|
39
|
-
/** Terminate the relayer backend and release resources. */
|
|
40
|
-
terminate(): void;
|
|
41
|
-
}
|
|
42
|
-
//#endregion
|
|
43
|
-
export { RelayerSDK as t };
|
|
44
|
-
//# sourceMappingURL=relayer-sdk-DPqytEbO.d.ts.map
|
|
@@ -1,528 +0,0 @@
|
|
|
1
|
-
import { Abi, Address, ContractFunctionArgs, ContractFunctionName, ContractFunctionReturnType, Hex } from "viem";
|
|
2
|
-
import * as SDK from "@zama-fhe/relayer-sdk/bundle";
|
|
3
|
-
import { FhevmInstanceConfig, InputProofBytesType, KmsDelegatedUserDecryptEIP712Type, ZKProofLike } from "@zama-fhe/relayer-sdk/bundle";
|
|
4
|
-
|
|
5
|
-
//#region src/worker/worker.types.d.ts
|
|
6
|
-
/**
|
|
7
|
-
* Optional logger for worker client observability.
|
|
8
|
-
* Pass to `WorkerClientConfig` or `NodeWorkerClientConfig` to observe
|
|
9
|
-
* request lifecycle (start, success, error, timeout).
|
|
10
|
-
*/
|
|
11
|
-
interface GenericLogger {
|
|
12
|
-
info: (message: string, data?: Record<string, unknown>) => void;
|
|
13
|
-
debug: (message: string, data?: Record<string, unknown>) => void;
|
|
14
|
-
warn: (message: string, data?: Record<string, unknown>) => void;
|
|
15
|
-
error: (message: string, data?: Record<string, unknown>) => void;
|
|
16
|
-
}
|
|
17
|
-
type WorkerRequestType = "INIT" | "NODE_INIT" | "UPDATE_CSRF" | "ENCRYPT" | "USER_DECRYPT" | "PUBLIC_DECRYPT" | "GENERATE_KEYPAIR" | "CREATE_EIP712" | "CREATE_DELEGATED_EIP712" | "DELEGATED_USER_DECRYPT" | "REQUEST_ZK_PROOF_VERIFICATION" | "GET_PUBLIC_KEY" | "GET_PUBLIC_PARAMS";
|
|
18
|
-
interface BaseRequest {
|
|
19
|
-
id: string;
|
|
20
|
-
type: WorkerRequestType;
|
|
21
|
-
}
|
|
22
|
-
interface InitRequest extends BaseRequest {
|
|
23
|
-
type: "INIT";
|
|
24
|
-
payload: {
|
|
25
|
-
cdnUrl: string;
|
|
26
|
-
fhevmConfig: FhevmInstanceConfig;
|
|
27
|
-
csrfToken: string; /** Expected SHA-384 hex digest for integrity verification. */
|
|
28
|
-
integrity?: string; /** Number of WASM threads for parallel FHE operations. */
|
|
29
|
-
thread?: number;
|
|
30
|
-
};
|
|
31
|
-
}
|
|
32
|
-
interface NodeInitRequest extends BaseRequest {
|
|
33
|
-
type: "NODE_INIT";
|
|
34
|
-
payload: {
|
|
35
|
-
fhevmConfig: FhevmInstanceConfig;
|
|
36
|
-
};
|
|
37
|
-
}
|
|
38
|
-
interface UpdateCsrfRequest extends BaseRequest {
|
|
39
|
-
type: "UPDATE_CSRF";
|
|
40
|
-
payload: {
|
|
41
|
-
csrfToken: string;
|
|
42
|
-
};
|
|
43
|
-
}
|
|
44
|
-
interface EncryptRequest extends BaseRequest {
|
|
45
|
-
type: "ENCRYPT";
|
|
46
|
-
payload: {
|
|
47
|
-
values: EncryptInput[];
|
|
48
|
-
contractAddress: Address;
|
|
49
|
-
userAddress: Address;
|
|
50
|
-
};
|
|
51
|
-
}
|
|
52
|
-
interface UserDecryptRequest extends BaseRequest {
|
|
53
|
-
type: "USER_DECRYPT";
|
|
54
|
-
payload: {
|
|
55
|
-
handles: Handle[];
|
|
56
|
-
contractAddress: Address;
|
|
57
|
-
signedContractAddresses: Address[];
|
|
58
|
-
privateKey: Hex;
|
|
59
|
-
publicKey: Hex;
|
|
60
|
-
signature: Hex;
|
|
61
|
-
signerAddress: Address;
|
|
62
|
-
startTimestamp: number;
|
|
63
|
-
durationDays: number;
|
|
64
|
-
};
|
|
65
|
-
}
|
|
66
|
-
interface PublicDecryptRequest extends BaseRequest {
|
|
67
|
-
type: "PUBLIC_DECRYPT";
|
|
68
|
-
payload: {
|
|
69
|
-
handles: Handle[];
|
|
70
|
-
};
|
|
71
|
-
}
|
|
72
|
-
interface GenerateKeypairRequest extends BaseRequest {
|
|
73
|
-
type: "GENERATE_KEYPAIR";
|
|
74
|
-
payload: Record<string, never>;
|
|
75
|
-
}
|
|
76
|
-
interface CreateEIP712Request extends BaseRequest {
|
|
77
|
-
type: "CREATE_EIP712";
|
|
78
|
-
payload: {
|
|
79
|
-
publicKey: Hex;
|
|
80
|
-
contractAddresses: Address[];
|
|
81
|
-
startTimestamp: number;
|
|
82
|
-
durationDays: number;
|
|
83
|
-
};
|
|
84
|
-
}
|
|
85
|
-
interface CreateDelegatedEIP712Request extends BaseRequest {
|
|
86
|
-
type: "CREATE_DELEGATED_EIP712";
|
|
87
|
-
payload: {
|
|
88
|
-
publicKey: Hex;
|
|
89
|
-
contractAddresses: Address[];
|
|
90
|
-
delegatorAddress: Address;
|
|
91
|
-
startTimestamp: number;
|
|
92
|
-
durationDays: number;
|
|
93
|
-
};
|
|
94
|
-
}
|
|
95
|
-
interface DelegatedUserDecryptRequest extends BaseRequest {
|
|
96
|
-
type: "DELEGATED_USER_DECRYPT";
|
|
97
|
-
payload: {
|
|
98
|
-
handles: Handle[];
|
|
99
|
-
contractAddress: Address;
|
|
100
|
-
signedContractAddresses: Address[];
|
|
101
|
-
privateKey: Hex;
|
|
102
|
-
publicKey: Hex;
|
|
103
|
-
signature: Hex;
|
|
104
|
-
delegatorAddress: Address;
|
|
105
|
-
delegateAddress: Address;
|
|
106
|
-
startTimestamp: number;
|
|
107
|
-
durationDays: number;
|
|
108
|
-
};
|
|
109
|
-
}
|
|
110
|
-
interface RequestZKProofVerificationRequest extends BaseRequest {
|
|
111
|
-
type: "REQUEST_ZK_PROOF_VERIFICATION";
|
|
112
|
-
payload: {
|
|
113
|
-
zkProof: ZKProofLike;
|
|
114
|
-
};
|
|
115
|
-
}
|
|
116
|
-
interface GetPublicKeyRequest extends BaseRequest {
|
|
117
|
-
type: "GET_PUBLIC_KEY";
|
|
118
|
-
payload: Record<string, never>;
|
|
119
|
-
}
|
|
120
|
-
interface GetPublicParamsRequest extends BaseRequest {
|
|
121
|
-
type: "GET_PUBLIC_PARAMS";
|
|
122
|
-
payload: {
|
|
123
|
-
bits: number;
|
|
124
|
-
};
|
|
125
|
-
}
|
|
126
|
-
type WorkerRequest = InitRequest | NodeInitRequest | UpdateCsrfRequest | EncryptRequest | UserDecryptRequest | PublicDecryptRequest | GenerateKeypairRequest | CreateEIP712Request | CreateDelegatedEIP712Request | DelegatedUserDecryptRequest | RequestZKProofVerificationRequest | GetPublicKeyRequest | GetPublicParamsRequest;
|
|
127
|
-
type EncryptPayload = EncryptRequest["payload"];
|
|
128
|
-
type UserDecryptPayload = UserDecryptRequest["payload"];
|
|
129
|
-
type DelegatedUserDecryptPayload = DelegatedUserDecryptRequest["payload"];
|
|
130
|
-
type CreateEIP712Payload = CreateEIP712Request["payload"];
|
|
131
|
-
type CreateDelegatedEIP712Payload = CreateDelegatedEIP712Request["payload"];
|
|
132
|
-
interface BaseResponse {
|
|
133
|
-
id: string;
|
|
134
|
-
type: WorkerRequestType;
|
|
135
|
-
}
|
|
136
|
-
interface SuccessResponse<T> extends BaseResponse {
|
|
137
|
-
success: true;
|
|
138
|
-
data: T;
|
|
139
|
-
}
|
|
140
|
-
interface ErrorResponse extends BaseResponse {
|
|
141
|
-
success: false;
|
|
142
|
-
error: string;
|
|
143
|
-
/** HTTP status code from the relayer, when available. */
|
|
144
|
-
statusCode?: number;
|
|
145
|
-
}
|
|
146
|
-
type WorkerResponse<T> = SuccessResponse<T> | ErrorResponse;
|
|
147
|
-
interface EncryptResponseData {
|
|
148
|
-
handles: Uint8Array[];
|
|
149
|
-
inputProof: Uint8Array;
|
|
150
|
-
}
|
|
151
|
-
interface UserDecryptResponseData {
|
|
152
|
-
clearValues: Record<Handle, ClearValueType>;
|
|
153
|
-
}
|
|
154
|
-
interface PublicDecryptResponseData {
|
|
155
|
-
clearValues: Readonly<Record<Handle, ClearValueType>>;
|
|
156
|
-
abiEncodedClearValues: Hex;
|
|
157
|
-
decryptionProof: Hex;
|
|
158
|
-
}
|
|
159
|
-
interface GenerateKeypairResponseData {
|
|
160
|
-
publicKey: Hex;
|
|
161
|
-
privateKey: Hex;
|
|
162
|
-
}
|
|
163
|
-
interface CreateEIP712ResponseData {
|
|
164
|
-
domain: {
|
|
165
|
-
name: string;
|
|
166
|
-
version: string;
|
|
167
|
-
chainId: number;
|
|
168
|
-
verifyingContract: Address;
|
|
169
|
-
};
|
|
170
|
-
types: {
|
|
171
|
-
UserDecryptRequestVerification: {
|
|
172
|
-
name: string;
|
|
173
|
-
type: string;
|
|
174
|
-
}[];
|
|
175
|
-
};
|
|
176
|
-
message: {
|
|
177
|
-
publicKey: Hex;
|
|
178
|
-
contractAddresses: Address[];
|
|
179
|
-
startTimestamp: bigint;
|
|
180
|
-
durationDays: bigint;
|
|
181
|
-
extraData: Hex;
|
|
182
|
-
};
|
|
183
|
-
}
|
|
184
|
-
type CreateDelegatedEIP712ResponseData = KmsDelegatedUserDecryptEIP712Type;
|
|
185
|
-
interface DelegatedUserDecryptResponseData {
|
|
186
|
-
clearValues: Record<Handle, ClearValueType>;
|
|
187
|
-
}
|
|
188
|
-
type RequestZKProofVerificationResponseData = InputProofBytesType;
|
|
189
|
-
interface GetPublicKeyResponseData {
|
|
190
|
-
result: {
|
|
191
|
-
publicKeyId: string;
|
|
192
|
-
publicKey: Uint8Array;
|
|
193
|
-
} | null;
|
|
194
|
-
}
|
|
195
|
-
interface GetPublicParamsResponseData {
|
|
196
|
-
result: {
|
|
197
|
-
publicParams: Uint8Array;
|
|
198
|
-
publicParamsId: string;
|
|
199
|
-
} | null;
|
|
200
|
-
}
|
|
201
|
-
//#endregion
|
|
202
|
-
//#region src/types/contract.d.ts
|
|
203
|
-
/** ABI type accepted by contract call builders. Supports both typed and untyped ABIs. */
|
|
204
|
-
type ContractAbi = Abi | readonly unknown[];
|
|
205
|
-
/** Extract read-only function names (`pure` | `view`) from a contract ABI. */
|
|
206
|
-
type ReadFunctionName<TAbi extends ContractAbi = ContractAbi> = ContractFunctionName<TAbi, "pure" | "view">;
|
|
207
|
-
/** Extract write function names (`nonpayable` | `payable`) from a contract ABI. */
|
|
208
|
-
type WriteFunctionName<TAbi extends ContractAbi = ContractAbi> = ContractFunctionName<TAbi, "nonpayable" | "payable">;
|
|
209
|
-
/** Infer the argument tuple for a read-only contract function. */
|
|
210
|
-
type ReadContractArgs<TAbi extends ContractAbi = ContractAbi, TFunctionName extends ReadFunctionName<TAbi> = ReadFunctionName<TAbi>> = ContractFunctionArgs<TAbi, "pure" | "view", TFunctionName>;
|
|
211
|
-
/** Infer the argument tuple for a write contract function. */
|
|
212
|
-
type WriteContractArgs<TAbi extends ContractAbi = ContractAbi, TFunctionName extends WriteFunctionName<TAbi> = WriteFunctionName<TAbi>> = ContractFunctionArgs<TAbi, "nonpayable" | "payable", TFunctionName>;
|
|
213
|
-
/** Infer the return type for a read-only contract function. */
|
|
214
|
-
type ReadContractReturnType<TAbi extends ContractAbi = ContractAbi, TFunctionName extends ReadFunctionName<TAbi> = ReadFunctionName<TAbi>, TArgs extends ReadContractArgs<TAbi, TFunctionName> = ReadContractArgs<TAbi, TFunctionName>> = ContractFunctionReturnType<TAbi, "pure" | "view", TFunctionName, TArgs>;
|
|
215
|
-
/**
|
|
216
|
-
* Typed read-contract configuration.
|
|
217
|
-
* Matches the shape returned by read contract builders in `src/contracts/`.
|
|
218
|
-
*/
|
|
219
|
-
interface ReadContractConfig<TAbi extends ContractAbi = ContractAbi, TFunctionName extends ReadFunctionName<TAbi> = ReadFunctionName<TAbi>, TArgs extends ReadContractArgs<TAbi, TFunctionName> = ReadContractArgs<TAbi, TFunctionName>> {
|
|
220
|
-
/** Target contract address. */
|
|
221
|
-
readonly address: Address;
|
|
222
|
-
/** ABI fragment for the function being called. */
|
|
223
|
-
readonly abi: TAbi;
|
|
224
|
-
/** Solidity function name. */
|
|
225
|
-
readonly functionName: TFunctionName;
|
|
226
|
-
/** Contract call arguments inferred from the ABI and function name. */
|
|
227
|
-
readonly args: TArgs;
|
|
228
|
-
}
|
|
229
|
-
/**
|
|
230
|
-
* Typed write-contract configuration.
|
|
231
|
-
* Matches the shape returned by write contract builders in `src/contracts/`.
|
|
232
|
-
*/
|
|
233
|
-
interface WriteContractConfig<TAbi extends ContractAbi = ContractAbi, TFunctionName extends WriteFunctionName<TAbi> = WriteFunctionName<TAbi>, TArgs extends WriteContractArgs<TAbi, TFunctionName> = WriteContractArgs<TAbi, TFunctionName>> {
|
|
234
|
-
/** Target contract address. */
|
|
235
|
-
readonly address: Address;
|
|
236
|
-
/** ABI fragment for the function being called. */
|
|
237
|
-
readonly abi: TAbi;
|
|
238
|
-
/** Solidity function name. */
|
|
239
|
-
readonly functionName: TFunctionName;
|
|
240
|
-
/** Contract call arguments inferred from the ABI and function name. */
|
|
241
|
-
readonly args: TArgs;
|
|
242
|
-
/** Native value to send with the transaction (for payable functions). */
|
|
243
|
-
readonly value?: bigint;
|
|
244
|
-
/** Gas limit override. */
|
|
245
|
-
readonly gas?: bigint;
|
|
246
|
-
}
|
|
247
|
-
//#endregion
|
|
248
|
-
//#region src/types/transaction.d.ts
|
|
249
|
-
/** Framework-agnostic log shape compatible with any Ethereum provider. */
|
|
250
|
-
interface RawLog {
|
|
251
|
-
/** Indexed event topics (topic[0] is the event signature hash). */
|
|
252
|
-
readonly topics: readonly Hex[];
|
|
253
|
-
/** ABI-encoded non-indexed event data. */
|
|
254
|
-
readonly data: Hex;
|
|
255
|
-
}
|
|
256
|
-
/** Framework-agnostic transaction receipt (only the fields the SDK needs). */
|
|
257
|
-
interface TransactionReceipt {
|
|
258
|
-
/** Event logs emitted during the transaction. */
|
|
259
|
-
readonly logs: readonly RawLog[];
|
|
260
|
-
}
|
|
261
|
-
/** Result of a write operation: the tx hash and its mined receipt. */
|
|
262
|
-
interface TransactionResult {
|
|
263
|
-
/** The transaction hash. */
|
|
264
|
-
txHash: Hex;
|
|
265
|
-
/** The mined transaction receipt. */
|
|
266
|
-
receipt: TransactionReceipt;
|
|
267
|
-
}
|
|
268
|
-
//#endregion
|
|
269
|
-
//#region src/types/signer.d.ts
|
|
270
|
-
/** Callbacks for signer lifecycle events (wallet disconnect, account switch). */
|
|
271
|
-
interface SignerLifecycleCallbacks {
|
|
272
|
-
/** Called when the wallet disconnects. */
|
|
273
|
-
onDisconnect?: () => void;
|
|
274
|
-
/** Called when the active account changes. */
|
|
275
|
-
onAccountChange?: (newAddress: Address) => void;
|
|
276
|
-
/** Called when the connected chain changes. */
|
|
277
|
-
onChainChange?: (newChainId: number) => void;
|
|
278
|
-
}
|
|
279
|
-
/**
|
|
280
|
-
* Framework-agnostic signer interface.
|
|
281
|
-
* Wallet devs implement this with their library of choice.
|
|
282
|
-
* The React SDK ships pre-built adapters for wagmi/viem/ethers.
|
|
283
|
-
*/
|
|
284
|
-
interface GenericSigner {
|
|
285
|
-
/** Return the chain ID of the connected network. */
|
|
286
|
-
getChainId(): Promise<number>;
|
|
287
|
-
/** The connected wallet address. */
|
|
288
|
-
getAddress: () => Promise<Address>;
|
|
289
|
-
/** Sign EIP-712 typed data (used for decrypt authorization). */
|
|
290
|
-
signTypedData(typedData: EIP712TypedData): Promise<Hex>;
|
|
291
|
-
/** Send a write transaction and return the tx hash. */
|
|
292
|
-
writeContract<const TAbi extends ContractAbi, TFunctionName extends WriteFunctionName<TAbi>, const TArgs extends WriteContractArgs<TAbi, TFunctionName>>(config: WriteContractConfig<TAbi, TFunctionName, TArgs>): Promise<Hex>;
|
|
293
|
-
/** Execute a read-only call and return the decoded result. */
|
|
294
|
-
readContract<const TAbi extends ContractAbi, TFunctionName extends ReadFunctionName<TAbi>, const TArgs extends ReadContractArgs<TAbi, TFunctionName>>(config: ReadContractConfig<TAbi, TFunctionName, TArgs>): Promise<ReadContractReturnType<TAbi, TFunctionName, TArgs>>;
|
|
295
|
-
/** Wait for a transaction to be mined and return its receipt. */
|
|
296
|
-
waitForTransactionReceipt(hash: Hex): Promise<TransactionReceipt>;
|
|
297
|
-
/**
|
|
298
|
-
* Return the latest block timestamp in seconds.
|
|
299
|
-
* Used by {@link ReadonlyToken.isDelegated} to compare delegation expiry
|
|
300
|
-
* against the chain clock instead of the local clock.
|
|
301
|
-
*/
|
|
302
|
-
getBlockTimestamp: () => Promise<bigint>;
|
|
303
|
-
/**
|
|
304
|
-
* Subscribe to wallet lifecycle events (disconnect, account change, chain change).
|
|
305
|
-
* Returns an unsubscribe function.
|
|
306
|
-
*
|
|
307
|
-
* Optional — server-side signers or custom implementations that don't
|
|
308
|
-
* support lifecycle events can omit this method entirely.
|
|
309
|
-
*/
|
|
310
|
-
subscribe?: (callbacks: SignerLifecycleCallbacks) => () => void;
|
|
311
|
-
}
|
|
312
|
-
//#endregion
|
|
313
|
-
//#region src/types/storage.d.ts
|
|
314
|
-
/**
|
|
315
|
-
* Pluggable key-value store for persisting FHE credentials.
|
|
316
|
-
*
|
|
317
|
-
* The SDK stores objects directly (not JSON strings). Implementations must
|
|
318
|
-
* preserve value types through round-trips — e.g. `IndexedDBStorage` uses
|
|
319
|
-
* structured clone, `MemoryStorage` stores values as-is.
|
|
320
|
-
*/
|
|
321
|
-
interface GenericStorage {
|
|
322
|
-
/** Retrieve a value by key. Returns `null` if the key does not exist. */
|
|
323
|
-
get<T = unknown>(key: string): Promise<T | null>;
|
|
324
|
-
/** Store a value under the given key, overwriting any existing entry. */
|
|
325
|
-
set<T = unknown>(key: string, value: T): Promise<void>;
|
|
326
|
-
/** Remove the entry for the given key (no-op if absent). */
|
|
327
|
-
delete(key: string): Promise<void>;
|
|
328
|
-
}
|
|
329
|
-
//#endregion
|
|
330
|
-
//#region src/types/credentials.d.ts
|
|
331
|
-
/** Stored FHE credential data (serialized as JSON in the credential store). */
|
|
332
|
-
interface StoredCredentials {
|
|
333
|
-
/** FHE public key (hex-encoded). */
|
|
334
|
-
publicKey: Hex;
|
|
335
|
-
/** FHE private key (hex-encoded, encrypted at rest via AES-GCM). */
|
|
336
|
-
privateKey: Hex;
|
|
337
|
-
/** EIP-712 signature authorizing decryption. */
|
|
338
|
-
signature: Hex;
|
|
339
|
-
/** Contract addresses this credential is authorized for. */
|
|
340
|
-
contractAddresses: Address[];
|
|
341
|
-
/** Unix timestamp (seconds) when the credential became valid. */
|
|
342
|
-
startTimestamp: number;
|
|
343
|
-
/** Number of days the credential remains valid. */
|
|
344
|
-
durationDays: number;
|
|
345
|
-
}
|
|
346
|
-
/** Stored FHE credential data for delegated decryption. */
|
|
347
|
-
interface DelegatedStoredCredentials extends StoredCredentials {
|
|
348
|
-
/** The address that granted delegation rights. */
|
|
349
|
-
delegatorAddress: Address;
|
|
350
|
-
/** The delegate address performing decryption on behalf of the delegator. */
|
|
351
|
-
delegateAddress: Address;
|
|
352
|
-
}
|
|
353
|
-
//#endregion
|
|
354
|
-
//#region src/types/callbacks.d.ts
|
|
355
|
-
/** Progress callbacks for multi-step unshield operations. */
|
|
356
|
-
interface UnshieldCallbacks {
|
|
357
|
-
/** Fired after the unwrap transaction is submitted. */
|
|
358
|
-
onUnwrapSubmitted?: (txHash: Hex) => void;
|
|
359
|
-
/** Fired when the finalization step begins (receipt parsed, about to finalize). */
|
|
360
|
-
onFinalizing?: () => void;
|
|
361
|
-
/** Fired after the finalize transaction is submitted. */
|
|
362
|
-
onFinalizeSubmitted?: (txHash: Hex) => void;
|
|
363
|
-
}
|
|
364
|
-
/** Progress callbacks for multi-step shield operations. */
|
|
365
|
-
interface ShieldCallbacks {
|
|
366
|
-
/** Fired after the ERC-20 approval transaction is submitted (skipped when `approvalStrategy: "skip"`). */
|
|
367
|
-
onApprovalSubmitted?: (txHash: Hex) => void;
|
|
368
|
-
/** Fired after the shield (wrap) transaction is submitted. */
|
|
369
|
-
onShieldSubmitted?: (txHash: Hex) => void;
|
|
370
|
-
}
|
|
371
|
-
/** Progress callbacks for multi-step confidential transfer operations. */
|
|
372
|
-
interface TransferCallbacks {
|
|
373
|
-
/** Fired after FHE encryption of the transfer amount completes. */
|
|
374
|
-
onEncryptComplete?: () => void;
|
|
375
|
-
/** Fired after the transfer transaction is submitted. */
|
|
376
|
-
onTransferSubmitted?: (txHash: Hex) => void;
|
|
377
|
-
}
|
|
378
|
-
//#endregion
|
|
379
|
-
//#region src/types/options.d.ts
|
|
380
|
-
/** Options for {@link ConfidentialToken.confidentialTransfer}. */
|
|
381
|
-
interface TransferOptions extends TransferCallbacks {
|
|
382
|
-
/** Skip confidential balance validation (e.g. for smart wallets). Default: `false`. */
|
|
383
|
-
skipBalanceCheck?: boolean;
|
|
384
|
-
}
|
|
385
|
-
/** Options for {@link Token.shield}. */
|
|
386
|
-
interface ShieldOptions extends ShieldCallbacks {
|
|
387
|
-
/** ERC-20 approval strategy: `"exact"` approves only `amount`, `"max"` approves unlimited, `"skip"` assumes pre-existing approval. Default: `"exact"`. */
|
|
388
|
-
approvalStrategy?: "max" | "exact" | "skip";
|
|
389
|
-
/** Recipient address for the shielded tokens. Defaults to the connected wallet. */
|
|
390
|
-
to?: Address;
|
|
391
|
-
}
|
|
392
|
-
/** Options for {@link ConfidentialToken.unshield}. */
|
|
393
|
-
interface UnshieldOptions extends UnshieldCallbacks {
|
|
394
|
-
/** Skip confidential balance validation (e.g. for smart wallets). Default: `false`. */
|
|
395
|
-
skipBalanceCheck?: boolean;
|
|
396
|
-
}
|
|
397
|
-
//#endregion
|
|
398
|
-
//#region src/relayer/relayer-sdk.types.d.ts
|
|
399
|
-
/** Network configuration for the Relayer SDK */
|
|
400
|
-
type NetworkType = "hardhat" | "sepolia" | "mainnet";
|
|
401
|
-
/** Security options for RelayerWeb. */
|
|
402
|
-
interface RelayerWebSecurityConfig {
|
|
403
|
-
/** Resolve the current CSRF token. Called before each authenticated network request. */
|
|
404
|
-
getCsrfToken?: () => string;
|
|
405
|
-
/** Verify SHA-384 integrity of the CDN bundle. Defaults to `true`. Set to `false` only in test environments with mocked SDK scripts. */
|
|
406
|
-
integrityCheck?: boolean;
|
|
407
|
-
}
|
|
408
|
-
/** Configuration for RelayerWeb (browser backend) initialization. */
|
|
409
|
-
interface RelayerWebConfig {
|
|
410
|
-
transports: Record<number, Partial<SDK.FhevmInstanceConfig>>;
|
|
411
|
-
/** Resolve the current chain ID. Called lazily before each operation; the worker is re-initialized when the value changes. */
|
|
412
|
-
getChainId: () => Promise<number>;
|
|
413
|
-
/** Security options (CSRF, CDN integrity). */
|
|
414
|
-
security?: RelayerWebSecurityConfig;
|
|
415
|
-
/** Optional logger for observing worker lifecycle and request timing. */
|
|
416
|
-
logger?: GenericLogger;
|
|
417
|
-
/**
|
|
418
|
-
* Number of WASM threads for parallel FHE operations inside the Web Worker.
|
|
419
|
-
* Uses `wasm-bindgen-rayon` under the hood via `SharedArrayBuffer`.
|
|
420
|
-
*
|
|
421
|
-
* **Requirements:** The page must be served with COOP/COEP headers:
|
|
422
|
-
* - `Cross-Origin-Opener-Policy: same-origin`
|
|
423
|
-
* - `Cross-Origin-Embedder-Policy: require-corp`
|
|
424
|
-
*
|
|
425
|
-
* 4–8 threads is the practical sweet spot; beyond that, diminishing returns
|
|
426
|
-
* and higher memory usage on low-end devices.
|
|
427
|
-
*
|
|
428
|
-
* When omitted, the relayer SDK uses its default (single-threaded).
|
|
429
|
-
*/
|
|
430
|
-
threads?: number;
|
|
431
|
-
/** Called whenever the SDK status changes (e.g. idle → initializing → ready). */
|
|
432
|
-
onStatusChange?: (status: RelayerSDKStatus, error?: Error) => void;
|
|
433
|
-
/**
|
|
434
|
-
* Persistent storage for caching FHE public key and params across sessions.
|
|
435
|
-
*
|
|
436
|
-
* Defaults to `new IndexedDBStorage("FheArtifactCache", 1, "artifacts")`.
|
|
437
|
-
* Pass a custom `IndexedDBStorage` instance to configure the database name,
|
|
438
|
-
* version, or store name. FHE public params can be several MB — avoid
|
|
439
|
-
* `localStorage`-backed storage which caps at ~5 MB.
|
|
440
|
-
*
|
|
441
|
-
* **Not to be confused with `ZamaProvider.storage`** which stores credentials.
|
|
442
|
-
*/
|
|
443
|
-
fheArtifactStorage?: GenericStorage;
|
|
444
|
-
/** Cache TTL in seconds for FHE public material. Default: 86 400 (24 h). Set to 0 to revalidate on every operation. Ignored when storage is not set. */
|
|
445
|
-
fheArtifactCacheTTL?: number;
|
|
446
|
-
}
|
|
447
|
-
/** Result from encryption operation */
|
|
448
|
-
interface EncryptResult {
|
|
449
|
-
handles: Uint8Array[];
|
|
450
|
-
inputProof: Uint8Array;
|
|
451
|
-
}
|
|
452
|
-
/** Canonical SDK type for encrypted ciphertext handles (`bytes32` values). */
|
|
453
|
-
type Handle = `0x${string}`;
|
|
454
|
-
/** Decrypted value type — one of bigint, boolean, or hex-encoded bytes. */
|
|
455
|
-
type ClearValueType = bigint | boolean | `0x${string}`;
|
|
456
|
-
/** A single value to encrypt with its FHE type. */
|
|
457
|
-
type EncryptInput = {
|
|
458
|
-
value: boolean | bigint;
|
|
459
|
-
type: "ebool";
|
|
460
|
-
} | {
|
|
461
|
-
value: bigint;
|
|
462
|
-
type: Exclude<SDK.FheTypeName, "ebool" | "eaddress">;
|
|
463
|
-
} | {
|
|
464
|
-
value: Address;
|
|
465
|
-
type: "eaddress";
|
|
466
|
-
};
|
|
467
|
-
/** Parameters for encryption */
|
|
468
|
-
interface EncryptParams {
|
|
469
|
-
/** Typed inputs for encryption. Each value must specify its FHE type. */
|
|
470
|
-
values: EncryptInput[];
|
|
471
|
-
contractAddress: Address;
|
|
472
|
-
userAddress: Address;
|
|
473
|
-
}
|
|
474
|
-
/** Parameters for user decryption */
|
|
475
|
-
interface UserDecryptParams {
|
|
476
|
-
handles: Handle[];
|
|
477
|
-
contractAddress: Address;
|
|
478
|
-
signedContractAddresses: Address[];
|
|
479
|
-
privateKey: Hex;
|
|
480
|
-
publicKey: Hex;
|
|
481
|
-
signature: Hex;
|
|
482
|
-
signerAddress: Address;
|
|
483
|
-
startTimestamp: number;
|
|
484
|
-
durationDays: number;
|
|
485
|
-
}
|
|
486
|
-
/** Result from public decryption */
|
|
487
|
-
type PublicDecryptResult = Omit<SDK.PublicDecryptResults, "clearValues"> & {
|
|
488
|
-
clearValues: Readonly<Record<Handle, ClearValueType>>;
|
|
489
|
-
};
|
|
490
|
-
/** EIP712 typed data structure */
|
|
491
|
-
interface EIP712TypedData {
|
|
492
|
-
domain: {
|
|
493
|
-
name: string;
|
|
494
|
-
version: string;
|
|
495
|
-
chainId: number;
|
|
496
|
-
verifyingContract: Address;
|
|
497
|
-
};
|
|
498
|
-
types: Record<string, readonly {
|
|
499
|
-
readonly name: string;
|
|
500
|
-
readonly type: string;
|
|
501
|
-
}[]>;
|
|
502
|
-
primaryType?: string;
|
|
503
|
-
message: {
|
|
504
|
-
publicKey: Hex;
|
|
505
|
-
contractAddresses: readonly Address[];
|
|
506
|
-
startTimestamp: bigint;
|
|
507
|
-
durationDays: bigint;
|
|
508
|
-
extraData: Hex;
|
|
509
|
-
};
|
|
510
|
-
}
|
|
511
|
-
/** Parameters for delegated user decryption */
|
|
512
|
-
interface DelegatedUserDecryptParams {
|
|
513
|
-
handles: Handle[];
|
|
514
|
-
contractAddress: Address;
|
|
515
|
-
signedContractAddresses: Address[];
|
|
516
|
-
privateKey: Hex;
|
|
517
|
-
publicKey: Hex;
|
|
518
|
-
signature: Hex;
|
|
519
|
-
delegatorAddress: Address;
|
|
520
|
-
delegateAddress: Address;
|
|
521
|
-
startTimestamp: number;
|
|
522
|
-
durationDays: number;
|
|
523
|
-
}
|
|
524
|
-
/** SDK status */
|
|
525
|
-
type RelayerSDKStatus = "idle" | "initializing" | "ready" | "error";
|
|
526
|
-
//#endregion
|
|
527
|
-
export { GetPublicKeyRequest as $, ReadContractConfig as A, CreateEIP712Payload as B, GenericSigner as C, TransactionResult as D, TransactionReceipt as E, WriteFunctionName as F, DelegatedUserDecryptResponseData as G, CreateEIP712ResponseData as H, BaseRequest as I, EncryptResponseData as J, EncryptPayload as K, CreateDelegatedEIP712Payload as L, ReadFunctionName as M, WriteContractArgs as N, ContractAbi as O, WriteContractConfig as P, GenericLogger as Q, CreateDelegatedEIP712Request as R, GenericStorage as S, RawLog as T, DelegatedUserDecryptPayload as U, CreateEIP712Request as V, DelegatedUserDecryptRequest as W, GenerateKeypairRequest as X, ErrorResponse as Y, GenerateKeypairResponseData as Z, ShieldCallbacks as _, EncryptParams as a, PublicDecryptRequest as at, DelegatedStoredCredentials as b, NetworkType as c, RequestZKProofVerificationResponseData as ct, RelayerWebConfig as d, UserDecryptPayload as dt, GetPublicKeyResponseData as et, RelayerWebSecurityConfig as f, UserDecryptRequest as ft, UnshieldOptions as g, WorkerResponse as gt, TransferOptions as h, WorkerRequestType as ht, EncryptInput as i, NodeInitRequest as it, ReadContractReturnType as j, ReadContractArgs as k, PublicDecryptResult as l, SuccessResponse as lt, ShieldOptions as m, WorkerRequest as mt, DelegatedUserDecryptParams as n, GetPublicParamsResponseData as nt, EncryptResult as o, PublicDecryptResponseData as ot, UserDecryptParams as p, UserDecryptResponseData as pt, EncryptRequest as q, EIP712TypedData as r, InitRequest as rt, Handle as s, RequestZKProofVerificationRequest as st, ClearValueType as t, GetPublicParamsRequest as tt, RelayerSDKStatus as u, UpdateCsrfRequest as ut, TransferCallbacks as v, SignerLifecycleCallbacks as w, StoredCredentials as x, UnshieldCallbacks as y, CreateDelegatedEIP712ResponseData as z };
|
|
528
|
-
//# sourceMappingURL=relayer-sdk.types-CGfXwKcB.d.ts.map
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
async function e(e,r=2){let i;for(let a=0;a<=r;a++)try{return await e()}catch(e){if(i=e,a<r&&t(e)){await n(500*2**a);continue}throw e}throw i}function t(e){if(!(e instanceof Error))return!1;let t=e.message.toLowerCase();return t.includes(`timed out`)||t.includes(`timeout`)||t.includes(`econnreset`)||t.includes(`econnrefused`)||t.includes(`network`)||t.includes(`fetch failed`)||t.includes(`socket hang up`)||t.includes(`502`)||t.includes(`503`)||t.includes(`504`)}function n(e){return new Promise(t=>setTimeout(t,e))}const r={chainId:1,gatewayChainId:261131,relayerUrl:`https://relayer.mainnet.zama.org/v2`,network:`https://ethereum-rpc.publicnode.com`,aclContractAddress:`0xcA2E8f1F656CD25C01F05d0b243Ab1ecd4a8ffb6`,kmsContractAddress:`0x77627828a55156b04Ac0DC0eb30467f1a552BB03`,inputVerifierContractAddress:`0xCe0FC2e05CFff1B719EFF7169f7D80Af770c8EA2`,verifyingContractAddressDecryption:`0x0f6024a97684f7d90ddb0fAAD79cB15F2C888D24`,verifyingContractAddressInputVerification:`0xcB1bB072f38bdAF0F328CdEf1Fc6eDa1DF029287`,registryAddress:`0xeb5015fF021DB115aCe010f23F55C2591059bBA0`},i={chainId:11155111,gatewayChainId:10901,relayerUrl:`https://relayer.testnet.zama.org/v2`,network:`https://ethereum-sepolia-rpc.publicnode.com`,aclContractAddress:`0xf0Ffdc93b7E186bC2f8CB3dAA75D86d1930A433D`,kmsContractAddress:`0xbE0E383937d564D7FF0BC3b46c51f0bF8d5C311A`,inputVerifierContractAddress:`0xBBC1fFCdc7C316aAAd72E807D9b0272BE8F84DA0`,verifyingContractAddressDecryption:`0x5D8BD78e2ea6bbE41f26dFe9fdaEAa349e077478`,verifyingContractAddressInputVerification:`0x483b9dE06E4E4C7D35CCf5837A1668487406D955`,registryAddress:`0x2f0750Bbb0A246059d80e94c454586a7F27a128e`},a={chainId:31337,gatewayChainId:10901,relayerUrl:``,network:`http://127.0.0.1:8545`,aclContractAddress:`0x50157CFfD6bBFA2DECe204a89ec419c23ef5755D`,inputVerifierContractAddress:`0x36772142b74871f255CbD7A3e89B401d3e45825f`,kmsContractAddress:`0x901F8942346f7AB3a01F6D7613119Bca447Bb030`,verifyingContractAddressDecryption:`0x5ffdaAB0373E62E2ea2944776209aEf29E631A64`,verifyingContractAddressInputVerification:`0x812b06e1CDCE800494b79fFE4f925A504a9A9810`,registryAddress:void 0},o={[r.chainId]:r,[i.chainId]:i,[a.chainId]:a},s={name:`string`,version:`string`,chainId:`uint256`,verifyingContract:`address`,salt:`bytes32`};function c(e){return Object.keys(s).filter(t=>t in e).map(e=>({name:e,type:s[e]}))}export{c as a,i,a as n,e as o,r,o as t};
|
|
2
|
-
//# sourceMappingURL=relayer-utils-BeoTNDM4.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"relayer-utils-BeoTNDM4.js","names":[],"sources":["../../src/relayer/relayer-utils.ts"],"sourcesContent":["import type { FhevmInstanceConfig } from \"@zama-fhe/relayer-sdk/bundle\";\nimport type { Address } from \"viem\";\nimport type { EIP712TypedData } from \"./relayer-sdk.types\";\n\nconst MAX_RETRIES = 2;\nconst RETRY_BASE_MS = 500;\n\n/**\n * Retry an async operation with exponential backoff.\n * Only retries on transient errors (timeout, network). Does not retry user-facing errors.\n */\nexport async function withRetry<T>(fn: () => Promise<T>, retries = MAX_RETRIES): Promise<T> {\n let lastError: unknown;\n for (let attempt = 0; attempt <= retries; attempt++) {\n try {\n return await fn();\n } catch (error) {\n lastError = error;\n if (attempt < retries && isTransientError(error)) {\n await sleep(RETRY_BASE_MS * 2 ** attempt);\n continue;\n }\n throw error;\n }\n }\n throw lastError;\n}\n\nfunction isTransientError(error: unknown): boolean {\n if (!(error instanceof Error)) {\n return false;\n }\n const msg = error.message.toLowerCase();\n return (\n msg.includes(\"timed out\") ||\n msg.includes(\"timeout\") ||\n msg.includes(\"econnreset\") ||\n msg.includes(\"econnrefused\") ||\n msg.includes(\"network\") ||\n msg.includes(\"fetch failed\") ||\n msg.includes(\"socket hang up\") ||\n msg.includes(\"502\") ||\n msg.includes(\"503\") ||\n msg.includes(\"504\")\n );\n}\n\nfunction sleep(ms: number): Promise<void> {\n return new Promise((resolve) => setTimeout(resolve, ms));\n}\n\n/**\n * Extends the base relayer config with the on-chain wrappers registry address.\n *\n * Used by `DefaultConfigs` and the `WrappersRegistry` class to\n * resolve the correct registry contract per chain.\n */\nexport interface ExtendedFhevmInstanceConfig extends FhevmInstanceConfig {\n /**\n * Address of the `ConfidentialTokenWrappersRegistry` contract.\n * `undefined` for chains where no registry is deployed (e.g. Hardhat).\n */\n registryAddress: Address | undefined;\n}\n\n/**\n * Mainnet network configuration (chainId 1).\n *\n * Contract addresses mirror `MainnetConfigV2` from `@zama-fhe/relayer-sdk`.\n * They are duplicated here because the `/bundle` export path only exposes\n * types at build time (runtime values require `/web` or `/node` which pull\n * in WASM). `satisfies ExtendedFhevmInstanceConfig` ensures structural drift\n * is caught at compile time.\n *\n * Includes `registryAddress` for the on-chain token wrappers registry.\n */\nexport const MainnetConfig = {\n chainId: 1,\n gatewayChainId: 261131,\n relayerUrl: \"https://relayer.mainnet.zama.org/v2\",\n network: \"https://ethereum-rpc.publicnode.com\",\n aclContractAddress: \"0xcA2E8f1F656CD25C01F05d0b243Ab1ecd4a8ffb6\",\n kmsContractAddress: \"0x77627828a55156b04Ac0DC0eb30467f1a552BB03\",\n inputVerifierContractAddress: \"0xCe0FC2e05CFff1B719EFF7169f7D80Af770c8EA2\",\n verifyingContractAddressDecryption: \"0x0f6024a97684f7d90ddb0fAAD79cB15F2C888D24\",\n verifyingContractAddressInputVerification: \"0xcB1bB072f38bdAF0F328CdEf1Fc6eDa1DF029287\",\n registryAddress: \"0xeb5015fF021DB115aCe010f23F55C2591059bBA0\",\n} as const satisfies ExtendedFhevmInstanceConfig;\n\n/**\n * Sepolia testnet network configuration (chainId 11155111).\n *\n * See {@link MainnetConfig} for why addresses are hardcoded.\n * Includes `registryAddress` for the on-chain token wrappers registry.\n */\nexport const SepoliaConfig = {\n chainId: 11155111,\n gatewayChainId: 10901,\n relayerUrl: \"https://relayer.testnet.zama.org/v2\",\n network: \"https://ethereum-sepolia-rpc.publicnode.com\",\n aclContractAddress: \"0xf0Ffdc93b7E186bC2f8CB3dAA75D86d1930A433D\",\n kmsContractAddress: \"0xbE0E383937d564D7FF0BC3b46c51f0bF8d5C311A\",\n inputVerifierContractAddress: \"0xBBC1fFCdc7C316aAAd72E807D9b0272BE8F84DA0\",\n verifyingContractAddressDecryption: \"0x5D8BD78e2ea6bbE41f26dFe9fdaEAa349e077478\",\n verifyingContractAddressInputVerification: \"0x483b9dE06E4E4C7D35CCf5837A1668487406D955\",\n registryAddress: \"0x2f0750Bbb0A246059d80e94c454586a7F27a128e\",\n} as const satisfies ExtendedFhevmInstanceConfig;\n\n/**\n * Hardhat local network configuration (chainId 31337).\n *\n * The addresses in this configuration must match those of your deployment.\n * Ensure that the executor address and other contract addresses correspond to\n * the contracts deployed on your Hardhat network.\n *\n * `registryAddress` is `undefined` — pass it explicitly via\n * `registryAddresses` when creating a `WrappersRegistry`.\n */\nexport const HardhatConfig = {\n chainId: 31337,\n gatewayChainId: 10901,\n relayerUrl: \"\",\n network: \"http://127.0.0.1:8545\",\n aclContractAddress: \"0x50157CFfD6bBFA2DECe204a89ec419c23ef5755D\",\n inputVerifierContractAddress: \"0x36772142b74871f255CbD7A3e89B401d3e45825f\",\n kmsContractAddress: \"0x901F8942346f7AB3a01F6D7613119Bca447Bb030\",\n verifyingContractAddressDecryption: \"0x5ffdaAB0373E62E2ea2944776209aEf29E631A64\",\n verifyingContractAddressInputVerification: \"0x812b06e1CDCE800494b79fFE4f925A504a9A9810\",\n registryAddress: undefined,\n} as const satisfies ExtendedFhevmInstanceConfig;\n\n/**\n * Built-in network configurations keyed by chain ID.\n *\n * Includes Mainnet (1), Sepolia (11155111), and Hardhat (31337).\n * Used by `RelayerWeb` to resolve transport configs and by\n * `WrappersRegistry` to resolve registry addresses.\n */\nexport const DefaultConfigs: Record<number, ExtendedFhevmInstanceConfig> = {\n [MainnetConfig.chainId]: MainnetConfig,\n [SepoliaConfig.chainId]: SepoliaConfig,\n [HardhatConfig.chainId]: HardhatConfig,\n} as const;\n\n/** EIP-712 domain field → Solidity type. Order follows the EIP-712 spec. */\nconst DOMAIN_FIELD_TYPES: Record<string, string> = {\n name: \"string\",\n version: \"string\",\n chainId: \"uint256\",\n verifyingContract: \"address\",\n salt: \"bytes32\",\n};\n\n/**\n * Build `EIP712Domain` type entries from the keys present in a domain object.\n * Order matches the EIP-712 spec (name → version → chainId → verifyingContract → salt).\n */\nexport function buildEIP712DomainType(\n domain: EIP712TypedData[\"domain\"],\n): { name: string; type: string }[] {\n return Object.keys(DOMAIN_FIELD_TYPES)\n .filter((k) => k in domain)\n .map((k) => ({ name: k, type: DOMAIN_FIELD_TYPES[k]! }));\n}\n"],"mappings":"AAWA,eAAsB,EAAa,EAAsB,EAAU,EAAyB,CAC1F,IAAI,EACJ,IAAK,IAAI,EAAU,EAAG,GAAW,EAAS,IACxC,GAAI,CACF,OAAO,MAAM,GAAI,OACV,EAAO,CAEd,GADA,EAAY,EACR,EAAU,GAAW,EAAiB,EAAM,CAAE,CAChD,MAAM,EAAM,IAAgB,GAAK,EAAQ,CACzC,SAEF,MAAM,EAGV,MAAM,EAGR,SAAS,EAAiB,EAAyB,CACjD,GAAI,EAAE,aAAiB,OACrB,MAAO,GAET,IAAM,EAAM,EAAM,QAAQ,aAAa,CACvC,OACE,EAAI,SAAS,YAAY,EACzB,EAAI,SAAS,UAAU,EACvB,EAAI,SAAS,aAAa,EAC1B,EAAI,SAAS,eAAe,EAC5B,EAAI,SAAS,UAAU,EACvB,EAAI,SAAS,eAAe,EAC5B,EAAI,SAAS,iBAAiB,EAC9B,EAAI,SAAS,MAAM,EACnB,EAAI,SAAS,MAAM,EACnB,EAAI,SAAS,MAAM,CAIvB,SAAS,EAAM,EAA2B,CACxC,OAAO,IAAI,QAAS,GAAY,WAAW,EAAS,EAAG,CAAC,CA4B1D,MAAa,EAAgB,CAC3B,QAAS,EACT,eAAgB,OAChB,WAAY,sCACZ,QAAS,sCACT,mBAAoB,6CACpB,mBAAoB,6CACpB,6BAA8B,6CAC9B,mCAAoC,6CACpC,0CAA2C,6CAC3C,gBAAiB,6CAClB,CAQY,EAAgB,CAC3B,QAAS,SACT,eAAgB,MAChB,WAAY,sCACZ,QAAS,8CACT,mBAAoB,6CACpB,mBAAoB,6CACpB,6BAA8B,6CAC9B,mCAAoC,6CACpC,0CAA2C,6CAC3C,gBAAiB,6CAClB,CAYY,EAAgB,CAC3B,QAAS,MACT,eAAgB,MAChB,WAAY,GACZ,QAAS,wBACT,mBAAoB,6CACpB,6BAA8B,6CAC9B,mBAAoB,6CACpB,mCAAoC,6CACpC,0CAA2C,6CAC3C,gBAAiB,IAAA,GAClB,CASY,EAA8D,EACxE,EAAc,SAAU,GACxB,EAAc,SAAU,GACxB,EAAc,SAAU,EAC1B,CAGK,EAA6C,CACjD,KAAM,SACN,QAAS,SACT,QAAS,UACT,kBAAmB,UACnB,KAAM,UACP,CAMD,SAAgB,EACd,EACkC,CAClC,OAAO,OAAO,KAAK,EAAmB,CACnC,OAAQ,GAAM,KAAK,EAAO,CAC1B,IAAK,IAAO,CAAE,KAAM,EAAG,KAAM,EAAmB,GAAK,EAAE"}
|