@zama-fhe/sdk 3.3.0 → 3.3.1-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 +0 -2
- package/dist/cjs/base-signer.cjs +1 -1
- package/dist/cjs/base-signer.cjs.map +1 -1
- package/dist/cjs/chains.cjs +1 -1
- package/dist/cjs/chains.cjs.map +1 -1
- package/dist/cjs/cleartext/index.cjs +1 -1
- package/dist/cjs/cleartext.cjs +2 -0
- package/dist/cjs/cleartext.cjs.map +1 -0
- package/dist/cjs/ethers/index.cjs.map +1 -1
- package/dist/cjs/fhevm-relayer.cjs +2 -0
- package/dist/cjs/fhevm-relayer.cjs.map +1 -0
- package/dist/cjs/index.cjs +1 -1
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/node/index.cjs +2 -0
- package/dist/cjs/node/index.cjs.map +1 -0
- package/dist/cjs/query/index.cjs +1 -1
- package/dist/cjs/query/index.cjs.map +1 -1
- package/dist/cjs/relayer.cjs +1 -1
- package/dist/cjs/relayer.cjs.map +1 -1
- package/dist/cjs/token.cjs +1 -1
- package/dist/cjs/token.cjs.map +1 -1
- package/dist/cjs/viem/index.cjs +1 -1
- package/dist/cjs/viem/index.cjs.map +1 -1
- package/dist/cjs/web/index.cjs +1 -590
- package/dist/cjs/web/index.cjs.map +1 -1
- package/dist/cjs/wrappers-registry.cjs.map +1 -1
- package/dist/esm/base-signer-CI-FYai2.js +2 -0
- package/dist/esm/base-signer-CI-FYai2.js.map +1 -0
- package/dist/esm/{base-signer-C3Wc5oi9.d.ts → base-signer-Q2EJECrc.d.ts} +2 -2
- package/dist/esm/chains/index.d.ts +2 -3
- package/dist/esm/chains/index.js +1 -1
- package/dist/esm/chains-CLv9HEJ_.js +2 -0
- package/dist/esm/chains-CLv9HEJ_.js.map +1 -0
- package/dist/esm/cleartext/index.d.ts +3 -2
- package/dist/esm/cleartext/index.js +1 -1
- package/dist/esm/cleartext-BfXTVQu-.js +2 -0
- package/dist/esm/cleartext-BfXTVQu-.js.map +1 -0
- package/dist/esm/cleartext-U6sPs_Kd.d.ts +19 -0
- package/dist/esm/ethers/index.d.ts +4 -5
- package/dist/esm/ethers/index.js +1 -1
- package/dist/esm/ethers/index.js.map +1 -1
- package/dist/esm/fhevm-relayer-B-lEKfPQ.js +2 -0
- package/dist/esm/fhevm-relayer-B-lEKfPQ.js.map +1 -0
- package/dist/esm/index-BnIp_-Ak.d.ts +328 -0
- package/dist/esm/{index-CYBH0nyo.d.ts → index-D66eC3G7.d.ts} +60 -13
- package/dist/esm/index.d.ts +8 -11
- package/dist/esm/index.js +1 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/node/index.d.ts +5 -194
- package/dist/esm/node/index.js +1 -1
- package/dist/esm/node/index.js.map +1 -1
- package/dist/esm/query/index.d.ts +3 -380
- package/dist/esm/query/index.js +1 -1
- package/dist/esm/query/index.js.map +1 -1
- package/dist/esm/relayer-BYq9bLh8.js +2 -0
- package/dist/esm/relayer-BYq9bLh8.js.map +1 -0
- package/dist/esm/token-CmHTAAWW.js +2 -0
- package/dist/esm/token-CmHTAAWW.js.map +1 -0
- package/dist/esm/{types-piBsdTIP.d.ts → types-Bov8XY36.d.ts} +3 -3
- package/dist/esm/{types-OHIaPwCy.d.ts → types-BpvL50qX.d.ts} +3 -3
- package/dist/esm/types-C-WTLcHZ.d.ts +988 -0
- package/dist/esm/viem/index.d.ts +4 -5
- package/dist/esm/viem/index.js +1 -1
- package/dist/esm/viem/index.js.map +1 -1
- package/dist/esm/web/index.d.ts +6 -9
- package/dist/esm/web/index.js +1 -590
- package/dist/esm/web/index.js.map +1 -1
- package/dist/esm/{wrappers-registry-C1oK8Bi6.js → wrappers-registry-xZWzyAi4.js} +2 -2
- package/dist/esm/wrappers-registry-xZWzyAi4.js.map +1 -0
- package/dist/esm/{index-C1Mtc8Rw.d.ts → zama-sdk-q4_qt64Q.d.ts} +1471 -1102
- package/package.json +6 -2
- package/dist/cjs/assertions.cjs +0 -2
- package/dist/cjs/assertions.cjs.map +0 -1
- package/dist/cjs/encryption.cjs +0 -2
- package/dist/cjs/encryption.cjs.map +0 -1
- package/dist/cjs/relayer-cleartext.cjs +0 -2
- package/dist/cjs/relayer-cleartext.cjs.map +0 -1
- package/dist/cjs/relayer-sdk.worker.js +0 -589
- package/dist/cjs/timeout.cjs +0 -2
- package/dist/cjs/timeout.cjs.map +0 -1
- package/dist/cjs/validation.cjs +0 -2
- package/dist/cjs/validation.cjs.map +0 -1
- package/dist/esm/assertions-zYseN5Xz.js +0 -2
- package/dist/esm/assertions-zYseN5Xz.js.map +0 -1
- package/dist/esm/base-signer-DjytqPkd.js +0 -2
- package/dist/esm/base-signer-DjytqPkd.js.map +0 -1
- package/dist/esm/chains-CXcO1DBP.js +0 -2
- package/dist/esm/chains-CXcO1DBP.js.map +0 -1
- package/dist/esm/cleartext-DAkOTlrE.d.ts +0 -19
- package/dist/esm/cleartext-rTWFctyd.js +0 -2
- package/dist/esm/cleartext-rTWFctyd.js.map +0 -1
- package/dist/esm/encryption-x4Z_Icqk.js +0 -2
- package/dist/esm/encryption-x4Z_Icqk.js.map +0 -1
- package/dist/esm/hex-A72GrTf9.js +0 -2
- package/dist/esm/hex-A72GrTf9.js.map +0 -1
- package/dist/esm/indexeddb-storage-Mi-fCWN3.js +0 -2
- package/dist/esm/indexeddb-storage-Mi-fCWN3.js.map +0 -1
- package/dist/esm/memory-storage-fp9RY5BQ.js +0 -2
- package/dist/esm/memory-storage-fp9RY5BQ.js.map +0 -1
- package/dist/esm/node/relayer-sdk.node-worker.d.ts +0 -1
- package/dist/esm/node/relayer-sdk.node-worker.js +0 -2
- package/dist/esm/node/relayer-sdk.node-worker.js.map +0 -1
- package/dist/esm/relayer-cleartext-Bp6jtxDd.js +0 -2
- package/dist/esm/relayer-cleartext-Bp6jtxDd.js.map +0 -1
- package/dist/esm/relayer-cleartext-CSeMlmGO.d.ts +0 -844
- package/dist/esm/relayer-eavK5bfZ.js +0 -2
- package/dist/esm/relayer-eavK5bfZ.js.map +0 -1
- package/dist/esm/relayer-sdk.worker.js +0 -589
- package/dist/esm/timeout-CNVfiaJD.js +0 -2
- package/dist/esm/timeout-CNVfiaJD.js.map +0 -1
- package/dist/esm/token-Bt33g0zQ.js +0 -2
- package/dist/esm/token-Bt33g0zQ.js.map +0 -1
- package/dist/esm/types-BgczXqW2.d.ts +0 -49
- package/dist/esm/types-Gn5MeDsr.d.ts +0 -669
- package/dist/esm/validation-DLszOweh.js +0 -2
- package/dist/esm/validation-DLszOweh.js.map +0 -1
- package/dist/esm/worker.base-client-BVnT4yJa.js +0 -2
- package/dist/esm/worker.base-client-BVnT4yJa.js.map +0 -1
- package/dist/esm/wrappers-registry-C1oK8Bi6.js.map +0 -1
|
@@ -0,0 +1,988 @@
|
|
|
1
|
+
import { l as AtLeastOneChain, u as FheChain } from "./index-D66eC3G7.js";
|
|
2
|
+
import { createFhevmBaseClient, createFhevmClient, createFhevmDecryptClient, createFhevmEncryptClient, setFhevmRuntimeConfig } from "@fhevm/sdk/viem";
|
|
3
|
+
import { Abi, Address, ContractFunctionArgs, ContractFunctionName, ContractFunctionReturnType, Hex } from "viem";
|
|
4
|
+
import { Eip712Like, TypedValue, TypedValue as TypedValue$1 } from "@fhevm/sdk/types";
|
|
5
|
+
import { DecryptValuesParameters } from "@fhevm/sdk/actions/decrypt";
|
|
6
|
+
|
|
7
|
+
//#region src/relayer/types.d.ts
|
|
8
|
+
/** Canonical SDK type for an encrypted value — a `bytes32` ciphertext reference. */
|
|
9
|
+
type EncryptedValue = Hex;
|
|
10
|
+
/** Canonical SDK type for a decrypted clear-text value. */
|
|
11
|
+
type ClearValue = TypedValue["value"] | bigint | string | undefined;
|
|
12
|
+
/** A single value to encrypt with its FHE type. */
|
|
13
|
+
type EncryptInput = {
|
|
14
|
+
readonly type: `e${Exclude<TypedValue["type"], "bool" | "address">}`;
|
|
15
|
+
readonly value: bigint;
|
|
16
|
+
} | {
|
|
17
|
+
readonly type: `e${Extract<TypedValue["type"], "bool">}`;
|
|
18
|
+
readonly value: boolean | 1n | 0n;
|
|
19
|
+
} | {
|
|
20
|
+
readonly type: `e${Extract<TypedValue["type"], "address">}`;
|
|
21
|
+
readonly value: Address;
|
|
22
|
+
};
|
|
23
|
+
/** Parameters for encryption */
|
|
24
|
+
interface EncryptParams {
|
|
25
|
+
/** Typed inputs for encryption. Each value must specify its FHE type. */
|
|
26
|
+
readonly values: readonly EncryptInput[];
|
|
27
|
+
contractAddress: Address;
|
|
28
|
+
userAddress: Address;
|
|
29
|
+
}
|
|
30
|
+
/** Result from encryption — contract-ready hex encrypted values and input proof. */
|
|
31
|
+
interface EncryptResult {
|
|
32
|
+
readonly encryptedValues: readonly EncryptedValue[];
|
|
33
|
+
inputProof: Hex;
|
|
34
|
+
}
|
|
35
|
+
/** Result from public decryption. */
|
|
36
|
+
interface DecryptPublicValuesResult {
|
|
37
|
+
readonly clearValues: Record<EncryptedValue, ClearValue>;
|
|
38
|
+
abiEncodedClearValues: Hex;
|
|
39
|
+
decryptionProof: Hex;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* EIP-712 typed data for a (delegated) user-decrypt permit. Built by the FHE
|
|
43
|
+
* backend and handed to the signer layer (`GenericSigner.signTypedData`), which
|
|
44
|
+
* forwards it to the wallet. A structural shape — the SDK's contract is "sign
|
|
45
|
+
* this typed data", independent of the specific KMS permit variant `@fhevm/sdk`
|
|
46
|
+
* produces (which is versioned and evolves).
|
|
47
|
+
*/
|
|
48
|
+
type EIP712TypedData = Eip712Like;
|
|
49
|
+
/** The underlying client returned by `@fhevm/sdk`'s `createFhevmClient`. */
|
|
50
|
+
type FhevmClient = ReturnType<typeof createFhevmClient>;
|
|
51
|
+
/** Per-client `@fhevm/sdk` options (`batchRpcCalls`, `fheEncryptionKey`). */
|
|
52
|
+
type FhevmClientOptions = NonNullable<Parameters<typeof createFhevmClient>[0]["options"]>;
|
|
53
|
+
/**
|
|
54
|
+
* Options for a relayer transport (`web` / `node` / `cleartext`): the per-client
|
|
55
|
+
* `@fhevm/sdk` options that shape the underlying client, plus the request
|
|
56
|
+
* defaults `timeout` and `debug` applied to every relayer round-trip on the
|
|
57
|
+
* chain. A per-call `timeout`/`debug` overrides these defaults.
|
|
58
|
+
*
|
|
59
|
+
* @remarks
|
|
60
|
+
* The three client options mirror {@link FhevmClientOptions} but are listed
|
|
61
|
+
* explicitly so each carries its own documentation; `timeout` and `debug` are
|
|
62
|
+
* picked from {@link FhevmRelayerOptions}, the per-request option set.
|
|
63
|
+
*/
|
|
64
|
+
interface RelayerOptions extends Pick<FhevmRelayerOptions, "timeout" | "debug"> {
|
|
65
|
+
/**
|
|
66
|
+
* Batch the client's JSON-RPC reads (the on-chain calls it makes to resolve
|
|
67
|
+
* the protocol and key versions) into a single request instead of issuing
|
|
68
|
+
* them one by one.
|
|
69
|
+
*
|
|
70
|
+
* @defaultValue `false`
|
|
71
|
+
*/
|
|
72
|
+
readonly batchRpcCalls?: boolean;
|
|
73
|
+
/**
|
|
74
|
+
* A pre-fetched FHE public encryption key. Supply it to skip the ~50 MB key
|
|
75
|
+
* fetch `@fhevm/sdk` otherwise performs during init — e.g. to reuse a key
|
|
76
|
+
* cached across clients or sessions.
|
|
77
|
+
*
|
|
78
|
+
* @defaultValue none — the key is fetched from the relayer's `keyurl`.
|
|
79
|
+
*/
|
|
80
|
+
readonly fheEncryptionKey?: FhevmClientOptions["fheEncryptionKey"];
|
|
81
|
+
/**
|
|
82
|
+
* Pins the TFHE/KMS WASM module versions instead of auto-resolving them from
|
|
83
|
+
* the chain's on-chain protocol version.
|
|
84
|
+
*
|
|
85
|
+
* @defaultValue `'auto'`
|
|
86
|
+
*/
|
|
87
|
+
readonly moduleVersions?: FhevmClientOptions["moduleVersions"];
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Global `@fhevm/sdk` runtime config — WASM load mode, threads, logger, auth,
|
|
91
|
+
* module versions. Applied once per process (the underlying `setFhevmRuntimeConfig`
|
|
92
|
+
* is one-shot and idempotent; conflicting configs across chains will throw).
|
|
93
|
+
*/
|
|
94
|
+
type FhevmRuntimeConfig = Parameters<typeof setFhevmRuntimeConfig>[0];
|
|
95
|
+
/**
|
|
96
|
+
* The full set of per-request options `@fhevm/sdk`'s relayer accepts on every
|
|
97
|
+
* round-trip (mirrors its `RelayerCommonOptions`). Distinct from
|
|
98
|
+
* {@link RelayerOptions}, which configures a transport once at construction —
|
|
99
|
+
* these are applied per call.
|
|
100
|
+
*
|
|
101
|
+
*/
|
|
102
|
+
interface FhevmRelayerOptions {
|
|
103
|
+
/** Relayer authentication for the chain. Defaulted from the chain's config. */
|
|
104
|
+
readonly auth?: FhevmRuntimeConfig["auth"];
|
|
105
|
+
/** Extra HTTP headers attached to each relayer request. */
|
|
106
|
+
readonly headers?: Record<string, string>;
|
|
107
|
+
/**
|
|
108
|
+
* When `true`, `@fhevm/sdk`'s relayer emits verbose per-request trace logs to
|
|
109
|
+
* `console.log` (`[RelayerAsyncRequest]:…`), following each round-trip through
|
|
110
|
+
* its polling/retry loop. Off by default. A per-call `debug` overrides this.
|
|
111
|
+
*
|
|
112
|
+
* @remarks
|
|
113
|
+
* This is a raw diagnostic switch on the FHE backend, separate from the SDK's
|
|
114
|
+
* own configurable logger ({@link GenericLogger} via `createConfig`): it always
|
|
115
|
+
* writes to `console`, regardless of any logger you pass. Use it for one-off
|
|
116
|
+
* troubleshooting of relayer round-trips, not as a production logging channel.
|
|
117
|
+
*
|
|
118
|
+
* @defaultValue `false` `@fhevm/sdk` treats a missing flag as off.
|
|
119
|
+
*/
|
|
120
|
+
readonly debug?: boolean;
|
|
121
|
+
/**
|
|
122
|
+
* Times a failed HTTP fetch is retried on transient errors before the request
|
|
123
|
+
* gives up. This is the low-level fetch retry, separate from the async-job
|
|
124
|
+
* polling loop that waits on a queued relayer request.
|
|
125
|
+
*
|
|
126
|
+
* @defaultValue `3` `@fhevm/sdk`'s `FETCH_RETRY`.
|
|
127
|
+
*/
|
|
128
|
+
readonly fetchRetries?: number;
|
|
129
|
+
/**
|
|
130
|
+
* Delay between those fetch retries, in milliseconds.
|
|
131
|
+
*
|
|
132
|
+
* @defaultValue `1_000` `@fhevm/sdk`'s `FETCH_RETRY_AFTER_MS`;
|
|
133
|
+
*/
|
|
134
|
+
readonly fetchRetryDelayInMilliseconds?: number;
|
|
135
|
+
/**
|
|
136
|
+
* Cancels the request (and its retry/backoff loop) when aborted.
|
|
137
|
+
*
|
|
138
|
+
* @defaultValue none — the SDK injects no signal, so a request is uncancellable
|
|
139
|
+
* unless a per-call `signal` is passed.
|
|
140
|
+
*/
|
|
141
|
+
readonly signal?: AbortSignal;
|
|
142
|
+
/**
|
|
143
|
+
* Maximum duration, in milliseconds, to wait for a relayer **request** — an
|
|
144
|
+
* input-proof generation or a decryption, including its retry/backoff polling
|
|
145
|
+
* loop, not a single HTTP call. Defaults to the `@fhevm/sdk` ceiling of one
|
|
146
|
+
* hour; set a shorter bound only if you would rather fail than keep waiting. A
|
|
147
|
+
* per-call `timeout` overrides this default.
|
|
148
|
+
*
|
|
149
|
+
* @remarks
|
|
150
|
+
* Bounds only the relayer request, not `@fhevm/sdk`'s one-time (per client)
|
|
151
|
+
* init phase — on-chain protocol-version resolution, the ~50 MB FHE key fetch,
|
|
152
|
+
* and the WASM module load — which runs before the first request and can hang
|
|
153
|
+
* independently of this value. A failed init does not self-recover; discard
|
|
154
|
+
* the client and build a new one to retry.
|
|
155
|
+
*
|
|
156
|
+
* @defaultValue `3_600_000` (1 hour) — `@fhevm/sdk`'s
|
|
157
|
+
* `DEFAULT_GLOBAL_REQUEST_TIMEOUT_MS`, applied when no `timeout` is set at
|
|
158
|
+
* construction or per call.
|
|
159
|
+
*
|
|
160
|
+
* @privateRemarks
|
|
161
|
+
* `@fhevm/sdk`'s `init()` accepts no options, so no timeout/signal reaches
|
|
162
|
+
* that phase, and it memoizes a rejected ready-promise (`??=`). Bounding init
|
|
163
|
+
* is tracked upstream in `@fhevm/sdk`.
|
|
164
|
+
*/
|
|
165
|
+
readonly timeout?: number;
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* Single-chain FHE backend contract. Implemented by `FhevmRelayer` (drives
|
|
169
|
+
* `@fhevm/sdk`); translates between the domain shapes above and the engine's API.
|
|
170
|
+
*/
|
|
171
|
+
interface FhevmRelayerSDK extends Pick<FhevmClient, "encryptValue" | "encryptValues" | "decryptPublicValue" | "decryptPublicValues" | "decryptPublicValuesWithSignatures" | "decryptValue" | "decryptValues" | "decryptValuesFromPairs" | "fetchFheEncryptionKeyBytes" | "generateTransportKeyPair" | "serializeTransportKeyPair" | "serializeSignedDecryptionPermit" | "signDecryptionPermit" | "parseTransportKeyPair" | "parseSignedDecryptionPermit"> {
|
|
172
|
+
chain: FheChain;
|
|
173
|
+
}
|
|
174
|
+
//#endregion
|
|
175
|
+
//#region src/types/transaction.d.ts
|
|
176
|
+
/** Framework-agnostic log shape compatible with any Ethereum provider. */
|
|
177
|
+
interface RawLog {
|
|
178
|
+
/** Indexed event topics (topic[0] is the event signature hash). */
|
|
179
|
+
readonly topics: readonly Hex[];
|
|
180
|
+
/** ABI-encoded non-indexed event data. */
|
|
181
|
+
readonly data: Hex;
|
|
182
|
+
}
|
|
183
|
+
/** Framework-agnostic transaction receipt (only the fields the SDK needs). */
|
|
184
|
+
interface TransactionReceipt {
|
|
185
|
+
/** Event logs emitted during the transaction. */
|
|
186
|
+
readonly logs: readonly RawLog[];
|
|
187
|
+
}
|
|
188
|
+
/** Result of a write operation: the tx hash and its mined receipt. */
|
|
189
|
+
interface TransactionResult {
|
|
190
|
+
/** The transaction hash. */
|
|
191
|
+
txHash: Hex;
|
|
192
|
+
/** The mined transaction receipt. */
|
|
193
|
+
receipt: TransactionReceipt;
|
|
194
|
+
}
|
|
195
|
+
//#endregion
|
|
196
|
+
//#region src/events/onchain-events.d.ts
|
|
197
|
+
/**
|
|
198
|
+
* Event topic0 constants (keccak256 of the canonical Solidity signature).
|
|
199
|
+
* Pass to `getLogs({ topics: [Object.values(Topics)] })` to fetch all events.
|
|
200
|
+
*/
|
|
201
|
+
declare const Topics: {
|
|
202
|
+
/** `ConfidentialTransfer(address indexed from, address indexed to, bytes32 indexed amount)` */readonly ConfidentialTransfer: `0x${string}`; /** `Wrap(address indexed to, uint256 roundedAmount, euint64 encryptedWrappedAmount)` */
|
|
203
|
+
readonly Wrap: `0x${string}`; /** `UnwrapRequested(address indexed receiver, bytes32 indexed unwrapRequestId, bytes32 amount)` */
|
|
204
|
+
readonly UnwrapRequested: `0x${string}`; /** `UnwrapFinalized(address indexed receiver, bytes32 indexed unwrapRequestId, bytes32 encryptedAmount, uint64 cleartextAmount)` */
|
|
205
|
+
readonly UnwrapFinalized: `0x${string}`;
|
|
206
|
+
};
|
|
207
|
+
/** Decoded `ConfidentialTransfer` event — an encrypted token transfer. */
|
|
208
|
+
interface ConfidentialTransferEvent {
|
|
209
|
+
readonly eventName: "ConfidentialTransfer";
|
|
210
|
+
/** Sender address. */
|
|
211
|
+
readonly from: Address;
|
|
212
|
+
/** Receiver address. */
|
|
213
|
+
readonly to: Address;
|
|
214
|
+
/** FHE encrypted value for the transferred amount. */
|
|
215
|
+
readonly encryptedAmount: EncryptedValue;
|
|
216
|
+
}
|
|
217
|
+
/**
|
|
218
|
+
* Decoded `Wrap` event — an ERC-20 shield (wrap) operation. Emitted alongside a
|
|
219
|
+
* `ConfidentialTransfer(from=zeroAddress, ...)`; `encryptedWrappedAmount` is the same FHE
|
|
220
|
+
* handle that lands in `ConfidentialTransfer.encryptedAmount`.
|
|
221
|
+
*/
|
|
222
|
+
interface WrapEvent {
|
|
223
|
+
readonly eventName: "Wrap";
|
|
224
|
+
/** Receiver of the minted confidential tokens. */
|
|
225
|
+
readonly to: Address;
|
|
226
|
+
/** Cleartext underlying ERC-20 tokens deposited, rounded down to a multiple of the rate. */
|
|
227
|
+
readonly roundedAmount: bigint;
|
|
228
|
+
/** FHE encrypted value for the wrapped (minted) amount. */
|
|
229
|
+
readonly encryptedWrappedAmount: EncryptedValue;
|
|
230
|
+
}
|
|
231
|
+
/** Decoded `UnwrapRequested` event — an unshield request submitted. */
|
|
232
|
+
interface UnwrapRequestedEvent {
|
|
233
|
+
readonly eventName: "UnwrapRequested";
|
|
234
|
+
/** Address that will receive the unwrapped ERC-20 tokens. */
|
|
235
|
+
readonly receiver: Address;
|
|
236
|
+
/** FHE encrypted value for the requested unshield amount. */
|
|
237
|
+
readonly encryptedAmount: EncryptedValue;
|
|
238
|
+
/** Request identifier from the `UnwrapRequested` event topic. */
|
|
239
|
+
readonly unwrapRequestId?: EncryptedValue;
|
|
240
|
+
}
|
|
241
|
+
/** Decoded `UnwrapFinalized` event — an unshield completed on-chain. */
|
|
242
|
+
interface UnwrapFinalizedEvent {
|
|
243
|
+
readonly eventName: "UnwrapFinalized";
|
|
244
|
+
/** Address receiving the unwrapped ERC-20 tokens. */
|
|
245
|
+
readonly receiver: Address;
|
|
246
|
+
/** FHE encrypted value of the burnt confidential balance. */
|
|
247
|
+
readonly encryptedAmount: EncryptedValue;
|
|
248
|
+
/** Cleartext amount of underlying ERC-20 tokens returned. */
|
|
249
|
+
readonly cleartextAmount: bigint;
|
|
250
|
+
/** Request identifier from the `UnwrapFinalized` event topic. */
|
|
251
|
+
readonly unwrapRequestId?: EncryptedValue;
|
|
252
|
+
}
|
|
253
|
+
/** Union of all decoded confidential token event types. */
|
|
254
|
+
type OnChainEvent = ConfidentialTransferEvent | WrapEvent | UnwrapRequestedEvent | UnwrapFinalizedEvent;
|
|
255
|
+
/**
|
|
256
|
+
* ConfidentialTransfer(address indexed from, address indexed to, bytes32 indexed amount)
|
|
257
|
+
* All 3 params indexed → topics[1..3], no data.
|
|
258
|
+
*/
|
|
259
|
+
declare function decodeConfidentialTransfer(log: RawLog): ConfidentialTransferEvent | null;
|
|
260
|
+
/**
|
|
261
|
+
* Wrap(address indexed to, uint256 roundedAmount, euint64 encryptedWrappedAmount)
|
|
262
|
+
* Indexed: to (topics[1])
|
|
263
|
+
* Data: roundedAmount (uint256), encryptedWrappedAmount (bytes32)
|
|
264
|
+
*/
|
|
265
|
+
declare function decodeWrap(log: RawLog): WrapEvent | null;
|
|
266
|
+
/**
|
|
267
|
+
* UnwrapRequested(address indexed receiver, bytes32 indexed unwrapRequestId, bytes32 amount)
|
|
268
|
+
*/
|
|
269
|
+
declare function decodeUnwrapRequested(log: RawLog): UnwrapRequestedEvent | null;
|
|
270
|
+
/**
|
|
271
|
+
* UnwrapFinalized(address indexed receiver, bytes32 indexed unwrapRequestId, bytes32 encryptedAmount, uint64 cleartextAmount)
|
|
272
|
+
*/
|
|
273
|
+
declare function decodeUnwrapFinalized(log: RawLog): UnwrapFinalizedEvent | null;
|
|
274
|
+
/**
|
|
275
|
+
* Try all decoders on a single log and return the first match, or `null`.
|
|
276
|
+
*
|
|
277
|
+
* @example
|
|
278
|
+
* ```ts
|
|
279
|
+
* const event = decodeOnChainEvent(log);
|
|
280
|
+
* if (event?.eventName === "ConfidentialTransfer") {
|
|
281
|
+
* console.log(event.from, event.to);
|
|
282
|
+
* }
|
|
283
|
+
* ```
|
|
284
|
+
*/
|
|
285
|
+
declare function decodeOnChainEvent(log: RawLog): OnChainEvent | null;
|
|
286
|
+
/**
|
|
287
|
+
* Batch-decode an array of logs, skipping unrecognized entries.
|
|
288
|
+
*
|
|
289
|
+
* @example
|
|
290
|
+
* ```ts
|
|
291
|
+
* const events = decodeOnChainEvents(receipt.logs);
|
|
292
|
+
* ```
|
|
293
|
+
*/
|
|
294
|
+
declare function decodeOnChainEvents(logs: readonly RawLog[]): OnChainEvent[];
|
|
295
|
+
/**
|
|
296
|
+
* Find the first {@link UnwrapRequestedEvent} in a logs array.
|
|
297
|
+
*
|
|
298
|
+
* @example
|
|
299
|
+
* ```ts
|
|
300
|
+
* const event = findUnwrapRequested(receipt.logs);
|
|
301
|
+
* if (event) console.log(event.receiver, event.encryptedAmount);
|
|
302
|
+
* ```
|
|
303
|
+
*/
|
|
304
|
+
declare function findUnwrapRequested(logs: readonly RawLog[]): UnwrapRequestedEvent | null;
|
|
305
|
+
/**
|
|
306
|
+
* Find the first {@link WrapEvent} in a logs array.
|
|
307
|
+
*
|
|
308
|
+
* @example
|
|
309
|
+
* ```ts
|
|
310
|
+
* const event = findWrap(receipt.logs);
|
|
311
|
+
* if (event) console.log(event.to, event.roundedAmount);
|
|
312
|
+
* ```
|
|
313
|
+
*/
|
|
314
|
+
declare function findWrap(logs: readonly RawLog[]): WrapEvent | null;
|
|
315
|
+
/**
|
|
316
|
+
* All confidential token event topic0 hashes.
|
|
317
|
+
* Pass to `getLogs({ topics: [TOKEN_TOPICS] })` to fetch
|
|
318
|
+
* all confidential token events in a single RPC call.
|
|
319
|
+
*/
|
|
320
|
+
declare const TOKEN_TOPICS: readonly [`0x${string}`, `0x${string}`, `0x${string}`, `0x${string}`];
|
|
321
|
+
/**
|
|
322
|
+
* ACL delegation event topic0 constants (keccak256 of the canonical Solidity signature).
|
|
323
|
+
* These are ACL events, NOT token events — they are emitted by the ACL contract.
|
|
324
|
+
*/
|
|
325
|
+
declare const AclTopics: {
|
|
326
|
+
/** `DelegatedForUserDecryption(address indexed delegator, address indexed delegate, address contractAddress, uint64 delegationCounter, uint64 oldExpirationDate, uint64 newExpirationDate)` */readonly DelegatedForUserDecryption: `0x${string}`; /** `RevokedDelegationForUserDecryption(address indexed delegator, address indexed delegate, address contractAddress, uint64 delegationCounter, uint64 oldExpirationDate)` */
|
|
327
|
+
readonly RevokedDelegationForUserDecryption: `0x${string}`;
|
|
328
|
+
};
|
|
329
|
+
/** Decoded `DelegatedForUserDecryption` event — a delegation was created or renewed. */
|
|
330
|
+
interface DelegatedForUserDecryptionEvent {
|
|
331
|
+
readonly eventName: "DelegatedForUserDecryption";
|
|
332
|
+
/** Address of the delegator (the account granting access). */
|
|
333
|
+
readonly delegator: Address;
|
|
334
|
+
/** Address of the delegate (the account receiving access). */
|
|
335
|
+
readonly delegate: Address;
|
|
336
|
+
/** Contract address the delegation applies to. */
|
|
337
|
+
readonly contractAddress: Address;
|
|
338
|
+
/** Monotonic delegation counter. */
|
|
339
|
+
readonly delegationCounter: bigint;
|
|
340
|
+
/** Previous expiration timestamp (0 if first delegation). */
|
|
341
|
+
readonly oldExpirationDate: bigint;
|
|
342
|
+
/** New expiration timestamp. */
|
|
343
|
+
readonly newExpirationDate: bigint;
|
|
344
|
+
}
|
|
345
|
+
/** Decoded `RevokedDelegationForUserDecryption` event — a delegation was revoked. */
|
|
346
|
+
interface RevokedDelegationForUserDecryptionEvent {
|
|
347
|
+
readonly eventName: "RevokedDelegationForUserDecryption";
|
|
348
|
+
/** Address of the delegator. */
|
|
349
|
+
readonly delegator: Address;
|
|
350
|
+
/** Address of the delegate. */
|
|
351
|
+
readonly delegate: Address;
|
|
352
|
+
/** Contract address the revocation applies to. */
|
|
353
|
+
readonly contractAddress: Address;
|
|
354
|
+
/** Monotonic delegation counter. */
|
|
355
|
+
readonly delegationCounter: bigint;
|
|
356
|
+
/** Expiration date that was active before revocation. */
|
|
357
|
+
readonly oldExpirationDate: bigint;
|
|
358
|
+
}
|
|
359
|
+
/** Union of all decoded ACL delegation event types. */
|
|
360
|
+
type AclEvent = DelegatedForUserDecryptionEvent | RevokedDelegationForUserDecryptionEvent;
|
|
361
|
+
/**
|
|
362
|
+
* DelegatedForUserDecryption(address indexed delegator, address indexed delegate,
|
|
363
|
+
* address contractAddress, uint64 delegationCounter, uint64 oldExpirationDate, uint64 newExpirationDate)
|
|
364
|
+
* Indexed: delegator (topics[1]), delegate (topics[2])
|
|
365
|
+
* Data: contractAddress, delegationCounter, oldExpirationDate, newExpirationDate
|
|
366
|
+
*/
|
|
367
|
+
declare function decodeDelegatedForUserDecryption(log: RawLog): DelegatedForUserDecryptionEvent | null;
|
|
368
|
+
/**
|
|
369
|
+
* RevokedDelegationForUserDecryption(address indexed delegator, address indexed delegate,
|
|
370
|
+
* address contractAddress, uint64 delegationCounter, uint64 oldExpirationDate)
|
|
371
|
+
* Indexed: delegator (topics[1]), delegate (topics[2])
|
|
372
|
+
* Data: contractAddress, delegationCounter, oldExpirationDate
|
|
373
|
+
*/
|
|
374
|
+
declare function decodeRevokedDelegationForUserDecryption(log: RawLog): RevokedDelegationForUserDecryptionEvent | null;
|
|
375
|
+
/**
|
|
376
|
+
* Try all ACL delegation decoders on a single log and return the first match, or `null`.
|
|
377
|
+
*/
|
|
378
|
+
declare function decodeAclEvent(log: RawLog): AclEvent | null;
|
|
379
|
+
/**
|
|
380
|
+
* Batch-decode an array of logs for ACL delegation events, skipping unrecognized entries.
|
|
381
|
+
*/
|
|
382
|
+
declare function decodeAclEvents(logs: readonly RawLog[]): AclEvent[];
|
|
383
|
+
/**
|
|
384
|
+
* Find the first {@link DelegatedForUserDecryptionEvent} in a logs array.
|
|
385
|
+
*/
|
|
386
|
+
declare function findDelegatedForUserDecryption(logs: readonly RawLog[]): DelegatedForUserDecryptionEvent | null;
|
|
387
|
+
/**
|
|
388
|
+
* Find the first {@link RevokedDelegationForUserDecryptionEvent} in a logs array.
|
|
389
|
+
*/
|
|
390
|
+
declare function findRevokedDelegationForUserDecryption(logs: readonly RawLog[]): RevokedDelegationForUserDecryptionEvent | null;
|
|
391
|
+
/**
|
|
392
|
+
* Both ACL delegation event topic0 hashes.
|
|
393
|
+
* Pass to `getLogs({ topics: [ACL_TOPICS] })` to fetch
|
|
394
|
+
* all delegation events in a single RPC call.
|
|
395
|
+
*/
|
|
396
|
+
declare const ACL_TOPICS: readonly [`0x${string}`, `0x${string}`];
|
|
397
|
+
//#endregion
|
|
398
|
+
//#region src/types/callbacks.d.ts
|
|
399
|
+
/** Progress callbacks for multi-step unshield operations. */
|
|
400
|
+
interface UnshieldCallbacks {
|
|
401
|
+
/** Fired after the unwrap transaction is submitted. */
|
|
402
|
+
onUnwrapSubmitted?: (txHash: Hex) => void;
|
|
403
|
+
/** Fired when the finalization step begins (receipt parsed, about to finalize). */
|
|
404
|
+
onFinalizing?: () => void;
|
|
405
|
+
/** Fired after the finalize transaction is submitted. */
|
|
406
|
+
onFinalizeSubmitted?: (txHash: Hex) => void;
|
|
407
|
+
}
|
|
408
|
+
/** Progress callbacks for multi-step shield operations. */
|
|
409
|
+
interface ShieldCallbacks {
|
|
410
|
+
/** Fired after the ERC-20 approval transaction is submitted (skipped when `approvalStrategy: "skip"`). */
|
|
411
|
+
onApprovalSubmitted?: (txHash: Hex) => void;
|
|
412
|
+
/** Fired after the shield (wrap) transaction is submitted. */
|
|
413
|
+
onShieldSubmitted?: (txHash: Hex) => void;
|
|
414
|
+
}
|
|
415
|
+
/** Progress callbacks for multi-step confidential transfer operations. */
|
|
416
|
+
interface TransferCallbacks {
|
|
417
|
+
/** Fired after FHE encryption of the transfer amount completes. */
|
|
418
|
+
onEncryptComplete?: () => void;
|
|
419
|
+
/** Fired after the transfer transaction is submitted. */
|
|
420
|
+
onTransferSubmitted?: (txHash: Hex) => void;
|
|
421
|
+
}
|
|
422
|
+
//#endregion
|
|
423
|
+
//#region src/types/token.d.ts
|
|
424
|
+
/** Options for {@link ConfidentialToken.confidentialTransfer}. */
|
|
425
|
+
interface TransferOptions extends TransferCallbacks {
|
|
426
|
+
/** Skip confidential balance validation (e.g. for smart wallets). Default: `false`. */
|
|
427
|
+
skipBalanceCheck?: boolean;
|
|
428
|
+
}
|
|
429
|
+
/**
|
|
430
|
+
* User-facing approval strategy.
|
|
431
|
+
*
|
|
432
|
+
* - `"exact"` (default): approve exactly `amount`.
|
|
433
|
+
* - `"max"`: approve unlimited.
|
|
434
|
+
* - `"skip"`: assume a pre-existing approval; skip the approve step.
|
|
435
|
+
*/
|
|
436
|
+
type ApprovalStrategy = "max" | "exact" | "skip";
|
|
437
|
+
/**
|
|
438
|
+
* The resolved shielding execution path — what actually ran on-chain.
|
|
439
|
+
* Reported on {@link ShieldSubmittedEvent}; on a failure, the path is
|
|
440
|
+
* encoded in {@link TransactionErrorEvent.operation} as
|
|
441
|
+
* `"shield:transferAndCall"` or `"shield:approveAndWrap"`. Decided
|
|
442
|
+
* automatically by ERC-165 introspection on the underlying ERC-20.
|
|
443
|
+
*
|
|
444
|
+
* - `"transferAndCall"`: single tx via ERC-1363 (no approval).
|
|
445
|
+
* - `"approveAndWrap"`: legacy two-tx path (`approve` then `wrap`).
|
|
446
|
+
*/
|
|
447
|
+
type ShieldPath = "transferAndCall" | "approveAndWrap";
|
|
448
|
+
/** Options for {@link WrappedToken.shield}. */
|
|
449
|
+
interface ShieldOptions extends ShieldCallbacks {
|
|
450
|
+
/** See {@link ApprovalStrategy}. Default: `"exact"`. Ignored when the underlying supports ERC-1363 (single-tx path requires no approval). */
|
|
451
|
+
approvalStrategy?: ApprovalStrategy;
|
|
452
|
+
/** Recipient address for the shielded tokens. Defaults to the connected wallet. */
|
|
453
|
+
to?: Address;
|
|
454
|
+
}
|
|
455
|
+
/** Options for {@link WrappedToken.unshield}. */
|
|
456
|
+
interface UnshieldOptions extends UnshieldCallbacks {
|
|
457
|
+
/** Skip confidential balance validation (e.g. for smart wallets). Default: `false`. */
|
|
458
|
+
skipBalanceCheck?: boolean;
|
|
459
|
+
}
|
|
460
|
+
//#endregion
|
|
461
|
+
//#region src/events/sdk-events.d.ts
|
|
462
|
+
/**
|
|
463
|
+
* All SDK event keys, accessible as `ZamaSDKEvents.EncryptStart` etc.
|
|
464
|
+
*/
|
|
465
|
+
declare const ZamaSDKEvents: {
|
|
466
|
+
readonly EncryptStart: "encrypt:start";
|
|
467
|
+
readonly EncryptEnd: "encrypt:end";
|
|
468
|
+
readonly EncryptError: "encrypt:error";
|
|
469
|
+
readonly DecryptStart: "decrypt:start";
|
|
470
|
+
readonly DecryptEnd: "decrypt:end";
|
|
471
|
+
readonly DecryptError: "decrypt:error";
|
|
472
|
+
readonly TransactionError: "transaction:error";
|
|
473
|
+
readonly ShieldSubmitted: "shield:submitted";
|
|
474
|
+
readonly TransferSubmitted: "transfer:submitted";
|
|
475
|
+
readonly TransferFromSubmitted: "transferFrom:submitted";
|
|
476
|
+
readonly SetOperatorSubmitted: "setOperator:submitted";
|
|
477
|
+
readonly ApproveUnderlyingSubmitted: "approveUnderlying:submitted";
|
|
478
|
+
readonly UnwrapSubmitted: "unwrap:submitted";
|
|
479
|
+
readonly FinalizeUnwrapSubmitted: "finalizeUnwrap:submitted";
|
|
480
|
+
readonly DelegationSubmitted: "delegation:submitted";
|
|
481
|
+
readonly RevokeDelegationSubmitted: "revokeDelegation:submitted";
|
|
482
|
+
readonly UnshieldPhase1Submitted: "unshield:phase1_submitted";
|
|
483
|
+
readonly UnshieldPhase2Started: "unshield:phase2_started";
|
|
484
|
+
readonly UnshieldPhase2Submitted: "unshield:phase2_submitted";
|
|
485
|
+
};
|
|
486
|
+
/** Union of all SDK event type strings. */
|
|
487
|
+
type ZamaSDKEventType = (typeof ZamaSDKEvents)[keyof typeof ZamaSDKEvents];
|
|
488
|
+
interface BaseEvent {
|
|
489
|
+
tokenAddress?: Address;
|
|
490
|
+
timestamp: number;
|
|
491
|
+
/** Shared identifier linking related events in multi-phase operations (e.g. unshield). */
|
|
492
|
+
operationId?: string;
|
|
493
|
+
}
|
|
494
|
+
interface EncryptStartEvent extends BaseEvent {
|
|
495
|
+
type: typeof ZamaSDKEvents.EncryptStart;
|
|
496
|
+
}
|
|
497
|
+
interface EncryptEndEvent extends BaseEvent {
|
|
498
|
+
type: typeof ZamaSDKEvents.EncryptEnd;
|
|
499
|
+
durationMs: number;
|
|
500
|
+
}
|
|
501
|
+
interface EncryptErrorEvent extends BaseEvent {
|
|
502
|
+
type: typeof ZamaSDKEvents.EncryptError;
|
|
503
|
+
/** The error that caused the encryption to fail. */
|
|
504
|
+
error: Error;
|
|
505
|
+
durationMs: number;
|
|
506
|
+
}
|
|
507
|
+
interface DecryptStartEvent extends BaseEvent {
|
|
508
|
+
type: typeof ZamaSDKEvents.DecryptStart;
|
|
509
|
+
/** Encrypted values being decrypted — correlate with matching DecryptEnd/DecryptError. */
|
|
510
|
+
encryptedValues: EncryptedValue[];
|
|
511
|
+
}
|
|
512
|
+
interface DecryptEndEvent extends BaseEvent {
|
|
513
|
+
type: typeof ZamaSDKEvents.DecryptEnd;
|
|
514
|
+
durationMs: number;
|
|
515
|
+
/** Encrypted values that were decrypted. */
|
|
516
|
+
encryptedValues: EncryptedValue[];
|
|
517
|
+
/** Decrypted values keyed by encrypted value — use this to correlate events to specific entries. */
|
|
518
|
+
result: Record<EncryptedValue, ClearValue>;
|
|
519
|
+
}
|
|
520
|
+
interface DecryptErrorEvent extends BaseEvent {
|
|
521
|
+
type: typeof ZamaSDKEvents.DecryptError;
|
|
522
|
+
/** The error that caused the decryption to fail. */
|
|
523
|
+
error: Error;
|
|
524
|
+
durationMs: number;
|
|
525
|
+
/** Encrypted values that were being decrypted when the error occurred. */
|
|
526
|
+
encryptedValues: EncryptedValue[];
|
|
527
|
+
}
|
|
528
|
+
interface TransactionErrorEvent extends BaseEvent {
|
|
529
|
+
type: typeof ZamaSDKEvents.TransactionError;
|
|
530
|
+
/** Which SDK operation failed. */
|
|
531
|
+
operation: TransactionOperation;
|
|
532
|
+
/** The error that caused the transaction to fail. */
|
|
533
|
+
error: Error;
|
|
534
|
+
}
|
|
535
|
+
interface ShieldSubmittedEvent extends BaseEvent {
|
|
536
|
+
type: typeof ZamaSDKEvents.ShieldSubmitted;
|
|
537
|
+
txHash: Hex;
|
|
538
|
+
/** Which execution path was used: single-tx `transferAndCall` or two-tx `approveAndWrap`. */
|
|
539
|
+
shieldPath: ShieldPath;
|
|
540
|
+
}
|
|
541
|
+
interface TransferSubmittedEvent extends BaseEvent {
|
|
542
|
+
type: typeof ZamaSDKEvents.TransferSubmitted;
|
|
543
|
+
txHash: Hex;
|
|
544
|
+
}
|
|
545
|
+
interface TransferFromSubmittedEvent extends BaseEvent {
|
|
546
|
+
type: typeof ZamaSDKEvents.TransferFromSubmitted;
|
|
547
|
+
txHash: Hex;
|
|
548
|
+
}
|
|
549
|
+
interface SetOperatorSubmittedEvent extends BaseEvent {
|
|
550
|
+
type: typeof ZamaSDKEvents.SetOperatorSubmitted;
|
|
551
|
+
txHash: Hex;
|
|
552
|
+
}
|
|
553
|
+
interface ApproveUnderlyingSubmittedEvent extends BaseEvent {
|
|
554
|
+
type: typeof ZamaSDKEvents.ApproveUnderlyingSubmitted;
|
|
555
|
+
txHash: Hex;
|
|
556
|
+
/** Which approval transaction was submitted. */
|
|
557
|
+
step: "reset" | "approve";
|
|
558
|
+
}
|
|
559
|
+
interface UnwrapSubmittedEvent extends BaseEvent {
|
|
560
|
+
type: typeof ZamaSDKEvents.UnwrapSubmitted;
|
|
561
|
+
txHash: Hex;
|
|
562
|
+
}
|
|
563
|
+
interface FinalizeUnwrapSubmittedEvent extends BaseEvent {
|
|
564
|
+
type: typeof ZamaSDKEvents.FinalizeUnwrapSubmitted;
|
|
565
|
+
txHash: Hex;
|
|
566
|
+
}
|
|
567
|
+
interface DelegationSubmittedEvent extends BaseEvent {
|
|
568
|
+
type: typeof ZamaSDKEvents.DelegationSubmitted;
|
|
569
|
+
txHash: Hex;
|
|
570
|
+
}
|
|
571
|
+
interface RevokeDelegationSubmittedEvent extends BaseEvent {
|
|
572
|
+
type: typeof ZamaSDKEvents.RevokeDelegationSubmitted;
|
|
573
|
+
txHash: Hex;
|
|
574
|
+
}
|
|
575
|
+
interface UnshieldPhase1SubmittedEvent extends BaseEvent {
|
|
576
|
+
type: typeof ZamaSDKEvents.UnshieldPhase1Submitted;
|
|
577
|
+
txHash: Hex;
|
|
578
|
+
}
|
|
579
|
+
interface UnshieldPhase2StartedEvent extends BaseEvent {
|
|
580
|
+
type: typeof ZamaSDKEvents.UnshieldPhase2Started;
|
|
581
|
+
}
|
|
582
|
+
interface UnshieldPhase2SubmittedEvent extends BaseEvent {
|
|
583
|
+
type: typeof ZamaSDKEvents.UnshieldPhase2Submitted;
|
|
584
|
+
txHash: Hex;
|
|
585
|
+
}
|
|
586
|
+
/**
|
|
587
|
+
* Discriminated union of all SDK events.
|
|
588
|
+
*
|
|
589
|
+
* Decrypt events carry encrypted values and decrypted clear-text values so event
|
|
590
|
+
* subscribers can correlate and bind them in UI layers. Events never carry
|
|
591
|
+
* private keys, permit signatures, or ZK proofs.
|
|
592
|
+
*/
|
|
593
|
+
type ZamaSDKEvent = EncryptStartEvent | EncryptEndEvent | EncryptErrorEvent | DecryptStartEvent | DecryptEndEvent | DecryptErrorEvent | TransactionErrorEvent | ShieldSubmittedEvent | TransferSubmittedEvent | TransferFromSubmittedEvent | SetOperatorSubmittedEvent | ApproveUnderlyingSubmittedEvent | UnwrapSubmittedEvent | FinalizeUnwrapSubmittedEvent | DelegationSubmittedEvent | RevokeDelegationSubmittedEvent | UnshieldPhase1SubmittedEvent | UnshieldPhase2StartedEvent | UnshieldPhase2SubmittedEvent;
|
|
594
|
+
type ZamaSDKEventListener = (event: ZamaSDKEvent) => void;
|
|
595
|
+
/** Distributive Omit that preserves the discriminated union. */
|
|
596
|
+
type ZamaSDKEventInput = ZamaSDKEvent extends infer E ? E extends ZamaSDKEvent ? Omit<E, "timestamp" | "tokenAddress"> : never : never;
|
|
597
|
+
/**
|
|
598
|
+
* Single source of truth for each transaction operation's submitted-event payload.
|
|
599
|
+
*
|
|
600
|
+
* Adding a write op = adding one entry here. `TransactionOperation` is then
|
|
601
|
+
* `keyof typeof transactionOperationMetadata`, so the dispatch table and the
|
|
602
|
+
* operation union cannot drift.
|
|
603
|
+
*
|
|
604
|
+
* The `satisfies` check enforces that every entry produces a valid
|
|
605
|
+
* {@link ZamaSDKEventInput}.
|
|
606
|
+
*/
|
|
607
|
+
declare const transactionOperationMetadata: {
|
|
608
|
+
approveUnderlying: {
|
|
609
|
+
submittedEvent: (txHash: Hex) => {
|
|
610
|
+
type: "approveUnderlying:submitted";
|
|
611
|
+
txHash: `0x${string}`;
|
|
612
|
+
step: "approve";
|
|
613
|
+
};
|
|
614
|
+
};
|
|
615
|
+
"approveUnderlying:reset": {
|
|
616
|
+
submittedEvent: (txHash: Hex) => {
|
|
617
|
+
type: "approveUnderlying:submitted";
|
|
618
|
+
txHash: `0x${string}`;
|
|
619
|
+
step: "reset";
|
|
620
|
+
};
|
|
621
|
+
};
|
|
622
|
+
delegateDecryption: {
|
|
623
|
+
submittedEvent: (txHash: Hex) => {
|
|
624
|
+
type: "delegation:submitted";
|
|
625
|
+
txHash: `0x${string}`;
|
|
626
|
+
};
|
|
627
|
+
};
|
|
628
|
+
finalizeUnwrap: {
|
|
629
|
+
submittedEvent: (txHash: Hex) => {
|
|
630
|
+
type: "finalizeUnwrap:submitted";
|
|
631
|
+
txHash: `0x${string}`;
|
|
632
|
+
};
|
|
633
|
+
};
|
|
634
|
+
revokeDelegation: {
|
|
635
|
+
submittedEvent: (txHash: Hex) => {
|
|
636
|
+
type: "revokeDelegation:submitted";
|
|
637
|
+
txHash: `0x${string}`;
|
|
638
|
+
};
|
|
639
|
+
};
|
|
640
|
+
setOperator: {
|
|
641
|
+
submittedEvent: (txHash: Hex) => {
|
|
642
|
+
type: "setOperator:submitted";
|
|
643
|
+
txHash: `0x${string}`;
|
|
644
|
+
};
|
|
645
|
+
};
|
|
646
|
+
"shield:transferAndCall": {
|
|
647
|
+
submittedEvent: (txHash: Hex) => {
|
|
648
|
+
type: "shield:submitted";
|
|
649
|
+
txHash: `0x${string}`;
|
|
650
|
+
shieldPath: "transferAndCall";
|
|
651
|
+
};
|
|
652
|
+
};
|
|
653
|
+
"shield:approveAndWrap": {
|
|
654
|
+
submittedEvent: (txHash: Hex) => {
|
|
655
|
+
type: "shield:submitted";
|
|
656
|
+
txHash: `0x${string}`;
|
|
657
|
+
shieldPath: "approveAndWrap";
|
|
658
|
+
};
|
|
659
|
+
};
|
|
660
|
+
transfer: {
|
|
661
|
+
submittedEvent: (txHash: Hex) => {
|
|
662
|
+
type: "transfer:submitted";
|
|
663
|
+
txHash: `0x${string}`;
|
|
664
|
+
};
|
|
665
|
+
};
|
|
666
|
+
transferAndCall: {
|
|
667
|
+
submittedEvent: (txHash: Hex) => {
|
|
668
|
+
type: "transfer:submitted";
|
|
669
|
+
txHash: `0x${string}`;
|
|
670
|
+
};
|
|
671
|
+
};
|
|
672
|
+
transferFrom: {
|
|
673
|
+
submittedEvent: (txHash: Hex) => {
|
|
674
|
+
type: "transferFrom:submitted";
|
|
675
|
+
txHash: `0x${string}`;
|
|
676
|
+
};
|
|
677
|
+
};
|
|
678
|
+
transferFromAndCall: {
|
|
679
|
+
submittedEvent: (txHash: Hex) => {
|
|
680
|
+
type: "transferFrom:submitted";
|
|
681
|
+
txHash: `0x${string}`;
|
|
682
|
+
};
|
|
683
|
+
};
|
|
684
|
+
unwrap: {
|
|
685
|
+
submittedEvent: (txHash: Hex) => {
|
|
686
|
+
type: "unwrap:submitted";
|
|
687
|
+
txHash: `0x${string}`;
|
|
688
|
+
};
|
|
689
|
+
};
|
|
690
|
+
unwrapAll: {
|
|
691
|
+
submittedEvent: (txHash: Hex) => {
|
|
692
|
+
type: "unwrap:submitted";
|
|
693
|
+
txHash: `0x${string}`;
|
|
694
|
+
};
|
|
695
|
+
};
|
|
696
|
+
};
|
|
697
|
+
/**
|
|
698
|
+
* SDK transaction operations that emit submitted/error lifecycle events.
|
|
699
|
+
*
|
|
700
|
+
* Operation strings encode the execution-path discriminator for flows that have
|
|
701
|
+
* one (`shield:transferAndCall` vs. `shield:approveAndWrap`), routing both error
|
|
702
|
+
* and success events on a single field — see {@link transactionOperationMetadata}.
|
|
703
|
+
*/
|
|
704
|
+
type TransactionOperation = keyof typeof transactionOperationMetadata;
|
|
705
|
+
//#endregion
|
|
706
|
+
//#region src/chains/router.d.ts
|
|
707
|
+
/**
|
|
708
|
+
* Multichain router. Owns chain management (chains / chain / switchChain) and
|
|
709
|
+
* hands out the single-chain {@link FhevmRelayerSDK} backend for the currently active
|
|
710
|
+
* chain via {@link ChainRouter.relayer}. Builds one backend per chain from its
|
|
711
|
+
* {@link RelayerConfig}.
|
|
712
|
+
*/
|
|
713
|
+
declare class ChainRouter {
|
|
714
|
+
#private;
|
|
715
|
+
constructor(chains: readonly [FheChain, ...FheChain[]], configs: Readonly<Record<number, RelayerConfig>>);
|
|
716
|
+
get chains(): readonly FheChain[];
|
|
717
|
+
get chain(): FheChain;
|
|
718
|
+
/**
|
|
719
|
+
* Point the router at `chainId`. The active chain follows the wallet even when
|
|
720
|
+
* that chain has no configured backend: the {@link chain} / {@link relayer}
|
|
721
|
+
* getters throw a {@link ConfigurationError} for an unconfigured chain, so an
|
|
722
|
+
* unsupported chain fails loudly at the next operation rather than silently
|
|
723
|
+
* routing to the previously active chain (which would encrypt against, and
|
|
724
|
+
* sign an EIP-712 decryption permit for, the wrong chain's domain and ACL).
|
|
725
|
+
* Switching back to a configured chain restores service.
|
|
726
|
+
*/
|
|
727
|
+
switchChain(chainId: number): void;
|
|
728
|
+
/** The single-chain backend for the currently active chain. */
|
|
729
|
+
get relayer(): FhevmRelayerSDK;
|
|
730
|
+
}
|
|
731
|
+
//#endregion
|
|
732
|
+
//#region src/types/contract.d.ts
|
|
733
|
+
/** ABI type accepted by contract call builders. Supports both typed and untyped ABIs. */
|
|
734
|
+
type ContractAbi = Abi | readonly unknown[];
|
|
735
|
+
/** Extract read-only function names (`pure` | `view`) from a contract ABI. */
|
|
736
|
+
type ReadFunctionName<TAbi extends ContractAbi = ContractAbi> = ContractFunctionName<TAbi, "pure" | "view">;
|
|
737
|
+
/** Extract write function names (`nonpayable` | `payable`) from a contract ABI. */
|
|
738
|
+
type WriteFunctionName<TAbi extends ContractAbi = ContractAbi> = ContractFunctionName<TAbi, "nonpayable" | "payable">;
|
|
739
|
+
/** Infer the argument tuple for a read-only contract function. */
|
|
740
|
+
type ReadContractArgs<TAbi extends ContractAbi = ContractAbi, TFunctionName extends ReadFunctionName<TAbi> = ReadFunctionName<TAbi>> = ContractFunctionArgs<TAbi, "pure" | "view", TFunctionName>;
|
|
741
|
+
/** Infer the argument tuple for a write contract function. */
|
|
742
|
+
type WriteContractArgs<TAbi extends ContractAbi = ContractAbi, TFunctionName extends WriteFunctionName<TAbi> = WriteFunctionName<TAbi>> = ContractFunctionArgs<TAbi, "nonpayable" | "payable", TFunctionName>;
|
|
743
|
+
/** Infer the return type for a read-only contract function. */
|
|
744
|
+
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>;
|
|
745
|
+
/**
|
|
746
|
+
* Typed read-contract configuration.
|
|
747
|
+
* Matches the shape returned by read contract builders in `src/contracts/`.
|
|
748
|
+
*/
|
|
749
|
+
interface ReadContractConfig<TAbi extends ContractAbi = ContractAbi, TFunctionName extends ReadFunctionName<TAbi> = ReadFunctionName<TAbi>, TArgs extends ReadContractArgs<TAbi, TFunctionName> = ReadContractArgs<TAbi, TFunctionName>> {
|
|
750
|
+
/** Target contract address. */
|
|
751
|
+
readonly address: Address;
|
|
752
|
+
/** ABI fragment for the function being called. */
|
|
753
|
+
readonly abi: TAbi;
|
|
754
|
+
/** Solidity function name. */
|
|
755
|
+
readonly functionName: TFunctionName;
|
|
756
|
+
/** Contract call arguments inferred from the ABI and function name. */
|
|
757
|
+
readonly args: TArgs;
|
|
758
|
+
}
|
|
759
|
+
/**
|
|
760
|
+
* Typed write-contract configuration.
|
|
761
|
+
* Matches the shape returned by write contract builders in `src/contracts/`.
|
|
762
|
+
*/
|
|
763
|
+
interface WriteContractConfig<TAbi extends ContractAbi = ContractAbi, TFunctionName extends WriteFunctionName<TAbi> = WriteFunctionName<TAbi>, TArgs extends WriteContractArgs<TAbi, TFunctionName> = WriteContractArgs<TAbi, TFunctionName>> {
|
|
764
|
+
/** Target contract address. */
|
|
765
|
+
readonly address: Address;
|
|
766
|
+
/** ABI fragment for the function being called. */
|
|
767
|
+
readonly abi: TAbi;
|
|
768
|
+
/** Solidity function name. */
|
|
769
|
+
readonly functionName: TFunctionName;
|
|
770
|
+
/** Contract call arguments inferred from the ABI and function name. */
|
|
771
|
+
readonly args: TArgs;
|
|
772
|
+
/** Native value to send with the transaction (for payable functions). */
|
|
773
|
+
readonly value?: bigint;
|
|
774
|
+
/** Gas limit override. */
|
|
775
|
+
readonly gas?: bigint;
|
|
776
|
+
}
|
|
777
|
+
//#endregion
|
|
778
|
+
//#region src/types/signer.d.ts
|
|
779
|
+
/** Snapshot of the connected wallet account at a point in time. */
|
|
780
|
+
interface WalletAccount {
|
|
781
|
+
address: Address;
|
|
782
|
+
chainId: number;
|
|
783
|
+
}
|
|
784
|
+
/** A wallet account transition emitted by signer adapters. */
|
|
785
|
+
interface WalletAccountChange {
|
|
786
|
+
previous?: WalletAccount;
|
|
787
|
+
next?: WalletAccount;
|
|
788
|
+
}
|
|
789
|
+
/** Listener for wallet account transitions. */
|
|
790
|
+
type WalletAccountListener = (change: WalletAccountChange) => void;
|
|
791
|
+
/**
|
|
792
|
+
* Synchronous observable store for wallet account readiness.
|
|
793
|
+
*
|
|
794
|
+
* Direct subscriptions observe raw signer adapter transitions. For SDK-
|
|
795
|
+
* coordinated cleanup and React query invalidation, subscribe through
|
|
796
|
+
* `ZamaSDK.onWalletAccountChange` so credential/cache cleanup runs first.
|
|
797
|
+
*/
|
|
798
|
+
interface WalletAccountStore {
|
|
799
|
+
/** Synchronous, non-prompting snapshot of the currently connected wallet account. */
|
|
800
|
+
getSnapshot(): WalletAccount | undefined;
|
|
801
|
+
/**
|
|
802
|
+
* Whether the store has received at least one snapshot. Adapters whose
|
|
803
|
+
* initial account is only available asynchronously start unready; callers
|
|
804
|
+
* can distinguish "still loading" from "wallet not connected".
|
|
805
|
+
*/
|
|
806
|
+
isReady(): boolean;
|
|
807
|
+
/**
|
|
808
|
+
* Subscribe to wallet account transitions (connect, disconnect, account
|
|
809
|
+
* change, chain change). Returns an unsubscribe function.
|
|
810
|
+
*
|
|
811
|
+
* If a wallet account is already known when `subscribe` is called, the
|
|
812
|
+
* listener MUST be invoked synchronously with
|
|
813
|
+
* `{ previous: undefined, next: <current> }`. The SDK relies on this to
|
|
814
|
+
* warm credentials for already-connected signers; custom stores that skip
|
|
815
|
+
* this initial emit will silently break credential pre-warming.
|
|
816
|
+
*/
|
|
817
|
+
subscribe(onWalletAccountChange: WalletAccountListener): () => void;
|
|
818
|
+
}
|
|
819
|
+
/**
|
|
820
|
+
* Framework-agnostic signer interface — wallet authority only.
|
|
821
|
+
*
|
|
822
|
+
* Public chain reads have moved to {@link GenericProvider}. A signer is only
|
|
823
|
+
* required for operations that involve a user-controlled wallet
|
|
824
|
+
* (`requireWalletAccount`, `signTypedData`, `writeContract`).
|
|
825
|
+
*/
|
|
826
|
+
interface GenericSigner {
|
|
827
|
+
/** Observable wallet account readiness state. */
|
|
828
|
+
readonly walletAccount: WalletAccountStore;
|
|
829
|
+
/**
|
|
830
|
+
* Return the currently connected wallet account or throw
|
|
831
|
+
* {@link WalletNotConnectedError}. Must not initiate wallet connection.
|
|
832
|
+
*/
|
|
833
|
+
requireWalletAccount(operation: string): WalletAccount;
|
|
834
|
+
/**
|
|
835
|
+
* Optional non-prompting account discovery hook for adapters whose initial
|
|
836
|
+
* account snapshot is only available asynchronously.
|
|
837
|
+
*/
|
|
838
|
+
refreshWalletAccount?(): Promise<WalletAccount | undefined>;
|
|
839
|
+
/** Sign EIP-712 typed data (used for decrypt authorization). */
|
|
840
|
+
signTypedData(typedData: EIP712TypedData): Promise<Hex>;
|
|
841
|
+
/** Send a write transaction and return the tx hash. */
|
|
842
|
+
writeContract<const TAbi extends ContractAbi, TFunctionName extends WriteFunctionName<TAbi>, const TArgs extends WriteContractArgs<TAbi, TFunctionName>>(config: WriteContractConfig<TAbi, TFunctionName, TArgs>): Promise<Hex>;
|
|
843
|
+
/** Release adapter-owned wallet watchers or provider event listeners. */
|
|
844
|
+
dispose?(): void;
|
|
845
|
+
}
|
|
846
|
+
//#endregion
|
|
847
|
+
//#region src/types/provider.d.ts
|
|
848
|
+
/**
|
|
849
|
+
* Framework-agnostic read-only provider interface.
|
|
850
|
+
*
|
|
851
|
+
* Represents the minimal set of capabilities needed to perform public chain
|
|
852
|
+
* reads: querying state via `eth_call`, checking chain identity, awaiting
|
|
853
|
+
* transaction receipts, and fetching block timestamps.
|
|
854
|
+
*
|
|
855
|
+
* Any caller with only an RPC endpoint (server indexer, SSR, dApp pre-connect)
|
|
856
|
+
* can drive the SDK via a {@link GenericProvider} implementation, without
|
|
857
|
+
* instantiating a wallet-shaped object. Use {@link ViemProvider},
|
|
858
|
+
* {@link EthersProvider}, or {@link WagmiProvider}; or implement the
|
|
859
|
+
* interface directly.
|
|
860
|
+
*/
|
|
861
|
+
interface GenericProvider {
|
|
862
|
+
/** Return the chain ID of the connected network. */
|
|
863
|
+
getChainId(): Promise<number>;
|
|
864
|
+
/** Execute a read-only call and return the decoded result. */
|
|
865
|
+
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>>;
|
|
866
|
+
/** Wait for a transaction to be mined and return its receipt. */
|
|
867
|
+
waitForTransactionReceipt(hash: Hex): Promise<TransactionReceipt>;
|
|
868
|
+
/** Return the latest block timestamp in seconds. */
|
|
869
|
+
getBlockTimestamp(): Promise<bigint>;
|
|
870
|
+
}
|
|
871
|
+
//#endregion
|
|
872
|
+
//#region src/types/storage.d.ts
|
|
873
|
+
/**
|
|
874
|
+
* Pluggable key-value store for persisting FHE credentials.
|
|
875
|
+
*
|
|
876
|
+
* The SDK stores objects directly (not JSON strings). Implementations must
|
|
877
|
+
* preserve value types through round-trips — e.g. `IndexedDBStorage` uses
|
|
878
|
+
* structured clone, `MemoryStorage` stores values as-is.
|
|
879
|
+
*/
|
|
880
|
+
interface GenericStorage {
|
|
881
|
+
/** Retrieve a value by key. Returns `null` if the key does not exist. */
|
|
882
|
+
get<T = unknown>(key: string): Promise<T | null>;
|
|
883
|
+
/** Store a value under the given key, overwriting any existing entry. */
|
|
884
|
+
set<T = unknown>(key: string, value: T): Promise<void>;
|
|
885
|
+
/** Remove the entry for the given key (no-op if absent). */
|
|
886
|
+
delete(key: string): Promise<void>;
|
|
887
|
+
}
|
|
888
|
+
//#endregion
|
|
889
|
+
//#region src/types/logger.d.ts
|
|
890
|
+
/**
|
|
891
|
+
* Optional logger for SDK observability.
|
|
892
|
+
* Pass via config to observe operation lifecycle (start, success, error, timeout).
|
|
893
|
+
*/
|
|
894
|
+
interface GenericLogger {
|
|
895
|
+
info: (message: string, data?: Record<string, unknown>) => void;
|
|
896
|
+
debug: (message: string, data?: Record<string, unknown>) => void;
|
|
897
|
+
warn: (message: string, data?: Record<string, unknown>) => void;
|
|
898
|
+
error: (message: string, data?: Record<string, unknown>) => void;
|
|
899
|
+
}
|
|
900
|
+
//#endregion
|
|
901
|
+
//#region src/config/types.d.ts
|
|
902
|
+
/**
|
|
903
|
+
* Base relayer config. `createRelayer` builds one single-chain relayer; the
|
|
904
|
+
* dispatcher calls it once per chain.
|
|
905
|
+
*/
|
|
906
|
+
interface RelayerConfig {
|
|
907
|
+
readonly type: string;
|
|
908
|
+
/** Create a single-chain relayer. */
|
|
909
|
+
readonly createRelayer: (chain: FheChain) => FhevmRelayerSDK;
|
|
910
|
+
}
|
|
911
|
+
/** Web relayer config — drives the FHE backend directly. */
|
|
912
|
+
interface WebRelayerConfig extends RelayerConfig {
|
|
913
|
+
readonly type: "web";
|
|
914
|
+
}
|
|
915
|
+
/** Cleartext relayer config — drives the FHE backend in cleartext mode. */
|
|
916
|
+
interface CleartextRelayerConfig extends RelayerConfig {
|
|
917
|
+
readonly type: "cleartext";
|
|
918
|
+
}
|
|
919
|
+
/** Shared options across all adapter paths. */
|
|
920
|
+
interface ZamaConfigBase<TChains extends AtLeastOneChain = AtLeastOneChain> {
|
|
921
|
+
/** FHE chain configurations. Defines which chains support FHE operations. */
|
|
922
|
+
chains: TChains;
|
|
923
|
+
/** Per-chain relayer configuration. Every chain must have a relayer entry. */
|
|
924
|
+
relayers: { [K in TChains[number]["id"]]: RelayerConfig };
|
|
925
|
+
/** Credential storage. Default: IndexedDB in browser, memory in Node. */
|
|
926
|
+
storage?: GenericStorage;
|
|
927
|
+
/** Optional dedicated storage for permits. Defaults to `storage`. */
|
|
928
|
+
permitStorage?: GenericStorage;
|
|
929
|
+
/** ML-KEM transport key pair TTL in seconds. Default: 2592000 (30 days). */
|
|
930
|
+
transportKeyPairTTL?: number;
|
|
931
|
+
/** Permit lifetime in days. Default: 30. Clamped to `transportKeyPairTTL / 86400`. */
|
|
932
|
+
permitTTL?: number;
|
|
933
|
+
/** Registry cache TTL in seconds. Default: 86400 (24h). */
|
|
934
|
+
registryTTL?: number;
|
|
935
|
+
/** SDK lifecycle event listener. */
|
|
936
|
+
onEvent?: ZamaSDKEventListener;
|
|
937
|
+
/**
|
|
938
|
+
* Global `@fhevm/sdk` runtime config — WASM load mode, threads, logger, auth,
|
|
939
|
+
* module versions. `runtime.auth` is the process-wide fallback; each chain's
|
|
940
|
+
* `auth` is forwarded on that chain's relayer requests and takes precedence.
|
|
941
|
+
*/
|
|
942
|
+
runtime?: FhevmRuntimeConfig;
|
|
943
|
+
/**
|
|
944
|
+
* Optional logger for SDK diagnostics. Conforms to the four-level
|
|
945
|
+
* {@link GenericLogger} interface (`error`/`warn`/`info`/`debug`), which
|
|
946
|
+
* common loggers (console, pino, winston, OpenTelemetry's `DiagLogger`)
|
|
947
|
+
* satisfy directly. When omitted, the SDK emits no log output of its own.
|
|
948
|
+
* The SDK never bundles a logging library or imposes a format.
|
|
949
|
+
*/
|
|
950
|
+
logger?: GenericLogger;
|
|
951
|
+
}
|
|
952
|
+
/** Generic config — pass any {@link GenericSigner} and {@link GenericProvider} directly. */
|
|
953
|
+
interface ZamaConfigGeneric<TChains extends AtLeastOneChain = AtLeastOneChain> extends ZamaConfigBase<TChains> {
|
|
954
|
+
/**
|
|
955
|
+
* Optional wallet signer. Omit for read-only usage (indexers, SSR,
|
|
956
|
+
* pre-wallet-connect states). Signer-required SDK operations throw
|
|
957
|
+
* `SignerNotConfiguredError` when invoked without a signer.
|
|
958
|
+
*/
|
|
959
|
+
signer?: GenericSigner;
|
|
960
|
+
provider: GenericProvider;
|
|
961
|
+
}
|
|
962
|
+
declare const zamaConfigBrand: unique symbol;
|
|
963
|
+
/**
|
|
964
|
+
* Resolved, validated config object. Obtain via `createConfig()` or an
|
|
965
|
+
* adapter-specific factory — never construct by hand.
|
|
966
|
+
*/
|
|
967
|
+
type ZamaConfig = {
|
|
968
|
+
readonly chains: readonly FheChain[];
|
|
969
|
+
readonly router: ChainRouter;
|
|
970
|
+
readonly provider: GenericProvider;
|
|
971
|
+
readonly signer: GenericSigner | undefined;
|
|
972
|
+
readonly storage: GenericStorage;
|
|
973
|
+
readonly permitStorage: GenericStorage;
|
|
974
|
+
readonly transportKeyPairTTL: number;
|
|
975
|
+
readonly permitTTL: number;
|
|
976
|
+
readonly registryTTL: number;
|
|
977
|
+
readonly onEvent: ZamaSDKEventListener | undefined;
|
|
978
|
+
/**
|
|
979
|
+
* The SDK-wide logger, always present. Wraps the optional consumer-supplied
|
|
980
|
+
* {@link GenericLogger}; silent when none was configured.
|
|
981
|
+
*/
|
|
982
|
+
readonly logger: GenericLogger;
|
|
983
|
+
} & {
|
|
984
|
+
readonly [zamaConfigBrand]: true;
|
|
985
|
+
};
|
|
986
|
+
//#endregion
|
|
987
|
+
export { TransferOptions as $, EncryptEndEvent as A, RawLog as At, TransferSubmittedEvent as B, EncryptedValue as Bt, ChainRouter as C, decodeUnwrapFinalized as Ct, DecryptErrorEvent as D, findRevokedDelegationForUserDecryption as Dt, DecryptEndEvent as E, findDelegatedForUserDecryption as Et, SetOperatorSubmittedEvent as F, DecryptValuesParameters as Ft, ZamaSDKEvent as G, TypedValue$1 as Gt, UnshieldPhase2StartedEvent as H, FhevmRelayerOptions as Ht, ShieldSubmittedEvent as I, EIP712TypedData as It, ZamaSDKEventType as J, ZamaSDKEventInput as K, TransactionErrorEvent as L, EncryptInput as Lt, EncryptStartEvent as M, TransactionResult as Mt, FinalizeUnwrapSubmittedEvent as N, ClearValue as Nt, DecryptStartEvent as O, findUnwrapRequested as Ot, RevokeDelegationSubmittedEvent as P, DecryptPublicValuesResult as Pt, ShieldPath as Q, TransactionOperation as R, EncryptParams as Rt, WriteFunctionName as S, decodeRevokedDelegationForUserDecryption as St, BaseEvent as T, decodeWrap as Tt, UnshieldPhase2SubmittedEvent as U, FhevmRelayerSDK as Ut, UnshieldPhase1SubmittedEvent as V, FhevmClient as Vt, UnwrapSubmittedEvent as W, RelayerOptions as Wt, ApprovalStrategy as X, ZamaSDKEvents as Y, ShieldOptions as Z, ReadContractConfig as _, decodeAclEvents as _t, ZamaConfigBase as a, AclEvent as at, WriteContractArgs as b, decodeOnChainEvent as bt, GenericStorage as c, DelegatedForUserDecryptionEvent as ct, WalletAccount as d, TOKEN_TOPICS as dt, UnshieldOptions as et, WalletAccountChange as f, Topics as ft, ReadContractArgs as g, decodeAclEvent as gt, ContractAbi as h, WrapEvent as ht, ZamaConfig as i, ACL_TOPICS as it, EncryptErrorEvent as j, TransactionReceipt as jt, DelegationSubmittedEvent as k, findWrap as kt, GenericProvider as l, OnChainEvent as lt, WalletAccountStore as m, UnwrapRequestedEvent as mt, RelayerConfig as n, TransferCallbacks as nt, ZamaConfigGeneric as o, AclTopics as ot, WalletAccountListener as p, UnwrapFinalizedEvent as pt, ZamaSDKEventListener as q, WebRelayerConfig as r, UnshieldCallbacks as rt, GenericLogger as s, ConfidentialTransferEvent as st, CleartextRelayerConfig as t, ShieldCallbacks as tt, GenericSigner as u, RevokedDelegationForUserDecryptionEvent as ut, ReadContractReturnType as v, decodeConfidentialTransfer as vt, ApproveUnderlyingSubmittedEvent as w, decodeUnwrapRequested as wt, WriteContractConfig as x, decodeOnChainEvents as xt, ReadFunctionName as y, decodeDelegatedForUserDecryption as yt, TransferFromSubmittedEvent as z, EncryptResult as zt };
|
|
988
|
+
//# sourceMappingURL=types-C-WTLcHZ.d.ts.map
|