@zama-fhe/sdk 3.6.0 → 3.7.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/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/ethers/index.cjs +1 -1
- package/dist/cjs/ethers/index.cjs.map +1 -1
- package/dist/cjs/fhevm-relayer.cjs +2 -2
- package/dist/cjs/fhevm-relayer.cjs.map +1 -1
- package/dist/cjs/index.cjs +1 -1
- 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.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/wrappers-registry.cjs +1 -1
- package/dist/cjs/wrappers-registry.cjs.map +1 -1
- package/dist/esm/base-signer--sBO2qJp.js +2 -0
- package/dist/esm/base-signer--sBO2qJp.js.map +1 -0
- package/dist/esm/{base-signer-Iu5Lszrf.d.ts → base-signer-S2Ogf6L4.d.ts} +2 -2
- package/dist/esm/chains/index.d.ts +1 -1
- package/dist/esm/chains/index.js +1 -1
- package/dist/esm/chains-DEpKup1n.js +2 -0
- package/dist/esm/chains-DEpKup1n.js.map +1 -0
- package/dist/esm/cleartext/index.d.ts +2 -2
- package/dist/esm/cleartext/index.js +1 -1
- package/dist/esm/{cleartext-iE4sWgSP.js → cleartext-DcbDCDXj.js} +2 -2
- package/dist/esm/{cleartext-iE4sWgSP.js.map → cleartext-DcbDCDXj.js.map} +1 -1
- package/dist/esm/{cleartext-B2DI8fgm.d.ts → cleartext-pv2blbFU.d.ts} +2 -2
- package/dist/esm/encrypt.worker.js +51 -51
- package/dist/esm/{encryption-BKoalB4o.js → encryption-DJljZ2oV.js} +2 -2
- package/dist/esm/{encryption-BKoalB4o.js.map → encryption-DJljZ2oV.js.map} +1 -1
- package/dist/esm/ethers/index.d.ts +5 -5
- package/dist/esm/ethers/index.js +1 -1
- package/dist/esm/ethers/index.js.map +1 -1
- package/dist/esm/fhevm-relayer-CPmCytDX.js +8 -0
- package/dist/esm/fhevm-relayer-CPmCytDX.js.map +1 -0
- package/dist/esm/{index-BCh3VaZo.d.ts → index-DRrrBtMX.d.ts} +2000 -1115
- package/dist/esm/{index-ijgDL4IC.d.ts → index-Gk1S0gjO.d.ts} +14 -1
- package/dist/esm/{index-S6QjPkZE.d.ts → index-tfvbrVa2.d.ts} +4 -4
- package/dist/esm/index.d.ts +108 -8
- package/dist/esm/index.js +1 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/node/index.d.ts +4 -4
- package/dist/esm/node/index.js +1 -1
- package/dist/esm/query/index.d.ts +4 -537
- package/dist/esm/query/index.js +1 -1
- package/dist/esm/query/index.js.map +1 -1
- package/dist/esm/relayer-B6Zo6EkX.js +2 -0
- package/dist/esm/relayer-B6Zo6EkX.js.map +1 -0
- package/dist/esm/token-BMQ6xlrk.js +2 -0
- package/dist/esm/{token-BejFVO8m.js.map → token-BMQ6xlrk.js.map} +1 -1
- package/dist/esm/{types-D3W3J65M.d.ts → types-BOyFfG7D.d.ts} +42 -7
- package/dist/esm/{types-Ce9Lhvrf.d.ts → types-BRIpBy9n.d.ts} +3 -3
- package/dist/esm/{types-CFDG6lIJ.d.ts → types-OXQqX_kH.d.ts} +3 -3
- package/dist/esm/{validation-BRu06AM_.js → validation-DWe2k89s.js} +2 -2
- package/dist/esm/{validation-BRu06AM_.js.map → validation-DWe2k89s.js.map} +1 -1
- package/dist/esm/viem/index.d.ts +5 -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 +1 -1
- package/dist/esm/web/index.js +1 -1
- package/dist/esm/wrappers-registry-BfQr2QHn.js +2 -0
- package/dist/esm/wrappers-registry-BfQr2QHn.js.map +1 -0
- package/package.json +2 -2
- package/dist/esm/base-signer-DGIEzavu.js +0 -2
- package/dist/esm/base-signer-DGIEzavu.js.map +0 -1
- package/dist/esm/chains-ByyCdrrd.js +0 -2
- package/dist/esm/chains-ByyCdrrd.js.map +0 -1
- package/dist/esm/fhevm-relayer-Cm-ZR1vP.js +0 -8
- package/dist/esm/fhevm-relayer-Cm-ZR1vP.js.map +0 -1
- package/dist/esm/relayer-CVKO9GmQ.js +0 -2
- package/dist/esm/relayer-CVKO9GmQ.js.map +0 -1
- package/dist/esm/token-BejFVO8m.js +0 -2
- package/dist/esm/wrappers-registry-BLe7PkZi.js +0 -2
- package/dist/esm/wrappers-registry-BLe7PkZi.js.map +0 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { d as AtLeastOneChain, f as FheChain } from "./index-
|
|
1
|
+
import { d as AtLeastOneChain, f as FheChain } from "./index-Gk1S0gjO.js";
|
|
2
2
|
import { Abi, Address, ContractFunctionArgs, ContractFunctionName, ContractFunctionReturnType, Hex } from "viem";
|
|
3
|
-
import { CreateUnsignedLegacyDecryptionPermitEip712Parameters, CreateUnsignedLegacyDecryptionPermitEip712ReturnType } from "@fhevm/sdk/actions/base";
|
|
3
|
+
import { CanUseUnifiedDecryptionPermitParameters, CanUseUnifiedDecryptionPermitReturnType, CreateUnsignedLegacyDecryptionPermitEip712Parameters, CreateUnsignedLegacyDecryptionPermitEip712ReturnType, CreateUnsignedUnifiedDecryptionPermitEip712Parameters, CreateUnsignedUnifiedDecryptionPermitEip712ReturnType } from "@fhevm/sdk/actions/base";
|
|
4
4
|
import { createFhevmClient, setFhevmRuntimeConfig } from "@fhevm/sdk/viem";
|
|
5
5
|
import { Eip712Like, TypedValue, TypedValue as TypedValue$1 } from "@fhevm/sdk/types";
|
|
6
6
|
import { DecryptValuesParameters } from "@fhevm/sdk/actions/decrypt";
|
|
@@ -176,7 +176,7 @@ interface FhevmRelayerOptions {
|
|
|
176
176
|
* Single-chain FHE backend contract. Implemented by `FhevmRelayer` (drives
|
|
177
177
|
* `@fhevm/sdk`); translates between the domain shapes above and the engine's API.
|
|
178
178
|
*/
|
|
179
|
-
interface RelayerSDK extends Pick<FhevmClient, "encryptValue" | "encryptValues" | "decryptPublicValue" | "decryptPublicValues" | "decryptPublicValuesWithSignatures" | "decryptValue" | "decryptValues" | "decryptValuesFromPairs" | "fetchFheEncryptionKeyBytes" | "generateTransportKeyPair" | "serializeTransportKeyPair" | "serializeSignedDecryptionPermit" | "signDecryptionPermit" | "parseTransportKeyPair" | "parseSignedDecryptionPermit"> {
|
|
179
|
+
interface RelayerSDK extends Pick<FhevmClient, "encryptValue" | "encryptValues" | "decryptPublicValue" | "decryptPublicValues" | "decryptPublicValuesWithSignatures" | "decryptValue" | "decryptValues" | "decryptValuesFromPairs" | "fetchFheEncryptionKeyBytes" | "generateTransportKeyPair" | "serializeTransportKeyPair" | "serializeSignedDecryptionPermit" | "signDecryptionPermit" | "signUnifiedDecryptionPermit" | "parseTransportKeyPair" | "parseSignedDecryptionPermit"> {
|
|
180
180
|
/** The single FHE-enabled chain this backend instance is bound to. */
|
|
181
181
|
chain: FheChain;
|
|
182
182
|
/**
|
|
@@ -191,6 +191,33 @@ interface RelayerSDK extends Pick<FhevmClient, "encryptValue" | "encryptValues"
|
|
|
191
191
|
* resolve the active protocol version — signer-offline, not network-offline.
|
|
192
192
|
*/
|
|
193
193
|
createUnsignedLegacyDecryptionPermitEip712(parameters: CreateUnsignedLegacyDecryptionPermitEip712Parameters): Promise<CreateUnsignedLegacyDecryptionPermitEip712ReturnType>;
|
|
194
|
+
/**
|
|
195
|
+
* Builds the unsigned EIP-712 typed data for a V2 (unified) decryption
|
|
196
|
+
* permit — the signer-less counterpart to {@link FhevmClient.signUnifiedDecryptionPermit}.
|
|
197
|
+
* Not exposed on `@fhevm/sdk`'s client decorator, so it's called directly
|
|
198
|
+
* against the base client rather than through a decorated method.
|
|
199
|
+
*
|
|
200
|
+
* Unlike its V1 counterpart, this builder has no `delegatorAddress`
|
|
201
|
+
* parameter: V2 delegation is post-sign metadata, not part of the signed
|
|
202
|
+
* message, so a delegated offline request carries it separately on
|
|
203
|
+
* {@link PreparedPermit} instead of threading it through here.
|
|
204
|
+
*
|
|
205
|
+
* Backs the offline permit flow (`Offline.preparePermit`): the SDK builds
|
|
206
|
+
* the typed data here and hands it to an out-of-process signer for
|
|
207
|
+
* `eth_signTypedData_v4`. Reads the chain's KMS signers context on-chain to
|
|
208
|
+
* resolve the active protocol version — signer-offline, not network-offline.
|
|
209
|
+
*/
|
|
210
|
+
createUnsignedUnifiedDecryptionPermitEip712(parameters: CreateUnsignedUnifiedDecryptionPermitEip712Parameters): Promise<CreateUnsignedUnifiedDecryptionPermitEip712ReturnType>;
|
|
211
|
+
/**
|
|
212
|
+
* Reports whether the connected relayer supports V2 (unified) decryption
|
|
213
|
+
* permits — specifically its `/v3/user-decrypt` route. Not exposed on
|
|
214
|
+
* `@fhevm/sdk`'s client decorator, so it's called directly against the base
|
|
215
|
+
* client rather than through a decorated method.
|
|
216
|
+
*
|
|
217
|
+
* The relayer's feature set is resolved once per client and pinned, so
|
|
218
|
+
* repeated calls are cheap and never drift.
|
|
219
|
+
*/
|
|
220
|
+
canUseUnifiedDecryptionPermit(parameters?: CanUseUnifiedDecryptionPermitParameters): Promise<CanUseUnifiedDecryptionPermitReturnType>;
|
|
194
221
|
/**
|
|
195
222
|
* Releases backend resources (e.g. an encrypt worker) once in-flight work
|
|
196
223
|
* finishes; a later call re-acquires them. Safe to omit and safe to call twice.
|
|
@@ -541,6 +568,7 @@ declare const ZamaSDKEvents: {
|
|
|
541
568
|
readonly FinalizeUnwrapSubmitted: "finalizeUnwrap:submitted";
|
|
542
569
|
readonly DelegationSubmitted: "delegation:submitted";
|
|
543
570
|
readonly RevokeDelegationSubmitted: "revokeDelegation:submitted";
|
|
571
|
+
readonly InvalidateDecryptionSignaturesSubmitted: "invalidateDecryptionSignatures:submitted";
|
|
544
572
|
readonly UnshieldPhase1Submitted: "unshield:phase1_submitted";
|
|
545
573
|
readonly UnshieldPhase2Started: "unshield:phase2_started";
|
|
546
574
|
readonly UnshieldPhase2Submitted: "unshield:phase2_submitted";
|
|
@@ -715,6 +743,13 @@ interface RevokeDelegationSubmittedEvent extends BaseEvent {
|
|
|
715
743
|
/** Hash of the submitted revokeDelegation transaction. */
|
|
716
744
|
txHash: Hex;
|
|
717
745
|
}
|
|
746
|
+
/** Emitted when an invalidate-decryption-signatures transaction has been submitted to the network. */
|
|
747
|
+
interface InvalidateDecryptionSignaturesSubmittedEvent extends BaseEvent {
|
|
748
|
+
/** Event type discriminant. */
|
|
749
|
+
type: typeof ZamaSDKEvents.InvalidateDecryptionSignaturesSubmitted;
|
|
750
|
+
/** Hash of the submitted invalidateDecryptionSignatures transaction. */
|
|
751
|
+
txHash: Hex;
|
|
752
|
+
}
|
|
718
753
|
/** Emitted when the first phase of an unshield (the unwrap request) has been submitted. */
|
|
719
754
|
interface UnshieldPhase1SubmittedEvent extends BaseEvent {
|
|
720
755
|
/** Event type discriminant. */
|
|
@@ -741,7 +776,7 @@ interface UnshieldPhase2SubmittedEvent extends BaseEvent {
|
|
|
741
776
|
* subscribers can correlate and bind them in UI layers. Events never carry
|
|
742
777
|
* private keys, permit signatures, or ZK proofs.
|
|
743
778
|
*/
|
|
744
|
-
type ZamaSDKEvent = EncryptStartEvent | EncryptEndEvent | EncryptErrorEvent | DecryptStartEvent | DecryptEndEvent | DecryptErrorEvent | PermitErrorEvent | TransactionErrorEvent | ShieldSubmittedEvent | TransferSubmittedEvent | TransferFromSubmittedEvent | SetOperatorSubmittedEvent | ApproveUnderlyingSubmittedEvent | WrapSubmittedEvent | UnwrapSubmittedEvent | FinalizeUnwrapSubmittedEvent | DelegationSubmittedEvent | RevokeDelegationSubmittedEvent | UnshieldPhase1SubmittedEvent | UnshieldPhase2StartedEvent | UnshieldPhase2SubmittedEvent;
|
|
779
|
+
type ZamaSDKEvent = EncryptStartEvent | EncryptEndEvent | EncryptErrorEvent | DecryptStartEvent | DecryptEndEvent | DecryptErrorEvent | PermitErrorEvent | TransactionErrorEvent | ShieldSubmittedEvent | TransferSubmittedEvent | TransferFromSubmittedEvent | SetOperatorSubmittedEvent | ApproveUnderlyingSubmittedEvent | WrapSubmittedEvent | UnwrapSubmittedEvent | FinalizeUnwrapSubmittedEvent | DelegationSubmittedEvent | RevokeDelegationSubmittedEvent | InvalidateDecryptionSignaturesSubmittedEvent | UnshieldPhase1SubmittedEvent | UnshieldPhase2StartedEvent | UnshieldPhase2SubmittedEvent;
|
|
745
780
|
/** Callback invoked with each emitted {@link ZamaSDKEvent}. */
|
|
746
781
|
type ZamaSDKEventListener = (event: ZamaSDKEvent) => void;
|
|
747
782
|
/**
|
|
@@ -751,7 +786,7 @@ type ZamaSDKEventListener = (event: ZamaSDKEvent) => void;
|
|
|
751
786
|
* one (`shield:transferAndCall` vs. `shield:approveAndWrap`), routing both error
|
|
752
787
|
* and success events on a single field — see {@link transactionOperationMetadata}.
|
|
753
788
|
*/
|
|
754
|
-
type TransactionOperation = "approveUnderlying" | "approveUnderlying:reset" | "delegateDecryption" | "finalizeUnwrap" | "revokeDelegation" | "setOperator" | "shield:transferAndCall" | "shield:approveAndWrap" | "wrap" | "transfer" | "transferAndCall" | "transferFrom" | "transferFromAndCall" | "unwrap" | "unwrapAll";
|
|
789
|
+
type TransactionOperation = "approveUnderlying" | "approveUnderlying:reset" | "delegateDecryption" | "finalizeUnwrap" | "invalidateDecryptionSignatures" | "revokeDelegation" | "setOperator" | "shield:transferAndCall" | "shield:approveAndWrap" | "wrap" | "transfer" | "transferAndCall" | "transferFrom" | "transferFromAndCall" | "unwrap" | "unwrapAll";
|
|
755
790
|
//#endregion
|
|
756
791
|
//#region src/types/contract.d.ts
|
|
757
792
|
/** ABI type accepted by contract call builders. Supports both typed and untyped ABIs. */
|
|
@@ -1344,5 +1379,5 @@ type ZamaConfig = {
|
|
|
1344
1379
|
readonly [zamaConfigBrand]: true;
|
|
1345
1380
|
};
|
|
1346
1381
|
//#endregion
|
|
1347
|
-
export {
|
|
1348
|
-
//# sourceMappingURL=types-
|
|
1382
|
+
export { RevokeDelegationSubmittedEvent as $, TransactionResult as $t, WalletAccountListener as A, OnChainEvent as At, ApproveUnderlyingSubmittedEvent as B, decodeDelegatedForUserDecryption as Bt, TransferAndCallRequest as C, TransferCallbacks as Ct, GenericSigner as D, AclTopics as Dt, WrapRequest as E, AclEvent as Et, ReadContractReturnType as F, UnwrapRequestedEvent as Ft, DelegationSubmittedEvent as G, decodeUnwrapRequested as Gt, DecryptEndEvent as H, decodeOnChainEvents as Ht, ReadFunctionName as I, WrapEvent as It, EncryptStartEvent as J, findRevokedDelegationForUserDecryption as Jt, EncryptEndEvent as K, decodeWrap as Kt, WriteContractArgs as L, decodeAclEvent as Lt, ContractAbi as M, TOKEN_TOPICS as Mt, ReadContractArgs as N, Topics as Nt, WalletAccount as O, ConfidentialTransferEvent as Ot, ReadContractConfig as P, UnwrapFinalizedEvent as Pt, PermitOperation as Q, TransactionReceipt as Qt, WriteContractConfig as R, decodeAclEvents as Rt, TransactionKind as S, ShieldCallbacks as St, UnwrapRequest as T, ACL_TOPICS as Tt, DecryptErrorEvent as U, decodeRevokedDelegationForUserDecryption as Ut, BaseEvent as V, decodeOnChainEvent as Vt, DecryptStartEvent as W, decodeUnwrapFinalized as Wt, InvalidateDecryptionSignaturesSubmittedEvent as X, findWrap as Xt, FinalizeUnwrapSubmittedEvent as Y, findUnwrapRequested as Yt, PermitErrorEvent as Z, RawLog as Zt, PrepareTransactionRequest as _, ShieldPath as _t, ZamaConfigBase as a, EncryptParams as an, TransferSubmittedEvent as at, RevokeDelegationRequest as b, UnwrapResult as bt, GenericStorage as c, FhevmClient as cn, UnshieldPhase2SubmittedEvent as ct, ConfidentialTransferFromRequest as d, FhevmRuntimeConfig as dn, ZamaSDKEvent as dt, ClearValue as en, SetOperatorSubmittedEvent as et, ConfidentialTransferRequest as f, RelayerOptions as fn, ZamaSDKEventListener as ft, PrepareOptions as g, ShieldOptions as gt, PrepareFees as h, ApprovalStrategy as ht, ZamaConfig as i, EncryptInput as in, TransferFromSubmittedEvent as it, WalletAccountStore as j, RevokedDelegationForUserDecryptionEvent as jt, WalletAccountChange as k, DelegatedForUserDecryptionEvent as kt, GenericProvider as l, FhevmClientOptions as ln, UnwrapSubmittedEvent as lt, FinalizeUnwrapRequest as m, TypedValue$1 as mn, ZamaSDKEvents as mt, RelayerConfig as n, DecryptValuesParameters as nn, TransactionErrorEvent as nt, ZamaConfigGeneric as o, EncryptResult as on, UnshieldPhase1SubmittedEvent as ot, DelegateDecryptionRequest as p, RelayerSDK as pn, ZamaSDKEventType as pt, EncryptErrorEvent as q, findDelegatedForUserDecryption as qt, WebRelayerConfig as r, EIP712TypedData as rn, TransactionOperation as rt, GenericLogger as s, EncryptedValue as sn, UnshieldPhase2StartedEvent as st, CleartextRelayerConfig as t, DecryptPublicValuesResult as tn, ShieldSubmittedEvent as tt, ApproveUnderlyingRequest as u, FhevmRelayerOptions as un, WrapSubmittedEvent as ut, PreparedFor as v, TransferOptions as vt, UnwrapAllRequest as w, UnshieldCallbacks as wt, SetOperatorRequest as x, WrapOptions as xt, PreparedTransaction as y, UnshieldOptions as yt, WriteFunctionName as z, decodeConfidentialTransfer as zt };
|
|
1383
|
+
//# sourceMappingURL=types-BOyFfG7D.d.ts.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { d as AtLeastOneChain } from "./index-
|
|
2
|
-
import { a as ZamaConfigBase } from "./types-
|
|
1
|
+
import { d as AtLeastOneChain } from "./index-Gk1S0gjO.js";
|
|
2
|
+
import { a as ZamaConfigBase } from "./types-BOyFfG7D.js";
|
|
3
3
|
import { EIP1193Provider, PublicClient, WalletClient } from "viem";
|
|
4
4
|
//#region src/viem/types.d.ts
|
|
5
5
|
/** Viem config — pass native viem clients directly. */
|
|
@@ -13,4 +13,4 @@ interface ZamaConfigViem<TChains extends AtLeastOneChain = AtLeastOneChain> exte
|
|
|
13
13
|
}
|
|
14
14
|
//#endregion
|
|
15
15
|
export { ZamaConfigViem as t };
|
|
16
|
-
//# sourceMappingURL=types-
|
|
16
|
+
//# sourceMappingURL=types-BRIpBy9n.d.ts.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { d as AtLeastOneChain } from "./index-
|
|
2
|
-
import { a as ZamaConfigBase } from "./types-
|
|
1
|
+
import { d as AtLeastOneChain } from "./index-Gk1S0gjO.js";
|
|
2
|
+
import { a as ZamaConfigBase } from "./types-BOyFfG7D.js";
|
|
3
3
|
import { EIP1193Provider } from "viem";
|
|
4
4
|
import { Provider, Signer } from "ethers";
|
|
5
5
|
//#region src/ethers/types.d.ts
|
|
@@ -26,4 +26,4 @@ type ZamaConfigEthers<TChains extends AtLeastOneChain = AtLeastOneChain> = ZamaC
|
|
|
26
26
|
});
|
|
27
27
|
//#endregion
|
|
28
28
|
export { ZamaConfigEthers as t };
|
|
29
|
-
//# sourceMappingURL=types-
|
|
29
|
+
//# sourceMappingURL=types-OXQqX_kH.d.ts.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{t as e}from"./relayer-
|
|
2
|
-
//# sourceMappingURL=validation-
|
|
1
|
+
import{t as e}from"./relayer-B6Zo6EkX.js";import{z as t}from"zod/mini";function n(n,r){let i=t.safeParse(n,r);if(i.success)return i.data;throw new e(t.prettifyError(i.error),{cause:i.error})}export{n as t};
|
|
2
|
+
//# sourceMappingURL=validation-DWe2k89s.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validation-
|
|
1
|
+
{"version":3,"file":"validation-DWe2k89s.js","names":[],"sources":["../../src/validation.ts"],"sourcesContent":["import { z } from \"zod/mini\";\nimport { ConfigurationError } from \"./errors\";\n\nexport function parseSchema<T>(schema: z.core.$ZodType<T>, value: unknown): T {\n const parsed = z.safeParse(schema, value);\n if (parsed.success) {\n return parsed.data;\n }\n throw new ConfigurationError(z.prettifyError(parsed.error), { cause: parsed.error });\n}\n"],"mappings":"uEAGA,SAAgB,EAAe,EAA4B,EAAmB,CAC5E,IAAM,EAAS,EAAE,UAAU,EAAQ,CAAK,EACxC,GAAI,EAAO,QACT,OAAO,EAAO,KAEhB,MAAM,IAAI,EAAmB,EAAE,cAAc,EAAO,KAAK,EAAG,CAAE,MAAO,EAAO,KAAM,CAAC,CACrF"}
|
package/dist/esm/viem/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { d as AtLeastOneChain, f as FheChain, p as FheChainAuth } from "../index-
|
|
2
|
-
import { $ as
|
|
3
|
-
import { n as MutableWalletAccountStore, t as BaseSigner } from "../base-signer-
|
|
4
|
-
import { t as ZamaConfigViem } from "../types-
|
|
1
|
+
import { d as AtLeastOneChain, f as FheChain, p as FheChainAuth } from "../index-Gk1S0gjO.js";
|
|
2
|
+
import { $ as RevokeDelegationSubmittedEvent, A as WalletAccountListener, B as ApproveUnderlyingSubmittedEvent, D as GenericSigner, F as ReadContractReturnType, G as DelegationSubmittedEvent, H as DecryptEndEvent, I as ReadFunctionName, J as EncryptStartEvent, K as EncryptEndEvent, L as WriteContractArgs, M as ContractAbi, N as ReadContractArgs, O as WalletAccount, P as ReadContractConfig, Q as PermitOperation, Qt as TransactionReceipt, R as WriteContractConfig, U as DecryptErrorEvent, V as BaseEvent, W as DecryptStartEvent, X as InvalidateDecryptionSignaturesSubmittedEvent, Y as FinalizeUnwrapSubmittedEvent, Z as PermitErrorEvent, Zt as RawLog, _t as ShieldPath, a as ZamaConfigBase, at as TransferSubmittedEvent, c as GenericStorage, ct as UnshieldPhase2SubmittedEvent, dn as FhevmRuntimeConfig, dt as ZamaSDKEvent, en as ClearValue, et as SetOperatorSubmittedEvent, ft as ZamaSDKEventListener, i as ZamaConfig, it as TransferFromSubmittedEvent, j as WalletAccountStore, k as WalletAccountChange, l as GenericProvider, lt as UnwrapSubmittedEvent, mt as ZamaSDKEvents, n as RelayerConfig, nt as TransactionErrorEvent, ot as UnshieldPhase1SubmittedEvent, pt as ZamaSDKEventType, q as EncryptErrorEvent, rn as EIP712TypedData, rt as TransactionOperation, s as GenericLogger, sn as EncryptedValue, st as UnshieldPhase2StartedEvent, tt as ShieldSubmittedEvent, ut as WrapSubmittedEvent, z as WriteFunctionName } from "../types-BOyFfG7D.js";
|
|
3
|
+
import { n as MutableWalletAccountStore, t as BaseSigner } from "../base-signer-S2Ogf6L4.js";
|
|
4
|
+
import { t as ZamaConfigViem } from "../types-BRIpBy9n.js";
|
|
5
5
|
import { Abi, Address, ContractFunctionArgs, ContractFunctionName, ContractFunctionReturnType, EIP1193Provider, Hex, Hex as Hex$1, PublicClient, WalletClient } from "viem";
|
|
6
6
|
//#region src/viem/config.d.ts
|
|
7
7
|
/** Create a {@link ZamaConfig} from viem clients. */
|
|
@@ -131,5 +131,5 @@ declare function readTokenAddressContract(client: PublicClient, registry: Addres
|
|
|
131
131
|
/** Reads whether a confidential token is registered and valid in a wrappers registry via a viem client. */
|
|
132
132
|
declare function readIsConfidentialTokenValidContract(client: PublicClient, registry: Address, confidentialTokenAddress: Address): Promise<boolean>;
|
|
133
133
|
//#endregion
|
|
134
|
-
export { type ApproveUnderlyingSubmittedEvent, type AtLeastOneChain, type BaseEvent, BaseSigner, type ClearValue, type ContractAbi, type DecryptEndEvent, type DecryptErrorEvent, type DecryptStartEvent, type DelegationSubmittedEvent, type EIP712TypedData, type EncryptEndEvent, type EncryptErrorEvent, type EncryptStartEvent, type EncryptedValue, type FheChain, type FheChainAuth, type FhevmRuntimeConfig, type FinalizeUnwrapSubmittedEvent, type GenericLogger, type GenericProvider, type GenericSigner, type GenericStorage, type Hex, type MutableWalletAccountStore, type PermitErrorEvent, type PermitOperation, type RawLog, type ReadContractArgs, type ReadContractConfig, type ReadContractReturnType, type ReadFunctionName, type RelayerConfig, type RevokeDelegationSubmittedEvent, type SetOperatorSubmittedEvent, type ShieldPath, type ShieldSubmittedEvent, type TransactionErrorEvent, type TransactionOperation, type TransactionReceipt, type TransferFromSubmittedEvent, type TransferSubmittedEvent, type UnshieldPhase1SubmittedEvent, type UnshieldPhase2StartedEvent, type UnshieldPhase2SubmittedEvent, type UnwrapSubmittedEvent, ViemProvider, type ViemProviderConfig, ViemSigner, type ViemSignerConfig, type WalletAccount, type WalletAccountChange, type WalletAccountListener, type WalletAccountStore, type WrapSubmittedEvent, type WriteContractArgs, type WriteContractConfig, type WriteFunctionName, type ZamaConfig, type ZamaConfigBase, type ZamaConfigViem, type ZamaSDKEvent, type ZamaSDKEventListener, type ZamaSDKEventType, ZamaSDKEvents, createConfig, readConfidentialBalanceOfContract, readConfidentialTokenAddressContract, readIsConfidentialTokenValidContract, readSupportsInterfaceContract, readTokenAddressContract, readTokenPairContract, readTokenPairsContract, readTokenPairsLengthContract, readTokenPairsSliceContract, readUnderlyingTokenContract, writeConfidentialTransferContract, writeFinalizeUnwrapContract, writeSetOperatorContract, writeUnwrapContract, writeUnwrapFromBalanceContract, writeWrapContract };
|
|
134
|
+
export { type ApproveUnderlyingSubmittedEvent, type AtLeastOneChain, type BaseEvent, BaseSigner, type ClearValue, type ContractAbi, type DecryptEndEvent, type DecryptErrorEvent, type DecryptStartEvent, type DelegationSubmittedEvent, type EIP712TypedData, type EncryptEndEvent, type EncryptErrorEvent, type EncryptStartEvent, type EncryptedValue, type FheChain, type FheChainAuth, type FhevmRuntimeConfig, type FinalizeUnwrapSubmittedEvent, type GenericLogger, type GenericProvider, type GenericSigner, type GenericStorage, type Hex, type InvalidateDecryptionSignaturesSubmittedEvent, type MutableWalletAccountStore, type PermitErrorEvent, type PermitOperation, type RawLog, type ReadContractArgs, type ReadContractConfig, type ReadContractReturnType, type ReadFunctionName, type RelayerConfig, type RevokeDelegationSubmittedEvent, type SetOperatorSubmittedEvent, type ShieldPath, type ShieldSubmittedEvent, type TransactionErrorEvent, type TransactionOperation, type TransactionReceipt, type TransferFromSubmittedEvent, type TransferSubmittedEvent, type UnshieldPhase1SubmittedEvent, type UnshieldPhase2StartedEvent, type UnshieldPhase2SubmittedEvent, type UnwrapSubmittedEvent, ViemProvider, type ViemProviderConfig, ViemSigner, type ViemSignerConfig, type WalletAccount, type WalletAccountChange, type WalletAccountListener, type WalletAccountStore, type WrapSubmittedEvent, type WriteContractArgs, type WriteContractConfig, type WriteFunctionName, type ZamaConfig, type ZamaConfigBase, type ZamaConfigViem, type ZamaSDKEvent, type ZamaSDKEventListener, type ZamaSDKEventType, ZamaSDKEvents, createConfig, readConfidentialBalanceOfContract, readConfidentialTokenAddressContract, readIsConfidentialTokenValidContract, readSupportsInterfaceContract, readTokenAddressContract, readTokenPairContract, readTokenPairsContract, readTokenPairsLengthContract, readTokenPairsSliceContract, readUnderlyingTokenContract, writeConfidentialTransferContract, writeFinalizeUnwrapContract, writeSetOperatorContract, writeUnwrapContract, writeUnwrapFromBalanceContract, writeWrapContract };
|
|
135
135
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/esm/viem/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{F as e,
|
|
1
|
+
import{F as e,L as t,M as n,N as r,O as i,P as a,S as o,T as s,Z as c,a as l,i as u,it as d,m as f,n as p,nt as m,o as h,r as g,s as _,t as v}from"../wrappers-registry-BfQr2QHn.js";import{i as y,t as b}from"../base-signer--sBO2qJp.js";import{t as x}from"../eip1193-subscribe-CNxVHW6y.js";import{encodeFunctionData as S,getAddress as C,serializeTransaction as w}from"viem";var T=class{#e;constructor(e){this.#e=e.publicClient}async getChainId(){return this.#e.getChainId()}async readContract(e){return this.#e.readContract(e)}async waitForTransactionReceipt(e){return this.#e.waitForTransactionReceipt({hash:e})}async getBlockTimestamp(){return(await this.#e.getBlock()).timestamp}async prepareTransaction(e){let{from:t,calldata:n}=e,r=S({abi:n.abi,functionName:n.functionName,args:n.args}),i=this.#e.getChainId(),a=e.nonce===void 0?this.#e.getTransactionCount({address:t,blockTag:`pending`}):Promise.resolve(e.nonce),o=e.gasLimit===void 0?n.gas??this.#e.estimateGas({account:t,to:n.address,data:r,value:n.value??0n}).catch(e=>{throw new d(`ViemProvider.prepareTransaction: gas estimation reverted for ${n.functionName} on ${n.address}`,{cause:e})}):Promise.resolve(e.gasLimit),s=e.fees??this.#e.estimateFeesPerGas(),[c,l,u,f]=await Promise.all([i,a,o,s]);return w({type:`eip1559`,chainId:c,nonce:l,to:n.address,data:r,value:n.value??0n,gas:u,maxFeePerGas:f.maxFeePerGas,maxPriorityFeePerGas:f.maxPriorityFeePerGas})}};function E(e){let t=(e.primaryType?e.types[e.primaryType]:void 0)??[],n={...e.message};for(let{name:e,type:r}of t)/^uint\d*$/.test(r)&&(n[e]=BigInt(n[e]));return n}function D(e){if(!(!e.account||!e.chain))return{address:C(e.account.address),chainId:e.chain.id}}var O=class extends b{#e;#t;#n;constructor(e){super(D(e.walletClient)),this.#e=e.walletClient,this.#t=e.ethereum,this.#n=this.#i()}#r(e){if(!this.#e.account)throw new m(e);return{walletClient:this.#e,account:this.#e.account}}async signTypedData(e){let{walletClient:t,account:n}=this.#r(`signTypedData`),{EIP712Domain:r,...i}=e.types;return t.signTypedData({account:n,primaryType:e.primaryType,types:i,domain:e.domain,message:E(e)})}async writeContract(e){let{walletClient:t,account:n}=this.#r(`writeContract`);return t.writeContract({chain:t.chain,account:n,...e})}#i(){return this.#t?x({provider:this.#t,getInitialWalletAccount:()=>D(this.#e),onWalletAccountChange:({next:e})=>{this.walletAccount.setSnapshot(e)}}):()=>{}}onDispose(){this.#n()}};function k(e){return y(new O({walletClient:e.walletClient,ethereum:e.ethereum}),new T({publicClient:e.publicClient}),e)}function A(e){if(!e.account)throw TypeError(`WalletClient has no account`);return e.account}function j(e,t,n){return e.readContract(o(t,n))}function M(e,t){return e.readContract(r(t))}function N(e,t,n){return e.readContract(f(t,n))}function P(e,t,n,r,i){return e.writeContract({chain:e.chain,account:A(e),...s(t,n,r,i)})}function F(e,t,n,r,i,o){return e.writeContract({chain:e.chain,account:A(e),...a(t,n,r,i,o)})}function I(t,n,r,i,a){return t.writeContract({chain:t.chain,account:A(t),...e(n,r,i,a)})}function L(e,t,n,r,a){return e.writeContract({chain:e.chain,account:A(e),...i(t,n,r,a)})}function R(e,t,r,i){return e.writeContract({chain:e.chain,account:A(e),...n(t,r,i)})}function z(e,n,r,i){return e.writeContract({chain:e.chain,account:A(e),...t(n,r,i)})}function B(e,t){return e.readContract(u(t))}function V(e,t){return e.readContract(l(t))}function H(e,t,n,r){return e.readContract(h(t,n,r))}function U(e,t,n){return e.readContract(g(t,n))}function W(e,t,n){return e.readContract(v(t,n))}function G(e,t,n){return e.readContract(p(t,n))}function K(e,t,n){return e.readContract(_(t,n))}export{b as BaseSigner,T as ViemProvider,O as ViemSigner,c as ZamaSDKEvents,k as createConfig,j as readConfidentialBalanceOfContract,W as readConfidentialTokenAddressContract,K as readIsConfidentialTokenValidContract,N as readSupportsInterfaceContract,G as readTokenAddressContract,U as readTokenPairContract,B as readTokenPairsContract,V as readTokenPairsLengthContract,H as readTokenPairsSliceContract,M as readUnderlyingTokenContract,P as writeConfidentialTransferContract,L as writeFinalizeUnwrapContract,R as writeSetOperatorContract,F as writeUnwrapContract,I as writeUnwrapFromBalanceContract,z as writeWrapContract};
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["#publicClient","#walletClient","#ethereum","#unsubscribeProvider","#subscribeToProvider","#requireAccount"],"sources":["../../../src/viem/viem-provider.ts","../../../src/viem/viem-signer.ts","../../../src/viem/config.ts","../../../src/viem/contracts.ts"],"sourcesContent":["import {\n encodeFunctionData,\n serializeTransaction,\n type Abi,\n type Address,\n type ContractFunctionArgs,\n type ContractFunctionName,\n type ContractFunctionReturnType,\n type Hex,\n type PublicClient,\n} from \"viem\";\nimport { TransactionRevertedError } from \"../errors\";\nimport type {\n ContractAbi,\n GenericProvider,\n ReadContractConfig,\n TransactionReceipt,\n WriteContractArgs,\n WriteContractConfig,\n WriteFunctionName,\n} from \"../types\";\n\n/** Configuration for {@link ViemProvider}. */\nexport interface ViemProviderConfig {\n /** A viem `PublicClient` backing all read operations. */\n publicClient: PublicClient;\n}\n\n/**\n * Read-only {@link GenericProvider} backed by a viem `PublicClient`.\n *\n * Use this for integrations that only need public chain reads before the user has Pair with a\n * {@link ViemSigner} when wallet authority is required; the two can share a transport or point at\n * independent RPCs.\n *\n * @example\n * ```ts\n * const publicClient = createPublicClient({ chain: sepolia, transport: http(ALCHEMY_URL) });\n * const provider = new ViemProvider({ publicClient });\n * ```\n */\nexport class ViemProvider implements GenericProvider {\n readonly #publicClient: PublicClient;\n\n constructor(config: ViemProviderConfig) {\n this.#publicClient = config.publicClient;\n }\n\n /** Return the chain ID of the connected network. */\n async getChainId(): Promise<number> {\n return this.#publicClient.getChainId();\n }\n\n /** Execute a read-only call and return the decoded result. */\n async readContract<\n const TAbi extends Abi | readonly unknown[],\n TFunctionName extends ContractFunctionName<TAbi, \"pure\" | \"view\">,\n const TArgs extends ContractFunctionArgs<TAbi, \"pure\" | \"view\", TFunctionName>,\n >(\n config: ReadContractConfig<TAbi, TFunctionName, TArgs>,\n ): Promise<ContractFunctionReturnType<TAbi, \"pure\" | \"view\", TFunctionName, TArgs>> {\n return this.#publicClient.readContract(config);\n }\n\n /** Wait for a transaction to be mined and return its receipt. */\n async waitForTransactionReceipt(hash: Hex): Promise<TransactionReceipt> {\n return this.#publicClient.waitForTransactionReceipt({ hash });\n }\n\n /** Return the latest block timestamp in seconds. */\n async getBlockTimestamp(): Promise<bigint> {\n const block = await this.#publicClient.getBlock();\n return block.timestamp;\n }\n\n /** Build a fully-populated, RLP-encoded unsigned transaction ready to be signed offline. */\n async prepareTransaction<\n const TAbi extends ContractAbi,\n TFunctionName extends WriteFunctionName<TAbi>,\n const TArgs extends WriteContractArgs<TAbi, TFunctionName>,\n >(args: {\n from: Address;\n calldata: WriteContractConfig<TAbi, TFunctionName, TArgs>;\n nonce?: number;\n gasLimit?: bigint;\n fees?: { maxFeePerGas: bigint; maxPriorityFeePerGas: bigint };\n }): Promise<Hex> {\n const { from, calldata } = args;\n const data = encodeFunctionData({\n abi: calldata.abi as Abi,\n functionName: calldata.functionName as string,\n args: calldata.args as readonly unknown[],\n });\n // Wrap the estimateGas leg so a pre-flight revert (the most common\n // prepareTransaction failure) surfaces as a typed error with the\n // function name + cause. Other legs propagate as-is — failures there\n // (chainId, nonce, fee data) are rare and usually self-explanatory.\n // Skip the network round-trips entirely when the caller supplied\n // overrides — useful for custodians with their own nonce/fee managers.\n const chainIdPromise = this.#publicClient.getChainId();\n const noncePromise =\n args.nonce !== undefined\n ? Promise.resolve(args.nonce)\n : this.#publicClient.getTransactionCount({ address: from, blockTag: \"pending\" });\n const gasPromise =\n args.gasLimit !== undefined\n ? Promise.resolve(args.gasLimit)\n : (calldata.gas ??\n this.#publicClient\n .estimateGas({ account: from, to: calldata.address, data, value: calldata.value ?? 0n })\n .catch((error: unknown) => {\n throw new TransactionRevertedError(\n `ViemProvider.prepareTransaction: gas estimation reverted for ${calldata.functionName} on ${calldata.address}`,\n { cause: error },\n );\n }));\n const feesPromise = args.fees ?? this.#publicClient.estimateFeesPerGas();\n const [chainId, nonce, gas, fees] = await Promise.all([\n chainIdPromise,\n noncePromise,\n gasPromise,\n feesPromise,\n ]);\n return serializeTransaction({\n type: \"eip1559\",\n chainId,\n nonce,\n to: calldata.address,\n data,\n value: calldata.value ?? 0n,\n gas,\n maxFeePerGas: fees.maxFeePerGas,\n maxPriorityFeePerGas: fees.maxPriorityFeePerGas,\n });\n }\n}\n","import type {\n Account,\n Abi,\n ContractFunctionArgs,\n ContractFunctionName,\n EIP1193Provider,\n WalletClient,\n Hex,\n} from \"viem\";\nimport { getAddress } from \"viem\";\nimport type { writeContract } from \"viem/actions\";\nimport { WalletNotConnectedError } from \"../errors\";\nimport type { EIP712TypedData } from \"../relayer/types\";\nimport { BaseSigner } from \"../signer/base-signer\";\nimport { eip1193Subscribe } from \"../signer/eip1193-subscribe\";\nimport type { WalletAccount, WriteContractConfig } from \"../types\";\n\n/**\n * Configuration for {@link ViemSigner}.\n *\n * The optional `ethereum` field is needed for `subscribe()` (EIP-1193\n * `accountsChanged` / `disconnect` events). It cannot be auto-extracted from\n * `walletClient` because viem's `custom(ethereum)` transport captures the\n * provider in a closure and does **not** expose `on` / `removeListener` on\n * `walletClient.transport`.\n *\n * If you omit `ethereum`, `subscribe()` returns a no-op. For automatic\n * wallet lifecycle handling, consider using `WagmiSigner` instead.\n */\nexport interface ViemSignerConfig {\n /** Wallet client for signing and write operations. */\n walletClient: WalletClient;\n /** Raw EIP-1193 provider enabling wallet lifecycle events; omit for a no-op `subscribe()`. */\n ethereum?: EIP1193Provider;\n}\n\n// viem requires uint values as bigints, but the KMS permit message carries them\n// as decimal strings. Convert by declared field type rather than by name so every\n// permit version is covered (V1 `durationDays`, V2 `durationSeconds`, ...).\nfunction messageWithBigIntUints(typedData: EIP712TypedData): Record<string, unknown> {\n const fields = (typedData.primaryType ? typedData.types[typedData.primaryType] : undefined) ?? [];\n const message: Record<string, unknown> = { ...typedData.message };\n for (const { name, type } of fields) {\n if (/^uint\\d*$/.test(type)) {\n message[name] = BigInt(message[name] as string | number | bigint);\n }\n }\n return message;\n}\n\nfunction walletAccountFromWalletClient(walletClient: WalletClient): WalletAccount | undefined {\n if (!walletClient.account || !walletClient.chain) {\n return undefined;\n }\n const address = getAddress(walletClient.account.address);\n return { address, chainId: walletClient.chain.id };\n}\n\n/**\n * {@link GenericSigner} backed by a viem `WalletClient` for EIP-712 signing and\n * write transactions. Pass `ethereum` in {@link ViemSignerConfig} to track\n * wallet lifecycle events.\n */\nexport class ViemSigner extends BaseSigner {\n readonly #walletClient: WalletClient;\n readonly #ethereum?: EIP1193Provider;\n readonly #unsubscribeProvider: () => void;\n\n constructor(config: ViemSignerConfig) {\n super(walletAccountFromWalletClient(config.walletClient));\n this.#walletClient = config.walletClient;\n this.#ethereum = config.ethereum;\n this.#unsubscribeProvider = this.#subscribeToProvider();\n }\n\n #requireAccount(operation: string): { walletClient: WalletClient; account: Account } {\n if (!this.#walletClient.account) {\n throw new WalletNotConnectedError(operation);\n }\n return { walletClient: this.#walletClient, account: this.#walletClient.account };\n }\n\n /** Sign EIP-712 typed data (used for decrypt authorization). */\n async signTypedData(typedData: EIP712TypedData): Promise<Hex> {\n const { walletClient, account } = this.#requireAccount(\"signTypedData\");\n const { EIP712Domain: _, ...sigTypes } = typedData.types;\n return walletClient.signTypedData({\n account,\n primaryType: typedData.primaryType,\n types: sigTypes,\n domain: typedData.domain,\n message: messageWithBigIntUints(typedData),\n // Cast: EIP712TypedData is structural (`Eip712Like`), so viem cannot correlate primaryType/types/message and the inferred `message` collapses to `never`.\n } as Parameters<typeof walletClient.signTypedData>[0]);\n }\n\n /** Send a write transaction and return the tx hash. */\n async writeContract<\n const TAbi extends Abi | readonly unknown[],\n TFunctionName extends ContractFunctionName<TAbi, \"nonpayable\" | \"payable\">,\n const TArgs extends ContractFunctionArgs<TAbi, \"nonpayable\" | \"payable\", TFunctionName>,\n >(config: WriteContractConfig<TAbi, TFunctionName, TArgs>): Promise<Hex> {\n const { walletClient, account } = this.#requireAccount(\"writeContract\");\n return walletClient.writeContract({\n chain: walletClient.chain,\n account,\n ...config,\n } as Parameters<typeof writeContract>[1]);\n }\n\n #subscribeToProvider(): () => void {\n if (!this.#ethereum) {\n return () => {};\n }\n return eip1193Subscribe({\n provider: this.#ethereum,\n getInitialWalletAccount: () => walletAccountFromWalletClient(this.#walletClient),\n onWalletAccountChange: ({ next }) => {\n this.walletAccount.setSnapshot(next);\n },\n });\n }\n\n /** Unsubscribe from the EIP-1193 provider's wallet lifecycle events. */\n protected override onDispose(): void {\n this.#unsubscribeProvider();\n }\n}\n","import type { FheChain } from \"../chains\";\nimport type { ZamaConfig } from \"../config/types\";\nimport { buildZamaConfig } from \"../config/build\";\nimport { ViemProvider } from \"./viem-provider\";\nimport { ViemSigner } from \"./viem-signer\";\nimport type { ZamaConfigViem } from \"./types\";\n\n/** Create a {@link ZamaConfig} from viem clients. */\nexport function createConfig<const TChains extends readonly [FheChain, ...FheChain[]]>(\n params: ZamaConfigViem<TChains>,\n): ZamaConfig {\n const signer = new ViemSigner({ walletClient: params.walletClient, ethereum: params.ethereum });\n const provider = new ViemProvider({ publicClient: params.publicClient });\n return buildZamaConfig(signer, provider, params);\n}\n","import type { PublicClient, WalletClient, Address, Hex } from \"viem\";\nimport type { EncryptedValue } from \"../relayer/types\";\nimport {\n confidentialBalanceOfContract,\n confidentialTransferContract,\n finalizeUnwrapContract,\n setOperatorContract,\n supportsInterfaceContract,\n underlyingContract,\n unwrapContract,\n unwrapFromBalanceContract,\n wrapContract,\n getTokenPairsContract,\n getTokenPairsLengthContract,\n getTokenPairsSliceContract,\n getTokenPairContract,\n getConfidentialTokenAddressContract,\n getTokenAddressContract,\n isConfidentialTokenValidContract,\n} from \"../contracts\";\n\n// ── Helpers ────────────────────────────────────────────────\n\nfunction requireAccount(client: WalletClient) {\n if (!client.account) {\n throw new TypeError(\"WalletClient has no account\");\n }\n return client.account;\n}\n\n// ── Read helpers ────────────────────────────────────────────\n\n/** Reads a token's confidential (encrypted) balance handle for `userAddress` via a viem client. */\nexport function readConfidentialBalanceOfContract(\n client: PublicClient,\n tokenAddress: Address,\n userAddress: Address,\n) {\n return client.readContract(confidentialBalanceOfContract(tokenAddress, userAddress));\n}\n\n/** Reads the underlying ERC-20 address wrapped by a confidential wrapper via a viem client. */\nexport function readUnderlyingTokenContract(client: PublicClient, wrapperAddress: Address) {\n return client.readContract(underlyingContract(wrapperAddress));\n}\n\n/** Reads whether a token implements the given ERC-165 interface id via a viem client. */\nexport function readSupportsInterfaceContract(\n client: PublicClient,\n tokenAddress: Address,\n interfaceId: Address,\n) {\n return client.readContract(supportsInterfaceContract(tokenAddress, interfaceId));\n}\n\n// ── Write helpers ───────────────────────────────────────────\n\n/** Submits a confidential transfer of an encrypted amount to `to` via a viem wallet client. */\nexport function writeConfidentialTransferContract(\n client: WalletClient,\n tokenAddress: Address,\n to: Address,\n encryptedAmount: EncryptedValue,\n inputProof: Hex,\n) {\n return client.writeContract({\n chain: client.chain,\n account: requireAccount(client),\n ...confidentialTransferContract(tokenAddress, to, encryptedAmount, inputProof),\n });\n}\n\n/** Submits an unwrap of an encrypted amount from `from` to `to` on a confidential ERC-20 via a viem wallet client. */\nexport function writeUnwrapContract(\n client: WalletClient,\n encryptedErc20: Address,\n from: Address,\n to: Address,\n encryptedAmount: EncryptedValue,\n inputProof: Hex,\n) {\n return client.writeContract({\n chain: client.chain,\n account: requireAccount(client),\n ...unwrapContract(encryptedErc20, from, to, encryptedAmount, inputProof),\n });\n}\n\n/** Submits an unwrap of the full encrypted balance from `from` to `to` via a viem wallet client. */\nexport function writeUnwrapFromBalanceContract(\n client: WalletClient,\n encryptedErc20: Address,\n from: Address,\n to: Address,\n encryptedBalance: EncryptedValue,\n) {\n return client.writeContract({\n chain: client.chain,\n account: requireAccount(client),\n ...unwrapFromBalanceContract(encryptedErc20, from, to, encryptedBalance),\n });\n}\n\n/** Finalizes a pending unwrap request with the decrypted amount and decryption proof via a viem wallet client. */\nexport function writeFinalizeUnwrapContract(\n client: WalletClient,\n wrapper: Address,\n unwrapRequestId: EncryptedValue,\n unwrapAmountCleartext: bigint,\n decryptionProof: Hex,\n) {\n return client.writeContract({\n chain: client.chain,\n account: requireAccount(client),\n ...finalizeUnwrapContract(wrapper, unwrapRequestId, unwrapAmountCleartext, decryptionProof),\n });\n}\n\n/** Authorizes `operator` on a token, until an optional expiry timestamp, via a viem wallet client. */\nexport function writeSetOperatorContract(\n client: WalletClient,\n tokenAddress: Address,\n operator: Address,\n until?: number,\n) {\n return client.writeContract({\n chain: client.chain,\n account: requireAccount(client),\n ...setOperatorContract(tokenAddress, operator, until),\n });\n}\n\n/** Wraps `amount` of the underlying ERC-20 into confidential tokens credited to `to` via a viem wallet client. */\nexport function writeWrapContract(\n client: WalletClient,\n wrapperAddress: Address,\n to: Address,\n amount: bigint,\n) {\n return client.writeContract({\n chain: client.chain,\n account: requireAccount(client),\n ...wrapContract(wrapperAddress, to, amount),\n });\n}\n\n// ── Registry read helpers ──────────────────────────────────\n\n/** Reads all underlying/confidential token pairs from a wrappers registry via a viem client. */\nexport function readTokenPairsContract(client: PublicClient, registry: Address) {\n return client.readContract(getTokenPairsContract(registry));\n}\n\n/** Reads the number of token pairs in a wrappers registry via a viem client. */\nexport function readTokenPairsLengthContract(client: PublicClient, registry: Address) {\n return client.readContract(getTokenPairsLengthContract(registry));\n}\n\n/** Reads a slice of token pairs (`fromIndex` to `toIndex`) from a wrappers registry via a viem client. */\nexport function readTokenPairsSliceContract(\n client: PublicClient,\n registry: Address,\n fromIndex: bigint,\n toIndex: bigint,\n) {\n return client.readContract(getTokenPairsSliceContract(registry, fromIndex, toIndex));\n}\n\n/** Reads the token pair at `index` from a wrappers registry via a viem client. */\nexport function readTokenPairContract(client: PublicClient, registry: Address, index: bigint) {\n return client.readContract(getTokenPairContract(registry, index));\n}\n\n/** Reads the confidential token registered for a given underlying token in a wrappers registry via a viem client. */\nexport function readConfidentialTokenAddressContract(\n client: PublicClient,\n registry: Address,\n tokenAddress: Address,\n) {\n return client.readContract(getConfidentialTokenAddressContract(registry, tokenAddress));\n}\n\n/** Reads the underlying token registered for a given confidential token in a wrappers registry via a viem client. */\nexport function readTokenAddressContract(\n client: PublicClient,\n registry: Address,\n confidentialTokenAddress: Address,\n) {\n return client.readContract(getTokenAddressContract(registry, confidentialTokenAddress));\n}\n\n/** Reads whether a confidential token is registered and valid in a wrappers registry via a viem client. */\nexport function readIsConfidentialTokenValidContract(\n client: PublicClient,\n registry: Address,\n confidentialTokenAddress: Address,\n) {\n return client.readContract(isConfidentialTokenValidContract(registry, confidentialTokenAddress));\n}\n"],"mappings":"kXAyCA,IAAa,EAAb,KAAqD,CACnD,GAEA,YAAY,EAA4B,CACtC,KAAKA,GAAgB,EAAO,YAC9B,C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O,MACd,QAAS,EAAe,CAAM,EAC9B,GAAG,EAAuB,EAAS,EAAiB,EAAuB,CAAe,CAC5F,CAAC,CACH,CAGA,SAAgB,EACd,EACA,EACA,EACA,EACA,CACA,OAAO,EAAO,cAAc,CAC1B,MAAO,EAAO,MACd,QAAS,EAAe,CAAM,EAC9B,GAAG,EAAoB,EAAc,EAAU,CAAK,CACtD,CAAC,CACH,CAGA,SAAgB,EACd,EACA,EACA,EACA,EACA,CACA,OAAO,EAAO,cAAc,CAC1B,MAAO,EAAO,MACd,QAAS,EAAe,CAAM,EAC9B,GAAG,EAAa,EAAgB,EAAI,CAAM,CAC5C,CAAC,CACH,CAKA,SAAgB,EAAuB,EAAsB,EAAmB,CAC9E,OAAO,EAAO,aAAa,EAAsB,CAAQ,CAAC,CAC5D,CAGA,SAAgB,EAA6B,EAAsB,EAAmB,CACpF,OAAO,EAAO,aAAa,EAA4B,CAAQ,CAAC,CAClE,CAGA,SAAgB,EACd,EACA,EACA,EACA,EACA,CACA,OAAO,EAAO,aAAa,EAA2B,EAAU,EAAW,CAAO,CAAC,CACrF,CAGA,SAAgB,EAAsB,EAAsB,EAAmB,EAAe,CAC5F,OAAO,EAAO,aAAa,EAAqB,EAAU,CAAK,CAAC,CAClE,CAGA,SAAgB,EACd,EACA,EACA,EACA,CACA,OAAO,EAAO,aAAa,EAAoC,EAAU,CAAY,CAAC,CACxF,CAGA,SAAgB,EACd,EACA,EACA,EACA,CACA,OAAO,EAAO,aAAa,EAAwB,EAAU,CAAwB,CAAC,CACxF,CAGA,SAAgB,EACd,EACA,EACA,EACA,CACA,OAAO,EAAO,aAAa,EAAiC,EAAU,CAAwB,CAAC,CACjG"}
|
|
1
|
+
{"version":3,"file":"index.js","names":["#publicClient","#walletClient","#ethereum","#unsubscribeProvider","#subscribeToProvider","#requireAccount"],"sources":["../../../src/viem/viem-provider.ts","../../../src/viem/viem-signer.ts","../../../src/viem/config.ts","../../../src/viem/contracts.ts"],"sourcesContent":["import {\n encodeFunctionData,\n serializeTransaction,\n type Abi,\n type Address,\n type ContractFunctionArgs,\n type ContractFunctionName,\n type ContractFunctionReturnType,\n type Hex,\n type PublicClient,\n} from \"viem\";\nimport { TransactionRevertedError } from \"../errors\";\nimport type {\n ContractAbi,\n GenericProvider,\n ReadContractConfig,\n TransactionReceipt,\n WriteContractArgs,\n WriteContractConfig,\n WriteFunctionName,\n} from \"../types\";\n\n/** Configuration for {@link ViemProvider}. */\nexport interface ViemProviderConfig {\n /** A viem `PublicClient` backing all read operations. */\n publicClient: PublicClient;\n}\n\n/**\n * Read-only {@link GenericProvider} backed by a viem `PublicClient`.\n *\n * Use this for integrations that only need public chain reads before the user has Pair with a\n * {@link ViemSigner} when wallet authority is required; the two can share a transport or point at\n * independent RPCs.\n *\n * @example\n * ```ts\n * const publicClient = createPublicClient({ chain: sepolia, transport: http(ALCHEMY_URL) });\n * const provider = new ViemProvider({ publicClient });\n * ```\n */\nexport class ViemProvider implements GenericProvider {\n readonly #publicClient: PublicClient;\n\n constructor(config: ViemProviderConfig) {\n this.#publicClient = config.publicClient;\n }\n\n /** Return the chain ID of the connected network. */\n async getChainId(): Promise<number> {\n return this.#publicClient.getChainId();\n }\n\n /** Execute a read-only call and return the decoded result. */\n async readContract<\n const TAbi extends Abi | readonly unknown[],\n TFunctionName extends ContractFunctionName<TAbi, \"pure\" | \"view\">,\n const TArgs extends ContractFunctionArgs<TAbi, \"pure\" | \"view\", TFunctionName>,\n >(\n config: ReadContractConfig<TAbi, TFunctionName, TArgs>,\n ): Promise<ContractFunctionReturnType<TAbi, \"pure\" | \"view\", TFunctionName, TArgs>> {\n return this.#publicClient.readContract(config);\n }\n\n /** Wait for a transaction to be mined and return its receipt. */\n async waitForTransactionReceipt(hash: Hex): Promise<TransactionReceipt> {\n return this.#publicClient.waitForTransactionReceipt({ hash });\n }\n\n /** Return the latest block timestamp in seconds. */\n async getBlockTimestamp(): Promise<bigint> {\n const block = await this.#publicClient.getBlock();\n return block.timestamp;\n }\n\n /** Build a fully-populated, RLP-encoded unsigned transaction ready to be signed offline. */\n async prepareTransaction<\n const TAbi extends ContractAbi,\n TFunctionName extends WriteFunctionName<TAbi>,\n const TArgs extends WriteContractArgs<TAbi, TFunctionName>,\n >(args: {\n from: Address;\n calldata: WriteContractConfig<TAbi, TFunctionName, TArgs>;\n nonce?: number;\n gasLimit?: bigint;\n fees?: { maxFeePerGas: bigint; maxPriorityFeePerGas: bigint };\n }): Promise<Hex> {\n const { from, calldata } = args;\n const data = encodeFunctionData({\n abi: calldata.abi as Abi,\n functionName: calldata.functionName as string,\n args: calldata.args as readonly unknown[],\n });\n // Wrap the estimateGas leg so a pre-flight revert (the most common\n // prepareTransaction failure) surfaces as a typed error with the\n // function name + cause. Other legs propagate as-is — failures there\n // (chainId, nonce, fee data) are rare and usually self-explanatory.\n // Skip the network round-trips entirely when the caller supplied\n // overrides — useful for custodians with their own nonce/fee managers.\n const chainIdPromise = this.#publicClient.getChainId();\n const noncePromise =\n args.nonce !== undefined\n ? Promise.resolve(args.nonce)\n : this.#publicClient.getTransactionCount({ address: from, blockTag: \"pending\" });\n const gasPromise =\n args.gasLimit !== undefined\n ? Promise.resolve(args.gasLimit)\n : (calldata.gas ??\n this.#publicClient\n .estimateGas({ account: from, to: calldata.address, data, value: calldata.value ?? 0n })\n .catch((error: unknown) => {\n throw new TransactionRevertedError(\n `ViemProvider.prepareTransaction: gas estimation reverted for ${calldata.functionName} on ${calldata.address}`,\n { cause: error },\n );\n }));\n const feesPromise = args.fees ?? this.#publicClient.estimateFeesPerGas();\n const [chainId, nonce, gas, fees] = await Promise.all([\n chainIdPromise,\n noncePromise,\n gasPromise,\n feesPromise,\n ]);\n return serializeTransaction({\n type: \"eip1559\",\n chainId,\n nonce,\n to: calldata.address,\n data,\n value: calldata.value ?? 0n,\n gas,\n maxFeePerGas: fees.maxFeePerGas,\n maxPriorityFeePerGas: fees.maxPriorityFeePerGas,\n });\n }\n}\n","import type {\n Account,\n Abi,\n ContractFunctionArgs,\n ContractFunctionName,\n EIP1193Provider,\n WalletClient,\n Hex,\n} from \"viem\";\nimport { getAddress } from \"viem\";\nimport type { writeContract } from \"viem/actions\";\nimport { WalletNotConnectedError } from \"../errors\";\nimport type { EIP712TypedData } from \"../relayer/types\";\nimport { BaseSigner } from \"../signer/base-signer\";\nimport { eip1193Subscribe } from \"../signer/eip1193-subscribe\";\nimport type { WalletAccount, WriteContractConfig } from \"../types\";\n\n/**\n * Configuration for {@link ViemSigner}.\n *\n * The optional `ethereum` field is needed for `subscribe()` (EIP-1193\n * `accountsChanged` / `disconnect` events). It cannot be auto-extracted from\n * `walletClient` because viem's `custom(ethereum)` transport captures the\n * provider in a closure and does **not** expose `on` / `removeListener` on\n * `walletClient.transport`.\n *\n * If you omit `ethereum`, `subscribe()` returns a no-op. For automatic\n * wallet lifecycle handling, consider using `WagmiSigner` instead.\n */\nexport interface ViemSignerConfig {\n /** Wallet client for signing and write operations. */\n walletClient: WalletClient;\n /** Raw EIP-1193 provider enabling wallet lifecycle events; omit for a no-op `subscribe()`. */\n ethereum?: EIP1193Provider;\n}\n\n// viem requires uint values as bigints, but the KMS permit message carries them\n// as decimal strings. Convert by declared field type rather than by name so every\n// permit version is covered (V1 `durationDays`, V2 `durationSeconds`, ...).\nfunction messageWithBigIntUints(typedData: EIP712TypedData): Record<string, unknown> {\n const fields = (typedData.primaryType ? typedData.types[typedData.primaryType] : undefined) ?? [];\n const message: Record<string, unknown> = { ...typedData.message };\n for (const { name, type } of fields) {\n if (/^uint\\d*$/.test(type)) {\n message[name] = BigInt(message[name] as string | number | bigint);\n }\n }\n return message;\n}\n\nfunction walletAccountFromWalletClient(walletClient: WalletClient): WalletAccount | undefined {\n if (!walletClient.account || !walletClient.chain) {\n return undefined;\n }\n const address = getAddress(walletClient.account.address);\n return { address, chainId: walletClient.chain.id };\n}\n\n/**\n * {@link GenericSigner} backed by a viem `WalletClient` for EIP-712 signing and\n * write transactions. Pass `ethereum` in {@link ViemSignerConfig} to track\n * wallet lifecycle events.\n */\nexport class ViemSigner extends BaseSigner {\n readonly #walletClient: WalletClient;\n readonly #ethereum?: EIP1193Provider;\n readonly #unsubscribeProvider: () => void;\n\n constructor(config: ViemSignerConfig) {\n super(walletAccountFromWalletClient(config.walletClient));\n this.#walletClient = config.walletClient;\n this.#ethereum = config.ethereum;\n this.#unsubscribeProvider = this.#subscribeToProvider();\n }\n\n #requireAccount(operation: string): { walletClient: WalletClient; account: Account } {\n if (!this.#walletClient.account) {\n throw new WalletNotConnectedError(operation);\n }\n return { walletClient: this.#walletClient, account: this.#walletClient.account };\n }\n\n /** Sign EIP-712 typed data (used for decrypt authorization). */\n async signTypedData(typedData: EIP712TypedData): Promise<Hex> {\n const { walletClient, account } = this.#requireAccount(\"signTypedData\");\n const { EIP712Domain: _, ...sigTypes } = typedData.types;\n return walletClient.signTypedData({\n account,\n primaryType: typedData.primaryType,\n types: sigTypes,\n domain: typedData.domain,\n message: messageWithBigIntUints(typedData),\n // Cast: EIP712TypedData is structural (`Eip712Like`), so viem cannot correlate primaryType/types/message and the inferred `message` collapses to `never`.\n } as Parameters<typeof walletClient.signTypedData>[0]);\n }\n\n /** Send a write transaction and return the tx hash. */\n async writeContract<\n const TAbi extends Abi | readonly unknown[],\n TFunctionName extends ContractFunctionName<TAbi, \"nonpayable\" | \"payable\">,\n const TArgs extends ContractFunctionArgs<TAbi, \"nonpayable\" | \"payable\", TFunctionName>,\n >(config: WriteContractConfig<TAbi, TFunctionName, TArgs>): Promise<Hex> {\n const { walletClient, account } = this.#requireAccount(\"writeContract\");\n return walletClient.writeContract({\n chain: walletClient.chain,\n account,\n ...config,\n } as Parameters<typeof writeContract>[1]);\n }\n\n #subscribeToProvider(): () => void {\n if (!this.#ethereum) {\n return () => {};\n }\n return eip1193Subscribe({\n provider: this.#ethereum,\n getInitialWalletAccount: () => walletAccountFromWalletClient(this.#walletClient),\n onWalletAccountChange: ({ next }) => {\n this.walletAccount.setSnapshot(next);\n },\n });\n }\n\n /** Unsubscribe from the EIP-1193 provider's wallet lifecycle events. */\n protected override onDispose(): void {\n this.#unsubscribeProvider();\n }\n}\n","import type { FheChain } from \"../chains\";\nimport type { ZamaConfig } from \"../config/types\";\nimport { buildZamaConfig } from \"../config/build\";\nimport { ViemProvider } from \"./viem-provider\";\nimport { ViemSigner } from \"./viem-signer\";\nimport type { ZamaConfigViem } from \"./types\";\n\n/** Create a {@link ZamaConfig} from viem clients. */\nexport function createConfig<const TChains extends readonly [FheChain, ...FheChain[]]>(\n params: ZamaConfigViem<TChains>,\n): ZamaConfig {\n const signer = new ViemSigner({ walletClient: params.walletClient, ethereum: params.ethereum });\n const provider = new ViemProvider({ publicClient: params.publicClient });\n return buildZamaConfig(signer, provider, params);\n}\n","import type { PublicClient, WalletClient, Address, Hex } from \"viem\";\nimport type { EncryptedValue } from \"../relayer/types\";\nimport {\n confidentialBalanceOfContract,\n confidentialTransferContract,\n finalizeUnwrapContract,\n setOperatorContract,\n supportsInterfaceContract,\n underlyingContract,\n unwrapContract,\n unwrapFromBalanceContract,\n wrapContract,\n getTokenPairsContract,\n getTokenPairsLengthContract,\n getTokenPairsSliceContract,\n getTokenPairContract,\n getConfidentialTokenAddressContract,\n getTokenAddressContract,\n isConfidentialTokenValidContract,\n} from \"../contracts\";\n\n// ── Helpers ────────────────────────────────────────────────\n\nfunction requireAccount(client: WalletClient) {\n if (!client.account) {\n throw new TypeError(\"WalletClient has no account\");\n }\n return client.account;\n}\n\n// ── Read helpers ────────────────────────────────────────────\n\n/** Reads a token's confidential (encrypted) balance handle for `userAddress` via a viem client. */\nexport function readConfidentialBalanceOfContract(\n client: PublicClient,\n tokenAddress: Address,\n userAddress: Address,\n) {\n return client.readContract(confidentialBalanceOfContract(tokenAddress, userAddress));\n}\n\n/** Reads the underlying ERC-20 address wrapped by a confidential wrapper via a viem client. */\nexport function readUnderlyingTokenContract(client: PublicClient, wrapperAddress: Address) {\n return client.readContract(underlyingContract(wrapperAddress));\n}\n\n/** Reads whether a token implements the given ERC-165 interface id via a viem client. */\nexport function readSupportsInterfaceContract(\n client: PublicClient,\n tokenAddress: Address,\n interfaceId: Address,\n) {\n return client.readContract(supportsInterfaceContract(tokenAddress, interfaceId));\n}\n\n// ── Write helpers ───────────────────────────────────────────\n\n/** Submits a confidential transfer of an encrypted amount to `to` via a viem wallet client. */\nexport function writeConfidentialTransferContract(\n client: WalletClient,\n tokenAddress: Address,\n to: Address,\n encryptedAmount: EncryptedValue,\n inputProof: Hex,\n) {\n return client.writeContract({\n chain: client.chain,\n account: requireAccount(client),\n ...confidentialTransferContract(tokenAddress, to, encryptedAmount, inputProof),\n });\n}\n\n/** Submits an unwrap of an encrypted amount from `from` to `to` on a confidential ERC-20 via a viem wallet client. */\nexport function writeUnwrapContract(\n client: WalletClient,\n encryptedErc20: Address,\n from: Address,\n to: Address,\n encryptedAmount: EncryptedValue,\n inputProof: Hex,\n) {\n return client.writeContract({\n chain: client.chain,\n account: requireAccount(client),\n ...unwrapContract(encryptedErc20, from, to, encryptedAmount, inputProof),\n });\n}\n\n/** Submits an unwrap of the full encrypted balance from `from` to `to` via a viem wallet client. */\nexport function writeUnwrapFromBalanceContract(\n client: WalletClient,\n encryptedErc20: Address,\n from: Address,\n to: Address,\n encryptedBalance: EncryptedValue,\n) {\n return client.writeContract({\n chain: client.chain,\n account: requireAccount(client),\n ...unwrapFromBalanceContract(encryptedErc20, from, to, encryptedBalance),\n });\n}\n\n/** Finalizes a pending unwrap request with the decrypted amount and decryption proof via a viem wallet client. */\nexport function writeFinalizeUnwrapContract(\n client: WalletClient,\n wrapper: Address,\n unwrapRequestId: EncryptedValue,\n unwrapAmountCleartext: bigint,\n decryptionProof: Hex,\n) {\n return client.writeContract({\n chain: client.chain,\n account: requireAccount(client),\n ...finalizeUnwrapContract(wrapper, unwrapRequestId, unwrapAmountCleartext, decryptionProof),\n });\n}\n\n/** Authorizes `operator` on a token, until an optional expiry timestamp, via a viem wallet client. */\nexport function writeSetOperatorContract(\n client: WalletClient,\n tokenAddress: Address,\n operator: Address,\n until?: number,\n) {\n return client.writeContract({\n chain: client.chain,\n account: requireAccount(client),\n ...setOperatorContract(tokenAddress, operator, until),\n });\n}\n\n/** Wraps `amount` of the underlying ERC-20 into confidential tokens credited to `to` via a viem wallet client. */\nexport function writeWrapContract(\n client: WalletClient,\n wrapperAddress: Address,\n to: Address,\n amount: bigint,\n) {\n return client.writeContract({\n chain: client.chain,\n account: requireAccount(client),\n ...wrapContract(wrapperAddress, to, amount),\n });\n}\n\n// ── Registry read helpers ──────────────────────────────────\n\n/** Reads all underlying/confidential token pairs from a wrappers registry via a viem client. */\nexport function readTokenPairsContract(client: PublicClient, registry: Address) {\n return client.readContract(getTokenPairsContract(registry));\n}\n\n/** Reads the number of token pairs in a wrappers registry via a viem client. */\nexport function readTokenPairsLengthContract(client: PublicClient, registry: Address) {\n return client.readContract(getTokenPairsLengthContract(registry));\n}\n\n/** Reads a slice of token pairs (`fromIndex` to `toIndex`) from a wrappers registry via a viem client. */\nexport function readTokenPairsSliceContract(\n client: PublicClient,\n registry: Address,\n fromIndex: bigint,\n toIndex: bigint,\n) {\n return client.readContract(getTokenPairsSliceContract(registry, fromIndex, toIndex));\n}\n\n/** Reads the token pair at `index` from a wrappers registry via a viem client. */\nexport function readTokenPairContract(client: PublicClient, registry: Address, index: bigint) {\n return client.readContract(getTokenPairContract(registry, index));\n}\n\n/** Reads the confidential token registered for a given underlying token in a wrappers registry via a viem client. */\nexport function readConfidentialTokenAddressContract(\n client: PublicClient,\n registry: Address,\n tokenAddress: Address,\n) {\n return client.readContract(getConfidentialTokenAddressContract(registry, tokenAddress));\n}\n\n/** Reads the underlying token registered for a given confidential token in a wrappers registry via a viem client. */\nexport function readTokenAddressContract(\n client: PublicClient,\n registry: Address,\n confidentialTokenAddress: Address,\n) {\n return client.readContract(getTokenAddressContract(registry, confidentialTokenAddress));\n}\n\n/** Reads whether a confidential token is registered and valid in a wrappers registry via a viem client. */\nexport function readIsConfidentialTokenValidContract(\n client: PublicClient,\n registry: Address,\n confidentialTokenAddress: Address,\n) {\n return client.readContract(isConfidentialTokenValidContract(registry, confidentialTokenAddress));\n}\n"],"mappings":"oXAyCA,IAAa,EAAb,KAAqD,CACnD,GAEA,YAAY,EAA4B,CACtC,KAAKA,GAAgB,EAAO,YAC9B,CAGA,MAAM,YAA8B,CAClC,OAAO,KAAKA,GAAc,WAAW,CACvC,CAGA,MAAM,aAKJ,EACkF,CAClF,OAAO,KAAKA,GAAc,aAAa,CAAM,CAC/C,CAGA,MAAM,0BAA0B,EAAwC,CACtE,OAAO,KAAKA,GAAc,0BAA0B,CAAE,MAAK,CAAC,CAC9D,CAGA,MAAM,mBAAqC,CAEzC,OAAO,MADa,KAAKA,GAAc,SAAS,EAAA,CACnC,SACf,CAGA,MAAM,mBAIJ,EAMe,CACf,GAAM,CAAE,OAAM,YAAa,EACrB,EAAO,EAAmB,CAC9B,IAAK,EAAS,IACd,aAAc,EAAS,aACvB,KAAM,EAAS,IACjB,CAAC,EAOK,EAAiB,KAAKA,GAAc,WAAW,EAC/C,EACJ,EAAK,QAAU,IAAA,GAEX,KAAKA,GAAc,oBAAoB,CAAE,QAAS,EAAM,SAAU,SAAU,CAAC,EAD7E,QAAQ,QAAQ,EAAK,KAAK,EAE1B,EACJ,EAAK,WAAa,IAAA,GAEb,EAAS,KACV,KAAKA,GACF,YAAY,CAAE,QAAS,EAAM,GAAI,EAAS,QAAS,OAAM,MAAO,EAAS,OAAS,EAAG,CAAC,CAAC,CACvF,MAAO,GAAmB,CACzB,MAAM,IAAI,EACR,gEAAgE,EAAS,aAAa,MAAM,EAAS,UACrG,CAAE,MAAO,CAAM,CACjB,CACF,CAAC,EATH,QAAQ,QAAQ,EAAK,QAAQ,EAU7B,EAAc,EAAK,MAAQ,KAAKA,GAAc,mBAAmB,EACjE,CAAC,EAAS,EAAO,EAAK,GAAQ,MAAM,QAAQ,IAAI,CACpD,EACA,EACA,EACA,CACF,CAAC,EACD,OAAO,EAAqB,CAC1B,KAAM,UACN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web/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { dn as FhevmRuntimeConfig, fn as RelayerOptions, ln as FhevmClientOptions, n as RelayerConfig, r as WebRelayerConfig, un as FhevmRelayerOptions } from "../types-BOyFfG7D.js";
|
|
2
2
|
import { EIP1193Provider } from "viem";
|
|
3
3
|
import "@fhevm/sdk/chains";
|
|
4
4
|
//#region src/worker/encrypt-worker-client.d.ts
|
package/dist/esm/web/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{n as e,t}from"../fhevm-relayer-
|
|
1
|
+
import{n as e,t}from"../fhevm-relayer-CPmCytDX.js";import{t as n}from"../validation-DWe2k89s.js";import{z as r}from"zod/mini";const i=e=>r._default(r.number().check(r.positive()),e),a=r.custom(e=>typeof e==`function`),o=r.object({offloadEncrypt:r._default(r.union([r.literal(`auto`),r.boolean()]),`auto`),offloadTimeouts:r.optional(r.object({spawn:i(e.spawn),init:i(e.init)})),offloadWorker:r.optional(r.union([r.string().check(r.minLength(1)),r.instanceof(URL),a]))});function s(e){let{offloadEncrypt:r,offloadTimeouts:i,offloadWorker:a,...s}=e??{},c=n(o,{offloadEncrypt:r,offloadTimeouts:i,offloadWorker:a});return{type:`web`,createRelayer:(e,n)=>new t({chain:e,options:s,offloadEncrypt:c.offloadEncrypt,offloadTimeouts:c.offloadTimeouts,offloadWorker:c.offloadWorker,logger:n})}}export{s as web};
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{b as e,i as t,l as n,p as r,r as i,u as a}from"./relayer-B6Zo6EkX.js";import{erc20Abi as o,getAddress as s,isAddress as c,isHex as l}from"viem";import{z as u}from"zod/mini";var d=class extends i{constructor(e,n){super(t.TransportKeyPairExpired,e,n),this.name=`TransportKeyPairExpiredError`}},f=class extends i{constructor(e,n){super(t.InvalidTransportKeyPair,e,n),this.name=`InvalidTransportKeyPairError`}},p=class extends i{constructor(e,n){super(t.RevokedKmsContext,e,n),this.name=`RevokedKmsContextError`}},m=class extends i{constructor(e,n){super(t.NoCiphertext,e,n),this.name=`NoCiphertextError`}},ee=class extends i{constructor(e,n){super(t.KeyWrappingFailed,e,n),this.name=`KeyWrappingError`}},te=class extends i{constructor(e,n){super(t.TransportKeyPairChanged,e,n),this.name=`TransportKeyPairChangedError`}},h=class extends i{preparedChainId;activeChainId;constructor({preparedChainId:e,activeChainId:n},r){super(t.PreparedPermitChainMismatch,`registerPermit: prepared.chainId (${e}) does not match the active chain (${n}). Register the permit while the SDK is configured for the chain it was prepared for.`,r),this.name=`PreparedPermitChainMismatchError`,this.preparedChainId=e,this.activeChainId=n}},g=class extends i{constructor(e,n){super(t.PreparedPermitExpired,e,n),this.name=`PreparedPermitExpiredError`}},_=class extends i{constructor(e,n){super(t.UnifiedPermitNotSupported,e,n),this.name=`UnifiedPermitNotSupportedError`}};function v(e){return`${e}: V2 (unified) decryption permits — including wildcard permits — require protocol v0.14 or later on this network. The connected chain hasn't upgraded yet (or its ProtocolConfig contract address isn't configured on this FheChain). Call ${e} with an explicit V1 contract list instead, or retry once the network upgrades.`}function y(e){return new _(v(e))}function ne(t,n){if(!(!(n instanceof Error)||!e(n.message)))return new _(v(t),{cause:n})}var re=class extends i{constructor(e,n){super(t.UnifiedDecryptionUnsupported,e,n),this.name=`UnifiedDecryptionUnsupportedError`}},ie=class extends i{constructor(e,n){super(t.InvalidationTimestampTooLow,e,n),this.name=`InvalidationTimestampTooLowError`}},ae=class extends i{constructor(e,n){super(t.InvalidationTimestampInFuture,e,n),this.name=`InvalidationTimestampInFutureError`}},b=class extends i{operation;rpcCode;walletErrorName;constructor(e,n){let{operation:r,rpcCode:i,walletErrorName:a,...o}=n??{};super(t.SigningRejected,e,o),this.name=`SigningRejectedError`,this.operation=r,this.rpcCode=i,this.walletErrorName=a}},x=class extends i{operation;rpcCode;walletErrorName;constructor(e,n){let{operation:r,rpcCode:i,walletErrorName:a,...o}=n??{};super(t.SigningFailed,e,o),this.name=`SigningFailedError`,this.operation=r,this.rpcCode=i,this.walletErrorName=a}};function oe(e,t){if(e instanceof i)return e;let{operation:o}=t,s=typeof e==`object`&&!!e&&`code`in e&&e.code===4001,c=e instanceof Error?e.message:String(e),l=c.toLowerCase(),u=l.includes(`user rejected`)||l.includes(`user denied`),d=`${o}: ${c}`;return s||u?new b(d,{cause:e,operation:o,rpcCode:n(e),walletErrorName:a(e)}):r(c)?new f(d,{cause:e}):new x(d,{cause:e,operation:o,rpcCode:n(e),walletErrorName:a(e)})}var S=class extends i{constructor(e,n){super(t.TransactionReverted,e,n),this.name=`TransactionRevertedError`}},C=class extends i{operation;constructor(e,t,n,r){super(e,n,r),this.name=`SignerRequiredError`,this.operation=t}},w=class extends C{constructor(e,n){super(t.SignerNotConfigured,e,`Cannot ${e} without a signer. Configure one via createConfig({ signer: ... }) or <ZamaProvider config={createConfig({ signer: ... })}>.`,n),this.name=`SignerNotConfiguredError`}},T=class extends C{constructor(e,n){super(t.WalletNotConnected,e,`Cannot ${e} without a connected wallet account.`,n),this.name=`WalletNotConnectedError`}},E=class extends C{constructor(e,n){super(t.WalletAccountNotReady,e,`Cannot ${e} before the wallet account is ready.`,n),this.name=`WalletAccountNotReadyError`}};function D(e,t){if(e==null)throw new w(t);return e}const O={EncryptStart:`encrypt:start`,EncryptEnd:`encrypt:end`,EncryptError:`encrypt:error`,DecryptStart:`decrypt:start`,DecryptEnd:`decrypt:end`,DecryptError:`decrypt:error`,PermitError:`permit:error`,TransactionError:`transaction:error`,ShieldSubmitted:`shield:submitted`,TransferSubmitted:`transfer:submitted`,TransferFromSubmitted:`transferFrom:submitted`,SetOperatorSubmitted:`setOperator:submitted`,ApproveUnderlyingSubmitted:`approveUnderlying:submitted`,WrapSubmitted:`wrap:submitted`,UnwrapSubmitted:`unwrap:submitted`,FinalizeUnwrapSubmitted:`finalizeUnwrap:submitted`,DelegationSubmitted:`delegation:submitted`,RevokeDelegationSubmitted:`revokeDelegation:submitted`,InvalidateDecryptionSignaturesSubmitted:`invalidateDecryptionSignatures:submitted`,UnshieldPhase1Submitted:`unshield:phase1_submitted`,UnshieldPhase2Started:`unshield:phase2_started`,UnshieldPhase2Submitted:`unshield:phase2_submitted`},k={approveUnderlying:{submittedEvent:e=>({type:O.ApproveUnderlyingSubmitted,txHash:e,step:`approve`})},"approveUnderlying:reset":{submittedEvent:e=>({type:O.ApproveUnderlyingSubmitted,txHash:e,step:`reset`})},delegateDecryption:{submittedEvent:e=>({type:O.DelegationSubmitted,txHash:e})},finalizeUnwrap:{submittedEvent:e=>({type:O.FinalizeUnwrapSubmitted,txHash:e})},invalidateDecryptionSignatures:{submittedEvent:e=>({type:O.InvalidateDecryptionSignaturesSubmitted,txHash:e})},revokeDelegation:{submittedEvent:e=>({type:O.RevokeDelegationSubmitted,txHash:e})},setOperator:{submittedEvent:e=>({type:O.SetOperatorSubmitted,txHash:e})},"shield:transferAndCall":{submittedEvent:e=>({type:O.ShieldSubmitted,txHash:e,shieldPath:`transferAndCall`})},"shield:approveAndWrap":{submittedEvent:e=>({type:O.ShieldSubmitted,txHash:e,shieldPath:`approveAndWrap`})},wrap:{submittedEvent:e=>({type:O.WrapSubmitted,txHash:e})},transfer:{submittedEvent:e=>({type:O.TransferSubmitted,txHash:e})},transferAndCall:{submittedEvent:e=>({type:O.TransferSubmitted,txHash:e})},transferFrom:{submittedEvent:e=>({type:O.TransferFromSubmitted,txHash:e})},transferFromAndCall:{submittedEvent:e=>({type:O.TransferFromSubmitted,txHash:e})},unwrap:{submittedEvent:e=>({type:O.UnwrapSubmitted,txHash:e})},unwrapAll:{submittedEvent:e=>({type:O.UnwrapSubmitted,txHash:e})}};function A(e){return s(e)}const j=u.custom(e=>typeof e==`string`&&l(e,{strict:!0}),`expected 0x-prefixed hex string`),M=u.custom(e=>typeof e==`string`&&c(e,{strict:!1}),`expected EVM address`),N=u.pipe(M,u.transform(A)),P=u.int().check(u.nonnegative()),F=u.int().check(u.positive()),I=u.int().check(u.nonnegative()),L=u.int().check(u.positive());u.int().check(u.positive());async function R(e,t,n){try{await t()}catch(t){n?.warn(`${e} failed`,{error:t})}}const z=86400,B=`wildcard`;function V(){return Math.floor(Date.now()/1e3)}function H(e){return[...new Set(e.map(A))].sort()}function U(e){let{chainId:t}=e.domain;return typeof t==`bigint`?{...e,domain:{...e.domain,chainId:t.toString()}}:e}const W=[{type:`function`,name:`UPGRADE_INTERFACE_VERSION`,inputs:[],outputs:[{name:``,type:`string`,internalType:`string`}],stateMutability:`view`},{type:`function`,name:`acceptOwnership`,inputs:[],outputs:[],stateMutability:`nonpayable`},{type:`function`,name:`blockUser`,inputs:[{name:`user`,type:`address`,internalType:`address`}],outputs:[],stateMutability:`nonpayable`},{type:`function`,name:`confidentialBalanceOf`,inputs:[{name:`account`,type:`address`,internalType:`address`}],outputs:[{name:``,type:`bytes32`,internalType:`euint64`}],stateMutability:`view`},{type:`function`,name:`confidentialProtocolId`,inputs:[],outputs:[{name:``,type:`uint256`,internalType:`uint256`}],stateMutability:`view`},{type:`function`,name:`confidentialTotalSupply`,inputs:[],outputs:[{name:``,type:`bytes32`,internalType:`euint64`}],stateMutability:`view`},{type:`function`,name:`confidentialTransfer`,inputs:[{name:`to`,type:`address`,internalType:`address`},{name:`encryptedAmount`,type:`bytes32`,internalType:`externalEuint64`},{name:`inputProof`,type:`bytes`,internalType:`bytes`}],outputs:[{name:``,type:`bytes32`,internalType:`euint64`}],stateMutability:`nonpayable`},{type:`function`,name:`confidentialTransfer`,inputs:[{name:`to`,type:`address`,internalType:`address`},{name:`amount`,type:`bytes32`,internalType:`euint64`}],outputs:[{name:``,type:`bytes32`,internalType:`euint64`}],stateMutability:`nonpayable`},{type:`function`,name:`confidentialTransferAndCall`,inputs:[{name:`to`,type:`address`,internalType:`address`},{name:`amount`,type:`bytes32`,internalType:`euint64`},{name:`data`,type:`bytes`,internalType:`bytes`}],outputs:[{name:`transferred`,type:`bytes32`,internalType:`euint64`}],stateMutability:`nonpayable`},{type:`function`,name:`confidentialTransferAndCall`,inputs:[{name:`to`,type:`address`,internalType:`address`},{name:`encryptedAmount`,type:`bytes32`,internalType:`externalEuint64`},{name:`inputProof`,type:`bytes`,internalType:`bytes`},{name:`data`,type:`bytes`,internalType:`bytes`}],outputs:[{name:`transferred`,type:`bytes32`,internalType:`euint64`}],stateMutability:`nonpayable`},{type:`function`,name:`confidentialTransferFrom`,inputs:[{name:`from`,type:`address`,internalType:`address`},{name:`to`,type:`address`,internalType:`address`},{name:`encryptedAmount`,type:`bytes32`,internalType:`externalEuint64`},{name:`inputProof`,type:`bytes`,internalType:`bytes`}],outputs:[{name:`transferred`,type:`bytes32`,internalType:`euint64`}],stateMutability:`nonpayable`},{type:`function`,name:`confidentialTransferFrom`,inputs:[{name:`from`,type:`address`,internalType:`address`},{name:`to`,type:`address`,internalType:`address`},{name:`amount`,type:`bytes32`,internalType:`euint64`}],outputs:[{name:`transferred`,type:`bytes32`,internalType:`euint64`}],stateMutability:`nonpayable`},{type:`function`,name:`confidentialTransferFromAndCall`,inputs:[{name:`from`,type:`address`,internalType:`address`},{name:`to`,type:`address`,internalType:`address`},{name:`encryptedAmount`,type:`bytes32`,internalType:`externalEuint64`},{name:`inputProof`,type:`bytes`,internalType:`bytes`},{name:`data`,type:`bytes`,internalType:`bytes`}],outputs:[{name:`transferred`,type:`bytes32`,internalType:`euint64`}],stateMutability:`nonpayable`},{type:`function`,name:`confidentialTransferFromAndCall`,inputs:[{name:`from`,type:`address`,internalType:`address`},{name:`to`,type:`address`,internalType:`address`},{name:`amount`,type:`bytes32`,internalType:`euint64`},{name:`data`,type:`bytes`,internalType:`bytes`}],outputs:[{name:`transferred`,type:`bytes32`,internalType:`euint64`}],stateMutability:`nonpayable`},{type:`function`,name:`contractURI`,inputs:[],outputs:[{name:``,type:`string`,internalType:`string`}],stateMutability:`view`},{type:`function`,name:`decimals`,inputs:[],outputs:[{name:``,type:`uint8`,internalType:`uint8`}],stateMutability:`view`},{type:`function`,name:`discloseEncryptedAmount`,inputs:[{name:`encryptedAmount`,type:`bytes32`,internalType:`euint64`},{name:`cleartextAmount`,type:`uint64`,internalType:`uint64`},{name:`decryptionProof`,type:`bytes`,internalType:`bytes`}],outputs:[],stateMutability:`nonpayable`},{type:`function`,name:`finalizeUnwrap`,inputs:[{name:`unwrapRequestId`,type:`bytes32`,internalType:`bytes32`},{name:`unwrapAmountCleartext`,type:`uint64`,internalType:`uint64`},{name:`decryptionProof`,type:`bytes`,internalType:`bytes`}],outputs:[],stateMutability:`nonpayable`},{type:`function`,name:`getUnderlyingDenyListSelector`,inputs:[],outputs:[{name:`isSet`,type:`bool`,internalType:`bool`},{name:`selector`,type:`bytes4`,internalType:`bytes4`}],stateMutability:`view`},{type:`function`,name:`inferredTotalSupply`,inputs:[],outputs:[{name:``,type:`uint256`,internalType:`uint256`}],stateMutability:`view`},{type:`function`,name:`initialize`,inputs:[{name:`name_`,type:`string`,internalType:`string`},{name:`symbol_`,type:`string`,internalType:`string`},{name:`contractURI_`,type:`string`,internalType:`string`},{name:`underlying_`,type:`address`,internalType:`contract IERC20`},{name:`owner_`,type:`address`,internalType:`address`}],outputs:[],stateMutability:`nonpayable`},{type:`function`,name:`isBlocked`,inputs:[{name:`user`,type:`address`,internalType:`address`}],outputs:[{name:``,type:`bool`,internalType:`bool`}],stateMutability:`view`},{type:`function`,name:`isOperator`,inputs:[{name:`holder`,type:`address`,internalType:`address`},{name:`spender`,type:`address`,internalType:`address`}],outputs:[{name:``,type:`bool`,internalType:`bool`}],stateMutability:`view`},{type:`function`,name:`maxTotalSupply`,inputs:[],outputs:[{name:``,type:`uint256`,internalType:`uint256`}],stateMutability:`view`},{type:`function`,name:`name`,inputs:[],outputs:[{name:``,type:`string`,internalType:`string`}],stateMutability:`view`},{type:`function`,name:`onTransferReceived`,inputs:[{name:`operator`,type:`address`,internalType:`address`},{name:`from`,type:`address`,internalType:`address`},{name:`amount`,type:`uint256`,internalType:`uint256`},{name:`data`,type:`bytes`,internalType:`bytes`}],outputs:[{name:``,type:`bytes4`,internalType:`bytes4`}],stateMutability:`nonpayable`},{type:`function`,name:`owner`,inputs:[],outputs:[{name:``,type:`address`,internalType:`address`}],stateMutability:`view`},{type:`function`,name:`pendingOwner`,inputs:[],outputs:[{name:``,type:`address`,internalType:`address`}],stateMutability:`view`},{type:`function`,name:`proxiableUUID`,inputs:[],outputs:[{name:``,type:`bytes32`,internalType:`bytes32`}],stateMutability:`view`},{type:`function`,name:`rate`,inputs:[],outputs:[{name:``,type:`uint256`,internalType:`uint256`}],stateMutability:`view`},{type:`function`,name:`reinitializeV2`,inputs:[],outputs:[],stateMutability:`nonpayable`},{type:`function`,name:`reinitializeV3`,inputs:[{name:`blockedUsers`,type:`address[]`,internalType:`address[]`},{name:`underlyingDenyListSelector`,type:`bytes4`,internalType:`bytes4`},{name:`hasUnderlyingDenyListSelector_`,type:`bool`,internalType:`bool`}],outputs:[],stateMutability:`nonpayable`},{type:`function`,name:`renounceOwnership`,inputs:[],outputs:[],stateMutability:`nonpayable`},{type:`function`,name:`requestDiscloseEncryptedAmount`,inputs:[{name:`encryptedAmount`,type:`bytes32`,internalType:`euint64`}],outputs:[],stateMutability:`nonpayable`},{type:`function`,name:`setOperator`,inputs:[{name:`operator`,type:`address`,internalType:`address`},{name:`until`,type:`uint48`,internalType:`uint48`}],outputs:[],stateMutability:`nonpayable`},{type:`function`,name:`supportsInterface`,inputs:[{name:`interfaceId`,type:`bytes4`,internalType:`bytes4`}],outputs:[{name:``,type:`bool`,internalType:`bool`}],stateMutability:`view`},{type:`function`,name:`symbol`,inputs:[],outputs:[{name:``,type:`string`,internalType:`string`}],stateMutability:`view`},{type:`function`,name:`transferOwnership`,inputs:[{name:`newOwner`,type:`address`,internalType:`address`}],outputs:[],stateMutability:`nonpayable`},{type:`function`,name:`unblockUser`,inputs:[{name:`user`,type:`address`,internalType:`address`}],outputs:[],stateMutability:`nonpayable`},{type:`function`,name:`underlying`,inputs:[],outputs:[{name:``,type:`address`,internalType:`address`}],stateMutability:`view`},{type:`function`,name:`unwrap`,inputs:[{name:`from`,type:`address`,internalType:`address`},{name:`to`,type:`address`,internalType:`address`},{name:`encryptedAmount`,type:`bytes32`,internalType:`externalEuint64`},{name:`inputProof`,type:`bytes`,internalType:`bytes`}],outputs:[{name:``,type:`bytes32`,internalType:`bytes32`}],stateMutability:`nonpayable`},{type:`function`,name:`unwrap`,inputs:[{name:`from`,type:`address`,internalType:`address`},{name:`to`,type:`address`,internalType:`address`},{name:`amount`,type:`bytes32`,internalType:`euint64`}],outputs:[{name:``,type:`bytes32`,internalType:`bytes32`}],stateMutability:`nonpayable`},{type:`function`,name:`unwrapAmount`,inputs:[{name:`unwrapRequestId`,type:`bytes32`,internalType:`bytes32`}],outputs:[{name:``,type:`bytes32`,internalType:`euint64`}],stateMutability:`view`},{type:`function`,name:`unwrapRequester`,inputs:[{name:`unwrapRequestId`,type:`bytes32`,internalType:`bytes32`}],outputs:[{name:``,type:`address`,internalType:`address`}],stateMutability:`view`},{type:`function`,name:`upgradeToAndCall`,inputs:[{name:`newImplementation`,type:`address`,internalType:`address`},{name:`data`,type:`bytes`,internalType:`bytes`}],outputs:[],stateMutability:`payable`},{type:`function`,name:`wrap`,inputs:[{name:`to`,type:`address`,internalType:`address`},{name:`amount`,type:`uint256`,internalType:`uint256`}],outputs:[{name:``,type:`bytes32`,internalType:`euint64`}],stateMutability:`nonpayable`},{type:`event`,name:`AmountDiscloseRequested`,inputs:[{name:`encryptedAmount`,type:`bytes32`,indexed:!0,internalType:`euint64`},{name:`requester`,type:`address`,indexed:!0,internalType:`address`}],anonymous:!1},{type:`event`,name:`AmountDisclosed`,inputs:[{name:`encryptedAmount`,type:`bytes32`,indexed:!0,internalType:`euint64`},{name:`amount`,type:`uint64`,indexed:!1,internalType:`uint64`}],anonymous:!1},{type:`event`,name:`ConfidentialTransfer`,inputs:[{name:`from`,type:`address`,indexed:!0,internalType:`address`},{name:`to`,type:`address`,indexed:!0,internalType:`address`},{name:`amount`,type:`bytes32`,indexed:!0,internalType:`euint64`}],anonymous:!1},{type:`event`,name:`Initialized`,inputs:[{name:`version`,type:`uint64`,indexed:!1,internalType:`uint64`}],anonymous:!1},{type:`event`,name:`OperatorSet`,inputs:[{name:`holder`,type:`address`,indexed:!0,internalType:`address`},{name:`operator`,type:`address`,indexed:!0,internalType:`address`},{name:`until`,type:`uint48`,indexed:!1,internalType:`uint48`}],anonymous:!1},{type:`event`,name:`OwnershipTransferStarted`,inputs:[{name:`previousOwner`,type:`address`,indexed:!0,internalType:`address`},{name:`newOwner`,type:`address`,indexed:!0,internalType:`address`}],anonymous:!1},{type:`event`,name:`OwnershipTransferred`,inputs:[{name:`previousOwner`,type:`address`,indexed:!0,internalType:`address`},{name:`newOwner`,type:`address`,indexed:!0,internalType:`address`}],anonymous:!1},{type:`event`,name:`PublicDecryptionVerified`,inputs:[{name:`handlesList`,type:`bytes32[]`,indexed:!1,internalType:`bytes32[]`},{name:`abiEncodedCleartexts`,type:`bytes`,indexed:!1,internalType:`bytes`}],anonymous:!1},{type:`event`,name:`UnwrapFinalized`,inputs:[{name:`receiver`,type:`address`,indexed:!0,internalType:`address`},{name:`unwrapRequestId`,type:`bytes32`,indexed:!0,internalType:`bytes32`},{name:`encryptedAmount`,type:`bytes32`,indexed:!1,internalType:`euint64`},{name:`cleartextAmount`,type:`uint64`,indexed:!1,internalType:`uint64`}],anonymous:!1},{type:`event`,name:`UnwrapRequested`,inputs:[{name:`receiver`,type:`address`,indexed:!0,internalType:`address`},{name:`unwrapRequestId`,type:`bytes32`,indexed:!0,internalType:`bytes32`},{name:`amount`,type:`bytes32`,indexed:!1,internalType:`euint64`}],anonymous:!1},{type:`event`,name:`Upgraded`,inputs:[{name:`implementation`,type:`address`,indexed:!0,internalType:`address`}],anonymous:!1},{type:`event`,name:`UserBlocked`,inputs:[{name:`user`,type:`address`,indexed:!0,internalType:`address`}],anonymous:!1},{type:`event`,name:`UserUnblocked`,inputs:[{name:`user`,type:`address`,indexed:!0,internalType:`address`}],anonymous:!1},{type:`event`,name:`Wrap`,inputs:[{name:`to`,type:`address`,indexed:!0,internalType:`address`},{name:`roundedAmount`,type:`uint256`,indexed:!1,internalType:`uint256`},{name:`encryptedWrappedAmount`,type:`bytes32`,indexed:!1,internalType:`euint64`}],anonymous:!1},{type:`error`,name:`AddressEmptyCode`,inputs:[{name:`target`,type:`address`,internalType:`address`}]},{type:`error`,name:`BlockedUser`,inputs:[{name:`user`,type:`address`,internalType:`address`}]},{type:`error`,name:`ERC1967InvalidImplementation`,inputs:[{name:`implementation`,type:`address`,internalType:`address`}]},{type:`error`,name:`ERC1967NonPayable`,inputs:[]},{type:`error`,name:`ERC7984InvalidReceiver`,inputs:[{name:`receiver`,type:`address`,internalType:`address`}]},{type:`error`,name:`ERC7984InvalidReceiver`,inputs:[{name:`receiver`,type:`address`,internalType:`address`}]},{type:`error`,name:`ERC7984InvalidSender`,inputs:[{name:`sender`,type:`address`,internalType:`address`}]},{type:`error`,name:`ERC7984TotalSupplyOverflow`,inputs:[]},{type:`error`,name:`ERC7984UnauthorizedCaller`,inputs:[{name:`caller`,type:`address`,internalType:`address`}]},{type:`error`,name:`ERC7984UnauthorizedSpender`,inputs:[{name:`holder`,type:`address`,internalType:`address`},{name:`spender`,type:`address`,internalType:`address`}]},{type:`error`,name:`ERC7984UnauthorizedUseOfEncryptedAmount`,inputs:[{name:`amount`,type:`bytes32`,internalType:`euint64`},{name:`user`,type:`address`,internalType:`address`}]},{type:`error`,name:`ERC7984ZeroBalance`,inputs:[{name:`holder`,type:`address`,internalType:`address`}]},{type:`error`,name:`FailedCall`,inputs:[]},{type:`error`,name:`InvalidInitialization`,inputs:[]},{type:`error`,name:`InvalidKMSSignatures`,inputs:[]},{type:`error`,name:`InvalidUnderlyingDenyListResponse`,inputs:[]},{type:`error`,name:`InvalidUnwrapRequest`,inputs:[{name:`unwrapRequestId`,type:`bytes32`,internalType:`bytes32`}]},{type:`error`,name:`NotInitializing`,inputs:[]},{type:`error`,name:`OwnableInvalidOwner`,inputs:[{name:`owner`,type:`address`,internalType:`address`}]},{type:`error`,name:`OwnableUnauthorizedAccount`,inputs:[{name:`account`,type:`address`,internalType:`address`}]},{type:`error`,name:`SafeCastOverflowedUintDowncast`,inputs:[{name:`bits`,type:`uint8`,internalType:`uint8`},{name:`value`,type:`uint256`,internalType:`uint256`}]},{type:`error`,name:`SafeERC20FailedOperation`,inputs:[{name:`token`,type:`address`,internalType:`address`}]},{type:`error`,name:`SenderNotAllowedToUseHandle`,inputs:[{name:`handle`,type:`bytes32`,internalType:`bytes32`},{name:`sender`,type:`address`,internalType:`address`}]},{type:`error`,name:`UUPSUnauthorizedCallContext`,inputs:[]},{type:`error`,name:`UUPSUnsupportedProxiableUUID`,inputs:[{name:`slot`,type:`bytes32`,internalType:`bytes32`}]},{type:`error`,name:`UnderlyingDenyListCallFailed`,inputs:[]},{type:`error`,name:`UnderlyingDenyListedAddress`,inputs:[{name:`user`,type:`address`,internalType:`address`}]},{type:`error`,name:`UserAlreadyBlocked`,inputs:[{name:`user`,type:`address`,internalType:`address`}]},{type:`error`,name:`UserAlreadyUnblocked`,inputs:[{name:`user`,type:`address`,internalType:`address`}]},{type:`error`,name:`ZamaProtocolUnsupported`,inputs:[]}];function G(e,t){return{address:e,abi:W,functionName:`confidentialBalanceOf`,args:[t]}}function K(e,t,n,r){return{address:e,abi:W,functionName:`confidentialTransfer`,args:[t,n,r]}}function q(e,t,n,r,i){return{address:e,abi:W,functionName:`confidentialTransferFrom`,args:[t,n,r,i]}}function se(e,t,n,r,i){return{address:e,abi:W,functionName:`confidentialTransferAndCall`,args:[t,n,r,i]}}function ce(e,t,n,r,i,a){return{address:e,abi:W,functionName:`confidentialTransferFromAndCall`,args:[t,n,r,i,a]}}function le(e,t,n){return{address:e,abi:W,functionName:`isOperator`,args:[t,n]}}function ue(e,t,n){return{address:e,abi:W,functionName:`setOperator`,args:[t,n??Math.floor(Date.now()/1e3)+3600]}}function de(e,t,n,r,i){return{address:e,abi:W,functionName:`unwrap`,args:[t,n,r,i]}}function fe(e,t,n,r){return{address:e,abi:W,functionName:`unwrap`,args:[t,n,r]}}function pe(e){return{address:e,abi:W,functionName:`confidentialTotalSupply`,args:[]}}function me(e){return{address:e,abi:W,functionName:`rate`,args:[]}}function he(e,t,n,r){return{address:e,abi:W,functionName:`finalizeUnwrap`,args:[t,n,r]}}function ge(e,t){return{address:e,abi:W,functionName:`unwrapRequester`,args:[t]}}function _e(e){return{address:e,abi:W,functionName:`underlying`,args:[]}}function ve(e){return{address:e,abi:W,functionName:`inferredTotalSupply`,args:[]}}function ye(e,t,n){return{address:e,abi:W,functionName:`wrap`,args:[t,n]}}function be(e){return{address:e,abi:o,functionName:`name`,args:[]}}function xe(e){return{address:e,abi:o,functionName:`symbol`,args:[]}}function Se(e){return{address:e,abi:o,functionName:`decimals`,args:[]}}function Ce(e){return{address:e,abi:o,functionName:`totalSupply`,args:[]}}function we(e,t){return{address:e,abi:o,functionName:`balanceOf`,args:[t]}}function Te(e,t,n){return{address:e,abi:o,functionName:`allowance`,args:[t,n]}}function Ee(e,t,n){return{address:e,abi:o,functionName:`approve`,args:[t,n]}}const De=[{type:`function`,name:`supportsInterface`,inputs:[{name:`interfaceId`,type:`bytes4`,internalType:`bytes4`}],outputs:[{name:``,type:`bool`,internalType:`bool`}],stateMutability:`view`}],J=`0x4958f2a4`,Y=`0x1f1c62b2`,X=`0xb0202a11`;function Z(e,t){return{address:e,abi:De,functionName:`supportsInterface`,args:[t]}}function Oe(e){return Z(e,J)}function ke(e){return Z(e,Y)}function Ae(e){return Z(e,X)}const Q=[{inputs:[],name:`getTokenConfidentialTokenPairs`,outputs:[{components:[{internalType:`address`,name:`tokenAddress`,type:`address`},{internalType:`address`,name:`confidentialTokenAddress`,type:`address`},{internalType:`bool`,name:`isValid`,type:`bool`}],internalType:`struct ConfidentialTokenWrappersRegistry.TokenWrapperPair[]`,name:``,type:`tuple[]`}],stateMutability:`view`,type:`function`},{inputs:[],name:`getTokenConfidentialTokenPairsLength`,outputs:[{internalType:`uint256`,name:``,type:`uint256`}],stateMutability:`view`,type:`function`},{inputs:[{internalType:`uint256`,name:`fromIndex`,type:`uint256`},{internalType:`uint256`,name:`toIndex`,type:`uint256`}],name:`getTokenConfidentialTokenPairsSlice`,outputs:[{components:[{internalType:`address`,name:`tokenAddress`,type:`address`},{internalType:`address`,name:`confidentialTokenAddress`,type:`address`},{internalType:`bool`,name:`isValid`,type:`bool`}],internalType:`struct ConfidentialTokenWrappersRegistry.TokenWrapperPair[]`,name:``,type:`tuple[]`}],stateMutability:`view`,type:`function`},{inputs:[{internalType:`uint256`,name:`index`,type:`uint256`}],name:`getTokenConfidentialTokenPair`,outputs:[{components:[{internalType:`address`,name:`tokenAddress`,type:`address`},{internalType:`address`,name:`confidentialTokenAddress`,type:`address`},{internalType:`bool`,name:`isValid`,type:`bool`}],internalType:`struct ConfidentialTokenWrappersRegistry.TokenWrapperPair`,name:``,type:`tuple`}],stateMutability:`view`,type:`function`},{inputs:[{internalType:`address`,name:`tokenAddress`,type:`address`}],name:`getConfidentialTokenAddress`,outputs:[{internalType:`bool`,name:``,type:`bool`},{internalType:`address`,name:``,type:`address`}],stateMutability:`view`,type:`function`},{inputs:[{internalType:`address`,name:`confidentialTokenAddress`,type:`address`}],name:`getTokenAddress`,outputs:[{internalType:`bool`,name:``,type:`bool`},{internalType:`address`,name:``,type:`address`}],stateMutability:`view`,type:`function`},{inputs:[{internalType:`address`,name:`confidentialTokenAddress`,type:`address`}],name:`isConfidentialTokenValid`,outputs:[{internalType:`bool`,name:``,type:`bool`}],stateMutability:`view`,type:`function`},{inputs:[{internalType:`address`,name:`initialOwner`,type:`address`}],name:`initialize`,outputs:[],stateMutability:`nonpayable`,type:`function`},{inputs:[{internalType:`address`,name:`tokenAddress`,type:`address`},{internalType:`address`,name:`confidentialTokenAddress`,type:`address`}],name:`registerConfidentialToken`,outputs:[],stateMutability:`nonpayable`,type:`function`},{inputs:[{internalType:`address`,name:`confidentialTokenAddress`,type:`address`}],name:`revokeConfidentialToken`,outputs:[],stateMutability:`nonpayable`,type:`function`}];function $(e){return{address:e,abi:Q,functionName:`getTokenConfidentialTokenPairs`,args:[]}}function je(e){return{address:e,abi:Q,functionName:`getTokenConfidentialTokenPairsLength`,args:[]}}function Me(e,t,n){return{address:e,abi:Q,functionName:`getTokenConfidentialTokenPairsSlice`,args:[t,n]}}function Ne(e,t){return{address:e,abi:Q,functionName:`getTokenConfidentialTokenPair`,args:[t]}}function Pe(e,t){return{address:e,abi:Q,functionName:`getConfidentialTokenAddress`,args:[t]}}function Fe(e,t){return{address:e,abi:Q,functionName:`getTokenAddress`,args:[t]}}function Ie(e,t){return{address:e,abi:Q,functionName:`isConfidentialTokenValid`,args:[t]}}export{w as $,le as A,H as B,pe as C,q as D,ce as E,fe as F,N as G,U as H,ge as I,L as J,j as K,ye as L,ue as M,_e as N,he as O,de as P,k as Q,z as R,G as S,K as T,R as U,V,A as W,P as X,F as Y,O as Z,we as _,d as _t,je as a,x as at,be as b,ne as bt,X as c,f as ct,Oe as d,ee as dt,C as et,ke as f,m as ft,Ee as g,te as gt,Te as h,p as ht,$ as i,S as it,me as j,ve as k,J as l,ae as lt,Z as m,g as mt,Fe as n,T as nt,Me as o,b as ot,Ae as p,h as pt,I as q,Ne as r,D as rt,Ie as s,oe as st,Pe as t,E as tt,Y as u,ie as ut,Se as v,re as vt,se as w,xe as x,y as xt,Ce as y,_ as yt,B as z};
|
|
2
|
+
//# sourceMappingURL=wrappers-registry-BfQr2QHn.js.map
|