@zama-fhe/sdk 2.0.0-alpha.2 → 2.0.0-alpha.3
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/relayer-utils.cjs +1 -1
- package/dist/cjs/relayer-utils.cjs.map +1 -1
- package/dist/esm/cleartext/index.d.ts +1 -1
- package/dist/esm/cleartext/index.js +1 -1
- package/dist/esm/index.d.ts +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/node/index.d.ts +1 -1
- package/dist/esm/node/index.js +1 -1
- package/dist/esm/{relayer-utils-CpHWf9Jl.js → relayer-utils-DOcfo9ga.js} +2 -2
- package/dist/esm/{relayer-utils-CpHWf9Jl.js.map → relayer-utils-DOcfo9ga.js.map} +1 -1
- package/dist/esm/{relayer-utils-DsivYLt_.d.ts → relayer-utils-Dj1FfwxT.d.ts} +2 -2
- package/package.json +1 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
async function e(e,r=2){let i;for(let a=0;a<=r;a++)try{return await e()}catch(e){if(i=e,a<r&&t(e)){await n(500*2**a);continue}throw e}throw i}function t(e){if(!(e instanceof Error))return!1;let t=e.message.toLowerCase();return t.includes(`timed out`)||t.includes(`timeout`)||t.includes(`econnreset`)||t.includes(`econnrefused`)||t.includes(`network`)||t.includes(`fetch failed`)||t.includes(`socket hang up`)||t.includes(`502`)||t.includes(`503`)||t.includes(`504`)}function n(e){return new Promise(t=>setTimeout(t,e))}const r={chainId:1,gatewayChainId:261131,relayerUrl:`https://relayer.mainnet.zama.org/v2`,network:`https://ethereum-rpc.publicnode.com`,aclContractAddress:`0xcA2E8f1F656CD25C01F05d0b243Ab1ecd4a8ffb6`,kmsContractAddress:`0x77627828a55156b04Ac0DC0eb30467f1a552BB03`,inputVerifierContractAddress:`0xCe0FC2e05CFff1B719EFF7169f7D80Af770c8EA2`,verifyingContractAddressDecryption:`0x0f6024a97684f7d90ddb0fAAD79cB15F2C888D24`,verifyingContractAddressInputVerification:`0xcB1bB072f38bdAF0F328CdEf1Fc6eDa1DF029287`},i={chainId:11155111,gatewayChainId:10901,relayerUrl:`https://relayer.testnet.zama.org/v2`,network:`https://ethereum-sepolia-rpc.publicnode.com`,aclContractAddress:`0xf0Ffdc93b7E186bC2f8CB3dAA75D86d1930A433D`,kmsContractAddress:`0xbE0E383937d564D7FF0BC3b46c51f0bF8d5C311A`,inputVerifierContractAddress:`0xBBC1fFCdc7C316aAAd72E807D9b0272BE8F84DA0`,verifyingContractAddressDecryption:`0x5D8BD78e2ea6bbE41f26dFe9fdaEAa349e077478`,verifyingContractAddressInputVerification:`0x483b9dE06E4E4C7D35CCf5837A1668487406D955`},a={chainId:31337,gatewayChainId:10901,relayerUrl:``,network:`http://127.0.0.1:8545`,aclContractAddress:`0x50157CFfD6bBFA2DECe204a89ec419c23ef5755D`,inputVerifierContractAddress:`0x36772142b74871f255CbD7A3e89B401d3e45825f`,kmsContractAddress:`
|
|
1
|
+
async function e(e,r=2){let i;for(let a=0;a<=r;a++)try{return await e()}catch(e){if(i=e,a<r&&t(e)){await n(500*2**a);continue}throw e}throw i}function t(e){if(!(e instanceof Error))return!1;let t=e.message.toLowerCase();return t.includes(`timed out`)||t.includes(`timeout`)||t.includes(`econnreset`)||t.includes(`econnrefused`)||t.includes(`network`)||t.includes(`fetch failed`)||t.includes(`socket hang up`)||t.includes(`502`)||t.includes(`503`)||t.includes(`504`)}function n(e){return new Promise(t=>setTimeout(t,e))}const r={chainId:1,gatewayChainId:261131,relayerUrl:`https://relayer.mainnet.zama.org/v2`,network:`https://ethereum-rpc.publicnode.com`,aclContractAddress:`0xcA2E8f1F656CD25C01F05d0b243Ab1ecd4a8ffb6`,kmsContractAddress:`0x77627828a55156b04Ac0DC0eb30467f1a552BB03`,inputVerifierContractAddress:`0xCe0FC2e05CFff1B719EFF7169f7D80Af770c8EA2`,verifyingContractAddressDecryption:`0x0f6024a97684f7d90ddb0fAAD79cB15F2C888D24`,verifyingContractAddressInputVerification:`0xcB1bB072f38bdAF0F328CdEf1Fc6eDa1DF029287`},i={chainId:11155111,gatewayChainId:10901,relayerUrl:`https://relayer.testnet.zama.org/v2`,network:`https://ethereum-sepolia-rpc.publicnode.com`,aclContractAddress:`0xf0Ffdc93b7E186bC2f8CB3dAA75D86d1930A433D`,kmsContractAddress:`0xbE0E383937d564D7FF0BC3b46c51f0bF8d5C311A`,inputVerifierContractAddress:`0xBBC1fFCdc7C316aAAd72E807D9b0272BE8F84DA0`,verifyingContractAddressDecryption:`0x5D8BD78e2ea6bbE41f26dFe9fdaEAa349e077478`,verifyingContractAddressInputVerification:`0x483b9dE06E4E4C7D35CCf5837A1668487406D955`},a={chainId:31337,gatewayChainId:10901,relayerUrl:``,network:`http://127.0.0.1:8545`,aclContractAddress:`0x50157CFfD6bBFA2DECe204a89ec419c23ef5755D`,inputVerifierContractAddress:`0x36772142b74871f255CbD7A3e89B401d3e45825f`,kmsContractAddress:`0x901F8942346f7AB3a01F6D7613119Bca447Bb030`,verifyingContractAddressDecryption:`0x5ffdaAB0373E62E2ea2944776209aEf29E631A64`,verifyingContractAddressInputVerification:`0x812b06e1CDCE800494b79fFE4f925A504a9A9810`},o={1:r,11155111:i,31337:a},s={name:`string`,version:`string`,chainId:`uint256`,verifyingContract:`address`,salt:`bytes32`};function c(e){return Object.keys(s).filter(t=>t in e).map(e=>({name:e,type:s[e]}))}Object.defineProperty(exports,`a`,{enumerable:!0,get:function(){return c}}),Object.defineProperty(exports,`i`,{enumerable:!0,get:function(){return i}}),Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return a}}),Object.defineProperty(exports,`o`,{enumerable:!0,get:function(){return e}}),Object.defineProperty(exports,`r`,{enumerable:!0,get:function(){return r}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return o}});
|
|
2
2
|
//# sourceMappingURL=relayer-utils.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"relayer-utils.cjs","names":[],"sources":["../../src/relayer/relayer-utils.ts"],"sourcesContent":["import type { EIP712TypedData } from \"./relayer-sdk.types\";\nimport type { FhevmInstanceConfig } from \"@zama-fhe/relayer-sdk/bundle\";\n\nconst MAX_RETRIES = 2;\nconst RETRY_BASE_MS = 500;\n\n/**\n * Retry an async operation with exponential backoff.\n * Only retries on transient errors (timeout, network). Does not retry user-facing errors.\n */\nexport async function withRetry<T>(fn: () => Promise<T>, retries = MAX_RETRIES): Promise<T> {\n let lastError: unknown;\n for (let attempt = 0; attempt <= retries; attempt++) {\n try {\n return await fn();\n } catch (error) {\n lastError = error;\n if (attempt < retries && isTransientError(error)) {\n await sleep(RETRY_BASE_MS * 2 ** attempt);\n continue;\n }\n throw error;\n }\n }\n throw lastError;\n}\n\nfunction isTransientError(error: unknown): boolean {\n if (!(error instanceof Error)) {\n return false;\n }\n const msg = error.message.toLowerCase();\n return (\n msg.includes(\"timed out\") ||\n msg.includes(\"timeout\") ||\n msg.includes(\"econnreset\") ||\n msg.includes(\"econnrefused\") ||\n msg.includes(\"network\") ||\n msg.includes(\"fetch failed\") ||\n msg.includes(\"socket hang up\") ||\n msg.includes(\"502\") ||\n msg.includes(\"503\") ||\n msg.includes(\"504\")\n );\n}\n\nfunction sleep(ms: number): Promise<void> {\n return new Promise((resolve) => setTimeout(resolve, ms));\n}\n\n/**\n * Mainnet network configuration (chainId 1).\n *\n * Contract addresses mirror `MainnetConfigV2` from `@zama-fhe/relayer-sdk`.\n * They are duplicated here because the `/bundle` export path only exposes\n * types at build time (runtime values require `/web` or `/node` which pull\n * in WASM). `satisfies FhevmInstanceConfig` ensures structural drift is\n * caught at compile time.\n */\nexport const MainnetConfig = {\n chainId: 1,\n gatewayChainId: 261131,\n relayerUrl: \"https://relayer.mainnet.zama.org/v2\",\n network: \"https://ethereum-rpc.publicnode.com\",\n aclContractAddress: \"0xcA2E8f1F656CD25C01F05d0b243Ab1ecd4a8ffb6\",\n kmsContractAddress: \"0x77627828a55156b04Ac0DC0eb30467f1a552BB03\",\n inputVerifierContractAddress: \"0xCe0FC2e05CFff1B719EFF7169f7D80Af770c8EA2\",\n verifyingContractAddressDecryption: \"0x0f6024a97684f7d90ddb0fAAD79cB15F2C888D24\",\n verifyingContractAddressInputVerification: \"0xcB1bB072f38bdAF0F328CdEf1Fc6eDa1DF029287\",\n} as const satisfies FhevmInstanceConfig;\n\n/**\n * Sepolia testnet network configuration (chainId 11155111).\n * See {@link MainnetConfig} for why addresses are hardcoded.\n */\nexport const SepoliaConfig = {\n chainId: 11155111,\n gatewayChainId: 10901,\n relayerUrl: \"https://relayer.testnet.zama.org/v2\",\n network: \"https://ethereum-sepolia-rpc.publicnode.com\",\n aclContractAddress: \"0xf0Ffdc93b7E186bC2f8CB3dAA75D86d1930A433D\",\n kmsContractAddress: \"0xbE0E383937d564D7FF0BC3b46c51f0bF8d5C311A\",\n inputVerifierContractAddress: \"0xBBC1fFCdc7C316aAAd72E807D9b0272BE8F84DA0\",\n verifyingContractAddressDecryption: \"0x5D8BD78e2ea6bbE41f26dFe9fdaEAa349e077478\",\n verifyingContractAddressInputVerification: \"0x483b9dE06E4E4C7D35CCf5837A1668487406D955\",\n} as const satisfies FhevmInstanceConfig;\n\n/**\n * Hardhat local network configuration (chainId 31337).\n *\n * The addresses in this configuration must match those of your deployment.\n * Ensure that the executor address and other contract addresses correspond to\n * the contracts deployed on your Hardhat network.\n */\nexport const HardhatConfig = {\n chainId: 31337,\n gatewayChainId: 10901,\n relayerUrl: \"\",\n network: \"http://127.0.0.1:8545\",\n aclContractAddress: \"0x50157CFfD6bBFA2DECe204a89ec419c23ef5755D\",\n inputVerifierContractAddress: \"0x36772142b74871f255CbD7A3e89B401d3e45825f\",\n kmsContractAddress: \"
|
|
1
|
+
{"version":3,"file":"relayer-utils.cjs","names":[],"sources":["../../src/relayer/relayer-utils.ts"],"sourcesContent":["import type { EIP712TypedData } from \"./relayer-sdk.types\";\nimport type { FhevmInstanceConfig } from \"@zama-fhe/relayer-sdk/bundle\";\n\nconst MAX_RETRIES = 2;\nconst RETRY_BASE_MS = 500;\n\n/**\n * Retry an async operation with exponential backoff.\n * Only retries on transient errors (timeout, network). Does not retry user-facing errors.\n */\nexport async function withRetry<T>(fn: () => Promise<T>, retries = MAX_RETRIES): Promise<T> {\n let lastError: unknown;\n for (let attempt = 0; attempt <= retries; attempt++) {\n try {\n return await fn();\n } catch (error) {\n lastError = error;\n if (attempt < retries && isTransientError(error)) {\n await sleep(RETRY_BASE_MS * 2 ** attempt);\n continue;\n }\n throw error;\n }\n }\n throw lastError;\n}\n\nfunction isTransientError(error: unknown): boolean {\n if (!(error instanceof Error)) {\n return false;\n }\n const msg = error.message.toLowerCase();\n return (\n msg.includes(\"timed out\") ||\n msg.includes(\"timeout\") ||\n msg.includes(\"econnreset\") ||\n msg.includes(\"econnrefused\") ||\n msg.includes(\"network\") ||\n msg.includes(\"fetch failed\") ||\n msg.includes(\"socket hang up\") ||\n msg.includes(\"502\") ||\n msg.includes(\"503\") ||\n msg.includes(\"504\")\n );\n}\n\nfunction sleep(ms: number): Promise<void> {\n return new Promise((resolve) => setTimeout(resolve, ms));\n}\n\n/**\n * Mainnet network configuration (chainId 1).\n *\n * Contract addresses mirror `MainnetConfigV2` from `@zama-fhe/relayer-sdk`.\n * They are duplicated here because the `/bundle` export path only exposes\n * types at build time (runtime values require `/web` or `/node` which pull\n * in WASM). `satisfies FhevmInstanceConfig` ensures structural drift is\n * caught at compile time.\n */\nexport const MainnetConfig = {\n chainId: 1,\n gatewayChainId: 261131,\n relayerUrl: \"https://relayer.mainnet.zama.org/v2\",\n network: \"https://ethereum-rpc.publicnode.com\",\n aclContractAddress: \"0xcA2E8f1F656CD25C01F05d0b243Ab1ecd4a8ffb6\",\n kmsContractAddress: \"0x77627828a55156b04Ac0DC0eb30467f1a552BB03\",\n inputVerifierContractAddress: \"0xCe0FC2e05CFff1B719EFF7169f7D80Af770c8EA2\",\n verifyingContractAddressDecryption: \"0x0f6024a97684f7d90ddb0fAAD79cB15F2C888D24\",\n verifyingContractAddressInputVerification: \"0xcB1bB072f38bdAF0F328CdEf1Fc6eDa1DF029287\",\n} as const satisfies FhevmInstanceConfig;\n\n/**\n * Sepolia testnet network configuration (chainId 11155111).\n * See {@link MainnetConfig} for why addresses are hardcoded.\n */\nexport const SepoliaConfig = {\n chainId: 11155111,\n gatewayChainId: 10901,\n relayerUrl: \"https://relayer.testnet.zama.org/v2\",\n network: \"https://ethereum-sepolia-rpc.publicnode.com\",\n aclContractAddress: \"0xf0Ffdc93b7E186bC2f8CB3dAA75D86d1930A433D\",\n kmsContractAddress: \"0xbE0E383937d564D7FF0BC3b46c51f0bF8d5C311A\",\n inputVerifierContractAddress: \"0xBBC1fFCdc7C316aAAd72E807D9b0272BE8F84DA0\",\n verifyingContractAddressDecryption: \"0x5D8BD78e2ea6bbE41f26dFe9fdaEAa349e077478\",\n verifyingContractAddressInputVerification: \"0x483b9dE06E4E4C7D35CCf5837A1668487406D955\",\n} as const satisfies FhevmInstanceConfig;\n\n/**\n * Hardhat local network configuration (chainId 31337).\n *\n * The addresses in this configuration must match those of your deployment.\n * Ensure that the executor address and other contract addresses correspond to\n * the contracts deployed on your Hardhat network.\n */\nexport const HardhatConfig = {\n chainId: 31337,\n gatewayChainId: 10901,\n relayerUrl: \"\",\n network: \"http://127.0.0.1:8545\",\n aclContractAddress: \"0x50157CFfD6bBFA2DECe204a89ec419c23ef5755D\",\n inputVerifierContractAddress: \"0x36772142b74871f255CbD7A3e89B401d3e45825f\",\n kmsContractAddress: \"0x901F8942346f7AB3a01F6D7613119Bca447Bb030\",\n verifyingContractAddressDecryption: \"0x5ffdaAB0373E62E2ea2944776209aEf29E631A64\",\n verifyingContractAddressInputVerification: \"0x812b06e1CDCE800494b79fFE4f925A504a9A9810\",\n} as const satisfies FhevmInstanceConfig;\n\nexport const DefaultConfigs: Record<number, FhevmInstanceConfig> = {\n 1: MainnetConfig,\n 11155111: SepoliaConfig,\n 31337: HardhatConfig,\n} as const;\n\n/** EIP-712 domain field → Solidity type. Order follows the EIP-712 spec. */\nconst DOMAIN_FIELD_TYPES: Record<string, string> = {\n name: \"string\",\n version: \"string\",\n chainId: \"uint256\",\n verifyingContract: \"address\",\n salt: \"bytes32\",\n};\n\n/**\n * Build `EIP712Domain` type entries from the keys present in a domain object.\n * Order matches the EIP-712 spec (name → version → chainId → verifyingContract → salt).\n */\nexport function buildEIP712DomainType(\n domain: EIP712TypedData[\"domain\"],\n): { name: string; type: string }[] {\n return Object.keys(DOMAIN_FIELD_TYPES)\n .filter((k) => k in domain)\n .map((k) => ({ name: k, type: DOMAIN_FIELD_TYPES[k]! }));\n}\n"],"mappings":"AAUA,eAAsB,EAAa,EAAsB,EAAU,EAAyB,CAC1F,IAAI,EACJ,IAAK,IAAI,EAAU,EAAG,GAAW,EAAS,IACxC,GAAI,CACF,OAAO,MAAM,GAAI,OACV,EAAO,CAEd,GADA,EAAY,EACR,EAAU,GAAW,EAAiB,EAAM,CAAE,CAChD,MAAM,EAAM,IAAgB,GAAK,EAAQ,CACzC,SAEF,MAAM,EAGV,MAAM,EAGR,SAAS,EAAiB,EAAyB,CACjD,GAAI,EAAE,aAAiB,OACrB,MAAO,GAET,IAAM,EAAM,EAAM,QAAQ,aAAa,CACvC,OACE,EAAI,SAAS,YAAY,EACzB,EAAI,SAAS,UAAU,EACvB,EAAI,SAAS,aAAa,EAC1B,EAAI,SAAS,eAAe,EAC5B,EAAI,SAAS,UAAU,EACvB,EAAI,SAAS,eAAe,EAC5B,EAAI,SAAS,iBAAiB,EAC9B,EAAI,SAAS,MAAM,EACnB,EAAI,SAAS,MAAM,EACnB,EAAI,SAAS,MAAM,CAIvB,SAAS,EAAM,EAA2B,CACxC,OAAO,IAAI,QAAS,GAAY,WAAW,EAAS,EAAG,CAAC,CAY1D,MAAa,EAAgB,CAC3B,QAAS,EACT,eAAgB,OAChB,WAAY,sCACZ,QAAS,sCACT,mBAAoB,6CACpB,mBAAoB,6CACpB,6BAA8B,6CAC9B,mCAAoC,6CACpC,0CAA2C,6CAC5C,CAMY,EAAgB,CAC3B,QAAS,SACT,eAAgB,MAChB,WAAY,sCACZ,QAAS,8CACT,mBAAoB,6CACpB,mBAAoB,6CACpB,6BAA8B,6CAC9B,mCAAoC,6CACpC,0CAA2C,6CAC5C,CASY,EAAgB,CAC3B,QAAS,MACT,eAAgB,MAChB,WAAY,GACZ,QAAS,wBACT,mBAAoB,6CACpB,6BAA8B,6CAC9B,mBAAoB,6CACpB,mCAAoC,6CACpC,0CAA2C,6CAC5C,CAEY,EAAsD,CACjE,EAAG,EACH,SAAU,EACV,MAAO,EACR,CAGK,EAA6C,CACjD,KAAM,SACN,QAAS,SACT,QAAS,UACT,kBAAmB,UACnB,KAAM,UACP,CAMD,SAAgB,EACd,EACkC,CAClC,OAAO,OAAO,KAAK,EAAmB,CACnC,OAAQ,GAAM,KAAK,EAAO,CAC1B,IAAK,IAAO,CAAE,KAAM,EAAG,KAAM,EAAmB,GAAK,EAAE"}
|
|
@@ -63,7 +63,7 @@ declare const hardhatCleartextConfig: {
|
|
|
63
63
|
network: "http://127.0.0.1:8545";
|
|
64
64
|
aclContractAddress: "0x50157CFfD6bBFA2DECe204a89ec419c23ef5755D";
|
|
65
65
|
inputVerifierContractAddress: "0x36772142b74871f255CbD7A3e89B401d3e45825f";
|
|
66
|
-
kmsContractAddress: "
|
|
66
|
+
kmsContractAddress: "0x901F8942346f7AB3a01F6D7613119Bca447Bb030";
|
|
67
67
|
verifyingContractAddressDecryption: "0x5ffdaAB0373E62E2ea2944776209aEf29E631A64";
|
|
68
68
|
verifyingContractAddressInputVerification: "0x812b06e1CDCE800494b79fFE4f925A504a9A9810";
|
|
69
69
|
};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{c as e,n as t,r as n}from"../errors-Cw9kKQJc.js";import{n as r}from"../relayer-utils-
|
|
1
|
+
import{c as e,n as t,r as n}from"../errors-Cw9kKQJc.js";import{n as r}from"../relayer-utils-DOcfo9ga.js";import{concat as i,createPublicClient as a,custom as o,encodePacked as s,getAddress as c,http as l,keccak256 as u,pad as d,parseAbi as f,toBytes as p,toHex as m}from"viem";import{privateKeyToAccount as h}from"viem/accounts";import{mainnet as g,sepolia as _}from"viem/chains";const v=(e,t)=>({name:`InputVerification`,version:`1`,chainId:Number(e),verifyingContract:t}),y=(e,t)=>({name:`Decryption`,version:`1`,chainId:Number(e),verifyingContract:t}),b={domain:v,types:{CiphertextVerification:[{name:`ctHandles`,type:`bytes32[]`},{name:`userAddress`,type:`address`},{name:`contractAddress`,type:`address`},{name:`contractChainId`,type:`uint256`},{name:`extraData`,type:`bytes`}]}},x={domain:y,types:{PublicDecryptVerification:[{name:`ctHandles`,type:`bytes32[]`},{name:`decryptedResult`,type:`bytes`},{name:`extraData`,type:`bytes`}]}},S={domain:y,types:{UserDecryptRequestVerification:[{name:`publicKey`,type:`bytes`},{name:`contractAddresses`,type:`address[]`},{name:`startTimestamp`,type:`uint256`},{name:`durationDays`,type:`uint256`},{name:`extraData`,type:`bytes`}]}},C={domain:y,types:{DelegatedUserDecryptRequestVerification:[{name:`publicKey`,type:`bytes`},{name:`contractAddresses`,type:`address[]`},{name:`delegatorAddress`,type:`address`},{name:`startTimestamp`,type:`uint256`},{name:`durationDays`,type:`uint256`},{name:`extraData`,type:`bytes`}]}},w={ebool:0,euint8:2,euint16:3,euint32:4,euint64:5,euint128:6,eaddress:7,euint256:8},T={0:`ebool`,2:`euint8`,3:`euint16`,4:`euint32`,5:`euint64`,6:`euint128`,7:`eaddress`,8:`euint256`},E={0:2,2:8,3:16,4:32,5:64,6:128,7:160,8:256};Object.freeze(w),Object.freeze(T),Object.freeze(E),Object.freeze({2:0,8:2,16:3,32:4,64:5,128:6,160:7,256:8});function D(e){switch(e){case 0:case 2:case 3:case 4:case 5:case 6:case 7:case 8:return!0;default:return!1}}function O(e){return typeof e==`string`?e in w:!1}function k(e){if(!O(e))throw Error(`Invalid FheType name '${e}'`);return w[e]}function A(e){if(!D(e))throw Error(`Invalid FheType id '${e}'`);let t=E[e];if(t<2)throw Error(`Invalid FheType encryption bit width: ${t}. Minimum is 2 bits.`);return t}const j=p(`ZK-w_rct`),M=p(`ZK-w_hdl`);function N(e,t){let n=Math.ceil(A(t)/8);return p(d(m(e),{size:n}))}function P(t,n,r){if(r.length!==32)throw new e(`random32 must be exactly 32 bytes`);let a=N(n,t),o=u(i([m(new Uint8Array([t])),m(a),m(r)]));return u(i([m(j),o]))}function F(t,n,r,a,o){if(!Number.isInteger(n)||n<0||n>255)throw new e(`index must be an integer between 0 and 255`);let c=u(i([m(j),t])),l=u(s([`bytes`,`bytes32`,`uint8`,`address`,`uint256`],[m(M),c,n,a,o])),d=o&18446744073709551615n;return m(BigInt(l)&115792089237316195423570985008687907853269984665640254554447762662844404858880n|BigInt(n)<<80n|d<<16n|BigInt(r)<<8n|BigInt(0),{size:32})}const I=f([`function persistAllowed(bytes32 handle, address account) view returns (bool)`,`function isAllowedForDecryption(bytes32 handle) view returns (bool)`,`function isHandleDelegatedForUserDecryption(address delegator, address delegate, address contractAddress, bytes32 handle) view returns (bool)`]),L=f([`function plaintexts(bytes32 handle) view returns (uint256)`]),R=[{name:`name`,type:`string`},{name:`version`,type:`string`},{name:`chainId`,type:`uint256`},{name:`verifyingContract`,type:`address`}],z={EIP712Domain:R,UserDecryptRequestVerification:S.types.UserDecryptRequestVerification},B={EIP712Domain:R,DelegatedUserDecryptRequestVerification:C.types.DelegatedUserDecryptRequestVerification},V={EIP712Domain:R,PublicDecryptVerification:x.types.PublicDecryptVerification},H=new Set([g.id,_.id]);function U(e,t){let n=Number(BigInt(e)>>8n&255n);return n===0?t!==0n:n===7?m(t,{size:20}):t}function W(t){if(!O(t.type))throw new e(`Unsupported FHE type`);let n=k(t.type),r;if(t.type===`ebool`){if(typeof t.value==`boolean`)r=t.value?1n:0n;else if(r=t.value,r!==0n&&r!==1n)throw new e(`Bool value must be 0, 1, true, or false`)}else r=t.type===`eaddress`?BigInt(c(t.value)):t.value;if(r<0n)throw new e(`Only non-negative cleartext values are supported`);let i=A(n),a=(1n<<BigInt(i))-1n;if(r>a)throw new e(`Value ${r} exceeds max ${a} for FheType ${n}`);return{fheType:n,value:r}}var G=class{#e;#t;kmsSigner;inputSigner;constructor(e){if(H.has(e.chainId))throw new t(`Cleartext mode is not allowed on chain ${e.chainId}. It is intended for local development and testing only.`);this.#e=a({transport:typeof e.network==`string`?l(e.network):o(e.network)}),this.#t=e,this.kmsSigner=h(e.kmsSignerPrivateKey??`0x388b7680e4e1afa06efbfd45cdd1fe39f3c6af381df6555a19661f283b97de91`),this.inputSigner=h(e.inputSignerPrivateKey??`0x7ec8ada6642fc4ccfb7729bc29c17cf8d21b61abd5642d1db992c0b8672ab901`)}async generateKeypair(){let e=m(crypto.getRandomValues(new Uint8Array(32))),t=m(crypto.getRandomValues(new Uint8Array(32)));for(;t===e;)t=m(crypto.getRandomValues(new Uint8Array(32)));return{publicKey:e,privateKey:t}}async createEIP712(e,t,n,r=7){return{domain:S.domain(this.#t.chainId,this.#t.verifyingContractAddressDecryption),types:z,primaryType:`UserDecryptRequestVerification`,message:{publicKey:e,contractAddresses:t,startTimestamp:BigInt(n),durationDays:BigInt(r),extraData:`0x00`}}}async encrypt(e){let t=e.values.map(W),n=c(e.contractAddress),r=c(e.userAddress),a=t.map(({fheType:e,value:t})=>P(e,t,crypto.getRandomValues(new Uint8Array(32)))),o=u(a.length>0?i(a):`0x`),s=t.map(({fheType:e},t)=>F(o,t,e,this.#t.aclContractAddress,BigInt(this.#t.chainId))),l=t.map(({value:e})=>d(m(e),{size:32})),f=l.length>0?i(l):`0x`,h=await this.inputSigner.signTypedData({domain:b.domain(this.#t.gatewayChainId,this.#t.verifyingContractAddressInputVerification),types:{CiphertextVerification:b.types.CiphertextVerification},primaryType:`CiphertextVerification`,message:{ctHandles:s,userAddress:r,contractAddress:n,contractChainId:BigInt(this.#t.chainId),extraData:f}}),g=p(i([m(new Uint8Array([s.length])),m(new Uint8Array([1])),...s,h,f]));return{handles:s.map(e=>p(e)),inputProof:g}}async userDecrypt(e){return await this.#r(e.handles,c(e.signerAddress),c(e.contractAddress),`User`,`user decrypt`),this.#n(e.handles)}async publicDecrypt(e){let t=e,r=(await Promise.all(t.map(e=>this.#o(e)))).findIndex(e=>!e);if(r!==-1)throw new n(`Handle ${t[r]} is not allowed for public decryption`);let a=await Promise.all(t.map(e=>this.#s(e))),o=Object.fromEntries(t.map((e,t)=>[e,U(e,a[t])])),s=i(a.map(e=>d(m(e),{size:32}))),c=await this.kmsSigner.signTypedData({domain:x.domain(this.#t.gatewayChainId,this.#t.verifyingContractAddressDecryption),types:V,primaryType:`PublicDecryptVerification`,message:{ctHandles:t,decryptedResult:s,extraData:`0x`}});return{clearValues:o,abiEncodedClearValues:s,decryptionProof:i([m(new Uint8Array([1])),c])}}async createDelegatedUserDecryptEIP712(e,t,n,r,i=7){let a={publicKey:e,contractAddresses:t,delegatorAddress:c(n),startTimestamp:String(r),durationDays:String(i),extraData:`0x00`};return{domain:C.domain(BigInt(this.#t.chainId),this.#t.verifyingContractAddressDecryption),types:B,primaryType:`DelegatedUserDecryptRequestVerification`,message:a}}async delegatedUserDecrypt(e){return await this.#i(e.handles,c(e.delegatorAddress),c(e.delegateAddress),c(e.contractAddress)),this.#n(e.handles)}async requestZKProofVerification(e){throw new t(`Not implemented in cleartext mode`)}async getPublicKey(){return{publicKeyId:`mock-public-key-id`,publicKey:new Uint8Array([32])}}async getPublicParams(e){return{publicParams:new Uint8Array([32]),publicParamsId:`mock-public-params-id`}}async getAclAddress(){return this.#t.aclContractAddress}terminate(){}async#n(e){let t=await Promise.all(e.map(e=>this.#s(e)));return Object.fromEntries(e.map((e,n)=>[e,U(e,t[n])]))}async#r(e,t,r,i,a){if(t===r)throw new n(`${i} address ${t} must not equal contract address for ${a}`);let o=await Promise.all(e.flatMap(e=>[this.#a(e,t),this.#a(e,r)]));for(let s=0;s<e.length;s++){let c=o[s*2],l=o[s*2+1];if(!c)throw new n(`${i} ${t} is not authorized for ${a} of handle ${e[s]}`);if(!l)throw new n(`Contract ${r} is not authorized for ${a} of handle ${e[s]}`)}}async#i(e,t,r,i){let a=await Promise.all(e.map(e=>this.#e.readContract({address:this.#t.aclContractAddress,abi:I,functionName:`isHandleDelegatedForUserDecryption`,args:[t,r,i,e]})));for(let t=0;t<e.length;t++)if(!a[t])throw new n(`Handle ${e[t]} is not delegated for user decryption`)}async#a(e,t){return this.#e.readContract({address:this.#t.aclContractAddress,abi:I,functionName:`persistAllowed`,args:[e,t]})}async#o(e){return this.#e.readContract({address:this.#t.aclContractAddress,abi:I,functionName:`isAllowedForDecryption`,args:[e]})}async#s(e){return this.#e.readContract({address:this.#t.executorAddress,abi:L,functionName:`plaintexts`,args:[e]})}};const K={...r,executorAddress:`0xe3a9105a3a932253A70F126eb1E3b589C643dD24`},q={chainId:560048,network:`https://rpc.hoodi.ethpandaops.io`,gatewayChainId:r.gatewayChainId,aclContractAddress:`0x6D3FAf6f86e1fF9F3B0831Dda920AbA1cBd5bd68`,executorAddress:`0xC316692627de536368d82e9121F1D44a550894E6`,verifyingContractAddressDecryption:r.verifyingContractAddressDecryption,verifyingContractAddressInputVerification:r.verifyingContractAddressInputVerification};export{G as RelayerCleartext,K as hardhatCleartextConfig,q as hoodiCleartextConfig};
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { a as EncryptResult, c as PublicDecryptResult, d as RelayerWebSecurityCo
|
|
|
2
2
|
import { A as decodeOnChainEvents, C as Topics, D as WrappedEvent, E as UnwrappedStartedEvent, F as findUnwrapRequested, I as findWrapped, M as decodeUnwrappedFinalized, N as decodeUnwrappedStarted, O as decodeConfidentialTransfer, P as decodeWrapped, S as TOKEN_TOPICS, T as UnwrappedFinalizedEvent, _ as WriteContractConfig, a as ReadContractArgs, b as OnChainEvent, c as ReadFunctionName, d as StoredCredentials, f as TransactionReceipt, g as WriteContractArgs, h as UnshieldCallbacks, i as GenericStorage, j as decodeUnwrapRequested, k as decodeOnChainEvent, l as ShieldCallbacks, m as TransferCallbacks, n as DelegatedStoredCredentials, o as ReadContractConfig, p as TransactionResult, r as GenericSigner, s as ReadContractReturnType, t as ContractAbi, u as SignerLifecycleCallbacks, v as WriteFunctionName, w as UnwrapRequestedEvent, x as RawLog, y as ConfidentialTransferEvent } from "./token.types-DDdIZEax.js";
|
|
3
3
|
import { A as confidentialTransferFromContract, C as finalizeUnwrapContract, D as confidentialBalanceOfContract, E as wrapETHContract, F as setFinalizeUnwrapOperatorContract, I as setOperatorContract, L as totalSupplyContract, M as isFinalizeUnwrapOperatorContract, N as isOperatorContract, O as confidentialTotalSupplyContract, P as rateContract, R as unwrapContract, S as symbolContract, T as wrapContract, _ as allowanceContract, a as confidentialBatchTransferContract, b as decimalsContract, c as getUnwrapFeeContract, d as ERC7984_WRAPPER_INTERFACE_ID, f as isConfidentialTokenContract, g as wrapperExistsContract, h as getWrapperContract, i as BatchTransferData, j as deploymentCoordinatorContract, k as confidentialTransferContract, l as getWrapFeeContract, m as supportsInterfaceContract, n as getDelegationExpiryContract, o as getBatchTransferFeeContract, p as isConfidentialWrapperContract, r as revokeDelegationContract, s as getFeeRecipientContract, t as delegateForUserDecryptionContract, u as ERC7984_INTERFACE_ID, v as approveContract, w as underlyingContract, x as nameContract, y as balanceOfContract, z as unwrapFromBalanceContract } from "./index-BFPpJ8wt.js";
|
|
4
4
|
import { t as RelayerSDK } from "./relayer-sdk-CVVR30IW.js";
|
|
5
|
-
import { n as MainnetConfig, r as SepoliaConfig, t as HardhatConfig } from "./relayer-utils-
|
|
5
|
+
import { n as MainnetConfig, r as SepoliaConfig, t as HardhatConfig } from "./relayer-utils-Dj1FfwxT.js";
|
|
6
6
|
import { $ as DecryptStartEvent, A as ZamaErrorCode, B as CredentialsManagerConfig, C as KeypairExpiredError, D as SigningRejectedError, E as SigningFailedError, F as ReadonlyTokenConfig, G as CredentialsCachedEvent, H as ApproveUnderlyingSubmittedEvent, I as ZERO_HANDLE, J as CredentialsExpiredEvent, K as CredentialsCreatedEvent, L as DelegatedCredentialsManager, M as BatchDecryptAsOptions, N as BatchDecryptOptions, O as TransactionRevertedError, P as ReadonlyToken, Q as DecryptErrorEvent, R as DelegatedCredentialsManagerConfig, S as InvalidKeypairError, T as RelayerRequestFailedError, U as BaseEvent, V as ApproveSubmittedEvent, W as CredentialsAllowedEvent, X as CredentialsRevokedEvent, Y as CredentialsLoadingEvent, Z as DecryptEndEvent, _ as DelegationCooldownError, _t as ZamaSDKEvents, a as ActivityType, at as ShieldSubmittedEvent, b as DelegationSelfNotAllowedError, c as parseActivityFeed, ct as TransferSubmittedEvent, d as ZamaSDKConfig, dt as UnshieldPhase2SubmittedEvent, et as EncryptEndEvent, f as Token, ft as UnwrapSubmittedEvent, g as DecryptionFailedError, gt as ZamaSDKEventType, h as ConfigurationError, ht as ZamaSDKEventListener, i as ActivityLogMetadata, it as SessionExpiredEvent, j as matchZamaError, k as ZamaError, l as sortByBlockNumber, lt as UnshieldPhase1SubmittedEvent, m as ApprovalFailedError, mt as ZamaSDKEventInput, n as ActivityDirection, nt as EncryptStartEvent, o as applyDecryptedValues, ot as TransactionErrorEvent, p as TokenConfig, pt as ZamaSDKEvent, q as CredentialsCreatingEvent, r as ActivityItem, rt as FinalizeUnwrapSubmittedEvent, s as extractEncryptedHandles, st as TransferFromSubmittedEvent, t as ActivityAmount, tt as EncryptErrorEvent, u as ZamaSDK, ut as UnshieldPhase2StartedEvent, v as DelegationExpiredError, w as NoCiphertextError, x as EncryptionFailedError, y as DelegationNotFoundError, z as CredentialsManager } from "./activity-B1fFV04Z.js";
|
|
7
7
|
import { Address, Address as Address$1, Hex, Hex as Hex$1 } from "viem";
|
|
8
8
|
import { ClearValueType, ClearValueType as ClearValueType$1, FheTypeName, FhevmInstanceConfig, InputProofBytesType, InputProofBytesType as InputProofBytesType$1, KeypairType, KeypairType as KeypairType$1, KmsDelegatedUserDecryptEIP712Type, KmsDelegatedUserDecryptEIP712Type as KmsDelegatedUserDecryptEIP712Type$1, ZKProofLike, ZKProofLike as ZKProofLike$1 } from "@zama-fhe/relayer-sdk/bundle";
|
package/dist/esm/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{_ as e,a as t,c as n,d as r,f as i,g as a,h as o,i as s,l as c,m as l,n as u,o as d,p as f,r as p,s as ee,t as m,u as h,v as g}from"./errors-Cw9kKQJc.js";import{t as te}from"./worker.base-client-DGGSkczN.js";import{a as ne,c as _}from"./utils-eIBZNA_w.js";import{a as re,i as ie,n as v,o as y,r as b,t as x}from"./relayer-utils-
|
|
1
|
+
import{_ as e,a as t,c as n,d as r,f as i,g as a,h as o,i as s,l as c,m as l,n as u,o as d,p as f,r as p,s as ee,t as m,u as h,v as g}from"./errors-Cw9kKQJc.js";import{t as te}from"./worker.base-client-DGGSkczN.js";import{a as ne,c as _}from"./utils-eIBZNA_w.js";import{a as re,i as ie,n as v,o as y,r as b,t as x}from"./relayer-utils-DOcfo9ga.js";import{C as S,S as ae,_ as oe,a as se,b as ce,c as C,d as w,f as le,g as ue,h as T,i as de,l as E,m as D,n as fe,o as pe,p as me,r as he,s as ge,t as O,u as k,v as A,w as j,x as M,y as N}from"./erc165-BZgfzGxL.js";import{A as P,C as F,D as I,E as L,F as _e,I as ve,M as R,N as ye,O as be,P as xe,S as z,T as Se,_ as Ce,a as we,b as B,c as Te,d as Ee,f as De,g as V,h as Oe,i as ke,j as H,k as Ae,l as je,m as U,n as Me,o as Ne,p as Pe,r as Fe,s as Ie,t as Le,u as Re,v as W,w as G,x as ze,y as K}from"./activity-DEoxFQLE.js";import{t as Be}from"./transfer-batcher-uEcB2HJO.js";import{getAddress as q,hexToBigInt as Ve}from"viem";var He=`(function() {
|
|
2
2
|
//#region src/utils.ts
|
|
3
3
|
/** Normalize a un-prefixed hex payload to a 0x-prefixed \`Hex\` value. */
|
|
4
4
|
function prefixHex(value) {
|
package/dist/esm/node/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { A as GetPublicKeyRequest, B as SuccessResponse, C as EncryptPayload, D as GenerateKeypairRequest, E as ErrorResponse, F as NodeInitRequest, G as WorkerRequest, H as UserDecryptPayload, I as PublicDecryptRequest, K as WorkerRequestType, L as PublicDecryptResponseData, M as GetPublicParamsRequest, N as GetPublicParamsResponseData, O as GenerateKeypairResponseData, P as InitRequest, R as RequestZKProofVerificationRequest, S as DelegatedUserDecryptResponseData, T as EncryptResponseData, U as UserDecryptRequest, V as UpdateCsrfRequest, W as UserDecryptResponseData, _ as CreateEIP712Payload, a as EncryptResult, b as DelegatedUserDecryptPayload, c as PublicDecryptResult, f as UserDecryptParams, g as CreateDelegatedEIP712ResponseData, h as CreateDelegatedEIP712Request, i as EncryptParams, j as GetPublicKeyResponseData, k as GenericLogger, m as CreateDelegatedEIP712Payload, n as EIP712TypedData, o as Handle, p as BaseRequest, q as WorkerResponse, t as DelegatedUserDecryptParams, v as CreateEIP712Request, w as EncryptRequest, x as DelegatedUserDecryptRequest, y as CreateEIP712ResponseData, z as RequestZKProofVerificationResponseData } from "../relayer-sdk.types-DI4WWkTB.js";
|
|
2
2
|
import { i as GenericStorage } from "../token.types-DDdIZEax.js";
|
|
3
3
|
import { t as RelayerSDK } from "../relayer-sdk-CVVR30IW.js";
|
|
4
|
-
import { n as MainnetConfig, r as SepoliaConfig, t as HardhatConfig } from "../relayer-utils-
|
|
4
|
+
import { n as MainnetConfig, r as SepoliaConfig, t as HardhatConfig } from "../relayer-utils-Dj1FfwxT.js";
|
|
5
5
|
import { Address, Hex } from "viem";
|
|
6
6
|
import { Worker } from "node:worker_threads";
|
|
7
7
|
import { ClearValueType, FhevmInstanceConfig, InputProofBytesType, KeypairType, KmsDelegatedUserDecryptEIP712Type, ZKProofLike } from "@zama-fhe/relayer-sdk/node";
|
package/dist/esm/node/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{c as e,g as t,n}from"../errors-Cw9kKQJc.js";import{t as r}from"../worker.base-client-DGGSkczN.js";import{a as i,i as a,n as o,o as s,r as c,t as l}from"../relayer-utils-
|
|
1
|
+
import{c as e,g as t,n}from"../errors-Cw9kKQJc.js";import{t as r}from"../worker.base-client-DGGSkczN.js";import{a as i,i as a,n as o,o as s,r as c,t as l}from"../relayer-utils-DOcfo9ga.js";import{availableParallelism as u}from"node:os";import{Worker as d}from"node:worker_threads";import{randomUUID as f}from"node:crypto";import{AsyncLocalStorage as p}from"node:async_hooks";var m=class extends r{constructor(e){super(e,e.logger)}createWorker(){return new d(new URL(`relayer-sdk.node-worker.js`,import.meta.url))}wireEvents(e){e.on(`message`,e=>this.handleResponse(e)),e.on(`error`,e=>this.handleWorkerError(e.message)),e.on(`messageerror`,()=>this.handleWorkerMessageError())}postMessage(e,t){e.postMessage(t)}terminateWorker(e){e.terminate()}generateRequestId(){return f()}getInitPayload(){return{type:`NODE_INIT`,payload:{fhevmConfig:this.config.fhevmConfig}}}onWorkerReady(e){e.unref()}},h=class{#e=[];#t=[];#n;#r;#i=null;constructor(e){this.#n=e,this.#r=e.poolSize??Math.min(u(),4)}get poolSize(){return this.#r}async initPool(){if(!(this.#e.length>0))return this.#i||=this.#a().finally(()=>{this.#i=null}),this.#i}async#a(){for(let e=0;e<this.#r;e++)this.#e.push(new m(this.#n)),this.#t.push(0);try{await Promise.all(this.#e.map(e=>e.initWorker()))}catch(e){for(let e of this.#e)e.terminate();throw this.#e.length=0,this.#t.length=0,e}}terminate(){for(let e of this.#e)e.terminate();this.#e.length=0,this.#t.length=0}#o(){let e=0,t=this.#t[0];for(let n=1;n<this.#t.length;n++)this.#t[n]<t&&(t=this.#t[n],e=n);return e}async#s(e){if(this.#e.length===0)throw Error(`NodeWorkerPool not initialized. Call initPool() first.`);let t=this.#o();this.#t[t]++;try{return await e(this.#e[t])}finally{this.#t[t]--}}async generateKeypair(){return this.#s(e=>e.generateKeypair())}async createEIP712(e){return this.#s(t=>t.createEIP712(e))}async encrypt(e){return this.#s(t=>t.encrypt(e))}async userDecrypt(e){return this.#s(t=>t.userDecrypt(e))}async publicDecrypt(e){return this.#s(t=>t.publicDecrypt(e))}async createDelegatedUserDecryptEIP712(e){return this.#s(t=>t.createDelegatedUserDecryptEIP712(e))}async delegatedUserDecrypt(e){return this.#s(t=>t.delegatedUserDecrypt(e))}async requestZKProofVerification(e){return this.#s(t=>t.requestZKProofVerification(e))}async getPublicKey(){return this.#s(e=>e.getPublicKey())}async getPublicParams(e){return this.#s(t=>t.getPublicParams(e))}},g=class{#e;#t=null;#n=null;#r=null;#i=!1;#a=null;constructor(e){this.#e=e}async#o(){let e=await this.#e.getChainId(),{transports:t,poolSize:n}=this.#e;return{fhevmConfig:Object.assign({},l[e],t[e]),poolSize:n,logger:this.#e.logger}}async#s(){if(this.#r)return this.#r;this.#r=this.#c();try{return await this.#r}finally{this.#r=null}}async#c(){if(this.#i)throw new e(`RelayerNode has been terminated`);let n=await this.#e.getChainId();return this.#a!==null&&n!==this.#a&&(this.#t?.terminate(),this.#t=null,this.#n=null),this.#a=n,this.#n||=this.#l().catch(n=>{throw this.#n=null,n instanceof t?n:new e(`Failed to initialize FHE worker pool`,{cause:n instanceof Error?n:void 0})}),this.#n}async#l(){let e=new h(await this.#o());if(await e.initPool(),this.#i)throw e.terminate(),Error(`RelayerNode was terminated during initialization`);return this.#t=e,e}terminate(){this.#i=!0,this.#t&&=(this.#t.terminate(),null),this.#n=null,this.#r=null}async generateKeypair(){let e=await(await this.#s()).generateKeypair();return{publicKey:e.publicKey,privateKey:e.privateKey}}async createEIP712(e,t,n,r=7){let a=await(await this.#s()).createEIP712({publicKey:e,contractAddresses:t,startTimestamp:n,durationDays:r}),o={name:a.domain.name,version:a.domain.version,chainId:a.domain.chainId,verifyingContract:a.domain.verifyingContract};return{domain:o,types:{EIP712Domain:i(o),UserDecryptRequestVerification:a.types.UserDecryptRequestVerification},message:{publicKey:a.message.publicKey,contractAddresses:a.message.contractAddresses,startTimestamp:a.message.startTimestamp,durationDays:a.message.durationDays,extraData:a.message.extraData}}}async encrypt(e){return s(async()=>{let t=await(await this.#s()).encrypt(e);return{handles:t.handles,inputProof:t.inputProof}})}async userDecrypt(e){return s(async()=>(await(await this.#s()).userDecrypt(e)).clearValues)}async publicDecrypt(e){return s(async()=>{let t=await(await this.#s()).publicDecrypt(e);return{clearValues:t.clearValues,abiEncodedClearValues:t.abiEncodedClearValues,decryptionProof:t.decryptionProof}})}async createDelegatedUserDecryptEIP712(e,t,n,r,i=7){return(await this.#s()).createDelegatedUserDecryptEIP712({publicKey:e,contractAddresses:t,delegatorAddress:n,startTimestamp:r,durationDays:i})}async delegatedUserDecrypt(e){return s(async()=>(await(await this.#s()).delegatedUserDecrypt(e)).clearValues)}async requestZKProofVerification(e){return s(async()=>(await this.#s()).requestZKProofVerification(e))}async getPublicKey(){return(await(await this.#s()).getPublicKey()).result}async getPublicParams(e){return(await(await this.#s()).getPublicParams(e)).result}async getAclAddress(){let e=await this.#e.getChainId(),t=Object.assign({},l[e],this.#e.transports[e]);if(!t.aclContractAddress)throw new n(`No ACL address configured for chain ${e}`);return t.aclContractAddress}},_=class{#e=new p;run(e){return this.#e.run(new Map,e)}async get(e){return this.#e.getStore()?.get(e)??null}async set(e,t){this.#e.getStore()?.set(e,t)}async delete(e){this.#e.getStore()?.delete(e)}};const v=new _;export{_ as AsyncLocalMapStorage,r as BaseWorkerClient,o as HardhatConfig,c as MainnetConfig,m as NodeWorkerClient,h as NodeWorkerPool,g as RelayerNode,a as SepoliaConfig,v as asyncLocalStorage};
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
async function e(e,r=2){let i;for(let a=0;a<=r;a++)try{return await e()}catch(e){if(i=e,a<r&&t(e)){await n(500*2**a);continue}throw e}throw i}function t(e){if(!(e instanceof Error))return!1;let t=e.message.toLowerCase();return t.includes(`timed out`)||t.includes(`timeout`)||t.includes(`econnreset`)||t.includes(`econnrefused`)||t.includes(`network`)||t.includes(`fetch failed`)||t.includes(`socket hang up`)||t.includes(`502`)||t.includes(`503`)||t.includes(`504`)}function n(e){return new Promise(t=>setTimeout(t,e))}const r={chainId:1,gatewayChainId:261131,relayerUrl:`https://relayer.mainnet.zama.org/v2`,network:`https://ethereum-rpc.publicnode.com`,aclContractAddress:`0xcA2E8f1F656CD25C01F05d0b243Ab1ecd4a8ffb6`,kmsContractAddress:`0x77627828a55156b04Ac0DC0eb30467f1a552BB03`,inputVerifierContractAddress:`0xCe0FC2e05CFff1B719EFF7169f7D80Af770c8EA2`,verifyingContractAddressDecryption:`0x0f6024a97684f7d90ddb0fAAD79cB15F2C888D24`,verifyingContractAddressInputVerification:`0xcB1bB072f38bdAF0F328CdEf1Fc6eDa1DF029287`},i={chainId:11155111,gatewayChainId:10901,relayerUrl:`https://relayer.testnet.zama.org/v2`,network:`https://ethereum-sepolia-rpc.publicnode.com`,aclContractAddress:`0xf0Ffdc93b7E186bC2f8CB3dAA75D86d1930A433D`,kmsContractAddress:`0xbE0E383937d564D7FF0BC3b46c51f0bF8d5C311A`,inputVerifierContractAddress:`0xBBC1fFCdc7C316aAAd72E807D9b0272BE8F84DA0`,verifyingContractAddressDecryption:`0x5D8BD78e2ea6bbE41f26dFe9fdaEAa349e077478`,verifyingContractAddressInputVerification:`0x483b9dE06E4E4C7D35CCf5837A1668487406D955`},a={chainId:31337,gatewayChainId:10901,relayerUrl:``,network:`http://127.0.0.1:8545`,aclContractAddress:`0x50157CFfD6bBFA2DECe204a89ec419c23ef5755D`,inputVerifierContractAddress:`0x36772142b74871f255CbD7A3e89B401d3e45825f`,kmsContractAddress:`
|
|
2
|
-
//# sourceMappingURL=relayer-utils-
|
|
1
|
+
async function e(e,r=2){let i;for(let a=0;a<=r;a++)try{return await e()}catch(e){if(i=e,a<r&&t(e)){await n(500*2**a);continue}throw e}throw i}function t(e){if(!(e instanceof Error))return!1;let t=e.message.toLowerCase();return t.includes(`timed out`)||t.includes(`timeout`)||t.includes(`econnreset`)||t.includes(`econnrefused`)||t.includes(`network`)||t.includes(`fetch failed`)||t.includes(`socket hang up`)||t.includes(`502`)||t.includes(`503`)||t.includes(`504`)}function n(e){return new Promise(t=>setTimeout(t,e))}const r={chainId:1,gatewayChainId:261131,relayerUrl:`https://relayer.mainnet.zama.org/v2`,network:`https://ethereum-rpc.publicnode.com`,aclContractAddress:`0xcA2E8f1F656CD25C01F05d0b243Ab1ecd4a8ffb6`,kmsContractAddress:`0x77627828a55156b04Ac0DC0eb30467f1a552BB03`,inputVerifierContractAddress:`0xCe0FC2e05CFff1B719EFF7169f7D80Af770c8EA2`,verifyingContractAddressDecryption:`0x0f6024a97684f7d90ddb0fAAD79cB15F2C888D24`,verifyingContractAddressInputVerification:`0xcB1bB072f38bdAF0F328CdEf1Fc6eDa1DF029287`},i={chainId:11155111,gatewayChainId:10901,relayerUrl:`https://relayer.testnet.zama.org/v2`,network:`https://ethereum-sepolia-rpc.publicnode.com`,aclContractAddress:`0xf0Ffdc93b7E186bC2f8CB3dAA75D86d1930A433D`,kmsContractAddress:`0xbE0E383937d564D7FF0BC3b46c51f0bF8d5C311A`,inputVerifierContractAddress:`0xBBC1fFCdc7C316aAAd72E807D9b0272BE8F84DA0`,verifyingContractAddressDecryption:`0x5D8BD78e2ea6bbE41f26dFe9fdaEAa349e077478`,verifyingContractAddressInputVerification:`0x483b9dE06E4E4C7D35CCf5837A1668487406D955`},a={chainId:31337,gatewayChainId:10901,relayerUrl:``,network:`http://127.0.0.1:8545`,aclContractAddress:`0x50157CFfD6bBFA2DECe204a89ec419c23ef5755D`,inputVerifierContractAddress:`0x36772142b74871f255CbD7A3e89B401d3e45825f`,kmsContractAddress:`0x901F8942346f7AB3a01F6D7613119Bca447Bb030`,verifyingContractAddressDecryption:`0x5ffdaAB0373E62E2ea2944776209aEf29E631A64`,verifyingContractAddressInputVerification:`0x812b06e1CDCE800494b79fFE4f925A504a9A9810`},o={1:r,11155111:i,31337:a},s={name:`string`,version:`string`,chainId:`uint256`,verifyingContract:`address`,salt:`bytes32`};function c(e){return Object.keys(s).filter(t=>t in e).map(e=>({name:e,type:s[e]}))}export{c as a,i,a as n,e as o,r,o as t};
|
|
2
|
+
//# sourceMappingURL=relayer-utils-DOcfo9ga.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"relayer-utils-
|
|
1
|
+
{"version":3,"file":"relayer-utils-DOcfo9ga.js","names":[],"sources":["../../src/relayer/relayer-utils.ts"],"sourcesContent":["import type { EIP712TypedData } from \"./relayer-sdk.types\";\nimport type { FhevmInstanceConfig } from \"@zama-fhe/relayer-sdk/bundle\";\n\nconst MAX_RETRIES = 2;\nconst RETRY_BASE_MS = 500;\n\n/**\n * Retry an async operation with exponential backoff.\n * Only retries on transient errors (timeout, network). Does not retry user-facing errors.\n */\nexport async function withRetry<T>(fn: () => Promise<T>, retries = MAX_RETRIES): Promise<T> {\n let lastError: unknown;\n for (let attempt = 0; attempt <= retries; attempt++) {\n try {\n return await fn();\n } catch (error) {\n lastError = error;\n if (attempt < retries && isTransientError(error)) {\n await sleep(RETRY_BASE_MS * 2 ** attempt);\n continue;\n }\n throw error;\n }\n }\n throw lastError;\n}\n\nfunction isTransientError(error: unknown): boolean {\n if (!(error instanceof Error)) {\n return false;\n }\n const msg = error.message.toLowerCase();\n return (\n msg.includes(\"timed out\") ||\n msg.includes(\"timeout\") ||\n msg.includes(\"econnreset\") ||\n msg.includes(\"econnrefused\") ||\n msg.includes(\"network\") ||\n msg.includes(\"fetch failed\") ||\n msg.includes(\"socket hang up\") ||\n msg.includes(\"502\") ||\n msg.includes(\"503\") ||\n msg.includes(\"504\")\n );\n}\n\nfunction sleep(ms: number): Promise<void> {\n return new Promise((resolve) => setTimeout(resolve, ms));\n}\n\n/**\n * Mainnet network configuration (chainId 1).\n *\n * Contract addresses mirror `MainnetConfigV2` from `@zama-fhe/relayer-sdk`.\n * They are duplicated here because the `/bundle` export path only exposes\n * types at build time (runtime values require `/web` or `/node` which pull\n * in WASM). `satisfies FhevmInstanceConfig` ensures structural drift is\n * caught at compile time.\n */\nexport const MainnetConfig = {\n chainId: 1,\n gatewayChainId: 261131,\n relayerUrl: \"https://relayer.mainnet.zama.org/v2\",\n network: \"https://ethereum-rpc.publicnode.com\",\n aclContractAddress: \"0xcA2E8f1F656CD25C01F05d0b243Ab1ecd4a8ffb6\",\n kmsContractAddress: \"0x77627828a55156b04Ac0DC0eb30467f1a552BB03\",\n inputVerifierContractAddress: \"0xCe0FC2e05CFff1B719EFF7169f7D80Af770c8EA2\",\n verifyingContractAddressDecryption: \"0x0f6024a97684f7d90ddb0fAAD79cB15F2C888D24\",\n verifyingContractAddressInputVerification: \"0xcB1bB072f38bdAF0F328CdEf1Fc6eDa1DF029287\",\n} as const satisfies FhevmInstanceConfig;\n\n/**\n * Sepolia testnet network configuration (chainId 11155111).\n * See {@link MainnetConfig} for why addresses are hardcoded.\n */\nexport const SepoliaConfig = {\n chainId: 11155111,\n gatewayChainId: 10901,\n relayerUrl: \"https://relayer.testnet.zama.org/v2\",\n network: \"https://ethereum-sepolia-rpc.publicnode.com\",\n aclContractAddress: \"0xf0Ffdc93b7E186bC2f8CB3dAA75D86d1930A433D\",\n kmsContractAddress: \"0xbE0E383937d564D7FF0BC3b46c51f0bF8d5C311A\",\n inputVerifierContractAddress: \"0xBBC1fFCdc7C316aAAd72E807D9b0272BE8F84DA0\",\n verifyingContractAddressDecryption: \"0x5D8BD78e2ea6bbE41f26dFe9fdaEAa349e077478\",\n verifyingContractAddressInputVerification: \"0x483b9dE06E4E4C7D35CCf5837A1668487406D955\",\n} as const satisfies FhevmInstanceConfig;\n\n/**\n * Hardhat local network configuration (chainId 31337).\n *\n * The addresses in this configuration must match those of your deployment.\n * Ensure that the executor address and other contract addresses correspond to\n * the contracts deployed on your Hardhat network.\n */\nexport const HardhatConfig = {\n chainId: 31337,\n gatewayChainId: 10901,\n relayerUrl: \"\",\n network: \"http://127.0.0.1:8545\",\n aclContractAddress: \"0x50157CFfD6bBFA2DECe204a89ec419c23ef5755D\",\n inputVerifierContractAddress: \"0x36772142b74871f255CbD7A3e89B401d3e45825f\",\n kmsContractAddress: \"0x901F8942346f7AB3a01F6D7613119Bca447Bb030\",\n verifyingContractAddressDecryption: \"0x5ffdaAB0373E62E2ea2944776209aEf29E631A64\",\n verifyingContractAddressInputVerification: \"0x812b06e1CDCE800494b79fFE4f925A504a9A9810\",\n} as const satisfies FhevmInstanceConfig;\n\nexport const DefaultConfigs: Record<number, FhevmInstanceConfig> = {\n 1: MainnetConfig,\n 11155111: SepoliaConfig,\n 31337: HardhatConfig,\n} as const;\n\n/** EIP-712 domain field → Solidity type. Order follows the EIP-712 spec. */\nconst DOMAIN_FIELD_TYPES: Record<string, string> = {\n name: \"string\",\n version: \"string\",\n chainId: \"uint256\",\n verifyingContract: \"address\",\n salt: \"bytes32\",\n};\n\n/**\n * Build `EIP712Domain` type entries from the keys present in a domain object.\n * Order matches the EIP-712 spec (name → version → chainId → verifyingContract → salt).\n */\nexport function buildEIP712DomainType(\n domain: EIP712TypedData[\"domain\"],\n): { name: string; type: string }[] {\n return Object.keys(DOMAIN_FIELD_TYPES)\n .filter((k) => k in domain)\n .map((k) => ({ name: k, type: DOMAIN_FIELD_TYPES[k]! }));\n}\n"],"mappings":"AAUA,eAAsB,EAAa,EAAsB,EAAU,EAAyB,CAC1F,IAAI,EACJ,IAAK,IAAI,EAAU,EAAG,GAAW,EAAS,IACxC,GAAI,CACF,OAAO,MAAM,GAAI,OACV,EAAO,CAEd,GADA,EAAY,EACR,EAAU,GAAW,EAAiB,EAAM,CAAE,CAChD,MAAM,EAAM,IAAgB,GAAK,EAAQ,CACzC,SAEF,MAAM,EAGV,MAAM,EAGR,SAAS,EAAiB,EAAyB,CACjD,GAAI,EAAE,aAAiB,OACrB,MAAO,GAET,IAAM,EAAM,EAAM,QAAQ,aAAa,CACvC,OACE,EAAI,SAAS,YAAY,EACzB,EAAI,SAAS,UAAU,EACvB,EAAI,SAAS,aAAa,EAC1B,EAAI,SAAS,eAAe,EAC5B,EAAI,SAAS,UAAU,EACvB,EAAI,SAAS,eAAe,EAC5B,EAAI,SAAS,iBAAiB,EAC9B,EAAI,SAAS,MAAM,EACnB,EAAI,SAAS,MAAM,EACnB,EAAI,SAAS,MAAM,CAIvB,SAAS,EAAM,EAA2B,CACxC,OAAO,IAAI,QAAS,GAAY,WAAW,EAAS,EAAG,CAAC,CAY1D,MAAa,EAAgB,CAC3B,QAAS,EACT,eAAgB,OAChB,WAAY,sCACZ,QAAS,sCACT,mBAAoB,6CACpB,mBAAoB,6CACpB,6BAA8B,6CAC9B,mCAAoC,6CACpC,0CAA2C,6CAC5C,CAMY,EAAgB,CAC3B,QAAS,SACT,eAAgB,MAChB,WAAY,sCACZ,QAAS,8CACT,mBAAoB,6CACpB,mBAAoB,6CACpB,6BAA8B,6CAC9B,mCAAoC,6CACpC,0CAA2C,6CAC5C,CASY,EAAgB,CAC3B,QAAS,MACT,eAAgB,MAChB,WAAY,GACZ,QAAS,wBACT,mBAAoB,6CACpB,6BAA8B,6CAC9B,mBAAoB,6CACpB,mCAAoC,6CACpC,0CAA2C,6CAC5C,CAEY,EAAsD,CACjE,EAAG,EACH,SAAU,EACV,MAAO,EACR,CAGK,EAA6C,CACjD,KAAM,SACN,QAAS,SACT,QAAS,UACT,kBAAmB,UACnB,KAAM,UACP,CAMD,SAAgB,EACd,EACkC,CAClC,OAAO,OAAO,KAAK,EAAmB,CACnC,OAAQ,GAAM,KAAK,EAAO,CAC1B,IAAK,IAAO,CAAE,KAAM,EAAG,KAAM,EAAmB,GAAK,EAAE"}
|
|
@@ -50,10 +50,10 @@ declare const HardhatConfig: {
|
|
|
50
50
|
readonly network: "http://127.0.0.1:8545";
|
|
51
51
|
readonly aclContractAddress: "0x50157CFfD6bBFA2DECe204a89ec419c23ef5755D";
|
|
52
52
|
readonly inputVerifierContractAddress: "0x36772142b74871f255CbD7A3e89B401d3e45825f";
|
|
53
|
-
readonly kmsContractAddress: "
|
|
53
|
+
readonly kmsContractAddress: "0x901F8942346f7AB3a01F6D7613119Bca447Bb030";
|
|
54
54
|
readonly verifyingContractAddressDecryption: "0x5ffdaAB0373E62E2ea2944776209aEf29E631A64";
|
|
55
55
|
readonly verifyingContractAddressInputVerification: "0x812b06e1CDCE800494b79fFE4f925A504a9A9810";
|
|
56
56
|
};
|
|
57
57
|
//#endregion
|
|
58
58
|
export { MainnetConfig as n, SepoliaConfig as r, HardhatConfig as t };
|
|
59
|
-
//# sourceMappingURL=relayer-utils-
|
|
59
|
+
//# sourceMappingURL=relayer-utils-Dj1FfwxT.d.ts.map
|