@zama-fhe/sdk 3.8.0-beta.20 → 3.8.0-beta.21

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (112) hide show
  1. package/dist/cjs/alignment.cjs +1 -1
  2. package/dist/cjs/alignment.cjs.map +1 -1
  3. package/dist/cjs/base-signer.cjs +1 -1
  4. package/dist/cjs/base-signer.cjs.map +1 -1
  5. package/dist/cjs/ethers/index.cjs +1 -1
  6. package/dist/cjs/ethers/index.cjs.map +1 -1
  7. package/dist/cjs/fhevm-relayer.cjs +2 -2
  8. package/dist/cjs/fhevm-relayer.cjs.map +1 -1
  9. package/dist/cjs/index.cjs +1 -1
  10. package/dist/cjs/index.cjs.map +1 -1
  11. package/dist/cjs/log-decoding.cjs +2 -0
  12. package/dist/cjs/log-decoding.cjs.map +1 -0
  13. package/dist/cjs/query/index.cjs +1 -1
  14. package/dist/cjs/query/index.cjs.map +1 -1
  15. package/dist/cjs/query-keys.cjs +2 -0
  16. package/dist/cjs/query-keys.cjs.map +1 -0
  17. package/dist/cjs/relayer.cjs +1 -1
  18. package/dist/cjs/relayer.cjs.map +1 -1
  19. package/dist/cjs/telemetry.cjs +1 -1
  20. package/dist/cjs/telemetry.cjs.map +1 -1
  21. package/dist/cjs/token.cjs +1 -1
  22. package/dist/cjs/token.cjs.map +1 -1
  23. package/dist/cjs/vaults/index.cjs +1 -1
  24. package/dist/cjs/vaults/index.cjs.map +1 -1
  25. package/dist/cjs/viem/index.cjs +1 -1
  26. package/dist/cjs/viem/index.cjs.map +1 -1
  27. package/dist/cjs/wrappers-registry.cjs +2 -0
  28. package/dist/cjs/wrappers-registry.cjs.map +1 -0
  29. package/dist/esm/alignment-o-YIndFR.js +2 -0
  30. package/dist/esm/alignment-o-YIndFR.js.map +1 -0
  31. package/dist/esm/{base-signer-C4P_Y-TS.d.ts → base-signer-nenGJU9U.d.ts} +1 -1
  32. package/dist/esm/base-signer-p5iz9eeb.js +2 -0
  33. package/dist/esm/base-signer-p5iz9eeb.js.map +1 -0
  34. package/dist/esm/cleartext/index.d.ts +2 -2
  35. package/dist/esm/cleartext/index.js +1 -1
  36. package/dist/esm/{cleartext-D587CgVj.d.ts → cleartext-BLMLdKFh.d.ts} +1 -1
  37. package/dist/esm/{cleartext-BrJewisr.js → cleartext-C1Y5zc1Y.js} +2 -2
  38. package/dist/esm/{cleartext-BrJewisr.js.map → cleartext-C1Y5zc1Y.js.map} +1 -1
  39. package/dist/esm/{index-TuEeFx9Z.d.ts → decryption-Cp8calaa.d.ts} +1110 -1575
  40. package/dist/esm/{encrypt-worker-client-Bjab5Grh.d.ts → encrypt-worker-client-CkEIA0Tp.d.ts} +1 -1
  41. package/dist/esm/{encryption-DDP0UpGa.js → encryption-BT886Jlj.js} +2 -2
  42. package/dist/esm/{encryption-DDP0UpGa.js.map → encryption-BT886Jlj.js.map} +1 -1
  43. package/dist/esm/ethers/index.d.ts +12 -4
  44. package/dist/esm/ethers/index.js +1 -1
  45. package/dist/esm/ethers/index.js.map +1 -1
  46. package/dist/esm/{fatal-batch-BqKg7m3V.js → fatal-batch-BYeHrf0V.js} +2 -2
  47. package/dist/esm/{fatal-batch-BqKg7m3V.js.map → fatal-batch-BYeHrf0V.js.map} +1 -1
  48. package/dist/esm/{fhevm-relayer-B-Ve8Yyz.js → fhevm-relayer-BEzN0aev.js} +2 -2
  49. package/dist/esm/{fhevm-relayer-B-Ve8Yyz.js.map → fhevm-relayer-BEzN0aev.js.map} +1 -1
  50. package/dist/esm/{index-Dae8rZWN.d.ts → index-CI6f4jxt.d.ts} +5 -5
  51. package/dist/esm/{index-yCC7GnOx.d.ts → index-ClNBSbRy.d.ts} +2 -2
  52. package/dist/esm/index.d.ts +8 -8
  53. package/dist/esm/index.js +1 -1
  54. package/dist/esm/index.js.map +1 -1
  55. package/dist/esm/internal/index.d.ts +3 -3
  56. package/dist/esm/internal/index.js +1 -1
  57. package/dist/esm/log-decoding-ZthqwHOv.js +2 -0
  58. package/dist/esm/log-decoding-ZthqwHOv.js.map +1 -0
  59. package/dist/esm/node/index.d.ts +3 -3
  60. package/dist/esm/node/index.js +1 -1
  61. package/dist/esm/query/index.d.ts +5 -5
  62. package/dist/esm/query/index.js +1 -1
  63. package/dist/esm/query/index.js.map +1 -1
  64. package/dist/esm/query-keys-CSPxPLBB.js +2 -0
  65. package/dist/esm/query-keys-CSPxPLBB.js.map +1 -0
  66. package/dist/esm/{relayer-CqdiNLZH.js → relayer-nWfQAlo7.js} +2 -2
  67. package/dist/esm/{relayer-CqdiNLZH.js.map → relayer-nWfQAlo7.js.map} +1 -1
  68. package/dist/esm/{signing-BIlZhi5G.js → signing-CVEOw21I.js} +2 -2
  69. package/dist/esm/{signing-BIlZhi5G.js.map → signing-CVEOw21I.js.map} +1 -1
  70. package/dist/esm/telemetry-YFH36F_7.js +2 -0
  71. package/dist/esm/telemetry-YFH36F_7.js.map +1 -0
  72. package/dist/esm/token-AXsOIUDB.js +2 -0
  73. package/dist/esm/{token-CxDfm7V-.js.map → token-AXsOIUDB.js.map} +1 -1
  74. package/dist/esm/{types-Bi-kDUxb.d.ts → types-D253qkvB.d.ts} +1 -1
  75. package/dist/esm/{types-D1qhoqkF.d.ts → types-DH06Ap0n.d.ts} +1 -1
  76. package/dist/esm/{types-DbnDm2O9.d.ts → types-Ubeo72FV.d.ts} +13 -1
  77. package/dist/esm/{validation-CL7MJT6k.js → validation-CZfDLOUh.js} +2 -2
  78. package/dist/esm/{validation-CL7MJT6k.js.map → validation-CZfDLOUh.js.map} +1 -1
  79. package/dist/esm/vaults/index.d.ts +262 -15600
  80. package/dist/esm/vaults/index.js +1 -1
  81. package/dist/esm/vaults/index.js.map +1 -1
  82. package/dist/esm/viem/index.d.ts +12 -4
  83. package/dist/esm/viem/index.js +1 -1
  84. package/dist/esm/viem/index.js.map +1 -1
  85. package/dist/esm/web/index.d.ts +2 -2
  86. package/dist/esm/web/index.js +1 -1
  87. package/dist/esm/wrappers-registry-Cm3JJeqx.js +2 -0
  88. package/dist/esm/wrappers-registry-Cm3JJeqx.js.map +1 -0
  89. package/package.json +1 -1
  90. package/dist/cjs/applied-runtime.cjs +0 -2
  91. package/dist/cjs/applied-runtime.cjs.map +0 -1
  92. package/dist/cjs/invalidation.cjs +0 -2
  93. package/dist/cjs/invalidation.cjs.map +0 -1
  94. package/dist/cjs/primitives.cjs +0 -2
  95. package/dist/cjs/primitives.cjs.map +0 -1
  96. package/dist/cjs/wrapped-token.cjs +0 -2
  97. package/dist/cjs/wrapped-token.cjs.map +0 -1
  98. package/dist/esm/alignment-CYa0d0Ud.js +0 -2
  99. package/dist/esm/alignment-CYa0d0Ud.js.map +0 -1
  100. package/dist/esm/applied-runtime-3fzqBC2V.js +0 -2
  101. package/dist/esm/applied-runtime-3fzqBC2V.js.map +0 -1
  102. package/dist/esm/base-signer-DvCCKQfk.js +0 -2
  103. package/dist/esm/base-signer-DvCCKQfk.js.map +0 -1
  104. package/dist/esm/invalidation-CzspPBR7.js +0 -2
  105. package/dist/esm/invalidation-CzspPBR7.js.map +0 -1
  106. package/dist/esm/primitives-Cym-3HKa.js +0 -2
  107. package/dist/esm/primitives-Cym-3HKa.js.map +0 -1
  108. package/dist/esm/telemetry-CmBkkrXK.js +0 -2
  109. package/dist/esm/telemetry-CmBkkrXK.js.map +0 -1
  110. package/dist/esm/token-CxDfm7V-.js +0 -2
  111. package/dist/esm/wrapped-token-BWMNyFj2.js +0 -2
  112. package/dist/esm/wrapped-token-BWMNyFj2.js.map +0 -1
@@ -4,10 +4,10 @@
4
4
  *
5
5
  * @packageDocumentation
6
6
  */
7
- import { t as ZamaConfigViem } from "../types-Bi-kDUxb.js";
8
- import { $ as SetOperatorSubmittedEvent, $t as TransactionReceipt, 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 RevokeDelegationSubmittedEvent, Qt as RawLog, R as WriteContractConfig, U as DecryptErrorEvent, V as BaseEvent, W as DecryptStartEvent, X as PermitErrorEvent, Y as FinalizeUnwrapSubmittedEvent, Z as PermitOperation, a as ZamaConfigBase, at as UnshieldPhase1SubmittedEvent, c as GenericStorage, cn as EncryptedValue, ct as UnwrapSubmittedEvent, dt as WrapSubmittedEvent, et as ShieldSubmittedEvent, fn as FhevmRuntimeConfig, ft as ZamaSDKEvent, ht as ZamaSDKEvents, i as ZamaConfig, in as EIP712TypedData, it as TransferSubmittedEvent, j as WalletAccountStore, k as WalletAccountChange, l as GenericProvider, mt as ZamaSDKEventType, n as RelayerConfig, nt as TransactionOperation, ot as UnshieldPhase2StartedEvent, pt as ZamaSDKEventListener, q as EncryptErrorEvent, rt as TransferFromSubmittedEvent, s as GenericLogger, st as UnshieldPhase2SubmittedEvent, tn as ClearValue, tt as TransactionErrorEvent, vt as ShieldPath, z as WriteFunctionName } from "../types-DbnDm2O9.js";
7
+ import { t as ZamaConfigViem } from "../types-D253qkvB.js";
8
+ import { $ as RevokeDelegationSubmittedEvent, $t as RawLog, A as WalletAccountListener, B as WriteFunctionName, D as GenericSigner, F as ReadContractConfig, G as DecryptStartEvent, H as BaseEvent, I as ReadContractReturnType, J as EncryptErrorEvent, K as DelegationSubmittedEvent, L as ReadFunctionName, M as ContractAbi, N as MulticallReturnType, O as WalletAccount, P as ReadContractArgs, Q as PermitOperation, R as WriteContractArgs, U as DecryptEndEvent, V as ApproveUnderlyingSubmittedEvent, W as DecryptErrorEvent, X as FinalizeUnwrapSubmittedEvent, Y as EncryptStartEvent, Z as PermitErrorEvent, a as ZamaConfigBase, an as EIP712TypedData, at as TransferSubmittedEvent, c as GenericStorage, ct as UnshieldPhase2SubmittedEvent, en as TransactionReceipt, et as SetOperatorSubmittedEvent, ft as WrapSubmittedEvent, gt as ZamaSDKEvents, ht as ZamaSDKEventType, i as ZamaConfig, it as TransferFromSubmittedEvent, j as WalletAccountStore, k as WalletAccountChange, l as GenericProvider, ln as EncryptedValue, lt as UnwrapSubmittedEvent, mt as ZamaSDKEventListener, n as RelayerConfig, nn as ClearValue, nt as TransactionErrorEvent, ot as UnshieldPhase1SubmittedEvent, pn as FhevmRuntimeConfig, pt as ZamaSDKEvent, q as EncryptEndEvent, rt as TransactionOperation, s as GenericLogger, st as UnshieldPhase2StartedEvent, tt as ShieldSubmittedEvent, yt as ShieldPath, z as WriteContractConfig } from "../types-Ubeo72FV.js";
9
9
  import { d as AtLeastOneChain, f as FheChain, p as FheChainAuth } from "../index-ZTcD9b_z.js";
10
- import { n as MutableWalletAccountStore, t as BaseSigner } from "../base-signer-C4P_Y-TS.js";
10
+ import { n as MutableWalletAccountStore, t as BaseSigner } from "../base-signer-nenGJU9U.js";
11
11
  import { Abi, Address, ContractFunctionArgs, ContractFunctionName, ContractFunctionReturnType, EIP1193Provider, Hex, Hex as Hex$1, PublicClient, WalletClient } from "viem";
12
12
  /** Create a {@link ZamaConfig} from viem clients. */
13
13
  export declare function createConfig<const TChains extends readonly [FheChain, ...FheChain[]]>(params: ZamaConfigViem<TChains>): ZamaConfig;
