@zama-fhe/sdk 3.7.0-alpha.2 → 3.7.0-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (102) hide show
  1. package/dist/cjs/base-signer.cjs +1 -1
  2. package/dist/cjs/base-signer.cjs.map +1 -1
  3. package/dist/cjs/chains.cjs +1 -1
  4. package/dist/cjs/chains.cjs.map +1 -1
  5. package/dist/cjs/erc165.cjs +2 -0
  6. package/dist/cjs/erc165.cjs.map +1 -0
  7. package/dist/cjs/ethers/index.cjs +1 -1
  8. package/dist/cjs/ethers/index.cjs.map +1 -1
  9. package/dist/cjs/fhevm-relayer.cjs +2 -2
  10. package/dist/cjs/fhevm-relayer.cjs.map +1 -1
  11. package/dist/cjs/index.cjs +1 -1
  12. package/dist/cjs/index.cjs.map +1 -1
  13. package/dist/cjs/invalidation.cjs +2 -0
  14. package/dist/cjs/invalidation.cjs.map +1 -0
  15. package/dist/cjs/primitives.cjs +2 -0
  16. package/dist/cjs/primitives.cjs.map +1 -0
  17. package/dist/cjs/query/index.cjs +1 -1
  18. package/dist/cjs/query/index.cjs.map +1 -1
  19. package/dist/cjs/relayer.cjs +1 -1
  20. package/dist/cjs/relayer.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 +2 -0
  24. package/dist/cjs/vaults/index.cjs.map +1 -0
  25. package/dist/cjs/viem/index.cjs +1 -1
  26. package/dist/cjs/viem/index.cjs.map +1 -1
  27. package/dist/cjs/wrapped-token.cjs +2 -0
  28. package/dist/cjs/wrapped-token.cjs.map +1 -0
  29. package/dist/cjs/wrappers-registry.cjs +1 -1
  30. package/dist/cjs/wrappers-registry.cjs.map +1 -1
  31. package/dist/esm/base-signer-D5Cwv7yb.js +2 -0
  32. package/dist/esm/base-signer-D5Cwv7yb.js.map +1 -0
  33. package/dist/esm/{base-signer-S2Ogf6L4.d.ts → base-signer-DIYZwDnc.d.ts} +2 -2
  34. package/dist/esm/chains/index.d.ts +1 -1
  35. package/dist/esm/chains/index.js +1 -1
  36. package/dist/esm/chains-ByyCdrrd.js +2 -0
  37. package/dist/esm/chains-ByyCdrrd.js.map +1 -0
  38. package/dist/esm/cleartext/index.d.ts +2 -2
  39. package/dist/esm/cleartext/index.js +1 -1
  40. package/dist/esm/{cleartext-pv2blbFU.d.ts → cleartext-3HOk1BAg.d.ts} +2 -2
  41. package/dist/esm/{cleartext-DcbDCDXj.js → cleartext-PCpNqRGV.js} +2 -2
  42. package/dist/esm/{cleartext-DcbDCDXj.js.map → cleartext-PCpNqRGV.js.map} +1 -1
  43. package/dist/esm/encrypt.worker.js +51 -51
  44. package/dist/esm/{encryption-DJljZ2oV.js → encryption-BKoalB4o.js} +2 -2
  45. package/dist/esm/{encryption-DJljZ2oV.js.map → encryption-BKoalB4o.js.map} +1 -1
  46. package/dist/esm/erc165-DbMOt-s6.js +2 -0
  47. package/dist/esm/erc165-DbMOt-s6.js.map +1 -0
  48. package/dist/esm/ethers/index.d.ts +5 -5
  49. package/dist/esm/ethers/index.js +1 -1
  50. package/dist/esm/ethers/index.js.map +1 -1
  51. package/dist/esm/fhevm-relayer-CtrnKjJf.js +8 -0
  52. package/dist/esm/fhevm-relayer-CtrnKjJf.js.map +1 -0
  53. package/dist/esm/{index-tfvbrVa2.d.ts → index-BHrjck_q.d.ts} +4 -4
  54. package/dist/esm/{index-DRrrBtMX.d.ts → index-DJYq1rAB.d.ts} +989 -1874
  55. package/dist/esm/{index-Gk1S0gjO.d.ts → index-ijgDL4IC.d.ts} +1 -14
  56. package/dist/esm/index.d.ts +8 -108
  57. package/dist/esm/index.js +1 -1
  58. package/dist/esm/index.js.map +1 -1
  59. package/dist/esm/invalidation-BgFjmXeQ.js +2 -0
  60. package/dist/esm/invalidation-BgFjmXeQ.js.map +1 -0
  61. package/dist/esm/invalidation-CJ-pzOUG.d.ts +46 -0
  62. package/dist/esm/node/index.d.ts +4 -4
  63. package/dist/esm/node/index.js +1 -1
  64. package/dist/esm/primitives-Cym-3HKa.js +2 -0
  65. package/dist/esm/primitives-Cym-3HKa.js.map +1 -0
  66. package/dist/esm/query/index.d.ts +495 -4
  67. package/dist/esm/query/index.js +1 -1
  68. package/dist/esm/query/index.js.map +1 -1
  69. package/dist/esm/relayer-CVKO9GmQ.js +2 -0
  70. package/dist/esm/relayer-CVKO9GmQ.js.map +1 -0
  71. package/dist/esm/token-CRJ8eCr7.js +2 -0
  72. package/dist/esm/token-CRJ8eCr7.js.map +1 -0
  73. package/dist/esm/{types-BOyFfG7D.d.ts → types-Bz5-wHPv.d.ts} +23 -43
  74. package/dist/esm/{types-BRIpBy9n.d.ts → types-CI6BtpB7.d.ts} +3 -3
  75. package/dist/esm/{types-OXQqX_kH.d.ts → types-v0_sfkli.d.ts} +3 -3
  76. package/dist/esm/{validation-DWe2k89s.js → validation-BRu06AM_.js} +2 -2
  77. package/dist/esm/{validation-DWe2k89s.js.map → validation-BRu06AM_.js.map} +1 -1
  78. package/dist/esm/vaults/index.d.ts +13833 -0
  79. package/dist/esm/vaults/index.js +2 -0
  80. package/dist/esm/vaults/index.js.map +1 -0
  81. package/dist/esm/viem/index.d.ts +5 -5
  82. package/dist/esm/viem/index.js +1 -1
  83. package/dist/esm/viem/index.js.map +1 -1
  84. package/dist/esm/web/index.d.ts +1 -1
  85. package/dist/esm/web/index.js +1 -1
  86. package/dist/esm/wrapped-token-BOtzaSAY.js +2 -0
  87. package/dist/esm/wrapped-token-BOtzaSAY.js.map +1 -0
  88. package/dist/esm/wrappers-registry-Cm3JJeqx.js +2 -0
  89. package/dist/esm/wrappers-registry-Cm3JJeqx.js.map +1 -0
  90. package/package.json +19 -5
  91. package/dist/esm/base-signer--sBO2qJp.js +0 -2
  92. package/dist/esm/base-signer--sBO2qJp.js.map +0 -1
  93. package/dist/esm/chains-DEpKup1n.js +0 -2
  94. package/dist/esm/chains-DEpKup1n.js.map +0 -1
  95. package/dist/esm/fhevm-relayer-CPmCytDX.js +0 -8
  96. package/dist/esm/fhevm-relayer-CPmCytDX.js.map +0 -1
  97. package/dist/esm/relayer-B6Zo6EkX.js +0 -2
  98. package/dist/esm/relayer-B6Zo6EkX.js.map +0 -1
  99. package/dist/esm/token-BMQ6xlrk.js +0 -2
  100. package/dist/esm/token-BMQ6xlrk.js.map +0 -1
  101. package/dist/esm/wrappers-registry-BfQr2QHn.js +0 -2
  102. package/dist/esm/wrappers-registry-BfQr2QHn.js.map +0 -1
@@ -1,10 +1,10 @@
1
- import { f as FheChain } from "./index-Gk1S0gjO.js";
2
- import { $t as TransactionResult, Ct as TransferCallbacks, D as GenericSigner, O as WalletAccount, S as TransactionKind, _ as PrepareTransactionRequest, an as EncryptParams, bt as UnwrapResult, c as GenericStorage, en as ClearValue, g as PrepareOptions, gt as ShieldOptions, i as ZamaConfig, l as GenericProvider, o as ZamaConfigGeneric, on as EncryptResult, pn as RelayerSDK, sn as EncryptedValue, tn as DecryptPublicValuesResult, un as FhevmRelayerOptions, v as PreparedFor, vt as TransferOptions, wt as UnshieldCallbacks, xt as WrapOptions, yt as UnshieldOptions } from "./types-BOyFfG7D.js";
3
- import "./cleartext-pv2blbFU.js";
4
- import "./types-OXQqX_kH.js";
5
- import "./types-BRIpBy9n.js";
6
- import "./index-tfvbrVa2.js";
7
- import { Address, Hex } from "viem";
1
+ import { f as FheChain } from "./index-ijgDL4IC.js";
2
+ import { D as GenericSigner, O as WalletAccount, S as TransactionKind, St as WrapOptions, Tt as UnshieldCallbacks, _ as PrepareTransactionRequest, _t as ShieldOptions, bt as UnshieldOptions, c as GenericStorage, cn as EncryptedValue, dn as FhevmRelayerOptions, en as TransactionResult, g as PrepareOptions, i as ZamaConfig, l as GenericProvider, mn as RelayerSDK, nn as DecryptPublicValuesResult, o as ZamaConfigGeneric, on as EncryptParams, sn as EncryptResult, tn as ClearValue, v as PreparedFor, wt as TransferCallbacks, xt as UnwrapResult, yt as TransferOptions } from "./types-Bz5-wHPv.js";
3
+ import "./cleartext-3HOk1BAg.js";
4
+ import "./types-v0_sfkli.js";
5
+ import "./base-signer-DIYZwDnc.js";
6
+ import "./types-CI6BtpB7.js";
7
+ import { Address, Address as Address$1, Hex, Hex as Hex$1 } from "viem";
8
8
  import { z } from "zod/mini";
9
9
  import { MutationFunctionContext, QueryKey, QueryObserverOptions, skipToken } from "@tanstack/query-core";
10
10
  //#region src/config/create.d.ts
@@ -17446,16 +17446,6 @@ declare function delegateForUserDecryptionContract(aclAddress: Address, delegate
17446
17446
  readonly internalType: "uint64";
17447
17447
  }];
17448
17448
  readonly stateMutability: "view";
17449
- }, {
17450
- readonly type: "function";
17451
- readonly name: "invalidateDecryptionSignaturesBefore";
17452
- readonly inputs: readonly [{
17453
- readonly name: "timestamp";
17454
- readonly type: "uint256";
17455
- readonly internalType: "uint256";
17456
- }];
17457
- readonly outputs: readonly [];
17458
- readonly stateMutability: "nonpayable";
17459
17449
  }, {
17460
17450
  readonly type: "function";
17461
17451
  readonly name: "isAccountDenied";
@@ -17674,16 +17664,6 @@ declare function revokeDelegationContract(aclAddress: Address, delegateAddress:
17674
17664
  readonly internalType: "uint64";
17675
17665
  }];
17676
17666
  readonly stateMutability: "view";
17677
- }, {
17678
- readonly type: "function";
17679
- readonly name: "invalidateDecryptionSignaturesBefore";
17680
- readonly inputs: readonly [{
17681
- readonly name: "timestamp";
17682
- readonly type: "uint256";
17683
- readonly internalType: "uint256";
17684
- }];
17685
- readonly outputs: readonly [];
17686
- readonly stateMutability: "nonpayable";
17687
17667
  }, {
17688
17668
  readonly type: "function";
17689
17669
  readonly name: "isAccountDenied";
@@ -17806,235 +17786,6 @@ declare function revokeDelegationContract(aclAddress: Address, delegateAddress:
17806
17786
  readonly functionName: "revokeDelegationForUserDecryption";
17807
17787
  readonly args: readonly [`0x${string}`, `0x${string}`];
17808
17788
  };
17809
- /**
17810
- * Returns the contract config to invalidate every decryption signature signed
17811
- * by `msg.sender` before `timestamp` (`0n` resolves to now on-chain).
17812
- *
17813
- * @example
17814
- * ```ts
17815
- * const txHash = await signer.writeContract(
17816
- * invalidateDecryptionSignaturesBeforeContract(aclAddress, 0n),
17817
- * );
17818
- * ```
17819
- */
17820
- declare function invalidateDecryptionSignaturesBeforeContract(aclAddress: Address, timestamp: bigint): {
17821
- readonly address: `0x${string}`;
17822
- readonly abi: readonly [{
17823
- readonly type: "function";
17824
- readonly name: "allow";
17825
- readonly inputs: readonly [{
17826
- readonly name: "handle";
17827
- readonly type: "bytes32";
17828
- readonly internalType: "bytes32";
17829
- }, {
17830
- readonly name: "account";
17831
- readonly type: "address";
17832
- readonly internalType: "address";
17833
- }];
17834
- readonly outputs: readonly [];
17835
- readonly stateMutability: "nonpayable";
17836
- }, {
17837
- readonly type: "function";
17838
- readonly name: "allowForDecryption";
17839
- readonly inputs: readonly [{
17840
- readonly name: "handlesList";
17841
- readonly type: "bytes32[]";
17842
- readonly internalType: "bytes32[]";
17843
- }];
17844
- readonly outputs: readonly [];
17845
- readonly stateMutability: "nonpayable";
17846
- }, {
17847
- readonly type: "function";
17848
- readonly name: "allowTransient";
17849
- readonly inputs: readonly [{
17850
- readonly name: "ciphertext";
17851
- readonly type: "bytes32";
17852
- readonly internalType: "bytes32";
17853
- }, {
17854
- readonly name: "account";
17855
- readonly type: "address";
17856
- readonly internalType: "address";
17857
- }];
17858
- readonly outputs: readonly [];
17859
- readonly stateMutability: "nonpayable";
17860
- }, {
17861
- readonly type: "function";
17862
- readonly name: "cleanTransientStorage";
17863
- readonly inputs: readonly [];
17864
- readonly outputs: readonly [];
17865
- readonly stateMutability: "nonpayable";
17866
- }, {
17867
- readonly type: "function";
17868
- readonly name: "delegateForUserDecryption";
17869
- readonly inputs: readonly [{
17870
- readonly name: "delegate";
17871
- readonly type: "address";
17872
- readonly internalType: "address";
17873
- }, {
17874
- readonly name: "contractAddress";
17875
- readonly type: "address";
17876
- readonly internalType: "address";
17877
- }, {
17878
- readonly name: "expirationDate";
17879
- readonly type: "uint64";
17880
- readonly internalType: "uint64";
17881
- }];
17882
- readonly outputs: readonly [];
17883
- readonly stateMutability: "nonpayable";
17884
- }, {
17885
- readonly type: "function";
17886
- readonly name: "getUserDecryptionDelegationExpirationDate";
17887
- readonly inputs: readonly [{
17888
- readonly name: "delegator";
17889
- readonly type: "address";
17890
- readonly internalType: "address";
17891
- }, {
17892
- readonly name: "delegate";
17893
- readonly type: "address";
17894
- readonly internalType: "address";
17895
- }, {
17896
- readonly name: "contractAddress";
17897
- readonly type: "address";
17898
- readonly internalType: "address";
17899
- }];
17900
- readonly outputs: readonly [{
17901
- readonly name: "";
17902
- readonly type: "uint64";
17903
- readonly internalType: "uint64";
17904
- }];
17905
- readonly stateMutability: "view";
17906
- }, {
17907
- readonly type: "function";
17908
- readonly name: "invalidateDecryptionSignaturesBefore";
17909
- readonly inputs: readonly [{
17910
- readonly name: "timestamp";
17911
- readonly type: "uint256";
17912
- readonly internalType: "uint256";
17913
- }];
17914
- readonly outputs: readonly [];
17915
- readonly stateMutability: "nonpayable";
17916
- }, {
17917
- readonly type: "function";
17918
- readonly name: "isAccountDenied";
17919
- readonly inputs: readonly [{
17920
- readonly name: "account";
17921
- readonly type: "address";
17922
- readonly internalType: "address";
17923
- }];
17924
- readonly outputs: readonly [{
17925
- readonly name: "";
17926
- readonly type: "bool";
17927
- readonly internalType: "bool";
17928
- }];
17929
- readonly stateMutability: "view";
17930
- }, {
17931
- readonly type: "function";
17932
- readonly name: "isAllowed";
17933
- readonly inputs: readonly [{
17934
- readonly name: "handle";
17935
- readonly type: "bytes32";
17936
- readonly internalType: "bytes32";
17937
- }, {
17938
- readonly name: "account";
17939
- readonly type: "address";
17940
- readonly internalType: "address";
17941
- }];
17942
- readonly outputs: readonly [{
17943
- readonly name: "";
17944
- readonly type: "bool";
17945
- readonly internalType: "bool";
17946
- }];
17947
- readonly stateMutability: "view";
17948
- }, {
17949
- readonly type: "function";
17950
- readonly name: "isAllowedForDecryption";
17951
- readonly inputs: readonly [{
17952
- readonly name: "handle";
17953
- readonly type: "bytes32";
17954
- readonly internalType: "bytes32";
17955
- }];
17956
- readonly outputs: readonly [{
17957
- readonly name: "";
17958
- readonly type: "bool";
17959
- readonly internalType: "bool";
17960
- }];
17961
- readonly stateMutability: "view";
17962
- }, {
17963
- readonly type: "function";
17964
- readonly name: "isHandleDelegatedForUserDecryption";
17965
- readonly inputs: readonly [{
17966
- readonly name: "delegator";
17967
- readonly type: "address";
17968
- readonly internalType: "address";
17969
- }, {
17970
- readonly name: "delegate";
17971
- readonly type: "address";
17972
- readonly internalType: "address";
17973
- }, {
17974
- readonly name: "contractAddress";
17975
- readonly type: "address";
17976
- readonly internalType: "address";
17977
- }, {
17978
- readonly name: "handle";
17979
- readonly type: "bytes32";
17980
- readonly internalType: "bytes32";
17981
- }];
17982
- readonly outputs: readonly [{
17983
- readonly name: "";
17984
- readonly type: "bool";
17985
- readonly internalType: "bool";
17986
- }];
17987
- readonly stateMutability: "view";
17988
- }, {
17989
- readonly type: "function";
17990
- readonly name: "multicall";
17991
- readonly inputs: readonly [{
17992
- readonly name: "data";
17993
- readonly type: "bytes[]";
17994
- readonly internalType: "bytes[]";
17995
- }];
17996
- readonly outputs: readonly [{
17997
- readonly name: "results";
17998
- readonly type: "bytes[]";
17999
- readonly internalType: "bytes[]";
18000
- }];
18001
- readonly stateMutability: "payable";
18002
- }, {
18003
- readonly type: "function";
18004
- readonly name: "persistAllowed";
18005
- readonly inputs: readonly [{
18006
- readonly name: "handle";
18007
- readonly type: "bytes32";
18008
- readonly internalType: "bytes32";
18009
- }, {
18010
- readonly name: "account";
18011
- readonly type: "address";
18012
- readonly internalType: "address";
18013
- }];
18014
- readonly outputs: readonly [{
18015
- readonly name: "";
18016
- readonly type: "bool";
18017
- readonly internalType: "bool";
18018
- }];
18019
- readonly stateMutability: "view";
18020
- }, {
18021
- readonly type: "function";
18022
- readonly name: "revokeDelegationForUserDecryption";
18023
- readonly inputs: readonly [{
18024
- readonly name: "delegate";
18025
- readonly type: "address";
18026
- readonly internalType: "address";
18027
- }, {
18028
- readonly name: "contractAddress";
18029
- readonly type: "address";
18030
- readonly internalType: "address";
18031
- }];
18032
- readonly outputs: readonly [];
18033
- readonly stateMutability: "nonpayable";
18034
- }];
18035
- readonly functionName: "invalidateDecryptionSignaturesBefore";
18036
- readonly args: readonly [bigint];
18037
- };
18038
17789
  /**
18039
17790
  * Returns the contract config to read the delegation expiry date.
18040
17791
  *
@@ -18131,16 +17882,6 @@ declare function getDelegationExpiryContract(aclAddress: Address, delegatorAddre
18131
17882
  readonly internalType: "uint64";
18132
17883
  }];
18133
17884
  readonly stateMutability: "view";
18134
- }, {
18135
- readonly type: "function";
18136
- readonly name: "invalidateDecryptionSignaturesBefore";
18137
- readonly inputs: readonly [{
18138
- readonly name: "timestamp";
18139
- readonly type: "uint256";
18140
- readonly internalType: "uint256";
18141
- }];
18142
- readonly outputs: readonly [];
18143
- readonly stateMutability: "nonpayable";
18144
17885
  }, {
18145
17886
  readonly type: "function";
18146
17887
  readonly name: "isAccountDenied";
@@ -18359,16 +18100,6 @@ declare function isHandleDelegatedContract(aclAddress: Address, delegatorAddress
18359
18100
  readonly internalType: "uint64";
18360
18101
  }];
18361
18102
  readonly stateMutability: "view";
18362
- }, {
18363
- readonly type: "function";
18364
- readonly name: "invalidateDecryptionSignaturesBefore";
18365
- readonly inputs: readonly [{
18366
- readonly name: "timestamp";
18367
- readonly type: "uint256";
18368
- readonly internalType: "uint256";
18369
- }];
18370
- readonly outputs: readonly [];
18371
- readonly stateMutability: "nonpayable";
18372
18103
  }, {
18373
18104
  readonly type: "function";
18374
18105
  readonly name: "isAccountDenied";
@@ -19880,26 +19611,7 @@ type ChecksummedAddress = Address & {
19880
19611
  readonly [checksummedTag]: true;
19881
19612
  };
19882
19613
  //#endregion
19883
- //#region src/credentials/utils.d.ts
19884
- /**
19885
- * Sentinel requesting a V2 permissive ("wildcard") permit from
19886
- * {@link CredentialService.grantPermit} / {@link Permits.grantPermit} /
19887
- * {@link Permits.grantDelegationPermit} — one permit covering every contract,
19888
- * present and future, instead of an explicit list. Always an explicit opt-in:
19889
- * passing a contract list, however large, never signs a wildcard permit.
19890
- *
19891
- * @example
19892
- * ```ts
19893
- * import { WILDCARD_PERMIT } from "@zama-fhe/sdk";
19894
- *
19895
- * await sdk.permits.grantPermit(WILDCARD_PERMIT);
19896
- * ```
19897
- */
19898
- declare const WILDCARD_PERMIT: "wildcard";
19899
- /** The type of {@link WILDCARD_PERMIT}. */
19900
- type WildcardPermit = typeof WILDCARD_PERMIT;
19901
- //#endregion
19902
- //#region src/credentials/types.d.ts
19614
+ //#region src/credentials/types.d.ts
19903
19615
  /**
19904
19616
  * Serialized transport key pair — ML-KEM public + private key as hex, the shape
19905
19617
  * we persist and hand to the decrypt path. Mirrors `@fhevm/sdk`'s
@@ -19948,54 +19660,27 @@ interface SerializedPermit {
19948
19660
  signature: Hex;
19949
19661
  /** Address that produced the signature. */
19950
19662
  signerAddress: ChecksummedAddress;
19951
- /**
19952
- * V2 (unified) permits only — delegation is metadata alongside the signed
19953
- * message, not part of it. Absent for V1 (where delegation lives inside
19954
- * `eip712.message`) and for a non-delegated V2 permit.
19955
- */
19956
- delegatorAddress?: ChecksummedAddress;
19957
19663
  }
