@zama-fhe/sdk 3.2.0 → 3.3.0-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/base-signer.cjs +1 -1
- package/dist/cjs/ethers/index.cjs +1 -1
- package/dist/cjs/index.cjs +1 -1
- package/dist/cjs/query/index.cjs +1 -1
- package/dist/cjs/query/index.cjs.map +1 -1
- package/dist/cjs/token.cjs +1 -1
- package/dist/cjs/token.cjs.map +1 -1
- package/dist/cjs/viem/index.cjs +1 -1
- package/dist/cjs/wrappers-registry.cjs +1 -1
- package/dist/cjs/wrappers-registry.cjs.map +1 -1
- package/dist/esm/base-signer-DaRQNB29.js +2 -0
- package/dist/esm/{base-signer-BVqcM5jt.js.map → base-signer-DaRQNB29.js.map} +1 -1
- package/dist/esm/{cleartext-DMW5nK1M.d.ts → cleartext-4WhQWHZF.d.ts} +2 -2
- package/dist/esm/ethers/index.d.ts +2 -2
- package/dist/esm/ethers/index.js +1 -1
- package/dist/esm/ethers/index.js.map +1 -1
- package/dist/esm/{index-DoVo9J1n.d.ts → index-BRIQ3Msg.d.ts} +56 -2
- package/dist/esm/index.d.ts +5 -5
- package/dist/esm/index.js +1 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/node/index.d.ts +2 -2
- package/dist/esm/node/index.js +1 -1
- package/dist/esm/node/index.js.map +1 -1
- package/dist/esm/query/index.d.ts +26 -3
- package/dist/esm/query/index.js +1 -1
- package/dist/esm/query/index.js.map +1 -1
- package/dist/esm/token-BTgHqRIL.js +2 -0
- package/dist/esm/token-BTgHqRIL.js.map +1 -0
- package/dist/esm/{types-BjDu-RZg.d.ts → types-C4JRzs5M.d.ts} +13 -1
- package/dist/esm/{types-DiZhtG8i.d.ts → types-Cb7AvEOP.d.ts} +2 -2
- package/dist/esm/{types-Xg_On_yY.d.ts → types-DJp9eoXC.d.ts} +2 -2
- package/dist/esm/viem/index.d.ts +2 -2
- package/dist/esm/viem/index.js +1 -1
- package/dist/esm/web/index.d.ts +1 -1
- package/dist/esm/{wrappers-registry-BWWG0aze.js → wrappers-registry-ChxQp8ty.js} +2 -2
- package/dist/esm/wrappers-registry-ChxQp8ty.js.map +1 -0
- package/package.json +1 -1
- package/dist/esm/base-signer-BVqcM5jt.js +0 -2
- package/dist/esm/token-TQ-VFHS4.js +0 -2
- package/dist/esm/token-TQ-VFHS4.js.map +0 -1
- package/dist/esm/wrappers-registry-BWWG0aze.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wrappers-registry-ChxQp8ty.js","names":[],"sources":["../../src/errors/signing.ts","../../src/errors/signer.ts","../../src/utils/swallow.ts","../../src/abi/confidential-wrapper.abi.ts","../../src/contracts/confidential-wrapper.ts","../../src/contracts/erc20.ts","../../src/abi/erc165.abi.ts","../../src/contracts/erc165.ts","../../src/contracts/wrappers-registry.ts"],"sourcesContent":["import { ZamaError, ZamaErrorCode } from \"./base\";\n\n/** User rejected the wallet signature prompt. */\nexport class SigningRejectedError extends ZamaError {\n constructor(message: string, options?: ErrorOptions) {\n super(ZamaErrorCode.SigningRejected, message, options);\n this.name = \"SigningRejectedError\";\n }\n}\n\n/** Wallet signature failed for a reason other than rejection. */\nexport class SigningFailedError extends ZamaError {\n constructor(message: string, options?: ErrorOptions) {\n super(ZamaErrorCode.SigningFailed, message, options);\n this.name = \"SigningFailedError\";\n }\n}\n\n/**\n * Wrap a signing error as {@link SigningRejectedError} or {@link SigningFailedError}.\n * Detects user rejection via EIP-1193 code 4001 or message heuristics.\n */\nexport function wrapSigningError(error: unknown, context: string): never {\n const hasCode4001 =\n typeof error === \"object\" && error !== null && \"code\" in error && error.code === 4001;\n const originalMsg = error instanceof Error ? error.message : String(error);\n const lowerMsg = originalMsg.toLowerCase();\n const hasRejectionMessage =\n lowerMsg.includes(\"user rejected\") || lowerMsg.includes(\"user denied\");\n const fullMessage = `${context}: ${originalMsg}`;\n if (hasCode4001 || hasRejectionMessage) {\n throw new SigningRejectedError(fullMessage, { cause: error });\n }\n throw new SigningFailedError(fullMessage, { cause: error });\n}\n","import { ZamaError, ZamaErrorCode } from \"./base\";\n\n/**\n * Base class for signer/account readiness failures.\n */\nexport class SignerRequiredError extends ZamaError {\n readonly operation: string;\n\n constructor(code: ZamaErrorCode, operation: string, message: string, options?: ErrorOptions) {\n super(code, message, options);\n this.name = \"SignerRequiredError\";\n this.operation = operation;\n }\n}\n\n/**\n * Thrown when an operation requires a signer but none is configured.\n *\n * The SDK can be constructed without a signer. Operations that need wallet\n * authority throw this before probing wallet state.\n *\n * @example\n * ```ts\n * try {\n * await token.confidentialTransfer(\"0xTo\", 100n);\n * } catch (e) {\n * if (e instanceof SignerNotConfiguredError) {\n * // Fix SDK/provider configuration.\n * }\n * }\n * ```\n */\nexport class SignerNotConfiguredError extends SignerRequiredError {\n constructor(operation: string, options?: ErrorOptions) {\n super(\n ZamaErrorCode.SignerNotConfigured,\n operation,\n `Cannot ${operation} without a signer. Configure one via createConfig({ signer: ... }) or <ZamaProvider config={createConfig({ signer: ... })}>.`,\n options,\n );\n this.name = \"SignerNotConfiguredError\";\n }\n}\n\n/** Thrown when a signer exists but no wallet account is currently connected. */\nexport class WalletNotConnectedError extends SignerRequiredError {\n constructor(operation: string, options?: ErrorOptions) {\n super(\n ZamaErrorCode.WalletNotConnected,\n operation,\n `Cannot ${operation} without a connected wallet account.`,\n options,\n );\n this.name = \"WalletNotConnectedError\";\n }\n}\n\n/** Thrown when an async adapter has not resolved its initial wallet account yet. */\nexport class WalletAccountNotReadyError extends SignerRequiredError {\n constructor(operation: string, options?: ErrorOptions) {\n super(\n ZamaErrorCode.WalletAccountNotReady,\n operation,\n `Cannot ${operation} before the wallet account is ready.`,\n options,\n );\n this.name = \"WalletAccountNotReadyError\";\n }\n}\n\n/**\n * Narrow a nullable signer-dependent value or throw {@link SignerNotConfiguredError}.\n */\nexport function requireConfigured<T>(value: T, operation: string): NonNullable<T> {\n if (value === null || value === undefined) {\n throw new SignerNotConfiguredError(operation);\n }\n return value as NonNullable<T>;\n}\n","import type { GenericLogger } from \"../worker/worker.types\";\n\n/**\n * Runs a function and swallows any errors.\n *\n * The swallowed error is a handled, best-effort failure — when a logger is\n * supplied it is routed to the {@link GenericLogger} at `warn`, never to the\n * console. Most SDK call sites pass the SDK-wide logger; a few (e.g. a signer\n * constructed before `createConfig` exists) genuinely have none, so the logger\n * is optional and the failure is then silent.\n */\nexport async function swallow(\n label: string,\n fn: () => Promise<void> | void,\n logger?: GenericLogger,\n): Promise<void> {\n try {\n await fn();\n } catch (error) {\n logger?.warn(`${label} failed`, { error });\n }\n}\n","// DO NOT EDIT: generated by `pnpm abi:build` from\n// contracts/out/ConfidentialWrapperV3.sol/ConfidentialWrapperV3.json.\n// Regenerate after `pnpm contracts:build`; `pnpm abi:check` enforces this in CI.\nexport const confidentialWrapperAbi = [\n {\n type: \"function\",\n name: \"UPGRADE_INTERFACE_VERSION\",\n inputs: [],\n outputs: [\n {\n name: \"\",\n type: \"string\",\n internalType: \"string\",\n },\n ],\n stateMutability: \"view\",\n },\n {\n type: \"function\",\n name: \"acceptOwnership\",\n inputs: [],\n outputs: [],\n stateMutability: \"nonpayable\",\n },\n {\n type: \"function\",\n name: \"blockUser\",\n inputs: [\n {\n name: \"user\",\n type: \"address\",\n internalType: \"address\",\n },\n ],\n outputs: [],\n stateMutability: \"nonpayable\",\n },\n {\n type: \"function\",\n name: \"confidentialBalanceOf\",\n inputs: [\n {\n name: \"account\",\n type: \"address\",\n internalType: \"address\",\n },\n ],\n outputs: [\n {\n name: \"\",\n type: \"bytes32\",\n internalType: \"euint64\",\n },\n ],\n stateMutability: \"view\",\n },\n {\n type: \"function\",\n name: \"confidentialProtocolId\",\n inputs: [],\n outputs: [\n {\n name: \"\",\n type: \"uint256\",\n internalType: \"uint256\",\n },\n ],\n stateMutability: \"view\",\n },\n {\n type: \"function\",\n name: \"confidentialTotalSupply\",\n inputs: [],\n outputs: [\n {\n name: \"\",\n type: \"bytes32\",\n internalType: \"euint64\",\n },\n ],\n stateMutability: \"view\",\n },\n {\n type: \"function\",\n name: \"confidentialTransfer\",\n inputs: [\n {\n name: \"to\",\n type: \"address\",\n internalType: \"address\",\n },\n {\n name: \"encryptedAmount\",\n type: \"bytes32\",\n internalType: \"externalEuint64\",\n },\n {\n name: \"inputProof\",\n type: \"bytes\",\n internalType: \"bytes\",\n },\n ],\n outputs: [\n {\n name: \"\",\n type: \"bytes32\",\n internalType: \"euint64\",\n },\n ],\n stateMutability: \"nonpayable\",\n },\n {\n type: \"function\",\n name: \"confidentialTransfer\",\n inputs: [\n {\n name: \"to\",\n type: \"address\",\n internalType: \"address\",\n },\n {\n name: \"amount\",\n type: \"bytes32\",\n internalType: \"euint64\",\n },\n ],\n outputs: [\n {\n name: \"\",\n type: \"bytes32\",\n internalType: \"euint64\",\n },\n ],\n stateMutability: \"nonpayable\",\n },\n {\n type: \"function\",\n name: \"confidentialTransferAndCall\",\n inputs: [\n {\n name: \"to\",\n type: \"address\",\n internalType: \"address\",\n },\n {\n name: \"amount\",\n type: \"bytes32\",\n internalType: \"euint64\",\n },\n {\n name: \"data\",\n type: \"bytes\",\n internalType: \"bytes\",\n },\n ],\n outputs: [\n {\n name: \"transferred\",\n type: \"bytes32\",\n internalType: \"euint64\",\n },\n ],\n stateMutability: \"nonpayable\",\n },\n {\n type: \"function\",\n name: \"confidentialTransferAndCall\",\n inputs: [\n {\n name: \"to\",\n type: \"address\",\n internalType: \"address\",\n },\n {\n name: \"encryptedAmount\",\n type: \"bytes32\",\n internalType: \"externalEuint64\",\n },\n {\n name: \"inputProof\",\n type: \"bytes\",\n internalType: \"bytes\",\n },\n {\n name: \"data\",\n type: \"bytes\",\n internalType: \"bytes\",\n },\n ],\n outputs: [\n {\n name: \"transferred\",\n type: \"bytes32\",\n internalType: \"euint64\",\n },\n ],\n stateMutability: \"nonpayable\",\n },\n {\n type: \"function\",\n name: \"confidentialTransferFrom\",\n inputs: [\n {\n name: \"from\",\n type: \"address\",\n internalType: \"address\",\n },\n {\n name: \"to\",\n type: \"address\",\n internalType: \"address\",\n },\n {\n name: \"encryptedAmount\",\n type: \"bytes32\",\n internalType: \"externalEuint64\",\n },\n {\n name: \"inputProof\",\n type: \"bytes\",\n internalType: \"bytes\",\n },\n ],\n outputs: [\n {\n name: \"transferred\",\n type: \"bytes32\",\n internalType: \"euint64\",\n },\n ],\n stateMutability: \"nonpayable\",\n },\n {\n type: \"function\",\n name: \"confidentialTransferFrom\",\n inputs: [\n {\n name: \"from\",\n type: \"address\",\n internalType: \"address\",\n },\n {\n name: \"to\",\n type: \"address\",\n internalType: \"address\",\n },\n {\n name: \"amount\",\n type: \"bytes32\",\n internalType: \"euint64\",\n },\n ],\n outputs: [\n {\n name: \"transferred\",\n type: \"bytes32\",\n internalType: \"euint64\",\n },\n ],\n stateMutability: \"nonpayable\",\n },\n {\n type: \"function\",\n name: \"confidentialTransferFromAndCall\",\n inputs: [\n {\n name: \"from\",\n type: \"address\",\n internalType: \"address\",\n },\n {\n name: \"to\",\n type: \"address\",\n internalType: \"address\",\n },\n {\n name: \"encryptedAmount\",\n type: \"bytes32\",\n internalType: \"externalEuint64\",\n },\n {\n name: \"inputProof\",\n type: \"bytes\",\n internalType: \"bytes\",\n },\n {\n name: \"data\",\n type: \"bytes\",\n internalType: \"bytes\",\n },\n ],\n outputs: [\n {\n name: \"transferred\",\n type: \"bytes32\",\n internalType: \"euint64\",\n },\n ],\n stateMutability: \"nonpayable\",\n },\n {\n type: \"function\",\n name: \"confidentialTransferFromAndCall\",\n inputs: [\n {\n name: \"from\",\n type: \"address\",\n internalType: \"address\",\n },\n {\n name: \"to\",\n type: \"address\",\n internalType: \"address\",\n },\n {\n name: \"amount\",\n type: \"bytes32\",\n internalType: \"euint64\",\n },\n {\n name: \"data\",\n type: \"bytes\",\n internalType: \"bytes\",\n },\n ],\n outputs: [\n {\n name: \"transferred\",\n type: \"bytes32\",\n internalType: \"euint64\",\n },\n ],\n stateMutability: \"nonpayable\",\n },\n {\n type: \"function\",\n name: \"contractURI\",\n inputs: [],\n outputs: [\n {\n name: \"\",\n type: \"string\",\n internalType: \"string\",\n },\n ],\n stateMutability: \"view\",\n },\n {\n type: \"function\",\n name: \"decimals\",\n inputs: [],\n outputs: [\n {\n name: \"\",\n type: \"uint8\",\n internalType: \"uint8\",\n },\n ],\n stateMutability: \"view\",\n },\n {\n type: \"function\",\n name: \"discloseEncryptedAmount\",\n inputs: [\n {\n name: \"encryptedAmount\",\n type: \"bytes32\",\n internalType: \"euint64\",\n },\n {\n name: \"cleartextAmount\",\n type: \"uint64\",\n internalType: \"uint64\",\n },\n {\n name: \"decryptionProof\",\n type: \"bytes\",\n internalType: \"bytes\",\n },\n ],\n outputs: [],\n stateMutability: \"nonpayable\",\n },\n {\n type: \"function\",\n name: \"finalizeUnwrap\",\n inputs: [\n {\n name: \"unwrapRequestId\",\n type: \"bytes32\",\n internalType: \"bytes32\",\n },\n {\n name: \"unwrapAmountCleartext\",\n type: \"uint64\",\n internalType: \"uint64\",\n },\n {\n name: \"decryptionProof\",\n type: \"bytes\",\n internalType: \"bytes\",\n },\n ],\n outputs: [],\n stateMutability: \"nonpayable\",\n },\n {\n type: \"function\",\n name: \"getUnderlyingDenyListSelector\",\n inputs: [],\n outputs: [\n {\n name: \"isSet\",\n type: \"bool\",\n internalType: \"bool\",\n },\n {\n name: \"selector\",\n type: \"bytes4\",\n internalType: \"bytes4\",\n },\n ],\n stateMutability: \"view\",\n },\n {\n type: \"function\",\n name: \"inferredTotalSupply\",\n inputs: [],\n outputs: [\n {\n name: \"\",\n type: \"uint256\",\n internalType: \"uint256\",\n },\n ],\n stateMutability: \"view\",\n },\n {\n type: \"function\",\n name: \"initialize\",\n inputs: [\n {\n name: \"name_\",\n type: \"string\",\n internalType: \"string\",\n },\n {\n name: \"symbol_\",\n type: \"string\",\n internalType: \"string\",\n },\n {\n name: \"contractURI_\",\n type: \"string\",\n internalType: \"string\",\n },\n {\n name: \"underlying_\",\n type: \"address\",\n internalType: \"contract IERC20\",\n },\n {\n name: \"owner_\",\n type: \"address\",\n internalType: \"address\",\n },\n ],\n outputs: [],\n stateMutability: \"nonpayable\",\n },\n {\n type: \"function\",\n name: \"isBlocked\",\n inputs: [\n {\n name: \"user\",\n type: \"address\",\n internalType: \"address\",\n },\n ],\n outputs: [\n {\n name: \"\",\n type: \"bool\",\n internalType: \"bool\",\n },\n ],\n stateMutability: \"view\",\n },\n {\n type: \"function\",\n name: \"isOperator\",\n inputs: [\n {\n name: \"holder\",\n type: \"address\",\n internalType: \"address\",\n },\n {\n name: \"spender\",\n type: \"address\",\n internalType: \"address\",\n },\n ],\n outputs: [\n {\n name: \"\",\n type: \"bool\",\n internalType: \"bool\",\n },\n ],\n stateMutability: \"view\",\n },\n {\n type: \"function\",\n name: \"maxTotalSupply\",\n inputs: [],\n outputs: [\n {\n name: \"\",\n type: \"uint256\",\n internalType: \"uint256\",\n },\n ],\n stateMutability: \"view\",\n },\n {\n type: \"function\",\n name: \"name\",\n inputs: [],\n outputs: [\n {\n name: \"\",\n type: \"string\",\n internalType: \"string\",\n },\n ],\n stateMutability: \"view\",\n },\n {\n type: \"function\",\n name: \"onTransferReceived\",\n inputs: [\n {\n name: \"operator\",\n type: \"address\",\n internalType: \"address\",\n },\n {\n name: \"from\",\n type: \"address\",\n internalType: \"address\",\n },\n {\n name: \"amount\",\n type: \"uint256\",\n internalType: \"uint256\",\n },\n {\n name: \"data\",\n type: \"bytes\",\n internalType: \"bytes\",\n },\n ],\n outputs: [\n {\n name: \"\",\n type: \"bytes4\",\n internalType: \"bytes4\",\n },\n ],\n stateMutability: \"nonpayable\",\n },\n {\n type: \"function\",\n name: \"owner\",\n inputs: [],\n outputs: [\n {\n name: \"\",\n type: \"address\",\n internalType: \"address\",\n },\n ],\n stateMutability: \"view\",\n },\n {\n type: \"function\",\n name: \"pendingOwner\",\n inputs: [],\n outputs: [\n {\n name: \"\",\n type: \"address\",\n internalType: \"address\",\n },\n ],\n stateMutability: \"view\",\n },\n {\n type: \"function\",\n name: \"proxiableUUID\",\n inputs: [],\n outputs: [\n {\n name: \"\",\n type: \"bytes32\",\n internalType: \"bytes32\",\n },\n ],\n stateMutability: \"view\",\n },\n {\n type: \"function\",\n name: \"rate\",\n inputs: [],\n outputs: [\n {\n name: \"\",\n type: \"uint256\",\n internalType: \"uint256\",\n },\n ],\n stateMutability: \"view\",\n },\n {\n type: \"function\",\n name: \"reinitializeV2\",\n inputs: [],\n outputs: [],\n stateMutability: \"nonpayable\",\n },\n {\n type: \"function\",\n name: \"reinitializeV3\",\n inputs: [\n {\n name: \"blockedUsers\",\n type: \"address[]\",\n internalType: \"address[]\",\n },\n {\n name: \"underlyingDenyListSelector\",\n type: \"bytes4\",\n internalType: \"bytes4\",\n },\n {\n name: \"hasUnderlyingDenyListSelector_\",\n type: \"bool\",\n internalType: \"bool\",\n },\n ],\n outputs: [],\n stateMutability: \"nonpayable\",\n },\n {\n type: \"function\",\n name: \"renounceOwnership\",\n inputs: [],\n outputs: [],\n stateMutability: \"nonpayable\",\n },\n {\n type: \"function\",\n name: \"requestDiscloseEncryptedAmount\",\n inputs: [\n {\n name: \"encryptedAmount\",\n type: \"bytes32\",\n internalType: \"euint64\",\n },\n ],\n outputs: [],\n stateMutability: \"nonpayable\",\n },\n {\n type: \"function\",\n name: \"setOperator\",\n inputs: [\n {\n name: \"operator\",\n type: \"address\",\n internalType: \"address\",\n },\n {\n name: \"until\",\n type: \"uint48\",\n internalType: \"uint48\",\n },\n ],\n outputs: [],\n stateMutability: \"nonpayable\",\n },\n {\n type: \"function\",\n name: \"supportsInterface\",\n inputs: [\n {\n name: \"interfaceId\",\n type: \"bytes4\",\n internalType: \"bytes4\",\n },\n ],\n outputs: [\n {\n name: \"\",\n type: \"bool\",\n internalType: \"bool\",\n },\n ],\n stateMutability: \"view\",\n },\n {\n type: \"function\",\n name: \"symbol\",\n inputs: [],\n outputs: [\n {\n name: \"\",\n type: \"string\",\n internalType: \"string\",\n },\n ],\n stateMutability: \"view\",\n },\n {\n type: \"function\",\n name: \"transferOwnership\",\n inputs: [\n {\n name: \"newOwner\",\n type: \"address\",\n internalType: \"address\",\n },\n ],\n outputs: [],\n stateMutability: \"nonpayable\",\n },\n {\n type: \"function\",\n name: \"unblockUser\",\n inputs: [\n {\n name: \"user\",\n type: \"address\",\n internalType: \"address\",\n },\n ],\n outputs: [],\n stateMutability: \"nonpayable\",\n },\n {\n type: \"function\",\n name: \"underlying\",\n inputs: [],\n outputs: [\n {\n name: \"\",\n type: \"address\",\n internalType: \"address\",\n },\n ],\n stateMutability: \"view\",\n },\n {\n type: \"function\",\n name: \"unwrap\",\n inputs: [\n {\n name: \"from\",\n type: \"address\",\n internalType: \"address\",\n },\n {\n name: \"to\",\n type: \"address\",\n internalType: \"address\",\n },\n {\n name: \"encryptedAmount\",\n type: \"bytes32\",\n internalType: \"externalEuint64\",\n },\n {\n name: \"inputProof\",\n type: \"bytes\",\n internalType: \"bytes\",\n },\n ],\n outputs: [\n {\n name: \"\",\n type: \"bytes32\",\n internalType: \"bytes32\",\n },\n ],\n stateMutability: \"nonpayable\",\n },\n {\n type: \"function\",\n name: \"unwrap\",\n inputs: [\n {\n name: \"from\",\n type: \"address\",\n internalType: \"address\",\n },\n {\n name: \"to\",\n type: \"address\",\n internalType: \"address\",\n },\n {\n name: \"amount\",\n type: \"bytes32\",\n internalType: \"euint64\",\n },\n ],\n outputs: [\n {\n name: \"\",\n type: \"bytes32\",\n internalType: \"bytes32\",\n },\n ],\n stateMutability: \"nonpayable\",\n },\n {\n type: \"function\",\n name: \"unwrapAmount\",\n inputs: [\n {\n name: \"unwrapRequestId\",\n type: \"bytes32\",\n internalType: \"bytes32\",\n },\n ],\n outputs: [\n {\n name: \"\",\n type: \"bytes32\",\n internalType: \"euint64\",\n },\n ],\n stateMutability: \"view\",\n },\n {\n type: \"function\",\n name: \"unwrapRequester\",\n inputs: [\n {\n name: \"unwrapRequestId\",\n type: \"bytes32\",\n internalType: \"bytes32\",\n },\n ],\n outputs: [\n {\n name: \"\",\n type: \"address\",\n internalType: \"address\",\n },\n ],\n stateMutability: \"view\",\n },\n {\n type: \"function\",\n name: \"upgradeToAndCall\",\n inputs: [\n {\n name: \"newImplementation\",\n type: \"address\",\n internalType: \"address\",\n },\n {\n name: \"data\",\n type: \"bytes\",\n internalType: \"bytes\",\n },\n ],\n outputs: [],\n stateMutability: \"payable\",\n },\n {\n type: \"function\",\n name: \"wrap\",\n inputs: [\n {\n name: \"to\",\n type: \"address\",\n internalType: \"address\",\n },\n {\n name: \"amount\",\n type: \"uint256\",\n internalType: \"uint256\",\n },\n ],\n outputs: [\n {\n name: \"\",\n type: \"bytes32\",\n internalType: \"euint64\",\n },\n ],\n stateMutability: \"nonpayable\",\n },\n {\n type: \"event\",\n name: \"AmountDiscloseRequested\",\n inputs: [\n {\n name: \"encryptedAmount\",\n type: \"bytes32\",\n indexed: true,\n internalType: \"euint64\",\n },\n {\n name: \"requester\",\n type: \"address\",\n indexed: true,\n internalType: \"address\",\n },\n ],\n anonymous: false,\n },\n {\n type: \"event\",\n name: \"AmountDisclosed\",\n inputs: [\n {\n name: \"encryptedAmount\",\n type: \"bytes32\",\n indexed: true,\n internalType: \"euint64\",\n },\n {\n name: \"amount\",\n type: \"uint64\",\n indexed: false,\n internalType: \"uint64\",\n },\n ],\n anonymous: false,\n },\n {\n type: \"event\",\n name: \"ConfidentialTransfer\",\n inputs: [\n {\n name: \"from\",\n type: \"address\",\n indexed: true,\n internalType: \"address\",\n },\n {\n name: \"to\",\n type: \"address\",\n indexed: true,\n internalType: \"address\",\n },\n {\n name: \"amount\",\n type: \"bytes32\",\n indexed: true,\n internalType: \"euint64\",\n },\n ],\n anonymous: false,\n },\n {\n type: \"event\",\n name: \"Initialized\",\n inputs: [\n {\n name: \"version\",\n type: \"uint64\",\n indexed: false,\n internalType: \"uint64\",\n },\n ],\n anonymous: false,\n },\n {\n type: \"event\",\n name: \"OperatorSet\",\n inputs: [\n {\n name: \"holder\",\n type: \"address\",\n indexed: true,\n internalType: \"address\",\n },\n {\n name: \"operator\",\n type: \"address\",\n indexed: true,\n internalType: \"address\",\n },\n {\n name: \"until\",\n type: \"uint48\",\n indexed: false,\n internalType: \"uint48\",\n },\n ],\n anonymous: false,\n },\n {\n type: \"event\",\n name: \"OwnershipTransferStarted\",\n inputs: [\n {\n name: \"previousOwner\",\n type: \"address\",\n indexed: true,\n internalType: \"address\",\n },\n {\n name: \"newOwner\",\n type: \"address\",\n indexed: true,\n internalType: \"address\",\n },\n ],\n anonymous: false,\n },\n {\n type: \"event\",\n name: \"OwnershipTransferred\",\n inputs: [\n {\n name: \"previousOwner\",\n type: \"address\",\n indexed: true,\n internalType: \"address\",\n },\n {\n name: \"newOwner\",\n type: \"address\",\n indexed: true,\n internalType: \"address\",\n },\n ],\n anonymous: false,\n },\n {\n type: \"event\",\n name: \"PublicDecryptionVerified\",\n inputs: [\n {\n name: \"handlesList\",\n type: \"bytes32[]\",\n indexed: false,\n internalType: \"bytes32[]\",\n },\n {\n name: \"abiEncodedCleartexts\",\n type: \"bytes\",\n indexed: false,\n internalType: \"bytes\",\n },\n ],\n anonymous: false,\n },\n {\n type: \"event\",\n name: \"UnwrapFinalized\",\n inputs: [\n {\n name: \"receiver\",\n type: \"address\",\n indexed: true,\n internalType: \"address\",\n },\n {\n name: \"unwrapRequestId\",\n type: \"bytes32\",\n indexed: true,\n internalType: \"bytes32\",\n },\n {\n name: \"encryptedAmount\",\n type: \"bytes32\",\n indexed: false,\n internalType: \"euint64\",\n },\n {\n name: \"cleartextAmount\",\n type: \"uint64\",\n indexed: false,\n internalType: \"uint64\",\n },\n ],\n anonymous: false,\n },\n {\n type: \"event\",\n name: \"UnwrapRequested\",\n inputs: [\n {\n name: \"receiver\",\n type: \"address\",\n indexed: true,\n internalType: \"address\",\n },\n {\n name: \"unwrapRequestId\",\n type: \"bytes32\",\n indexed: true,\n internalType: \"bytes32\",\n },\n {\n name: \"amount\",\n type: \"bytes32\",\n indexed: false,\n internalType: \"euint64\",\n },\n ],\n anonymous: false,\n },\n {\n type: \"event\",\n name: \"Upgraded\",\n inputs: [\n {\n name: \"implementation\",\n type: \"address\",\n indexed: true,\n internalType: \"address\",\n },\n ],\n anonymous: false,\n },\n {\n type: \"event\",\n name: \"UserBlocked\",\n inputs: [\n {\n name: \"user\",\n type: \"address\",\n indexed: true,\n internalType: \"address\",\n },\n ],\n anonymous: false,\n },\n {\n type: \"event\",\n name: \"UserUnblocked\",\n inputs: [\n {\n name: \"user\",\n type: \"address\",\n indexed: true,\n internalType: \"address\",\n },\n ],\n anonymous: false,\n },\n {\n type: \"event\",\n name: \"Wrap\",\n inputs: [\n {\n name: \"to\",\n type: \"address\",\n indexed: true,\n internalType: \"address\",\n },\n {\n name: \"roundedAmount\",\n type: \"uint256\",\n indexed: false,\n internalType: \"uint256\",\n },\n {\n name: \"encryptedWrappedAmount\",\n type: \"bytes32\",\n indexed: false,\n internalType: \"euint64\",\n },\n ],\n anonymous: false,\n },\n {\n type: \"error\",\n name: \"AddressEmptyCode\",\n inputs: [\n {\n name: \"target\",\n type: \"address\",\n internalType: \"address\",\n },\n ],\n },\n {\n type: \"error\",\n name: \"BlockedUser\",\n inputs: [\n {\n name: \"user\",\n type: \"address\",\n internalType: \"address\",\n },\n ],\n },\n {\n type: \"error\",\n name: \"ERC1967InvalidImplementation\",\n inputs: [\n {\n name: \"implementation\",\n type: \"address\",\n internalType: \"address\",\n },\n ],\n },\n {\n type: \"error\",\n name: \"ERC1967NonPayable\",\n inputs: [],\n },\n {\n type: \"error\",\n name: \"ERC7984InvalidReceiver\",\n inputs: [\n {\n name: \"receiver\",\n type: \"address\",\n internalType: \"address\",\n },\n ],\n },\n {\n type: \"error\",\n name: \"ERC7984InvalidReceiver\",\n inputs: [\n {\n name: \"receiver\",\n type: \"address\",\n internalType: \"address\",\n },\n ],\n },\n {\n type: \"error\",\n name: \"ERC7984InvalidSender\",\n inputs: [\n {\n name: \"sender\",\n type: \"address\",\n internalType: \"address\",\n },\n ],\n },\n {\n type: \"error\",\n name: \"ERC7984TotalSupplyOverflow\",\n inputs: [],\n },\n {\n type: \"error\",\n name: \"ERC7984UnauthorizedCaller\",\n inputs: [\n {\n name: \"caller\",\n type: \"address\",\n internalType: \"address\",\n },\n ],\n },\n {\n type: \"error\",\n name: \"ERC7984UnauthorizedSpender\",\n inputs: [\n {\n name: \"holder\",\n type: \"address\",\n internalType: \"address\",\n },\n {\n name: \"spender\",\n type: \"address\",\n internalType: \"address\",\n },\n ],\n },\n {\n type: \"error\",\n name: \"ERC7984UnauthorizedUseOfEncryptedAmount\",\n inputs: [\n {\n name: \"amount\",\n type: \"bytes32\",\n internalType: \"euint64\",\n },\n {\n name: \"user\",\n type: \"address\",\n internalType: \"address\",\n },\n ],\n },\n {\n type: \"error\",\n name: \"ERC7984ZeroBalance\",\n inputs: [\n {\n name: \"holder\",\n type: \"address\",\n internalType: \"address\",\n },\n ],\n },\n {\n type: \"error\",\n name: \"FailedCall\",\n inputs: [],\n },\n {\n type: \"error\",\n name: \"InvalidInitialization\",\n inputs: [],\n },\n {\n type: \"error\",\n name: \"InvalidKMSSignatures\",\n inputs: [],\n },\n {\n type: \"error\",\n name: \"InvalidUnderlyingDenyListResponse\",\n inputs: [],\n },\n {\n type: \"error\",\n name: \"InvalidUnwrapRequest\",\n inputs: [\n {\n name: \"unwrapRequestId\",\n type: \"bytes32\",\n internalType: \"bytes32\",\n },\n ],\n },\n {\n type: \"error\",\n name: \"NotInitializing\",\n inputs: [],\n },\n {\n type: \"error\",\n name: \"OwnableInvalidOwner\",\n inputs: [\n {\n name: \"owner\",\n type: \"address\",\n internalType: \"address\",\n },\n ],\n },\n {\n type: \"error\",\n name: \"OwnableUnauthorizedAccount\",\n inputs: [\n {\n name: \"account\",\n type: \"address\",\n internalType: \"address\",\n },\n ],\n },\n {\n type: \"error\",\n name: \"SafeCastOverflowedUintDowncast\",\n inputs: [\n {\n name: \"bits\",\n type: \"uint8\",\n internalType: \"uint8\",\n },\n {\n name: \"value\",\n type: \"uint256\",\n internalType: \"uint256\",\n },\n ],\n },\n {\n type: \"error\",\n name: \"SafeERC20FailedOperation\",\n inputs: [\n {\n name: \"token\",\n type: \"address\",\n internalType: \"address\",\n },\n ],\n },\n {\n type: \"error\",\n name: \"SenderNotAllowedToUseHandle\",\n inputs: [\n {\n name: \"handle\",\n type: \"bytes32\",\n internalType: \"bytes32\",\n },\n {\n name: \"sender\",\n type: \"address\",\n internalType: \"address\",\n },\n ],\n },\n {\n type: \"error\",\n name: \"UUPSUnauthorizedCallContext\",\n inputs: [],\n },\n {\n type: \"error\",\n name: \"UUPSUnsupportedProxiableUUID\",\n inputs: [\n {\n name: \"slot\",\n type: \"bytes32\",\n internalType: \"bytes32\",\n },\n ],\n },\n {\n type: \"error\",\n name: \"UnderlyingDenyListCallFailed\",\n inputs: [],\n },\n {\n type: \"error\",\n name: \"UnderlyingDenyListedAddress\",\n inputs: [\n {\n name: \"user\",\n type: \"address\",\n internalType: \"address\",\n },\n ],\n },\n {\n type: \"error\",\n name: \"UserAlreadyBlocked\",\n inputs: [\n {\n name: \"user\",\n type: \"address\",\n internalType: \"address\",\n },\n ],\n },\n {\n type: \"error\",\n name: \"UserAlreadyUnblocked\",\n inputs: [\n {\n name: \"user\",\n type: \"address\",\n internalType: \"address\",\n },\n ],\n },\n {\n type: \"error\",\n name: \"ZamaProtocolUnsupported\",\n inputs: [],\n },\n] as const;\n","import type { Address, Hex } from \"viem\";\nimport { confidentialWrapperAbi } from \"../abi/confidential-wrapper.abi\";\nimport type { EncryptedValue } from \"../relayer/relayer-sdk.types\";\n\n/**\n * Returns the contract config to read an encrypted balance.\n *\n * @example\n * ```ts\n * const handle = await provider.readContract(\n * confidentialBalanceOfContract(tokenAddress, userAddress),\n * );\n * ```\n */\nexport function confidentialBalanceOfContract(tokenAddress: Address, userAddress: Address) {\n return {\n address: tokenAddress,\n abi: confidentialWrapperAbi,\n functionName: \"confidentialBalanceOf\",\n args: [userAddress],\n } as const;\n}\n\n/**\n * Returns the contract config for a confidential transfer.\n *\n * @example\n * ```ts\n * const txHash = await signer.writeContract(\n * confidentialTransferContract(tokenAddress, to, encryptedValues[0], inputProof),\n * );\n * ```\n */\nexport function confidentialTransferContract(\n encryptedErc20: Address,\n to: Address,\n encryptedAmount: EncryptedValue,\n inputProof: Hex,\n) {\n return {\n address: encryptedErc20,\n abi: confidentialWrapperAbi,\n functionName: \"confidentialTransfer\",\n args: [to, encryptedAmount, inputProof],\n } as const;\n}\n\n/**\n * Returns the contract config for a confidential transferFrom.\n *\n * @example\n * ```ts\n * const txHash = await signer.writeContract(\n * confidentialTransferFromContract(tokenAddress, from, to, encryptedValues[0], inputProof),\n * );\n * ```\n */\nexport function confidentialTransferFromContract(\n encryptedErc20: Address,\n from: Address,\n to: Address,\n encryptedAmount: EncryptedValue,\n inputProof: Hex,\n) {\n return {\n address: encryptedErc20,\n abi: confidentialWrapperAbi,\n functionName: \"confidentialTransferFrom\",\n args: [from, to, encryptedAmount, inputProof],\n } as const;\n}\n\n/**\n * Returns the contract config for a confidential transferAndCall. The caller\n * supplies an opaque `data` payload that is forwarded to the recipient's\n * ERC-7984 receiver hook (`onConfidentialTransferReceived`). The SDK does not\n * craft, validate, or inspect `data` — encoding the call site's domain message\n * is the caller's responsibility.\n *\n * @example\n * ```ts\n * const txHash = await signer.writeContract(\n * confidentialTransferAndCallContract(\n * tokenAddress,\n * to,\n * encryptedValues[0],\n * inputProof,\n * data,\n * ),\n * );\n * ```\n */\nexport function confidentialTransferAndCallContract(\n encryptedErc20: Address,\n to: Address,\n encryptedAmount: EncryptedValue,\n inputProof: Hex,\n data: Hex,\n) {\n return {\n address: encryptedErc20,\n abi: confidentialWrapperAbi,\n functionName: \"confidentialTransferAndCall\",\n args: [to, encryptedAmount, inputProof, data],\n } as const;\n}\n\n/**\n * Returns the contract config for a confidential transferFromAndCall. The\n * caller supplies an opaque `data` payload forwarded to the recipient's\n * ERC-7984 receiver hook; the SDK does not craft or inspect it.\n *\n * @example\n * ```ts\n * const txHash = await signer.writeContract(\n * confidentialTransferFromAndCallContract(\n * tokenAddress,\n * from,\n * to,\n * encryptedValues[0],\n * inputProof,\n * data,\n * ),\n * );\n * ```\n */\nexport function confidentialTransferFromAndCallContract(\n encryptedErc20: Address,\n from: Address,\n to: Address,\n encryptedAmount: EncryptedValue,\n inputProof: Hex,\n data: Hex,\n) {\n return {\n address: encryptedErc20,\n abi: confidentialWrapperAbi,\n functionName: \"confidentialTransferFromAndCall\",\n args: [from, to, encryptedAmount, inputProof, data],\n } as const;\n}\n\n/**\n * Returns the contract config for checking operator status.\n *\n * @example\n * ```ts\n * const isOperator = await provider.readContract(\n * isOperatorContract(tokenAddress, holder, spender),\n * );\n * ```\n */\nexport function isOperatorContract(tokenAddress: Address, holder: Address, spender: Address) {\n return {\n address: tokenAddress,\n abi: confidentialWrapperAbi,\n functionName: \"isOperator\",\n args: [holder, spender],\n } as const;\n}\n\n/**\n * Returns the contract config for setting an operator.\n * Defaults until to 1 hour from now.\n *\n * @example\n * ```ts\n * const txHash = await signer.writeContract(\n * setOperatorContract(tokenAddress, operator),\n * );\n * ```\n */\nexport function setOperatorContract(tokenAddress: Address, operator: Address, until?: number) {\n const effectiveUntil = until ?? Math.floor(Date.now() / 1000) + 3600;\n return {\n address: tokenAddress,\n abi: confidentialWrapperAbi,\n functionName: \"setOperator\",\n args: [operator, effectiveUntil],\n } as const;\n}\n\n/**\n * Returns the contract config for an unwrap with newly encrypted amount.\n *\n * @example\n * ```ts\n * const txHash = await signer.writeContract(\n * unwrapContract(encryptedErc20, from, to, encryptedValues[0], inputProof),\n * );\n * ```\n */\nexport function unwrapContract(\n encryptedErc20: Address,\n from: Address,\n to: Address,\n encryptedAmount: EncryptedValue,\n inputProof: Hex,\n) {\n return {\n address: encryptedErc20,\n abi: confidentialWrapperAbi,\n functionName: \"unwrap\",\n args: [from, to, encryptedAmount, inputProof],\n } as const;\n}\n\n/**\n * Returns the contract config for an unwrap with an existing balance handle.\n *\n * @example\n * ```ts\n * const txHash = await signer.writeContract(\n * unwrapFromBalanceContract(encryptedErc20, from, to, encryptedBalance),\n * );\n * ```\n */\nexport function unwrapFromBalanceContract(\n encryptedErc20: Address,\n from: Address,\n to: Address,\n encryptedBalance: EncryptedValue,\n) {\n return {\n address: encryptedErc20,\n abi: confidentialWrapperAbi,\n functionName: \"unwrap\",\n args: [from, to, encryptedBalance],\n } as const;\n}\n\n/**\n * Returns the contract config to read the confidential (encrypted) total supply.\n *\n * @example\n * ```ts\n * const handle = await provider.readContract(\n * confidentialTotalSupplyContract(tokenAddress),\n * );\n * ```\n */\nexport function confidentialTotalSupplyContract(tokenAddress: Address) {\n return {\n address: tokenAddress,\n abi: confidentialWrapperAbi,\n functionName: \"confidentialTotalSupply\",\n args: [],\n } as const;\n}\n\n/**\n * Returns the contract config to read the wrap/unwrap conversion rate.\n *\n * @example\n * ```ts\n * const rate = await provider.readContract(rateContract(tokenAddress));\n * ```\n */\nexport function rateContract(tokenAddress: Address) {\n return {\n address: tokenAddress,\n abi: confidentialWrapperAbi,\n functionName: \"rate\",\n args: [],\n } as const;\n}\n\n/**\n * Returns the contract config for finalizing an unwrap.\n *\n * @example\n * ```ts\n * const txHash = await signer.writeContract(\n * finalizeUnwrapContract(wrapper, unwrapRequestId, cleartext, proof),\n * );\n * ```\n */\nexport function finalizeUnwrapContract(\n wrapper: Address,\n unwrapRequestId: EncryptedValue,\n unwrapAmountCleartext: bigint,\n decryptionProof: Hex,\n) {\n return {\n address: wrapper,\n abi: confidentialWrapperAbi,\n functionName: \"finalizeUnwrap\",\n args: [unwrapRequestId, unwrapAmountCleartext, decryptionProof],\n } as const;\n}\n\n/**\n * Returns the contract config to read the underlying ERC-20 token of a wrapper.\n *\n * @example\n * ```ts\n * const token = await provider.readContract(underlyingContract(wrapperAddress));\n * ```\n */\nexport function underlyingContract(wrapperAddress: Address) {\n return {\n address: wrapperAddress,\n abi: confidentialWrapperAbi,\n functionName: \"underlying\",\n args: [],\n } as const;\n}\n\n/**\n * Returns the contract config to read the inferred plaintext total supply.\n *\n * @example\n * ```ts\n * const supply = await provider.readContract(\n * inferredTotalSupplyContract(wrapperAddress),\n * );\n * ```\n */\nexport function inferredTotalSupplyContract(wrapperAddress: Address) {\n return {\n address: wrapperAddress,\n abi: confidentialWrapperAbi,\n functionName: \"inferredTotalSupply\",\n args: [],\n } as const;\n}\n\n/**\n * Returns the contract config for a wrap (shield) operation.\n *\n * @example\n * ```ts\n * const txHash = await signer.writeContract(\n * wrapContract(wrapperAddress, to, amount),\n * );\n * ```\n */\nexport function wrapContract(wrapperAddress: Address, to: Address, amount: bigint) {\n return {\n address: wrapperAddress,\n abi: confidentialWrapperAbi,\n functionName: \"wrap\",\n args: [to, amount],\n } as const;\n}\n","import { erc20Abi, type Address } from \"viem\";\n\n/**\n * Returns the contract config to read a token's name.\n *\n * @example\n * ```ts\n * const name = await provider.readContract(nameContract(tokenAddress));\n * ```\n */\nexport function nameContract(tokenAddress: Address) {\n return {\n address: tokenAddress,\n abi: erc20Abi,\n functionName: \"name\",\n args: [],\n } as const;\n}\n\n/**\n * Returns the contract config to read a token's symbol.\n *\n * @example\n * ```ts\n * const symbol = await provider.readContract(symbolContract(tokenAddress));\n * ```\n */\nexport function symbolContract(tokenAddress: Address) {\n return {\n address: tokenAddress,\n abi: erc20Abi,\n functionName: \"symbol\",\n args: [],\n } as const;\n}\n\n/**\n * Returns the contract config to read a token's decimals.\n *\n * @example\n * ```ts\n * const decimals = await provider.readContract(decimalsContract(tokenAddress));\n * ```\n */\nexport function decimalsContract(tokenAddress: Address) {\n return {\n address: tokenAddress,\n abi: erc20Abi,\n functionName: \"decimals\",\n args: [],\n } as const;\n}\n\n/**\n * Returns the contract config to read an ERC-20 token's total supply.\n *\n * @example\n * ```ts\n * const supply = await provider.readContract(erc20TotalSupplyContract(tokenAddress));\n * ```\n */\nexport function erc20TotalSupplyContract(tokenAddress: Address) {\n return {\n address: tokenAddress,\n abi: erc20Abi,\n functionName: \"totalSupply\",\n args: [],\n } as const;\n}\n\n/**\n * Returns the contract config to read an ERC-20 balance.\n *\n * @example\n * ```ts\n * const balance = await provider.readContract(\n * balanceOfContract(tokenAddress, account),\n * );\n * ```\n */\nexport function balanceOfContract(tokenAddress: Address, account: Address) {\n return {\n address: tokenAddress,\n abi: erc20Abi,\n functionName: \"balanceOf\",\n args: [account],\n } as const;\n}\n\n/**\n * Returns the contract config to read an ERC-20 allowance.\n *\n * @example\n * ```ts\n * const allowance = await provider.readContract(\n * allowanceContract(tokenAddress, owner, spender),\n * );\n * ```\n */\nexport function allowanceContract(tokenAddress: Address, owner: Address, spender: Address) {\n return {\n address: tokenAddress,\n abi: erc20Abi,\n functionName: \"allowance\",\n args: [owner, spender],\n } as const;\n}\n\n/**\n * Returns the contract config for an ERC-20 approve.\n *\n * @example\n * ```ts\n * const txHash = await signer.writeContract(\n * approveContract(tokenAddress, spender, amount),\n * );\n * ```\n */\nexport function approveContract(tokenAddress: Address, spender: Address, value: bigint) {\n return {\n address: tokenAddress,\n abi: erc20Abi,\n functionName: \"approve\",\n args: [spender, value],\n } as const;\n}\n","// DO NOT EDIT: generated by `pnpm abi:build` from\n// contracts/out/IERC165.sol/IERC165.json.\n// Regenerate after `pnpm contracts:build`; `pnpm abi:check` enforces this in CI.\nexport const erc165Abi = [\n {\n type: \"function\",\n name: \"supportsInterface\",\n inputs: [\n {\n name: \"interfaceId\",\n type: \"bytes4\",\n internalType: \"bytes4\",\n },\n ],\n outputs: [\n {\n name: \"\",\n type: \"bool\",\n internalType: \"bool\",\n },\n ],\n stateMutability: \"view\",\n },\n] as const;\n","import type { Address } from \"viem\";\nimport { erc165Abi } from \"../abi/erc165.abi\";\n\n/** ERC-165 interface ID for IERC7984 (confidential fungible token). */\nexport const ERC7984_INTERFACE_ID = \"0x4958f2a4\" as const;\n\n/** ERC-165 interface ID for IERC7984ERC20Wrapper (confidential wrapper). */\nexport const ERC7984_WRAPPER_INTERFACE_ID = \"0x1f1c62b2\" as const;\n\n/** ERC-165 interface ID for ERC-1363 (payable token — `transferAndCall`). */\nexport const ERC1363_INTERFACE_ID = \"0xb0202a11\" as const;\n\n/**\n * Returns the contract config for an ERC-165 `supportsInterface` check.\n *\n * Use with {@link ERC7984_INTERFACE_ID} to detect confidential tokens,\n * or {@link ERC7984_WRAPPER_INTERFACE_ID} to detect wrappers.\n *\n * @example\n * ```ts\n * const isConfidential = await provider.readContract(\n * supportsInterfaceContract(tokenAddress, ERC7984_INTERFACE_ID),\n * );\n * ```\n */\nexport function supportsInterfaceContract(tokenAddress: Address, interfaceId: Address) {\n return {\n address: tokenAddress,\n abi: erc165Abi,\n functionName: \"supportsInterface\",\n args: [interfaceId],\n } as const;\n}\n\n/**\n * Returns contract config to check if a token implements IERC7984 (confidential fungible token).\n *\n * @example\n * ```ts\n * const isConfidential = await provider.readContract(\n * isConfidentialTokenContract(\"0xTokenAddress\"),\n * );\n * ```\n */\nexport function isConfidentialTokenContract(tokenAddress: Address) {\n return supportsInterfaceContract(tokenAddress, ERC7984_INTERFACE_ID);\n}\n\n/**\n * Returns contract config to check if a token implements IERC7984ERC20Wrapper (confidential wrapper).\n *\n * @example\n * ```ts\n * const isWrapper = await provider.readContract(\n * isConfidentialWrapperContract(\"0xWrapperAddress\"),\n * );\n * ```\n */\nexport function isConfidentialWrapperContract(tokenAddress: Address) {\n return supportsInterfaceContract(tokenAddress, ERC7984_WRAPPER_INTERFACE_ID);\n}\n\n/**\n * Returns contract config to check if a token implements ERC-1363 (payable token).\n *\n * @example\n * ```ts\n * const isPayable = await provider.readContract(\n * isPayableTokenContract(\"0xTokenAddress\"),\n * );\n * ```\n */\nexport function isPayableTokenContract(tokenAddress: Address) {\n return supportsInterfaceContract(tokenAddress, ERC1363_INTERFACE_ID);\n}\n","import type { Address } from \"viem\";\n\nexport const wrappersRegistryAbi = [\n {\n inputs: [],\n name: \"getTokenConfidentialTokenPairs\",\n outputs: [\n {\n components: [\n { internalType: \"address\", name: \"tokenAddress\", type: \"address\" },\n {\n internalType: \"address\",\n name: \"confidentialTokenAddress\",\n type: \"address\",\n },\n { internalType: \"bool\", name: \"isValid\", type: \"bool\" },\n ],\n internalType: \"struct ConfidentialTokenWrappersRegistry.TokenWrapperPair[]\",\n name: \"\",\n type: \"tuple[]\",\n },\n ],\n stateMutability: \"view\",\n type: \"function\",\n },\n {\n inputs: [],\n name: \"getTokenConfidentialTokenPairsLength\",\n outputs: [{ internalType: \"uint256\", name: \"\", type: \"uint256\" }],\n stateMutability: \"view\",\n type: \"function\",\n },\n {\n inputs: [\n { internalType: \"uint256\", name: \"fromIndex\", type: \"uint256\" },\n { internalType: \"uint256\", name: \"toIndex\", type: \"uint256\" },\n ],\n name: \"getTokenConfidentialTokenPairsSlice\",\n outputs: [\n {\n components: [\n { internalType: \"address\", name: \"tokenAddress\", type: \"address\" },\n {\n internalType: \"address\",\n name: \"confidentialTokenAddress\",\n type: \"address\",\n },\n { internalType: \"bool\", name: \"isValid\", type: \"bool\" },\n ],\n internalType: \"struct ConfidentialTokenWrappersRegistry.TokenWrapperPair[]\",\n name: \"\",\n type: \"tuple[]\",\n },\n ],\n stateMutability: \"view\",\n type: \"function\",\n },\n {\n inputs: [{ internalType: \"uint256\", name: \"index\", type: \"uint256\" }],\n name: \"getTokenConfidentialTokenPair\",\n outputs: [\n {\n components: [\n { internalType: \"address\", name: \"tokenAddress\", type: \"address\" },\n {\n internalType: \"address\",\n name: \"confidentialTokenAddress\",\n type: \"address\",\n },\n { internalType: \"bool\", name: \"isValid\", type: \"bool\" },\n ],\n internalType: \"struct ConfidentialTokenWrappersRegistry.TokenWrapperPair\",\n name: \"\",\n type: \"tuple\",\n },\n ],\n stateMutability: \"view\",\n type: \"function\",\n },\n {\n inputs: [{ internalType: \"address\", name: \"tokenAddress\", type: \"address\" }],\n name: \"getConfidentialTokenAddress\",\n outputs: [\n { internalType: \"bool\", name: \"\", type: \"bool\" },\n { internalType: \"address\", name: \"\", type: \"address\" },\n ],\n stateMutability: \"view\",\n type: \"function\",\n },\n {\n inputs: [\n {\n internalType: \"address\",\n name: \"confidentialTokenAddress\",\n type: \"address\",\n },\n ],\n name: \"getTokenAddress\",\n outputs: [\n { internalType: \"bool\", name: \"\", type: \"bool\" },\n { internalType: \"address\", name: \"\", type: \"address\" },\n ],\n stateMutability: \"view\",\n type: \"function\",\n },\n {\n inputs: [\n {\n internalType: \"address\",\n name: \"confidentialTokenAddress\",\n type: \"address\",\n },\n ],\n name: \"isConfidentialTokenValid\",\n outputs: [{ internalType: \"bool\", name: \"\", type: \"bool\" }],\n stateMutability: \"view\",\n type: \"function\",\n },\n {\n inputs: [{ internalType: \"address\", name: \"initialOwner\", type: \"address\" }],\n name: \"initialize\",\n outputs: [],\n stateMutability: \"nonpayable\",\n type: \"function\",\n },\n {\n inputs: [\n { internalType: \"address\", name: \"tokenAddress\", type: \"address\" },\n { internalType: \"address\", name: \"confidentialTokenAddress\", type: \"address\" },\n ],\n name: \"registerConfidentialToken\",\n outputs: [],\n stateMutability: \"nonpayable\",\n type: \"function\",\n },\n {\n inputs: [\n {\n internalType: \"address\",\n name: \"confidentialTokenAddress\",\n type: \"address\",\n },\n ],\n name: \"revokeConfidentialToken\",\n outputs: [],\n stateMutability: \"nonpayable\",\n type: \"function\",\n },\n] as const;\n\nexport interface TokenWrapperPair {\n readonly tokenAddress: Address;\n readonly confidentialTokenAddress: Address;\n readonly isValid: boolean;\n}\n\n/** Extended pair with on-chain metadata for both tokens. */\nexport interface TokenWrapperPairWithMetadata extends TokenWrapperPair {\n readonly underlying: {\n readonly name: string;\n readonly symbol: string;\n readonly decimals: number;\n readonly totalSupply: bigint;\n };\n readonly confidential: {\n readonly name: string;\n readonly symbol: string;\n readonly decimals: number;\n };\n}\n\n/** Paginated result set modelled after standard API pagination. */\nexport interface PaginatedResult<T> {\n readonly items: readonly T[];\n readonly total: number;\n readonly page: number;\n readonly pageSize: number;\n}\n\n/**\n * Returns the contract config to fetch all token wrapper pairs.\n *\n * @example\n * ```ts\n * const pairs = await client.readContract(\n * getTokenPairsContract(registryAddress),\n * );\n * ```\n */\nexport function getTokenPairsContract(registry: Address) {\n return {\n address: registry,\n abi: wrappersRegistryAbi,\n functionName: \"getTokenConfidentialTokenPairs\",\n args: [],\n } as const;\n}\n\n/**\n * Returns the contract config to get the number of token wrapper pairs.\n *\n * @example\n * ```ts\n * const length = await client.readContract(\n * getTokenPairsLengthContract(registryAddress),\n * );\n * ```\n */\nexport function getTokenPairsLengthContract(registry: Address) {\n return {\n address: registry,\n abi: wrappersRegistryAbi,\n functionName: \"getTokenConfidentialTokenPairsLength\",\n args: [],\n } as const;\n}\n\n/**\n * Returns the contract config to fetch a slice of token wrapper pairs.\n *\n * @example\n * ```ts\n * const pairs = await client.readContract(\n * getTokenPairsSliceContract(registryAddress, 0n, 10n),\n * );\n * ```\n */\nexport function getTokenPairsSliceContract(registry: Address, fromIndex: bigint, toIndex: bigint) {\n return {\n address: registry,\n abi: wrappersRegistryAbi,\n functionName: \"getTokenConfidentialTokenPairsSlice\",\n args: [fromIndex, toIndex],\n } as const;\n}\n\n/**\n * Returns the contract config to fetch a single token wrapper pair by index.\n *\n * @example\n * ```ts\n * const pair = await client.readContract(\n * getTokenPairContract(registryAddress, 0n),\n * );\n * ```\n */\nexport function getTokenPairContract(registry: Address, index: bigint) {\n return {\n address: registry,\n abi: wrappersRegistryAbi,\n functionName: \"getTokenConfidentialTokenPair\",\n args: [index],\n } as const;\n}\n\n/**\n * Returns the contract config to look up the confidential token for a given plain token.\n *\n * @example\n * ```ts\n * const [isValid, confidentialToken] = await client.readContract(\n * getConfidentialTokenAddressContract(registryAddress, tokenAddress),\n * );\n * // isValid=false + confidentialToken=zeroAddress → not registered\n * // isValid=false + confidentialToken=nonZeroAddress → registered but revoked\n * // isValid=true + confidentialToken=nonZeroAddress → registered and valid\n * ```\n */\nexport function getConfidentialTokenAddressContract(registry: Address, tokenAddress: Address) {\n return {\n address: registry,\n abi: wrappersRegistryAbi,\n functionName: \"getConfidentialTokenAddress\",\n args: [tokenAddress],\n } as const;\n}\n\n/**\n * Returns the contract config to look up the plain token for a given confidential token.\n *\n * @example\n * ```ts\n * const [isValid, token] = await client.readContract(\n * getTokenAddressContract(registryAddress, confidentialTokenAddress),\n * );\n * // isValid=false + token=zeroAddress → not registered\n * // isValid=false + token=nonZeroAddress → registered but revoked\n * // isValid=true + token=nonZeroAddress → registered and valid\n * ```\n */\nexport function getTokenAddressContract(registry: Address, confidentialTokenAddress: Address) {\n return {\n address: registry,\n abi: wrappersRegistryAbi,\n functionName: \"getTokenAddress\",\n args: [confidentialTokenAddress],\n } as const;\n}\n\n/**\n * Returns the contract config to check if a confidential token is valid.\n *\n * @example\n * ```ts\n * const isValid = await client.readContract(\n * isConfidentialTokenValidContract(registryAddress, confidentialTokenAddress),\n * );\n * ```\n */\nexport function isConfidentialTokenValidContract(\n registry: Address,\n confidentialTokenAddress: Address,\n) {\n return {\n address: registry,\n abi: wrappersRegistryAbi,\n functionName: \"isConfidentialTokenValid\",\n args: [confidentialTokenAddress],\n } as const;\n}\n"],"mappings":"iFAGA,IAAa,EAAb,cAA0C,CAAU,CAClD,YAAY,EAAiB,EAAwB,CACnD,MAAM,EAAc,gBAAiB,EAAS,CAAO,EACrD,KAAK,KAAO,sBACd,CACF,EAGa,EAAb,cAAwC,CAAU,CAChD,YAAY,EAAiB,EAAwB,CACnD,MAAM,EAAc,cAAe,EAAS,CAAO,EACnD,KAAK,KAAO,oBACd,CACF,EAMA,SAAgB,EAAiB,EAAgB,EAAwB,CACvE,IAAM,EACJ,OAAO,GAAU,YAAY,GAAkB,SAAU,GAAS,EAAM,OAAS,KAC7E,EAAc,aAAiB,MAAQ,EAAM,QAAU,OAAO,CAAK,EACnE,EAAW,EAAY,YAAY,EACnC,EACJ,EAAS,SAAS,eAAe,GAAK,EAAS,SAAS,aAAa,EACjE,EAAc,GAAG,EAAQ,IAAI,IAInC,MAHI,GAAe,EACX,IAAI,EAAqB,EAAa,CAAE,MAAO,CAAM,CA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ACN,KAAM,wBACN,OAAQ,CACN,CACE,KAAM,UACN,KAAM,UACN,aAAc,SAChB,CACF,EACA,QAAS,CACP,CACE,KAAM,GACN,KAAM,UACN,aAAc,SAChB,CACF,EACA,gBAAiB,MACnB,EACA,CACE,KAAM,WACN,KAAM,yBACN,OAAQ,CAAC,EACT,QAAS,CACP,CACE,KAAM,GACN,KAAM,UACN,aAAc,SAChB,CACF,EACA,gBAAiB,MACnB,EACA,CACE,KAAM,WACN,KAAM,0BACN,OAAQ,CAAC,EACT,QAAS,CACP,CACE,KAAM,GACN,KAAM,UACN,aAAc,SAChB,CACF,EACA,gBAAiB,MACnB,EACA,CACE,KAAM,WACN,KAAM,uBACN,OAAQ,CACN,CACE,KAAM,KACN,KAAM,UACN,aAAc,SAChB,EACA,CACE,KAAM,kBACN,KAAM,UACN,aAAc,iBAChB,EACA,CACE,KAAM,aACN,KAAM,QACN,aAAc,OAChB,CACF,EACA,QAAS,CACP,CACE,KAAM,GACN,KAAM,UACN,aAAc,SAChB,CACF,EACA,gBAAiB,YACnB,EACA,CACE,KAAM,WACN,KAAM,uBACN,OAAQ,CACN,CACE,KAAM,KACN,KAAM,UACN,aAAc,SAChB,EACA,CACE,KAAM,SACN,KAAM,UACN,aAAc,SAChB,CACF,EACA,QAAS,CACP,CACE,KAAM,GACN,KAAM,UACN,aAAc,SAChB,CACF,EACA,gBAAiB,YACnB,EACA,CACE,KAAM,WACN,KAAM,8BACN,OAAQ,CACN,CACE,KAAM,KACN,KAAM,UACN,aAAc,SAChB,EACA,CACE,KAAM,SACN,KAAM,UACN,aAAc,SAChB,EACA,CACE,KAAM,OACN,KAAM,QACN,aAAc,OAChB,CACF,EACA,QAAS,CACP,CACE,KAAM,cACN,KAAM,UACN,aAAc,SAChB,CACF,EACA,gBAAiB,YACnB,EACA,CACE,KAAM,WACN,KAAM,8BACN,OAAQ,CACN,CACE,KAAM,KACN,KAAM,UACN,aAAc,SAChB,EACA,CACE,KAAM,kBACN,KAAM,UACN,aAAc,iBAChB,EACA,CACE,KAAM,aACN,KAAM,QACN,aAAc,OAChB,EACA,CACE,KAAM,OACN,KAAM,QACN,aAAc,OAChB,CACF,EACA,QAAS,CACP,CACE,KAAM,cACN,KAAM,UACN,aAAc,SAChB,CACF,EACA,gBAAiB,YACnB,EACA,CACE,KAAM,WACN,KAAM,2BACN,OAAQ,CACN,CACE,KAAM,OACN,KAAM,UACN,aAAc,SAChB,EACA,CACE,KAAM,KACN,KAAM,UACN,aAAc,SAChB,EACA,CACE,KAAM,kBACN,KAAM,UACN,aAAc,iBAChB,EACA,CACE,KAAM,aACN,KAAM,QACN,aAAc,OAChB,CACF,EACA,QAAS,CACP,CACE,KAAM,cACN,KAAM,UACN,aAAc,SAChB,CACF,EACA,gBAAiB,YACnB,EACA,CACE,KAAM,WACN,KAAM,2BACN,OAAQ,CACN,CACE,KAAM,OACN,KAAM,UACN,aAAc,SAChB,EACA,CACE,KAAM,KACN,KAAM,UACN,aAAc,SAChB,EACA,CACE,KAAM,SACN,KAAM,UACN,aAAc,SAChB,CACF,EACA,QAAS,CACP,CACE,KAAM,cACN,KAAM,UACN,aAAc,SAChB,CACF,EACA,gBAAiB,YACnB,EACA,CACE,KAAM,WACN,KAAM,kCACN,OAAQ,CACN,CACE,KAAM,OACN,KAAM,UACN,aAAc,SAChB,EACA,CACE,KAAM,KACN,KAAM,UACN,aAAc,SAChB,EACA,CACE,KAAM,kBACN,KAAM,UACN,aAAc,iBAChB,EACA,CACE,KAAM,aACN,KAAM,QACN,aAAc,OAChB,EACA,CACE,KAAM,OACN,KAAM,QACN,aAAc,OAChB,CACF,EACA,QAAS,CACP,CACE,KAAM,cACN,KAAM,UACN,aAAc,SAChB,CACF,EACA,gBAAiB,YACnB,EACA,CACE,KAAM,WACN,KAAM,kCACN,OAAQ,CACN,CACE,KAAM,OACN,KAAM,UACN,aAAc,SAChB,EACA,CACE,KAAM,KACN,KAAM,UACN,aAAc,SAChB,EACA,CACE,KAAM,SACN,KAAM,UACN,aAAc,SAChB,EACA,CACE,KAAM,OACN,KAAM,QACN,aAAc,OAChB,CACF,EACA,QAAS,CACP,CACE,KAAM,cACN,KAAM,UACN,aAAc,SAChB,CACF,EACA,gBAAiB,YACnB,EACA,CACE,KAAM,WACN,KAAM,cACN,OAAQ,CAAC,EACT,QAAS,CACP,CACE,KAAM,GACN,KAAM,SACN,aAAc,QAChB,CACF,EACA,gBAAiB,MACnB,EACA,CACE,KAAM,WACN,KAAM,WACN,OAAQ,CAAC,EACT,QAAS,CACP,CACE,KAAM,GACN,KAAM,QACN,aAAc,OAChB,CACF,EACA,gBAAiB,MACnB,EACA,CACE,KAAM,WACN,KAAM,0BACN,OAAQ,CACN,CACE,KAAM,kBACN,KAAM,UACN,aAAc,SAChB,EACA,CACE,KAAM,kBACN,KAAM,SACN,aAAc,QAChB,EACA,CACE,KAAM,kBACN,KAAM,QACN,aAAc,OAChB,CACF,EACA,QAAS,CAAC,EACV,gBAAiB,YACnB,EACA,CACE,KAAM,WACN,KAAM,iBACN,OAAQ,CACN,CACE,KAAM,kBACN,KAAM,UACN,aAAc,SAChB,EACA,CACE,KAAM,wBACN,KAAM,SACN,aAAc,QAChB,EACA,CACE,KAAM,kBACN,KAAM,QACN,aAAc,OAChB,CACF,EACA,QAAS,CAAC,EACV,gBAAiB,YACnB,EACA,CACE,KAAM,WACN,KAAM,gCACN,OAAQ,CAAC,EACT,QAAS,CACP,CACE,KAAM,QACN,KAAM,OACN,aAAc,MAChB,EACA,CACE,KAAM,WACN,KAAM,SACN,aAAc,QAChB,CACF,EACA,gBAAiB,MACnB,EACA,CACE,KAAM,WACN,KAAM,sBACN,OAAQ,CAAC,EACT,QAAS,CACP,CACE,KAAM,GACN,KAAM,UACN,aAAc,SAChB,CACF,EACA,gBAAiB,MACnB,EACA,CACE,KAAM,WACN,KAAM,aACN,OAAQ,CACN,CACE,KAAM,QACN,KAAM,SACN,aAAc,QAChB,EACA,CACE,KAAM,UACN,KAAM,SACN,aAAc,QAChB,EACA,CACE,KAAM,eACN,KAAM,SACN,aAAc,QAChB,EACA,CACE,KAAM,cACN,KAAM,UACN,aAAc,iBAChB,EACA,CACE,KAAM,SACN,KAAM,UACN,aAAc,SAChB,CACF,EACA,QAAS,CAAC,EACV,gBAAiB,YACnB,EACA,CACE,KAAM,WACN,KAAM,YACN,OAAQ,CACN,CACE,KAAM,OACN,KAAM,UACN,aAAc,SAChB,CACF,EACA,QAAS,CACP,CACE,KAAM,GACN,KAAM,OACN,aAAc,MAChB,CACF,EACA,gBAAiB,MACnB,EACA,CACE,KAAM,WACN,KAAM,aACN,OAAQ,CACN,CACE,KAAM,SACN,KAAM,UACN,aAAc,SAChB,EACA,CACE,KAAM,UACN,KAAM,UACN,aAAc,SAChB,CACF,EACA,QAAS,CACP,CACE,KAAM,GACN,KAAM,OACN,aAAc,MAChB,CACF,EACA,gBAAiB,MACnB,EACA,CACE,KAAM,WACN,KAAM,iBACN,OAAQ,CAAC,EACT,QAAS,CACP,CACE,KAAM,GACN,KAAM,UACN,aAAc,SAChB,CACF,EACA,gBAAiB,MACnB,EACA,CACE,KAAM,WACN,KAAM,OACN,OAAQ,CAAC,EACT,QAAS,CACP,CACE,KAAM,GACN,KAAM,SACN,aAAc,QAChB,CACF,EACA,gBAAiB,MACnB,EACA,CACE,KAAM,WACN,KAAM,qBACN,OAAQ,CACN,CACE,KAAM,WACN,KAAM,UACN,aAAc,SAChB,EACA,CACE,KAAM,OACN,KAAM,UACN,aAAc,SAChB,EACA,CACE,KAAM,SACN,KAAM,UACN,aAAc,SAChB,EACA,CACE,KAAM,OACN,KAAM,QACN,aAAc,OAChB,CACF,EACA,QAAS,CACP,CACE,KAAM,GACN,KAAM,SACN,aAAc,QAChB,CACF,EACA,gBAAiB,YACnB,EACA,CACE,KAAM,WACN,KAAM,QACN,OAAQ,CAAC,EACT,QAAS,CACP,CACE,KAAM,GACN,KAAM,UACN,aAAc,SAChB,CACF,EACA,gBAAiB,MACnB,EACA,CACE,KAAM,WACN,KAAM,eACN,OAAQ,CAAC,EACT,QAAS,CACP,CACE,KAAM,GACN,KAAM,UACN,aAAc,SAChB,CACF,EACA,gBAAiB,MACnB,EACA,CACE,KAAM,WACN,KAAM,gBACN,OAAQ,CAAC,EACT,QAAS,CACP,CACE,KAAM,GACN,KAAM,UACN,aAAc,SAChB,CACF,EACA,gBAAiB,MACnB,EACA,CACE,KAAM,WACN,KAAM,OACN,OAAQ,CAAC,EACT,QAAS,CACP,CACE,KAAM,GACN,KAAM,UACN,aAAc,SAChB,CACF,EACA,gBAAiB,MACnB,EACA,CACE,KAAM,WACN,KAAM,iBACN,OAAQ,CAAC,EACT,QAAS,CAAC,EACV,gBAAiB,YACnB,EACA,CACE,KAAM,WACN,KAAM,iBACN,OAAQ,CACN,CACE,KAAM,eACN,KAAM,YACN,aAAc,WAChB,EACA,CACE,KAAM,6BACN,KAAM,SACN,aAAc,QAChB,EACA,CACE,KAAM,iCACN,KAAM,OACN,aAAc,MAChB,CACF,EACA,QAAS,CAAC,EACV,gBAAiB,YACnB,EACA,CACE,KAAM,WACN,KAAM,oBACN,OAAQ,CAAC,EACT,QAAS,CAAC,EACV,gBAAiB,YACnB,EACA,CACE,KAAM,WACN,KAAM,iCACN,OAAQ,CACN,CACE,KAAM,kBACN,KAAM,UACN,aAAc,SAChB,CACF,EACA,QAAS,CAAC,EACV,gBAAiB,YACnB,EACA,CACE,KAAM,WACN,KAAM,cACN,OAAQ,CACN,CACE,KAAM,WACN,KAAM,UACN,aAAc,SAChB,EACA,CACE,KAAM,QACN,KAAM,SACN,aAAc,QAChB,CACF,EACA,QAAS,CAAC,EACV,gBAAiB,YACnB,EACA,CACE,KAAM,WACN,KAAM,oBACN,OAAQ,CACN,CACE,KAAM,cACN,KAAM,SACN,aAAc,QAChB,CACF,EACA,QAAS,CACP,CACE,KAAM,GACN,KAAM,OACN,aAAc,MAChB,CACF,EACA,gBAAiB,MACnB,EACA,CACE,KAAM,WACN,KAAM,SACN,OAAQ,CAAC,EACT,QAAS,CACP,CACE,KAAM,GACN,KAAM,SACN,aAAc,QAChB,CACF,EACA,gBAAiB,MACnB,EACA,CACE,KAAM,WACN,KAAM,oBACN,OAAQ,CACN,CACE,KAAM,WACN,KAAM,UACN,aAAc,SAChB,CACF,EACA,QAAS,CAAC,EACV,gBAAiB,YACnB,EACA,CACE,KAAM,WACN,KAAM,cACN,OAAQ,CACN,CACE,KAAM,OACN,KAAM,UACN,aAAc,SAChB,CACF,EACA,QAAS,CAAC,EACV,gBAAiB,YACnB,EACA,CACE,KAAM,WACN,KAAM,aACN,OAAQ,CAAC,EACT,QAAS,CACP,CACE,KAAM,GACN,KAAM,UACN,aAAc,SAChB,CACF,EACA,gBAAiB,MACnB,EACA,CACE,KAAM,WACN,KAAM,SACN,OAAQ,CACN,CACE,KAAM,OACN,KAAM,UACN,aAAc,SAChB,EACA,CACE,KAAM,KACN,KAAM,UACN,aAAc,SAChB,EACA,CACE,KAAM,kBACN,KAAM,UACN,aAAc,iBAChB,EACA,CACE,KAAM,aACN,KAAM,QACN,aAAc,OAChB,CACF,EACA,QAAS,CACP,CACE,KAAM,GACN,KAAM,UACN,aAAc,SAChB,CACF,EACA,gBAAiB,YACnB,EACA,CACE,KAAM,WACN,KAAM,SACN,OAAQ,CACN,CACE,KAAM,OACN,KAAM,UACN,aAAc,SAChB,EACA,CACE,KAAM,KACN,KAAM,UACN,aAAc,SAChB,EACA,CACE,KAAM,SACN,KAAM,UACN,aAAc,SAChB,CACF,EACA,QAAS,CACP,CACE,KAAM,GACN,KAAM,UACN,aAAc,SAChB,CACF,EACA,gBAAiB,YACnB,EACA,CACE,KAAM,WACN,KAAM,eACN,OAAQ,CACN,CACE,KAAM,kBACN,KAAM,UACN,aAAc,SAChB,CACF,EACA,QAAS,CACP,CACE,KAAM,GACN,KAAM,UACN,aAAc,SAChB,CACF,EACA,gBAAiB,MACnB,EACA,CACE,KAAM,WACN,KAAM,kBACN,OAAQ,CACN,CACE,KAAM,kBACN,KAAM,UACN,aAAc,SAChB,CACF,EACA,QAAS,CACP,CACE,KAAM,GACN,KAAM,UACN,aAAc,SAChB,CACF,EACA,gBAAiB,MACnB,EACA,CACE,KAAM,WACN,KAAM,mBACN,OAAQ,CACN,CACE,KAAM,oBACN,KAAM,UACN,aAAc,SAChB,EACA,CACE,KAAM,OACN,KAAM,QACN,aAAc,OAChB,CACF,EACA,QAAS,CAAC,EACV,gBAAiB,SACnB,EACA,CACE,KAAM,WACN,KAAM,OACN,OAAQ,CACN,CACE,KAAM,KACN,KAAM,UACN,aAAc,SAChB,EACA,CACE,KAAM,SACN,KAAM,UACN,aAAc,SAChB,CACF,EACA,QAAS,CACP,CACE,KAAM,GACN,KAAM,UACN,aAAc,SAChB,CACF,EACA,gBAAiB,YACnB,EACA,CACE,KAAM,QACN,KAAM,0BACN,OAAQ,CACN,CACE,KAAM,kBACN,KAAM,UACN,QAAS,GACT,aAAc,SAChB,EACA,CACE,KAAM,YACN,KAAM,UACN,QAAS,GACT,aAAc,SAChB,CACF,EACA,UAAW,EACb,EACA,CACE,KAAM,QACN,KAAM,kBACN,OAAQ,CACN,CACE,KAAM,kBACN,KAAM,UACN,QAAS,GACT,aAAc,SAChB,EACA,CACE,KAAM,SACN,KAAM,SACN,QAAS,GACT,aAAc,QAChB,CACF,EACA,UAAW,EACb,EACA,CACE,KAAM,QACN,KAAM,uBACN,OAAQ,CACN,CACE,KAAM,OACN,KAAM,UACN,QAAS,GACT,aAAc,SAChB,EACA,CACE,KAAM,KACN,KAAM,UACN,QAAS,GACT,aAAc,SAChB,EACA,CACE,KAAM,SACN,KAAM,UACN,QAAS,GACT,aAAc,SAChB,CACF,EACA,UAAW,EACb,EACA,CACE,KAAM,QACN,KAAM,cACN,OAAQ,CACN,CACE,KAAM,UACN,KAAM,SACN,QAAS,GACT,aAAc,QAChB,CACF,EACA,UAAW,EACb,EACA,CACE,KAAM,QACN,KAAM,cACN,OAAQ,CACN,CACE,KAAM,SACN,KAAM,UACN,QAAS,GACT,aAAc,SAChB,EACA,CACE,KAAM,WACN,KAAM,UACN,QAAS,GACT,aAAc,SAChB,EACA,CACE,KAAM,QACN,KAAM,SACN,QAAS,GACT,aAAc,QAChB,CACF,EACA,UAAW,EACb,EACA,CACE,KAAM,QACN,KAAM,2BACN,OAAQ,CACN,CACE,KAAM,gBACN,KAAM,UACN,QAAS,GACT,aAAc,SAChB,EACA,CACE,KAAM,WACN,KAAM,UACN,QAAS,GACT,aAAc,SAChB,CACF,EACA,UAAW,EACb,EACA,CACE,KAAM,QACN,KAAM,uBACN,OAAQ,CACN,CACE,KAAM,gBACN,KAAM,UACN,QAAS,GACT,aAAc,SAChB,EACA,CACE,KAAM,WACN,KAAM,UACN,QAAS,GACT,aAAc,SAChB,CACF,EACA,UAAW,EACb,EACA,CACE,KAAM,QACN,KAAM,2BACN,OAAQ,CACN,CACE,KAAM,cACN,KAAM,YACN,QAAS,GACT,aAAc,WAChB,EACA,CACE,KAAM,uBACN,KAAM,QACN,QAAS,GACT,aAAc,OAChB,CACF,EACA,UAAW,EACb,EACA,CACE,KAAM,QACN,KAAM,kBACN,OAAQ,CACN,CACE,KAAM,WACN,KAAM,UACN,QAAS,GACT,aAAc,SAChB,EACA,CACE,KAAM,kBACN,KAAM,UACN,QAAS,GACT,aAAc,SAChB,EACA,CACE,KAAM,kBACN,KAAM,UACN,QAAS,GACT,aAAc,SAChB,EACA,CACE,KAAM,kBACN,KAAM,SACN,QAAS,GACT,aAAc,QAChB,CACF,EACA,UAAW,EACb,EACA,CACE,KAAM,QACN,KAAM,kBACN,OAAQ,CACN,CACE,KAAM,WACN,KAAM,UACN,QAAS,GACT,aAAc,SAChB,EACA,CACE,KAAM,kBACN,KAAM,UACN,QAAS,GACT,aAAc,SAChB,EACA,CACE,KAAM,SACN,KAAM,UACN,QAAS,GACT,aAAc,SAChB,CACF,EACA,UAAW,EACb,EACA,CACE,KAAM,QACN,KAAM,WACN,OAAQ,CACN,CACE,KAAM,iBACN,KAAM,UACN,QAAS,GACT,aAAc,SAChB,CACF,EACA,UAAW,EACb,EACA,CACE,KAAM,QACN,KAAM,cACN,OAAQ,CACN,CACE,KAAM,OACN,KAAM,UACN,QAAS,GACT,aAAc,SAChB,CACF,EACA,UAAW,EACb,EACA,CACE,KAAM,QACN,KAAM,gBACN,OAAQ,CACN,CACE,KAAM,OACN,KAAM,UACN,QAAS,GACT,aAAc,SAChB,CACF,EACA,UAAW,EACb,EACA,CACE,KAAM,QACN,KAAM,OACN,OAAQ,CACN,CACE,KAAM,KACN,KAAM,UACN,QAAS,GACT,aAAc,SAChB,EACA,CACE,KAAM,gBACN,KAAM,UACN,QAAS,GACT,aAAc,SAChB,EACA,CACE,KAAM,yBACN,KAAM,UACN,QAAS,GACT,aAAc,SAChB,CACF,EACA,UAAW,EACb,EACA,CACE,KAAM,QACN,KAAM,mBACN,OAAQ,CACN,CACE,KAAM,SACN,KAAM,UACN,aAAc,SAChB,CACF,CACF,EACA,CACE,KAAM,QACN,KAAM,cACN,OAAQ,CACN,CACE,KAAM,OACN,KAAM,UACN,aAAc,SAChB,CACF,CACF,EACA,CACE,KAAM,QACN,KAAM,+BACN,OAAQ,CACN,CACE,KAAM,iBACN,KAAM,UACN,aAAc,SAChB,CACF,CACF,EACA,CACE,KAAM,QACN,KAAM,oBACN,OAAQ,CAAC,CACX,EACA,CACE,KAAM,QACN,KAAM,yBACN,OAAQ,CACN,CACE,KAAM,WACN,KAAM,UACN,aAAc,SAChB,CACF,CACF,EACA,CACE,KAAM,QACN,KAAM,yBACN,OAAQ,CACN,CACE,KAAM,WACN,KAAM,UACN,aAAc,SAChB,CACF,CACF,EACA,CACE,KAAM,QACN,KAAM,uBACN,OAAQ,CACN,CACE,KAAM,SACN,KAAM,UACN,aAAc,SAChB,CACF,CACF,EACA,CACE,KAAM,QACN,KAAM,6BACN,OAAQ,CAAC,CACX,EACA,CACE,KAAM,QACN,KAAM,4BACN,OAAQ,CACN,CACE,KAAM,SACN,KAAM,UACN,aAAc,SAChB,CACF,CACF,EACA,CACE,KAAM,QACN,KAAM,6BACN,OAAQ,CACN,CACE,KAAM,SACN,KAAM,UACN,aAAc,SAChB,EACA,CACE,KAAM,UACN,KAAM,UACN,aAAc,SAChB,CACF,CACF,EACA,CACE,KAAM,QACN,KAAM,0CACN,OAAQ,CACN,CACE,KAAM,SACN,KAAM,UACN,aAAc,SAChB,EACA,CACE,KAAM,OACN,KAAM,UACN,aAAc,SAChB,CACF,CACF,EACA,CACE,KAAM,QACN,KAAM,qBACN,OAAQ,CACN,CACE,KAAM,SACN,KAAM,UACN,aAAc,SAChB,CACF,CACF,EACA,CACE,KAAM,QACN,KAAM,aACN,OAAQ,CAAC,CACX,EACA,CACE,KAAM,QACN,KAAM,wBACN,OAAQ,CAAC,CACX,EACA,CACE,KAAM,QACN,KAAM,uBACN,OAAQ,CAAC,CACX,EACA,CACE,KAAM,QACN,KAAM,oCACN,OAAQ,CAAC,CACX,EACA,CACE,KAAM,QACN,KAAM,uBACN,OAAQ,CACN,CACE,KAAM,kBACN,KAAM,UACN,aAAc,SAChB,CACF,CACF,EACA,CACE,KAAM,QACN,KAAM,kBACN,OAAQ,CAAC,CACX,EACA,CACE,KAAM,QACN,KAAM,sBACN,OAAQ,CACN,CACE,KAAM,QACN,KAAM,UACN,aAAc,SAChB,CACF,CACF,EACA,CACE,KAAM,QACN,KAAM,6BACN,OAAQ,CACN,CACE,KAAM,UACN,KAAM,UACN,aAAc,SAChB,CACF,CACF,EACA,CACE,KAAM,QACN,KAAM,iCACN,OAAQ,CACN,CACE,KAAM,OACN,KAAM,QACN,aAAc,OAChB,EACA,CACE,KAAM,QACN,KAAM,UACN,aAAc,SAChB,CACF,CACF,EACA,CACE,KAAM,QACN,KAAM,2BACN,OAAQ,CACN,CACE,KAAM,QACN,KAAM,UACN,aAAc,SAChB,CACF,CACF,EACA,CACE,KAAM,QACN,KAAM,8BACN,OAAQ,CACN,CACE,KAAM,SACN,KAAM,UACN,aAAc,SAChB,EACA,CACE,KAAM,SACN,KAAM,UACN,aAAc,SAChB,CACF,CACF,EACA,CACE,KAAM,QACN,KAAM,8BACN,OAAQ,CAAC,CACX,EACA,CACE,KAAM,QACN,KAAM,+BACN,OAAQ,CACN,CACE,KAAM,OACN,KAAM,UACN,aAAc,SAChB,CACF,CACF,EACA,CACE,KAAM,QACN,KAAM,+BACN,OAAQ,CAAC,CACX,EACA,CACE,KAAM,QACN,KAAM,8BACN,OAAQ,CACN,CACE,KAAM,OACN,KAAM,UACN,aAAc,SAChB,CACF,CACF,EACA,CACE,KAAM,QACN,KAAM,qBACN,OAAQ,CACN,CACE,KAAM,OACN,KAAM,UACN,aAAc,SAChB,CACF,CACF,EACA,CACE,KAAM,QACN,KAAM,uBACN,OAAQ,CACN,CACE,KAAM,OACN,KAAM,UACN,aAAc,SAChB,CACF,CACF,EACA,CACE,KAAM,QACN,KAAM,0BACN,OAAQ,CAAC,CACX,CACF,ECr7CA,SAAgB,EAA8B,EAAuB,EAAsB,CACzF,MAAO,CACL,QAAS,EACT,IAAK,EACL,aAAc,wBACd,KAAM,CAAC,CAAW,CACpB,CACF,CAYA,SAAgB,EACd,EACA,EACA,EACA,EACA,CACA,MAAO,CACL,QAAS,EACT,IAAK,EACL,aAAc,uBACd,KAAM,CAAC,EAAI,EAAiB,CAAU,CACxC,CACF,CAYA,SAAgB,EACd,EACA,EACA,EACA,EACA,EACA,CACA,MAAO,CACL,QAAS,EACT,IAAK,EACL,aAAc,2BACd,KAAM,CAAC,EAAM,EAAI,EAAiB,CAAU,CAC9C,CACF,CAsBA,SAAgB,EACd,EACA,EACA,EACA,EACA,EACA,CACA,MAAO,CACL,QAAS,EACT,IAAK,EACL,aAAc,8BACd,KAAM,CAAC,EAAI,EAAiB,EAAY,CAAI,CAC9C,CACF,CAqBA,SAAgB,EACd,EACA,EACA,EACA,EACA,EACA,EACA,CACA,MAAO,CACL,QAAS,EACT,IAAK,EACL,aAAc,kCACd,KAAM,CAAC,EAAM,EAAI,EAAiB,EAAY,CAAI,CACpD,CACF,CAYA,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AAC,CACT,CACF,CAYA,SAAgB,EAA2B,EAAmB,EAAmB,EAAiB,CAChG,MAAO,CACL,QAAS,EACT,IAAK,EACL,aAAc,sCACd,KAAM,CAAC,EAAW,CAAO,CAC3B,CACF,CAYA,SAAgB,EAAqB,EAAmB,EAAe,CACrE,MAAO,CACL,QAAS,EACT,IAAK,EACL,aAAc,gCACd,KAAM,CAAC,CAAK,CACd,CACF,CAeA,SAAgB,EAAoC,EAAmB,EAAuB,CAC5F,MAAO,CACL,QAAS,EACT,IAAK,EACL,aAAc,8BACd,KAAM,CAAC,CAAY,CACrB,CACF,CAeA,SAAgB,EAAwB,EAAmB,EAAmC,CAC5F,MAAO,CACL,QAAS,EACT,IAAK,EACL,aAAc,kBACd,KAAM,CAAC,CAAwB,CACjC,CACF,CAYA,SAAgB,EACd,EACA,EACA,CACA,MAAO,CACL,QAAS,EACT,IAAK,EACL,aAAc,2BACd,KAAM,CAAC,CAAwB,CACjC,CACF"}
|
package/package.json
CHANGED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{r as e,t}from"./relayer-D-nicEYJ.js";import{F as n,U as r,a as i,b as a,i as o,n as s,o as c,r as l,s as u,t as d,v as f,x as p,y as m,z as h}from"./wrappers-registry-BWWG0aze.js";import{r as g}from"./error-W1N-FGwV.js";import{t as ee}from"./indexeddb-storage-Mi-fCWN3.js";import{t as te}from"./memory-storage-fp9RY5BQ.js";import{i as _}from"./assertions-CnPIS0VN.js";import{a as v,c as y,n as b,o as x,s as S}from"./chains-CXcO1DBP.js";import{t as C}from"./validation-DHZ3JPOn.js";import{getAddress as w,isAddress as ne,isHex as re,zeroAddress as T}from"viem";import{z as E}from"zod/mini";function D(e){return`keypair:${e}`}function O(e){return`permits:${e.signerAddress}:${e.chainId}:${e.delegatorAddress}`}function k(e){return`permits-index:${e}`}function A(e){return w(e)}const j=E.custom(e=>typeof e==`string`&&re(e,{strict:!0}),`expected 0x-prefixed hex string`),ie=E.custom(e=>typeof e==`string`&&ne(e,{strict:!1}),`expected EVM address`),M=E.pipe(ie,E.transform(A)),N=E.int().check(E.nonnegative()),P=E.int().check(E.positive()),ae=E.int().check(E.nonnegative()),oe=E.int().check(E.positive()),se=E.int().check(E.positive());function F(){return Math.floor(Date.now()/1e3)}function I(e){return[...new Set(e.map(A))].toSorted()}const L=`transportKeyPairTTL must be a positive integer number of seconds`,R=`permitTTL must be a positive integer number of days`,z=365*86400,B=E.int({error:L}).check(E.positive({error:L}),E.maximum(z,`transportKeyPairTTL must not exceed the fhevm ACL maximum of ${z}s (365 days)`)),V=E.int({error:R}).check(E.positive({error:R})),H=E.object({publicKey:j,privateKey:j,createdAt:N,expiresAt:P}),U=E.object({keypairPublicKey:j,signerAddress:M,delegatorAddress:M,chainId:se,signedContractAddresses:E.array(M).check(E.maxLength(10)),signature:j,startTimestamp:N,durationDays:oe}),W=E.array(U),G=E.array(E.string());var ce=class{#e;#t;#n;#r;#i=new Map;constructor(e){this.#e=e.generator,this.#t=e.storage,this.#n=e.ttl,this.#r=e.logger}async readStored(e){let t=D(e),r=await this.#t.get(t);if(r==null)return null;let i=H.safeParse(r);if(!i.success)return await n(`delete transport key pair entry`,()=>this.#t.delete(t),this.#r),null;let a=i.data;return F()>=a.expiresAt?(await n(`delete transport key pair entry`,()=>this.#t.delete(t),this.#r),null):a}async getOrCreate(e){let t=this.#i.get(e);if(t)return t;let r=(async()=>{let t=await this.readStored(e);if(t!==null)return t;let r=await this.#e(),i=F(),a={publicKey:r.publicKey,privateKey:r.privateKey,createdAt:i,expiresAt:i+this.#n},o=D(e);return await n(`persist transport key pair`,()=>this.#t.set(o,a),this.#r),a})().finally(()=>{this.#i.delete(e)});return this.#i.set(e,r),r}async clear(e){let t=D(e);await n(`delete transport key pair entry`,()=>this.#t.delete(t),this.#r)}};function K(e,t){let n=new Set(e.flatMap(e=>e.signedContractAddresses));return t.filter(e=>!n.has(e))}function le(e){let t=[];for(let n=0;n<e.length;n+=10)t.push(e.slice(n,n+10));return t}function ue(e,t,n){return e.filter(e=>e.keypairPublicKey===t&&n<e.startTimestamp+e.durationDays*86400)}function de(e,t){let n=new Set(t);return e.filter(e=>!e.signedContractAddresses.some(e=>n.has(e)))}function fe(e,t){return[...new Set([...e,...t])].toSorted()}function pe(e,t,n){let r=new Set(n),i=e.filter(e=>new Set([...e.signedContractAddresses,...t]).size<=10);if(i.length===0)return null;function a(e){return e.signedContractAddresses.reduce((e,t)=>e+ +!!r.has(t),0)}let o=Math.max(...i.map(a));return i.filter(e=>a(e)===o).reduce((e,t)=>t.startTimestamp>e.startTimestamp?t:e)}var me=class{#e;#t;constructor(e){this.#e=e.storage,this.#t=e.logger}async list(e){let t=O(e),n=await this.#e.get(t);if(n==null)return[];let r=W.safeParse(n);return r.success?r.data:(await this.#a(t),await this.#i(e),[])}async listUsableAndPrune(e,t){let r=await this.list(e),i=ue(r,t,Math.floor(Date.now()/1e3));if(i.length!==r.length){let t=O(e);i.length===0?(await this.#a(t),await this.#i(e)):await n(`update permit entry`,()=>this.#e.set(t,i),this.#t)}return i}async append(e,t){if(t.length===0)return;let n=t.map(e=>U.parse(e)),r=await this.list(e);await this.#e.set(O(e),[...r,...n]),await this.#r(e)}async replace(e,t,n){let r=U.parse(n),i=(await this.list(e)).filter(e=>e.signature!==t);await this.#e.set(O(e),[...i,r]),await this.#r(e)}async deletePermitsTouching(e,t){let n=await this.list(e);if(n.length===0)return;let r=O(e),i=de(n,t);i.length===0?(await this.#a(r),await this.#i(e)):await this.#e.set(r,i)}async clearAllForSigner(e){let t=k(e),r=await this.#n(t);await Promise.all(r.map(e=>this.#a(e))),await n(`delete permit index`,()=>this.#e.delete(t),this.#t)}async#n(e){let t=await this.#e.get(e);if(t==null)return[];let r=G.safeParse(t);return r.success?r.data:(await n(`delete permit index`,()=>this.#e.delete(e),this.#t),[])}async#r(e){let t=k(e.signerAddress),n=O(e),r=await this.#n(t);r.includes(n)||await this.#e.set(t,[...r,n])}async#i(e){let t=k(e.signerAddress),r=O(e),i=await this.#n(t),a=i.filter(e=>e!==r);a.length!==i.length&&(a.length===0?await n(`delete permit index`,()=>this.#e.delete(t),this.#t):await n(`update permit index`,()=>this.#e.set(t,a),this.#t))}async#a(e){await n(`delete permit entry`,()=>this.#e.delete(e),this.#t)}},he=class{#e;#t;#n;#r;#i;#a;constructor(e){this.#e=new ce({generator:()=>e.relayer.generateTransportKeyPair(),storage:e.storage,ttl:e.transportKeyPairTTL,logger:e.logger}),this.#t=new me({storage:e.permitStorage??e.storage,logger:e.logger}),this.#n=e.relayer,this.#r=e.signer,this.#i=e.permitTTL,this.#a=e.logger}async grantPermit(e,t){let r=this.#r.requireWalletAccount(`grantPermit`),i=A(r.address),a=I(e),o=await this.#e.getOrCreate(i);if(a.length===0)return{keypair:o,permits:[]};let s={signerAddress:i,chainId:r.chainId,delegatorAddress:t?A(t):i},c=await this.#t.listUsableAndPrune(s,o.publicKey),l=K(c,a);if(l.length>0){let e=pe(c,l,a);if(e!==null){let t=fe(e.signedContractAddresses,l),r=await this.#o({chunk:t,keypair:o,scope:s});await n(`replace permit`,()=>this.#t.replace(s,e.signature,r),this.#a),c[c.indexOf(e)]=r}else for(let e of le(l)){let t=await this.#o({chunk:e,keypair:o,scope:s});c.push(t),await n(`persist permit`,()=>this.#t.append(s,[t]),this.#a)}}let u=new Set(a);return{keypair:o,permits:c.filter(e=>e.signedContractAddresses.some(e=>u.has(e)))}}async hasPermit(e,t){if(e.length===0)return!0;let n=this.#r.walletAccount.getSnapshot();if(!n)return!1;let r=A(n.address),i=await this.#e.readStored(r);if(i===null)return!1;let a={signerAddress:r,chainId:n.chainId,delegatorAddress:t?A(t):r};return K(await this.#t.listUsableAndPrune(a,i.publicKey),I(e)).length===0}async revokePermits(e){let t=this.#r.requireWalletAccount(`revokePermits`),n=A(t.address);if(e===void 0){await this.#t.clearAllForSigner(n);return}let r=I(e);if(r.length===0)return;let i=t.chainId;await this.#t.deletePermitsTouching({signerAddress:n,chainId:i,delegatorAddress:n},r)}async clearCredentials(){let e=A(this.#r.requireWalletAccount(`clearCredentials`).address);await this.#e.clear(e),await this.#t.clearAllForSigner(e)}async warmTransportKeyPair(e){await this.#e.getOrCreate(A(e))}async handleWalletAccountChange(e,t){let n=e?A(e.address):void 0;n!==(t?A(t.address):void 0)&&n&&(await this.#e.clear(n),await this.#t.clearAllForSigner(n))}async#o(t){let{chunk:n,keypair:i,scope:a}=t,o=F(),s=a.delegatorAddress!==a.signerAddress;try{let e=s?await this.#n.createDelegatedUserDecryptEIP712(i.publicKey,n,a.delegatorAddress,o,this.#i):await this.#n.createEIP712(i.publicKey,n,o,this.#i),t=await this.#r.signTypedData(e);return{keypairPublicKey:i.publicKey,signerAddress:a.signerAddress,delegatorAddress:a.delegatorAddress,chainId:a.chainId,signedContractAddresses:n,signature:t,startTimestamp:o,durationDays:this.#i}}catch(t){throw t instanceof e?t:r(t,`Credential signing failed`)}}},ge=class{#e;#t=`[zama-sdk]`;constructor(e){this.#e=e}error(e,t){this.#e?.error(`${this.#t} ${e}`,t)}warn(e,t){this.#e?.warn(`${this.#t} ${e}`,t)}info(e,t){this.#e?.info(`${this.#t} ${e}`,t)}debug(e,t){this.#e?.debug(`${this.#t} ${e}`,t)}};function _e(){return typeof window<`u`?new ee(`CredentialStore`):new te}function q(e=_e(),t=e){return{storage:e,permitStorage:t}}function J(e,n){let r=new Map(e.map(e=>[e.id,e]));if(r.size!==e.length){let n=e.map(e=>e.id);throw new t(`Duplicate chain id(s) [${[...new Set(n.filter((e,t)=>n.indexOf(e)!==t))].join(`, `)}] in the chains array. Each chain id must appear only once. Note: hardhat and anvil are aliases (both use 31337).`)}let i=new Map(Object.entries(n)),a=new Map;for(let e of r.keys()){let n=r.get(e),o=i.get(String(e));if(!o)throw new t(`Chain ${e} has no relayer configured. Add a relayer entry: relayers: { [${e}]: web() }`);if(!n)throw new t(`Chain ${e} has a relayer configured but no entry in the chains array. Add the chain config to the chains array.`);a.set(e,{chain:n,relayer:o})}let o=new Set(Object.keys(n).map(Number)),s=new Set([...o].filter(e=>!r.has(e)));if(s.size>0)throw new t(`Relayer entries for chain(s) [${[...s].join(`, `)}] have no matching entry in the chains array. Remove them or add the corresponding chain config.`);return a}var Y=class{#e;#t;#n;#r;constructor(e,n,r){if(e.length===0)throw new t(`At least one chain is required.`);this.#e=new Map(e.map(e=>[e.id,e])),this.#r=e[0].id;let i=J(e,n),a=new Map;for(let[e,t]of i){let n=t.relayer,r=a.get(n);r||(r=[],a.set(n,r)),r.push([e,t.chain])}let o=new Map,s=[];try{for(let[e,t]of a){let n=t.map(([,e])=>e),i=e.createWorker?.(n,r);i&&s.push(i);for(let[n,a]of t)o.set(n,e.createRelayer(a,i,r))}}catch(e){for(let e of s)try{e.terminate()}catch{}throw e}this.#t=o,this.#n=s}get chains(){return[...this.#e.values()]}get chain(){let e=this.#e.get(this.#r);return _(e,`RelayerDispatcher: chain`),e}switchChain(e){if(!this.#e.has(e))throw new t(`No relayer configured for chain ${e}. Add it to the chains array.`);this.#r=e}get#i(){let e=this.#t.get(this.#r);return _(e,`RelayerDispatcher: relayer`),e}generateTransportKeyPair(){return this.#i.generateTransportKeyPair()}createEIP712(e,t,n,r){return this.#i.createEIP712(e,t,n,r)}encrypt(e){return this.#i.encrypt(e)}userDecrypt(e){return this.#i.userDecrypt(e)}publicDecrypt(e){return this.#i.publicDecrypt(e)}createDelegatedUserDecryptEIP712(e,t,n,r,i){return this.#i.createDelegatedUserDecryptEIP712(e,t,n,r,i)}delegatedUserDecrypt(e){return this.#i.delegatedUserDecrypt(e)}requestZKProofVerification(e){return this.#i.requestZKProofVerification(e)}fetchFheEncryptionKeyBytes(){return this.#i.fetchFheEncryptionKeyBytes()}getPublicParams(e){return this.#i.getPublicParams(e)}getAclAddress(){return this.#i.getAclAddress()}terminate(){let e=[];for(let t of new Set(this.#t.values()))try{t.terminate()}catch(t){e.push(g(t))}for(let t of new Set(this.#n))try{t.terminate()}catch(t){e.push(g(t))}if(e.length>0)throw AggregateError(e,`Failed to terminate relayer resources`)}[Symbol.dispose](){this.terminate()}};const X={[S.id]:S.registryAddress,[y.id]:y.registryAddress,[v.id]:v.registryAddress,[x.id]:x.registryAddress,[b.id]:b.registryAddress},ve=E.record(E.string().check(E.regex(/^\d+$/,`expected numeric chain id key`)),M),Z=ae,Q=300*1e3;var ye=class{provider;#e;#t;#n=new Map;constructor(e){this.provider=e.provider,this.#e=Object.assign({},X,C(E.optional(ve),e.registryAddresses)),this.#t=C(Z,e.registryTTL??86400)*1e3}getAddress(e){return this.#e[e]}#r(e){let t=this.#n.get(e);if(t){if(Date.now()>=t.expiresAt){this.#n.delete(e);return}return t.data}}#i(e,t,n=this.#t){return this.#n.set(e,{data:t,expiresAt:Date.now()+n}),t}refresh(){this.#n.clear()}get ttlMs(){return this.#t}async getRegistryAddress(){let e=await this.provider.getChainId(),n=this.#e[e];if(!n)throw new t(`No wrappers registry address configured for chain ${e}.\nPass a registryAddresses entry for this chain.`);return w(n)}async listPairs(e={}){let n=e.page??1,r=e.pageSize??100,a=e.metadata??!1;if(n<1)throw new t(`page must be >= 1, got ${n}`);if(r<1)throw new t(`pageSize must be >= 1, got ${r}`);let o=await this.getRegistryAddress(),s=`total:${o}`,l=this.#r(s);if(l===void 0){let e=await this.provider.readContract(i(o));l=this.#i(s,Number(e))}let u=BigInt((n-1)*r),d=u+BigInt(r)>BigInt(l)?BigInt(l):u+BigInt(r);if(u>=BigInt(l))return{items:[],total:l,page:n,pageSize:r};let f=`slice:${o}:${u}:${d}`,p=this.#r(f);if(p===void 0){let e=await this.provider.readContract(c(o,u,d));p=this.#i(f,[...e])}if(!a)return{items:p,total:l,page:n,pageSize:r};let m=`metadata:${o}:${u}:${d}`,h=this.#r(m);if(h===void 0){let e=await Promise.allSettled(p.map(e=>this.#a(e))),t=e.some(e=>e.status===`rejected`),n=e.map((e,t)=>e.status===`fulfilled`?e.value:Object.assign({},p[t],{metadataFailed:!0,underlying:{name:`Unknown`,symbol:`???`,decimals:0,totalSupply:0n},confidential:{name:`Unknown`,symbol:`???`,decimals:0}}));h=this.#i(m,n,t?Q:void 0)}return{items:h,total:l,page:n,pageSize:r}}async#a(e){let[t,n,r,i,o,s,c]=await Promise.all([this.provider.readContract(a(e.tokenAddress)),this.provider.readContract(p(e.tokenAddress)),this.provider.readContract(f(e.tokenAddress)),this.provider.readContract(m(e.tokenAddress)),this.provider.readContract(a(e.confidentialTokenAddress)),this.provider.readContract(p(e.confidentialTokenAddress)),this.provider.readContract(f(e.confidentialTokenAddress))]);return{...e,underlying:{name:t,symbol:n,decimals:r,totalSupply:i},confidential:{name:o,symbol:s,decimals:c}}}async getConfidentialToken(e){let t=await this.getRegistryAddress(),n=w(e),r=`ct:${t}:${n}`,i=this.#r(r);if(i!==void 0)return i;let[a,o]=await this.provider.readContract(d(t,n));return o===T?this.#i(r,null,Q):this.#i(r,{confidentialTokenAddress:o,isValid:a})}async getUnderlyingToken(e){let t=await this.getRegistryAddress(),n=w(e),r=`ut:${t}:${n}`,i=this.#r(r);if(i!==void 0)return i;let[a,o]=await this.provider.readContract(s(t,n));return o===T?this.#i(r,null,Q):this.#i(r,{tokenAddress:o,isValid:a})}async getTokenPairs(){let e=await this.getRegistryAddress();return this.provider.readContract(o(e))}async getTokenPairsLength(){let e=await this.getRegistryAddress();return this.provider.readContract(i(e))}async getTokenPairsSlice(e,t){let n=await this.getRegistryAddress();return this.provider.readContract(c(n,e,t))}async getTokenPair(e){let t=await this.getRegistryAddress();return this.provider.readContract(l(t,e))}async getConfidentialTokenAddress(e){let t=await this.getRegistryAddress();return this.provider.readContract(d(t,w(e)))}async getTokenAddress(e){let t=await this.getRegistryAddress();return this.provider.readContract(s(t,w(e)))}async isConfidentialTokenValid(e){let t=await this.getRegistryAddress();return this.provider.readContract(u(t,w(e)))}};function be(e,t,n){let{storage:r,permitStorage:i}=q(n.storage,n.permitStorage),a=new ge(n.logger),o=new Y(n.chains,n.relayers,a);return{chains:n.chains,relayer:o,provider:t,signer:e,storage:r,permitStorage:i,transportKeyPairTTL:C(B,n.transportKeyPairTTL??2592e3),permitTTL:C(V,n.permitTTL??30),registryTTL:C(Z,n.registryTTL??86400),logger:a,onEvent:n.onEvent}}function xe(e,t){return e?.address===t?.address&&e?.chainId===t?.chainId}var $=class{#e=new Set;#t;#n;constructor(e){this.#t=e,this.#n=e!==void 0}getSnapshot(){return this.#t}isReady(){return this.#n}setSnapshot(e){this.#n=!0;let t=this.#t;xe(t,e)||(this.#t=e,this.#r({previous:t,next:e}))}subscribe(e){this.#e.add(e);let t=this.#t;return t&&e({previous:void 0,next:t}),()=>{this.#e.delete(e)}}#r(e){for(let t of this.#e)t(e)}};function Se(e){return new $(e)}var Ce=class{walletAccount;#e=!1;constructor(e){this.walletAccount=new $(e)}requireWalletAccount(e){let t=this.walletAccount.getSnapshot();if(!t)throw new h(e);return t}dispose(){this.#e||(this.#e=!0,this.onDispose())}[Symbol.dispose](){this.dispose()}onDispose(){}};export{X as a,q as c,M as d,j as f,be as i,he as l,$ as n,ye as o,Se as r,J as s,Ce as t,A as u};
|
|
2
|
-
//# sourceMappingURL=base-signer-BVqcM5jt.js.map
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{i as e,r as t,t as n}from"./relayer-D-nicEYJ.js";import{A as r,B as i,F as a,H as o,I as s,O as c,R as l,S as u,T as d,V as f,b as p,l as m,m as h,u as g,v as _,w as v,x as y}from"./wrappers-registry-BWWG0aze.js";import{n as b,t as x}from"./encryption-BGmINekJ.js";import{r as S}from"./error-W1N-FGwV.js";import{t as C}from"./assertions-CnPIS0VN.js";import{getAddress as w}from"viem";var T=class extends t{constructor(t,n){super(e.TransactionReverted,t,n),this.name=`TransactionRevertedError`}},E=class extends t{operation;signerChainId;providerChainId;constructor({operation:t,signerChainId:n,providerChainId:r},i){super(e.ChainMismatch,`Operation "${t}" requires signer and provider to be on the same chain, but signer is on chain ${n} and provider is on chain ${r}.`,i),this.name=`ChainMismatchError`,this.operation=t,this.signerChainId=n,this.providerChainId=r}},D=class extends t{requested;available;token;constructor(t,n,r){super(e.InsufficientConfidentialBalance,t,r),this.name=`InsufficientConfidentialBalanceError`,this.requested=n.requested,this.available=n.available,this.token=n.token}},O=class extends t{requested;available;token;constructor(t,n,r){super(e.InsufficientERC20Balance,t,r),this.name=`InsufficientERC20BalanceError`,this.requested=n.requested,this.available=n.available,this.token=n.token}},k=class extends t{constructor(t,n){super(e.BalanceCheckUnavailable,t,n),this.name=`BalanceCheckUnavailableError`}},A=class extends t{constructor(t,n){super(e.ERC20ReadFailed,t,n),this.name=`ERC20ReadFailedError`}};function j(e){return e instanceof o||e instanceof f||e instanceof n}const M=[{type:`function`,name:`allow`,inputs:[{name:`handle`,type:`bytes32`,internalType:`bytes32`},{name:`account`,type:`address`,internalType:`address`}],outputs:[],stateMutability:`nonpayable`},{type:`function`,name:`allowForDecryption`,inputs:[{name:`handlesList`,type:`bytes32[]`,internalType:`bytes32[]`}],outputs:[],stateMutability:`nonpayable`},{type:`function`,name:`allowTransient`,inputs:[{name:`ciphertext`,type:`bytes32`,internalType:`bytes32`},{name:`account`,type:`address`,internalType:`address`}],outputs:[],stateMutability:`nonpayable`},{type:`function`,name:`cleanTransientStorage`,inputs:[],outputs:[],stateMutability:`nonpayable`},{type:`function`,name:`delegateForUserDecryption`,inputs:[{name:`delegate`,type:`address`,internalType:`address`},{name:`contractAddress`,type:`address`,internalType:`address`},{name:`expirationDate`,type:`uint64`,internalType:`uint64`}],outputs:[],stateMutability:`nonpayable`},{type:`function`,name:`getUserDecryptionDelegationExpirationDate`,inputs:[{name:`delegator`,type:`address`,internalType:`address`},{name:`delegate`,type:`address`,internalType:`address`},{name:`contractAddress`,type:`address`,internalType:`address`}],outputs:[{name:``,type:`uint64`,internalType:`uint64`}],stateMutability:`view`},{type:`function`,name:`isAccountDenied`,inputs:[{name:`account`,type:`address`,internalType:`address`}],outputs:[{name:``,type:`bool`,internalType:`bool`}],stateMutability:`view`},{type:`function`,name:`isAllowed`,inputs:[{name:`handle`,type:`bytes32`,internalType:`bytes32`},{name:`account`,type:`address`,internalType:`address`}],outputs:[{name:``,type:`bool`,internalType:`bool`}],stateMutability:`view`},{type:`function`,name:`isAllowedForDecryption`,inputs:[{name:`handle`,type:`bytes32`,internalType:`bytes32`}],outputs:[{name:``,type:`bool`,internalType:`bool`}],stateMutability:`view`},{type:`function`,name:`isHandleDelegatedForUserDecryption`,inputs:[{name:`delegator`,type:`address`,internalType:`address`},{name:`delegate`,type:`address`,internalType:`address`},{name:`contractAddress`,type:`address`,internalType:`address`},{name:`handle`,type:`bytes32`,internalType:`bytes32`}],outputs:[{name:``,type:`bool`,internalType:`bool`}],stateMutability:`view`},{type:`function`,name:`multicall`,inputs:[{name:`data`,type:`bytes[]`,internalType:`bytes[]`}],outputs:[{name:`results`,type:`bytes[]`,internalType:`bytes[]`}],stateMutability:`payable`},{type:`function`,name:`persistAllowed`,inputs:[{name:`handle`,type:`bytes32`,internalType:`bytes32`},{name:`account`,type:`address`,internalType:`address`}],outputs:[{name:``,type:`bool`,internalType:`bool`}],stateMutability:`view`},{type:`function`,name:`revokeDelegationForUserDecryption`,inputs:[{name:`delegate`,type:`address`,internalType:`address`},{name:`contractAddress`,type:`address`,internalType:`address`}],outputs:[],stateMutability:`nonpayable`}];function N(e,t,n,r){return{address:e,abi:M,functionName:`delegateForUserDecryption`,args:[t,n,r]}}function P(e,t,n){return{address:e,abi:M,functionName:`revokeDelegationForUserDecryption`,args:[t,n]}}function F(e,t,n,r){return{address:e,abi:M,functionName:`getUserDecryptionDelegationExpirationDate`,args:[t,n,r]}}function I(e,t,n,r,i){return{address:e,abi:M,functionName:`isHandleDelegatedForUserDecryption`,args:[t,n,r,i]}}const L=2n**64n-1n;async function R(e,t,n){if(!t)throw new s(e);let r;try{r=t.requireWalletAccount(e)}catch(n){if(!(n instanceof l)||!t.refreshWalletAccount)throw n;await t.refreshWalletAccount(),r=t.requireWalletAccount(e)}let i=await n.getChainId();if(r.chainId!==i)throw new E({operation:e,signerChainId:r.chainId,providerChainId:i});return r}async function z(e,t,n){return(await R(e,t,n)).chainId}const B={EncryptStart:`encrypt:start`,EncryptEnd:`encrypt:end`,EncryptError:`encrypt:error`,DecryptStart:`decrypt:start`,DecryptEnd:`decrypt:end`,DecryptError:`decrypt:error`,TransactionError:`transaction:error`,ShieldSubmitted:`shield:submitted`,TransferSubmitted:`transfer:submitted`,TransferFromSubmitted:`transferFrom:submitted`,SetOperatorSubmitted:`setOperator:submitted`,ApproveUnderlyingSubmitted:`approveUnderlying:submitted`,UnwrapSubmitted:`unwrap:submitted`,FinalizeUnwrapSubmitted:`finalizeUnwrap:submitted`,DelegationSubmitted:`delegation:submitted`,RevokeDelegationSubmitted:`revokeDelegation:submitted`,UnshieldPhase1Submitted:`unshield:phase1_submitted`,UnshieldPhase2Started:`unshield:phase2_started`,UnshieldPhase2Submitted:`unshield:phase2_submitted`},V={approveUnderlying:{submittedEvent:e=>({type:B.ApproveUnderlyingSubmitted,txHash:e,step:`approve`})},"approveUnderlying:reset":{submittedEvent:e=>({type:B.ApproveUnderlyingSubmitted,txHash:e,step:`reset`})},delegateDecryption:{submittedEvent:e=>({type:B.DelegationSubmitted,txHash:e})},finalizeUnwrap:{submittedEvent:e=>({type:B.FinalizeUnwrapSubmitted,txHash:e})},revokeDelegation:{submittedEvent:e=>({type:B.RevokeDelegationSubmitted,txHash:e})},setOperator:{submittedEvent:e=>({type:B.SetOperatorSubmitted,txHash:e})},"shield:transferAndCall":{submittedEvent:e=>({type:B.ShieldSubmitted,txHash:e,shieldPath:`transferAndCall`})},"shield:approveAndWrap":{submittedEvent:e=>({type:B.ShieldSubmitted,txHash:e,shieldPath:`approveAndWrap`})},transfer:{submittedEvent:e=>({type:B.TransferSubmitted,txHash:e})},transferFrom:{submittedEvent:e=>({type:B.TransferFromSubmitted,txHash:e})},unwrap:{submittedEvent:e=>({type:B.UnwrapSubmitted,txHash:e})},unwrapAll:{submittedEvent:e=>({type:B.UnwrapSubmitted,txHash:e})}};async function H(e,t=1/0){if(Number.isFinite(t)&&t<=0)throw Error(`maxConcurrency must be a positive number`);if(!Number.isFinite(t)||t>=e.length)return Promise.all(e.map(e=>e()));let n=Array.from({length:e.length}),r=0;async function i(){for(;r<e.length;){let t=r++;e[t]&&(n[t]=await e[t]())}}return await Promise.all(Array.from({length:t},i)),n}const U=`0x0000000000000000000000000000000000000000000000000000000000000000`;function W(e){return e===`0x0000000000000000000000000000000000000000000000000000000000000000`||e===`0x`}async function G(e){let{operation:n,signer:r,provider:i,config:o,emit:s,onSubmitted:c,logger:l}=e,u=V[n];try{let e=await r.writeContract(o);return s(u.submittedEvent(e)),a(`${n}: onSubmitted`,()=>c?.(e),l),{txHash:e,receipt:await i.waitForTransactionReceipt(e)}}catch(e){let r=e instanceof t?e:new T(`Transaction failed during ${n}`,{cause:e});throw s({type:B.TransactionError,operation:n,error:r}),r}}var K=class e{sdk;address;constructor(e,t){this.sdk=e,this.address=w(t)}#e(e){return i(this.sdk.signer,e)}async name(){return this.sdk.provider.readContract(p(this.address))}async symbol(){return this.sdk.provider.readContract(y(this.address))}async decimals(){return this.sdk.provider.readContract(_(this.address))}async isConfidential(){return this.sdk.provider.readContract(h(this.address,m))}async isWrapper(){return this.sdk.provider.readContract(h(this.address,g))}async balanceOf(e){let t=w(e),n=await this.readConfidentialBalanceOf(t),r=(await this.sdk.decryption.decryptValues([{encryptedValue:n,contractAddress:this.address}]))[n];if(r===void 0)throw new x(`Decryption returned no value for ${n}`);return C(r,`balanceOf: result[encryptedValue]`),r}async confidentialBalanceOf(e){return this.readConfidentialBalanceOf(w(e))}async decryptBalanceAs({delegatorAddress:e,accountAddress:t}){await z(`decryptBalanceAs`,this.sdk.signer,this.sdk.provider);let n=w(e),r=t?w(t):n,i=await this.readConfidentialBalanceOf(r);if(W(i))return 0n;let a=(await this.sdk.decryption.delegatedDecryptValues([{encryptedValue:i,contractAddress:this.address}],n,r))[i];if(a===void 0)throw new x(`Delegated decryption returned no value for ${i}`);return C(a,`decryptBalanceAs: result[encryptedValue]`),a}static async batchBalancesOf(n,r){let i=new Map,a=new Map;if(n.length===0)return{results:i,errors:a};let o=e.assertSameSdk(n);await z(`batchBalancesOf`,o.signer,o.provider),await o.permits.grantPermit(n.map(e=>e.address));let s=await H(n.map(e=>async()=>{try{return{status:`fulfilled`,value:await e.balanceOf(r)}}catch(e){return{status:`rejected`,reason:e}}}),5);for(let e=0;e<n.length;e++){let r=n[e].address,o=s[e];if(o.status===`fulfilled`)i.set(r,o.value);else{let e=o.reason;if(j(e))throw e;let n=e instanceof t?e:new x(S(e).message,{cause:e});a.set(r,n)}}if(a.size===n.length)throw a.values().next().value??new x(`All token balance decryptions failed`);return{results:i,errors:a}}static async batchDecryptBalancesAs(t,n){if(t.length===0)return new Map;let r=e.assertSameSdk(t),i=new Map,a=new Map,o=n.accountAddress?w(n.accountAddress):w(n.delegatorAddress),s=n.maxConcurrency??10;if(n.encryptedValues&&t.length!==n.encryptedValues.length)throw new x(`tokens.length (${t.length}) must equal encryptedValues.length (${n.encryptedValues.length})`);let c=n.encryptedValues??await e.readBalanceHandlesBatch(t,o,a,s),l=[];for(let[e,n]of t.entries()){let t=c[e];!t||a.has(n.address)||(W(t)?i.set(n.address,0n):l.push({token:n,encryptedValue:t}))}if(l.length>0){let e=await r.decryption.delegatedBatchDecryptValues({encryptedInputs:l.map(({token:e,encryptedValue:t})=>({encryptedValue:t,contractAddress:e.address})),delegatorAddress:n.delegatorAddress,accountAddress:n.accountAddress,maxConcurrency:s});for(let[t,n]of e.items.entries()){let e=l[t];if(!e)continue;if(n.error){a.set(e.token.address,n.error);continue}let r=n.value;if(r===void 0){a.set(e.token.address,new x(`Batch delegated decryption returned no value for ${n.encryptedValue} on token ${e.token.address}`));continue}C(r,`batchDecryptBalancesAs: result[encryptedValue]`),i.set(e.token.address,r)}}if(a.size===0)return i;if(n.onError){let e=[];for(let[t,r]of a)try{i.set(t,n.onError(r,t))}catch(n){e.push({address:t,error:S(n)})}if(e.length>0){let t=e.map(({address:e,error:t})=>`${e}: ${t.message}`).join(`; `);throw new x(`Batch delegated decryption onError callback failed for ${e.length} token(s): ${t}`,{cause:e[0]?.error})}return i}let u=Array.from(a.entries()),d=u.map(([e,t])=>`${e}: ${t.message}`).join(`; `);throw new x(`Batch delegated decryption failed for ${a.size} token(s): ${d}`,{cause:u[0]?.[1]})}static async readBalanceHandlesBatch(e,n,r,i){let a=await H(e.map(e=>async()=>{try{return{status:`fulfilled`,value:await e.readConfidentialBalanceOf(n)}}catch(e){return{status:`rejected`,reason:e}}}),i),o=[];for(let[n,i]of e.entries()){let e=a[n];if(e){if(e.status===`fulfilled`){o[n]=e.value;continue}if(j(e.reason))throw e.reason;r.set(i.address,e.reason instanceof t?e.reason:new x(S(e.reason).message,{cause:e.reason}))}}return o}async confidentialTransfer(e,t,n){this.#e(`confidentialTransfer`);let r=await R(`confidentialTransfer`,this.sdk.signer,this.sdk.provider),{skipBalanceCheck:i=!1,onEncryptComplete:o,onTransferSubmitted:s}=n??{},c=w(e);i||await this.assertConfidentialBalance(t);let{encryptedValues:l,inputProof:u}=await this.sdk.encrypt({values:[{value:t,type:`euint64`}],contractAddress:this.address,userAddress:w(r.address)});if(a(`transfer: onEncryptComplete`,()=>o?.(),this.sdk.logger),l.length===0)throw new b(`Encryption returned no encrypted values`);return this.submitTransaction({operation:`transfer`,config:v(this.address,c,l[0],u),onSubmitted:s})}async confidentialTransferFrom(e,t,n,r){this.#e(`confidentialTransferFrom`),await R(`confidentialTransferFrom`,this.sdk.signer,this.sdk.provider);let i=w(e),o=w(t),{encryptedValues:s,inputProof:c}=await this.sdk.encrypt({values:[{value:n,type:`euint64`}],contractAddress:this.address,userAddress:i});if(a(`transferFrom: onEncryptComplete`,()=>r?.onEncryptComplete?.(),this.sdk.logger),s.length===0)throw new b(`Encryption returned no encrypted values`);return this.submitTransaction({operation:`transferFrom`,config:d(this.address,i,o,s[0],c),onSubmitted:r?.onTransferSubmitted})}async setOperator(e,t){this.#e(`setOperator`),await z(`setOperator`,this.sdk.signer,this.sdk.provider);let n=w(e);return this.submitTransaction({operation:`setOperator`,config:r(this.address,n,t)})}async isOperator(e,t){return this.sdk.provider.readContract(c(this.address,w(e),w(t)))}async readConfidentialBalanceOf(e){return await this.sdk.provider.readContract(u(this.address,e))}async assertConfidentialBalance(e){if(e===0n)return;let n;try{let e=await R(`assertConfidentialBalance`,this.sdk.signer,this.sdk.provider);n=await this.balanceOf(w(e.address))}catch(e){throw e instanceof t?e:new k(`Balance validation failed (token: ${this.address})`,{cause:e})}if(n<e)throw new D(`Insufficient confidential balance: requested ${e}, available ${n} (token: ${this.address})`,{requested:e,available:n,token:this.address})}emit(e){this.sdk.emitEvent(e,this.address)}async submitTransaction(e){let{operation:t,config:n,onSubmitted:r}=e;return G({operation:t,signer:this.#e(t),provider:this.sdk.provider,config:n,emit:e=>this.emit(e),onSubmitted:r,logger:this.sdk.logger})}static assertSameSdk(e){let t=e[0].sdk;for(let r=1;r<e.length;r++)if(e[r].sdk!==t)throw new n(`All tokens in a batch operation must share the same ZamaSDK instance`);return t}};export{D as _,H as a,T as b,z as c,F as d,I as f,A as g,k as h,W as i,L as l,j as m,G as n,B as o,P as p,U as r,R as s,K as t,N as u,O as v,E as y};
|
|
2
|
-
//# sourceMappingURL=token-TQ-VFHS4.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"token-TQ-VFHS4.js","names":["#requireSigner","submitSdkTransaction"],"sources":["../../src/errors/transaction.ts","../../src/errors/chain.ts","../../src/errors/balance.ts","../../src/errors/fatal-batch.ts","../../src/abi/acl.abi.ts","../../src/contracts/acl.ts","../../src/contracts/constants.ts","../../src/utils/alignment.ts","../../src/events/sdk-events.ts","../../src/utils/concurrency.ts","../../src/utils/handles.ts","../../src/utils/submit-transaction.ts","../../src/token/token.ts"],"sourcesContent":["import { ZamaError, ZamaErrorCode } from \"./base\";\n\n/** On-chain transaction reverted. */\nexport class TransactionRevertedError extends ZamaError {\n constructor(message: string, options?: ErrorOptions) {\n super(ZamaErrorCode.TransactionReverted, message, options);\n this.name = \"TransactionRevertedError\";\n }\n}\n","import { ZamaError, ZamaErrorCode } from \"./base\";\n\n/**\n * Thrown when the signer and provider are connected to different chains at the\n * start of a write operation.\n *\n * Every write method runs a chain-alignment pre-flight check. If\n * `signer.getChainId()` and `provider.getChainId()` return different values,\n * this error is thrown before any RPC mutation is attempted.\n *\n * @example\n * ```ts\n * try {\n * await token.shield(1000n);\n * } catch (e) {\n * if (e instanceof ChainMismatchError) {\n * console.error(\n * `Signer is on chain ${e.signerChainId} but provider is on chain ${e.providerChainId}`,\n * );\n * }\n * }\n * ```\n */\nexport class ChainMismatchError extends ZamaError {\n readonly operation: string;\n readonly signerChainId: number;\n readonly providerChainId: number;\n\n constructor(\n {\n operation,\n signerChainId,\n providerChainId,\n }: { operation: string; signerChainId: number; providerChainId: number },\n options?: ErrorOptions,\n ) {\n super(\n ZamaErrorCode.ChainMismatch,\n `Operation \"${operation}\" requires signer and provider to be on the same chain, ` +\n `but signer is on chain ${signerChainId} and provider is on chain ${providerChainId}.`,\n options,\n );\n this.name = \"ChainMismatchError\";\n this.operation = operation;\n this.signerChainId = signerChainId;\n this.providerChainId = providerChainId;\n }\n}\n","import type { Address } from \"viem\";\nimport { ZamaError, ZamaErrorCode } from \"./base\";\n\n/** Structured details shared by balance-related errors. */\nexport interface BalanceErrorDetails {\n readonly requested: bigint;\n readonly available: bigint;\n readonly token: Address;\n}\n\n/** Confidential (cToken) balance is insufficient for the requested operation. */\nexport class InsufficientConfidentialBalanceError extends ZamaError {\n /** The amount the caller requested. */\n readonly requested: bigint;\n /** The available balance at the time of the check. */\n readonly available: bigint;\n /** The token contract address. */\n readonly token: Address;\n\n constructor(message: string, details: BalanceErrorDetails, options?: ErrorOptions) {\n super(ZamaErrorCode.InsufficientConfidentialBalance, message, options);\n this.name = \"InsufficientConfidentialBalanceError\";\n this.requested = details.requested;\n this.available = details.available;\n this.token = details.token;\n }\n}\n\n/** ERC-20 balance is insufficient for the requested shield amount. */\nexport class InsufficientERC20BalanceError extends ZamaError {\n /** The amount the caller requested. */\n readonly requested: bigint;\n /** The available balance at the time of the check. */\n readonly available: bigint;\n /** The ERC-20 token contract address. */\n readonly token: Address;\n\n constructor(message: string, details: BalanceErrorDetails, options?: ErrorOptions) {\n super(ZamaErrorCode.InsufficientERC20Balance, message, options);\n this.name = \"InsufficientERC20BalanceError\";\n this.requested = details.requested;\n this.available = details.available;\n this.token = details.token;\n }\n}\n\n/** Balance validation could not be performed (no cached credentials and decryption not possible). */\nexport class BalanceCheckUnavailableError extends ZamaError {\n constructor(message: string, options?: ErrorOptions) {\n super(ZamaErrorCode.BalanceCheckUnavailable, message, options);\n this.name = \"BalanceCheckUnavailableError\";\n }\n}\n\n/** A public ERC-20 read (e.g. balanceOf) failed due to a network or contract error. */\nexport class ERC20ReadFailedError extends ZamaError {\n constructor(message: string, options?: ErrorOptions) {\n super(ZamaErrorCode.ERC20ReadFailed, message, options);\n this.name = \"ERC20ReadFailedError\";\n }\n}\n","import { ConfigurationError } from \"./relayer\";\nimport { SigningRejectedError, SigningFailedError } from \"./signing\";\n\n/**\n * Returns `true` for errors that should abort an entire batch operation\n * rather than be recorded per-item — wallet signature rejected, signing\n * infrastructure broken, or SDK misconfigured. These are systemic failures\n * that won't recover within the same call.\n *\n * Callers iterating over a batch (e.g. per-token decrypt) should rethrow when\n * this predicate is true so the whole batch aborts, and record the error\n * per-item otherwise.\n */\nexport function isFatalBatchError(error: unknown): boolean {\n return (\n error instanceof SigningRejectedError ||\n error instanceof SigningFailedError ||\n error instanceof ConfigurationError\n );\n}\n","// DO NOT EDIT: generated by `pnpm abi:build` from\n// contracts/out/Impl.sol/IACL.json.\n// Regenerate after `pnpm contracts:build`; `pnpm abi:check` enforces this in CI.\nexport const aclAbi = [\n {\n type: \"function\",\n name: \"allow\",\n inputs: [\n {\n name: \"handle\",\n type: \"bytes32\",\n internalType: \"bytes32\",\n },\n {\n name: \"account\",\n type: \"address\",\n internalType: \"address\",\n },\n ],\n outputs: [],\n stateMutability: \"nonpayable\",\n },\n {\n type: \"function\",\n name: \"allowForDecryption\",\n inputs: [\n {\n name: \"handlesList\",\n type: \"bytes32[]\",\n internalType: \"bytes32[]\",\n },\n ],\n outputs: [],\n stateMutability: \"nonpayable\",\n },\n {\n type: \"function\",\n name: \"allowTransient\",\n inputs: [\n {\n name: \"ciphertext\",\n type: \"bytes32\",\n internalType: \"bytes32\",\n },\n {\n name: \"account\",\n type: \"address\",\n internalType: \"address\",\n },\n ],\n outputs: [],\n stateMutability: \"nonpayable\",\n },\n {\n type: \"function\",\n name: \"cleanTransientStorage\",\n inputs: [],\n outputs: [],\n stateMutability: \"nonpayable\",\n },\n {\n type: \"function\",\n name: \"delegateForUserDecryption\",\n inputs: [\n {\n name: \"delegate\",\n type: \"address\",\n internalType: \"address\",\n },\n {\n name: \"contractAddress\",\n type: \"address\",\n internalType: \"address\",\n },\n {\n name: \"expirationDate\",\n type: \"uint64\",\n internalType: \"uint64\",\n },\n ],\n outputs: [],\n stateMutability: \"nonpayable\",\n },\n {\n type: \"function\",\n name: \"getUserDecryptionDelegationExpirationDate\",\n inputs: [\n {\n name: \"delegator\",\n type: \"address\",\n internalType: \"address\",\n },\n {\n name: \"delegate\",\n type: \"address\",\n internalType: \"address\",\n },\n {\n name: \"contractAddress\",\n type: \"address\",\n internalType: \"address\",\n },\n ],\n outputs: [\n {\n name: \"\",\n type: \"uint64\",\n internalType: \"uint64\",\n },\n ],\n stateMutability: \"view\",\n },\n {\n type: \"function\",\n name: \"isAccountDenied\",\n inputs: [\n {\n name: \"account\",\n type: \"address\",\n internalType: \"address\",\n },\n ],\n outputs: [\n {\n name: \"\",\n type: \"bool\",\n internalType: \"bool\",\n },\n ],\n stateMutability: \"view\",\n },\n {\n type: \"function\",\n name: \"isAllowed\",\n inputs: [\n {\n name: \"handle\",\n type: \"bytes32\",\n internalType: \"bytes32\",\n },\n {\n name: \"account\",\n type: \"address\",\n internalType: \"address\",\n },\n ],\n outputs: [\n {\n name: \"\",\n type: \"bool\",\n internalType: \"bool\",\n },\n ],\n stateMutability: \"view\",\n },\n {\n type: \"function\",\n name: \"isAllowedForDecryption\",\n inputs: [\n {\n name: \"handle\",\n type: \"bytes32\",\n internalType: \"bytes32\",\n },\n ],\n outputs: [\n {\n name: \"\",\n type: \"bool\",\n internalType: \"bool\",\n },\n ],\n stateMutability: \"view\",\n },\n {\n type: \"function\",\n name: \"isHandleDelegatedForUserDecryption\",\n inputs: [\n {\n name: \"delegator\",\n type: \"address\",\n internalType: \"address\",\n },\n {\n name: \"delegate\",\n type: \"address\",\n internalType: \"address\",\n },\n {\n name: \"contractAddress\",\n type: \"address\",\n internalType: \"address\",\n },\n {\n name: \"handle\",\n type: \"bytes32\",\n internalType: \"bytes32\",\n },\n ],\n outputs: [\n {\n name: \"\",\n type: \"bool\",\n internalType: \"bool\",\n },\n ],\n stateMutability: \"view\",\n },\n {\n type: \"function\",\n name: \"multicall\",\n inputs: [\n {\n name: \"data\",\n type: \"bytes[]\",\n internalType: \"bytes[]\",\n },\n ],\n outputs: [\n {\n name: \"results\",\n type: \"bytes[]\",\n internalType: \"bytes[]\",\n },\n ],\n stateMutability: \"payable\",\n },\n {\n type: \"function\",\n name: \"persistAllowed\",\n inputs: [\n {\n name: \"handle\",\n type: \"bytes32\",\n internalType: \"bytes32\",\n },\n {\n name: \"account\",\n type: \"address\",\n internalType: \"address\",\n },\n ],\n outputs: [\n {\n name: \"\",\n type: \"bool\",\n internalType: \"bool\",\n },\n ],\n stateMutability: \"view\",\n },\n {\n type: \"function\",\n name: \"revokeDelegationForUserDecryption\",\n inputs: [\n {\n name: \"delegate\",\n type: \"address\",\n internalType: \"address\",\n },\n {\n name: \"contractAddress\",\n type: \"address\",\n internalType: \"address\",\n },\n ],\n outputs: [],\n stateMutability: \"nonpayable\",\n },\n] as const;\n","import type { Address } from \"viem\";\nimport { aclAbi } from \"../abi/acl.abi\";\n\n/**\n * Returns the contract config to delegate user decryption rights.\n *\n * @example\n * ```ts\n * const txHash = await signer.writeContract(\n * delegateForUserDecryptionContract(aclAddress, delegateAddress, contractAddress, expirationDate),\n * );\n * ```\n */\nexport function delegateForUserDecryptionContract(\n aclAddress: Address,\n delegateAddress: Address,\n contractAddress: Address,\n expirationDate: bigint,\n) {\n return {\n address: aclAddress,\n abi: aclAbi,\n functionName: \"delegateForUserDecryption\",\n args: [delegateAddress, contractAddress, expirationDate],\n } as const;\n}\n\n/**\n * Returns the contract config to revoke a user decryption delegation.\n *\n * @example\n * ```ts\n * const txHash = await signer.writeContract(\n * revokeDelegationContract(aclAddress, delegateAddress, contractAddress),\n * );\n * ```\n */\nexport function revokeDelegationContract(\n aclAddress: Address,\n delegateAddress: Address,\n contractAddress: Address,\n) {\n return {\n address: aclAddress,\n abi: aclAbi,\n functionName: \"revokeDelegationForUserDecryption\",\n args: [delegateAddress, contractAddress],\n } as const;\n}\n\n/**\n * Returns the contract config to read the delegation expiry date.\n *\n * @example\n * ```ts\n * const expiry = await provider.readContract(\n * getDelegationExpiryContract(aclAddress, delegatorAddress, delegateAddress, contractAddress),\n * );\n * ```\n */\nexport function getDelegationExpiryContract(\n aclAddress: Address,\n delegatorAddress: Address,\n delegateAddress: Address,\n contractAddress: Address,\n) {\n return {\n address: aclAddress,\n abi: aclAbi,\n functionName: \"getUserDecryptionDelegationExpirationDate\",\n args: [delegatorAddress, delegateAddress, contractAddress],\n } as const;\n}\n\n/**\n * Returns the contract config to check if a specific handle is delegated.\n *\n * @example\n * ```ts\n * const isDelegated = await provider.readContract(\n * isHandleDelegatedContract(aclAddress, delegatorAddress, delegateAddress, contractAddress, handle),\n * );\n * ```\n */\nexport function isHandleDelegatedContract(\n aclAddress: Address,\n delegatorAddress: Address,\n delegateAddress: Address,\n contractAddress: Address,\n handle: `0x${string}`,\n) {\n return {\n address: aclAddress,\n abi: aclAbi,\n functionName: \"isHandleDelegatedForUserDecryption\",\n args: [delegatorAddress, delegateAddress, contractAddress, handle],\n } as const;\n}\n","/** uint64 max — represents a permanent (no-expiry) delegation. */\nexport const MAX_UINT64 = 2n ** 64n - 1n;\n","import {\n ChainMismatchError,\n SignerNotConfiguredError,\n WalletAccountNotReadyError,\n} from \"../errors\";\nimport type { GenericProvider, GenericSigner, WalletAccount } from \"../types\";\n\n/**\n * Pre-flight guard for signer-required operations. Resolves the connected\n * wallet account (refreshing once if the signer reports it isn't ready) and\n * verifies the signer's chain matches the provider's.\n *\n * @internal\n */\nexport async function requireAlignedWalletAccount(\n operation: string,\n signer: GenericSigner | undefined,\n provider: GenericProvider,\n): Promise<WalletAccount> {\n if (!signer) {\n throw new SignerNotConfiguredError(operation);\n }\n let account: WalletAccount;\n try {\n account = signer.requireWalletAccount(operation);\n } catch (error) {\n if (!(error instanceof WalletAccountNotReadyError) || !signer.refreshWalletAccount) {\n throw error;\n }\n await signer.refreshWalletAccount();\n account = signer.requireWalletAccount(operation);\n }\n const providerChainId = await provider.getChainId();\n if (account.chainId !== providerChainId) {\n throw new ChainMismatchError({\n operation,\n signerChainId: account.chainId,\n providerChainId,\n });\n }\n return account;\n}\n\n/**\n * Variant of {@link requireAlignedWalletAccount} that returns only the aligned\n * chain ID. Useful when a write path only needs to ensure signer/provider\n * coherence and doesn't otherwise consume the account.\n *\n * @internal\n */\nexport async function requireChainAlignment(\n operation: string,\n signer: GenericSigner | undefined,\n provider: GenericProvider,\n): Promise<number> {\n return (await requireAlignedWalletAccount(operation, signer, provider)).chainId;\n}\n","import type { Address, Hex } from \"viem\";\nimport type { ClearValue, EncryptedValue } from \"../relayer/relayer-sdk.types\";\nimport type { ShieldPath } from \"../types/token\";\n\n/**\n * All SDK event keys, accessible as `ZamaSDKEvents.EncryptStart` etc.\n */\nexport const ZamaSDKEvents = {\n // FHE operations\n EncryptStart: \"encrypt:start\",\n EncryptEnd: \"encrypt:end\",\n EncryptError: \"encrypt:error\",\n DecryptStart: \"decrypt:start\",\n DecryptEnd: \"decrypt:end\",\n DecryptError: \"decrypt:error\",\n // Write operations\n TransactionError: \"transaction:error\",\n ShieldSubmitted: \"shield:submitted\",\n TransferSubmitted: \"transfer:submitted\",\n TransferFromSubmitted: \"transferFrom:submitted\",\n SetOperatorSubmitted: \"setOperator:submitted\",\n ApproveUnderlyingSubmitted: \"approveUnderlying:submitted\",\n UnwrapSubmitted: \"unwrap:submitted\",\n FinalizeUnwrapSubmitted: \"finalizeUnwrap:submitted\",\n // Delegation operations\n DelegationSubmitted: \"delegation:submitted\",\n RevokeDelegationSubmitted: \"revokeDelegation:submitted\",\n // Unshield orchestration\n UnshieldPhase1Submitted: \"unshield:phase1_submitted\",\n UnshieldPhase2Started: \"unshield:phase2_started\",\n UnshieldPhase2Submitted: \"unshield:phase2_submitted\",\n} as const;\n\n/** Union of all SDK event type strings. */\nexport type ZamaSDKEventType = (typeof ZamaSDKEvents)[keyof typeof ZamaSDKEvents];\n\n// -- Base fields present on every event --\n\nexport interface BaseEvent {\n tokenAddress?: Address;\n timestamp: number;\n /** Shared identifier linking related events in multi-phase operations (e.g. unshield). */\n operationId?: string;\n}\n\n// -- Per-event typed payloads --\n\nexport interface EncryptStartEvent extends BaseEvent {\n type: typeof ZamaSDKEvents.EncryptStart;\n}\n\nexport interface EncryptEndEvent extends BaseEvent {\n type: typeof ZamaSDKEvents.EncryptEnd;\n durationMs: number;\n}\n\nexport interface EncryptErrorEvent extends BaseEvent {\n type: typeof ZamaSDKEvents.EncryptError;\n /** The error that caused the encryption to fail. */\n error: Error;\n durationMs: number;\n}\n\nexport interface DecryptStartEvent extends BaseEvent {\n type: typeof ZamaSDKEvents.DecryptStart;\n /** Encrypted values being decrypted — correlate with matching DecryptEnd/DecryptError. */\n encryptedValues: EncryptedValue[];\n}\n\nexport interface DecryptEndEvent extends BaseEvent {\n type: typeof ZamaSDKEvents.DecryptEnd;\n durationMs: number;\n /** Encrypted values that were decrypted. */\n encryptedValues: EncryptedValue[];\n /** Decrypted values keyed by encrypted value — use this to correlate events to specific entries. */\n result: Record<EncryptedValue, ClearValue>;\n}\n\nexport interface DecryptErrorEvent extends BaseEvent {\n type: typeof ZamaSDKEvents.DecryptError;\n /** The error that caused the decryption to fail. */\n error: Error;\n durationMs: number;\n /** Encrypted values that were being decrypted when the error occurred. */\n encryptedValues: EncryptedValue[];\n}\n\nexport interface TransactionErrorEvent extends BaseEvent {\n type: typeof ZamaSDKEvents.TransactionError;\n /** Which SDK operation failed. */\n operation: TransactionOperation;\n /** The error that caused the transaction to fail. */\n error: Error;\n}\n\nexport interface ShieldSubmittedEvent extends BaseEvent {\n type: typeof ZamaSDKEvents.ShieldSubmitted;\n txHash: Hex;\n /** Which execution path was used: single-tx `transferAndCall` or two-tx `approveAndWrap`. */\n shieldPath: ShieldPath;\n}\n\nexport interface TransferSubmittedEvent extends BaseEvent {\n type: typeof ZamaSDKEvents.TransferSubmitted;\n txHash: Hex;\n}\n\nexport interface TransferFromSubmittedEvent extends BaseEvent {\n type: typeof ZamaSDKEvents.TransferFromSubmitted;\n txHash: Hex;\n}\n\nexport interface SetOperatorSubmittedEvent extends BaseEvent {\n type: typeof ZamaSDKEvents.SetOperatorSubmitted;\n txHash: Hex;\n}\n\nexport interface ApproveUnderlyingSubmittedEvent extends BaseEvent {\n type: typeof ZamaSDKEvents.ApproveUnderlyingSubmitted;\n txHash: Hex;\n /** Which approval transaction was submitted. */\n step: \"reset\" | \"approve\";\n}\n\nexport interface UnwrapSubmittedEvent extends BaseEvent {\n type: typeof ZamaSDKEvents.UnwrapSubmitted;\n txHash: Hex;\n}\n\nexport interface FinalizeUnwrapSubmittedEvent extends BaseEvent {\n type: typeof ZamaSDKEvents.FinalizeUnwrapSubmitted;\n txHash: Hex;\n}\n\nexport interface DelegationSubmittedEvent extends BaseEvent {\n type: typeof ZamaSDKEvents.DelegationSubmitted;\n txHash: Hex;\n}\n\nexport interface RevokeDelegationSubmittedEvent extends BaseEvent {\n type: typeof ZamaSDKEvents.RevokeDelegationSubmitted;\n txHash: Hex;\n}\n\nexport interface UnshieldPhase1SubmittedEvent extends BaseEvent {\n type: typeof ZamaSDKEvents.UnshieldPhase1Submitted;\n txHash: Hex;\n}\n\nexport interface UnshieldPhase2StartedEvent extends BaseEvent {\n type: typeof ZamaSDKEvents.UnshieldPhase2Started;\n}\n\nexport interface UnshieldPhase2SubmittedEvent extends BaseEvent {\n type: typeof ZamaSDKEvents.UnshieldPhase2Submitted;\n txHash: Hex;\n}\n\n/**\n * Discriminated union of all SDK events.\n *\n * Decrypt events carry encrypted values and decrypted clear-text values so event\n * subscribers can correlate and bind them in UI layers. Events never carry\n * private keys, permit signatures, or ZK proofs.\n */\nexport type ZamaSDKEvent =\n | EncryptStartEvent\n | EncryptEndEvent\n | EncryptErrorEvent\n | DecryptStartEvent\n | DecryptEndEvent\n | DecryptErrorEvent\n | TransactionErrorEvent\n | ShieldSubmittedEvent\n | TransferSubmittedEvent\n | TransferFromSubmittedEvent\n | SetOperatorSubmittedEvent\n | ApproveUnderlyingSubmittedEvent\n | UnwrapSubmittedEvent\n | FinalizeUnwrapSubmittedEvent\n | DelegationSubmittedEvent\n | RevokeDelegationSubmittedEvent\n | UnshieldPhase1SubmittedEvent\n | UnshieldPhase2StartedEvent\n | UnshieldPhase2SubmittedEvent;\n\nexport type ZamaSDKEventListener = (event: ZamaSDKEvent) => void;\n\n/** Distributive Omit that preserves the discriminated union. */\nexport type ZamaSDKEventInput = ZamaSDKEvent extends infer E\n ? E extends ZamaSDKEvent\n ? Omit<E, \"timestamp\" | \"tokenAddress\">\n : never\n : never;\n\n/**\n * Single source of truth for each transaction operation's submitted-event payload.\n *\n * Adding a write op = adding one entry here. `TransactionOperation` is then\n * `keyof typeof transactionOperationMetadata`, so the dispatch table and the\n * operation union cannot drift.\n *\n * The `satisfies` check enforces that every entry produces a valid\n * {@link ZamaSDKEventInput}.\n */\nexport const transactionOperationMetadata = {\n approveUnderlying: {\n submittedEvent: (txHash: Hex) => ({\n type: ZamaSDKEvents.ApproveUnderlyingSubmitted,\n txHash,\n step: \"approve\" as const,\n }),\n },\n \"approveUnderlying:reset\": {\n submittedEvent: (txHash: Hex) => ({\n type: ZamaSDKEvents.ApproveUnderlyingSubmitted,\n txHash,\n step: \"reset\" as const,\n }),\n },\n delegateDecryption: {\n submittedEvent: (txHash: Hex) => ({ type: ZamaSDKEvents.DelegationSubmitted, txHash }),\n },\n finalizeUnwrap: {\n submittedEvent: (txHash: Hex) => ({ type: ZamaSDKEvents.FinalizeUnwrapSubmitted, txHash }),\n },\n revokeDelegation: {\n submittedEvent: (txHash: Hex) => ({ type: ZamaSDKEvents.RevokeDelegationSubmitted, txHash }),\n },\n setOperator: {\n submittedEvent: (txHash: Hex) => ({ type: ZamaSDKEvents.SetOperatorSubmitted, txHash }),\n },\n \"shield:transferAndCall\": {\n submittedEvent: (txHash: Hex) => ({\n type: ZamaSDKEvents.ShieldSubmitted,\n txHash,\n shieldPath: \"transferAndCall\" as const,\n }),\n },\n \"shield:approveAndWrap\": {\n submittedEvent: (txHash: Hex) => ({\n type: ZamaSDKEvents.ShieldSubmitted,\n txHash,\n shieldPath: \"approveAndWrap\" as const,\n }),\n },\n transfer: {\n submittedEvent: (txHash: Hex) => ({ type: ZamaSDKEvents.TransferSubmitted, txHash }),\n },\n transferFrom: {\n submittedEvent: (txHash: Hex) => ({ type: ZamaSDKEvents.TransferFromSubmitted, txHash }),\n },\n unwrap: {\n submittedEvent: (txHash: Hex) => ({ type: ZamaSDKEvents.UnwrapSubmitted, txHash }),\n },\n unwrapAll: {\n submittedEvent: (txHash: Hex) => ({ type: ZamaSDKEvents.UnwrapSubmitted, txHash }),\n },\n} satisfies Record<string, { submittedEvent: (txHash: Hex) => ZamaSDKEventInput }>;\n\n/**\n * SDK transaction operations that emit submitted/error lifecycle events.\n *\n * Operation strings encode the execution-path discriminator for flows that have\n * one (`shield:transferAndCall` vs. `shield:approveAndWrap`), routing both error\n * and success events on a single field — see {@link transactionOperationMetadata}.\n */\nexport type TransactionOperation = keyof typeof transactionOperationMetadata;\n","/**\n * Execute an array of async thunks with bounded concurrency.\n * Defaults to `Infinity` (equivalent to `Promise.all`).\n */\nexport async function pLimit<T>(\n fns: (() => Promise<T>)[],\n maxConcurrency = Infinity,\n): Promise<T[]> {\n if (Number.isFinite(maxConcurrency) && maxConcurrency <= 0) {\n throw new Error(\"maxConcurrency must be a positive number\");\n }\n if (!Number.isFinite(maxConcurrency) || maxConcurrency >= fns.length) {\n return Promise.all(fns.map((f) => f()));\n }\n\n const results: T[] = Array.from({ length: fns.length });\n let index = 0;\n\n async function worker() {\n while (index < fns.length) {\n const i = index++;\n if (fns[i]) {\n results[i] = await fns[i]();\n }\n }\n }\n\n await Promise.all(Array.from({ length: maxConcurrency }, worker));\n return results;\n}\n","export const ZERO_ENCRYPTED_VALUE =\n \"0x0000000000000000000000000000000000000000000000000000000000000000\" as const;\n\n/**\n * Check whether an encrypted value represents the zero value.\n */\nexport function isEncryptedValueZero(encryptedValue: string): boolean {\n return encryptedValue === ZERO_ENCRYPTED_VALUE || encryptedValue === \"0x\";\n}\n","import type { Hex } from \"viem\";\nimport { TransactionRevertedError, ZamaError } from \"../errors\";\nimport type { TransactionOperation, ZamaSDKEventInput } from \"../events/sdk-events\";\nimport { transactionOperationMetadata, ZamaSDKEvents } from \"../events/sdk-events\";\nimport type {\n GenericProvider,\n GenericSigner,\n TransactionResult,\n WriteContractConfig,\n} from \"../types\";\nimport type { GenericLogger } from \"../worker/worker.types\";\nimport { swallow } from \"./swallow\";\n\n/**\n * Shared write-transaction pipeline for SDK calls that submit a transaction.\n *\n * On success: writes the tx, emits the per-operation submitted event from\n * {@link transactionOperationMetadata}, fires `onSubmitted`, waits for the\n * receipt, and returns `{ txHash, receipt }`.\n *\n * On failure: emits a {@link ZamaSDKEvents.TransactionError} event with the\n * transaction-level error it will throw, then throws it. Existing `ZamaError`\n * instances are rethrown as-is; all other failures are wrapped in\n * `TransactionRevertedError` with the original error as `cause`.\n */\nexport async function submitTransaction(params: {\n operation: TransactionOperation;\n signer: GenericSigner;\n provider: GenericProvider;\n config: WriteContractConfig;\n emit: (input: ZamaSDKEventInput) => void;\n onSubmitted?: (txHash: Hex) => void;\n logger: GenericLogger;\n}): Promise<TransactionResult> {\n const { operation, signer, provider, config, emit, onSubmitted, logger } = params;\n const metadata = transactionOperationMetadata[operation];\n\n try {\n const txHash = await signer.writeContract(config);\n emit(metadata.submittedEvent(txHash));\n void swallow(`${operation}: onSubmitted`, () => onSubmitted?.(txHash), logger);\n const receipt = await provider.waitForTransactionReceipt(txHash);\n return { txHash, receipt };\n } catch (error) {\n const failure =\n error instanceof ZamaError\n ? error\n : new TransactionRevertedError(`Transaction failed during ${operation}`, {\n cause: error,\n });\n\n emit({\n type: ZamaSDKEvents.TransactionError,\n operation,\n error: failure,\n });\n throw failure;\n }\n}\n","import { type Address, getAddress, type Hex } from \"viem\";\nimport {\n confidentialBalanceOfContract,\n confidentialTransferContract,\n confidentialTransferFromContract,\n decimalsContract,\n ERC7984_INTERFACE_ID,\n ERC7984_WRAPPER_INTERFACE_ID,\n isOperatorContract,\n nameContract,\n setOperatorContract,\n supportsInterfaceContract,\n symbolContract,\n} from \"../contracts\";\nimport {\n BalanceCheckUnavailableError,\n ConfigurationError,\n DecryptionFailedError,\n EncryptionFailedError,\n InsufficientConfidentialBalanceError,\n isFatalBatchError,\n requireConfigured,\n ZamaError,\n} from \"../errors\";\nimport type { TransactionOperation, ZamaSDKEventInput } from \"../events/sdk-events\";\nimport type { ClearValue, EncryptedValue } from \"../relayer/relayer-sdk.types\";\nimport { toError } from \"../utils\";\nimport { requireAlignedWalletAccount, requireChainAlignment } from \"../utils/alignment\";\nimport { assertBigint } from \"../utils/assertions\";\nimport { pLimit } from \"../utils/concurrency\";\nimport { isEncryptedValueZero } from \"../utils/handles\";\nimport { submitTransaction as submitSdkTransaction } from \"../utils/submit-transaction\";\nimport { swallow } from \"../utils/swallow\";\nimport type {\n GenericSigner,\n TransactionResult,\n TransferCallbacks,\n TransferOptions,\n WriteContractConfig,\n} from \"../types\";\nimport type { ZamaSDK } from \"../zama-sdk\";\n\n/** Options for {@link Token.batchDecryptBalancesAs}. */\nexport interface BatchDecryptAsOptions {\n /** The address of the account that delegated decryption rights. */\n delegatorAddress: Address;\n /** Pre-fetched encrypted values. When omitted, they are fetched from the chain. */\n encryptedValues?: EncryptedValue[];\n /**\n * The account whose on-chain balance to read. Defaults to the delegator\n * address, which is the common case (the delegator grants permission to\n * decrypt their own balance). Only set this when the account differs\n * from the delegator.\n *\n * Matches the `account` parameter of `confidentialBalanceOf(account)` on-chain.\n */\n accountAddress?: Address;\n /** Maximum number of concurrent decrypt calls. Default: 10. */\n maxConcurrency?: number;\n /** Called when decryption fails for a single token. Return a fallback bigint. */\n onError?: (error: Error, address: Address) => bigint;\n}\n\n/** Result of {@link Token.batchBalancesOf}. */\nexport interface BatchBalancesResult {\n /** Successfully decrypted balances, keyed by token address. */\n results: Map<Address, bigint>;\n /** Per-token errors for tokens that failed to decrypt. */\n errors: Map<Address, ZamaError>;\n}\n\n/**\n * High-level interface for an ERC-7984 confidential token.\n * Hides FHE complexity (encryption, decryption, EIP-712 signing) behind\n * familiar ERC-20-like methods.\n *\n * For ERC-7984 wrappers (shield/unshield), use {@link WrappedToken} instead —\n * it extends `Token` with wrapper-specific operations.\n *\n * Decryption, credentials, caching, and event emission are handled by the\n * owning {@link ZamaSDK} — this class only exposes token-scoped helpers\n * that delegate to `sdk.decryption.decryptValues` and `sdk.permits.grantPermit`.\n */\nexport class Token {\n readonly sdk: ZamaSDK;\n readonly address: Address;\n\n constructor(sdk: ZamaSDK, address: Address) {\n this.sdk = sdk;\n this.address = getAddress(address);\n }\n\n /** Resolve `sdk.signer` or throw {@link SignerNotConfiguredError} tagged with `operation`. */\n #requireSigner(operation: string): GenericSigner {\n return requireConfigured(this.sdk.signer, operation);\n }\n\n // METADATA\n\n /** Read the token name from the contract. */\n async name(): Promise<string> {\n return this.sdk.provider.readContract(nameContract(this.address));\n }\n\n /** Read the token symbol from the contract. */\n async symbol(): Promise<string> {\n return this.sdk.provider.readContract(symbolContract(this.address));\n }\n\n /** Read the token decimals from the contract. */\n async decimals(): Promise<number> {\n return this.sdk.provider.readContract(decimalsContract(this.address));\n }\n\n // ERC-165 DISCOVERY\n\n /**\n * ERC-165 check for {@link ERC7984_INTERFACE_ID} support.\n *\n * @returns `true` if the contract implements the ERC-7984 confidential token interface.\n */\n async isConfidential(): Promise<boolean> {\n return this.sdk.provider.readContract(\n supportsInterfaceContract(this.address, ERC7984_INTERFACE_ID),\n );\n }\n\n /**\n * ERC-165 check for IERC7984ERC20Wrapper support.\n *\n * @returns `true` if the contract implements the ERC-7984 wrapper interface\n * ({@link ERC7984_WRAPPER_INTERFACE_ID}, `0x1f1c62b2`).\n */\n async isWrapper(): Promise<boolean> {\n return this.sdk.provider.readContract(\n supportsInterfaceContract(this.address, ERC7984_WRAPPER_INTERFACE_ID),\n );\n }\n\n // BALANCES\n\n /**\n * Decrypt and return the plaintext balance for the given owner.\n * Acquires FHE credentials via a wallet signature if none are cached.\n *\n * @param owner - Balance owner address.\n * @returns The decrypted plaintext balance as a bigint.\n * @throws if FHE decryption fails. {@link DecryptionFailedError}\n *\n * @example\n * ```ts\n * const balance = await token.balanceOf(\"0xOwner\");\n * ```\n */\n async balanceOf(owner: Address): Promise<bigint> {\n const ownerAddress = getAddress(owner);\n const encryptedValue = await this.readConfidentialBalanceOf(ownerAddress);\n const result = await this.sdk.decryption.decryptValues([\n { encryptedValue, contractAddress: this.address },\n ]);\n const value = result[encryptedValue];\n if (value === undefined) {\n throw new DecryptionFailedError(`Decryption returned no value for ${encryptedValue}`);\n }\n assertBigint(value, \"balanceOf: result[encryptedValue]\");\n return value;\n }\n\n /**\n * Return the raw encrypted balance without decrypting.\n *\n * @param owner - Balance owner address.\n * @returns The encrypted balance as a hex string.\n *\n * @example\n * ```ts\n * const encryptedValue = await token.confidentialBalanceOf(\"0xOwner\");\n * ```\n */\n async confidentialBalanceOf(owner: Address): Promise<EncryptedValue> {\n return this.readConfidentialBalanceOf(getAddress(owner));\n }\n\n /**\n * Decrypt the balance of a delegator using delegated decryption credentials.\n * The connected signer acts as the delegatee who has been granted permission\n * by the delegator to decrypt their balance.\n *\n * Clear values are cached in storage keyed by `(account, token, encryptedValue)`.\n * Because every on-chain balance change produces a new encrypted value,\n * stale cache entries are never served. Cache write failures are silently\n * ignored — they do not affect the returned value.\n *\n * @param delegatorAddress - The address of the account that delegated decryption rights.\n * @param accountAddress - The account whose on-chain balance to read. Defaults\n * to the delegator address.\n * @returns The decrypted plaintext balance as a bigint.\n * @throws if no active delegation exists. {@link DelegationNotFoundError}\n * @throws if the delegation has expired. {@link DelegationExpiredError}\n * @throws if delegated decryption fails. {@link DecryptionFailedError}\n *\n * @example\n * ```ts\n * const balance = await token.decryptBalanceAs({\n * delegatorAddress: \"0xDelegator\",\n * });\n * ```\n */\n async decryptBalanceAs({\n delegatorAddress,\n accountAddress,\n }: {\n delegatorAddress: Address;\n accountAddress?: Address;\n }): Promise<bigint> {\n await requireChainAlignment(\"decryptBalanceAs\", this.sdk.signer, this.sdk.provider);\n const normalizedDelegator = getAddress(delegatorAddress);\n const normalizedAccount = accountAddress ? getAddress(accountAddress) : normalizedDelegator;\n\n const encryptedValue = await this.readConfidentialBalanceOf(normalizedAccount);\n if (isEncryptedValueZero(encryptedValue)) {\n return 0n;\n }\n\n const result = await this.sdk.decryption.delegatedDecryptValues(\n [{ encryptedValue, contractAddress: this.address }],\n normalizedDelegator,\n normalizedAccount,\n );\n\n const value = result[encryptedValue];\n if (value === undefined) {\n throw new DecryptionFailedError(\n `Delegated decryption returned no value for ${encryptedValue}`,\n );\n }\n assertBigint(value, \"decryptBalanceAs: result[encryptedValue]\");\n return value;\n }\n\n // BATCH STATICS\n\n /**\n * Decrypt confidential balances for multiple tokens in parallel, returning\n * successes and per-token errors separately. Pre-authorizes all token\n * addresses in a single wallet signature, then delegates each decrypt to\n * `sdk.decryption.decryptValues`.\n *\n * Tokens that fail to decrypt land in `errors` rather than aborting the\n * whole batch — caller decides how to surface them.\n *\n * @param tokens - Array of {@link Token} instances bound to the same SDK.\n * @param owner - Balance owner address.\n * @returns `{ results, errors }` partitioning the per-token outcomes.\n *\n * @example\n * ```ts\n * const { results, errors } = await Token.batchBalancesOf(tokens, owner);\n * ```\n */\n static async batchBalancesOf(tokens: Token[], owner: Address): Promise<BatchBalancesResult> {\n const results = new Map<Address, bigint>();\n const errors = new Map<Address, ZamaError>();\n if (tokens.length === 0) {\n return { results, errors };\n }\n\n const sdk = Token.assertSameSdk(tokens);\n // Fail fast on chain mismatch before prompting the wallet for a signature.\n await requireChainAlignment(\"batchBalancesOf\", sdk.signer, sdk.provider);\n // Pre-authorize the full token set in one wallet signature so subsequent\n // per-token decryptValues calls reuse the cached credentials.\n await sdk.permits.grantPermit(tokens.map((t) => t.address));\n\n const outcomes = await pLimit(\n tokens.map((t) => async () => {\n try {\n return {\n status: \"fulfilled\" as const,\n value: await t.balanceOf(owner),\n };\n } catch (reason) {\n return { status: \"rejected\" as const, reason };\n }\n }),\n 5,\n );\n\n for (let i = 0; i < tokens.length; i++) {\n const tokenAddress = tokens[i]!.address;\n const outcome = outcomes[i]!;\n if (outcome.status === \"fulfilled\") {\n results.set(tokenAddress, outcome.value);\n } else {\n const reason = outcome.reason;\n // Session-level failures (user rejected signature, SDK misconfigured)\n // apply to every token — surface them instead of collecting per-token.\n if (isFatalBatchError(reason)) {\n throw reason;\n }\n const error =\n reason instanceof ZamaError\n ? reason\n : new DecryptionFailedError(toError(reason).message, {\n cause: reason,\n });\n errors.set(tokenAddress, error);\n }\n }\n\n // Total failure: surface the first error so callers know nothing decrypted.\n if (errors.size === tokens.length) {\n const firstError = errors.values().next().value;\n throw firstError ?? new DecryptionFailedError(\"All token balance decryptions failed\");\n }\n\n return { results, errors };\n }\n\n /**\n * Batch decrypt confidential balances as a delegate across multiple tokens.\n * Mirrors {@link batchBalancesOf} but uses delegated credentials.\n *\n * **Error handling:** If a per-token decryption fails and no `onError` callback\n * is provided, errors are collected and thrown as an aggregated\n * `DecryptionFailedError`. When the relayer returns no value for an encrypted value,\n * a `DecryptionFailedError` is thrown for that token (never silently returns `0n`).\n * Pass `onError: () => 0n` to opt into the silent zero behavior.\n *\n * @param tokens - Array of Token instances to decrypt balances for.\n * @param options - Delegated decryption configuration.\n * @returns A Map from token address to decrypted balance.\n * @throws if no active delegation exists. {@link DelegationNotFoundError}\n * @throws if the delegation has expired. {@link DelegationExpiredError}\n * @throws if any decryption fails and no `onError` is provided. {@link DecryptionFailedError}\n *\n * @example\n * ```ts\n * const balances = await Token.batchDecryptBalancesAs(tokens, {\n * delegatorAddress: \"0xDelegator\",\n * onError: (err, addr) => { console.error(addr, err); return 0n; },\n * });\n * ```\n */\n static async batchDecryptBalancesAs(\n tokens: Token[],\n options: BatchDecryptAsOptions,\n ): Promise<Map<Address, bigint>> {\n if (tokens.length === 0) {\n return new Map();\n }\n\n const sdk = Token.assertSameSdk(tokens);\n const results = new Map<Address, bigint>();\n const errors = new Map<Address, ZamaError>();\n const normalizedAccount = options.accountAddress\n ? getAddress(options.accountAddress)\n : getAddress(options.delegatorAddress);\n const maxConcurrency = options.maxConcurrency ?? 10;\n if (options.encryptedValues && tokens.length !== options.encryptedValues.length) {\n throw new DecryptionFailedError(\n `tokens.length (${tokens.length}) must equal encryptedValues.length (${options.encryptedValues.length})`,\n );\n }\n const resolvedEncryptedValues =\n options.encryptedValues ??\n (await Token.readBalanceHandlesBatch(tokens, normalizedAccount, errors, maxConcurrency));\n\n const decryptRequests: Array<{ token: Token; encryptedValue: EncryptedValue }> = [];\n for (const [index, token] of tokens.entries()) {\n const encryptedValue = resolvedEncryptedValues[index];\n if (!encryptedValue || errors.has(token.address)) {\n continue;\n }\n if (isEncryptedValueZero(encryptedValue)) {\n // Zero balance → skip the relayer; no decryption needed.\n results.set(token.address, 0n);\n } else {\n decryptRequests.push({ token, encryptedValue });\n }\n }\n\n if (decryptRequests.length > 0) {\n const decrypted = await sdk.decryption.delegatedBatchDecryptValues({\n encryptedInputs: decryptRequests.map(({ token, encryptedValue }) => ({\n encryptedValue,\n contractAddress: token.address,\n })),\n delegatorAddress: options.delegatorAddress,\n accountAddress: options.accountAddress,\n maxConcurrency,\n });\n\n for (const [index, item] of decrypted.items.entries()) {\n const request = decryptRequests[index];\n if (!request) {\n continue;\n }\n if (item.error) {\n errors.set(request.token.address, item.error);\n continue;\n }\n const value = item.value;\n if (value === undefined) {\n errors.set(\n request.token.address,\n new DecryptionFailedError(\n `Batch delegated decryption returned no value for ${item.encryptedValue} on token ${request.token.address}`,\n ),\n );\n continue;\n }\n assertBigint(value, \"batchDecryptBalancesAs: result[encryptedValue]\");\n results.set(request.token.address, value);\n }\n }\n\n if (errors.size === 0) {\n return results;\n }\n\n if (options.onError) {\n const callbackErrors: Array<{ address: Address; error: Error }> = [];\n for (const [address, error] of errors) {\n try {\n results.set(address, options.onError(error, address));\n } catch (callbackError) {\n callbackErrors.push({ address, error: toError(callbackError) });\n }\n }\n if (callbackErrors.length > 0) {\n const message = callbackErrors\n .map(({ address, error }) => `${address}: ${error.message}`)\n .join(\"; \");\n throw new DecryptionFailedError(\n `Batch delegated decryption onError callback failed for ${callbackErrors.length} token(s): ${message}`,\n { cause: callbackErrors[0]?.error },\n );\n }\n return results;\n }\n\n const errorEntries = Array.from(errors.entries());\n const message = errorEntries.map(([addr, e]) => `${addr}: ${e.message}`).join(\"; \");\n throw new DecryptionFailedError(\n `Batch delegated decryption failed for ${errors.size} token(s): ${message}`,\n { cause: errorEntries[0]?.[1] },\n );\n }\n\n private static async readBalanceHandlesBatch(\n tokens: Token[],\n accountAddress: Address,\n errors: Map<Address, ZamaError>,\n maxConcurrency: number,\n ): Promise<Array<EncryptedValue | undefined>> {\n const outcomes = await pLimit(\n tokens.map((token) => async () => {\n try {\n return {\n status: \"fulfilled\" as const,\n value: await token.readConfidentialBalanceOf(accountAddress),\n };\n } catch (reason) {\n return { status: \"rejected\" as const, reason };\n }\n }),\n maxConcurrency,\n );\n\n const encryptedValues: Array<EncryptedValue | undefined> = [];\n for (const [index, token] of tokens.entries()) {\n const outcome = outcomes[index];\n if (!outcome) {\n continue;\n }\n if (outcome.status === \"fulfilled\") {\n encryptedValues[index] = outcome.value;\n continue;\n }\n if (isFatalBatchError(outcome.reason)) {\n throw outcome.reason;\n }\n errors.set(\n token.address,\n outcome.reason instanceof ZamaError\n ? outcome.reason\n : new DecryptionFailedError(toError(outcome.reason).message, {\n cause: outcome.reason,\n }),\n );\n }\n return encryptedValues;\n }\n\n // WRITE OPERATIONS\n\n /**\n * Confidential transfer. Encrypts the amount via FHE, then calls the contract.\n *\n * By default, the SDK validates the confidential balance before submitting.\n * If a cached plaintext balance exists it is used; otherwise, if credentials\n * are cached, it decrypts on the fly. Set `skipBalanceCheck: true` to bypass\n * this validation (e.g. for smart wallets).\n *\n * @param to - Recipient address.\n * @param amount - Plaintext amount to transfer (encrypted automatically via FHE).\n * @param options - Optional: `skipBalanceCheck` (default `false`).\n * @returns The transaction hash and mined receipt.\n * @throws if signer and provider are on different chains. {@link ChainMismatchError}\n * @throws if the balance is less than `amount`. {@link InsufficientConfidentialBalanceError}\n * @throws if balance validation requires decryption that is not possible. {@link BalanceCheckUnavailableError}\n * @throws if FHE encryption fails. {@link EncryptionFailedError}\n * @throws if the on-chain transfer reverts. {@link TransactionRevertedError}\n *\n * @example\n * ```ts\n * const txHash = await token.confidentialTransfer(\"0xRecipient\", 1000n);\n * ```\n */\n async confidentialTransfer(\n to: Address,\n amount: bigint,\n options?: TransferOptions,\n ): Promise<TransactionResult> {\n this.#requireSigner(\"confidentialTransfer\");\n const account = await requireAlignedWalletAccount(\n \"confidentialTransfer\",\n this.sdk.signer,\n this.sdk.provider,\n );\n const { skipBalanceCheck = false, onEncryptComplete, onTransferSubmitted } = options ?? {};\n\n const normalizedTo = getAddress(to);\n\n if (!skipBalanceCheck) {\n await this.assertConfidentialBalance(amount);\n }\n\n const { encryptedValues, inputProof } = await this.sdk.encrypt({\n values: [{ value: amount, type: \"euint64\" }],\n contractAddress: this.address,\n userAddress: getAddress(account.address),\n });\n void swallow(\"transfer: onEncryptComplete\", () => onEncryptComplete?.(), this.sdk.logger);\n\n if (encryptedValues.length === 0) {\n throw new EncryptionFailedError(\"Encryption returned no encrypted values\");\n }\n\n return this.submitTransaction({\n operation: \"transfer\",\n config: confidentialTransferContract(\n this.address,\n normalizedTo,\n encryptedValues[0]!,\n inputProof,\n ),\n onSubmitted: onTransferSubmitted,\n });\n }\n\n /**\n * Operator encrypted transfer on behalf of another address.\n * The caller must be an approved operator for `from`.\n *\n * @param from - The address to transfer from (caller must be an approved operator).\n * @param to - Recipient address.\n * @param amount - Plaintext amount to transfer (encrypted automatically via FHE).\n * @returns The transaction hash and mined receipt.\n *\n * @example\n * ```ts\n * const txHash = await token.confidentialTransferFrom(\"0xFrom\", \"0xTo\", 500n);\n * ```\n */\n async confidentialTransferFrom(\n from: Address,\n to: Address,\n amount: bigint,\n callbacks?: TransferCallbacks,\n ): Promise<TransactionResult> {\n this.#requireSigner(\"confidentialTransferFrom\");\n await requireAlignedWalletAccount(\n \"confidentialTransferFrom\",\n this.sdk.signer,\n this.sdk.provider,\n );\n const normalizedFrom = getAddress(from);\n const normalizedTo = getAddress(to);\n\n const { encryptedValues, inputProof } = await this.sdk.encrypt({\n values: [{ value: amount, type: \"euint64\" }],\n contractAddress: this.address,\n userAddress: normalizedFrom,\n });\n void swallow(\n \"transferFrom: onEncryptComplete\",\n () => callbacks?.onEncryptComplete?.(),\n this.sdk.logger,\n );\n\n if (encryptedValues.length === 0) {\n throw new EncryptionFailedError(\"Encryption returned no encrypted values\");\n }\n\n return this.submitTransaction({\n operation: \"transferFrom\",\n config: confidentialTransferFromContract(\n this.address,\n normalizedFrom,\n normalizedTo,\n encryptedValues[0]!,\n inputProof,\n ),\n onSubmitted: callbacks?.onTransferSubmitted,\n });\n }\n\n // OPERATOR APPROVAL\n\n /**\n * Set operator approval for the confidential token.\n * Defaults to 1 hour from now if `until` is not specified.\n *\n * @param operator - The address to set as an operator.\n * @param until - Optional Unix timestamp for approval expiry. Defaults to now + 1 hour.\n * @returns The transaction hash and mined receipt.\n *\n * @example\n * ```ts\n * const txHash = await token.setOperator(\"0xOperator\");\n * ```\n */\n async setOperator(operator: Address, until?: number): Promise<TransactionResult> {\n this.#requireSigner(\"setOperator\");\n await requireChainAlignment(\"setOperator\", this.sdk.signer, this.sdk.provider);\n const normalizedOperator = getAddress(operator);\n return this.submitTransaction({\n operation: \"setOperator\",\n config: setOperatorContract(this.address, normalizedOperator, until),\n });\n }\n\n /**\n * Check if a spender is an approved operator for a given holder.\n *\n * @param holder - The token holder address.\n * @param spender - The address to check operator approval for.\n * @returns `true` if the spender is an approved operator for the holder.\n *\n * @example\n * ```ts\n * if (await token.isOperator(\"0xHolder\", \"0xSpender\")) {\n * // spender can call transferFrom on behalf of holder\n * }\n * ```\n */\n async isOperator(holder: Address, spender: Address): Promise<boolean> {\n return this.sdk.provider.readContract(\n isOperatorContract(this.address, getAddress(holder), getAddress(spender)),\n );\n }\n\n // PROTECTED HELPERS\n\n /**\n * Read the on-chain encrypted balance for a given owner.\n *\n * @internal\n */\n protected async readConfidentialBalanceOf(owner: Address): Promise<EncryptedValue> {\n return await this.sdk.provider.readContract(confidentialBalanceOfContract(this.address, owner));\n }\n\n /**\n * Pre-flight check: decrypt the confidential balance and compare against the\n * requested amount. If credentials are cached the decrypt happens silently;\n * if not, throws {@link BalanceCheckUnavailableError} instead of triggering\n * a surprise EIP-712 popup.\n *\n * @internal\n */\n protected async assertConfidentialBalance(amount: bigint): Promise<void> {\n if (amount === 0n) {\n return;\n }\n\n let balance: bigint;\n try {\n const account = await requireAlignedWalletAccount(\n \"assertConfidentialBalance\",\n this.sdk.signer,\n this.sdk.provider,\n );\n balance = await this.balanceOf(getAddress(account.address));\n } catch (error) {\n if (error instanceof ZamaError) {\n throw error;\n }\n throw new BalanceCheckUnavailableError(`Balance validation failed (token: ${this.address})`, {\n cause: error,\n });\n }\n\n if (balance < amount) {\n throw new InsufficientConfidentialBalanceError(\n `Insufficient confidential balance: requested ${amount}, available ${balance} (token: ${this.address})`,\n { requested: amount, available: balance, token: this.address },\n );\n }\n }\n\n /**\n * Emit a token-scoped event through the owning {@link ZamaSDK} so that\n * subscribers see a unified stream.\n *\n * @internal\n */\n protected emit(input: ZamaSDKEventInput): void {\n this.sdk.emitEvent(input, this.address);\n }\n\n /**\n * Submit a token-scoped write transaction through the shared SDK transaction\n * pipeline. Callers keep pre-flight and operation-specific work local.\n *\n * @internal\n */\n protected async submitTransaction(params: {\n operation: TransactionOperation;\n config: WriteContractConfig;\n onSubmitted?: (txHash: Hex) => void;\n }): Promise<TransactionResult> {\n const { operation, config, onSubmitted } = params;\n return submitSdkTransaction({\n operation,\n signer: this.#requireSigner(operation),\n provider: this.sdk.provider,\n config,\n emit: (input) => this.emit(input),\n onSubmitted,\n logger: this.sdk.logger,\n });\n }\n\n /** Verify all tokens share the same SDK instance and return it. */\n private static assertSameSdk(tokens: Token[]): ZamaSDK {\n const sdk = tokens[0]!.sdk;\n for (let i = 1; i < tokens.length; i++) {\n if (tokens[i]!.sdk !== sdk) {\n throw new ConfigurationError(\n \"All tokens in a batch operation must share the same ZamaSDK instance\",\n );\n }\n }\n return sdk;\n }\n}\n\n/** @internal */\nexport type DecryptedHandlesMap = Map<EncryptedValue, ClearValue>;\n"],"mappings":"uYAGA,IAAa,EAAb,cAA8C,CAAU,CACtD,YAAY,EAAiB,EAAwB,CACnD,MAAM,EAAc,oBAAqB,EAAS,CAAO,EACzD,KAAK,KAAO,0BACd,CACF,ECea,EAAb,cAAwC,CAAU,CAChD,UACA,cACA,gBAEA,YACE,CACE,YACA,gBACA,mBAEF,EACA,CACA,MACE,EAAc,cACd,cAAc,EAAU,iFACI,EAAc,4BAA4B,EAAgB,GACtF,CACF,EACA,KAAK,KAAO,qBACZ,KAAK,UAAY,EACjB,KAAK,cAAgB,EACrB,KAAK,gBAAkB,CACzB,CACF,ECpCa,EAAb,cAA0D,CAAU,CAElE,UAEA,UAEA,MAEA,YAAY,EAAiB,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QAAS,CAAC,EACV,gBAAiB,YACnB,EACA,CACE,KAAM,WACN,KAAM,4BACN,OAAQ,CACN,CACE,KAAM,WACN,KAAM,UACN,aAAc,SAChB,EACA,CACE,KAAM,kBACN,KAAM,UACN,aAAc,SAChB,EACA,CACE,KAAM,iBACN,KAAM,SACN,aAAc,QAChB,CACF,EACA,QAAS,CAAC,EACV,gBAAiB,YACnB,EACA,CACE,KAAM,WACN,KAAM,4CACN,OAAQ,CACN,CACE,KAAM,YACN,KAAM,UACN,aAAc,SAChB,EACA,CACE,KAAM,WACN,KAAM,UACN,aAAc,SAChB,EACA,CACE,KAAM,kBACN,KAAM,UACN,aAAc,SAChB,CACF,EACA,QAAS,CACP,CACE,KAAM,GACN,KAAM,SACN,aAAc,QAChB,CACF,EACA,gBAAiB,MACnB,EACA,CACE,KAAM,WACN,KAAM,kBACN,OAAQ,CACN,CACE,KAAM,UACN,KAAM,UACN,aAAc,SAChB,CACF,EACA,QAAS,CACP,CACE,KAAM,GACN,KAAM,OACN,aAAc,MAChB,CACF,EACA,gBAAiB,MACnB,EACA,CACE,KAAM,WACN,KAAM,YACN,OAAQ,CACN,CACE,KAAM,SACN,KAAM,UACN,aAAc,SAChB,EACA,CACE,KAAM,UACN,KAAM,UACN,aAAc,SAChB,CACF,EACA,QAAS,CACP,CACE,KAAM,GACN,KAAM,OACN,aAAc,MAChB,CACF,EACA,gBAAiB,MACnB,EACA,CACE,KAAM,WACN,KAAM,yBACN,OAAQ,CACN,CACE,KAAM,SACN,KAAM,UACN,aAAc,SAChB,CACF,EACA,QAAS,CACP,CACE,KAAM,GACN,KAAM,OACN,aAAc,MAChB,CACF,EACA,gBAAiB,MACnB,EACA,CACE,KAAM,WACN,KAAM,qCACN,OAAQ,CACN,CACE,KAAM,YACN,KAAM,UACN,aAAc,SAChB,EACA,CACE,KAAM,WACN,KAAM,UACN,aAAc,SAChB,EACA,CACE,KAAM,kBACN,KAAM,UACN,aAAc,SAChB,EACA,CACE,KAAM,SACN,KAAM,UACN,aAAc,SAChB,CACF,EACA,QAAS,CACP,CACE,KAAM,GACN,KAAM,OACN,aAAc,MAChB,CACF,EACA,gBAAiB,MACnB,EACA,CACE,KAAM,WACN,KAAM,YACN,OAAQ,CACN,CACE,KAAM,OACN,KAAM,UACN,aAAc,SAChB,CACF,EACA,QAAS,CACP,CACE,KAAM,UACN,KAAM,UACN,aAAc,SAChB,CACF,EACA,gBAAiB,SACnB,EACA,CACE,KAAM,WACN,KAAM,iBACN,OAAQ,CACN,CACE,KAAM,SACN,KAAM,UACN,aAAc,SAChB,EACA,CACE,KAAM,UACN,KAAM,UACN,aAAc,SAChB,CACF,EACA,QAAS,CACP,CACE,KAAM,GACN,KAAM,OACN,aAAc,MAChB,CACF,EACA,gBAAiB,MACnB,EACA,CACE,KAAM,WACN,KAAM,oCACN,OAAQ,CACN,CACE,KAAM,WACN,KAAM,UACN,aAAc,SAChB,EACA,CACE,KAAM,kBACN,KAAM,UACN,aAAc,SAChB,CACF,EACA,QAAS,CAAC,EACV,gBAAiB,YACnB,CACF,EChQA,SAAgB,EACd,EACA,EACA,EACA,EACA,CACA,MAAO,CACL,QAAS,EACT,IAAK,EACL,aAAc,4BACd,KAAM,CAAC,EAAiB,EAAiB,CAAc,CACzD,CACF,CAYA,SAAgB,EACd,EACA,EACA,EACA,CACA,MAAO,CACL,QAAS,EACT,IAAK,EACL,aAAc,oCACd,KAAM,CAAC,EAAiB,CAAe,CACzC,CACF,CAYA,SAAgB,EACd,EACA,EACA,EACA,EACA,CACA,MAAO,CACL,QAAS,EACT,IAAK,EACL,aAAc,4CACd,KAAM,CAAC,EAAkB,EAAiB,CAAe,CAC3D,CACF,CAYA,SAAgB,EACd,EACA,EACA,EACA,EACA,EACA,CACA,MAAO,CACL,QAAS,EACT,IAAK,EACL,aAAc,qCACd,KAAM,CAAC,EAAkB,EAAiB,EAAiB,CAAM,CACnE,CACF,CChGA,MAAa,EAAa,IAAM,IAAM,GCatC,eAAsB,EACpB,EACA,EACA,E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