@@ -69,6 +69,14 @@ export declare class ViemProvider implements GenericProvider {
69
69
  getChainId(): Promise<number>;
70
70
  /** Execute a read-only call and return the decoded result. */
71
71
  readContract<const TAbi extends Abi | readonly unknown[], TFunctionName extends ContractFunctionName<TAbi, "pure" | "view">, const TArgs extends ContractFunctionArgs<TAbi, "pure" | "view", TFunctionName>>(config: ReadContractConfig<TAbi, TFunctionName, TArgs>): Promise<ContractFunctionReturnType<TAbi, "pure" | "view", TFunctionName, TArgs>>;
72
+ /**
73
+ * Run many reads in one Multicall3 call. On a chain whose viem definition
74
+ * names no Multicall3, such as a local Hardhat node, the call carries its code.
75
+ */
76
+ multicall<const TCalls extends readonly ReadContractConfig[]>(params: {
77
+ readonly calls: TCalls;
78
+ readonly chainId?: number;
79
+ }): Promise<MulticallReturnType<TCalls>>;
72
80
  /** Wait for a transaction to be mined and return its receipt. */
73
81
  waitForTransactionReceipt(hash: Hex$1): Promise<TransactionReceipt>;
74
82
  /** Return the latest block timestamp in seconds. */
@@ -129,4 +137,4 @@ export declare function readConfidentialTokenAddressContract(client: PublicClien
129
137
  export declare function readTokenAddressContract(client: PublicClient, registry: Address, confidentialTokenAddress: Address): Promise<readonly [boolean, `0x${string}`]>;
130
138
  /** Reads whether a confidential token is registered and valid in a wrappers registry via a viem client. */
131
139
  export declare function readIsConfidentialTokenValidContract(client: PublicClient, registry: Address, confidentialTokenAddress: Address): Promise<boolean>;
132
- 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, type ViemProviderConfig, 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 };
140
+ 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 MulticallReturnType, 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, type ViemProviderConfig, 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 };
@@ -1,2 +1,2 @@
1
- import{B as e,E as t,H as n,I as r,L as i,M as a,Q as o,a as s,c,d as l,k as u,l as d,o as f,q as p,r as m,rt as h,s as g,u as _,v,z as y}from"../alignment-CYa0d0Ud.js";import{i as b,t as x}from"../base-signer-DvCCKQfk.js";import{t as S}from"../eip1193-subscribe-DxAQh8dY.js";import{t as C}from"../typed-data-eAgGr9V-.js";import{encodeFunctionData as w,getAddress as T,serializeTransaction as E}from"viem";var D=class{#e;constructor(e){this.#e=e.publicClient}async getChainId(){return this.#e.getChainId()}async readContract(e){let{chainId:t,...n}=e;return await m(`ViemProvider`,t,()=>this.getChainId()),this.#e.readContract(n)}async waitForTransactionReceipt(e){return this.#e.waitForTransactionReceipt({hash:e})}async getBlockTimestamp(e){return await m(`ViemProvider`,e,()=>this.getChainId()),(await this.#e.getBlock()).timestamp}async prepareTransaction(e){let{from:t,calldata:n}=e,r=w({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 h(`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,d]=await Promise.all([i,a,o,s]);return E({type:`eip1559`,chainId:c,nonce:l,to:n.address,data:r,value:n.value??0n,gas:u,maxFeePerGas:d.maxFeePerGas,maxPriorityFeePerGas:d.maxPriorityFeePerGas})}};function O(e){if(e.account&&e.chain)return{address:T(e.account.address),chainId:e.chain.id}}var k=class extends x{#e;#t;#n;constructor(e){super(O(e.walletClient)),this.#e=e.walletClient,this.#t=e.ethereum,this.#n=this.#i()}#r(e){if(!this.#e.account)throw new o(e);return{walletClient:this.#e,account:this.#e.account}}async signTypedData(e){let{walletClient:t,account:n}=this.#r(`signTypedData`);return t.signTypedData({account:n,...C(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?S({provider:this.#t,getInitialWalletAccount:()=>O(this.#e),onWalletAccountChange:({next:e})=>{this.walletAccount.setSnapshot(e)}}):()=>{}}onDispose(){this.#n()}};function A(e){let t=new k({walletClient:e.walletClient,ethereum:e.ethereum}),n=new D({publicClient:e.publicClient});return b(t,n,e)}function j(e){if(!e.account)throw TypeError(`WalletClient has no account`);return e.account}function M(e,n,r){return e.readContract(t(n,r))}function N(e,t){return e.readContract(i(t))}function P(e,t,n){return e.readContract(v(t,n))}function F(e,t,n,r,i){return e.writeContract({chain:e.chain,account:j(e),...u(t,n,r,i)})}function I(e,t,n,r,i,a){return e.writeContract({chain:e.chain,account:j(e),...y(t,n,r,i,a)})}function L(t,n,r,i,a){return t.writeContract({chain:t.chain,account:j(t),...e(n,r,i,a)})}function R(e,t,n,r,i){return e.writeContract({chain:e.chain,account:j(e),...a(t,n,r,i)})}function z(e,t,n,i){return e.writeContract({chain:e.chain,account:j(e),...r(t,n,i)})}function B(e,t,r,i){return e.writeContract({chain:e.chain,account:j(e),...n(t,r,i)})}function V(e,t){return e.readContract(c(t))}function H(e,t){return e.readContract(d(t))}function U(e,t,n,r){return e.readContract(_(t,n,r))}function W(e,t,n){return e.readContract(g(t,n))}function G(e,t,n){return e.readContract(s(t,n))}function K(e,t,n){return e.readContract(f(t,n))}function q(e,t,n){return e.readContract(l(t,n))}export{x as BaseSigner,D as ViemProvider,k as ViemSigner,p as ZamaSDKEvents,A as createConfig,M as readConfidentialBalanceOfContract,G as readConfidentialTokenAddressContract,q as readIsConfidentialTokenValidContract,P as readSupportsInterfaceContract,K as readTokenAddressContract,W as readTokenPairContract,V as readTokenPairsContract,H as readTokenPairsLengthContract,U as readTokenPairsSliceContract,N as readUnderlyingTokenContract,F as writeConfidentialTransferContract,R as writeFinalizeUnwrapContract,z as writeSetOperatorContract,I as writeUnwrapContract,L as writeUnwrapFromBalanceContract,B as writeWrapContract};
1
+ import{A as e,B as t,F as n,G as r,M as i,N as a,S as o,T as s,X as c,d as l,k as u,r as d,y as f}from"../alignment-o-YIndFR.js";import{i as p,t as m}from"../base-signer-p5iz9eeb.js";import{t as h}from"../eip1193-subscribe-DxAQh8dY.js";import{t as g}from"../typed-data-eAgGr9V-.js";import{a as _,i as v,n as y,o as b,r as x,s as S,t as C}from"../wrappers-registry-Cm3JJeqx.js";import{encodeFunctionData as w,getAddress as T,serializeTransaction as E}from"viem";var D=class{#e;constructor(e){this.#e=e.publicClient}async getChainId(){return this.#e.getChainId()}async readContract(e){let{chainId:t,...n}=e;return await d(`ViemProvider`,t,()=>this.getChainId()),this.#e.readContract(n)}async multicall(e){return await d(`ViemProvider`,e.chainId,()=>this.getChainId()),await this.#e.multicall({contracts:e.calls.map(({chainId:e,...t})=>t),allowFailure:!1,deployless:this.#e.chain?.contracts?.multicall3===void 0})}async waitForTransactionReceipt(e){return this.#e.waitForTransactionReceipt({hash:e})}async getBlockTimestamp(e){return await d(`ViemProvider`,e,()=>this.getChainId()),(await this.#e.getBlock()).timestamp}async prepareTransaction(e){let{from:t,calldata:n}=e,r=w({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 c(`ViemProvider.prepareTransaction: gas estimation reverted for ${n.functionName} on ${n.address}`,{cause:e})}):Promise.resolve(e.gasLimit),s=e.fees??this.#e.estimateFeesPerGas(),[l,u,d,f]=await Promise.all([i,a,o,s]);return E({type:`eip1559`,chainId:l,nonce:u,to:n.address,data:r,value:n.value??0n,gas:d,maxFeePerGas:f.maxFeePerGas,maxPriorityFeePerGas:f.maxPriorityFeePerGas})}};function O(e){if(e.account&&e.chain)return{address:T(e.account.address),chainId:e.chain.id}}var k=class extends m{#e;#t;#n;constructor(e){super(O(e.walletClient)),this.#e=e.walletClient,this.#t=e.ethereum,this.#n=this.#i()}#r(e){if(!this.#e.account)throw new r(e);return{walletClient:this.#e,account:this.#e.account}}async signTypedData(e){let{walletClient:t,account:n}=this.#r(`signTypedData`);return t.signTypedData({account:n,...g(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?h({provider:this.#t,getInitialWalletAccount:()=>O(this.#e),onWalletAccountChange:({next:e})=>{this.walletAccount.setSnapshot(e)}}):()=>{}}onDispose(){this.#n()}};function A(e){let t=new k({walletClient:e.walletClient,ethereum:e.ethereum}),n=new D({publicClient:e.publicClient});return p(t,n,e)}function j(e){if(!e.account)throw TypeError(`WalletClient has no account`);return e.account}function M(e,t,n){return e.readContract(f(t,n))}function N(t,n){return t.readContract(e(n))}function P(e,t,n){return e.readContract(l(t,n))}function F(e,t,n,r,i){return e.writeContract({chain:e.chain,account:j(e),...o(t,n,r,i)})}function I(e,t,n,r,a,o){return e.writeContract({chain:e.chain,account:j(e),...i(t,n,r,a,o)})}function L(e,t,n,r,i){return e.writeContract({chain:e.chain,account:j(e),...a(t,n,r,i)})}function R(e,t,n,r,i){return e.writeContract({chain:e.chain,account:j(e),...s(t,n,r,i)})}function z(e,t,n,r){return e.writeContract({chain:e.chain,account:j(e),...u(t,n,r)})}function B(e,t,r,i){return e.writeContract({chain:e.chain,account:j(e),...n(t,r,i)})}function V(e,t){return e.readContract(v(t))}function H(e,t){return e.readContract(_(t))}function U(e,t,n,r){return e.readContract(b(t,n,r))}function W(e,t,n){return e.readContract(x(t,n))}function G(e,t,n){return e.readContract(C(t,n))}function K(e,t,n){return e.readContract(y(t,n))}function q(e,t,n){return e.readContract(S(t,n))}export{m as BaseSigner,D as ViemProvider,k as ViemSigner,t as ZamaSDKEvents,A as createConfig,M as readConfidentialBalanceOfContract,G as readConfidentialTokenAddressContract,q as readIsConfidentialTokenValidContract,P as readSupportsInterfaceContract,K as readTokenAddressContract,W as readTokenPairContract,V as readTokenPairsContract,H as readTokenPairsLengthContract,U as readTokenPairsSliceContract,N as readUnderlyingTokenContract,F as writeConfidentialTransferContract,R as writeFinalizeUnwrapContract,z as writeSetOperatorContract,I as writeUnwrapContract,L as writeUnwrapFromBalanceContract,B as writeWrapContract};
2
2
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["unwrapFromBalanceContract","confidentialBalanceOfContract","wrapContract","setOperatorContract","underlyingContract","finalizeUnwrapContract","WalletNotConnectedError","getConfidentialTokenAddressContract","isConfidentialTokenValidContract","confidentialTransferContract","getTokenPairsLengthContract","getTokenAddressContract","ZamaSDKEvents","requireReadChain","TransactionRevertedError","getTokenPairContract","getTokenPairsSliceContract","unwrapContract","buildZamaConfig","BaseSigner","eip1193Subscribe","toViemTypedData","ViemProvider","#publicClient","config","call","chainId","args","data","encodeFunctionData","calldata","chainIdPromise","noncePromise","from","gasPromise","error","feesPromise","nonce","gas","fees","serializeTransaction","walletAccountFromWalletClient","walletClient","getAddress","ViemSigner","#walletClient","#ethereum","#unsubscribeProvider","#subscribeToProvider","operation","#requireAccount","typedData","next","createConfig","signer","params","provider","requireAccount","client","readConfidentialBalanceOfContract","tokenAddress","userAddress","readUnderlyingTokenContract","wrapperAddress","readSupportsInterfaceContract","supportsInterfaceContract","interfaceId","writeConfidentialTransferContract","to","encryptedAmount","inputProof","writeUnwrapContract","encryptedErc20","writeUnwrapFromBalanceContract","encryptedBalance","writeFinalizeUnwrapContract","wrapper","unwrapRequestId","unwrapAmountCleartext","decryptionProof","writeSetOperatorContract","operator","until","writeWrapContract","amount","readTokenPairsContract","getTokenPairsContract","registry","readTokenPairsLengthContract","readTokenPairsSliceContract","fromIndex","toIndex","readTokenPairContract","index","readConfidentialTokenAddressContract","readTokenAddressContract","confidentialTokenAddress","readIsConfidentialTokenValidContract"],"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\";\nimport { requireReadChain } from \"../utils/alignment\";\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 const { chainId, ...call } = config;\n await requireReadChain(\"ViemProvider\", chainId, () => this.getChainId());\n return this.#publicClient.readContract(call as typeof 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(chainId?: number): Promise<bigint> {\n await requireReadChain(\"ViemProvider\", chainId, () => this.getChainId());\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\";\nimport { toViemTypedData } from \"./typed-data\";\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\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 return walletClient.signTypedData({ account, ...toViemTypedData(typedData) });\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":"A,sZA0CA,IAAasB,EAAb,KAAqD,CACnD,GAEA,YAAY,EAA4B,CACtC,KAAKC,GAAgBC,EAAO,YAC9B,CAGA,MAAM,YAA8B,CAClC,OAAO,KAAKD,GAAc,WAAW,CACvC,CAGA,MAAM,aAKJ,EACkF,CAClF,GAAM,CAAE,UAAS,GAAGE,GAASD,EAE7B,OADA,MAAMX,EAAiB,eAAgBa,MAAe,KAAK,WAAW,CAAC,EAChE,KAAKH,GAAc,aAAaE,CAAqB,CAC9D,CAGA,MAAM,0BAA0B,EAAwC,CACtE,OAAO,KAAKF,GAAc,0BAA0B,CAAE,MAAK,CAAC,CAC9D,CAGA,MAAM,kBAAkB,EAAmC,CAGzD,OAFA,MAAMV,EAAiB,eAAgBa,MAAe,KAAK,WAAW,CAAC,GAEhE,MADa,KAAKH,GAAc,SAAS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,CAAM,CAC5C,CAAC,CACH,CAKA,SAAgBC,EAAuB,EAAsB,EAAmB,CAC9E,OAAO3B,EAAO,aAAa4B,EAAsBC,CAAQ,CAAC,CAC5D,CAGA,SAAgBC,EAA6B,EAAsB,EAAmB,CACpF,OAAO9B,EAAO,aAAahD,EAA4B6E,CAAQ,CAAC,CAClE,CAGA,SAAgBE,EACd,EACA,EACA,EACA,EACA,CACA,OAAO/B,EAAO,aAAa1C,EAA2BuE,EAAUG,EAAWC,CAAO,CAAC,CACrF,CAGA,SAAgBC,EAAsB,EAAsB,EAAmB,EAAe,CAC5F,OAAOlC,EAAO,aAAa3C,EAAqBwE,EAAUM,CAAK,CAAC,CAClE,CAGA,SAAgBC,EACd,EACA,EACA,EACA,CACA,OAAOpC,EAAO,aAAanD,EAAoCgF,EAAU3B,CAAY,CAAC,CACxF,CAGA,SAAgBmC,EACd,EACA,EACA,EACA,CACA,OAAOrC,EAAO,aAAa/C,EAAwB4E,EAAUS,CAAwB,CAAC,CACxF,CAGA,SAAgBC,EACd,EACA,EACA,EACA,CACA,OAAOvC,EAAO,aAAalD,EAAiC+E,EAAUS,CAAwB,CAAC,CACjG,C"}
1
+ {"version":3,"file":"index.js","names":["underlyingContract","ZamaSDKEvents","wrapContract","WalletNotConnectedError","unwrapContract","unwrapFromBalanceContract","confidentialTransferContract","finalizeUnwrapContract","TransactionRevertedError","supportsInterfaceContract","setOperatorContract","requireReadChain","confidentialBalanceOfContract","buildZamaConfig","BaseSigner","eip1193Subscribe","toViemTypedData","getTokenPairsLengthContract","getTokenPairsContract","getTokenAddressContract","getTokenPairsSliceContract","getTokenPairContract","isConfidentialTokenValidContract","getConfidentialTokenAddressContract","ViemProvider","#publicClient","config","call","chainId","params","_","args","data","encodeFunctionData","calldata","chainIdPromise","noncePromise","from","gasPromise","error","feesPromise","nonce","gas","fees","serializeTransaction","walletAccountFromWalletClient","walletClient","getAddress","ViemSigner","#walletClient","#ethereum","#unsubscribeProvider","#subscribeToProvider","operation","#requireAccount","typedData","next","createConfig","signer","provider","requireAccount","client","readConfidentialBalanceOfContract","tokenAddress","userAddress","readUnderlyingTokenContract","wrapperAddress","readSupportsInterfaceContract","interfaceId","writeConfidentialTransferContract","to","encryptedAmount","inputProof","writeUnwrapContract","encryptedErc20","writeUnwrapFromBalanceContract","encryptedBalance","writeFinalizeUnwrapContract","wrapper","unwrapRequestId","unwrapAmountCleartext","decryptionProof","writeSetOperatorContract","operator","until","writeWrapContract","amount","readTokenPairsContract","registry","readTokenPairsLengthContract","readTokenPairsSliceContract","fromIndex","toIndex","readTokenPairContract","index","readConfidentialTokenAddressContract","readTokenAddressContract","confidentialTokenAddress","readIsConfidentialTokenValidContract"],"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 MulticallReturnType,\n ReadContractConfig,\n TransactionReceipt,\n WriteContractArgs,\n WriteContractConfig,\n WriteFunctionName,\n} from \"../types\";\nimport { requireReadChain } from \"../utils/alignment\";\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 const { chainId, ...call } = config;\n await requireReadChain(\"ViemProvider\", chainId, () => this.getChainId());\n return this.#publicClient.readContract(call as typeof config);\n }\n\n /**\n * Run many reads in one Multicall3 call. On a chain whose viem definition\n * names no Multicall3, such as a local Hardhat node, the call carries its code.\n */\n async multicall<const TCalls extends readonly ReadContractConfig[]>(params: {\n readonly calls: TCalls;\n readonly chainId?: number;\n }): Promise<MulticallReturnType<TCalls>> {\n await requireReadChain(\"ViemProvider\", params.chainId, () => this.getChainId());\n const results = await this.#publicClient.multicall({\n contracts: params.calls.map(({ chainId: _, ...call }) => call) as never,\n allowFailure: false,\n deployless: this.#publicClient.chain?.contracts?.multicall3 === undefined,\n });\n return results as MulticallReturnType<TCalls>;\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(chainId?: number): Promise<bigint> {\n await requireReadChain(\"ViemProvider\", chainId, () => this.getChainId());\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\";\nimport { toViemTypedData } from \"./typed-data\";\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\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 return walletClient.signTypedData({ account, ...toViemTypedData(typedData) });\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":"A,6cA2CA,IAAawB,EAAb,KAAqD,CACnD,GAEA,YAAY,EAA4B,CACtC,KAAKC,GAAgBC,EAAO,YAC9B,CAGA,MAAM,YAA8B,CAClC,OAAO,KAAKD,GAAc,WAAW,CACvC,CAGA,MAAM,aAKJ,EACkF,CAClF,GAAM,CAAE,UAAS,GAAGE,GAASD,EAE7B,OADA,MAAMf,EAAiB,eAAgBiB,MAAe,KAAK,WAAW,CAAC,EAChE,KAAKH,GAAc,aAAaE,CAAqB,CAC9D,CAMA,MAAM,UAA8D,EAG3B,CAOvC,OANA,MAAMhB,EAAiB,eAAgBkB,EAAO,YAAe,KAAK,WAAW,CAAC,EAMvE,MALe,KAAKJ,GAAc,UAAU,CACjD,UAAWI,EAAO,MAAM,KAAK,CAAE,QAASC,EAAG,GAAGH,KAAWA,CAAI,EAC7D,aAAc,GACd,WAAY,KAAKF,GAAc,OAAO,WAAW,aAAe,IAAA,EAClE,CAA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CAAM,EAC9B,GAAGnD,EAAoBqD,EAAcoB,EAAUC,CAAK,CACtD,CAAC,CACH,CAGA,SAAgBC,EACd,EACA,EACA,EACA,EACA,CACA,OAAOxB,EAAO,cAAc,CAC1B,MAAOA,EAAO,MACd,QAASD,EAAeC,CAAM,EAC9B,GAAG3D,EAAagE,EAAgBI,EAAIgB,CAAM,CAC5C,CAAC,CACH,CAKA,SAAgBC,EAAuB,EAAsB,EAAmB,CAC9E,OAAO1B,EAAO,aAAa3C,EAAsBsE,CAAQ,CAAC,CAC5D,CAGA,SAAgBC,EAA6B,EAAsB,EAAmB,CACpF,OAAO5B,EAAO,aAAa5C,EAA4BuE,CAAQ,CAAC,CAClE,CAGA,SAAgBE,EACd,EACA,EACA,EACA,EACA,CACA,OAAO7B,EAAO,aAAazC,EAA2BoE,EAAUG,EAAWC,CAAO,CAAC,CACrF,CAGA,SAAgBC,EAAsB,EAAsB,EAAmB,EAAe,CAC5F,OAAOhC,EAAO,aAAaxC,EAAqBmE,EAAUM,CAAK,CAAC,CAClE,CAGA,SAAgBC,EACd,EACA,EACA,EACA,CACA,OAAOlC,EAAO,aAAatC,EAAoCiE,EAAUzB,CAAY,CAAC,CACxF,CAGA,SAAgBiC,EACd,EACA,EACA,EACA,CACA,OAAOnC,EAAO,aAAa1C,EAAwBqE,EAAUS,CAAwB,CAAC,CACxF,CAGA,SAAgBC,EACd,EACA,EACA,EACA,CACA,OAAOrC,EAAO,aAAavC,EAAiCkE,EAAUS,CAAwB,CAAC,CACjG,C"}
@@ -7,8 +7,8 @@
7
7
  *
8
8
  * @packageDocumentation
9
9
  */
10
- import { dn as FhevmRelayerOptions, fn as FhevmRuntimeConfig, n as RelayerConfig, pn as RelayerOptions, r as WebRelayerConfig, un as FhevmClientOptions } from "../types-DbnDm2O9.js";
11
- import { t as EncryptWorkerTimeouts } from "../encrypt-worker-client-Bjab5Grh.js";
10
+ import { dn as FhevmClientOptions, fn as FhevmRelayerOptions, mn as RelayerOptions, n as RelayerConfig, pn as FhevmRuntimeConfig, r as WebRelayerConfig } from "../types-Ubeo72FV.js";
11
+ import { t as EncryptWorkerTimeouts } from "../encrypt-worker-client-CkEIA0Tp.js";
12
12
  /** {@link RelayerOptions} plus the web-only encryption offload switches. */
13
13
  interface WebRelayerOptions extends RelayerOptions {
14
14
  /**
@@ -1,2 +1,2 @@
1
- import{r as e,t}from"../fhevm-relayer-B-Ve8Yyz.js";import{t as n}from"../validation-CL7MJT6k.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,r)=>new t({chain:e,options:s,telemetry:r&&{state:r,runtime:`web`,mode:r.mode},offloadEncrypt:c.offloadEncrypt,offloadTimeouts:c.offloadTimeouts,offloadWorker:c.offloadWorker,logger:n})}}export{s as web};
1
+ import{r as e,t}from"../fhevm-relayer-BEzN0aev.js";import{t as n}from"../validation-CZfDLOUh.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,r)=>new t({chain:e,options:s,telemetry:r&&{state:r,runtime:`web`,mode:r.mode},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
+ const e=[{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 t(t){return{address:t,abi:e,functionName:`getTokenConfidentialTokenPairs`,args:[]}}function n(t){return{address:t,abi:e,functionName:`getTokenConfidentialTokenPairsLength`,args:[]}}function r(t,n,r){return{address:t,abi:e,functionName:`getTokenConfidentialTokenPairsSlice`,args:[n,r]}}function i(t,n){return{address:t,abi:e,functionName:`getTokenConfidentialTokenPair`,args:[n]}}function a(t,n){return{address:t,abi:e,functionName:`getConfidentialTokenAddress`,args:[n]}}function o(t,n){return{address:t,abi:e,functionName:`getTokenAddress`,args:[n]}}function s(t,n){return{address:t,abi:e,functionName:`isConfidentialTokenValid`,args:[n]}}export{n as a,t as i,o as n,r as o,i as r,s,a as t};
2
+ //# sourceMappingURL=wrappers-registry-Cm3JJeqx.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wrappers-registry-Cm3JJeqx.js","names":["wrappersRegistryAbi","getTokenPairsContract","registry","getTokenPairsLengthContract","getTokenPairsSliceContract","fromIndex","toIndex","getTokenPairContract","index","getConfidentialTokenAddressContract","tokenAddress","getTokenAddressContract","confidentialTokenAddress","isConfidentialTokenValidContract"],"sources":["../../src/contracts/wrappers-registry.ts"],"sourcesContent":["import type { Address } from \"viem\";\n\nexport const wrappersRegistryAbi = [\n {\n inputs: [],\n name: \"getTokenConfidentialTokenPairs\",\n outputs: [\n {\n components: [\n { internalType: \"address\", name: \"tokenAddress\", type: \"address\" },\n { internalType: \"address\", name: \"confidentialTokenAddress\", type: \"address\" },\n { internalType: \"bool\", name: \"isValid\", type: \"bool\" },\n ],\n internalType: \"struct ConfidentialTokenWrappersRegistry.TokenWrapperPair[]\",\n name: \"\",\n type: \"tuple[]\",\n },\n ],\n stateMutability: \"view\",\n type: \"function\",\n },\n {\n inputs: [],\n name: \"getTokenConfidentialTokenPairsLength\",\n outputs: [{ internalType: \"uint256\", name: \"\", type: \"uint256\" }],\n stateMutability: \"view\",\n type: \"function\",\n },\n {\n inputs: [\n { internalType: \"uint256\", name: \"fromIndex\", type: \"uint256\" },\n { internalType: \"uint256\", name: \"toIndex\", type: \"uint256\" },\n ],\n name: \"getTokenConfidentialTokenPairsSlice\",\n outputs: [\n {\n components: [\n { internalType: \"address\", name: \"tokenAddress\", type: \"address\" },\n { internalType: \"address\", name: \"confidentialTokenAddress\", type: \"address\" },\n { internalType: \"bool\", name: \"isValid\", type: \"bool\" },\n ],\n internalType: \"struct ConfidentialTokenWrappersRegistry.TokenWrapperPair[]\",\n name: \"\",\n type: \"tuple[]\",\n },\n ],\n stateMutability: \"view\",\n type: \"function\",\n },\n {\n inputs: [{ internalType: \"uint256\", name: \"index\", type: \"uint256\" }],\n name: \"getTokenConfidentialTokenPair\",\n outputs: [\n {\n components: [\n { internalType: \"address\", name: \"tokenAddress\", type: \"address\" },\n { internalType: \"address\", name: \"confidentialTokenAddress\", type: \"address\" },\n { internalType: \"bool\", name: \"isValid\", type: \"bool\" },\n ],\n internalType: \"struct ConfidentialTokenWrappersRegistry.TokenWrapperPair\",\n name: \"\",\n type: \"tuple\",\n },\n ],\n stateMutability: \"view\",\n type: \"function\",\n },\n {\n inputs: [{ internalType: \"address\", name: \"tokenAddress\", type: \"address\" }],\n name: \"getConfidentialTokenAddress\",\n outputs: [\n { internalType: \"bool\", name: \"\", type: \"bool\" },\n { internalType: \"address\", name: \"\", type: \"address\" },\n ],\n stateMutability: \"view\",\n type: \"function\",\n },\n {\n inputs: [{ internalType: \"address\", name: \"confidentialTokenAddress\", type: \"address\" }],\n name: \"getTokenAddress\",\n outputs: [\n { internalType: \"bool\", name: \"\", type: \"bool\" },\n { internalType: \"address\", name: \"\", type: \"address\" },\n ],\n stateMutability: \"view\",\n type: \"function\",\n },\n {\n inputs: [{ internalType: \"address\", name: \"confidentialTokenAddress\", type: \"address\" }],\n name: \"isConfidentialTokenValid\",\n outputs: [{ internalType: \"bool\", name: \"\", type: \"bool\" }],\n stateMutability: \"view\",\n type: \"function\",\n },\n {\n inputs: [{ internalType: \"address\", name: \"initialOwner\", type: \"address\" }],\n name: \"initialize\",\n outputs: [],\n stateMutability: \"nonpayable\",\n type: \"function\",\n },\n {\n inputs: [\n { internalType: \"address\", name: \"tokenAddress\", type: \"address\" },\n { internalType: \"address\", name: \"confidentialTokenAddress\", type: \"address\" },\n ],\n name: \"registerConfidentialToken\",\n outputs: [],\n stateMutability: \"nonpayable\",\n type: \"function\",\n },\n {\n inputs: [{ internalType: \"address\", name: \"confidentialTokenAddress\", type: \"address\" }],\n name: \"revokeConfidentialToken\",\n outputs: [],\n stateMutability: \"nonpayable\",\n type: \"function\",\n },\n] as const;\n\n/** A registered plain-token / confidential-token pairing from the wrappers registry. */\nexport interface TokenWrapperPair {\n /** Address of the underlying public ERC-20 token. */\n readonly tokenAddress: Address;\n /** Address of the paired confidential (ERC-7984) token. */\n readonly confidentialTokenAddress: Address;\n /** Whether the pairing is currently valid (registered and not revoked). */\n readonly isValid: boolean;\n}\n\n/** Extended pair with on-chain metadata for both tokens. */\nexport interface TokenWrapperPairWithMetadata extends TokenWrapperPair {\n /** On-chain metadata of the underlying public ERC-20 token. */\n readonly underlying: {\n readonly name: string;\n readonly symbol: string;\n readonly decimals: number;\n readonly totalSupply: bigint;\n };\n /** On-chain metadata of the confidential token. */\n readonly confidential: {\n readonly name: string;\n readonly symbol: string;\n readonly decimals: number;\n };\n}\n\n/** Paginated result set modeled after standard API pagination. */\nexport interface PaginatedResult<T> {\n /** Items on the current page. */\n readonly items: readonly T[];\n /** Total number of items across all pages. */\n readonly total: number;\n /** One-based index of the current page. */\n readonly page: number;\n /** Maximum number of items per page. */\n readonly pageSize: number;\n}\n\n/**\n * Returns the contract config to fetch all token wrapper pairs.\n *\n * @example\n * ```ts\n * const pairs = await client.readContract(\n * getTokenPairsContract(registryAddress),\n * );\n * ```\n */\nexport function getTokenPairsContract(registry: Address) {\n return {\n address: registry,\n abi: wrappersRegistryAbi,\n functionName: \"getTokenConfidentialTokenPairs\",\n args: [],\n } as const;\n}\n\n/**\n * Returns the contract config to get the number of token wrapper pairs.\n *\n * @example\n * ```ts\n * const length = await client.readContract(\n * getTokenPairsLengthContract(registryAddress),\n * );\n * ```\n */\nexport function getTokenPairsLengthContract(registry: Address) {\n return {\n address: registry,\n abi: wrappersRegistryAbi,\n functionName: \"getTokenConfidentialTokenPairsLength\",\n args: [],\n } as const;\n}\n\n/**\n * Returns the contract config to fetch a slice of token wrapper pairs.\n *\n * @example\n * ```ts\n * const pairs = await client.readContract(\n * getTokenPairsSliceContract(registryAddress, 0n, 10n),\n * );\n * ```\n */\nexport function getTokenPairsSliceContract(registry: Address, fromIndex: bigint, toIndex: bigint) {\n return {\n address: registry,\n abi: wrappersRegistryAbi,\n functionName: \"getTokenConfidentialTokenPairsSlice\",\n args: [fromIndex, toIndex],\n } as const;\n}\n\n/**\n * Returns the contract config to fetch a single token wrapper pair by index.\n *\n * @example\n * ```ts\n * const pair = await client.readContract(\n * getTokenPairContract(registryAddress, 0n),\n * );\n * ```\n */\nexport function getTokenPairContract(registry: Address, index: bigint) {\n return {\n address: registry,\n abi: wrappersRegistryAbi,\n functionName: \"getTokenConfidentialTokenPair\",\n args: [index],\n } as const;\n}\n\n/**\n * Returns the contract config to look up the confidential token for a given plain token.\n *\n * @example\n * ```ts\n * const [isValid, confidentialToken] = await client.readContract(\n * getConfidentialTokenAddressContract(registryAddress, tokenAddress),\n * );\n * // isValid=false + confidentialToken=zeroAddress → not registered\n * // isValid=false + confidentialToken=nonZeroAddress → registered but revoked\n * // isValid=true + confidentialToken=nonZeroAddress → registered and valid\n * ```\n */\nexport function getConfidentialTokenAddressContract(registry: Address, tokenAddress: Address) {\n return {\n address: registry,\n abi: wrappersRegistryAbi,\n functionName: \"getConfidentialTokenAddress\",\n args: [tokenAddress],\n } as const;\n}\n\n/**\n * Returns the contract config to look up the plain token for a given confidential token.\n *\n * @example\n * ```ts\n * const [isValid, token] = await client.readContract(\n * getTokenAddressContract(registryAddress, confidentialTokenAddress),\n * );\n * // isValid=false + token=zeroAddress → not registered\n * // isValid=false + token=nonZeroAddress → registered but revoked\n * // isValid=true + token=nonZeroAddress → registered and valid\n * ```\n */\nexport function getTokenAddressContract(registry: Address, confidentialTokenAddress: Address) {\n return {\n address: registry,\n abi: wrappersRegistryAbi,\n functionName: \"getTokenAddress\",\n args: [confidentialTokenAddress],\n } as const;\n}\n\n/**\n * Returns the contract config to check if a confidential token is valid.\n *\n * @example\n * ```ts\n * const isValid = await client.readContract(\n * isConfidentialTokenValidContract(registryAddress, confidentialTokenAddress),\n * );\n * ```\n */\nexport function isConfidentialTokenValidContract(\n registry: Address,\n confidentialTokenAddress: Address,\n) {\n return {\n address: registry,\n abi: wrappersRegistryAbi,\n functionName: \"isConfidentialTokenValid\",\n args: [confidentialTokenAddress],\n } as const;\n}\n"],"mappings":"AAEA,MAAaA,EAAsB,CACjC,CACE,OAAQ,CAAC,EACT,KAAM,iCACN,QAAS,CACP,CACE,WAAY,CACV,CAAE,aAAc,UAAW,KAAM,eAAgB,KAAM,SAAU,EACjE,CAAE,aAAc,UAAW,KAAM,2BAA4B,KAAM,SAAU,EAC7E,CAAE,aAAc,OAAQ,KAAM,UAAW,KAAM,MAAO,CACxD,EACA,aAAc,8DACd,KAAM,GACN,KAAM,SACR,CACF,EACA,gBAAiB,OACjB,KAAM,UACR,E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,QAASP,EACT,IAAKF,EACL,aAAc,8BACd,KAAM,CAACU,CAAY,CACrB,CACF,CAeA,SAAgBC,EAAwB,EAAmB,EAAmC,CAC5F,MAAO,CACL,QAAST,EACT,IAAKF,EACL,aAAc,kBACd,KAAM,CAACY,CAAwB,CACjC,CACF,CAYA,SAAgBC,EACd,EACA,EACA,CACA,MAAO,CACL,QAASX,EACT,IAAKF,EACL,aAAc,2BACd,KAAM,CAACY,CAAwB,CACjC,CACF,C"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zama-fhe/sdk",
3
- "version": "3.8.0-beta.20",
3
+ "version": "3.8.0-beta.21",
4
4
  "description": "TypeScript SDK for Zama fhEVM confidential smart contracts",
5
5
  "keywords": [
6
6
  "blockchain",
@@ -1,2 +0,0 @@
1
- let e,t=!1;function n(n){e=Object.freeze({wasmAssetLoadMode:n.wasmAssetLoadMode,moduleVersions:n.moduleVersions,singleThread:n.singleThread,numberOfThreads:n.numberOfThreads,auth:n.auth}),t=n.locateFile!==void 0}function r(){return e}function i(){return t}Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return i}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return n}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return r}});
2
- //# sourceMappingURL=applied-runtime.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"applied-runtime.cjs","names":["appliedWireRuntime","appliedLocateFile","recordAppliedRuntimeConfig","runtime","getAppliedWireRuntime","hasAppliedLocateFile"],"sources":["../../src/relayer/applied-runtime.ts"],"sourcesContent":["import type { FhevmRuntimeConfig, WireRuntimeConfig } from \"./types\";\n\n/**\n * Mirror of the runtime config this package applied via the upstream\n * `setFhevmRuntimeConfig`, which is itself a process-wide one-shot. An encrypt\n * worker realm replicates it, since the upstream lock offers no getter.\n */\nlet appliedWireRuntime: WireRuntimeConfig | undefined;\n\n/** `locateFile` is a function, so it stays off the wire and is only flagged here. */\nlet appliedLocateFile = false;\n\n/** Projects the applied runtime onto the fields a worker realm replicates. */\nexport function recordAppliedRuntimeConfig(runtime: FhevmRuntimeConfig): void {\n appliedWireRuntime = Object.freeze({\n wasmAssetLoadMode: runtime.wasmAssetLoadMode,\n moduleVersions: runtime.moduleVersions,\n singleThread: runtime.singleThread,\n numberOfThreads: runtime.numberOfThreads,\n auth: runtime.auth,\n });\n appliedLocateFile = runtime.locateFile !== undefined;\n}\n\n/** `undefined` when the upstream lock was set outside this package. */\nexport function getAppliedWireRuntime(): WireRuntimeConfig | undefined {\n return appliedWireRuntime;\n}\n\nexport function hasAppliedLocateFile(): boolean {\n return appliedLocateFile;\n}\n\n/** @internal */\nexport function resetAppliedRuntimeConfig(): void {\n appliedWireRuntime = undefined;\n appliedLocateFile = false;\n}\n"],"mappings":"AAOA,IAAIA,EAGAC,EAAoB,GAGxB,SAAgBC,EAA2B,EAAmC,CAC5E,EAAqB,OAAO,OAAO,CACjC,kBAAmBC,EAAQ,kBAC3B,eAAgBA,EAAQ,eACxB,aAAcA,EAAQ,aACtB,gBAAiBA,EAAQ,gBACzB,KAAMA,EAAQ,IAChB,CAAC,EACD,EAAoBA,EAAQ,aAAe,IAAA,EAC7C,CAGA,SAAgBC,GAAuD,CACrE,OAAOJ,CACT,CAEA,SAAgBK,GAAgC,CAC9C,OAAOJ,CACT,C"}
@@ -1,2 +0,0 @@
1
- let e=require("viem"),t=require("zod/mini");function n(e){if(!r(e))return!1;let t=e.constructor;if(t===void 0)return!0;let n=t.prototype;return!(!r(n)||!n.hasOwnProperty(`isPrototypeOf`))}function r(e){return Object.prototype.toString.call(e)===`[object Object]`}function i(e){let{gcTime:t,staleTime:n,enabled:r,select:i,refetchInterval:a,refetchOnMount:o,refetchOnWindowFocus:s,refetchOnReconnect:c,retry:l,retryDelay:u,retryOnMount:d,queryFn:f,queryKey:p,queryKeyHashFn:m,initialData:h,initialDataUpdatedAt:g,placeholderData:_,structuralSharing:v,throwOnError:y,meta:b,query:x,pollingInterval:S,...C}=e;return C}function a(e){return JSON.stringify(e,(e,t)=>n(t)?Object.keys(t).sort().reduce((e,n)=>(e[n]=t[n],e),{}):typeof t==`bigint`?t.toString():t)}const o=t=>t.map(t=>(0,e.getAddress)(t)),s=t=>t===void 0?void 0:(0,e.getAddress)(t),c=t=>t?{walletAddress:(0,e.getAddress)(t.address),walletChainId:t.chainId}:{},l={confidentialBalance:{all:[`zama.confidentialBalance`],token:t=>[`zama.confidentialBalance`,{tokenAddress:(0,e.getAddress)(t)}],owner:(t,n,r)=>[`zama.confidentialBalance`,{tokenAddress:(0,e.getAddress)(t),...c(r),...n?{owner:(0,e.getAddress)(n)}:{}}]},confidentialBalances:{all:[`zama.confidentialBalances`],tokens:(t,n,r)=>[`zama.confidentialBalances`,{tokenAddresses:o(t),...c(r),...n?{owner:(0,e.getAddress)(n)}:{}}]},tokenMetadata:{all:[`zama.tokenMetadata`],token:t=>[`zama.tokenMetadata`,{tokenAddress:(0,e.getAddress)(t)}]},isConfidential:{all:[`zama.isConfidential`],token:t=>[`zama.isConfidential`,{tokenAddress:(0,e.getAddress)(t)}]},isWrapper:{all:[`zama.isWrapper`],token:t=>[`zama.isWrapper`,{tokenAddress:(0,e.getAddress)(t)}]},wrapperDiscovery:{all:[`zama.wrapperDiscovery`],token:(e,t,n)=>{let r=s(e),i=s(t),a=s(n);return[`zama.wrapperDiscovery`,{...r?{tokenAddress:r}:{},...i?{erc20Address:i}:{},...a?{registryAddress:a}:{}}]}},underlyingAllowance:{all:[`zama.underlyingAllowance`],token:t=>[`zama.underlyingAllowance`,{tokenAddress:(0,e.getAddress)(t)}],scope:(t,n)=>[`zama.underlyingAllowance`,{tokenAddress:(0,e.getAddress)(t),...n?{owner:(0,e.getAddress)(n)}:{}}]},confidentialIsOperator:{all:[`zama.confidentialIsOperator`],token:e=>{let t=s(e);return[`zama.confidentialIsOperator`,t?{tokenAddress:t}:{}]},scope:(e,t,n)=>{let r=s(e),i=s(t),a=s(n);return[`zama.confidentialIsOperator`,{...r?{tokenAddress:r}:{},...i?{holder:i}:{},...a?{spender:a}:{}}]}},totalSupply:{all:[`zama.totalSupply`],token:t=>[`zama.totalSupply`,{tokenAddress:(0,e.getAddress)(t)}]},pendingUnshield:{all:[`zama.pendingUnshield`],token:t=>[`zama.pendingUnshield`,{tokenAddress:(0,e.getAddress)(t)}]},hasPermit:{all:[`zama.hasPermit`],scope:(e,t)=>[`zama.hasPermit`,{...c(t),contractAddresses:o(e).sort()}]},delegationStatus:{all:[`zama.delegationStatus`],contract:e=>{let t=s(e);return[`zama.delegationStatus`,t?{contractAddress:t}:{}]},scope:(e,t,n)=>{let r=s(e),i=s(t),a=s(n);return[`zama.delegationStatus`,{...r?{contractAddress:r}:{},...i?{delegatorAddress:i}:{},...a?{delegateAddress:a}:{}}]}},decryption:{all:[`zama.decryption`],encryptedValue:(t,n)=>[`zama.decryption`,{encryptedValue:t,...n===void 0?{}:{contractAddress:(0,e.getAddress)(n)}}],encryptedInputs:(t,n)=>[`zama.decryption`,{...c(n),encryptedInputs:[...t].sort((e,t)=>e.encryptedValue.localeCompare(t.encryptedValue)).map(t=>({encryptedValue:t.encryptedValue,contractAddress:(0,e.getAddress)(t.contractAddress)}))}]},wrappersRegistry:{all:[`zama.wrappersRegistry`],chainId:e=>[`zama.wrappersRegistry`,{type:`chainId`,...e===void 0?{}:{walletChainId:e}}],tokenPairs:t=>[`zama.wrappersRegistry`,{type:`tokenPairs`,registryAddress:(0,e.getAddress)(t)}],confidentialTokenAddress:(t,n)=>[`zama.wrappersRegistry`,{type:`confidentialTokenAddress`,registryAddress:(0,e.getAddress)(t),tokenAddress:(0,e.getAddress)(n)}],tokenAddress:(t,n)=>[`zama.wrappersRegistry`,{type:`tokenAddress`,registryAddress:(0,e.getAddress)(t),confidentialTokenAddress:(0,e.getAddress)(n)}],tokenPairsLength:t=>[`zama.wrappersRegistry`,{type:`tokenPairsLength`,registryAddress:(0,e.getAddress)(t)}],tokenPairsSlice:(t,n,r)=>[`zama.wrappersRegistry`,{type:`tokenPairsSlice`,registryAddress:(0,e.getAddress)(t),fromIndex:n,toIndex:r}],tokenPair:(t,n)=>[`zama.wrappersRegistry`,{type:`tokenPair`,registryAddress:(0,e.getAddress)(t),index:n}],isConfidentialTokenValid:(t,n)=>[`zama.wrappersRegistry`,{type:`isConfidentialTokenValid`,registryAddress:(0,e.getAddress)(t),confidentialTokenAddress:(0,e.getAddress)(n)}],listPairs:(t,n,r,i)=>[`zama.wrappersRegistry`,{type:`listPairs`,registryAddress:(0,e.getAddress)(t),page:n,pageSize:r,metadata:i}]}};function u(e,t){e.invalidateQueries({queryKey:l.underlyingAllowance.token(t)})}function d(e,t){e.invalidateQueries({queryKey:l.pendingUnshield.token(t)})}function f(e,t){m(e,t),u(e,t),d(e,t),D(e)}function p(e,t){m(e,t),u(e,t),D(e)}function m(e,t){e.invalidateQueries({queryKey:l.confidentialBalance.token(t)}),e.invalidateQueries({queryKey:l.confidentialBalances.all})}function h(e,t){m(e,t),u(e,t),D(e)}function g(e,t){m(e,t),u(e,t),d(e,t),D(e)}function _(e,t){d(e,t)}function v(e,t){m(e,t)}function y(e,t){u(e,t)}function b(e,t){e.invalidateQueries({queryKey:l.confidentialIsOperator.token(t)})}function x(e){return Array.isArray(e.queryKey)&&typeof e.queryKey[0]==`string`?e.queryKey[0].startsWith(`zama.`):!1}const S=t.z.enum([`balanceOf`,`confidentialBalanceOf`]),C=t.z.object({functionName:S}),w=t.z.object({contracts:t.z.array(t.z.unknown())});function T(e){if(C.safeParse(e).success)return!0;let t=w.safeParse(e);return t.success&&t.data.contracts.some(e=>C.safeParse(e).success)}function E(e){return Array.isArray(e.queryKey)&&e.queryKey.some(T)}function D(e){e.invalidateQueries({predicate:E})}function O(e){e.removeQueries({queryKey:l.decryption.all}),e.removeQueries({queryKey:l.hasPermit.all}),e.invalidateQueries({predicate:x}),D(e)}Object.defineProperty(exports,"a",{enumerable:!0,get:function(){return g}}),Object.defineProperty(exports,"c",{enumerable:!0,get:function(){return p}}),Object.defineProperty(exports,"d",{enumerable:!0,get:function(){return O}}),Object.defineProperty(exports,"f",{enumerable:!0,get:function(){return l}}),Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return v}}),Object.defineProperty(exports,"l",{enumerable:!0,get:function(){return m}}),Object.defineProperty(exports,"m",{enumerable:!0,get:function(){return a}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return b}}),Object.defineProperty(exports,"o",{enumerable:!0,get:function(){return _}}),Object.defineProperty(exports,"p",{enumerable:!0,get:function(){return i}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return h}}),Object.defineProperty(exports,"s",{enumerable:!0,get:function(){return f}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return y}}),Object.defineProperty(exports,"u",{enumerable:!0,get:function(){return D}});
2
- //# sourceMappingURL=invalidation.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"invalidation.cjs","names":["getAddress","z","viem","zod_mini","isPlainObject","hasObjectPrototype","value","ctor","prot","o","filterQueryOptions","_gcTime","_staleTime","_enabled","_select","_refetchInterval","_refetchOnMount","_refetchOnWindowFocus","_refetchOnReconnect","_retry","_retryDelay","_retryOnMount","_queryFn","_queryKey","_queryKeyHashFn","_initialData","_initialDataUpdatedAt","_placeholderData","_structuralSharing","_throwOnError","_meta","_query","_pollingInterval","rest","options","hashFn","queryKey","key","result","normalizeAddresses","addresses","address","normalizeAddress","walletAccountKey","walletAccount","zamaQueryKeys","tokenAddress","owner","tokenAddresses","t","e","erc20Address","r","registryAddress","h","holder","s","spender","contractAddresses","contractAddress","dr","delegator","de","delegate","encryptedInputs","a","b","walletChainId","confidentialTokenAddress","invalidateUnderlyingAllowanceQueries","queryClient","invalidatePendingUnshieldQueries","invalidateAfterUnwrap","invalidateBalanceQueries","invalidateWagmiBalanceQueries","invalidateAfterWrap","invalidateAfterShield","invalidateAfterUnshield","invalidateAfterUnshieldSettled","invalidateAfterTransfer","invalidateAfterApproveUnderlying","invalidateAfterSetOperator","isZamaQuery","query","balanceFunctionName","balanceReadArgs","batchedReadArgs","isBalanceReadPart","part","batched","c","isWagmiBalanceQuery","invalidateWalletLifecycleQueries"],"sources":["../../src/query/utils.ts","../../src/query/query-keys.ts","../../src/query/invalidation.ts"],"sourcesContent":["// Adapted from the wagmi codebase\n// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-wrapper-object-types\nfunction isPlainObject(value: any): value is Object {\n if (!hasObjectPrototype(value)) {\n return false;\n }\n\n // If has modified constructor\n const ctor = value.constructor;\n if (ctor === undefined) {\n return true;\n }\n\n // If has modified prototype\n const prot = ctor.prototype;\n if (!hasObjectPrototype(prot)) {\n return false;\n }\n\n // If constructor does not have an Object-specific method\n // eslint-disable-next-line no-prototype-builtins\n if (!prot.hasOwnProperty(\"isPrototypeOf\")) {\n return false;\n }\n\n // Most likely a plain Object\n return true;\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nfunction hasObjectPrototype(o: any): boolean {\n return Object.prototype.toString.call(o) === \"[object Object]\";\n}\n\n/** Union of TanStack Query option keys stripped by {@link filterQueryOptions}, leaving only domain parameters. */\nexport type StrippedQueryOptionKeys =\n // Keep this union aligned with @tanstack/query-core behavioral options\n // (for example QueryObserverOptions). Revisit on every upgrade to avoid\n // leaking query controls into lower-level query factories.\n | \"gcTime\"\n | \"staleTime\"\n | \"enabled\"\n | \"select\"\n | \"refetchInterval\"\n | \"refetchOnMount\"\n | \"refetchOnWindowFocus\"\n | \"refetchOnReconnect\"\n | \"retry\"\n | \"retryDelay\"\n | \"retryOnMount\"\n | \"queryFn\"\n | \"queryKey\"\n | \"queryKeyHashFn\"\n | \"initialData\"\n | \"initialDataUpdatedAt\"\n | \"placeholderData\"\n | \"structuralSharing\"\n | \"throwOnError\"\n | \"meta\"\n | \"query\"\n | \"pollingInterval\";\n\n/**\n * Remove TanStack behavioral options from a query config object so only domain\n * parameters remain for the lower-level factory.\n *\n * @example\n * ```ts\n * const params = filterQueryOptions({\n * query: { enabled: false },\n * gcTime: 60_000,\n * owner: \"0xabc\",\n * });\n * // => { owner: \"0xabc\" }\n * ```\n */\nexport function filterQueryOptions<TOptions extends Record<string, unknown>>(\n options: TOptions,\n): Omit<TOptions, StrippedQueryOptionKeys> {\n const {\n gcTime: _gcTime,\n staleTime: _staleTime,\n enabled: _enabled,\n select: _select,\n refetchInterval: _refetchInterval,\n refetchOnMount: _refetchOnMount,\n refetchOnWindowFocus: _refetchOnWindowFocus,\n refetchOnReconnect: _refetchOnReconnect,\n retry: _retry,\n retryDelay: _retryDelay,\n retryOnMount: _retryOnMount,\n queryFn: _queryFn,\n queryKey: _queryKey,\n queryKeyHashFn: _queryKeyHashFn,\n initialData: _initialData,\n initialDataUpdatedAt: _initialDataUpdatedAt,\n placeholderData: _placeholderData,\n structuralSharing: _structuralSharing,\n throwOnError: _throwOnError,\n meta: _meta,\n query: _query,\n pollingInterval: _pollingInterval,\n ...rest\n } = options;\n\n return rest;\n}\n\n/**\n * Stable hash function for query keys.\n * Sorts object keys recursively and converts bigint values to strings.\n *\n * @remarks\n * bigint values are serialized as decimal strings, so `42n` and `\"42\"` hash to\n * the same token when they occupy the same position. This collision is accepted\n * by design for the current query-key conventions in this package.\n */\nexport function hashFn(queryKey: readonly unknown[]): string {\n return JSON.stringify(queryKey, (_, value) => {\n if (isPlainObject(value)) {\n return Object.keys(value)\n .sort()\n .reduce(\n (result, key) => {\n result[key] = value[key];\n return result;\n },\n {} as Record<string, unknown>,\n );\n }\n\n if (typeof value === \"bigint\") {\n return value.toString();\n }\n\n return value;\n });\n}\n","import { getAddress } from \"viem\";\nimport type { Address, Hex } from \"viem\";\nimport type { WalletAccount } from \"../types\";\n\nconst normalizeAddresses = (addresses: Address[]): Address[] =>\n addresses.map((address) => getAddress(address));\nconst normalizeAddress = (address?: Address): Address | undefined =>\n address === undefined ? undefined : getAddress(address);\nconst walletAccountKey = (walletAccount?: WalletAccount) =>\n walletAccount\n ? { walletAddress: getAddress(walletAccount.address), walletChainId: walletAccount.chainId }\n : {};\n\n/**\n * Canonical query-key namespace for `@zama-fhe/sdk/query`.\n *\n * @example\n * ```ts\n * queryClient.invalidateQueries({\n * queryKey: zamaQueryKeys.confidentialBalance.token(\"0xToken\"),\n * });\n * ```\n */\nexport const zamaQueryKeys = {\n confidentialBalance: {\n all: [\"zama.confidentialBalance\"] as const,\n token: (tokenAddress: Address) =>\n [\"zama.confidentialBalance\", { tokenAddress: getAddress(tokenAddress) }] as const,\n owner: (tokenAddress: Address, owner?: Address, walletAccount?: WalletAccount) =>\n [\n \"zama.confidentialBalance\",\n {\n tokenAddress: getAddress(tokenAddress),\n ...walletAccountKey(walletAccount),\n ...(owner ? { owner: getAddress(owner) } : {}),\n },\n ] as const,\n },\n\n confidentialBalances: {\n all: [\"zama.confidentialBalances\"] as const,\n tokens: (tokenAddresses: Address[], owner?: Address, walletAccount?: WalletAccount) =>\n [\n \"zama.confidentialBalances\",\n {\n tokenAddresses: normalizeAddresses(tokenAddresses),\n ...walletAccountKey(walletAccount),\n ...(owner ? { owner: getAddress(owner) } : {}),\n },\n ] as const,\n },\n\n tokenMetadata: {\n all: [\"zama.tokenMetadata\"] as const,\n token: (tokenAddress: Address) =>\n [\"zama.tokenMetadata\", { tokenAddress: getAddress(tokenAddress) }] as const,\n },\n\n isConfidential: {\n all: [\"zama.isConfidential\"] as const,\n token: (tokenAddress: Address) =>\n [\"zama.isConfidential\", { tokenAddress: getAddress(tokenAddress) }] as const,\n },\n\n isWrapper: {\n all: [\"zama.isWrapper\"] as const,\n token: (tokenAddress: Address) =>\n [\"zama.isWrapper\", { tokenAddress: getAddress(tokenAddress) }] as const,\n },\n\n wrapperDiscovery: {\n all: [\"zama.wrapperDiscovery\"] as const,\n token: (tokenAddress?: Address, erc20Address?: Address, registryAddress?: Address) => {\n const t = normalizeAddress(tokenAddress);\n const e = normalizeAddress(erc20Address);\n const r = normalizeAddress(registryAddress);\n return [\n \"zama.wrapperDiscovery\",\n {\n ...(t ? { tokenAddress: t } : {}),\n ...(e ? { erc20Address: e } : {}),\n ...(r ? { registryAddress: r } : {}),\n },\n ] as const;\n },\n },\n\n underlyingAllowance: {\n all: [\"zama.underlyingAllowance\"] as const,\n token: (tokenAddress: Address) =>\n [\"zama.underlyingAllowance\", { tokenAddress: getAddress(tokenAddress) }] as const,\n scope: (tokenAddress: Address, owner?: Address) =>\n [\n \"zama.underlyingAllowance\",\n { tokenAddress: getAddress(tokenAddress), ...(owner ? { owner: getAddress(owner) } : {}) },\n ] as const,\n },\n\n confidentialIsOperator: {\n all: [\"zama.confidentialIsOperator\"] as const,\n token: (tokenAddress?: Address) => {\n const t = normalizeAddress(tokenAddress);\n return [\"zama.confidentialIsOperator\", t ? { tokenAddress: t } : {}] as const;\n },\n scope: (tokenAddress?: Address, holder?: Address, spender?: Address) => {\n const t = normalizeAddress(tokenAddress);\n const h = normalizeAddress(holder);\n const s = normalizeAddress(spender);\n return [\n \"zama.confidentialIsOperator\",\n {\n ...(t ? { tokenAddress: t } : {}),\n ...(h ? { holder: h } : {}),\n ...(s ? { spender: s } : {}),\n },\n ] as const;\n },\n },\n\n totalSupply: {\n all: [\"zama.totalSupply\"] as const,\n token: (tokenAddress: Address) =>\n [\"zama.totalSupply\", { tokenAddress: getAddress(tokenAddress) }] as const,\n },\n\n pendingUnshield: {\n all: [\"zama.pendingUnshield\"] as const,\n token: (tokenAddress: Address) =>\n [\"zama.pendingUnshield\", { tokenAddress: getAddress(tokenAddress) }] as const,\n },\n\n hasPermit: {\n all: [\"zama.hasPermit\"] as const,\n scope: (contractAddresses: Address[], walletAccount?: WalletAccount) =>\n [\n \"zama.hasPermit\",\n {\n ...walletAccountKey(walletAccount),\n contractAddresses: normalizeAddresses(contractAddresses).sort(),\n },\n ] as const,\n },\n\n delegationStatus: {\n all: [\"zama.delegationStatus\"] as const,\n contract: (contractAddress?: Address) => {\n const t = normalizeAddress(contractAddress);\n return [\"zama.delegationStatus\", t ? { contractAddress: t } : {}] as const;\n },\n scope: (contractAddress?: Address, delegator?: Address, delegate?: Address) => {\n const t = normalizeAddress(contractAddress);\n const dr = normalizeAddress(delegator);\n const de = normalizeAddress(delegate);\n return [\n \"zama.delegationStatus\",\n {\n ...(t ? { contractAddress: t } : {}),\n ...(dr ? { delegatorAddress: dr } : {}),\n ...(de ? { delegateAddress: de } : {}),\n },\n ] as const;\n },\n },\n\n decryption: {\n all: [\"zama.decryption\"] as const,\n encryptedValue: (encryptedValue: string, contractAddress?: Address) =>\n [\n \"zama.decryption\",\n {\n encryptedValue,\n ...(contractAddress === undefined\n ? {}\n : { contractAddress: getAddress(contractAddress) }),\n },\n ] as const,\n encryptedInputs: (\n encryptedInputs: readonly { encryptedValue: string; contractAddress: Address }[],\n walletAccount?: WalletAccount,\n ) =>\n [\n \"zama.decryption\",\n {\n ...walletAccountKey(walletAccount),\n encryptedInputs: [...encryptedInputs]\n .sort((a, b) => a.encryptedValue.localeCompare(b.encryptedValue))\n .map((h) => ({\n encryptedValue: h.encryptedValue as Hex,\n contractAddress: getAddress(h.contractAddress),\n })),\n },\n ] as const,\n },\n\n wrappersRegistry: {\n all: [\"zama.wrappersRegistry\"] as const,\n chainId: (walletChainId?: number) =>\n [\n \"zama.wrappersRegistry\",\n { type: \"chainId\", ...(walletChainId === undefined ? {} : { walletChainId }) },\n ] as const,\n tokenPairs: (registryAddress: Address) =>\n [\n \"zama.wrappersRegistry\",\n { type: \"tokenPairs\", registryAddress: getAddress(registryAddress) },\n ] as const,\n confidentialTokenAddress: (registryAddress: Address, tokenAddress: Address) =>\n [\n \"zama.wrappersRegistry\",\n {\n type: \"confidentialTokenAddress\",\n registryAddress: getAddress(registryAddress),\n tokenAddress: getAddress(tokenAddress),\n },\n ] as const,\n tokenAddress: (registryAddress: Address, confidentialTokenAddress: Address) =>\n [\n \"zama.wrappersRegistry\",\n {\n type: \"tokenAddress\",\n registryAddress: getAddress(registryAddress),\n confidentialTokenAddress: getAddress(confidentialTokenAddress),\n },\n ] as const,\n tokenPairsLength: (registryAddress: Address) =>\n [\n \"zama.wrappersRegistry\",\n { type: \"tokenPairsLength\", registryAddress: getAddress(registryAddress) },\n ] as const,\n tokenPairsSlice: (registryAddress: Address, fromIndex: string, toIndex: string) =>\n [\n \"zama.wrappersRegistry\",\n {\n type: \"tokenPairsSlice\",\n registryAddress: getAddress(registryAddress),\n fromIndex,\n toIndex,\n },\n ] as const,\n tokenPair: (registryAddress: Address, index: string) =>\n [\n \"zama.wrappersRegistry\",\n { type: \"tokenPair\", registryAddress: getAddress(registryAddress), index },\n ] as const,\n isConfidentialTokenValid: (registryAddress: Address, confidentialTokenAddress: Address) =>\n [\n \"zama.wrappersRegistry\",\n {\n type: \"isConfidentialTokenValid\",\n registryAddress: getAddress(registryAddress),\n confidentialTokenAddress: getAddress(confidentialTokenAddress),\n },\n ] as const,\n listPairs: (registryAddress: Address, page: number, pageSize: number, metadata: boolean) =>\n [\n \"zama.wrappersRegistry\",\n {\n type: \"listPairs\",\n registryAddress: getAddress(registryAddress),\n page,\n pageSize,\n metadata,\n },\n ] as const,\n },\n} as const;\n","import type { Address } from \"viem\";\nimport { z } from \"zod/mini\";\nimport { zamaQueryKeys } from \"./query-keys\";\n\n/** Minimal query shape read by the invalidation predicates. */\nexport interface QueryLike {\n /** The query's cache key. */\n queryKey: readonly unknown[];\n}\n\n/** Minimal filter shape accepted by the invalidation helpers, matching TanStack Query's `QueryFilters`. */\nexport interface QueryFilterLike {\n /** Match queries whose key starts with this prefix. */\n queryKey?: readonly unknown[];\n /** Match queries for which this returns `true`. */\n predicate?: (query: QueryLike) => boolean;\n}\n\n/** Minimal `QueryClient` surface used by the invalidation helpers. */\nexport interface QueryClientLike {\n /** Mark matching queries stale so they refetch. */\n invalidateQueries(filters: QueryFilterLike): void | Promise<void>;\n /** Remove matching queries from the cache entirely. */\n removeQueries(filters: QueryFilterLike): void;\n}\n\nfunction invalidateUnderlyingAllowanceQueries(\n queryClient: QueryClientLike,\n tokenAddress: Address,\n): void {\n void queryClient.invalidateQueries({\n queryKey: zamaQueryKeys.underlyingAllowance.token(tokenAddress),\n });\n}\n\nfunction invalidatePendingUnshieldQueries(\n queryClient: QueryClientLike,\n tokenAddress: Address,\n): void {\n void queryClient.invalidateQueries({\n queryKey: zamaQueryKeys.pendingUnshield.token(tokenAddress),\n });\n}\n\n/** Invalidates the caches affected by an unwrap: confidential balances, underlying allowance, and pending unshields. */\nexport function invalidateAfterUnwrap(queryClient: QueryClientLike, tokenAddress: Address): void {\n invalidateBalanceQueries(queryClient, tokenAddress);\n invalidateUnderlyingAllowanceQueries(queryClient, tokenAddress);\n invalidatePendingUnshieldQueries(queryClient, tokenAddress);\n invalidateWagmiBalanceQueries(queryClient);\n}\n\n/** Invalidates the caches affected by a wrap: confidential balances and underlying allowance. */\nexport function invalidateAfterWrap(queryClient: QueryClientLike, tokenAddress: Address): void {\n invalidateBalanceQueries(queryClient, tokenAddress);\n invalidateUnderlyingAllowanceQueries(queryClient, tokenAddress);\n invalidateWagmiBalanceQueries(queryClient);\n}\n\n/** Invalidates the confidential balance queries for a token (single-token and batched). */\nexport function invalidateBalanceQueries(\n queryClient: QueryClientLike,\n tokenAddress: Address,\n): void {\n void queryClient.invalidateQueries({\n queryKey: zamaQueryKeys.confidentialBalance.token(tokenAddress),\n });\n void queryClient.invalidateQueries({ queryKey: zamaQueryKeys.confidentialBalances.all });\n}\n\n/** Invalidates the caches affected by a shield: confidential balances and underlying allowance. */\nexport function invalidateAfterShield(queryClient: QueryClientLike, tokenAddress: Address): void {\n invalidateBalanceQueries(queryClient, tokenAddress);\n invalidateUnderlyingAllowanceQueries(queryClient, tokenAddress);\n invalidateWagmiBalanceQueries(queryClient);\n}\n\n/** Invalidates the caches affected by an unshield request: confidential balances, underlying allowance, and pending unshields. */\nexport function invalidateAfterUnshield(queryClient: QueryClientLike, tokenAddress: Address): void {\n invalidateBalanceQueries(queryClient, tokenAddress);\n invalidateUnderlyingAllowanceQueries(queryClient, tokenAddress);\n invalidatePendingUnshieldQueries(queryClient, tokenAddress);\n invalidateWagmiBalanceQueries(queryClient);\n}\n\n/** Invalidates the pending-unshield cache once an unshield has settled on-chain. */\nexport function invalidateAfterUnshieldSettled(\n queryClient: QueryClientLike,\n tokenAddress: Address,\n): void {\n invalidatePendingUnshieldQueries(queryClient, tokenAddress);\n}\n\n/** Invalidates the confidential balance caches affected by a transfer. */\nexport function invalidateAfterTransfer(queryClient: QueryClientLike, tokenAddress: Address): void {\n invalidateBalanceQueries(queryClient, tokenAddress);\n}\n\n/** Invalidates the underlying-allowance cache after approving the underlying ERC-20. */\nexport function invalidateAfterApproveUnderlying(\n queryClient: QueryClientLike,\n tokenAddress: Address,\n): void {\n invalidateUnderlyingAllowanceQueries(queryClient, tokenAddress);\n}\n\n/** Invalidates the operator-status cache after changing a token operator. */\nexport function invalidateAfterSetOperator(\n queryClient: QueryClientLike,\n tokenAddress: Address,\n): void {\n void queryClient.invalidateQueries({\n queryKey: zamaQueryKeys.confidentialIsOperator.token(tokenAddress),\n });\n}\n\nfunction isZamaQuery(query: QueryLike): boolean {\n return Array.isArray(query.queryKey) && typeof query.queryKey[0] === \"string\"\n ? query.queryKey[0].startsWith(\"zama.\")\n : false;\n}\n\nconst balanceFunctionName = z.enum([\"balanceOf\", \"confidentialBalanceOf\"]);\n\nconst balanceReadArgs = z.object({ functionName: balanceFunctionName });\n\nconst batchedReadArgs = z.object({ contracts: z.array(z.unknown()) });\n\nfunction isBalanceReadPart(part: unknown): boolean {\n if (balanceReadArgs.safeParse(part).success) {\n return true;\n }\n const batched = batchedReadArgs.safeParse(part);\n return (\n batched.success && batched.data.contracts.some((c) => balanceReadArgs.safeParse(c).success)\n );\n}\n\nfunction isWagmiBalanceQuery(query: QueryLike): boolean {\n return Array.isArray(query.queryKey) && query.queryKey.some(isBalanceReadPart);\n}\n\n/** Invalidates any wagmi `useBalance`/`readContract` balance queries so ERC-20 balances refresh. */\nexport function invalidateWagmiBalanceQueries(queryClient: QueryClientLike): void {\n void queryClient.invalidateQueries({ predicate: isWagmiBalanceQuery });\n}\n\n/** Clears wallet-local caches (decryption, permits) and invalidates all Zama queries — call on wallet connect/disconnect so a stale entitlement can't leak across accounts. */\nexport function invalidateWalletLifecycleQueries(queryClient: QueryClientLike): void {\n // Remove (not just invalidate) wallet-local caches so a stale allowed/true\n // cannot surface between wallet disconnect and the next refetch.\n queryClient.removeQueries({ queryKey: zamaQueryKeys.decryption.all });\n queryClient.removeQueries({ queryKey: zamaQueryKeys.hasPermit.all });\n void queryClient.invalidateQueries({ predicate: isZamaQuery });\n invalidateWagmiBalanceQueries(queryClient);\n}\n"],"mappings":"A,4CAEA,SAASI,EAAc,EAA6B,CAClD,GAAI,CAACC,EAAmBC,CAAK,EAC3B,MAAO,GAIT,IAAMC,EAAOD,EAAM,YACnB,GAAIC,IAAS,IAAA,GACX,MAAO,GAIT,IAAMC,EAAOD,EAAK,UAYlB,MALA,EANI,CAACF,EAAmBG,CAAI,GAMxB,CAACA,EAAK,eAAe,eAAe,EAM1C,CAGA,SAASH,EAAmB,EAAiB,CAC3C,OAAO,OAAO,UAAU,SAAS,KAAKI,CAAC,IAAM,iBAC/C,CA4CA,SAAgBC,EACd,EACyC,CACzC,GAAM,CACJ,OAAQC,EACR,UAAWC,EACX,QAASC,EACT,OAAQC,EACR,gBAAiBC,EACjB,eAAgBC,EAChB,qBAAsBC,EACtB,mBAAoBC,EACpB,MAAOC,EACP,WAAYC,EACZ,aAAcC,EACd,QAASC,EACT,SAAUC,EACV,eAAgBC,EAChB,YAAaC,EACb,qBAAsBC,EACtB,gBAAiBC,EACjB,kBAAmBC,EACnB,aAAcC,EACd,KAAMC,EACN,MAAOC,EACP,gBAAiBC,EACjB,GAAGC,GACDC,EAEJ,OAAOD,CACT,CAWA,SAAgBE,EAAO,EAAsC,CAC3D,OAAO,KAAK,UAAUC,GAAW,EAAG,IAC9BhC,EAAcE,CAAK,EACd,OAAO,KAAKA,CAAK,CAAC,CACtB,KAAK,CAAC,CACN,QACE,EAAQ,KACP,EAAO+B,GAAO/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iB,kBAAkB,CAAE,UAAWqB,CAAoB,CAAC,CACvE,CAGA,SAAgBC,EAAiC,EAAoC,CAGnFtB,EAAY,cAAc,CAAE,SAAUzB,EAAc,WAAW,GAAI,CAAC,EACpEyB,EAAY,cAAc,CAAE,SAAUzB,EAAc,UAAU,GAAI,CAAC,EACnEyB,EAAiB,kBAAkB,CAAE,UAAWY,CAAY,CAAC,EAC7DR,EAA8BJ,CAAW,CAC3C,C"}
@@ -1,2 +0,0 @@
1
- let e=require("viem"),t=require("zod/mini");function n(t){return(0,e.getAddress)(t)}const r=t.z.custom(t=>typeof t==`string`&&(0,e.isHex)(t,{strict:!0}),`expected 0x-prefixed hex string`),i=t.z.custom(t=>typeof t==`string`&&(0,e.isAddress)(t,{strict:!1}),`expected EVM address`),a=t.z.pipe(i,t.z.transform(n)),o=t.z.int().check(t.z.nonnegative()),s=t.z.int().check(t.z.positive()),c=t.z.int().check(t.z.nonnegative()),l=t.z.int().check(t.z.positive());t.z.int().check(t.z.positive()),Object.defineProperty(exports,"a",{enumerable:!0,get:function(){return l}}),Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return c}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return a}}),Object.defineProperty(exports,"o",{enumerable:!0,get:function(){return s}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return r}}),Object.defineProperty(exports,"s",{enumerable:!0,get:function(){return o}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return n}});
2
- //# sourceMappingURL=primitives.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"primitives.cjs","names":["getAddress","z","isHex","isAddress","viem","zod_mini","checksum","value","hex","v","evmAddress","checksummedAddress","unixSeconds","positiveSeconds","nonNegativeSeconds","positiveDays"],"sources":["../../src/schemas/primitives.ts"],"sourcesContent":["import { type Address, getAddress, isAddress, isHex, type Hex } from \"viem\";\nimport { z } from \"zod/mini\";\n\ndeclare const checksummedTag: unique symbol;\n\n/** An EVM address that has been put through `getAddress` (EIP-55 checksum form). */\nexport type ChecksummedAddress = Address & { readonly [checksummedTag]: true };\n\n/** Stamp the brand on an arbitrary `Address` after normalizing it. */\nexport function checksum(value: Address): ChecksummedAddress {\n return getAddress(value) as ChecksummedAddress;\n}\n\n/** `0x`-prefixed hex string. */\nexport const hex = z.custom<Hex>(\n (v) => typeof v === \"string\" && isHex(v, { strict: true }),\n \"expected 0x-prefixed hex string\",\n);\n\n/** Validates an EVM address string. Output type is `Address` (`` `0x${string}` ``). */\nexport const evmAddress = z.custom<Address>(\n (v) => typeof v === \"string\" && isAddress(v, { strict: false }),\n \"expected EVM address\",\n);\n\n/** Validates and EIP-55 checksums an EVM address. Output is {@link ChecksummedAddress}. */\nexport const checksummedAddress = z.pipe(evmAddress, z.transform(checksum));\n\n/** Non-negative integer Unix timestamp in seconds. */\nexport const unixSeconds = z.int().check(z.nonnegative());\n\n/** Positive integer count of seconds (e.g. a TTL). */\nexport const positiveSeconds = z.int().check(z.positive());\n\n/** Non-negative integer count of seconds (e.g. a cache TTL where 0 disables caching). */\nexport const nonNegativeSeconds = z.int().check(z.nonnegative());\n\n/** Positive integer count of days (e.g. a permit duration). */\nexport const positiveDays = z.int().check(z.positive());\n\n/** Positive integer EVM chain ID. */\nexport const chainId = z.int().check(z.positive());\n"],"mappings":"A,4CASA,SAAgBM,EAAS,EAAoC,CAC3D,OAAA,EAAON,EAAAA,WAAAA,CAAWO,CAAK,CACzB,CAGA,MAAaC,EAAMP,EAAAA,EAAE,OAClB,GAAM,OAAOQ,GAAM,WAAA,EAAYP,EAAAA,MAAAA,CAAMO,EAAG,CAAE,OAAQ,EAAK,CAAC,EACzD,iCACF,EAGaC,EAAaT,EAAAA,EAAE,OACzB,GAAM,OAAOQ,GAAM,WAAA,EAAYN,EAAAA,UAAAA,CAAUM,EAAG,CAAE,OAAQ,EAAM,CAAC,EAC9D,sBACF,EAGaE,EAAqBV,EAAAA,EAAE,KAAKS,EAAYT,EAAAA,EAAE,UAAUK,CAAQ,CAAC,EAG7DM,EAAcX,EAAAA,EAAE,IAAI,CAAC,CAAC,MAAMA,EAAAA,EAAE,YAAY,CAAC,EAG3CY,EAAkBZ,EAAAA,EAAE,IAAI,CAAC,CAAC,MAAMA,EAAAA,EAAE,SAAS,CAAC,EAG5Ca,EAAqBb,EAAAA,EAAE,IAAI,CAAC,CAAC,MAAMA,EAAAA,EAAE,YAAY,CAAC,EAGlDc,EAAed,EAAAA,EAAE,IAAI,CAAC,CAAC,MAAMA,EAAAA,EAAE,SAAS,CAAC,EAG/BA,EAAAA,EAAE,IAAI,CAAC,CAAC,MAAMA,EAAAA,EAAE,SAAS,CAAC,E"}
@@ -1,2 +0,0 @@
1
- const e=require("./relayer.cjs"),t=require("./encryption.cjs"),n=require("./alignment.cjs"),r=require("./token.cjs"),i=require("./primitives.cjs");let a=require("viem"),o=require("zod/mini");function s(e){if(!(e instanceof Error))return null;let t=e.cause;if(typeof t!=`object`||!t||!(`data`in t))return null;let{data:n}=t;return typeof n!=`object`||!n||!(`errorName`in n)?null:typeof n.errorName==`string`?n.errorName:null}var c=class extends e.r{unwrapTxHash;unwrapRequestId;constructor(t,n,r){super(e.i.UnshieldAlreadyFinalized,t,r),this.name=`UnshieldAlreadyFinalizedError`,this.unwrapTxHash=n.unwrapTxHash,this.unwrapRequestId=n.unwrapRequestId}};const l=`InvalidUnwrapRequest`,u=(0,a.keccak256)((0,a.toBytes)(`${l}(bytes32)`)).slice(0,10);function d(e){for(let t=e;t instanceof Error;t=t.cause)if(s(t)===l||t.message.includes(l)||t.message.includes(u))return!0;return!1}var f=class extends e.r{token;registry;constructor(t,n,r){super(e.i.UnlistedConfidentialToken,t,r),this.name=`UnlistedConfidentialTokenError`,this.token=n.token,this.registry=n.registry}},p=class extends e.r{batcher;vaultId;constructor(t,n,r){super(e.i.VaultBatcherPaused,t,r),this.name=`VaultBatcherPausedError`,this.batcher=n.batcher,this.vaultId=n.vaultId}},m=class extends e.r{batcher;batchId;state;constructor(t,n,r){super(e.i.VaultBatchNotDispatched,t,r),this.name=`VaultBatchNotDispatchedError`,this.batcher=n.batcher,this.batchId=n.batchId,this.state=n.state}},h=class extends e.r{txHash;receipt;joins;unconfirmed;constructor(t,n,r){super(e.i.VaultGroupJoinUnconfirmed,t,r),this.name=`VaultGroupJoinUnconfirmedError`,this.txHash=n.txHash,this.receipt=n.receipt,this.joins=n.joins,this.unconfirmed=n.unconfirmed}};const g=[{type:`function`,name:`allowance`,inputs:[{name:`owner`,type:`address`,internalType:`address`},{name:`spender`,type:`address`,internalType:`address`}],outputs:[{name:``,type:`uint256`,internalType:`uint256`}],stateMutability:`view`},{type:`function`,name:`approve`,inputs:[{name:`spender`,type:`address`,internalType:`address`},{name:`value`,type:`uint256`,internalType:`uint256`}],outputs:[{name:``,type:`bool`,internalType:`bool`}],stateMutability:`nonpayable`},{type:`function`,name:`approveAndCall`,inputs:[{name:`spender`,type:`address`,internalType:`address`},{name:`value`,type:`uint256`,internalType:`uint256`}],outputs:[{name:``,type:`bool`,internalType:`bool`}],stateMutability:`nonpayable`},{type:`function`,name:`approveAndCall`,inputs:[{name:`spender`,type:`address`,internalType:`address`},{name:`value`,type:`uint256`,internalType:`uint256`},{name:`data`,type:`bytes`,internalType:`bytes`}],outputs:[{name:``,type:`bool`,internalType:`bool`}],stateMutability:`nonpayable`},{type:`function`,name:`balanceOf`,inputs:[{name:`account`,type:`address`,internalType:`address`}],outputs:[{name:``,type:`uint256`,internalType:`uint256`}],stateMutability:`view`},{type:`function`,name:`supportsInterface`,inputs:[{name:`interfaceId`,type:`bytes4`,internalType:`bytes4`}],outputs:[{name:``,type:`bool`,internalType:`bool`}],stateMutability:`view`},{type:`function`,name:`totalSupply`,inputs:[],outputs:[{name:``,type:`uint256`,internalType:`uint256`}],stateMutability:`view`},{type:`function`,name:`transfer`,inputs:[{name:`to`,type:`address`,internalType:`address`},{name:`value`,type:`uint256`,internalType:`uint256`}],outputs:[{name:``,type:`bool`,internalType:`bool`}],stateMutability:`nonpayable`},{type:`function`,name:`transferAndCall`,inputs:[{name:`to`,type:`address`,internalType:`address`},{name:`value`,type:`uint256`,internalType:`uint256`}],outputs:[{name:``,type:`bool`,internalType:`bool`}],stateMutability:`nonpayable`},{type:`function`,name:`transferAndCall`,inputs:[{name:`to`,type:`address`,internalType:`address`},{name:`value`,type:`uint256`,internalType:`uint256`},{name:`data`,type:`bytes`,internalType:`bytes`}],outputs:[{name:``,type:`bool`,internalType:`bool`}],stateMutability:`nonpayable`},{type:`function`,name:`transferFrom`,inputs:[{name:`from`,type:`address`,internalType:`address`},{name:`to`,type:`address`,internalType:`address`},{name:`value`,type:`uint256`,internalType:`uint256`}],outputs:[{name:``,type:`bool`,internalType:`bool`}],stateMutability:`nonpayable`},{type:`function`,name:`transferFromAndCall`,inputs:[{name:`from`,type:`address`,internalType:`address`},{name:`to`,type:`address`,internalType:`address`},{name:`value`,type:`uint256`,internalType:`uint256`},{name:`data`,type:`bytes`,internalType:`bytes`}],outputs:[{name:``,type:`bool`,internalType:`bool`}],stateMutability:`nonpayable`},{type:`function`,name:`transferFromAndCall`,inputs:[{name:`from`,type:`address`,internalType:`address`},{name:`to`,type:`address`,internalType:`address`},{name:`value`,type:`uint256`,internalType:`uint256`}],outputs:[{name:``,type:`bool`,internalType:`bool`}],stateMutability:`nonpayable`},{type:`event`,name:`Approval`,inputs:[{name:`owner`,type:`address`,indexed:!0,internalType:`address`},{name:`spender`,type:`address`,indexed:!0,internalType:`address`},{name:`value`,type:`uint256`,indexed:!1,internalType:`uint256`}],anonymous:!1},{type:`event`,name:`Transfer`,inputs:[{name:`from`,type:`address`,indexed:!0,internalType:`address`},{name:`to`,type:`address`,indexed:!0,internalType:`address`},{name:`value`,type:`uint256`,indexed:!1,internalType:`uint256`}],anonymous:!1}];function _(e,t,n,r=`0x`){return{address:e,abi:g,functionName:`transferAndCall`,args:[t,n,r]}}function v(e){return e.startsWith(`0x`)?e:`0x${e}`}function y(e){return(0,a.keccak256)((0,a.toBytes)(e))}function b(e){return(0,a.getAddress)(v(e.slice(-40)))}function x(e){return e}function S(e,t){let n=2+t*64,r=e.slice(n,n+64);return r.length===64?r:r.padEnd(64,`0`)}function C(e,t){return(0,a.getAddress)(v(S(e,t).slice(-40)))}function w(e,t){return BigInt(`0x`+S(e,t))}function T(e,t){return v(S(e,t))}const E={ConfidentialTransfer:y(`ConfidentialTransfer(address,address,bytes32)`),Wrap:y(`Wrap(address,uint256,bytes32)`),UnwrapRequested:y(`UnwrapRequested(address,bytes32,bytes32)`),UnwrapFinalized:y(`UnwrapFinalized(address,bytes32,bytes32,uint64)`)};function D(e){return e.topics[0]!==E.ConfidentialTransfer||e.topics.length<4?null:{eventName:`ConfidentialTransfer`,from:b(e.topics[1]),to:b(e.topics[2]),encryptedAmount:x(e.topics[3])}}function O(e){return e.topics[0]!==E.Wrap||e.topics.length<2?null:{eventName:`Wrap`,to:b(e.topics[1]),roundedAmount:w(e.data,0),encryptedWrappedAmount:T(e.data,1)}}function k(e){return e.topics[0]!==E.UnwrapRequested||e.topics.length<3?null:{eventName:`UnwrapRequested`,receiver:b(e.topics[1]),unwrapRequestId:x(e.topics[2]),encryptedAmount:T(e.data,0)}}function A(e){return e.topics[0]!==E.UnwrapFinalized||e.topics.length<3?null:{eventName:`UnwrapFinalized`,receiver:b(e.topics[1]),unwrapRequestId:x(e.topics[2]),encryptedAmount:T(e.data,0),cleartextAmount:w(e.data,1)}}function j(e){return D(e)??O(e)??k(e)??A(e)}function M(e){let t=[];for(let n of e){let e=j(n);e&&t.push(e)}return t}function N(e){for(let t of e){let e=k(t);if(e)return e}return null}function P(e){for(let t of e){let e=O(t);if(e)return e}return null}const F=[E.ConfidentialTransfer,E.Wrap,E.UnwrapRequested,E.UnwrapFinalized],I={DelegatedForUserDecryption:y(`DelegatedForUserDecryption(address,address,address,uint64,uint64,uint64)`),RevokedDelegationForUserDecryption:y(`RevokedDelegationForUserDecryption(address,address,address,uint64,uint64)`)};function L(e){return e.topics[0]!==I.DelegatedForUserDecryption||e.topics.length<3?null:{eventName:`DelegatedForUserDecryption`,delegator:b(e.topics[1]),delegate:b(e.topics[2]),contractAddress:C(e.data,0),delegationCounter:w(e.data,1),oldExpirationDate:w(e.data,2),newExpirationDate:w(e.data,3)}}function R(e){return e.topics[0]!==I.RevokedDelegationForUserDecryption||e.topics.length<3?null:{eventName:`RevokedDelegationForUserDecryption`,delegator:b(e.topics[1]),delegate:b(e.topics[2]),contractAddress:C(e.data,0),delegationCounter:w(e.data,1),oldExpirationDate:w(e.data,2)}}function z(e){return L(e)??R(e)}function B(e){let t=[];for(let n of e){let e=z(n);e&&t.push(e)}return t}function V(e){for(let t of e){let e=L(t);if(e)return e}return null}function H(e){for(let t of e){let e=R(t);if(e)return e}return null}const U=[I.DelegatedForUserDecryption,I.RevokedDelegationForUserDecryption];function W(e){return`zama:pending-unshield:${i.t(e)}`}const G=o.z.union([o.z.pipe(i.r,o.z.transform(e=>({unwrapTxHash:e}))),o.z.pipe(o.z.object({version:o.z.literal(1),unwrapTxHash:i.r,unwrapRequestId:o.z.optional(i.r)}),o.z.transform(({unwrapTxHash:e,unwrapRequestId:t})=>({unwrapTxHash:e,unwrapRequestId:t})))]);async function K(e,t,n,r){r===void 0?await e.set(W(t),n):await e.set(W(t),{version:1,unwrapTxHash:n,unwrapRequestId:r})}async function q(e,t){let n=W(t),r=await e.get(n);if(r==null)return null;let i=G.safeParse(r);return i.success?i.data:(await e.delete(n),null)}async function J(e,t){await e.delete(W(t))}var Y=class extends r.t{#e;#t=null;#n=null;#r(e){try{return n.K(this.sdk.signer,`WrappedToken.sdk.signer`),this.sdk.signer}catch(t){throw new n.Y(e,{cause:t})}}async underlying(){return this.#f()}async isPayable(){if(this.#n!==null)return this.#n;try{let e=await this.#f();this.#n=await this.sdk.provider.readContract(n._(e))}catch{this.#n=!1}return this.#n}async allowance(e){let t=await this.#f();return this.sdk.provider.readContract(n.y(t,(0,a.getAddress)(e),this.address))}async shield(t,i){let o=await n.t(`shield`,this.sdk.signer,this.sdk.provider),s=await this.isPayable(),c=await this.#f(),l=(0,a.getAddress)(o.address),u;try{u=await this.sdk.provider.readContract(n.x(c,l))}catch(t){throw t instanceof e.r?t:new r.u(`Could not read ERC-20 balance for shield validation (token: ${c})`,{cause:e.C(t)})}if(u<t)throw new r.p(`Insufficient ERC-20 balance: requested ${t}, available ${u} (token: ${c})`,{requested:t,available:u,token:c});return s?this.#i(t,c,l,i):this.#a(t,l,i)}async#i(e,t,n,r){this.#r(`shield`);let i=r?.to?(0,a.getAddress)(r.to):n,o=i===n?`0x`:i;return this.submitTransaction({operation:`shield:transferAndCall`,config:_(t,this.address,e,o),onSubmitted:r?.onShieldSubmitted})}async wrap(t,i){this.#r(`wrap`);let o=await n.t(`wrap`,this.sdk.signer,this.sdk.provider),s=await this.#f(),c=(0,a.getAddress)(o.address),l;try{l=await this.sdk.provider.readContract(n.x(s,c))}catch(t){throw t instanceof e.r?t:new r.u(`Could not read ERC-20 balance for wrap validation (token: ${s})`,{cause:e.C(t)})}if(l<t)throw new r.p(`Insufficient ERC-20 balance: requested ${t}, available ${l} (token: ${s})`,{requested:t,available:l,token:s});let u;try{u=await this.sdk.provider.readContract(n.y(s,c,this.address))}catch(t){throw t instanceof e.r?t:new r.u(`Could not read ERC-20 allowance for wrap validation (token: ${s})`,{cause:e.C(t)})}if(u<t)throw new r.d(`Insufficient allowance for wrap: requested ${t}, approved ${u}. Call approveUnderlying() first (token: ${s}).`,{requested:t,available:u,token:s});let d=i?.to?(0,a.getAddress)(i.to):c;return this.submitTransaction({operation:`wrap`,config:n.H(this.address,d,t),onSubmitted:i?.onWrapSubmitted})}async#a(e,t,r){this.#r(`shield`);let i=r?.approvalStrategy??`exact`;i!==`skip`&&await this.#m(e,i===`max`,r);let o=r?.to?(0,a.getAddress)(r.to):t;return this.submitTransaction({operation:`shield:approveAndWrap`,config:n.H(this.address,o,e),onSubmitted:r?.onShieldSubmitted})}async approveUnderlying(e){this.#r(`approveUnderlying`);let t=await n.t(`approveUnderlying`,this.sdk.signer,this.sdk.provider),r=await this.#f(),i=(0,a.getAddress)(t.address),o=e??2n**256n-1n;return o>0n&&await this.sdk.provider.readContract(n.y(r,i,this.address))>0n&&await this.submitTransaction({operation:`approveUnderlying:reset`,config:n.b(r,this.address,0n)}),this.submitTransaction({operation:`approveUnderlying`,config:n.b(r,this.address,o)})}async unshield(e,t){let{skipBalanceCheck:r=!1,onUnwrapSubmitted:i,onFinalizing:a,onFinalizeSubmitted:o}=t??{};r||await this.assertConfidentialBalance(e,`unshield`);let s={onFinalizing:a,onFinalizeSubmitted:o},c=crypto.randomUUID(),l=await this.#o(e,`unshield`);return n.U(`unshield: onUnwrapSubmitted`,()=>i?.(l.txHash),this.sdk.logger),this.#p(l.unwrapRequestId,l.txHash,c,s,`unshield`)}async unshieldAll(e){let t=crypto.randomUUID(),r=await this.unwrapAll();return n.U(`unshieldAll: onUnwrapSubmitted`,()=>e?.onUnwrapSubmitted?.(r.txHash),this.sdk.logger),this.#p(r.unwrapRequestId,r.txHash,t,e,`unshield-all`)}async resumeUnshield(t,r){let i;try{i=await this.sdk.provider.waitForTransactionReceipt(t)}catch(t){throw t instanceof e.r?t:new n.rt(`Failed to get unwrap receipt`,{cause:t})}if(i.status===`reverted`)throw new n.rt(`Unwrap transaction ${t} reverted, so there is nothing to resume`);let a=this.#c(i.logs);if(await this.#l(a))throw await this.#d(`resumeUnshield`),new c(`Nothing to resume: the unwrap request was already finalized on-chain and the funds were delivered.`,{unwrapTxHash:t,unwrapRequestId:a});return this.#p(a,t,crypto.randomUUID(),r,`resume-unshield`)}async getPendingUnshield(){let e=await q(this.sdk.storage,this.address);return e?await this.#u(e)?(await this.#d(`getPendingUnshield`),null):e.unwrapTxHash:null}async unwrap(e){return this.#o(e,`unwrap`)}async#o(e,r){this.#r(`unwrap`);let i=await n.t(`unwrap`,this.sdk.signer,this.sdk.provider),o=(0,a.getAddress)(i.address),{encryptedValues:s,inputProof:c}=await this.sdk.encrypt({values:[{value:e,type:`euint64`}],contractAddress:this.address,userAddress:o},{operation:r}),[l]=s;if(!l)throw new t.r(`Encryption returned no encrypted values`);let u=await this.submitTransaction({operation:`unwrap`,config:n.z(this.address,o,o,l,c)});return{...u,unwrapRequestId:this.#c(u.receipt.logs)}}async unwrapAll(){this.#r(`unwrapAll`);let e=await n.t(`unwrapAll`,this.sdk.signer,this.sdk.provider),i=(0,a.getAddress)(e.address),o=await this.readConfidentialBalanceOf(i);if(r.c(o))throw new t.t(`Cannot unshield: balance is zero`);let s=await this.submitTransaction({operation:`unwrapAll`,config:n.B(this.address,i,i,o)});return{...s,unwrapRequestId:this.#c(s.receipt.logs)}}async finalizeUnwrap(e){return this.#s(e,`finalize-unwrap`)}async#s(e,t){this.#r(`finalizeUnwrap`),await n.n(`finalizeUnwrap`,this.sdk.signer,this.sdk.provider);let r=await this.sdk.decryption.decryptPublicValues([e],{operation:t}),i=r.clearValues[e];return n.W(i,`finalizeUnwrap: clearValue`),this.submitTransaction({operation:`finalizeUnwrap`,config:n.M(this.address,e,i,r.decryptionProof)})}#c(e){let t=N(e.filter(e=>e.address===void 0||(0,a.getAddress)(e.address)===this.address));if(!t)throw new n.rt(`No UnwrapRequested event from this wrapper found in the unwrap receipt`);return t.unwrapRequestId}async#l(e){try{return await this.sdk.provider.readContract(n.V(this.address,e))===a.zeroAddress}catch{return!1}}async#u(e){let t=e.unwrapRequestId;if(t===void 0)try{let n=await this.sdk.provider.waitForTransactionReceipt(e.unwrapTxHash);t=this.#c(n.logs)}catch{return!1}return this.#l(t)}async#d(e){await n.U(`${e}: clearPendingUnshield`,()=>J(this.sdk.storage,this.address),this.sdk.logger)}async#f(){return this.#e===void 0?(this.#t||=this.sdk.provider.readContract(n.L(this.address)).then(e=>(this.#e=e,this.#t=null,e)).catch(e=>{throw this.#t=null,e}),this.#t):this.#e}async#p(e,t,r,i,a){this.emit({type:n.q.UnshieldPhase1Submitted,txHash:t,operationId:r}),await n.U(`unshield: savePendingUnshield`,()=>K(this.sdk.storage,this.address,t,e),this.sdk.logger),this.emit({type:n.q.UnshieldPhase2Started,operationId:r}),n.U(`unshield: onFinalizing`,()=>i?.onFinalizing?.(),this.sdk.logger);let o;try{o=await this.#s(e,a)}catch(r){throw d(r)||r instanceof n.rt&&await this.#l(e)?(await this.#d(`unshield`),new c(`The unwrap request was finalized concurrently — the funds were already delivered.`,{unwrapTxHash:t,unwrapRequestId:e},{cause:r})):r}return this.emit({type:n.q.UnshieldPhase2Submitted,txHash:o.txHash,operationId:r}),n.U(`unshield: onFinalizeSubmitted`,()=>i?.onFinalizeSubmitted?.(o.txHash),this.sdk.logger),await this.#d(`unshield`),o}async#m(e,t,r){this.#r(`approveUnderlying`);let i=await this.#f(),o=await n.t(`approveUnderlying`,this.sdk.signer,this.sdk.provider),s=(0,a.getAddress)(o.address),c=await this.sdk.provider.readContract(n.y(i,s,this.address));if(c>=e)return;c>0n&&await this.submitTransaction({operation:`approveUnderlying:reset`,config:n.b(i,this.address,0n)});let l=t?2n**256n-1n:e;await this.submitTransaction({operation:`approveUnderlying`,config:n.b(i,this.address,l),onSubmitted:r?.onApprovalSubmitted})}};Object.defineProperty(exports,"C",{enumerable:!0,get:function(){return _}}),Object.defineProperty(exports,"D",{enumerable:!0,get:function(){return h}}),Object.defineProperty(exports,"E",{enumerable:!0,get:function(){return p}}),Object.defineProperty(exports,"O",{enumerable:!0,get:function(){return c}}),Object.defineProperty(exports,"S",{enumerable:!0,get:function(){return T}}),Object.defineProperty(exports,"T",{enumerable:!0,get:function(){return m}}),Object.defineProperty(exports,"_",{enumerable:!0,get:function(){return H}}),Object.defineProperty(exports,"a",{enumerable:!0,get:function(){return E}}),Object.defineProperty(exports,"b",{enumerable:!0,get:function(){return y}}),Object.defineProperty(exports,"c",{enumerable:!0,get:function(){return D}}),Object.defineProperty(exports,"d",{enumerable:!0,get:function(){return M}}),Object.defineProperty(exports,"f",{enumerable:!0,get:function(){return R}}),Object.defineProperty(exports,"g",{enumerable:!0,get:function(){return V}}),Object.defineProperty(exports,"h",{enumerable:!0,get:function(){return O}}),Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return F}}),Object.defineProperty(exports,"k",{enumerable:!0,get:function(){return s}}),Object.defineProperty(exports,"l",{enumerable:!0,get:function(){return L}}),Object.defineProperty(exports,"m",{enumerable:!0,get:function(){return k}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return U}}),Object.defineProperty(exports,"o",{enumerable:!0,get:function(){return z}}),Object.defineProperty(exports,"p",{enumerable:!0,get:function(){return A}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return I}}),Object.defineProperty(exports,"s",{enumerable:!0,get:function(){return B}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(exports,"u",{enumerable:!0,get:function(){return j}}),Object.defineProperty(exports,"v",{enumerable:!0,get:function(){return N}}),Object.defineProperty(exports,"w",{enumerable:!0,get:function(){return f}}),Object.defineProperty(exports,"x",{enumerable:!0,get:function(){return b}}),Object.defineProperty(exports,"y",{enumerable:!0,get:function(){return P}});
2
- //# sourceMappingURL=wrapped-token.cjs.map