19958
- /** Fields shared by every permit version, regardless of shape. */
19959
- interface PermissionBase {
19664
+ /**
19665
+ * A signed EIP-712 permit binding a signer (and optional delegator) to a set of
19666
+ * contract addresses for a bounded time window. Wraps the serialized `@fhevm/sdk`
19667
+ * permit ({@link SerializedPermit}) alongside the scope/coverage metadata the
19668
+ * permission store indexes on.
19669
+ *
19670
+ * Mirrors {@link PermissionSchema}; kept in sync by a `.test-d.ts` guard.
19671
+ */
19672
+ interface Permission {
19960
19673
  /** Public key of the transport key pair this permit is bound to, hex-encoded. */
19961
19674
  keypairPublicKey: Hex;
19962
- /**
19963
- * Contract addresses this permit grants decrypt access to. Never empty for
19964
- * a V1 permit; an empty list on a V2 permit is a wildcard — see {@link PermissionV2}.
19965
- */
19675
+ /** Contract addresses this permit grants decrypt access to. */
19966
19676
  contractAddresses: ChecksummedAddress[];
19967
19677
  /** The signed serialized permit. */
19968
19678
  serializedPermit: SerializedPermit;
19969
19679
  /** Unix timestamp (seconds) when the permit becomes valid. */
19970
19680
  startTimestamp: number;
19971
- }
19972
- /** A V1 ("legacy") permit — always scoped to a specific, non-empty contract list. */
19973
- interface PermissionV1 extends PermissionBase {
19974
- /** Discriminant identifying this as a {@link PermissionV1}. */
19975
- version: 1;
19976
- /** Validity window length in days from {@link PermissionBase.startTimestamp}. */
19681
+ /** Validity window length in days from {@link Permission.startTimestamp}. */
19977
19682
  durationDays: number;
19978
19683
  }
19979
- /**
19980
- * A V2 (unified) permit. `contractAddresses: []` is a *wildcard* (permissive)
19981
- * permit — it covers every contract, not zero.
19982
- */
19983
- interface PermissionV2 extends PermissionBase {
19984
- /** Discriminant identifying this as a {@link PermissionV2}. */
19985
- version: 2;
19986
- /** Validity window length in seconds from {@link PermissionBase.startTimestamp}. */
19987
- durationSeconds: number;
19988
- }
19989
- /**
19990
- * A signed EIP-712 permit binding a signer (and optional delegator) to a set of
19991
- * contract addresses for a bounded time window. Wraps the serialized `@fhevm/sdk`
19992
- * permit ({@link SerializedPermit}) alongside the scope/coverage metadata the
19993
- * permission store indexes on.
19994
- *
19995
- * Discriminated by `version`: {@link PermissionV1} or {@link PermissionV2}.
19996
- * Mirrors {@link PermissionSchema}; kept in sync by a `.test-d.ts` guard.
19997
- */
19998
- type Permission = PermissionV1 | PermissionV2;
19999
19684
  /**
20000
19685
  * Offline `preparePermit` request — `grantPermit`'s parameters split around
20001
19686
  * the wallet signature. `signer` and `delegator` are explicit addresses, not
@@ -20005,12 +19690,8 @@ type Permission = PermissionV1 | PermissionV2;
20005
19690
  interface PreparePermitRequest {
20006
19691
  /** Address that will sign the returned EIP-712 typed data. */
20007
19692
  signer: Address;
20008
- /**
20009
- * Contract addresses to authorize, or {@link WildcardPermit} to request a
20010
- * V2 permit covering every contract. Maximum {@link MAX_CONTRACTS_PER_PERMIT}
20011
- * per call — no chunking. Ignored (and unchecked) when requesting a wildcard.
20012
- */
20013
- contracts: readonly Address[] | WildcardPermit;
19693
+ /** Contract addresses to authorize. Maximum {@link MAX_CONTRACTS_PER_PERMIT} — no chunking. */
19694
+ contracts: readonly Address[];
20014
19695
  /** Delegator address, for a delegated permit. Omit for a self permit. */
20015
19696
  delegator?: Address;
20016
19697
  /** Permit validity window in days. Defaults to the SDK's configured `permitTTL`. */
@@ -20022,40 +19703,24 @@ interface PreparePermitRequest {
20022
19703
  * out-of-process signer returns for it.
20023
19704
  *
20024
19705
  * Deliberately minimal: `chainId`, `contracts`, `startTimestamp`,
20025
- * `durationDays`/`durationSeconds`, and the transport public key are all
20026
- * readable off {@link PreparedPermitBase.eip712}'s `domain`/`message` directly
20027
- * (and, once registered, off the signature-verified payload) — carrying
20028
- * separate top-level copies would only create two sources of truth that could
20029
- * disagree. Read them from `eip712` for display/logging use.
19706
+ * `durationDays`, and the transport public key are all readable off
19707
+ * {@link eip712}'s `domain`/`message` directly (and, once registered, off the
19708
+ * signature-verified payload) — carrying separate top-level copies would only
19709
+ * create two sources of truth that could disagree. Read them from `eip712`
19710
+ * for display/logging use.
20030
19711
  *
20031
- * Discriminated by `version`: {@link PreparedPermitV1} (protocol ≤0.13) or
20032
- * {@link PreparedPermitV2} (protocol ≥0.14, unified/wildcard). JSON-safe —
20033
- * ships across a process boundary as-is.
19712
+ * `version` pins the permit shape (`1` while the SDK targets protocol ≤0.13)
19713
+ * so a future V2 flow is additive, not breaking. JSON-safe — ships across a
19714
+ * process boundary as-is.
20034
19715
  */
20035
- type PreparedPermit = PreparedPermitV1 | PreparedPermitV2;
20036
- /** Fields shared by every prepared-permit version. */
20037
- interface PreparedPermitBase {
19716
+ interface PreparedPermit {
19717
+ /** Permit format version. Always `1` while the SDK targets protocol ≤0.13. */
19718
+ version: 1;
20038
19719
  /** The EIP-712 typed data to sign with `eth_signTypedData_v4`. */
20039
19720
  eip712: SerializedPermitEip712;
20040
19721
  /** Address expected to sign {@link eip712}. */
20041
19722
  signerAddress: ChecksummedAddress;
20042
19723
  }
20043
- /** A V1 ("legacy") prepared permit. Delegation, if any, lives inside `eip712.message`. */
20044
- interface PreparedPermitV1 extends PreparedPermitBase {
20045
- /** Discriminant identifying this as a {@link PreparedPermitV1}. */
20046
- version: 1;
20047
- }
20048
- /**
20049
- * A V2 (unified) prepared permit. V2 delegation is post-sign metadata, not
20050
- * part of the signed message, so a delegated request carries it here instead
20051
- * of inside `eip712.message`.
20052
- */
20053
- interface PreparedPermitV2 extends PreparedPermitBase {
20054
- /** Discriminant identifying this as a {@link PreparedPermitV2}. */
20055
- version: 2;
20056
- /** Delegator address, for a delegated permit. Absent for a self permit. */
20057
- delegatorAddress?: ChecksummedAddress;
20058
- }
20059
19724
  //#endregion
20060
19725
  //#region src/errors/base.d.ts
20061
19726
  /**
@@ -20124,8 +19789,6 @@ declare const ZamaErrorCode: {
20124
19789
  readonly DelegationExpiryUnchanged: "DELEGATION_EXPIRY_UNCHANGED";
20125
19790
  /** Delegate address cannot be the contract address. */
20126
19791
  readonly DelegationDelegateEqualsContract: "DELEGATION_DELEGATE_EQUALS_CONTRACT";
20127
- /** Delegate address cannot be the wildcard address — it's only valid as `contractAddress`. */
20128
- readonly DelegationDelegateCannotBeWildcard: "DELEGATION_DELEGATE_CANNOT_BE_WILDCARD";
20129
19792
  /** Contract address cannot be the sender address. */
20130
19793
  readonly DelegationContractIsSelf: "DELEGATION_CONTRACT_IS_SELF";
20131
19794
  /** The ACL contract is paused. */
@@ -20150,14 +19813,6 @@ declare const ZamaErrorCode: {
20150
19813
  readonly PreparedPermitChainMismatch: "PREPARED_PERMIT_CHAIN_MISMATCH";
20151
19814
  /** A prepared permit's validity window elapsed before its signature was registered. */
20152
19815
  readonly PreparedPermitExpired: "PREPARED_PERMIT_EXPIRED";
20153
- /** V2 (unified) decryption permits — including wildcard permits — need protocol v0.14+; the connected chain hasn't upgraded yet. */
20154
- readonly UnifiedPermitNotSupported: "UNIFIED_PERMIT_NOT_SUPPORTED";
20155
- /** A stored V2/wildcard permit's scope is needed, but the connected relayer instance doesn't support unified decryption yet. */
20156
- readonly UnifiedDecryptionUnsupported: "UNIFIED_DECRYPTION_UNSUPPORTED";
20157
- /** `invalidateDecryptionSignatures` was given a cutoff at or below the account's current one; the ACL only moves it forward. */
20158
- readonly InvalidationTimestampTooLow: "INVALIDATION_TIMESTAMP_TOO_LOW";
20159
- /** `invalidateDecryptionSignatures` was given a cutoff in the future; the ACL only accepts now or earlier. */
20160
- readonly InvalidationTimestampInFuture: "INVALIDATION_TIMESTAMP_IN_FUTURE";
20161
19816
  /** The unwrap request was already finalized on-chain; there is nothing left to resume. */
20162
19817
  readonly UnshieldAlreadyFinalized: "UNSHIELD_ALREADY_FINALIZED";
20163
19818
  };
@@ -20319,45 +19974,6 @@ declare class PreparedPermitChainMismatchError extends ZamaError {
20319
19974
  declare class PreparedPermitExpiredError extends ZamaError {
20320
19975
  constructor(message: string, options?: ErrorOptions);
20321
19976
  }
20322
- /**
20323
- * The connected chain doesn't support V2 (unified) decryption permits yet —
20324
- * including {@link WILDCARD_PERMIT} — because it hasn't upgraded to protocol
20325
- * v0.14 or later. Thrown before any wallet prompt: the SDK detects this from
20326
- * the chain's on-chain KMS context, without a signature attempt. V1 permits
20327
- * (an explicit contract list, not `WILDCARD_PERMIT`) are unaffected — grant
20328
- * one of those instead, or retry once the network upgrades.
20329
- */
20330
- declare class UnifiedPermitNotSupportedError extends ZamaError {
20331
- constructor(message: string, options?: ErrorOptions);
20332
- }
20333
- /**
20334
- * A stored V2 (unified/wildcard) permit's scope is needed for this decrypt,
20335
- * but the connected relayer instance hasn't deployed the `/v3/user-decrypt`
20336
- * route it requires. Distinct from {@link UnifiedPermitNotSupportedError}:
20337
- * that one fires at *signing* time because the *chain* hasn't upgraded to
20338
- * protocol v0.14+; this one fires at *decrypt* time even though the chain and
20339
- * the stored permit are both V2-capable — only this particular relayer
20340
- * instance hasn't deployed the route yet. Grant a specific-contract (V1)
20341
- * permit instead, or retry once the relayer upgrades.
20342
- */
20343
- declare class UnifiedDecryptionUnsupportedError extends ZamaError {
20344
- constructor(message: string, options?: ErrorOptions);
20345
- }
20346
- /**
20347
- * The requested invalidation cutoff was not strictly later than the account's
20348
- * current one. The ACL only ever moves the cutoff forward, so re-sending the
20349
- * same or an older timestamp always reverts.
20350
- */
20351
- declare class InvalidationTimestampTooLowError extends ZamaError {
20352
- constructor(message: string, options?: ErrorOptions);
20353
- }
20354
- /**
20355
- * The requested invalidation cutoff was in the future. The ACL refuses to
20356
- * invalidate signatures that have not been produced yet.
20357
- */
20358
- declare class InvalidationTimestampInFutureError extends ZamaError {
20359
- constructor(message: string, options?: ErrorOptions);
20360
- }
20361
19977
  //#endregion
20362
19978
  //#region src/errors/delegation.d.ts
20363
19979
  /** Delegation cannot target self (delegate === msg.sender). */
@@ -20384,10 +20000,6 @@ declare class DelegationExpiryUnchangedError extends ZamaError {
20384
20000
  declare class DelegationDelegateEqualsContractError extends ZamaError {
20385
20001
  constructor(message: string, options?: ErrorOptions);
20386
20002
  }
20387
- /** Delegate address cannot be the wildcard address — it's only valid as `contractAddress`. */
20388
- declare class DelegationDelegateCannotBeWildcardError extends ZamaError {
20389
- constructor(message: string, options?: ErrorOptions);
20390
- }
20391
20003
  /** Contract address cannot be the sender address. */
20392
20004
  declare class DelegationContractIsSelfError extends ZamaError {
20393
20005
  constructor(message: string, options?: ErrorOptions);
@@ -20746,8 +20358,6 @@ interface ErrorForCode {
20746
20358
  [ZamaErrorCode.DelegationExpiryUnchanged]: DelegationExpiryUnchangedError;
20747
20359
  /** Thrown for {@link ZamaErrorCode.DelegationDelegateEqualsContract}. */
20748
20360
  [ZamaErrorCode.DelegationDelegateEqualsContract]: DelegationDelegateEqualsContractError;
20749
- /** Thrown for {@link ZamaErrorCode.DelegationDelegateCannotBeWildcard}. */
20750
- [ZamaErrorCode.DelegationDelegateCannotBeWildcard]: DelegationDelegateCannotBeWildcardError;
20751
20361
  /** Thrown for {@link ZamaErrorCode.DelegationContractIsSelf}. */
20752
20362
  [ZamaErrorCode.DelegationContractIsSelf]: DelegationContractIsSelfError;
20753
20363
  /** Thrown for {@link ZamaErrorCode.AclPaused}. */
@@ -20772,14 +20382,6 @@ interface ErrorForCode {
20772
20382
  [ZamaErrorCode.PreparedPermitChainMismatch]: PreparedPermitChainMismatchError;
20773
20383
  /** Thrown for {@link ZamaErrorCode.PreparedPermitExpired}. */
20774
20384
  [ZamaErrorCode.PreparedPermitExpired]: PreparedPermitExpiredError;
20775
- /** Thrown for {@link ZamaErrorCode.UnifiedPermitNotSupported}. */
20776
- [ZamaErrorCode.UnifiedPermitNotSupported]: UnifiedPermitNotSupportedError;
20777
- /** Thrown for {@link ZamaErrorCode.UnifiedDecryptionUnsupported}. */
20778
- [ZamaErrorCode.UnifiedDecryptionUnsupported]: UnifiedDecryptionUnsupportedError;
20779
- /** Thrown for {@link ZamaErrorCode.InvalidationTimestampTooLow}. */
20780
- [ZamaErrorCode.InvalidationTimestampTooLow]: InvalidationTimestampTooLowError;
20781
- /** Thrown for {@link ZamaErrorCode.InvalidationTimestampInFuture}. */
20782
- [ZamaErrorCode.InvalidationTimestampInFuture]: InvalidationTimestampInFutureError;
20783
20385
  /** Thrown for {@link ZamaErrorCode.UnshieldAlreadyFinalized}. */
20784
20386
  [ZamaErrorCode.UnshieldAlreadyFinalized]: UnshieldAlreadyFinalizedError;
20785
20387
  }
@@ -20834,29 +20436,21 @@ declare class Permits {
20834
20436
  * rejection is preserved (already-signed chunks are persisted before the
20835
20437
  * next prompt).
20836
20438
  *
20837
- * Pass {@link WILDCARD_PERMIT} instead of an address list to request a V2
20838
- * permissive permit covering every contract, present and future — an
20839
- * explicit opt-in, not something a large address list implies. A stolen
20840
- * wildcard permit decrypts anything the signer owns until it expires, so
20841
- * prefer a specific contract list unless the caller genuinely needs
20842
- * unbounded coverage.
20843
- *
20844
- * @param contracts - Contract addresses to authorize, or {@link WILDCARD_PERMIT}.
20439
+ * @param contracts - Contract addresses to authorize.
20845
20440
  * @throws if `transportKeyPairDerivationSecret` is configured and the keypair fails to wrap or
20846
20441
  * unwrap. {@link KeyWrappingError}
20847
20442
  */
20848
- grantPermit(contracts: Address[] | WildcardPermit): Promise<void>;
20443
+ grantPermit(contracts: Address[]): Promise<void>;
20849
20444
  /**
20850
20445
  * Sign and store an EIP-712 delegation permit authorizing decryption on
20851
- * behalf of `delegator`. Same idempotence/chunking/wildcard semantics as
20852
- * {@link grantPermit}.
20446
+ * behalf of `delegator`. Same idempotence/chunking semantics as {@link grantPermit}.
20853
20447
  *
20854
20448
  * @param delegator - The address that delegated decryption rights to the connected signer.
20855
- * @param contracts - Contract addresses to authorize, or {@link WILDCARD_PERMIT}.
20449
+ * @param contracts - Contract addresses to authorize.
20856
20450
  * @throws if `transportKeyPairDerivationSecret` is configured and the keypair fails to wrap or
20857
20451
  * unwrap. {@link KeyWrappingError}
20858
20452
  */
20859
- grantDelegationPermit(delegator: Address, contracts: Address[] | WildcardPermit): Promise<void>;
20453
+ grantDelegationPermit(delegator: Address, contracts: Address[]): Promise<void>;
20860
20454
  /**
20861
20455
  * Pure store lookup: is there a permit covering `contracts`?
20862
20456
  * No wallet prompt, no transport key pair generation. Returns `false` when no signer
@@ -20904,8 +20498,7 @@ declare class Permits {
20904
20498
  * (and `prepared.delegatorAddress`, if present), not a connected signer.
20905
20499
  *
20906
20500
  * @param prepared - The payload `sdk.offline.preparePermit` returned.
20907
- * @param signature - The `eth_signTypedData_v4` signature over `prepared.eip712`.
20908
- * V2 permits also accept a variable-length ERC-1271 (smart-wallet) blob.
20501
+ * @param signature - The 65-byte `eth_signTypedData_v4` signature over `prepared.eip712`.
20909
20502
  * @throws if `prepared` doesn't match the `PreparedPermit` shape (e.g. it crossed a
20910
20503
  * process boundary and was corrupted). {@link ConfigurationError}
20911
20504
  * @throws if the chain embedded in `prepared.eip712` doesn't match the active chain. {@link PreparedPermitChainMismatchError}
@@ -20973,32 +20566,10 @@ declare class Permits {
20973
20566
  * unwrap. {@link KeyWrappingError}
20974
20567
  */
20975
20568
  warmTransportKeyPairScope(scopeId: string): Promise<void>;
20976
- /**
20977
- * Invalidate every decryption signature signed before `timestamp`, via
20978
- * `ACL.invalidateDecryptionSignaturesBefore`. The KMS Connector rejects
20979
- * any decryption request whose permit predates the new cutoff — the
20980
- * recourse when a permissive/wildcard permit or its signing key is
20981
- * compromised, or on a multisig (ERC-1271/Safe) owner rotation. Call this
20982
- * on every multisig signer rotation and on suspected signing-key compromise.
20983
- *
20984
- * On success, this signer's locally-stored permits for the current chain
20985
- * are cleared automatically — they would now only fail against the KMS
20986
- * Connector.
20987
- *
20988
- * @param timestamp - Oldest timestamp that remains valid. Omit to invalidate
20989
- * everything up to now.
20990
- * @throws if no signer is configured. {@link SignerNotConfiguredError}
20991
- * @throws if signer and provider are on different chains. {@link ChainMismatchError}
20992
- * @throws if `timestamp` is not strictly later than the account's current
20993
- * cutoff. {@link InvalidationTimestampTooLowError}
20994
- * @throws if `timestamp` is in the future. {@link InvalidationTimestampInFutureError}
20995
- * @throws if the invalidation transaction reverts for any other reason. {@link TransactionRevertedError}
20996
- */
20997
- invalidateDecryptionSignatures(timestamp?: Date): Promise<TransactionResult>;
20998
20569
  }
20999
20570
  //#endregion
21000
20571
  //#region src/services/delegation-service.d.ts
21001
- /** Delegation activity and expiry, resolved from the active contract or wildcard grant. */
20572
+ /** Delegation activity and expiry, resolved from a single expiry read. */
21002
20573
  interface DelegationStatus {
21003
20574
  /** Whether the delegation is currently active (exists and not expired). */
21004
20575
  isActive: boolean;
@@ -21031,8 +20602,7 @@ declare class Delegations {
21031
20602
  * window with a bounded internal retry, so you can decrypt right after this
21032
20603
  * resolves.
21033
20604
  *
21034
- * @param contractAddress - The confidential contract address to delegate on, or
21035
- * {@link WILDCARD_CONTRACT} to cover every contract with a single delegation.
20605
+ * @param contractAddress - The confidential contract address to delegate on.
21036
20606
  * @param delegateAddress - Address to delegate decryption rights to.
21037
20607
  * @param expirationDate - Optional expiration date (defaults to permanent delegation via `uint64.max`).
21038
20608
  * @returns The transaction hash and mined receipt.
@@ -21040,7 +20610,6 @@ declare class Delegations {
21040
20610
  * @throws if signer and provider are on different chains. {@link ChainMismatchError}
21041
20611
  * @throws if `expirationDate` is less than 1 hour in the future. {@link DelegationExpirationTooSoonError}
21042
20612
  * @throws if the delegate equals the connected wallet. {@link DelegationSelfNotAllowedError}
21043
- * @throws if the delegate is the wildcard address. {@link DelegationDelegateCannotBeWildcardError}
21044
20613
  * @throws if the delegate equals the contract address. {@link DelegationDelegateEqualsContractError}
21045
20614
  * @throws if the new expiry equals the current one. {@link DelegationExpiryUnchangedError}
21046
20615
  * @throws if the delegation transaction reverts. {@link TransactionRevertedError}
@@ -21114,667 +20683,104 @@ declare class Delegations {
21114
20683
  }): Promise<DelegationStatus>;
21115
20684
  }
21116
20685
  //#endregion
21117
- //#region src/query/utils.d.ts
21118
- /** Union of TanStack Query option keys stripped by {@link filterQueryOptions}, leaving only domain parameters. */
21119
- type StrippedQueryOptionKeys = "gcTime" | "staleTime" | "enabled" | "select" | "refetchInterval" | "refetchOnMount" | "refetchOnWindowFocus" | "refetchOnReconnect" | "retry" | "retryDelay" | "retryOnMount" | "queryFn" | "queryKey" | "queryKeyHashFn" | "initialData" | "initialDataUpdatedAt" | "placeholderData" | "structuralSharing" | "throwOnError" | "meta" | "query" | "pollingInterval";
21120
- /**
21121
- * Remove TanStack behavioral options from a query config object so only domain
21122
- * parameters remain for the lower-level factory.
21123
- *
21124
- * @example
21125
- * ```ts
21126
- * const params = filterQueryOptions({
21127
- * query: { enabled: false },
21128
- * gcTime: 60_000,
21129
- * owner: "0xabc",
21130
- * });
21131
- * // => { owner: "0xabc" }
21132
- * ```
21133
- */
21134
- declare function filterQueryOptions<TOptions extends Record<string, unknown>>(options: TOptions): Omit<TOptions, StrippedQueryOptionKeys>;
21135
- /**
21136
- * Stable hash function for query keys.
21137
- * Sorts object keys recursively and converts bigint values to strings.
21138
- *
21139
- * @remarks
21140
- * bigint values are serialized as decimal strings, so `42n` and `"42"` hash to
21141
- * the same token when they occupy the same position. This collision is accepted
21142
- * by design for the current query-key conventions in this package.
21143
- */
21144
- declare function hashFn(queryKey: readonly unknown[]): string;
21145
- //#endregion
21146
- //#region src/query/factory-types.d.ts
20686
+ //#region src/namespaces/offline.d.ts
21147
20687
  /**
21148
- * TanStack Query options object returned by the SDK's `*QueryOptions` factories:
21149
- * `QueryObserverOptions` with `queryKey` and `queryFn` required and the
21150
- * cache-internal keys (`queryHash`, `queryKeyHashFn`, `throwOnError`) removed.
20688
+ * Namespace for the offline-signing pipeline —
20689
+ * `prepare → [external sign + self-publish]` — for institutional custody, HSM
20690
+ * ceremonies, and policy-engine workflows where signing runs out-of-process and
20691
+ * cannot happen synchronously in a single Promise.
21151
20692
  */
21152
- type QueryFactoryOptions<TQueryFnData = unknown, TError = Error, TData = TQueryFnData, TQueryKey extends QueryKey = QueryKey> = Omit<Omit<QueryObserverOptions<TQueryFnData, TError, TData, TQueryFnData, TQueryKey>, "queryKey"> & Required<Pick<QueryObserverOptions<TQueryFnData, TError, TData, TQueryFnData, TQueryKey>, "queryKey">>, "queryFn" | "queryHash" | "queryKeyHashFn" | "throwOnError"> & {
21153
- queryFn: Exclude<QueryObserverOptions<TQueryFnData, TError, TData, TQueryFnData, TQueryKey>["queryFn"], typeof skipToken | undefined>;
21154
- };
21155
- /** TanStack Query mutation options object returned by the SDK's `*MutationOptions` factories. */
21156
- interface MutationFactoryOptions<TMutationKey extends readonly unknown[], TVariables, TData, TOnMutateResult = unknown> {
21157
- /** Cache key identifying the mutation. */
21158
- mutationKey: TMutationKey;
21159
- /** Runs the mutation for the given variables. */
21160
- mutationFn: (variables: TVariables) => Promise<TData>;
21161
- /** Optional callback invoked after the mutation succeeds. */
21162
- onSuccess?: (data: TData, variables: TVariables, onMutateResult: TOnMutateResult, context: MutationFunctionContext) => void;
20693
+ declare class Offline {
20694
+ #private;
20695
+ /**
20696
+ * Build an RLP-encoded unsigned transaction for the given request. The
20697
+ * caller signs it externally — via an HSM ceremony, an out-of-process
20698
+ * custodian, or any signer holding the key — and broadcasts the signed bytes
20699
+ * through its own channel.
20700
+ *
20701
+ * Signer-optional: works without a configured signer (canonical shape for
20702
+ * cross-process custody — the back-end signer service consumes
20703
+ * `prepared.unsignedTx` and returns signed bytes).
20704
+ *
20705
+ * @remarks
20706
+ * `request.from` is only a declaration — the SDK does not prove the caller
20707
+ * controls it, and an EIP-1559 unsigned tx carries no `from` field at all
20708
+ * (the on-chain sender is whichever key signs the bytes). Point `from` at
20709
+ * the account the custodian will sign with; custodians enforce key-control
20710
+ * at sign time — a signing request for a key the credential can't use fails
20711
+ * there — so a mismatched `from` cannot make the custodian sign from an
20712
+ * account you don't control. Verifying control of `from` up front is still
20713
+ * the application's responsibility.
20714
+ */
20715
+ prepare<K extends TransactionKind>(request: Extract<PrepareTransactionRequest, {
20716
+ kind: K;
20717
+ }>, options?: PrepareOptions): Promise<PreparedFor<K>>;
20718
+ /**
20719
+ * Build the offline-signing payload for a decryption permit: the unsigned
20720
+ * EIP-712 typed data plus everything `sdk.permits.registerPermit` needs to
20721
+ * verify and persist the signature an out-of-process signer returns for it.
20722
+ *
20723
+ * Not a `prepare()` transaction kind: a permit is not a transaction —
20724
+ * nothing is broadcast, and registering the signature is a local operation,
20725
+ * not a relayer round-trip.
20726
+ *
20727
+ * Signer-optional, like {@link prepare}: `request.signer` is an explicit
20728
+ * address, not a connected wallet account. Building the typed data still
20729
+ * reads the chain's KMS signers context on-chain — signer-offline, not
20730
+ * network-offline.
20731
+ *
20732
+ * One permit per call: unlike `sdk.permits.grantPermit`, this never widens
20733
+ * an existing permit or chunks over 10 contracts — `request.contracts` maps
20734
+ * to exactly one signature.
20735
+ *
20736
+ * @throws if `request.contracts` is empty or exceeds 10 addresses, `request.delegator`
20737
+ * equals `request.signer`, or `request.durationDays` exceeds the V1 permit maximum
20738
+ * of 365 days. {@link ConfigurationError}
20739
+ * @throws if a concurrent `permits.revokeTransportKeyPair()` rotates the transport key
20740
+ * pair while this call is generating one. {@link TransportKeyPairChangedError}
20741
+ */
20742
+ preparePermit(request: PreparePermitRequest): Promise<PreparedPermit>;
21163
20743
  }
21164
20744
  //#endregion
21165
- //#region src/query/signer-query-context.d.ts
21166
- /** Connected-wallet context threaded into query factories to scope cache keys and gate signer-dependent queries. */
21167
- interface SignerQueryContext {
21168
- /** Connected wallet account; queries that need a signer stay disabled until it is set. */
21169
- walletAccount?: WalletAccount;
20745
+ //#region src/token/token.d.ts
20746
+ /** Options for {@link Token.batchDecryptBalancesAs}. */
20747
+ interface BatchDecryptAsOptions {
20748
+ /** The address of the account that delegated decryption rights. */
20749
+ delegatorAddress: Address;
20750
+ /** Pre-fetched encrypted values. When omitted, they are fetched from the chain. */
20751
+ encryptedValues?: EncryptedValue[];
20752
+ /**
20753
+ * The account whose on-chain balance to read. Defaults to the delegator
20754
+ * address, which is the common case (the delegator grants permission to
20755
+ * decrypt their own balance). Only set this when the account differs
20756
+ * from the delegator.
20757
+ *
20758
+ * Matches the `account` parameter of `confidentialBalanceOf(account)` on-chain.
20759
+ */
20760
+ accountAddress?: Address;
20761
+ /** Maximum number of concurrent decrypt calls. Default: 10. */
20762
+ maxConcurrency?: number;
20763
+ /** Called when decryption fails for a single token. Return a fallback bigint. */
20764
+ onError?: (error: Error, address: Address) => bigint;
20765
+ }
20766
+ /** Result of {@link Token.batchBalancesOf}. */
20767
+ interface BatchBalancesResult {
20768
+ /** Successfully decrypted balances, keyed by token address. */
20769
+ results: Map<Address, bigint>;
20770
+ /** Per-token errors for tokens that failed to decrypt. */
20771
+ errors: Map<Address, ZamaError>;
21170
20772
  }
21171
- //#endregion
21172
- //#region src/query/query-keys.d.ts
21173
20773
  /**
21174
- * Canonical query-key namespace for `@zama-fhe/sdk/query`.
20774
+ * High-level interface for an ERC-7984 confidential token.
20775
+ * Hides FHE complexity (encryption, decryption, EIP-712 signing) behind
20776
+ * familiar ERC-20-like methods.
21175
20777
  *
21176
- * @example
21177
- * ```ts
21178
- * queryClient.invalidateQueries({
21179
- * queryKey: zamaQueryKeys.confidentialBalance.token("0xToken"),
21180
- * });
21181
- * ```
21182
- */
21183
- declare const zamaQueryKeys: {
21184
- readonly confidentialBalance: {
21185
- readonly all: readonly ["zama.confidentialBalance"];
21186
- readonly token: (tokenAddress: Address) => readonly ["zama.confidentialBalance", {
21187
- readonly tokenAddress: `0x${string}`;
21188
- }];
21189
- readonly owner: (tokenAddress: Address, owner?: Address, walletAccount?: WalletAccount) => readonly ["zama.confidentialBalance", {
21190
- readonly owner?: `0x${string}` | undefined;
21191
- readonly walletAddress: `0x${string}`;
21192
- readonly walletChainId: number;
21193
- readonly tokenAddress: `0x${string}`;
21194
- } | {
21195
- readonly owner?: `0x${string}` | undefined;
21196
- readonly walletAddress?: undefined;
21197
- readonly walletChainId?: undefined;
21198
- readonly tokenAddress: `0x${string}`;
21199
- }];
21200
- };
21201
- readonly confidentialBalances: {
21202
- readonly all: readonly ["zama.confidentialBalances"];
21203
- readonly tokens: (tokenAddresses: Address[], owner?: Address, walletAccount?: WalletAccount) => readonly ["zama.confidentialBalances", {
21204
- readonly owner?: `0x${string}` | undefined;
21205
- readonly walletAddress: `0x${string}`;
21206
- readonly walletChainId: number;
21207
- readonly tokenAddresses: `0x${string}`[];
21208
- } | {
21209
- readonly owner?: `0x${string}` | undefined;
21210
- readonly walletAddress?: undefined;
21211
- readonly walletChainId?: undefined;
21212
- readonly tokenAddresses: `0x${string}`[];
21213
- }];
21214
- };
21215
- readonly tokenMetadata: {
21216
- readonly all: readonly ["zama.tokenMetadata"];
21217
- readonly token: (tokenAddress: Address) => readonly ["zama.tokenMetadata", {
21218
- readonly tokenAddress: `0x${string}`;
21219
- }];
21220
- };
21221
- readonly isConfidential: {
21222
- readonly all: readonly ["zama.isConfidential"];
21223
- readonly token: (tokenAddress: Address) => readonly ["zama.isConfidential", {
21224
- readonly tokenAddress: `0x${string}`;
21225
- }];
21226
- };
21227
- readonly isWrapper: {
21228
- readonly all: readonly ["zama.isWrapper"];
21229
- readonly token: (tokenAddress: Address) => readonly ["zama.isWrapper", {
21230
- readonly tokenAddress: `0x${string}`;
21231
- }];
21232
- };
21233
- readonly wrapperDiscovery: {
21234
- readonly all: readonly ["zama.wrapperDiscovery"];
21235
- readonly token: (tokenAddress?: Address, erc20Address?: Address, registryAddress?: Address) => readonly ["zama.wrapperDiscovery", {
21236
- readonly registryAddress?: `0x${string}` | undefined;
21237
- readonly erc20Address?: `0x${string}` | undefined;
21238
- readonly tokenAddress?: `0x${string}` | undefined;
21239
- }];
21240
- };
21241
- readonly underlyingAllowance: {
21242
- readonly all: readonly ["zama.underlyingAllowance"];
21243
- readonly token: (tokenAddress: Address) => readonly ["zama.underlyingAllowance", {
21244
- readonly tokenAddress: `0x${string}`;
21245
- }];
21246
- readonly scope: (tokenAddress: Address, owner?: Address) => readonly ["zama.underlyingAllowance", {
21247
- readonly owner?: `0x${string}` | undefined;
21248
- readonly tokenAddress: `0x${string}`;
21249
- }];
21250
- };
21251
- readonly confidentialIsOperator: {
21252
- readonly all: readonly ["zama.confidentialIsOperator"];
21253
- readonly token: (tokenAddress?: Address) => readonly ["zama.confidentialIsOperator", {
21254
- tokenAddress: `0x${string}`;
21255
- } | {
21256
- tokenAddress?: undefined;
21257
- }];
21258
- readonly scope: (tokenAddress?: Address, holder?: Address, spender?: Address) => readonly ["zama.confidentialIsOperator", {
21259
- readonly spender?: `0x${string}` | undefined;
21260
- readonly holder?: `0x${string}` | undefined;
21261
- readonly tokenAddress?: `0x${string}` | undefined;
21262
- }];
21263
- };
21264
- readonly totalSupply: {
21265
- readonly all: readonly ["zama.totalSupply"];
21266
- readonly token: (tokenAddress: Address) => readonly ["zama.totalSupply", {
21267
- readonly tokenAddress: `0x${string}`;
21268
- }];
21269
- };
21270
- readonly pendingUnshield: {
21271
- readonly all: readonly ["zama.pendingUnshield"];
21272
- readonly token: (tokenAddress: Address) => readonly ["zama.pendingUnshield", {
21273
- readonly tokenAddress: `0x${string}`;
21274
- }];
21275
- };
21276
- readonly hasPermit: {
21277
- readonly all: readonly ["zama.hasPermit"];
21278
- readonly scope: (contractAddresses: Address[], walletAccount?: WalletAccount) => readonly ["zama.hasPermit", {
21279
- readonly contractAddresses: `0x${string}`[];
21280
- readonly walletAddress: `0x${string}`;
21281
- readonly walletChainId: number;
21282
- } | {
21283
- readonly contractAddresses: `0x${string}`[];
21284
- readonly walletAddress?: undefined;
21285
- readonly walletChainId?: undefined;
21286
- }];
21287
- };
21288
- readonly delegationStatus: {
21289
- readonly all: readonly ["zama.delegationStatus"];
21290
- readonly contract: (contractAddress?: Address) => readonly ["zama.delegationStatus", {
21291
- contractAddress: `0x${string}`;
21292
- } | {
21293
- contractAddress?: undefined;
21294
- }];
21295
- readonly scope: (contractAddress?: Address, delegator?: Address, delegate?: Address) => readonly ["zama.delegationStatus", {
21296
- readonly delegateAddress?: `0x${string}` | undefined;
21297
- readonly delegatorAddress?: `0x${string}` | undefined;
21298
- readonly contractAddress?: `0x${string}` | undefined;
21299
- }];
21300
- };
21301
- readonly decryption: {
21302
- readonly all: readonly ["zama.decryption"];
21303
- readonly encryptedValue: (encryptedValue: string, contractAddress?: Address) => readonly ["zama.decryption", {
21304
- readonly contractAddress?: `0x${string}` | undefined;
21305
- readonly encryptedValue: string;
21306
- }];
21307
- readonly encryptedInputs: (encryptedInputs: readonly {
21308
- encryptedValue: string;
21309
- contractAddress: Address;
21310
- }[], walletAccount?: WalletAccount) => readonly ["zama.decryption", {
21311
- readonly encryptedInputs: {
21312
- encryptedValue: Hex;
21313
- contractAddress: `0x${string}`;
21314
- }[];
21315
- readonly walletAddress: `0x${string}`;
21316
- readonly walletChainId: number;
21317
- } | {
21318
- readonly encryptedInputs: {
21319
- encryptedValue: Hex;
21320
- contractAddress: `0x${string}`;
21321
- }[];
21322
- readonly walletAddress?: undefined;
21323
- readonly walletChainId?: undefined;
21324
- }];
21325
- };
21326
- readonly wrappersRegistry: {
21327
- readonly all: readonly ["zama.wrappersRegistry"];
21328
- readonly chainId: () => readonly ["zama.wrappersRegistry", {
21329
- readonly type: "chainId";
21330
- }];
21331
- readonly tokenPairs: (registryAddress: Address) => readonly ["zama.wrappersRegistry", {
21332
- readonly type: "tokenPairs";
21333
- readonly registryAddress: `0x${string}`;
21334
- }];
21335
- readonly confidentialTokenAddress: (registryAddress: Address, tokenAddress: Address) => readonly ["zama.wrappersRegistry", {
21336
- readonly type: "confidentialTokenAddress";
21337
- readonly registryAddress: `0x${string}`;
21338
- readonly tokenAddress: `0x${string}`;
21339
- }];
21340
- readonly tokenAddress: (registryAddress: Address, confidentialTokenAddress: Address) => readonly ["zama.wrappersRegistry", {
21341
- readonly type: "tokenAddress";
21342
- readonly registryAddress: `0x${string}`;
21343
- readonly confidentialTokenAddress: `0x${string}`;
21344
- }];
21345
- readonly tokenPairsLength: (registryAddress: Address) => readonly ["zama.wrappersRegistry", {
21346
- readonly type: "tokenPairsLength";
21347
- readonly registryAddress: `0x${string}`;
21348
- }];
21349
- readonly tokenPairsSlice: (registryAddress: Address, fromIndex: string, toIndex: string) => readonly ["zama.wrappersRegistry", {
21350
- readonly type: "tokenPairsSlice";
21351
- readonly registryAddress: `0x${string}`;
21352
- readonly fromIndex: string;
21353
- readonly toIndex: string;
21354
- }];
21355
- readonly tokenPair: (registryAddress: Address, index: string) => readonly ["zama.wrappersRegistry", {
21356
- readonly type: "tokenPair";
21357
- readonly registryAddress: `0x${string}`;
21358
- readonly index: string;
21359
- }];
21360
- readonly isConfidentialTokenValid: (registryAddress: Address, confidentialTokenAddress: Address) => readonly ["zama.wrappersRegistry", {
21361
- readonly type: "isConfidentialTokenValid";
21362
- readonly registryAddress: `0x${string}`;
21363
- readonly confidentialTokenAddress: `0x${string}`;
21364
- }];
21365
- readonly listPairs: (registryAddress: Address, page: number, pageSize: number, metadata: boolean) => readonly ["zama.wrappersRegistry", {
21366
- readonly type: "listPairs";
21367
- readonly registryAddress: `0x${string}`;
21368
- readonly page: number;
21369
- readonly pageSize: number;
21370
- readonly metadata: boolean;
21371
- }];
21372
- };
21373
- };
21374
- //#endregion
21375
- //#region src/query/invalidation.d.ts
21376
- /** Minimal query shape read by the invalidation predicates. */
21377
- interface QueryLike {
21378
- /** The query's cache key. */
21379
- queryKey: readonly unknown[];
21380
- }
21381
- /** Minimal filter shape accepted by the invalidation helpers, matching TanStack Query's `QueryFilters`. */
21382
- interface QueryFilterLike {
21383
- /** Match queries whose key starts with this prefix. */
21384
- queryKey?: readonly unknown[];
21385
- /** Match queries for which this returns `true`. */
21386
- predicate?: (query: QueryLike) => boolean;
21387
- }
21388
- /** Minimal `QueryClient` surface used by the invalidation helpers. */
21389
- interface QueryClientLike {
21390
- /** Mark matching queries stale so they refetch. */
21391
- invalidateQueries(filters: QueryFilterLike): void | Promise<void>;
21392
- /** Remove matching queries from the cache entirely. */
21393
- removeQueries(filters: QueryFilterLike): void;
21394
- }
21395
- /** Invalidates the caches affected by an unwrap: confidential balances, underlying allowance, and pending unshields. */
21396
- declare function invalidateAfterUnwrap(queryClient: QueryClientLike, tokenAddress: Address): void;
21397
- /** Invalidates the caches affected by a wrap: confidential balances and underlying allowance. */
21398
- declare function invalidateAfterWrap(queryClient: QueryClientLike, tokenAddress: Address): void;
21399
- /** Invalidates the confidential balance queries for a token (single-token and batched). */
21400
- declare function invalidateBalanceQueries(queryClient: QueryClientLike, tokenAddress: Address): void;
21401
- /** Invalidates the caches affected by a shield: confidential balances and underlying allowance. */
21402
- declare function invalidateAfterShield(queryClient: QueryClientLike, tokenAddress: Address): void;
21403
- /** Invalidates the caches affected by an unshield request: confidential balances, underlying allowance, and pending unshields. */
21404
- declare function invalidateAfterUnshield(queryClient: QueryClientLike, tokenAddress: Address): void;
21405
- /** Invalidates the pending-unshield cache once an unshield has settled on-chain. */
21406
- declare function invalidateAfterUnshieldSettled(queryClient: QueryClientLike, tokenAddress: Address): void;
21407
- /** Invalidates the confidential balance caches affected by a transfer. */
21408
- declare function invalidateAfterTransfer(queryClient: QueryClientLike, tokenAddress: Address): void;
21409
- /** Invalidates the underlying-allowance cache after approving the underlying ERC-20. */
21410
- declare function invalidateAfterApproveUnderlying(queryClient: QueryClientLike, tokenAddress: Address): void;
21411
- /** Invalidates the operator-status cache after changing a token operator. */
21412
- declare function invalidateAfterSetOperator(queryClient: QueryClientLike, tokenAddress: Address): void;
21413
- /** Invalidates any wagmi `useBalance`/`readContract` balance queries so ERC-20 balances refresh. */
21414
- declare function invalidateWagmiBalanceQueries(queryClient: QueryClientLike): void;
21415
- /** 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. */
21416
- declare function invalidateWalletLifecycleQueries(queryClient: QueryClientLike): void;
21417
- //#endregion
21418
- //#region src/query/token-metadata.d.ts
21419
- /** ERC-20 token metadata returned by {@link tokenMetadataQueryOptions}. */
21420
- interface TokenMetadata {
21421
- /** Human-readable token name. */
21422
- name: string;
21423
- /** Token ticker symbol. */
21424
- symbol: string;
21425
- /** Number of decimals the token uses. */
21426
- decimals: number;
21427
- }
21428
- /** Configuration for {@link tokenMetadataQueryOptions}. */
21429
- interface TokenMetadataQueryConfig {
21430
- /** Additional TanStack Query options merged into the generated query (e.g. `staleTime`, `enabled`). */
21431
- query?: Record<string, unknown>;
21432
- }
21433
- /** Builds TanStack Query options for reading an ERC-20 token's name, symbol, and decimals. */
21434
- declare function tokenMetadataQueryOptions(sdk: ZamaSDK, tokenAddress: Address, config?: TokenMetadataQueryConfig): QueryFactoryOptions<TokenMetadata, Error, TokenMetadata, ReturnType<typeof zamaQueryKeys.tokenMetadata.token>>;
21435
- //#endregion
21436
- //#region src/query/is-confidential.d.ts
21437
- /** Configuration for {@link isConfidentialQueryOptions} and {@link isWrapperQueryOptions}. */
21438
- interface IsConfidentialQueryConfig {
21439
- /** Additional TanStack Query options merged into the generated query (e.g. `staleTime`, `enabled`). */
21440
- query?: Record<string, unknown>;
21441
- }
21442
- /** Builds TanStack Query options for reading whether a token address implements the confidential (ERC-7984) token interface. */
21443
- declare function isConfidentialQueryOptions(sdk: ZamaSDK, tokenAddress: Address, config?: IsConfidentialQueryConfig): QueryFactoryOptions<boolean, Error, boolean, ReturnType<typeof zamaQueryKeys.isConfidential.token>>;
21444
- /** Builds TanStack Query options for reading whether a token address is a confidential wrapper (ERC-7984 wrapper) contract. */
21445
- declare function isWrapperQueryOptions(sdk: ZamaSDK, tokenAddress: Address, config?: IsConfidentialQueryConfig): QueryFactoryOptions<boolean, Error, boolean, ReturnType<typeof zamaQueryKeys.isWrapper.token>>;
21446
- //#endregion
21447
- //#region src/query/total-supply.d.ts
21448
- /** Configuration for {@link totalSupplyQueryOptions}. */
21449
- interface TotalSupplyQueryConfig {
21450
- /** Additional TanStack Query options merged into the generated query (e.g. `staleTime`, `enabled`). */
21451
- query?: Record<string, unknown>;
21452
- }
21453
- /** Builds TanStack Query options for reading a token's total supply. */
21454
- declare function totalSupplyQueryOptions(sdk: ZamaSDK, tokenAddress: Address, config?: TotalSupplyQueryConfig): QueryFactoryOptions<bigint, Error, bigint, ReturnType<typeof zamaQueryKeys.totalSupply.token>>;
21455
- //#endregion
21456
- //#region src/wrappers-registry.d.ts
21457
- /**
21458
- * Default wrappers registry addresses for known chains.
21459
- * Only includes chains where a registry is deployed (excludes Hardhat).
21460
- *
21461
- * @deprecated Read `registryAddress` from the chain presets instead (e.g.
21462
- * `sepolia.registryAddress`). Will be removed in the next major version.
21463
- */
21464
- declare const DefaultRegistryAddresses: Record<number, Address>;
21465
- /** Configuration for {@link WrappersRegistry}. */
21466
- interface WrappersRegistryConfig {
21467
- /** Read-only chain provider used for every registry lookup. */
21468
- provider: GenericProvider;
21469
- /**
21470
- * Per-chain registry address overrides, merged on top of
21471
- * {@link DefaultRegistryAddresses}. Use this to supply a registry
21472
- * address for custom or local chains (e.g. Hardhat).
21473
- *
21474
- * @example
21475
- * ```ts
21476
- * new WrappersRegistry({
21477
- * provider,
21478
- * registryAddresses: { [31337]: "0xYourHardhatRegistry" },
21479
- * });
21480
- * ```
21481
- */
21482
- registryAddresses?: Record<number, Address>;
21483
- /**
21484
- * How long cached registry results remain valid, in seconds.
21485
- * Default: `86400` (24 hours).
21486
- */
21487
- registryTTL?: number;
21488
- }
21489
- /** Options for {@link WrappersRegistry.listPairs}. */
21490
- interface ListPairsOptions {
21491
- /** Page number (1-indexed). Default: `1`. */
21492
- page?: number;
21493
- /** Number of items per page. Default: `100`. */
21494
- pageSize?: number;
21495
- /**
21496
- * When `true`, fetches on-chain metadata (name, symbol, decimals) for both
21497
- * the ERC-20 and confidential token, plus totalSupply for the ERC-20.
21498
- * Default: `false`.
21499
- */
21500
- metadata?: boolean;
21501
- }
21502
- /**
21503
- * High-level interface for the on-chain token wrappers registry.
21504
- *
21505
- * Uses the configured {@link GenericProvider} to resolve the correct registry
21506
- * contract address for the current chain and exposes typed read helpers for
21507
- * every registry query. Results are cached in memory with a configurable TTL
21508
- * (default 24 hours).
21509
- *
21510
- * @example
21511
- * ```ts
21512
- * const registry = new WrappersRegistry({ provider });
21513
- *
21514
- * // Paginated listing
21515
- * const page1 = await registry.listPairs({ page: 1, pageSize: 20 });
21516
- *
21517
- * // Structured lookups
21518
- * const result = await registry.getConfidentialToken(erc20Address);
21519
- * if (result) console.log(result.confidentialTokenAddress);
21520
- *
21521
- * // Force refresh
21522
- * registry.refresh();
21523
- * ```
21524
- */
21525
- declare class WrappersRegistry {
21526
- #private;
21527
- /** Read-only chain access used for registry contract reads. */
21528
- readonly provider: GenericProvider;
21529
- constructor(config: WrappersRegistryConfig);
21530
- /**
21531
- * Synchronous lookup of the registry address for a given chain ID.
21532
- * Returns `undefined` if no address is configured for that chain.
21533
- */
21534
- getAddress(chainId: number): Address | undefined;
21535
- /**
21536
- * Force-invalidate the in-memory cache. The next call to any read method
21537
- * will fetch fresh data from the chain.
21538
- */
21539
- refresh(): void;
21540
- /**
21541
- * The cache TTL in milliseconds.
21542
- * Exposed so query option factories can set a matching `staleTime`.
21543
- */
21544
- get ttlMs(): number;
21545
- /**
21546
- * Resolve the registry contract address for the current chain.
21547
- *
21548
- * Priority: `registryAddresses[chainId]` \> built-in default.
21549
- *
21550
- * @returns The registry contract address for the connected chain.
21551
- * @throws if no address is configured for the chain. {@link ConfigurationError}
21552
- */
21553
- getRegistryAddress(): Promise<Address>;
21554
- /**
21555
- * List token wrapper pairs with page-based pagination.
21556
- *
21557
- * Internally maps to `getTokenConfidentialTokenPairsSlice` on-chain.
21558
- *
21559
- * @param options - Pagination and enrichment options.
21560
- * @returns A {@link PaginatedResult} of pairs.
21561
- *
21562
- * @example
21563
- * ```ts
21564
- * const result = await registry.listPairs({ page: 1, pageSize: 20 });
21565
- * console.log(`${result.total} pairs, showing page ${result.page}`);
21566
- *
21567
- * // With on-chain metadata
21568
- * const withMeta = await registry.listPairs({ metadata: true, pageSize: 10 });
21569
- * for (const pair of withMeta.items) {
21570
- * console.log(pair.underlying.symbol, "→", pair.confidential.symbol);
21571
- * }
21572
- * ```
21573
- */
21574
- listPairs(options: ListPairsOptions & {
21575
- metadata: true;
21576
- }): Promise<PaginatedResult<TokenWrapperPairWithMetadata>>;
21577
- /** Lists registered underlying/confidential token pairs; pass `{ metadata: true }` to include on-chain token metadata. */
21578
- listPairs(options?: ListPairsOptions): Promise<PaginatedResult<TokenWrapperPair>>;
21579
- /**
21580
- * Look up the confidential token for a given plain ERC-20 address.
21581
- *
21582
- * @param tokenAddress - The plain ERC-20 token address.
21583
- * @returns The lookup result, or `null` if the token has never been registered.
21584
- * **Note:** revoked tokens (registered then invalidated) return a non-null result
21585
- * with `isValid: false`. Check `result.isValid` explicitly rather than using
21586
- * `if (result)` to guard against processing revoked tokens.
21587
- *
21588
- * @example
21589
- * ```ts
21590
- * const result = await registry.getConfidentialToken(usdcAddress);
21591
- * if (result?.isValid) {
21592
- * console.log(result.confidentialTokenAddress);
21593
- * }
21594
- * ```
21595
- */
21596
- getConfidentialToken(tokenAddress: Address): Promise<{
21597
- confidentialTokenAddress: Address;
21598
- isValid: boolean;
21599
- } | null>;
21600
- /**
21601
- * Reverse lookup — find the plain ERC-20 for a given confidential token.
21602
- *
21603
- * @param confidentialTokenAddress - The confidential token address.
21604
- * @returns The lookup result, or `null` if no pair is registered.
21605
- *
21606
- * @example
21607
- * ```ts
21608
- * const result = await registry.getUnderlyingToken(cUsdcAddress);
21609
- * if (result) {
21610
- * console.log(result.tokenAddress, result.isValid);
21611
- * }
21612
- * ```
21613
- */
21614
- getUnderlyingToken(confidentialTokenAddress: Address): Promise<{
21615
- tokenAddress: Address;
21616
- isValid: boolean;
21617
- } | null>;
21618
- /**
21619
- * Fetch all token wrapper pairs from the registry.
21620
- *
21621
- * @returns All registered `TokenWrapperPair` entries.
21622
- */
21623
- getTokenPairs(): Promise<readonly TokenWrapperPair[]>;
21624
- /**
21625
- * Get the total number of token wrapper pairs.
21626
- *
21627
- * @returns The count as a bigint.
21628
- */
21629
- getTokenPairsLength(): Promise<bigint>;
21630
- /**
21631
- * Fetch a range of token wrapper pairs (paginated by index).
21632
- *
21633
- * @param fromIndex - Start index (inclusive).
21634
- * @param toIndex - End index (exclusive).
21635
- * @returns The slice of `TokenWrapperPair` entries.
21636
- */
21637
- getTokenPairsSlice(fromIndex: bigint, toIndex: bigint): Promise<readonly TokenWrapperPair[]>;
21638
- /**
21639
- * Fetch a single token wrapper pair by index.
21640
- *
21641
- * @param index - Zero-based pair index.
21642
- * @returns The `TokenWrapperPair` at that index.
21643
- */
21644
- getTokenPair(index: bigint): Promise<TokenWrapperPair>;
21645
- /**
21646
- * Look up the confidential token address for a given plain ERC-20 token.
21647
- *
21648
- * @param tokenAddress - The plain ERC-20 token address.
21649
- * @returns A tuple `[isValid, confidentialTokenAddress]`. `isValid` is `true` only for a
21650
- * registered, non-revoked wrapper. The address is the zero address when no pair is registered.
21651
- * A non-zero address with `isValid=false` means the wrapper was registered but later revoked.
21652
- */
21653
- getConfidentialTokenAddress(tokenAddress: Address): Promise<readonly [boolean, Address]>;
21654
- /**
21655
- * Reverse lookup — find the plain ERC-20 for a given confidential token.
21656
- *
21657
- * @param confidentialTokenAddress - The confidential token address.
21658
- * @returns A tuple `[isValid, tokenAddress]`. `isValid` is `true` only for a registered,
21659
- * non-revoked wrapper. The address is the zero address when no pair is registered.
21660
- * A non-zero address with `isValid=false` means the wrapper was registered but later revoked.
21661
- */
21662
- getTokenAddress(confidentialTokenAddress: Address): Promise<readonly [boolean, Address]>;
21663
- /**
21664
- * Check whether a confidential token is registered and valid.
21665
- *
21666
- * @param confidentialTokenAddress - The confidential token address to check.
21667
- * @returns `true` if the token is a known valid wrapper in the registry.
21668
- */
21669
- isConfidentialTokenValid(confidentialTokenAddress: Address): Promise<boolean>;
21670
- }
21671
- //#endregion
21672
- //#region src/query/wrapper-discovery.d.ts
21673
- /** Configuration for {@link wrapperDiscoveryQueryOptions}. */
21674
- interface WrapperDiscoveryQueryConfig {
21675
- /**
21676
- * Address of any confidential token you control.
21677
- * Used to scope the query cache key and to gate whether the query
21678
- * is enabled — it does not affect which wrapper the registry returns.
21679
- */
21680
- tokenAddress?: Address;
21681
- /**
21682
- * The ERC-20 token address to discover the confidential wrapper for.
21683
- * The registry is resolved automatically from chain config.
21684
- */
21685
- erc20Address?: Address;
21686
- /**
21687
- * The resolved registry contract address for the current chain.
21688
- * Included in the query key so that switching chains invalidates
21689
- * stale cached results. Pass `undefined` when the chain ID is not
21690
- * yet known — the query will be disabled.
21691
- */
21692
- registryAddress?: Address;
21693
- /** Additional TanStack Query options merged into the generated query (e.g. `staleTime`, `enabled`). */
21694
- query?: Record<string, unknown>;
21695
- }
21696
- /** Builds TanStack Query options for discovering the confidential wrapper address for a given ERC-20 token (resolves to `null` when none is registered). */
21697
- declare function wrapperDiscoveryQueryOptions(registry: WrappersRegistry, config: WrapperDiscoveryQueryConfig): QueryFactoryOptions<Address | null, Error, Address | null, ReturnType<typeof zamaQueryKeys.wrapperDiscovery.token>>;
21698
- //#endregion
21699
- //#region src/query/underlying-allowance.d.ts
21700
- /** Configuration for {@link underlyingAllowanceQueryOptions}. */
21701
- interface UnderlyingAllowanceQueryConfig {
21702
- /** Owner whose underlying-token allowance to read; the query stays disabled until provided. */
21703
- owner?: Address;
21704
- /** Additional TanStack Query options merged into the generated query (e.g. `staleTime`, `enabled`). */
21705
- query?: Record<string, unknown>;
21706
- }
21707
- /** Builds TanStack Query options for reading the ERC-20 allowance the owner has granted a confidential wrapper on its underlying token. */
21708
- declare function underlyingAllowanceQueryOptions(sdk: ZamaSDK, tokenAddress: Address, config: UnderlyingAllowanceQueryConfig): QueryFactoryOptions<bigint, Error, bigint, ReturnType<typeof zamaQueryKeys.underlyingAllowance.scope>>;
21709
- //#endregion
21710
- //#region src/query/pending-unshield.d.ts
21711
- /** Configuration for {@link pendingUnshieldQueryOptions}. */
21712
- interface PendingUnshieldQueryConfig {
21713
- /** Additional TanStack Query options merged into the generated query (e.g. `staleTime`, `enabled`). */
21714
- query?: Record<string, unknown>;
21715
- }
21716
- /**
21717
- * Query options for reading the unwrap tx hash of an unshield that was
21718
- * interrupted between its two phases (returns `null` if none is pending).
21719
- *
21720
- * Backed by {@link ZamaSDK} storage via `WrappedToken.getPendingUnshield()`.
21721
- * `staleTime: 0` so the value reflects storage on mount; the unshield/unwrap
21722
- * mutations also invalidate this key on success.
21723
- */
21724
- declare function pendingUnshieldQueryOptions(sdk: ZamaSDK, tokenAddress: Address, config?: PendingUnshieldQueryConfig): QueryFactoryOptions<Hex | null, Error, Hex | null, ReturnType<typeof zamaQueryKeys.pendingUnshield.token>>;
21725
- //#endregion
21726
- //#region src/query/confidential-is-operator.d.ts
21727
- /** Configuration for {@link confidentialIsOperatorQueryOptions}. */
21728
- interface ConfidentialIsOperatorQueryConfig {
21729
- /** Token holder whose operator authorization to check; the query stays disabled until provided. */
21730
- holder?: Address;
21731
- /** Spender address to check for operator authorization; the query stays disabled until provided. */
21732
- spender?: Address;
21733
- /** Additional TanStack Query options merged into the generated query (e.g. `staleTime`, `enabled`). */
21734
- query?: Record<string, unknown>;
21735
- }
21736
- /** Builds TanStack Query options for reading whether a spender is an authorized operator of a holder on a confidential token. */
21737
- declare function confidentialIsOperatorQueryOptions(sdk: ZamaSDK, tokenAddress: Address | undefined, config: ConfidentialIsOperatorQueryConfig): QueryFactoryOptions<boolean, Error, boolean, ReturnType<typeof zamaQueryKeys.confidentialIsOperator.scope>>;
21738
- //#endregion
21739
- //#region src/token/token.d.ts
21740
- /** Options for {@link Token.batchDecryptBalancesAs}. */
21741
- interface BatchDecryptAsOptions {
21742
- /** The address of the account that delegated decryption rights. */
21743
- delegatorAddress: Address;
21744
- /** Pre-fetched encrypted values. When omitted, they are fetched from the chain. */
21745
- encryptedValues?: EncryptedValue[];
21746
- /**
21747
- * The account whose on-chain balance to read. Defaults to the delegator
21748
- * address, which is the common case (the delegator grants permission to
21749
- * decrypt their own balance). Only set this when the account differs
21750
- * from the delegator.
21751
- *
21752
- * Matches the `account` parameter of `confidentialBalanceOf(account)` on-chain.
21753
- */
21754
- accountAddress?: Address;
21755
- /** Maximum number of concurrent decrypt calls. Default: 10. */
21756
- maxConcurrency?: number;
21757
- /** Called when decryption fails for a single token. Return a fallback bigint. */
21758
- onError?: (error: Error, address: Address) => bigint;
21759
- }
21760
- /** Result of {@link Token.batchBalancesOf}. */
21761
- interface BatchBalancesResult {
21762
- /** Successfully decrypted balances, keyed by token address. */
21763
- results: Map<Address, bigint>;
21764
- /** Per-token errors for tokens that failed to decrypt. */
21765
- errors: Map<Address, ZamaError>;
21766
- }
21767
- /**
21768
- * High-level interface for an ERC-7984 confidential token.
21769
- * Hides FHE complexity (encryption, decryption, EIP-712 signing) behind
21770
- * familiar ERC-20-like methods.
21771
- *
21772
- * For ERC-7984 wrappers (shield/unshield), use {@link WrappedToken} instead —
21773
- * it extends `Token` with wrapper-specific operations.
21774
- *
21775
- * Decryption, credentials, caching, and event emission are handled by the
21776
- * owning {@link ZamaSDK} — this class only exposes token-scoped helpers
21777
- * that delegate to `sdk.decryption.decryptValues` and `sdk.permits.grantPermit`.
20778
+ * For ERC-7984 wrappers (shield/unshield), use {@link WrappedToken} instead —
20779
+ * it extends `Token` with wrapper-specific operations.
20780
+ *
20781
+ * Decryption, credentials, caching, and event emission are handled by the
20782
+ * owning {@link ZamaSDK} — this class only exposes token-scoped helpers
20783
+ * that delegate to `sdk.decryption.decryptValues` and `sdk.permits.grantPermit`.
21778
20784
  */
21779
20785
  declare class Token {
21780
20786
  #private;
@@ -22000,631 +21006,869 @@ declare class Token {
22000
21006
  * );
22001
21007
  * ```
22002
21008
  */
22003
- confidentialTransferFromAndCall(from: Address, to: Address, amount: bigint, data: Hex, callbacks?: TransferCallbacks): Promise<TransactionResult>;
21009
+ confidentialTransferFromAndCall(from: Address, to: Address, amount: bigint, data: Hex, callbacks?: TransferCallbacks): Promise<TransactionResult>;
21010
+ /**
21011
+ * Set operator approval for the confidential token.
21012
+ * Defaults to 1 hour from now if `until` is not specified.
21013
+ *
21014
+ * @param operator - The address to set as an operator.
21015
+ * @param until - Optional Unix timestamp for approval expiry. Defaults to now + 1 hour.
21016
+ * @returns The transaction hash and mined receipt.
21017
+ *
21018
+ * @example
21019
+ * ```ts
21020
+ * const txHash = await token.setOperator("0xOperator");
21021
+ * ```
21022
+ */
21023
+ setOperator(operator: Address, until?: number): Promise<TransactionResult>;
21024
+ /**
21025
+ * Check if a spender is an approved operator for a given holder.
21026
+ *
21027
+ * @param holder - The token holder address.
21028
+ * @param spender - The address to check operator approval for.
21029
+ * @returns `true` if the spender is an approved operator for the holder.
21030
+ *
21031
+ * @example
21032
+ * ```ts
21033
+ * if (await token.isOperator("0xHolder", "0xSpender")) {
21034
+ * // spender can call transferFrom on behalf of holder
21035
+ * }
21036
+ * ```
21037
+ */
21038
+ isOperator(holder: Address, spender: Address): Promise<boolean>;
21039
+ /** Verify all tokens share the same SDK instance and return it. */
21040
+ private static assertSameSdk;
21041
+ }
21042
+ //#endregion
21043
+ //#region src/token/wrapped-token.d.ts
21044
+ /**
21045
+ * Confidential ERC-20 wrapper (ERC-7984 ERC20Wrapper).
21046
+ *
21047
+ * Extends {@link Token} with wrapper-specific operations:
21048
+ * - `shield` / `unshield` — convert between the underlying ERC-20 and confidential balance
21049
+ * - `unwrap` / `unwrapAll` / `finalizeUnwrap` — low-level two-phase primitives
21050
+ * - `underlying` / `allowance` — wrapper reads
21051
+ *
21052
+ * `WrappedToken.address` is the wrapper contract address itself — the wrapper
21053
+ * IS the confidential token.
21054
+ */
21055
+ declare class WrappedToken extends Token {
21056
+ #private;
21057
+ /**
21058
+ * Read the underlying ERC-20 token address from the wrapper contract.
21059
+ *
21060
+ * @returns The underlying ERC-20 token address.
21061
+ */
21062
+ underlying(): Promise<Address>;
21063
+ /**
21064
+ * Check whether the underlying ERC-20 supports ERC-1363 (payable token).
21065
+ * Result is cached per WrappedToken instance (negative results included):
21066
+ * once we know an underlying does not support ERC-1363, subsequent shields
21067
+ * go straight to the `approve` + `wrap` path without re-probing.
21068
+ */
21069
+ isPayable(): Promise<boolean>;
21070
+ /**
21071
+ * Read the ERC-20 allowance granted by `owner` to this wrapper for the
21072
+ * underlying token.
21073
+ *
21074
+ * @param owner - The owner address whose allowance to read.
21075
+ * @returns The current allowance as a bigint.
21076
+ */
21077
+ allowance(owner: Address): Promise<bigint>;
21078
+ /**
21079
+ * Shield public ERC-20 tokens into confidential tokens.
21080
+ *
21081
+ * The execution path is decided automatically by ERC-165 introspection on
21082
+ * the underlying ERC-20:
21083
+ * - **`transferAndCall`** (single tx): when the underlying supports
21084
+ * ERC-1363, no approval is required — the wrapper's `onTransferReceived`
21085
+ * callback mints confidential tokens directly. `approvalStrategy` is
21086
+ * **ignored** on this path. See {@link ShieldPath}.
21087
+ * - **`approveAndWrap`** (two-tx fallback): otherwise, an `approve` is
21088
+ * followed by a `wrap`. Approval is controlled by `approvalStrategy`
21089
+ * (`"exact"` by default, `"max"` for unlimited, `"skip"` to opt out).
21090
+ *
21091
+ * The ERC-20 balance is validated before submitting (public read, no
21092
+ * signing required) so the call works for all wallet types, including
21093
+ * smart wallets.
21094
+ *
21095
+ * @param amount - The plaintext amount to shield.
21096
+ * @param options - Optional: `approvalStrategy`, `to`, callbacks.
21097
+ * @returns The transaction hash and mined receipt.
21098
+ * @throws if signer and provider are on different chains. {@link ChainMismatchError}
21099
+ * @throws if the ERC-20 balance is less than `amount`. {@link InsufficientERC20BalanceError}
21100
+ * @throws if the ERC-20 approval or shield transaction reverts. {@link TransactionRevertedError}
21101
+ *
21102
+ * @example
21103
+ * ```ts
21104
+ * const txHash = await wrappedToken.shield(1000n);
21105
+ * ```
21106
+ */
21107
+ shield(amount: bigint, options?: ShieldOptions): Promise<TransactionResult>;
21108
+ /**
21109
+ * Wrap already-approved underlying ERC-20 into confidential tokens.
21110
+ *
21111
+ * Escape hatch for splitting shield across two signatures: call
21112
+ * {@link approveUnderlying} first, then `wrap`. Most callers should use
21113
+ * {@link shield}, which routes and orchestrates approval automatically.
21114
+ *
21115
+ * Validates the ERC-20 balance and the allowance granted to this wrapper
21116
+ * (public reads, no signing) and fails early with a clear error.
21117
+ *
21118
+ * @param amount - The plaintext amount to wrap.
21119
+ * @param options - Optional `to` recipient and `onWrapSubmitted` callback.
21120
+ * @returns The transaction hash and mined receipt.
21121
+ * @throws if reading the ERC-20 balance or allowance fails. {@link ERC20ReadFailedError}
21122
+ * @throws if the ERC-20 balance is less than `amount`. {@link InsufficientERC20BalanceError}
21123
+ * @throws if the allowance granted to the wrapper is less than `amount`. {@link InsufficientAllowanceError}
21124
+ *
21125
+ * @example
21126
+ * ```ts
21127
+ * await wrappedToken.approveUnderlying(1000n);
21128
+ * await wrappedToken.wrap(1000n);
21129
+ * ```
21130
+ */
21131
+ wrap(amount: bigint, options?: WrapOptions): Promise<TransactionResult>;
21132
+ /**
21133
+ * Approve this wrapper contract to spend the underlying ERC-20.
21134
+ * Defaults to max uint256. Resets to zero first if there's an existing
21135
+ * non-zero allowance (required by tokens like USDT).
21136
+ *
21137
+ * @param amount - Optional approval amount. Defaults to max uint256.
21138
+ * @returns The transaction hash and mined receipt.
21139
+ *
21140
+ * @example
21141
+ * ```ts
21142
+ * await wrappedToken.approveUnderlying(); // max approval
21143
+ * await wrappedToken.approveUnderlying(1000n); // exact amount
21144
+ * ```
21145
+ */
21146
+ approveUnderlying(amount?: bigint): Promise<TransactionResult>;
21147
+ /**
21148
+ * Unshield a specific amount and finalize in one call.
21149
+ * Orchestrates: unshield → wait for receipt → parse event → finalize.
21150
+ *
21151
+ * By default, the SDK validates the confidential balance before submitting.
21152
+ * Set `skipBalanceCheck: true` to bypass this validation (e.g. for smart wallets).
21153
+ *
21154
+ * @param amount - The plaintext amount to unshield.
21155
+ * @param options - Optional: `skipBalanceCheck` (default `false`), callbacks.
21156
+ * @returns The finalize transaction hash and mined receipt.
21157
+ *
21158
+ * @example
21159
+ * ```ts
21160
+ * const txHash = await wrappedToken.unshield(500n);
21161
+ * ```
21162
+ */
21163
+ unshield(amount: bigint, options?: UnshieldOptions): Promise<TransactionResult>;
21164
+ /**
21165
+ * Unshield the entire balance and finalize in one call.
21166
+ * Orchestrates: unshieldAll → wait for receipt → parse event → finalize.
21167
+ *
21168
+ * @param callbacks - Optional progress callbacks for each phase.
21169
+ * @returns The finalize transaction hash and mined receipt.
21170
+ * @throws if the balance is zero. {@link DecryptionFailedError}
21171
+ *
21172
+ * @example
21173
+ * ```ts
21174
+ * const txHash = await wrappedToken.unshieldAll();
21175
+ * ```
21176
+ */
21177
+ unshieldAll(callbacks?: UnshieldCallbacks): Promise<TransactionResult>;
21178
+ /**
21179
+ * Resume an in-progress unshield from an existing unwrap tx hash.
21180
+ * Useful when the user already submitted the unwrap but the finalize step
21181
+ * was interrupted (e.g. page reload, network error).
21182
+ *
21183
+ * @param unwrapTxHash - The transaction hash of the previously submitted unwrap.
21184
+ * @param callbacks - Optional progress callbacks.
21185
+ * @returns The finalize transaction hash and mined receipt.
21186
+ * @throws if the unwrap request was already finalized on-chain; the persisted
21187
+ * pending-unshield state is cleared first. {@link UnshieldAlreadyFinalizedError}
21188
+ *
21189
+ * @example
21190
+ * ```ts
21191
+ * const txHash = await wrappedToken.resumeUnshield(previousUnwrapTxHash);
21192
+ * ```
21193
+ */
21194
+ resumeUnshield(unwrapTxHash: Hex, callbacks?: UnshieldCallbacks): Promise<TransactionResult>;
21195
+ /**
21196
+ * Return the unwrap tx hash of an unshield that was interrupted between its
21197
+ * two phases, or `null` if none is pending for this wrapper.
21198
+ *
21199
+ * The SDK persists this automatically when {@link unshield}/{@link unshieldAll}
21200
+ * submit phase 1, and clears it once phase 2 finalizes. Use the returned hash
21201
+ * to surface a "resume" affordance, then pass it to {@link resumeUnshield}.
21202
+ * Resuming is intentionally caller-driven — auto-resuming on load would fire a
21203
+ * wallet transaction unprompted.
21204
+ *
21205
+ * The pointer is verified on-chain before it is reported: if the unwrap
21206
+ * request was already finalized (e.g. the tab closed before the SDK could
21207
+ * clear storage), the stale pointer is cleared and `null` is returned. When
21208
+ * the verification read fails, the pointer is returned unverified: a
21209
+ * network error never deletes recovery state.
21210
+ *
21211
+ * @returns The pending unwrap tx hash, or `null`.
21212
+ *
21213
+ * @example
21214
+ * ```ts
21215
+ * const unwrapTxHash = await wrappedToken.getPendingUnshield();
21216
+ * if (unwrapTxHash) await wrappedToken.resumeUnshield(unwrapTxHash);
21217
+ * ```
21218
+ */
21219
+ getPendingUnshield(): Promise<Hex | null>;
21220
+ /**
21221
+ * Request an unwrap for a specific amount. Encrypts the amount first.
21222
+ * Pass the result's `unwrapRequestId` to {@link finalizeUnwrap} once the
21223
+ * request is processed on-chain.
21224
+ *
21225
+ * @param amount - The plaintext amount to unwrap (encrypted automatically).
21226
+ * @returns The tx hash, mined receipt, and the `unwrapRequestId` for `finalizeUnwrap`.
21227
+ *
21228
+ * @example
21229
+ * ```ts
21230
+ * const result = await wrappedToken.unwrap(500n);
21231
+ * await wrappedToken.finalizeUnwrap(result.unwrapRequestId);
21232
+ * ```
21233
+ */
21234
+ unwrap(amount: bigint): Promise<UnwrapResult>;
21235
+ /**
21236
+ * Request an unwrap for the entire confidential balance.
21237
+ * Uses the on-chain encrypted balance directly (no encryption needed).
21238
+ * Throws if the balance is zero.
21239
+ *
21240
+ * @returns The tx hash, mined receipt, and the `unwrapRequestId` for `finalizeUnwrap`.
21241
+ * @throws if the balance is zero. {@link DecryptionFailedError}
21242
+ *
21243
+ * @example
21244
+ * ```ts
21245
+ * const result = await wrappedToken.unwrapAll();
21246
+ * await wrappedToken.finalizeUnwrap(result.unwrapRequestId);
21247
+ * ```
21248
+ */
21249
+ unwrapAll(): Promise<UnwrapResult>;
22004
21250
  /**
22005
- * Set operator approval for the confidential token.
22006
- * Defaults to 1 hour from now if `until` is not specified.
21251
+ * Complete an unwrap by fetching the public decryption proof and finalizing.
21252
+ * Call this once the unwrap request has been processed on-chain.
22007
21253
  *
22008
- * @param operator - The address to set as an operator.
22009
- * @param until - Optional Unix timestamp for approval expiry. Defaults to now + 1 hour.
21254
+ * @param unwrapRequestId - The `unwrapRequestId` from an {@link UnwrapResult}
21255
+ * (`result.unwrapRequestId`) returned by {@link unwrap} / {@link unwrapAll},
21256
+ * or one decoded from an `UnwrapRequested` event (e.g. when finalizing
21257
+ * across sessions).
22010
21258
  * @returns The transaction hash and mined receipt.
22011
21259
  *
22012
21260
  * @example
22013
21261
  * ```ts
22014
- * const txHash = await token.setOperator("0xOperator");
21262
+ * const { unwrapRequestId } = await wrappedToken.unwrap(500n);
21263
+ * await wrappedToken.finalizeUnwrap(unwrapRequestId);
22015
21264
  * ```
22016
21265
  */
22017
- setOperator(operator: Address, until?: number): Promise<TransactionResult>;
21266
+ finalizeUnwrap(unwrapRequestId: EncryptedValue): Promise<TransactionResult>;
21267
+ }
21268
+ //#endregion
21269
+ //#region src/wrappers-registry.d.ts
21270
+ /**
21271
+ * Default wrappers registry addresses for known chains.
21272
+ * Only includes chains where a registry is deployed (excludes Hardhat).
21273
+ *
21274
+ * @deprecated Read `registryAddress` from the chain presets instead (e.g.
21275
+ * `sepolia.registryAddress`). Will be removed in the next major version.
21276
+ */
21277
+ declare const DefaultRegistryAddresses: Record<number, Address>;
21278
+ /** Configuration for {@link WrappersRegistry}. */
21279
+ interface WrappersRegistryConfig {
21280
+ /** Read-only chain provider used for every registry lookup. */
21281
+ provider: GenericProvider;
22018
21282
  /**
22019
- * Check if a spender is an approved operator for a given holder.
22020
- *
22021
- * @param holder - The token holder address.
22022
- * @param spender - The address to check operator approval for.
22023
- * @returns `true` if the spender is an approved operator for the holder.
21283
+ * Per-chain registry address overrides, merged on top of
21284
+ * {@link DefaultRegistryAddresses}. Use this to supply a registry
21285
+ * address for custom or local chains (e.g. Hardhat).
22024
21286
  *
22025
21287
  * @example
22026
21288
  * ```ts
22027
- * if (await token.isOperator("0xHolder", "0xSpender")) {
22028
- * // spender can call transferFrom on behalf of holder
22029
- * }
21289
+ * new WrappersRegistry({
21290
+ * provider,
21291
+ * registryAddresses: { [31337]: "0xYourHardhatRegistry" },
21292
+ * });
22030
21293
  * ```
22031
21294
  */
22032
- isOperator(holder: Address, spender: Address): Promise<boolean>;
22033
- /** Verify all tokens share the same SDK instance and return it. */
22034
- private static assertSameSdk;
21295
+ registryAddresses?: Record<number, Address>;
21296
+ /**
21297
+ * How long cached registry results remain valid, in seconds.
21298
+ * Default: `86400` (24 hours).
21299
+ */
21300
+ registryTTL?: number;
21301
+ }
21302
+ /** Options for {@link WrappersRegistry.listPairs}. */
21303
+ interface ListPairsOptions {
21304
+ /** Page number (1-indexed). Default: `1`. */
21305
+ page?: number;
21306
+ /** Number of items per page. Default: `100`. */
21307
+ pageSize?: number;
21308
+ /**
21309
+ * When `true`, fetches on-chain metadata (name, symbol, decimals) for both
21310
+ * the ERC-20 and confidential token, plus totalSupply for the ERC-20.
21311
+ * Default: `false`.
21312
+ */
21313
+ metadata?: boolean;
22035
21314
  }
22036
- //#endregion
22037
- //#region src/token/wrapped-token.d.ts
22038
21315
  /**
22039
- * Confidential ERC-20 wrapper (ERC-7984 ERC20Wrapper).
21316
+ * High-level interface for the on-chain token wrappers registry.
22040
21317
  *
22041
- * Extends {@link Token} with wrapper-specific operations:
22042
- * - `shield` / `unshield` — convert between the underlying ERC-20 and confidential balance
22043
- * - `unwrap` / `unwrapAll` / `finalizeUnwrap` — low-level two-phase primitives
22044
- * - `underlying` / `allowance` — wrapper reads
21318
+ * Uses the configured {@link GenericProvider} to resolve the correct registry
21319
+ * contract address for the current chain and exposes typed read helpers for
21320
+ * every registry query. Results are cached in memory with a configurable TTL
21321
+ * (default 24 hours).
22045
21322
  *
22046
- * `WrappedToken.address` is the wrapper contract address itself — the wrapper
22047
- * IS the confidential token.
21323
+ * @example
21324
+ * ```ts
21325
+ * const registry = new WrappersRegistry({ provider });
21326
+ *
21327
+ * // Paginated listing
21328
+ * const page1 = await registry.listPairs({ page: 1, pageSize: 20 });
21329
+ *
21330
+ * // Structured lookups
21331
+ * const result = await registry.getConfidentialToken(erc20Address);
21332
+ * if (result) console.log(result.confidentialTokenAddress);
21333
+ *
21334
+ * // Force refresh
21335
+ * registry.refresh();
21336
+ * ```
22048
21337
  */
22049
- declare class WrappedToken extends Token {
21338
+ declare class WrappersRegistry {
22050
21339
  #private;
21340
+ /** Read-only chain access used for registry contract reads. */
21341
+ readonly provider: GenericProvider;
21342
+ constructor(config: WrappersRegistryConfig);
22051
21343
  /**
22052
- * Read the underlying ERC-20 token address from the wrapper contract.
22053
- *
22054
- * @returns The underlying ERC-20 token address.
21344
+ * Synchronous lookup of the registry address for a given chain ID.
21345
+ * Returns `undefined` if no address is configured for that chain.
22055
21346
  */
22056
- underlying(): Promise<Address>;
21347
+ getAddress(chainId: number): Address | undefined;
22057
21348
  /**
22058
- * Check whether the underlying ERC-20 supports ERC-1363 (payable token).
22059
- * Result is cached per WrappedToken instance (negative results included):
22060
- * once we know an underlying does not support ERC-1363, subsequent shields
22061
- * go straight to the `approve` + `wrap` path without re-probing.
21349
+ * Force-invalidate the in-memory cache. The next call to any read method
21350
+ * will fetch fresh data from the chain.
22062
21351
  */
22063
- isPayable(): Promise<boolean>;
21352
+ refresh(): void;
22064
21353
  /**
22065
- * Read the ERC-20 allowance granted by `owner` to this wrapper for the
22066
- * underlying token.
22067
- *
22068
- * @param owner - The owner address whose allowance to read.
22069
- * @returns The current allowance as a bigint.
21354
+ * The cache TTL in milliseconds.
21355
+ * Exposed so query option factories can set a matching `staleTime`.
22070
21356
  */
22071
- allowance(owner: Address): Promise<bigint>;
21357
+ get ttlMs(): number;
22072
21358
  /**
22073
- * Shield public ERC-20 tokens into confidential tokens.
21359
+ * Resolve the registry contract address for the current chain.
22074
21360
  *
22075
- * The execution path is decided automatically by ERC-165 introspection on
22076
- * the underlying ERC-20:
22077
- * - **`transferAndCall`** (single tx): when the underlying supports
22078
- * ERC-1363, no approval is required — the wrapper's `onTransferReceived`
22079
- * callback mints confidential tokens directly. `approvalStrategy` is
22080
- * **ignored** on this path. See {@link ShieldPath}.
22081
- * - **`approveAndWrap`** (two-tx fallback): otherwise, an `approve` is
22082
- * followed by a `wrap`. Approval is controlled by `approvalStrategy`
22083
- * (`"exact"` by default, `"max"` for unlimited, `"skip"` to opt out).
21361
+ * Priority: `registryAddresses[chainId]` \> built-in default.
22084
21362
  *
22085
- * The ERC-20 balance is validated before submitting (public read, no
22086
- * signing required) so the call works for all wallet types, including
22087
- * smart wallets.
21363
+ * @returns The registry contract address for the connected chain.
21364
+ * @throws if no address is configured for the chain. {@link ConfigurationError}
21365
+ */
21366
+ getRegistryAddress(): Promise<Address>;
21367
+ /**
21368
+ * List token wrapper pairs with page-based pagination.
22088
21369
  *
22089
- * @param amount - The plaintext amount to shield.
22090
- * @param options - Optional: `approvalStrategy`, `to`, callbacks.
22091
- * @returns The transaction hash and mined receipt.
22092
- * @throws if signer and provider are on different chains. {@link ChainMismatchError}
22093
- * @throws if the ERC-20 balance is less than `amount`. {@link InsufficientERC20BalanceError}
22094
- * @throws if the ERC-20 approval or shield transaction reverts. {@link TransactionRevertedError}
21370
+ * Internally maps to `getTokenConfidentialTokenPairsSlice` on-chain.
21371
+ *
21372
+ * @param options - Pagination and enrichment options.
21373
+ * @returns A {@link PaginatedResult} of pairs.
22095
21374
  *
22096
21375
  * @example
22097
21376
  * ```ts
22098
- * const txHash = await wrappedToken.shield(1000n);
21377
+ * const result = await registry.listPairs({ page: 1, pageSize: 20 });
21378
+ * console.log(`${result.total} pairs, showing page ${result.page}`);
21379
+ *
21380
+ * // With on-chain metadata
21381
+ * const withMeta = await registry.listPairs({ metadata: true, pageSize: 10 });
21382
+ * for (const pair of withMeta.items) {
21383
+ * console.log(pair.underlying.symbol, "→", pair.confidential.symbol);
21384
+ * }
22099
21385
  * ```
22100
21386
  */
22101
- shield(amount: bigint, options?: ShieldOptions): Promise<TransactionResult>;
21387
+ listPairs(options: ListPairsOptions & {
21388
+ metadata: true;
21389
+ }): Promise<PaginatedResult<TokenWrapperPairWithMetadata>>;
21390
+ /** Lists registered underlying/confidential token pairs; pass `{ metadata: true }` to include on-chain token metadata. */
21391
+ listPairs(options?: ListPairsOptions): Promise<PaginatedResult<TokenWrapperPair>>;
22102
21392
  /**
22103
- * Wrap already-approved underlying ERC-20 into confidential tokens.
21393
+ * Look up the confidential token for a given plain ERC-20 address.
22104
21394
  *
22105
- * Escape hatch for splitting shield across two signatures: call
22106
- * {@link approveUnderlying} first, then `wrap`. Most callers should use
22107
- * {@link shield}, which routes and orchestrates approval automatically.
21395
+ * @param tokenAddress - The plain ERC-20 token address.
21396
+ * @returns The lookup result, or `null` if the token has never been registered.
21397
+ * **Note:** revoked tokens (registered then invalidated) return a non-null result
21398
+ * with `isValid: false`. Check `result.isValid` explicitly rather than using
21399
+ * `if (result)` to guard against processing revoked tokens.
22108
21400
  *
22109
- * Validates the ERC-20 balance and the allowance granted to this wrapper
22110
- * (public reads, no signing) and fails early with a clear error.
21401
+ * @example
21402
+ * ```ts
21403
+ * const result = await registry.getConfidentialToken(usdcAddress);
21404
+ * if (result?.isValid) {
21405
+ * console.log(result.confidentialTokenAddress);
21406
+ * }
21407
+ * ```
21408
+ */
21409
+ getConfidentialToken(tokenAddress: Address): Promise<{
21410
+ confidentialTokenAddress: Address;
21411
+ isValid: boolean;
21412
+ } | null>;
21413
+ /**
21414
+ * Reverse lookup — find the plain ERC-20 for a given confidential token.
22111
21415
  *
22112
- * @param amount - The plaintext amount to wrap.
22113
- * @param options - Optional `to` recipient and `onWrapSubmitted` callback.
22114
- * @returns The transaction hash and mined receipt.
22115
- * @throws if reading the ERC-20 balance or allowance fails. {@link ERC20ReadFailedError}
22116
- * @throws if the ERC-20 balance is less than `amount`. {@link InsufficientERC20BalanceError}
22117
- * @throws if the allowance granted to the wrapper is less than `amount`. {@link InsufficientAllowanceError}
21416
+ * @param confidentialTokenAddress - The confidential token address.
21417
+ * @returns The lookup result, or `null` if no pair is registered.
22118
21418
  *
22119
21419
  * @example
22120
21420
  * ```ts
22121
- * await wrappedToken.approveUnderlying(1000n);
22122
- * await wrappedToken.wrap(1000n);
21421
+ * const result = await registry.getUnderlyingToken(cUsdcAddress);
21422
+ * if (result) {
21423
+ * console.log(result.tokenAddress, result.isValid);
21424
+ * }
22123
21425
  * ```
22124
21426
  */
22125
- wrap(amount: bigint, options?: WrapOptions): Promise<TransactionResult>;
21427
+ getUnderlyingToken(confidentialTokenAddress: Address): Promise<{
21428
+ tokenAddress: Address;
21429
+ isValid: boolean;
21430
+ } | null>;
21431
+ /**
21432
+ * Fetch all token wrapper pairs from the registry.
21433
+ *
21434
+ * @returns All registered `TokenWrapperPair` entries.
21435
+ */
21436
+ getTokenPairs(): Promise<readonly TokenWrapperPair[]>;
21437
+ /**
21438
+ * Get the total number of token wrapper pairs.
21439
+ *
21440
+ * @returns The count as a bigint.
21441
+ */
21442
+ getTokenPairsLength(): Promise<bigint>;
21443
+ /**
21444
+ * Fetch a range of token wrapper pairs (paginated by index).
21445
+ *
21446
+ * @param fromIndex - Start index (inclusive).
21447
+ * @param toIndex - End index (exclusive).
21448
+ * @returns The slice of `TokenWrapperPair` entries.
21449
+ */
21450
+ getTokenPairsSlice(fromIndex: bigint, toIndex: bigint): Promise<readonly TokenWrapperPair[]>;
21451
+ /**
21452
+ * Fetch a single token wrapper pair by index.
21453
+ *
21454
+ * @param index - Zero-based pair index.
21455
+ * @returns The `TokenWrapperPair` at that index.
21456
+ */
21457
+ getTokenPair(index: bigint): Promise<TokenWrapperPair>;
21458
+ /**
21459
+ * Look up the confidential token address for a given plain ERC-20 token.
21460
+ *
21461
+ * @param tokenAddress - The plain ERC-20 token address.
21462
+ * @returns A tuple `[isValid, confidentialTokenAddress]`. `isValid` is `true` only for a
21463
+ * registered, non-revoked wrapper. The address is the zero address when no pair is registered.
21464
+ * A non-zero address with `isValid=false` means the wrapper was registered but later revoked.
21465
+ */
21466
+ getConfidentialTokenAddress(tokenAddress: Address): Promise<readonly [boolean, Address]>;
22126
21467
  /**
22127
- * Approve this wrapper contract to spend the underlying ERC-20.
22128
- * Defaults to max uint256. Resets to zero first if there's an existing
22129
- * non-zero allowance (required by tokens like USDT).
22130
- *
22131
- * @param amount - Optional approval amount. Defaults to max uint256.
22132
- * @returns The transaction hash and mined receipt.
21468
+ * Reverse lookup — find the plain ERC-20 for a given confidential token.
22133
21469
  *
22134
- * @example
22135
- * ```ts
22136
- * await wrappedToken.approveUnderlying(); // max approval
22137
- * await wrappedToken.approveUnderlying(1000n); // exact amount
22138
- * ```
21470
+ * @param confidentialTokenAddress - The confidential token address.
21471
+ * @returns A tuple `[isValid, tokenAddress]`. `isValid` is `true` only for a registered,
21472
+ * non-revoked wrapper. The address is the zero address when no pair is registered.
21473
+ * A non-zero address with `isValid=false` means the wrapper was registered but later revoked.
22139
21474
  */
22140
- approveUnderlying(amount?: bigint): Promise<TransactionResult>;
21475
+ getTokenAddress(confidentialTokenAddress: Address): Promise<readonly [boolean, Address]>;
22141
21476
  /**
22142
- * Unshield a specific amount and finalize in one call.
22143
- * Orchestrates: unshield → wait for receipt → parse event → finalize.
22144
- *
22145
- * By default, the SDK validates the confidential balance before submitting.
22146
- * Set `skipBalanceCheck: true` to bypass this validation (e.g. for smart wallets).
22147
- *
22148
- * @param amount - The plaintext amount to unshield.
22149
- * @param options - Optional: `skipBalanceCheck` (default `false`), callbacks.
22150
- * @returns The finalize transaction hash and mined receipt.
21477
+ * Check whether a confidential token is registered and valid.
22151
21478
  *
22152
- * @example
22153
- * ```ts
22154
- * const txHash = await wrappedToken.unshield(500n);
22155
- * ```
21479
+ * @param confidentialTokenAddress - The confidential token address to check.
21480
+ * @returns `true` if the token is a known valid wrapper in the registry.
22156
21481
  */
22157
- unshield(amount: bigint, options?: UnshieldOptions): Promise<TransactionResult>;
21482
+ isConfidentialTokenValid(confidentialTokenAddress: Address): Promise<boolean>;
21483
+ }
21484
+ //#endregion
21485
+ //#region src/zama-sdk.d.ts
21486
+ /** Instance-level options that are deliberately not part of the shareable config object. */
21487
+ interface ZamaSDKOptions {
22158
21488
  /**
22159
- * Unshield the entire balance and finalize in one call.
22160
- * Orchestrates: unshieldAll → wait for receipt → parse event → finalize.
21489
+ * Encrypts the transport key pair's private half at rest. Headless environments only
21490
+ * (CLI tools, servers, agents); the constructor rejects it in browser contexts. Supply
21491
+ * at least 32 random bytes, or a string of at least 64 characters, from a CSPRNG or
21492
+ * secrets manager. The SDK copies a Uint8Array secret and zeroizes its own copy after
21493
+ * key import; it never touches your buffer, so zeroize yours after construction.
21494
+ * The SDK never persists or exposes this value. Omit for the default:
21495
+ * plaintext at rest, security delegated to the storage backend.
21496
+ */
21497
+ transportKeyPairDerivationSecret?: string | Uint8Array;
21498
+ }
21499
+ /**
21500
+ * ZamaSDK — composes a RelayerSDK with contract abstraction.
21501
+ *
21502
+ * Exposes domain namespaces for permits, delegations, decryption, offline
21503
+ * signing, and tokens, plus an unchanged registry, a top-level `encrypt`, and
21504
+ * lifecycle methods. Internal `*Service` classes do the work; the namespace
21505
+ * classes own SDK-level guards (chain alignment, signer requirement, event
21506
+ * emission).
21507
+ */
21508
+ declare class ZamaSDK {
21509
+ #private;
21510
+ /** Read-only chain access used for all contract reads. */
21511
+ readonly provider: GenericProvider;
21512
+ /** Wallet signer used for write operations, or `undefined` when the SDK is read-only. */
21513
+ readonly signer: GenericSigner | undefined;
21514
+ /** Storage for cached permits and transport key pairs. */
21515
+ readonly storage: GenericStorage;
21516
+ /**
21517
+ * A {@link WrappersRegistry} instance auto-configured for the current chain.
21518
+ * Uses built-in defaults from chain configs, and the SDK's `registryTTL` if configured.
21519
+ */
21520
+ readonly registry: WrappersRegistry;
21521
+ /** Permit and keypair management. */
21522
+ readonly permits: Permits;
21523
+ /** On-chain decryption-delegation management. */
21524
+ readonly delegations: Delegations;
21525
+ /** FHE decryption (user, delegated user, public). */
21526
+ readonly decryption: Decryption;
21527
+ /** Offline-signing pipeline: `prepare` builds an unsigned tx the caller signs and broadcasts out-of-process — for HSM, policy-engine, and cross-process custody workflows. */
21528
+ readonly offline: Offline;
21529
+ constructor(config: ZamaConfig, options?: ZamaSDKOptions);
21530
+ /**
21531
+ * The single-chain relayer backend for the **currently active** chain.
21532
+ */
21533
+ get relayer(): RelayerSDK;
21534
+ /**
21535
+ * Create a {@link WrappersRegistry} instance bound to this SDK's provider.
21536
+ * Inherits the registry addresses derived from the SDK's chain configs, so
21537
+ * the result is consistent with {@link ZamaSDK.registry}.
22161
21538
  *
22162
- * @param callbacks - Optional progress callbacks for each phase.
22163
- * @returns The finalize transaction hash and mined receipt.
22164
- * @throws if the balance is zero. {@link DecryptionFailedError}
21539
+ * @param registryAddresses - Optional per-chain overrides for this registry instance.
21540
+ * @returns A {@link WrappersRegistry} instance.
22165
21541
  *
22166
21542
  * @example
22167
21543
  * ```ts
22168
- * const txHash = await wrappedToken.unshieldAll();
21544
+ * // Addresses resolved from the SDK's chain configs
21545
+ * const registry = sdk.createWrappersRegistry();
21546
+ *
21547
+ * // Hardhat or custom chain — override per chain for this registry instance
21548
+ * const registry = sdk.createWrappersRegistry({ [31337]: "0xYourRegistry" });
21549
+ *
21550
+ * const pairs = await registry.getTokenPairs();
22169
21551
  * ```
22170
21552
  */
22171
- unshieldAll(callbacks?: UnshieldCallbacks): Promise<TransactionResult>;
21553
+ createWrappersRegistry(registryAddresses?: Record<number, Address>): WrappersRegistry;
22172
21554
  /**
22173
- * Resume an in-progress unshield from an existing unwrap tx hash.
22174
- * Useful when the user already submitted the unwrap but the finalize step
22175
- * was interrupted (e.g. page reload, network error).
21555
+ * Encrypt one or more plaintext values into FHE ciphertexts.
22176
21556
  *
22177
- * @param unwrapTxHash - The transaction hash of the previously submitted unwrap.
22178
- * @param callbacks - Optional progress callbacks.
22179
- * @returns The finalize transaction hash and mined receipt.
22180
- * @throws if the unwrap request was already finalized on-chain; the persisted
22181
- * pending-unshield state is cleared first. {@link UnshieldAlreadyFinalizedError}
21557
+ * @param params - Typed FHE inputs, the target contract address, and the user address.
21558
+ * @returns External encrypted values and the input proof for on-chain submission.
21559
+ * @throws if FHE encryption fails. {@link EncryptionFailedError}
22182
21560
  *
22183
21561
  * @example
22184
21562
  * ```ts
22185
- * const txHash = await wrappedToken.resumeUnshield(previousUnwrapTxHash);
21563
+ * const { encryptedValues, inputProof } = await sdk.encrypt({
21564
+ * values: [{ value: 1000n, type: "euint64" }],
21565
+ * contractAddress: "0xToken",
21566
+ * userAddress: "0xUser",
21567
+ * });
22186
21568
  * ```
22187
21569
  */
22188
- resumeUnshield(unwrapTxHash: Hex, callbacks?: UnshieldCallbacks): Promise<TransactionResult>;
21570
+ encrypt(params: EncryptParams, options?: Pick<FhevmRelayerOptions, "signal" | "timeout">): Promise<EncryptResult>;
22189
21571
  /**
22190
- * Return the unwrap tx hash of an unshield that was interrupted between its
22191
- * two phases, or `null` if none is pending for this wrapper.
22192
- *
22193
- * The SDK persists this automatically when {@link unshield}/{@link unshieldAll}
22194
- * submit phase 1, and clears it once phase 2 finalizes. Use the returned hash
22195
- * to surface a "resume" affordance, then pass it to {@link resumeUnshield}.
22196
- * Resuming is intentionally caller-driven — auto-resuming on load would fire a
22197
- * wallet transaction unprompted.
21572
+ * Create a high-level ERC-20-style interface for an ERC-7984 confidential token.
21573
+ * Supports balance queries, transfers, operator approvals, and decryption.
22198
21574
  *
22199
- * The pointer is verified on-chain before it is reported: if the unwrap
22200
- * request was already finalized (e.g. the tab closed before the SDK could
22201
- * clear storage), the stale pointer is cleared and `null` is returned. When
22202
- * the verification read fails, the pointer is returned unverified: a
22203
- * network error never deletes recovery state.
21575
+ * For ERC-7984 wrappers (shield/unshield/allowance), use {@link createWrappedToken} instead.
22204
21576
  *
22205
- * @returns The pending unwrap tx hash, or `null`.
21577
+ * @param address - The confidential token contract address.
21578
+ * @returns A {@link Token} instance bound to this SDK.
22206
21579
  *
22207
21580
  * @example
22208
21581
  * ```ts
22209
- * const unwrapTxHash = await wrappedToken.getPendingUnshield();
22210
- * if (unwrapTxHash) await wrappedToken.resumeUnshield(unwrapTxHash);
21582
+ * const token = sdk.createToken(cUSDT);
21583
+ * const balance = await token.balanceOf(userAddress);
22211
21584
  * ```
22212
21585
  */
22213
- getPendingUnshield(): Promise<Hex | null>;
21586
+ createToken(address: Address): Token;
22214
21587
  /**
22215
- * Request an unwrap for a specific amount. Encrypts the amount first.
22216
- * Pass the result's `unwrapRequestId` to {@link finalizeUnwrap} once the
22217
- * request is processed on-chain.
21588
+ * Create a high-level interface for an ERC-7984 wrapper token.
21589
+ * Extends {@link Token} with shield/unshield/allowance/finalize-unwrap operations.
22218
21590
  *
22219
- * @param amount - The plaintext amount to unwrap (encrypted automatically).
22220
- * @returns The tx hash, mined receipt, and the `unwrapRequestId` for `finalizeUnwrap`.
21591
+ * @param address - The wrapper token contract address.
21592
+ * @returns A {@link WrappedToken} instance bound to this SDK.
22221
21593
  *
22222
21594
  * @example
22223
21595
  * ```ts
22224
- * const result = await wrappedToken.unwrap(500n);
22225
- * await wrappedToken.finalizeUnwrap(result.unwrapRequestId);
21596
+ * const wrapped = sdk.createWrappedToken(wUSDT);
21597
+ * await wrapped.shield(1_000_000n);
22226
21598
  * ```
22227
21599
  */
22228
- unwrap(amount: bigint): Promise<UnwrapResult>;
21600
+ createWrappedToken(address: Address): WrappedToken;
22229
21601
  /**
22230
- * Request an unwrap for the entire confidential balance.
22231
- * Uses the on-chain encrypted balance directly (no encryption needed).
22232
- * Throws if the balance is zero.
22233
- *
22234
- * @returns The tx hash, mined receipt, and the `unwrapRequestId` for `finalizeUnwrap`.
22235
- * @throws if the balance is zero. {@link DecryptionFailedError}
22236
- *
22237
- * @example
22238
- * ```ts
22239
- * const result = await wrappedToken.unwrapAll();
22240
- * await wrappedToken.finalizeUnwrap(result.unwrapRequestId);
22241
- * ```
21602
+ * Release the SDK-owned resources: signer lifecycle subscriptions and the
21603
+ * relayer backend's resources, an encrypt worker included. Call this when the
21604
+ * SDK instance is being replaced (e.g. React provider unmount or a Strict Mode
21605
+ * remount). Work already in flight runs to completion, and the instance stays
21606
+ * usable: the next encryption spawns a fresh worker.
22242
21607
  */
22243
- unwrapAll(): Promise<UnwrapResult>;
21608
+ dispose(): void;
22244
21609
  /**
22245
- * Complete an unwrap by fetching the public decryption proof and finalizing.
22246
- * Call this once the unwrap request has been processed on-chain.
22247
- *
22248
- * @param unwrapRequestId - The `unwrapRequestId` from an {@link UnwrapResult}
22249
- * (`result.unwrapRequestId`) returned by {@link unwrap} / {@link unwrapAll},
22250
- * or one decoded from an `UnwrapRequested` event (e.g. when finalizing
22251
- * across sessions).
22252
- * @returns The transaction hash and mined receipt.
21610
+ * {@link dispose} plus the signer's own disposal. Call this when the SDK is no
21611
+ * longer needed (e.g. on shutdown). Work already in flight runs to completion.
21612
+ */
21613
+ terminate(): void;
21614
+ /**
21615
+ * Implements the TC39 Explicit Resource Management protocol.
21616
+ * Calls {@link terminate} when the `using` binding goes out of scope,
21617
+ * unsubscribing signer events and releasing the relayer's resources.
22253
21618
  *
22254
21619
  * @example
22255
21620
  * ```ts
22256
- * const { unwrapRequestId } = await wrappedToken.unwrap(500n);
22257
- * await wrappedToken.finalizeUnwrap(unwrapRequestId);
22258
- * ```
22259
- */
22260
- finalizeUnwrap(unwrapRequestId: EncryptedValue): Promise<TransactionResult>;
22261
- }
22262
- //#endregion
22263
- //#region src/query/confidential-balance.d.ts
22264
- /** Configuration for {@link confidentialBalanceQueryOptions}. */
22265
- interface ConfidentialBalanceQueryConfig {
22266
- /** Address of the confidential token to read the balance of. */
22267
- tokenAddress: Address;
22268
- /** Account whose confidential balance to read; the query stays disabled until provided. */
22269
- account?: Address;
22270
- /** Additional TanStack Query options merged into the generated query (e.g. `staleTime`, `enabled`). */
22271
- query?: Record<string, unknown>;
22272
- }
22273
- /** Query options for a single confidential token balance. Auto-gated on `account`. */
22274
- declare function confidentialBalanceQueryOptions(token: Token, config: ConfidentialBalanceQueryConfig, signerContext?: SignerQueryContext): QueryFactoryOptions<bigint, Error, bigint, ReturnType<typeof zamaQueryKeys.confidentialBalance.owner>>;
22275
- //#endregion
22276
- //#region src/query/confidential-balances.d.ts
22277
- /** Configuration for {@link confidentialBalancesQueryOptions}. */
22278
- interface ConfidentialBalancesQueryConfig {
22279
- /** Account whose confidential balances to read; the query stays disabled until provided. */
22280
- account?: Address;
22281
- /** Additional TanStack Query options merged into the generated query (e.g. `staleTime`, `enabled`). */
22282
- query?: Record<string, unknown>;
22283
- }
22284
- /** Builds TanStack Query options for reading the confidential balances of several tokens for one account in a single batch. */
22285
- declare function confidentialBalancesQueryOptions(tokens: Token[], config?: ConfidentialBalancesQueryConfig, signerContext?: SignerQueryContext): QueryFactoryOptions<BatchBalancesResult, Error, BatchBalancesResult, ReturnType<typeof zamaQueryKeys.confidentialBalances.tokens>>;
22286
- //#endregion
22287
- //#region src/query/wrappers-registry.d.ts
22288
- /** Base configuration shared by the wrappers-registry query option factories. */
22289
- interface WrappersRegistryQueryConfig {
22290
- /** Registry contract address for the current chain; used as a query key discriminator. */
22291
- registryAddress: Address | undefined;
22292
- /** Additional TanStack Query options merged into the generated query (e.g. `staleTime`, `enabled`). */
22293
- query?: Record<string, unknown>;
22294
- }
22295
- /** Builds TanStack Query options for reading all token wrapper pairs registered in the wrappers registry. */
22296
- declare function tokenPairsQueryOptions(sdk: ZamaSDK, config: WrappersRegistryQueryConfig): QueryFactoryOptions<readonly TokenWrapperPair[], Error, readonly TokenWrapperPair[], ReturnType<typeof zamaQueryKeys.wrappersRegistry.tokenPairs>>;
22297
- /** Configuration for {@link confidentialTokenAddressQueryOptions}. */
22298
- interface ConfidentialTokenAddressQueryConfig extends WrappersRegistryQueryConfig {
22299
- /** Underlying ERC-20 token address whose confidential counterpart to look up. */
22300
- tokenAddress?: Address;
22301
- }
22302
- /** Builds TanStack Query options for reading the confidential token address registered for a given underlying ERC-20 token. */
22303
- declare function confidentialTokenAddressQueryOptions(sdk: ZamaSDK, config: ConfidentialTokenAddressQueryConfig): QueryFactoryOptions<readonly [boolean, Address], Error, readonly [boolean, Address], ReturnType<typeof zamaQueryKeys.wrappersRegistry.confidentialTokenAddress>>;
22304
- /** Configuration for {@link tokenAddressQueryOptions}. */
22305
- interface TokenAddressQueryConfig extends WrappersRegistryQueryConfig {
22306
- /** Confidential token address whose underlying ERC-20 counterpart to look up. */
22307
- confidentialTokenAddress?: Address;
22308
- }
22309
- /** Builds TanStack Query options for reading the underlying ERC-20 token address registered for a given confidential token. */
22310
- declare function tokenAddressQueryOptions(sdk: ZamaSDK, config: TokenAddressQueryConfig): QueryFactoryOptions<readonly [boolean, Address], Error, readonly [boolean, Address], ReturnType<typeof zamaQueryKeys.wrappersRegistry.tokenAddress>>;
22311
- /** Builds TanStack Query options for reading the total number of token wrapper pairs in the registry. */
22312
- declare function tokenPairsLengthQueryOptions(sdk: ZamaSDK, config: WrappersRegistryQueryConfig): QueryFactoryOptions<bigint, Error, bigint, ReturnType<typeof zamaQueryKeys.wrappersRegistry.tokenPairsLength>>;
22313
- /** Configuration for {@link tokenPairsSliceQueryOptions}. */
22314
- interface TokenPairsSliceQueryConfig extends WrappersRegistryQueryConfig {
22315
- /** Zero-based index of the first pair in the slice (inclusive). */
22316
- fromIndex?: bigint;
22317
- /** Index bounding the end of the slice. */
22318
- toIndex?: bigint;
22319
- }
22320
- /** Builds TanStack Query options for reading a contiguous slice of the registry's token wrapper pairs. */
22321
- declare function tokenPairsSliceQueryOptions(sdk: ZamaSDK, config: TokenPairsSliceQueryConfig): QueryFactoryOptions<readonly TokenWrapperPair[], Error, readonly TokenWrapperPair[], ReturnType<typeof zamaQueryKeys.wrappersRegistry.tokenPairsSlice>>;
22322
- /** Configuration for {@link tokenPairQueryOptions}. */
22323
- interface TokenPairQueryConfig extends WrappersRegistryQueryConfig {
22324
- /** Zero-based index of the token wrapper pair to read. */
22325
- index?: bigint;
22326
- }
22327
- /** Builds TanStack Query options for reading a single token wrapper pair by its index in the registry. */
22328
- declare function tokenPairQueryOptions(sdk: ZamaSDK, config: TokenPairQueryConfig): QueryFactoryOptions<TokenWrapperPair, Error, TokenWrapperPair, ReturnType<typeof zamaQueryKeys.wrappersRegistry.tokenPair>>;
22329
- /** Configuration for {@link isConfidentialTokenValidQueryOptions}. */
22330
- interface IsConfidentialTokenValidQueryConfig extends WrappersRegistryQueryConfig {
22331
- /** Confidential token address to validate against the registry. */
22332
- confidentialTokenAddress?: Address;
22333
- }
22334
- /** Builds TanStack Query options for checking whether a confidential token is registered and valid in the registry. */
22335
- declare function isConfidentialTokenValidQueryOptions(sdk: ZamaSDK, config: IsConfidentialTokenValidQueryConfig): QueryFactoryOptions<boolean, Error, boolean, ReturnType<typeof zamaQueryKeys.wrappersRegistry.isConfidentialTokenValid>>;
22336
- /** Configuration for {@link listPairsQueryOptions}. */
22337
- interface ListPairsQueryConfig {
22338
- /**
22339
- * The registry address for this chain — used as a query key discriminator.
22340
- * The registry instance already knows how to resolve the address for the
22341
- * current chain; this field just keeps the TanStack Query cache isolated
22342
- * per registry contract.
22343
- */
22344
- registryAddress: Address | undefined;
22345
- /** 1-based page number to fetch; defaults to `1`. */
22346
- page?: number;
22347
- /** Number of pairs per page; defaults to `100`. */
22348
- pageSize?: number;
22349
- /** When `true`, resolve each pair's on-chain metadata; defaults to `false`. */
22350
- metadata?: boolean;
22351
- /** Additional TanStack Query options merged into the generated query (e.g. `staleTime`, `enabled`). */
22352
- query?: Record<string, unknown>;
22353
- }
22354
- /**
22355
- * Query options for paginated listing of token wrapper pairs.
22356
- *
22357
- * Accepts a {@link WrappersRegistry} instance rather than a raw provider so that the
22358
- * class-level TTL cache is shared across multiple `queryFn` executions. Pass
22359
- * `sdk.registry` (the ZamaSDK lazy singleton) to ensure a single shared cache.
22360
- */
22361
- declare function listPairsQueryOptions(registry: WrappersRegistry, config: ListPairsQueryConfig): QueryFactoryOptions<PaginatedResult<TokenWrapperPair | TokenWrapperPairWithMetadata>, Error, PaginatedResult<TokenWrapperPair | TokenWrapperPairWithMetadata>, ReturnType<typeof zamaQueryKeys.wrappersRegistry.listPairs>>;
22362
- //#endregion
22363
- //#region src/query/shield.d.ts
22364
- /** Variables for {@link shieldMutationOptions}. */
22365
- interface ShieldParams extends ShieldOptions {
22366
- /** Amount of the public ERC-20 to shield, in the token's base units. */
22367
- amount: bigint;
22368
- }
22369
- /** Builds TanStack Query mutation options for {@link WrappedToken.shield | shielding} a public ERC-20 into its confidential form. @see {@link ShieldParams} */
22370
- declare function shieldMutationOptions(token: WrappedToken): MutationFactoryOptions<readonly ["zama.shield", Address], ShieldParams, TransactionResult>;
22371
- //#endregion
22372
- //#region src/query/transfer.d.ts
22373
- /** Variables for {@link confidentialTransferMutationOptions}. */
22374
- interface ConfidentialTransferParams extends TransferOptions {
22375
- /** Recipient address. */
22376
- to: Address;
22377
- /** Amount of tokens to transfer, in the token's base units. */
22378
- amount: bigint;
22379
- }
22380
- /** Builds TanStack Query mutation options for {@link Token.confidentialTransfer | transferring} confidential tokens. @see {@link ConfidentialTransferParams} */
22381
- declare function confidentialTransferMutationOptions(token: Token): MutationFactoryOptions<readonly ["zama.confidentialTransfer", Address], ConfidentialTransferParams, TransactionResult>;
22382
- //#endregion
22383
- //#region src/query/transfer-and-call.d.ts
22384
- /** Variables for {@link confidentialTransferAndCallMutationOptions}. */
22385
- interface ConfidentialTransferAndCallParams extends TransferOptions {
22386
- /** Recipient address. */
22387
- to: Address;
22388
- /** Amount of tokens to transfer, in the token's base units. */
22389
- amount: bigint;
22390
- /** Opaque bytes forwarded to the recipient's ERC-7984 receiver hook. */
22391
- data: Hex;
22392
- }
22393
- /** Builds TanStack Query mutation options for {@link Token.confidentialTransferAndCall | transferring} confidential tokens and invoking the recipient's receiver hook. @see {@link ConfidentialTransferAndCallParams} */
22394
- declare function confidentialTransferAndCallMutationOptions(token: Token): MutationFactoryOptions<readonly ["zama.confidentialTransferAndCall", Address], ConfidentialTransferAndCallParams, TransactionResult>;
22395
- //#endregion
22396
- //#region src/query/transfer-from.d.ts
22397
- /** Variables for {@link confidentialTransferFromMutationOptions}. */
22398
- interface ConfidentialTransferFromParams {
22399
- /** Address to transfer from. */
22400
- from: Address;
22401
- /** Recipient address. */
22402
- to: Address;
22403
- /** Amount of tokens to transfer, in the token's base units. */
22404
- amount: bigint;
22405
- /** Optional progress callbacks for the multi-step transfer flow. */
22406
- callbacks?: TransferCallbacks;
22407
- }
22408
- /** Builds TanStack Query mutation options for {@link Token.confidentialTransferFrom | transferring} confidential tokens from another account (operator flow). @see {@link ConfidentialTransferFromParams} */
22409
- declare function confidentialTransferFromMutationOptions(token: Token): MutationFactoryOptions<readonly ["zama.confidentialTransferFrom", Address], ConfidentialTransferFromParams, TransactionResult>;
22410
- //#endregion
22411
- //#region src/query/transfer-from-and-call.d.ts
22412
- /** Variables for {@link confidentialTransferFromAndCallMutationOptions}. */
22413
- interface ConfidentialTransferFromAndCallParams {
22414
- /** Address to transfer from. */
22415
- from: Address;
22416
- /** Recipient address. */
22417
- to: Address;
22418
- /** Amount of tokens to transfer, in the token's base units. */
22419
- amount: bigint;
22420
- /** Opaque bytes forwarded to the recipient's ERC-7984 receiver hook. */
22421
- data: Hex;
22422
- /** Optional progress callbacks for the multi-step transfer flow. */
22423
- callbacks?: TransferCallbacks;
22424
- }
22425
- /** Builds TanStack Query mutation options for {@link Token.confidentialTransferFromAndCall | transferring} confidential tokens from another account and invoking the recipient's receiver hook. @see {@link ConfidentialTransferFromAndCallParams} */
22426
- declare function confidentialTransferFromAndCallMutationOptions(token: Token): MutationFactoryOptions<readonly ["zama.confidentialTransferFromAndCall", Address], ConfidentialTransferFromAndCallParams, TransactionResult>;
22427
- //#endregion
22428
- //#region src/query/set-operator.d.ts
22429
- /** Variables for {@link confidentialSetOperatorMutationOptions}. */
22430
- interface ConfidentialSetOperatorParams {
22431
- /** Operator address to authorize. */
22432
- operator: Address;
22433
- /** Unix timestamp (seconds) when the operator authorization expires; defaults to one hour from now. */
22434
- until?: number;
22435
- }
22436
- /** Builds TanStack Query mutation options for {@link Token.setOperator | authorizing} an operator on a confidential token. @see {@link ConfidentialSetOperatorParams} */
22437
- declare function confidentialSetOperatorMutationOptions(token: Token): MutationFactoryOptions<readonly ["zama.confidentialSetOperator", Address], ConfidentialSetOperatorParams, TransactionResult>;
22438
- //#endregion
22439
- //#region src/query/approve-underlying.d.ts
22440
- /** Variables for {@link approveUnderlyingMutationOptions}. */
22441
- interface ApproveUnderlyingParams {
22442
- /** Amount of the underlying ERC-20 to approve, in its base units; omit for a max approval. */
22443
- amount?: bigint;
22444
- }
22445
- /** Builds TanStack Query mutation options for {@link WrappedToken.approveUnderlying | approving} the wrapper to spend the underlying ERC-20. @see {@link ApproveUnderlyingParams} */
22446
- declare function approveUnderlyingMutationOptions(token: WrappedToken): MutationFactoryOptions<readonly ["zama.approveUnderlying", Address], ApproveUnderlyingParams, TransactionResult>;
22447
- //#endregion
22448
- //#region src/query/unshield.d.ts
22449
- /** Variables for {@link unshieldMutationOptions}. */
22450
- interface UnshieldParams extends UnshieldOptions {
22451
- /** Amount of tokens to unshield, in the token's base units. */
22452
- amount: bigint;
22453
- }
22454
- /** Builds TanStack Query mutation options for {@link WrappedToken.unshield | unshielding} a confidential token back into its public ERC-20. @see {@link UnshieldParams} */
22455
- declare function unshieldMutationOptions(token: WrappedToken): MutationFactoryOptions<readonly ["zama.unshield", Address], UnshieldParams, TransactionResult>;
22456
- //#endregion
22457
- //#region src/query/unshield-all.d.ts
22458
- /** Variables for {@link unshieldAllMutationOptions}. */
22459
- interface UnshieldAllParams extends UnshieldCallbacks {}
22460
- /** Builds TanStack Query mutation options for {@link WrappedToken.unshieldAll | unshielding} the entire confidential balance back into the public ERC-20. @see {@link UnshieldAllParams} */
22461
- declare function unshieldAllMutationOptions(token: WrappedToken): MutationFactoryOptions<readonly ["zama.unshieldAll", Address], UnshieldAllParams | void, TransactionResult>;
22462
- //#endregion
22463
- //#region src/query/resume-unshield.d.ts
22464
- /** Variables for {@link resumeUnshieldMutationOptions}. */
22465
- interface ResumeUnshieldParams extends UnshieldCallbacks {
22466
- /** Hash of the earlier unwrap request transaction to resume from. */
22467
- unwrapTxHash: Hex;
22468
- }
22469
- /** Builds TanStack Query mutation options for {@link WrappedToken.resumeUnshield | resuming} an interrupted unshield from its unwrap request transaction. @see {@link ResumeUnshieldParams} */
22470
- declare function resumeUnshieldMutationOptions(token: WrappedToken): MutationFactoryOptions<readonly ["zama.resumeUnshield", Address], ResumeUnshieldParams, TransactionResult>;
22471
- //#endregion
22472
- //#region src/query/unwrap.d.ts
22473
- /** Variables for {@link unwrapMutationOptions}. */
22474
- interface UnwrapParams {
22475
- /** Amount of tokens to unwrap, in the token's base units. */
22476
- amount: bigint;
22477
- }
22478
- /** Builds TanStack Query mutation options for {@link WrappedToken.unwrap | unwrapping} a confidential token (request phase of the two-phase unwrap). @see {@link UnwrapParams} */
22479
- declare function unwrapMutationOptions(token: WrappedToken): MutationFactoryOptions<readonly ["zama.unwrap", Address], UnwrapParams, UnwrapResult>;
22480
- //#endregion
22481
- //#region src/query/wrap.d.ts
22482
- /** Variables for {@link wrapMutationOptions}. */
22483
- interface WrapParams extends WrapOptions {
22484
- /** Amount of the public ERC-20 to wrap, in the token's base units. */
22485
- amount: bigint;
21621
+ * {
21622
+ * using sdk = new ZamaSDK({ relayer, provider, signer, storage });
21623
+ * await sdk.permits.grantPermit([cUSDT]);
21624
+ * const balance = await sdk.createToken(cUSDT).balanceOf(userAddress);
21625
+ * } // sdk.terminate() called automatically here
21626
+ * ```
21627
+ */
21628
+ [Symbol.dispose](): void;
22486
21629
  }
22487
- /** Builds TanStack Query mutation options for {@link WrappedToken.wrap | wrapping} a public ERC-20 into its confidential form. @see {@link WrapParams} */
22488
- declare function wrapMutationOptions(token: WrappedToken): MutationFactoryOptions<readonly ["zama.wrap", Address], WrapParams, TransactionResult>;
22489
21630
  //#endregion
22490
- //#region src/query/unwrap-all.d.ts
22491
- /** Builds TanStack Query mutation options for {@link WrappedToken.unwrapAll | unwrapping} the entire confidential balance. */
22492
- declare function unwrapAllMutationOptions(token: WrappedToken): MutationFactoryOptions<readonly ["zama.unwrapAll", Address], void, UnwrapResult>;
22493
- //#endregion
22494
- //#region src/query/finalize-unwrap.d.ts
22495
- /** Variables for {@link finalizeUnwrapMutationOptions}. */
22496
- type FinalizeUnwrapParams = {
22497
- /** Identifier from an `UnwrapRequested` event. */
22498
- unwrapRequestId: EncryptedValue;
21631
+ //#region src/query/factory-types.d.ts
21632
+ /**
21633
+ * TanStack Query options object returned by the SDK's `*QueryOptions` factories:
21634
+ * `QueryObserverOptions` with `queryKey` and `queryFn` required and the
21635
+ * cache-internal keys (`queryHash`, `queryKeyHashFn`, `throwOnError`) removed.
21636
+ */
21637
+ type QueryFactoryOptions<TQueryFnData = unknown, TError = Error, TData = TQueryFnData, TQueryKey extends QueryKey = QueryKey> = Omit<Omit<QueryObserverOptions<TQueryFnData, TError, TData, TQueryFnData, TQueryKey>, "queryKey"> & Required<Pick<QueryObserverOptions<TQueryFnData, TError, TData, TQueryFnData, TQueryKey>, "queryKey">>, "queryFn" | "queryHash" | "queryKeyHashFn" | "throwOnError"> & {
21638
+ queryFn: Exclude<QueryObserverOptions<TQueryFnData, TError, TData, TQueryFnData, TQueryKey>["queryFn"], typeof skipToken | undefined>;
22499
21639
  };
22500
- /** Builds TanStack Query mutation options for {@link WrappedToken.finalizeUnwrap | finalizing} a previously requested unwrap. @see {@link FinalizeUnwrapParams} */
22501
- declare function finalizeUnwrapMutationOptions(token: WrappedToken): MutationFactoryOptions<readonly ["zama.finalizeUnwrap", Address], FinalizeUnwrapParams, TransactionResult>;
22502
- //#endregion
22503
- //#region src/query/encrypt.d.ts
22504
- /** Builds TanStack Query mutation options for {@link ZamaSDK.encrypt | encrypting} plaintext inputs into an encrypted payload. */
22505
- declare function encryptMutationOptions(sdk: ZamaSDK): MutationFactoryOptions<readonly ["zama.encrypt"], EncryptParams, EncryptResult>;
22506
- //#endregion
22507
- //#region src/query/delegated-decrypt.d.ts
22508
- /** Variables for {@link delegatedDecryptValuesMutationOptions}. */
22509
- interface DelegatedDecryptValuesMutationParams {
22510
- /** Encrypted values (with their contract addresses) to decrypt. */
22511
- encryptedInputs: EncryptedInput[];
22512
- /** Address of the account that delegated decryption rights to the connected wallet. */
22513
- delegatorAddress: Address;
21640
+ /** TanStack Query mutation options object returned by the SDK's `*MutationOptions` factories. */
21641
+ interface MutationFactoryOptions<TMutationKey extends readonly unknown[], TVariables, TData, TOnMutateResult = unknown> {
21642
+ /** Cache key identifying the mutation. */
21643
+ mutationKey: TMutationKey;
21644
+ /** Runs the mutation for the given variables. */
21645
+ mutationFn: (variables: TVariables) => Promise<TData>;
21646
+ /** Optional callback invoked after the mutation succeeds. */
21647
+ onSuccess?: (data: TData, variables: TVariables, onMutateResult: TOnMutateResult, context: MutationFunctionContext) => void;
22514
21648
  }
22515
- /** Builds TanStack Query mutation options for {@link Decryption.delegatedDecryptValues | decrypting} encrypted values via delegated decryption credentials. @see {@link DelegatedDecryptValuesMutationParams} */
22516
- declare function delegatedDecryptValuesMutationOptions(sdk: ZamaSDK): MutationFactoryOptions<readonly ["zama.delegatedDecryptValues"], DelegatedDecryptValuesMutationParams, Readonly<Record<EncryptedValue, ClearValue>>>;
22517
21649
  //#endregion
22518
- //#region src/query/public-decrypt.d.ts
22519
- /** Builds TanStack Query mutation options for {@link Decryption.decryptPublicValues | publicly decrypting} encrypted values, caching each clear result. */
22520
- declare function decryptPublicValuesMutationOptions(sdk: ZamaSDK): MutationFactoryOptions<readonly ["zama.decryptPublicValues"], EncryptedValue[], DecryptPublicValuesResult>;
22521
- //#endregion
22522
- //#region src/query/grant-permit.d.ts
21650
+ //#region src/query/query-keys.d.ts
22523
21651
  /**
22524
- * Builds TanStack Query mutation options for {@link Permits.grantPermit | granting}
22525
- * decryption permits for the given contract addresses, or {@link WILDCARD_PERMIT}
22526
- * for a permissive V2 permit covering every contract.
21652
+ * Canonical query-key namespace for `@zama-fhe/sdk/query`.
21653
+ *
21654
+ * @example
21655
+ * ```ts
21656
+ * queryClient.invalidateQueries({
21657
+ * queryKey: zamaQueryKeys.confidentialBalance.token("0xToken"),
21658
+ * });
21659
+ * ```
22527
21660
  */
22528
- declare function grantPermitMutationOptions(sdk: ZamaSDK): MutationFactoryOptions<readonly ["zama.grantPermit"], Address[] | WildcardPermit, void>;
22529
- //#endregion
22530
- //#region src/query/prepare-permit.d.ts
22531
- /** Builds TanStack Query mutation options for {@link Offline.preparePermit | preparing} an offline decryption permit. */
22532
- declare function preparePermitMutationOptions(sdk: ZamaSDK): MutationFactoryOptions<readonly ["zama.preparePermit"], PreparePermitRequest, PreparedPermit>;
22533
- //#endregion
22534
- //#region src/query/register-permit.d.ts
22535
- /** Parameters for {@link registerPermitMutationOptions}. */
22536
- interface RegisterPermitParams {
22537
- /** The payload `sdk.offline.preparePermit` returned. */
22538
- prepared: PreparedPermit;
22539
- /** The `eth_signTypedData_v4` signature over `prepared.eip712`. */
22540
- signature: Hex;
22541
- }
22542
- /** Builds TanStack Query mutation options for {@link Permits.registerPermit | registering} a signed offline permit. */
22543
- declare function registerPermitMutationOptions(sdk: ZamaSDK): MutationFactoryOptions<readonly ["zama.registerPermit"], RegisterPermitParams, void>;
22544
- //#endregion
22545
- //#region src/query/has-permit.d.ts
22546
- /** Configuration for {@link hasPermitQueryOptions}. */
22547
- interface HasPermitQueryConfig {
22548
- /** Contract addresses to check credentials against. */
22549
- contractAddresses: Address[];
22550
- /**
22551
- * Standard TanStack query options. `hasPermit` intentionally overrides cache
22552
- * timing because permit state is wallet-local, not server state: every fetch
22553
- * should read the SDK credential service directly.
22554
- */
22555
- query?: Record<string, unknown>;
22556
- }
22557
- /** Builds TanStack Query options for reading whether the connected wallet holds a valid decryption permit for the given contracts. */
22558
- declare function hasPermitQueryOptions(sdk: ZamaSDK, config: HasPermitQueryConfig, signerContext?: SignerQueryContext): QueryFactoryOptions<boolean, Error, boolean, ReturnType<typeof zamaQueryKeys.hasPermit.scope>>;
22559
- //#endregion
22560
- //#region src/query/revoke-permits.d.ts
22561
- /** TanStack Query mutation factory for {@link Permits.revokePermits}. */
22562
- declare function revokePermitsMutationOptions(sdk: ZamaSDK): MutationFactoryOptions<readonly ["zama.revokePermits"], Address[] | void, void>;
22563
- //#endregion
22564
- //#region src/query/clear-credentials.d.ts
22565
- /** TanStack Query mutation factory for {@link Permits.clear}. */
22566
- declare function clearCredentialsMutationOptions(sdk: ZamaSDK): MutationFactoryOptions<readonly ["zama.clearCredentials"], void, void>;
22567
- //#endregion
22568
- //#region src/query/delegate-decryption.d.ts
22569
- /** Variables for {@link delegateDecryptionMutationOptions}. */
22570
- interface DelegateDecryptionParams {
22571
- /** Address to grant delegated decryption rights to. */
22572
- delegateAddress: Address;
22573
- /** When the delegation expires; omit for no expiry. */
22574
- expirationDate?: Date;
22575
- }
22576
- /** Builds TanStack Query mutation options for {@link Delegations.delegateDecryption | granting} delegated decryption rights on a contract. @see {@link DelegateDecryptionParams} */
22577
- declare function delegateDecryptionMutationOptions(sdk: ZamaSDK, contractAddress: Address): MutationFactoryOptions<readonly ["zama.delegateDecryption", Address], DelegateDecryptionParams, TransactionResult>;
22578
- //#endregion
22579
- //#region src/query/decrypt-balance-as.d.ts
22580
- /** Variables for {@link decryptBalanceAsMutationOptions}. */
22581
- interface DecryptBalanceAsParams {
22582
- /** Address of the account that delegated decryption rights to the connected wallet. */
22583
- delegatorAddress: Address;
22584
- /** Account whose on-chain balance to read; defaults to the delegator address. */
22585
- accountAddress?: Address;
22586
- }
22587
- /** Builds TanStack Query mutation options for {@link Token.decryptBalanceAs | decrypting} a balance via delegated decryption credentials. @see {@link DecryptBalanceAsParams} */
22588
- declare function decryptBalanceAsMutationOptions(token: Token): MutationFactoryOptions<readonly ["zama.decryptBalanceAs", Address], DecryptBalanceAsParams, bigint>;
22589
- //#endregion
22590
- //#region src/query/batch-decrypt-balances-as.d.ts
22591
- /** Variables for {@link batchDecryptBalancesAsMutationOptions}. */
22592
- type BatchDecryptBalancesAsParams = BatchDecryptAsOptions;
22593
- /** Builds TanStack Query mutation options for {@link Token.batchDecryptBalancesAs | decrypting} multiple token balances via delegated decryption credentials. @see {@link BatchDecryptBalancesAsParams} */
22594
- declare function batchDecryptBalancesAsMutationOptions(tokens: Token[]): MutationFactoryOptions<readonly ["zama.batchDecryptBalancesAs", ...Address[]], BatchDecryptBalancesAsParams, Map<Address, bigint>>;
22595
- //#endregion
22596
- //#region src/query/revoke-delegation.d.ts
22597
- /** Variables for {@link revokeDelegationMutationOptions}. */
22598
- interface RevokeDelegationParams {
22599
- /** Address whose delegated decryption rights to revoke. */
22600
- delegateAddress: Address;
22601
- }
22602
- /** Builds TanStack Query mutation options for {@link Delegations.revokeDelegation | revoking} delegated decryption rights on a contract. @see {@link RevokeDelegationParams} */
22603
- declare function revokeDelegationMutationOptions(sdk: ZamaSDK, contractAddress: Address): MutationFactoryOptions<readonly ["zama.revokeDelegation", Address], RevokeDelegationParams, TransactionResult>;
21661
+ declare const zamaQueryKeys: {
21662
+ readonly confidentialBalance: {
21663
+ readonly all: readonly ["zama.confidentialBalance"];
21664
+ readonly token: (tokenAddress: Address) => readonly ["zama.confidentialBalance", {
21665
+ readonly tokenAddress: `0x${string}`;
21666
+ }];
21667
+ readonly owner: (tokenAddress: Address, owner?: Address, walletAccount?: WalletAccount) => readonly ["zama.confidentialBalance", {
21668
+ readonly owner?: `0x${string}` | undefined;
21669
+ readonly walletAddress: `0x${string}`;
21670
+ readonly walletChainId: number;
21671
+ readonly tokenAddress: `0x${string}`;
21672
+ } | {
21673
+ readonly owner?: `0x${string}` | undefined;
21674
+ readonly walletAddress?: undefined;
21675
+ readonly walletChainId?: undefined;
21676
+ readonly tokenAddress: `0x${string}`;
21677
+ }];
21678
+ };
21679
+ readonly confidentialBalances: {
21680
+ readonly all: readonly ["zama.confidentialBalances"];
21681
+ readonly tokens: (tokenAddresses: Address[], owner?: Address, walletAccount?: WalletAccount) => readonly ["zama.confidentialBalances", {
21682
+ readonly owner?: `0x${string}` | undefined;
21683
+ readonly walletAddress: `0x${string}`;
21684
+ readonly walletChainId: number;
21685
+ readonly tokenAddresses: `0x${string}`[];
21686
+ } | {
21687
+ readonly owner?: `0x${string}` | undefined;
21688
+ readonly walletAddress?: undefined;
21689
+ readonly walletChainId?: undefined;
21690
+ readonly tokenAddresses: `0x${string}`[];
21691
+ }];
21692
+ };
21693
+ readonly tokenMetadata: {
21694
+ readonly all: readonly ["zama.tokenMetadata"];
21695
+ readonly token: (tokenAddress: Address) => readonly ["zama.tokenMetadata", {
21696
+ readonly tokenAddress: `0x${string}`;
21697
+ }];
21698
+ };
21699
+ readonly isConfidential: {
21700
+ readonly all: readonly ["zama.isConfidential"];
21701
+ readonly token: (tokenAddress: Address) => readonly ["zama.isConfidential", {
21702
+ readonly tokenAddress: `0x${string}`;
21703
+ }];
21704
+ };
21705
+ readonly isWrapper: {
21706
+ readonly all: readonly ["zama.isWrapper"];
21707
+ readonly token: (tokenAddress: Address) => readonly ["zama.isWrapper", {
21708
+ readonly tokenAddress: `0x${string}`;
21709
+ }];
21710
+ };
21711
+ readonly wrapperDiscovery: {
21712
+ readonly all: readonly ["zama.wrapperDiscovery"];
21713
+ readonly token: (tokenAddress?: Address, erc20Address?: Address, registryAddress?: Address) => readonly ["zama.wrapperDiscovery", {
21714
+ readonly registryAddress?: `0x${string}` | undefined;
21715
+ readonly erc20Address?: `0x${string}` | undefined;
21716
+ readonly tokenAddress?: `0x${string}` | undefined;
21717
+ }];
21718
+ };
21719
+ readonly underlyingAllowance: {
21720
+ readonly all: readonly ["zama.underlyingAllowance"];
21721
+ readonly token: (tokenAddress: Address) => readonly ["zama.underlyingAllowance", {
21722
+ readonly tokenAddress: `0x${string}`;
21723
+ }];
21724
+ readonly scope: (tokenAddress: Address, owner?: Address) => readonly ["zama.underlyingAllowance", {
21725
+ readonly owner?: `0x${string}` | undefined;
21726
+ readonly tokenAddress: `0x${string}`;
21727
+ }];
21728
+ };
21729
+ readonly confidentialIsOperator: {
21730
+ readonly all: readonly ["zama.confidentialIsOperator"];
21731
+ readonly token: (tokenAddress?: Address) => readonly ["zama.confidentialIsOperator", {
21732
+ tokenAddress: `0x${string}`;
21733
+ } | {
21734
+ tokenAddress?: undefined;
21735
+ }];
21736
+ readonly scope: (tokenAddress?: Address, holder?: Address, spender?: Address) => readonly ["zama.confidentialIsOperator", {
21737
+ readonly spender?: `0x${string}` | undefined;
21738
+ readonly holder?: `0x${string}` | undefined;
21739
+ readonly tokenAddress?: `0x${string}` | undefined;
21740
+ }];
21741
+ };
21742
+ readonly totalSupply: {
21743
+ readonly all: readonly ["zama.totalSupply"];
21744
+ readonly token: (tokenAddress: Address) => readonly ["zama.totalSupply", {
21745
+ readonly tokenAddress: `0x${string}`;
21746
+ }];
21747
+ };
21748
+ readonly pendingUnshield: {
21749
+ readonly all: readonly ["zama.pendingUnshield"];
21750
+ readonly token: (tokenAddress: Address) => readonly ["zama.pendingUnshield", {
21751
+ readonly tokenAddress: `0x${string}`;
21752
+ }];
21753
+ };
21754
+ readonly hasPermit: {
21755
+ readonly all: readonly ["zama.hasPermit"];
21756
+ readonly scope: (contractAddresses: Address[], walletAccount?: WalletAccount) => readonly ["zama.hasPermit", {
21757
+ readonly contractAddresses: `0x${string}`[];
21758
+ readonly walletAddress: `0x${string}`;
21759
+ readonly walletChainId: number;
21760
+ } | {
21761
+ readonly contractAddresses: `0x${string}`[];
21762
+ readonly walletAddress?: undefined;
21763
+ readonly walletChainId?: undefined;
21764
+ }];
21765
+ };
21766
+ readonly delegationStatus: {
21767
+ readonly all: readonly ["zama.delegationStatus"];
21768
+ readonly contract: (contractAddress?: Address) => readonly ["zama.delegationStatus", {
21769
+ contractAddress: `0x${string}`;
21770
+ } | {
21771
+ contractAddress?: undefined;
21772
+ }];
21773
+ readonly scope: (contractAddress?: Address, delegator?: Address, delegate?: Address) => readonly ["zama.delegationStatus", {
21774
+ readonly delegateAddress?: `0x${string}` | undefined;
21775
+ readonly delegatorAddress?: `0x${string}` | undefined;
21776
+ readonly contractAddress?: `0x${string}` | undefined;
21777
+ }];
21778
+ };
21779
+ readonly decryption: {
21780
+ readonly all: readonly ["zama.decryption"];
21781
+ readonly encryptedValue: (encryptedValue: string, contractAddress?: Address) => readonly ["zama.decryption", {
21782
+ readonly contractAddress?: `0x${string}` | undefined;
21783
+ readonly encryptedValue: string;
21784
+ }];
21785
+ readonly encryptedInputs: (encryptedInputs: readonly {
21786
+ encryptedValue: string;
21787
+ contractAddress: Address;
21788
+ }[], walletAccount?: WalletAccount) => readonly ["zama.decryption", {
21789
+ readonly encryptedInputs: {
21790
+ encryptedValue: Hex;
21791
+ contractAddress: `0x${string}`;
21792
+ }[];
21793
+ readonly walletAddress: `0x${string}`;
21794
+ readonly walletChainId: number;
21795
+ } | {
21796
+ readonly encryptedInputs: {
21797
+ encryptedValue: Hex;
21798
+ contractAddress: `0x${string}`;
21799
+ }[];
21800
+ readonly walletAddress?: undefined;
21801
+ readonly walletChainId?: undefined;
21802
+ }];
21803
+ };
21804
+ readonly wrappersRegistry: {
21805
+ readonly all: readonly ["zama.wrappersRegistry"];
21806
+ readonly chainId: () => readonly ["zama.wrappersRegistry", {
21807
+ readonly type: "chainId";
21808
+ }];
21809
+ readonly tokenPairs: (registryAddress: Address) => readonly ["zama.wrappersRegistry", {
21810
+ readonly type: "tokenPairs";
21811
+ readonly registryAddress: `0x${string}`;
21812
+ }];
21813
+ readonly confidentialTokenAddress: (registryAddress: Address, tokenAddress: Address) => readonly ["zama.wrappersRegistry", {
21814
+ readonly type: "confidentialTokenAddress";
21815
+ readonly registryAddress: `0x${string}`;
21816
+ readonly tokenAddress: `0x${string}`;
21817
+ }];
21818
+ readonly tokenAddress: (registryAddress: Address, confidentialTokenAddress: Address) => readonly ["zama.wrappersRegistry", {
21819
+ readonly type: "tokenAddress";
21820
+ readonly registryAddress: `0x${string}`;
21821
+ readonly confidentialTokenAddress: `0x${string}`;
21822
+ }];
21823
+ readonly tokenPairsLength: (registryAddress: Address) => readonly ["zama.wrappersRegistry", {
21824
+ readonly type: "tokenPairsLength";
21825
+ readonly registryAddress: `0x${string}`;
21826
+ }];
21827
+ readonly tokenPairsSlice: (registryAddress: Address, fromIndex: string, toIndex: string) => readonly ["zama.wrappersRegistry", {
21828
+ readonly type: "tokenPairsSlice";
21829
+ readonly registryAddress: `0x${string}`;
21830
+ readonly fromIndex: string;
21831
+ readonly toIndex: string;
21832
+ }];
21833
+ readonly tokenPair: (registryAddress: Address, index: string) => readonly ["zama.wrappersRegistry", {
21834
+ readonly type: "tokenPair";
21835
+ readonly registryAddress: `0x${string}`;
21836
+ readonly index: string;
21837
+ }];
21838
+ readonly isConfidentialTokenValid: (registryAddress: Address, confidentialTokenAddress: Address) => readonly ["zama.wrappersRegistry", {
21839
+ readonly type: "isConfidentialTokenValid";
21840
+ readonly registryAddress: `0x${string}`;
21841
+ readonly confidentialTokenAddress: `0x${string}`;
21842
+ }];
21843
+ readonly listPairs: (registryAddress: Address, page: number, pageSize: number, metadata: boolean) => readonly ["zama.wrappersRegistry", {
21844
+ readonly type: "listPairs";
21845
+ readonly registryAddress: `0x${string}`;
21846
+ readonly page: number;
21847
+ readonly pageSize: number;
21848
+ readonly metadata: boolean;
21849
+ }];
21850
+ };
21851
+ };
22604
21852
  //#endregion
22605
- //#region src/query/invalidate-decryption-signatures.d.ts
22606
- /** Variables for {@link invalidateDecryptionSignaturesMutationOptions}. */
22607
- interface InvalidateDecryptionSignaturesParams {
22608
- /** Oldest timestamp that remains valid. Omit to invalidate everything up to now. */
22609
- timestamp?: Date;
21853
+ //#region src/query/signer-query-context.d.ts
21854
+ /** Connected-wallet context threaded into query factories to scope cache keys and gate signer-dependent queries. */
21855
+ interface SignerQueryContext {
21856
+ /** Connected wallet account; queries that need a signer stay disabled until it is set. */
21857
+ walletAccount?: WalletAccount;
22610
21858
  }
22611
- /** Builds TanStack Query mutation options for {@link Permits.invalidateDecryptionSignatures | invalidating} every decryption signature signed before a timestamp. @see {@link InvalidateDecryptionSignaturesParams} */
22612
- declare function invalidateDecryptionSignaturesMutationOptions(sdk: ZamaSDK): MutationFactoryOptions<readonly ["zama.invalidateDecryptionSignatures"], InvalidateDecryptionSignaturesParams | void, TransactionResult>;
22613
21859
  //#endregion
22614
- //#region src/query/delegation-status.d.ts
22615
- /** Configuration for {@link delegationStatusQueryOptions}. */
22616
- interface DelegationStatusQueryConfig {
22617
- /** Contract the delegation applies to; pass `undefined` to keep the query disabled. */
22618
- contractAddress: Address | undefined;
22619
- /** Address granting the delegated decryption rights; the query stays disabled until provided. */
22620
- delegatorAddress?: Address;
22621
- /** Address receiving the delegated decryption rights; the query stays disabled until provided. */
22622
- delegateAddress?: Address;
22623
- /** Additional TanStack Query options merged into the generated query (e.g. `staleTime`, `enabled`). */
22624
- query?: Record<string, unknown>;
21860
+ //#region src/query/user-decrypt.d.ts
21861
+ /** A single encrypted value to decrypt, paired with the contract that owns it. */
21862
+ interface EncryptedInput {
21863
+ /** Encrypted handle to decrypt. */
21864
+ encryptedValue: EncryptedValue;
21865
+ /** Address of the contract the encrypted value belongs to. */
21866
+ contractAddress: Address;
22625
21867
  }
22626
- /** Builds TanStack Query options for reading the decryption-delegation status between a delegator and a delegate on a contract. */
22627
- declare function delegationStatusQueryOptions(sdk: ZamaSDK, config: DelegationStatusQueryConfig): QueryFactoryOptions<DelegationStatus, Error, DelegationStatus, ReturnType<typeof zamaQueryKeys.delegationStatus.scope>>;
21868
+ /** Decrypted clear values keyed by encrypted handle. */
21869
+ type DecryptResult = Readonly<Record<EncryptedValue, ClearValue>>;
21870
+ /** Builds TanStack Query options for decrypting a batch of encrypted handles into their clear values. */
21871
+ declare function decryptValuesQueryOptions(sdk: ZamaSDK, encryptedInputs: EncryptedInput[], signerContext?: SignerQueryContext): QueryFactoryOptions<DecryptResult, Error, DecryptResult, ReturnType<typeof zamaQueryKeys.decryption.encryptedInputs>>;
22628
21872
  //#endregion
22629
21873
  //#region src/services/decryption-service.d.ts
22630
21874
  /** Options shared by the delegated-decrypt entry points. */
@@ -22654,224 +21898,6 @@ interface BatchDecryptResult {
22654
21898
  items: BatchDecryptItem[];
22655
21899
  }
22656
21900
  //#endregion
22657
- //#region src/namespaces/offline.d.ts
22658
- /**
22659
- * Namespace for the offline-signing pipeline —
22660
- * `prepare → [external sign + self-publish]` — for institutional custody, HSM
22661
- * ceremonies, and policy-engine workflows where signing runs out-of-process and
22662
- * cannot happen synchronously in a single Promise.
22663
- */
22664
- declare class Offline {
22665
- #private;
22666
- /**
22667
- * Build an RLP-encoded unsigned transaction for the given request. The
22668
- * caller signs it externally — via an HSM ceremony, an out-of-process
22669
- * custodian, or any signer holding the key — and broadcasts the signed bytes
22670
- * through its own channel.
22671
- *
22672
- * Signer-optional: works without a configured signer (canonical shape for
22673
- * cross-process custody — the back-end signer service consumes
22674
- * `prepared.unsignedTx` and returns signed bytes).
22675
- *
22676
- * @remarks
22677
- * `request.from` is only a declaration — the SDK does not prove the caller
22678
- * controls it, and an EIP-1559 unsigned tx carries no `from` field at all
22679
- * (the on-chain sender is whichever key signs the bytes). Point `from` at
22680
- * the account the custodian will sign with; custodians enforce key-control
22681
- * at sign time — a signing request for a key the credential can't use fails
22682
- * there — so a mismatched `from` cannot make the custodian sign from an
22683
- * account you don't control. Verifying control of `from` up front is still
22684
- * the application's responsibility.
22685
- */
22686
- prepare<K extends TransactionKind>(request: Extract<PrepareTransactionRequest, {
22687
- kind: K;
22688
- }>, options?: PrepareOptions): Promise<PreparedFor<K>>;
22689
- /**
22690
- * Build the offline-signing payload for a decryption permit: the unsigned
22691
- * EIP-712 typed data plus everything `sdk.permits.registerPermit` needs to
22692
- * verify and persist the signature an out-of-process signer returns for it.
22693
- *
22694
- * Not a `prepare()` transaction kind: a permit is not a transaction —
22695
- * nothing is broadcast, and registering the signature is a local operation,
22696
- * not a relayer round-trip.
22697
- *
22698
- * Signer-optional, like {@link prepare}: `request.signer` is an explicit
22699
- * address, not a connected wallet account. Building the typed data still
22700
- * reads the chain's KMS signers context on-chain — signer-offline, not
22701
- * network-offline.
22702
- *
22703
- * One permit per call: unlike `sdk.permits.grantPermit`, this never widens
22704
- * an existing permit or chunks over 10 contracts — `request.contracts` maps
22705
- * to exactly one signature.
22706
- *
22707
- * @throws if `request.contracts` is empty or exceeds 10 addresses, `request.delegator`
22708
- * equals `request.signer`, or `request.durationDays` exceeds the V1 permit maximum
22709
- * of 365 days. {@link ConfigurationError}
22710
- * @throws if a concurrent `permits.revokeTransportKeyPair()` rotates the transport key
22711
- * pair while this call is generating one. {@link TransportKeyPairChangedError}
22712
- */
22713
- preparePermit(request: PreparePermitRequest): Promise<PreparedPermit>;
22714
- }
22715
- //#endregion
22716
- //#region src/zama-sdk.d.ts
22717
- /** Instance-level options that are deliberately not part of the shareable config object. */
22718
- interface ZamaSDKOptions {
22719
- /**
22720
- * Encrypts the transport key pair's private half at rest. Headless environments only
22721
- * (CLI tools, servers, agents); the constructor rejects it in browser contexts. Supply
22722
- * at least 32 random bytes, or a string of at least 64 characters, from a CSPRNG or
22723
- * secrets manager. The SDK copies a Uint8Array secret and zeroizes its own copy after
22724
- * key import; it never touches your buffer, so zeroize yours after construction.
22725
- * The SDK never persists or exposes this value. Omit for the default:
22726
- * plaintext at rest, security delegated to the storage backend.
22727
- */
22728
- transportKeyPairDerivationSecret?: string | Uint8Array;
22729
- }
22730
- /**
22731
- * ZamaSDK — composes a RelayerSDK with contract abstraction.
22732
- *
22733
- * Exposes domain namespaces for permits, delegations, decryption, offline
22734
- * signing, and tokens, plus an unchanged registry, a top-level `encrypt`, and
22735
- * lifecycle methods. Internal `*Service` classes do the work; the namespace
22736
- * classes own SDK-level guards (chain alignment, signer requirement, event
22737
- * emission).
22738
- */
22739
- declare class ZamaSDK {
22740
- #private;
22741
- /** Read-only chain access used for all contract reads. */
22742
- readonly provider: GenericProvider;
22743
- /** Wallet signer used for write operations, or `undefined` when the SDK is read-only. */
22744
- readonly signer: GenericSigner | undefined;
22745
- /** Storage for cached permits and transport key pairs. */
22746
- readonly storage: GenericStorage;
22747
- /**
22748
- * A {@link WrappersRegistry} instance auto-configured for the current chain.
22749
- * Uses built-in defaults from chain configs, and the SDK's `registryTTL` if configured.
22750
- */
22751
- readonly registry: WrappersRegistry;
22752
- /** Permit and keypair management. */
22753
- readonly permits: Permits;
22754
- /** On-chain decryption-delegation management. */
22755
- readonly delegations: Delegations;
22756
- /** FHE decryption (user, delegated user, public). */
22757
- readonly decryption: Decryption;
22758
- /** Offline-signing pipeline: `prepare` builds an unsigned tx the caller signs and broadcasts out-of-process — for HSM, policy-engine, and cross-process custody workflows. */
22759
- readonly offline: Offline;
22760
- constructor(config: ZamaConfig, options?: ZamaSDKOptions);
22761
- /**
22762
- * The single-chain relayer backend for the **currently active** chain.
22763
- */
22764
- get relayer(): RelayerSDK;
22765
- /**
22766
- * Create a {@link WrappersRegistry} instance bound to this SDK's provider.
22767
- * Inherits the registry addresses derived from the SDK's chain configs, so
22768
- * the result is consistent with {@link ZamaSDK.registry}.
22769
- *
22770
- * @param registryAddresses - Optional per-chain overrides for this registry instance.
22771
- * @returns A {@link WrappersRegistry} instance.
22772
- *
22773
- * @example
22774
- * ```ts
22775
- * // Addresses resolved from the SDK's chain configs
22776
- * const registry = sdk.createWrappersRegistry();
22777
- *
22778
- * // Hardhat or custom chain — override per chain for this registry instance
22779
- * const registry = sdk.createWrappersRegistry({ [31337]: "0xYourRegistry" });
22780
- *
22781
- * const pairs = await registry.getTokenPairs();
22782
- * ```
22783
- */
22784
- createWrappersRegistry(registryAddresses?: Record<number, Address>): WrappersRegistry;
22785
- /**
22786
- * Encrypt one or more plaintext values into FHE ciphertexts.
22787
- *
22788
- * @param params - Typed FHE inputs, the target contract address, and the user address.
22789
- * @returns External encrypted values and the input proof for on-chain submission.
22790
- * @throws if FHE encryption fails. {@link EncryptionFailedError}
22791
- *
22792
- * @example
22793
- * ```ts
22794
- * const { encryptedValues, inputProof } = await sdk.encrypt({
22795
- * values: [{ value: 1000n, type: "euint64" }],
22796
- * contractAddress: "0xToken",
22797
- * userAddress: "0xUser",
22798
- * });
22799
- * ```
22800
- */
22801
- encrypt(params: EncryptParams, options?: Pick<FhevmRelayerOptions, "signal" | "timeout">): Promise<EncryptResult>;
22802
- /**
22803
- * Create a high-level ERC-20-style interface for an ERC-7984 confidential token.
22804
- * Supports balance queries, transfers, operator approvals, and decryption.
22805
- *
22806
- * For ERC-7984 wrappers (shield/unshield/allowance), use {@link createWrappedToken} instead.
22807
- *
22808
- * @param address - The confidential token contract address.
22809
- * @returns A {@link Token} instance bound to this SDK.
22810
- *
22811
- * @example
22812
- * ```ts
22813
- * const token = sdk.createToken(cUSDT);
22814
- * const balance = await token.balanceOf(userAddress);
22815
- * ```
22816
- */
22817
- createToken(address: Address): Token;
22818
- /**
22819
- * Create a high-level interface for an ERC-7984 wrapper token.
22820
- * Extends {@link Token} with shield/unshield/allowance/finalize-unwrap operations.
22821
- *
22822
- * @param address - The wrapper token contract address.
22823
- * @returns A {@link WrappedToken} instance bound to this SDK.
22824
- *
22825
- * @example
22826
- * ```ts
22827
- * const wrapped = sdk.createWrappedToken(wUSDT);
22828
- * await wrapped.shield(1_000_000n);
22829
- * ```
22830
- */
22831
- createWrappedToken(address: Address): WrappedToken;
22832
- /**
22833
- * Release the SDK-owned resources: signer lifecycle subscriptions and the
22834
- * relayer backend's resources, an encrypt worker included. Call this when the
22835
- * SDK instance is being replaced (e.g. React provider unmount or a Strict Mode
22836
- * remount). Work already in flight runs to completion, and the instance stays
22837
- * usable: the next encryption spawns a fresh worker.
22838
- */
22839
- dispose(): void;
22840
- /**
22841
- * {@link dispose} plus the signer's own disposal. Call this when the SDK is no
22842
- * longer needed (e.g. on shutdown). Work already in flight runs to completion.
22843
- */
22844
- terminate(): void;
22845
- /**
22846
- * Implements the TC39 Explicit Resource Management protocol.
22847
- * Calls {@link terminate} when the `using` binding goes out of scope,
22848
- * unsubscribing signer events and releasing the relayer's resources.
22849
- *
22850
- * @example
22851
- * ```ts
22852
- * {
22853
- * using sdk = new ZamaSDK({ relayer, provider, signer, storage });
22854
- * await sdk.permits.grantPermit([cUSDT]);
22855
- * const balance = await sdk.createToken(cUSDT).balanceOf(userAddress);
22856
- * } // sdk.terminate() called automatically here
22857
- * ```
22858
- */
22859
- [Symbol.dispose](): void;
22860
- }
22861
- //#endregion
22862
- //#region src/query/user-decrypt.d.ts
22863
- /** A single encrypted value to decrypt, paired with the contract that owns it. */
22864
- interface EncryptedInput {
22865
- /** Encrypted handle to decrypt. */
22866
- encryptedValue: EncryptedValue;
22867
- /** Address of the contract the encrypted value belongs to. */
22868
- contractAddress: Address;
22869
- }
22870
- /** Decrypted clear values keyed by encrypted handle. */
22871
- type DecryptResult = Readonly<Record<EncryptedValue, ClearValue>>;
22872
- /** Builds TanStack Query options for decrypting a batch of encrypted handles into their clear values. */
22873
- declare function decryptValuesQueryOptions(sdk: ZamaSDK, encryptedInputs: EncryptedInput[], signerContext?: SignerQueryContext): QueryFactoryOptions<DecryptResult, Error, DecryptResult, ReturnType<typeof zamaQueryKeys.decryption.encryptedInputs>>;
22874
- //#endregion
22875
21901
  //#region src/namespaces/decryption.d.ts
22876
21902
  /**
22877
21903
  * Public namespace for FHE decryption — the canonical way to decrypt.
@@ -23012,5 +22038,94 @@ declare class Decryption {
23012
22038
  } & DelegatedDecryptOptions): Promise<BatchDecryptResult>;
23013
22039
  }
23014
22040
  //#endregion
23015
- export { confidentialTransferFromAndCallMutationOptions as $, DelegationExpiryUnchangedError as $n, ERC7984_WRAPPER_INTERFACE_ID as $r, QueryLike as $t, grantPermitMutationOptions as A, SignerRequiredError as An, SerializedPermitEip712 as Ar, Token as At, UnwrapParams as B, InsufficientAllowanceError as Bn, getTokenPairContract as Br, ListPairsOptions as Bt, clearCredentialsMutationOptions as C, createConfig as Ci, UnshieldAlreadyFinalizedDetails as Cn, PermissionV2 as Cr, ConfidentialBalancesQueryConfig as Ct, RegisterPermitParams as D, SigningFailedError as Dn, PreparedPermitV1 as Dr, WrappedToken as Dt, hasPermitQueryOptions as E, SigningErrorMetadata as En, PreparedPermitBase as Er, confidentialBalanceQueryOptions as Et, FinalizeUnwrapParams as F, ConfigurationError as Fn, PaginatedResult as Fr, UnderlyingAllowanceQueryConfig as Ft, unshieldAllMutationOptions as G, EncryptionFailedError as Gn, delegateForUserDecryptionContract as Gr, IsConfidentialQueryConfig as Gt, ResumeUnshieldParams as H, InsufficientERC20BalanceError as Hn, getTokenPairsLengthContract as Hr, WrappersRegistryConfig as Ht, finalizeUnwrapMutationOptions as I, RelayerRequestFailedError as In, TokenWrapperPair as Ir, underlyingAllowanceQueryOptions as It, ApproveUnderlyingParams as J, DelegationCooldownError as Jn, isHandleDelegatedContract as Jr, TokenMetadata as Jt, UnshieldParams as K, AclPausedError as Kn, getDelegationExpiryContract as Kr, isConfidentialQueryOptions as Kt, unwrapAllMutationOptions as L, BalanceCheckUnavailableError as Ln, TokenWrapperPairWithMetadata as Lr, WrapperDiscoveryQueryConfig as Lt, DelegatedDecryptValuesMutationParams as M, WalletNotConnectedError as Mn, WILDCARD_PERMIT as Mr, confidentialIsOperatorQueryOptions as Mt, delegatedDecryptValuesMutationOptions as N, RpcRateLimitError as Nn, WildcardPermit as Nr, PendingUnshieldQueryConfig as Nt, registerPermitMutationOptions as O, SigningRejectedError as On, PreparedPermitV2 as Or, BatchBalancesResult as Ot, encryptMutationOptions as P, NotEntitledError as Pn, ChecksummedAddress as Pr, pendingUnshieldQueryOptions as Pt, ConfidentialTransferFromAndCallParams as Q, DelegationExpiredError as Qn, ERC7984_INTERFACE_ID as Qr, QueryFilterLike as Qt, WrapParams as R, BalanceErrorDetails as Rn, getConfidentialTokenAddressContract as Rr, wrapperDiscoveryQueryOptions as Rt, delegateDecryptionMutationOptions as S, wrapContract as Si, matchZamaError as Sn, PermissionV1 as Sr, tokenPairsSliceQueryOptions as St, HasPermitQueryConfig as T, TransactionRevertedError as Tn, PreparedPermit as Tr, ConfidentialBalanceQueryConfig as Tt, resumeUnshieldMutationOptions as U, DecryptionFailedError as Un, getTokenPairsSliceContract as Ur, TotalSupplyQueryConfig as Ut, unwrapMutationOptions as V, InsufficientConfidentialBalanceError as Vn, getTokenPairsContract as Vr, WrappersRegistry as Vt, UnshieldAllParams as W, EncryptOffloadUnavailableError as Wn, isConfidentialTokenValidContract as Wr, totalSupplyQueryOptions as Wt, ConfidentialSetOperatorParams as X, DelegationDelegateEqualsContractError as Xn, transferAndCallContract as Xr, tokenMetadataQueryOptions as Xt, approveUnderlyingMutationOptions as Y, DelegationDelegateCannotBeWildcardError as Yn, revokeDelegationContract as Yr, TokenMetadataQueryConfig as Yt, confidentialSetOperatorMutationOptions as Z, DelegationExpirationTooSoonError as Zn, ERC1363_INTERFACE_ID as Zr, QueryClientLike as Zt, BatchDecryptBalancesAsParams as _, setOperatorContract as _i, hashFn as _n, ZamaErrorCode as _r, listPairsQueryOptions as _t, ZamaSDK as a, balanceOfContract as ai, invalidateAfterUnshieldSettled as an, InvalidationTimestampTooLowError as ar, confidentialTransferMutationOptions as at, decryptBalanceAsMutationOptions as b, unwrapFromBalanceContract as bi, Permits as bn, Permission as br, tokenPairsLengthQueryOptions as bt, BatchDecryptItem as c, symbolContract as ci, invalidateBalanceQueries as cn, PreparedPermitChainMismatchError as cr, ConfidentialTokenAddressQueryConfig as ct, DelegationStatusQueryConfig as d, confidentialTransferContract as di, zamaQueryKeys as dn, TransportKeyPairChangedError as dr, TokenAddressQueryConfig as dt, isConfidentialTokenContract as ei, invalidateAfterApproveUnderlying as en, DelegationNotFoundError as er, ConfidentialTransferFromParams as et, delegationStatusQueryOptions as f, confidentialTransferFromContract as fi, SignerQueryContext as fn, TransportKeyPairExpiredError as fr, TokenPairQueryConfig as ft, revokeDelegationMutationOptions as g, rateContract as gi, filterQueryOptions as gn, ZamaError as gr, isConfidentialTokenValidQueryOptions as gt, RevokeDelegationParams as h, isOperatorContract as hi, StrippedQueryOptionKeys as hn, ChainMismatchError as hr, confidentialTokenAddressQueryOptions as ht, decryptValuesQueryOptions as i, approveContract as ii, invalidateAfterUnshield as in, InvalidationTimestampInFutureError as ir, ConfidentialTransferParams as it, decryptPublicValuesMutationOptions as j, WalletAccountNotReadyError as jn, SerializedTransportKeyPair as jr, ConfidentialIsOperatorQueryConfig as jt, preparePermitMutationOptions as k, SignerNotConfiguredError as kn, SerializedPermit as kr, BatchDecryptAsOptions as kt, BatchDecryptResult as l, confidentialBalanceOfContract as li, invalidateWagmiBalanceQueries as ln, PreparedPermitExpiredError as lr, IsConfidentialTokenValidQueryConfig as lt, invalidateDecryptionSignaturesMutationOptions as m, inferredTotalSupplyContract as mi, QueryFactoryOptions as mn, UnifiedPermitNotSupportedError as mr, WrappersRegistryQueryConfig as mt, DecryptResult as n, supportsInterfaceContract as ni, invalidateAfterShield as nn, DelegationSelfNotAllowedError as nr, ConfidentialTransferAndCallParams as nt, ZamaSDKOptions as o, decimalsContract as oi, invalidateAfterUnwrap as on, KeyWrappingError as or, ShieldParams as ot, InvalidateDecryptionSignaturesParams as p, finalizeUnwrapContract as pi, MutationFactoryOptions as pn, UnifiedDecryptionUnsupportedError as pr, TokenPairsSliceQueryConfig as pt, unshieldMutationOptions as q, DelegationContractIsSelfError as qn, invalidateDecryptionSignaturesBeforeContract as qr, isWrapperQueryOptions as qt, EncryptedInput as r, allowanceContract as ri, invalidateAfterTransfer as rn, InvalidTransportKeyPairError as rr, confidentialTransferAndCallMutationOptions as rt, Offline as s, nameContract as si, invalidateAfterWrap as sn, NoCiphertextError as sr, shieldMutationOptions as st, Decryption as t, isConfidentialWrapperContract as ti, invalidateAfterSetOperator as tn, DelegationNotPropagatedError as tr, confidentialTransferFromMutationOptions as tt, DelegatedDecryptOptions as u, confidentialTotalSupplyContract as ui, invalidateWalletLifecycleQueries as un, RevokedKmsContextError as ur, ListPairsQueryConfig as ut, batchDecryptBalancesAsMutationOptions as v, underlyingContract as vi, Delegations as vn, isRetryable as vr, tokenAddressQueryOptions as vt, revokePermitsMutationOptions as w, UnshieldAlreadyFinalizedError as wn, PreparePermitRequest as wr, confidentialBalancesQueryOptions as wt, DelegateDecryptionParams as x, unwrapRequesterContract as xi, ErrorForCode as xn, PermissionBase as xr, tokenPairsQueryOptions as xt, DecryptBalanceAsParams as y, unwrapContract as yi, DelegationStatus as yn, retryAfterSeconds as yr, tokenPairQueryOptions as yt, wrapMutationOptions as z, ERC20ReadFailedError as zn, getTokenAddressContract as zr, DefaultRegistryAddresses as zt };
23016
- //# sourceMappingURL=index-DRrrBtMX.d.ts.map
22041
+ //#region src/storage/memory-storage.d.ts
22042
+ /** In-memory credential store. Credentials are lost on page reload. */
22043
+ declare class MemoryStorage implements GenericStorage {
22044
+ #private;
22045
+ /**
22046
+ * Retrieve a value by key.
22047
+ * @returns The stored value, or `null` if the key does not exist.
22048
+ */
22049
+ get<T = unknown>(key: string): Promise<T | null>;
22050
+ /** Store a value under the given key, overwriting any existing entry. */
22051
+ set<T = unknown>(key: string, value: T): Promise<void>;
22052
+ /** Remove the entry for the given key (no-op if absent). */
22053
+ delete(key: string): Promise<void>;
22054
+ }
22055
+ /** Default singleton for application-wide use. */
22056
+ declare const memoryStorage: MemoryStorage;
22057
+ //#endregion
22058
+ //#region src/storage/indexeddb-storage.d.ts
22059
+ /**
22060
+ * IndexedDB-backed {@link GenericStorage}.
22061
+ *
22062
+ * Stores keypair and permit objects keyed by a hashed wallet address. The
22063
+ * SDK delegates security to the storage backend — values are persisted
22064
+ * verbatim with no SDK-layer encryption.
22065
+ */
22066
+ declare class IndexedDBStorage implements GenericStorage {
22067
+ #private;
22068
+ constructor(dbName?: string, dbVersion?: number, storeName?: string);
22069
+ /**
22070
+ * Retrieve a value by key.
22071
+ * @returns The stored value, or `null` if the key does not exist.
22072
+ */
22073
+ get<T = unknown>(key: string): Promise<T | null>;
22074
+ /** Store a value under the given key, overwriting any existing entry. */
22075
+ set<T = unknown>(key: string, value: T): Promise<void>;
22076
+ /** Remove the entry for the given key (no-op if absent). */
22077
+ delete(key: string): Promise<void>;
22078
+ /** Remove all stored entries. */
22079
+ clear(): Promise<void>;
22080
+ }
22081
+ /** Default singleton for application-wide use. */
22082
+ declare const indexedDBStorage: IndexedDBStorage;
22083
+ //#endregion
22084
+ //#region src/storage/chrome-session-storage.d.ts
22085
+ /**
22086
+ * {@link GenericStorage} backed by `chrome.storage.session`.
22087
+ *
22088
+ * Use this in MV3 web extensions so the wallet signature survives
22089
+ * service worker restarts and is shared across popup, background,
22090
+ * and content script contexts.
22091
+ *
22092
+ * @example
22093
+ * ```ts
22094
+ * import { ZamaSDK, indexedDBStorage, chromeSessionStorage } from "@zama-fhe/sdk";
22095
+ * import { createConfig } from "@zama-fhe/sdk/viem";
22096
+ *
22097
+ * const config = createConfig({
22098
+ * chains: [mySepolia],
22099
+ * publicClient,
22100
+ * walletClient,
22101
+ * relayers: { [mySepolia.id]: web() },
22102
+ * storage: indexedDBStorage, // encrypted transport key pair — persistent
22103
+ * permitStorage: chromeSessionStorage, // signed permits — ephemeral
22104
+ * });
22105
+ * const sdk = new ZamaSDK(config);
22106
+ * ```
22107
+ */
22108
+ declare class ChromeSessionStorage implements GenericStorage {
22109
+ /**
22110
+ * Retrieve a value by key.
22111
+ * @returns The stored value, or `null` if the key does not exist.
22112
+ */
22113
+ get<T = unknown>(key: string): Promise<T | null>;
22114
+ /** Store a value under the given key, overwriting any existing entry. */
22115
+ set(key: string, value: unknown): Promise<void>;
22116
+ /** Remove the entry for the given key (no-op if absent). */
22117
+ delete(key: string): Promise<void>;
22118
+ }
22119
+ /** Default singleton for application-wide use. */
22120
+ declare const chromeSessionStorage: ChromeSessionStorage;
22121
+ //#endregion
22122
+ //#region src/utils/handles.d.ts
22123
+ /** All-zero encrypted-value sentinel — a 32-byte zero handle representing the cleartext value `0`. */
22124
+ declare const ZERO_ENCRYPTED_VALUE: "0x0000000000000000000000000000000000000000000000000000000000000000";
22125
+ /**
22126
+ * Check whether an encrypted value represents the zero value.
22127
+ */
22128
+ declare function isEncryptedValueZero(encryptedValue: string): boolean;
22129
+ //#endregion
22130
+ export { BalanceErrorDetails as $, ERC7984_INTERFACE_ID as $t, BatchDecryptAsOptions as A, Permission as At, TransactionRevertedError as B, getConfidentialTokenAddressContract as Bt, ZamaSDKOptions as C, wrapContract as Cn, TransportKeyPairChangedError as Ct, WrappersRegistryConfig as D, ZamaErrorCode as Dt, WrappersRegistry as E, ZamaError as Et, Permits as F, SerializedTransportKeyPair as Ft, SignerRequiredError as G, getTokenPairsSliceContract as Gt, SigningFailedError as H, getTokenPairContract as Ht, ErrorForCode as I, ChecksummedAddress as It, RpcRateLimitError as J, getDelegationExpiryContract as Jt, WalletAccountNotReadyError as K, isConfidentialTokenValidContract as Kt, matchZamaError as L, PaginatedResult as Lt, Offline as M, PreparedPermit as Mt, Delegations as N, SerializedPermit as Nt, WrappedToken as O, isRetryable as Ot, DelegationStatus as P, SerializedPermitEip712 as Pt, BalanceCheckUnavailableError as Q, ERC1363_INTERFACE_ID as Qt, UnshieldAlreadyFinalizedDetails as R, TokenWrapperPair as Rt, ZamaSDK as S, unwrapRequesterContract as Sn, RevokedKmsContextError as St, ListPairsOptions as T, ChainMismatchError as Tt, SigningRejectedError as U, getTokenPairsContract as Ut, SigningErrorMetadata as V, getTokenAddressContract as Vt, SignerNotConfiguredError as W, getTokenPairsLengthContract as Wt, ConfigurationError as X, revokeDelegationContract as Xt, NotEntitledError as Y, isHandleDelegatedContract as Yt, RelayerRequestFailedError as Z, transferAndCallContract as Zt, decryptValuesQueryOptions as _, rateContract as _n, InvalidTransportKeyPairError as _t, ChromeSessionStorage as a, approveContract as an, EncryptOffloadUnavailableError as at, MutationFactoryOptions as b, unwrapContract as bn, PreparedPermitChainMismatchError as bt, indexedDBStorage as c, nameContract as cn, DelegationContractIsSelfError as ct, Decryption as d, confidentialTotalSupplyContract as dn, DelegationExpirationTooSoonError as dt, ERC7984_WRAPPER_INTERFACE_ID as en, ERC20ReadFailedError as et, BatchDecryptItem as f, confidentialTransferContract as fn, DelegationExpiredError as ft, EncryptedInput as g, isOperatorContract as gn, DelegationSelfNotAllowedError as gt, DecryptResult as h, inferredTotalSupplyContract as hn, DelegationNotPropagatedError as ht, isEncryptedValueZero as i, allowanceContract as in, DecryptionFailedError as it, Token as j, PreparePermitRequest as jt, BatchBalancesResult as k, retryAfterSeconds as kt, MemoryStorage as l, symbolContract as ln, DelegationCooldownError as lt, DelegatedDecryptOptions as m, finalizeUnwrapContract as mn, DelegationNotFoundError as mt, Hex$1 as n, isConfidentialWrapperContract as nn, InsufficientConfidentialBalanceError as nt, chromeSessionStorage as o, balanceOfContract as on, EncryptionFailedError as ot, BatchDecryptResult as p, confidentialTransferFromContract as pn, DelegationExpiryUnchangedError as pt, WalletNotConnectedError as q, delegateForUserDecryptionContract as qt, ZERO_ENCRYPTED_VALUE as r, supportsInterfaceContract as rn, InsufficientERC20BalanceError as rt, IndexedDBStorage as s, decimalsContract as sn, AclPausedError as st, Address$1 as t, isConfidentialTokenContract as tn, InsufficientAllowanceError as tt, memoryStorage as u, confidentialBalanceOfContract as un, DelegationDelegateEqualsContractError as ut, SignerQueryContext as v, setOperatorContract as vn, KeyWrappingError as vt, DefaultRegistryAddresses as w, createConfig as wn, TransportKeyPairExpiredError as wt, QueryFactoryOptions as x, unwrapFromBalanceContract as xn, PreparedPermitExpiredError as xt, zamaQueryKeys as y, underlyingContract as yn, NoCiphertextError as yt, UnshieldAlreadyFinalizedError as z, TokenWrapperPairWithMetadata as zt };
22131
+ //# sourceMappingURL=index-DJYq1rAB.d.ts.map