@lifi/sdk-provider-ethereum 4.0.3 → 4.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (67) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/cjs/actions/getAllowance.js +4 -2
  3. package/dist/cjs/actions/getAllowance.js.map +1 -1
  4. package/dist/cjs/client/publicClient.js +2 -1
  5. package/dist/cjs/client/publicClient.js.map +1 -1
  6. package/dist/cjs/core/tasks/EthereumCheckPermitsTask.js +2 -0
  7. package/dist/cjs/core/tasks/EthereumCheckPermitsTask.js.map +1 -1
  8. package/dist/cjs/core/tasks/EthereumNativePermitTask.js +5 -0
  9. package/dist/cjs/core/tasks/EthereumNativePermitTask.js.map +1 -1
  10. package/dist/cjs/core/tasks/EthereumRelayedSignAndExecuteTask.js +2 -0
  11. package/dist/cjs/core/tasks/EthereumRelayedSignAndExecuteTask.js.map +1 -1
  12. package/dist/cjs/core/tasks/EthereumStandardSignAndExecuteTask.js +2 -1
  13. package/dist/cjs/core/tasks/EthereumStandardSignAndExecuteTask.js.map +1 -1
  14. package/dist/cjs/core/tasks/helpers/signHyperliquidTypedData.js +3 -0
  15. package/dist/cjs/core/tasks/helpers/signHyperliquidTypedData.js.map +1 -1
  16. package/dist/cjs/permits/isNativePermitValid.js +2 -0
  17. package/dist/cjs/permits/isNativePermitValid.js.map +1 -1
  18. package/dist/cjs/permits/signPermit2Message.js +2 -0
  19. package/dist/cjs/permits/signPermit2Message.js.map +1 -1
  20. package/dist/cjs/utils/isValidSignature.d.ts +15 -0
  21. package/dist/cjs/utils/isValidSignature.js +22 -0
  22. package/dist/cjs/utils/isValidSignature.js.map +1 -0
  23. package/dist/cjs/version.d.ts +1 -1
  24. package/dist/cjs/version.js +1 -1
  25. package/dist/cjs/version.js.map +1 -1
  26. package/dist/esm/actions/getAllowance.js +4 -2
  27. package/dist/esm/actions/getAllowance.js.map +1 -1
  28. package/dist/esm/client/publicClient.js +2 -1
  29. package/dist/esm/client/publicClient.js.map +1 -1
  30. package/dist/esm/core/tasks/EthereumCheckPermitsTask.d.ts.map +1 -1
  31. package/dist/esm/core/tasks/EthereumCheckPermitsTask.js +2 -0
  32. package/dist/esm/core/tasks/EthereumCheckPermitsTask.js.map +1 -1
  33. package/dist/esm/core/tasks/EthereumNativePermitTask.d.ts.map +1 -1
  34. package/dist/esm/core/tasks/EthereumNativePermitTask.js +5 -0
  35. package/dist/esm/core/tasks/EthereumNativePermitTask.js.map +1 -1
  36. package/dist/esm/core/tasks/EthereumRelayedSignAndExecuteTask.d.ts.map +1 -1
  37. package/dist/esm/core/tasks/EthereumRelayedSignAndExecuteTask.js +2 -0
  38. package/dist/esm/core/tasks/EthereumRelayedSignAndExecuteTask.js.map +1 -1
  39. package/dist/esm/core/tasks/EthereumStandardSignAndExecuteTask.d.ts.map +1 -1
  40. package/dist/esm/core/tasks/EthereumStandardSignAndExecuteTask.js +2 -1
  41. package/dist/esm/core/tasks/EthereumStandardSignAndExecuteTask.js.map +1 -1
  42. package/dist/esm/core/tasks/helpers/signHyperliquidTypedData.d.ts.map +1 -1
  43. package/dist/esm/core/tasks/helpers/signHyperliquidTypedData.js +3 -0
  44. package/dist/esm/core/tasks/helpers/signHyperliquidTypedData.js.map +1 -1
  45. package/dist/esm/permits/isNativePermitValid.d.ts.map +1 -1
  46. package/dist/esm/permits/isNativePermitValid.js +2 -0
  47. package/dist/esm/permits/isNativePermitValid.js.map +1 -1
  48. package/dist/esm/permits/signPermit2Message.d.ts.map +1 -1
  49. package/dist/esm/permits/signPermit2Message.js +2 -0
  50. package/dist/esm/permits/signPermit2Message.js.map +1 -1
  51. package/dist/esm/utils/isValidSignature.d.ts +15 -0
  52. package/dist/esm/utils/isValidSignature.d.ts.map +1 -0
  53. package/dist/esm/utils/isValidSignature.js +20 -0
  54. package/dist/esm/utils/isValidSignature.js.map +1 -0
  55. package/dist/esm/version.d.ts +1 -1
  56. package/dist/esm/version.js +1 -1
  57. package/dist/esm/version.js.map +1 -1
  58. package/package.json +2 -2
  59. package/src/core/tasks/EthereumCheckPermitsTask.ts +2 -0
  60. package/src/core/tasks/EthereumNativePermitTask.ts +9 -0
  61. package/src/core/tasks/EthereumRelayedSignAndExecuteTask.ts +3 -0
  62. package/src/core/tasks/EthereumStandardSignAndExecuteTask.ts +3 -1
  63. package/src/core/tasks/helpers/signHyperliquidTypedData.ts +3 -0
  64. package/src/permits/isNativePermitValid.ts +6 -0
  65. package/src/permits/signPermit2Message.ts +3 -0
  66. package/src/utils/isValidSignature.ts +26 -0
  67. package/src/version.ts +1 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @lifi/sdk-provider-ethereum
2
2
 
3
+ ## 4.0.5
4
+
5
+ ### Patch Changes
6
+
7
+ - [#425](https://github.com/lifinance/sdk/pull/425) [`7ebebde`](https://github.com/lifinance/sdk/commit/7ebebde35415024f9966123556b882fdb2d7b1bc) Thanks [@chybisov](https://github.com/chybisov)! - Handle wallets that resolve `signTypedData` with a nullish or empty signature instead of rejecting ([#424](https://github.com/lifinance/sdk/issues/424)). The EIP-2612 native permit flow now falls back to the Permit2/standard approval path instead of crashing later with `TypeError: Cannot read properties of null (reading 'slice')`, and the other signing flows (API permits, relayed intents, Permit2 messages) throw a descriptive `SignatureRejected` error. Permit lookups also ignore stored entries without a usable signature.
8
+
9
+ ## 4.0.4
10
+
11
+ ### Patch Changes
12
+
13
+ - [#422](https://github.com/lifinance/sdk/pull/422) [`e7f2f97`](https://github.com/lifinance/sdk/commit/e7f2f975031cd43f3e39c03dd6bb16b661d4bf0b) Thanks [@chybisov](https://github.com/chybisov)! - Bump runtime dependencies: viem to 2.54.6 and @solana/kit to 7.0.0.
14
+
3
15
  ## 4.0.3
4
16
 
5
17
  ### Patch Changes
@@ -48,7 +48,8 @@ const getAllowanceMulticall = async (client, viemClient, chainId, tokens, ownerA
48
48
  */
49
49
  const getTokenAllowance = async (client, token, ownerAddress, spenderAddress) => {
50
50
  if (require_utils_isZeroAddress.isZeroAddress(token.address)) return;
51
- return await getAllowance(client, await require_client_publicClient.getPublicClient(client, token.chainId), token.address, ownerAddress, spenderAddress);
51
+ const viemClient = await require_client_publicClient.getPublicClient(client, token.chainId);
52
+ return await getAllowance(client, viemClient, token.address, ownerAddress, spenderAddress);
52
53
  };
53
54
  /**
54
55
  * Get the current allowance for a list of token/spender address pairs.
@@ -66,7 +67,8 @@ const getTokenAllowanceMulticall = async (client, ownerAddress, tokens) => {
66
67
  }
67
68
  const chainKeys = Object.keys(tokenDataByChain).map(Number.parseInt);
68
69
  return (await Promise.all(chainKeys.map(async (chainId) => {
69
- return getAllowanceMulticall(client, await require_client_publicClient.getPublicClient(client, chainId), chainId, tokenDataByChain[chainId], ownerAddress);
70
+ const viemClient = await require_client_publicClient.getPublicClient(client, chainId);
71
+ return getAllowanceMulticall(client, viemClient, chainId, tokenDataByChain[chainId], ownerAddress);
70
72
  }))).flat();
71
73
  };
72
74
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"getAllowance.js","names":["getActionWithFallback","readContract","allowanceAbi","getMulticallAddress","multicall","isZeroAddress","getPublicClient"],"sources":["../../../src/actions/getAllowance.ts"],"sourcesContent":["import type { BaseToken, ChainId, SDKClient } from '@lifi/sdk'\nimport type { Address, Client } from 'viem'\nimport { multicall, readContract } from 'viem/actions'\nimport { getPublicClient } from '../client/publicClient.js'\nimport type {\n TokenAllowance,\n TokenSpender,\n TokenSpenderAllowance,\n} from '../types.js'\nimport { allowanceAbi } from '../utils/abi.js'\nimport { getActionWithFallback } from '../utils/getActionWithFallback.js'\nimport { isZeroAddress } from '../utils/isZeroAddress.js'\nimport { getMulticallAddress } from './getMulticallAddress.js'\n\nexport const getAllowance = async (\n client: SDKClient,\n viemClient: Client,\n tokenAddress: Address,\n ownerAddress: Address,\n spenderAddress: Address\n): Promise<bigint> => {\n try {\n const approved = await getActionWithFallback(\n client,\n viemClient,\n readContract,\n 'readContract',\n {\n address: tokenAddress as Address,\n abi: allowanceAbi,\n functionName: 'allowance' as const,\n args: [ownerAddress, spenderAddress] as const,\n }\n )\n return approved as bigint\n } catch (_e) {\n return 0n\n }\n}\n\nexport const getAllowanceMulticall = async (\n client: SDKClient,\n viemClient: Client,\n chainId: ChainId,\n tokens: TokenSpender[],\n ownerAddress: Address\n): Promise<TokenSpenderAllowance[]> => {\n if (!tokens.length) {\n return []\n }\n const multicallAddress = await getMulticallAddress(client, chainId)\n if (!multicallAddress) {\n throw new Error(`No multicall address configured for chainId ${chainId}.`)\n }\n const contracts = tokens.map((token) => ({\n address: token.token.address as Address,\n abi: allowanceAbi,\n functionName: 'allowance',\n args: [ownerAddress, token.spenderAddress],\n }))\n\n const results = await getActionWithFallback(\n client,\n viemClient,\n multicall,\n 'multicall',\n {\n contracts,\n multicallAddress: multicallAddress as Address,\n }\n )\n\n if (!results.length) {\n throw new Error(\n `Couldn't load allowance from chainId ${chainId} using multicall.`\n )\n }\n\n return tokens.map(({ token, spenderAddress }, i: number) => ({\n token,\n spenderAddress,\n allowance: results[i].result as bigint,\n }))\n}\n\n/**\n * Get the current allowance for a certain token.\n * @param client - The SDK client\n * @param token - The token that should be checked\n * @param ownerAddress - The owner of the token\n * @param spenderAddress - The spender address that has to be approved\n * @returns Returns allowance\n */\nexport const getTokenAllowance = async (\n client: SDKClient,\n token: BaseToken,\n ownerAddress: Address,\n spenderAddress: Address\n): Promise<bigint | undefined> => {\n // native token don't need approval\n if (isZeroAddress(token.address)) {\n return\n }\n\n const viemClient = await getPublicClient(client, token.chainId)\n\n const approved = await getAllowance(\n client,\n viemClient,\n token.address as Address,\n ownerAddress,\n spenderAddress\n )\n return approved\n}\n\n/**\n * Get the current allowance for a list of token/spender address pairs.\n * @param client - The SDK client\n * @param ownerAddress - The owner of the tokens\n * @param tokens - A list of token and spender address pairs\n * @returns Returns array of tokens and their allowance\n */\nexport const getTokenAllowanceMulticall = async (\n client: SDKClient,\n ownerAddress: Address,\n tokens: TokenSpender[]\n): Promise<TokenAllowance[]> => {\n // filter out native tokens\n const filteredTokens = tokens.filter(\n ({ token }) => !isZeroAddress(token.address)\n )\n\n // group by chain\n const tokenDataByChain: { [chainId: number]: TokenSpender[] } = {}\n for (const data of filteredTokens) {\n if (!tokenDataByChain[data.token.chainId]) {\n tokenDataByChain[data.token.chainId] = []\n }\n tokenDataByChain[data.token.chainId].push(data)\n }\n\n const chainKeys = Object.keys(tokenDataByChain).map(Number.parseInt)\n\n const allowances = (\n await Promise.all(\n chainKeys.map(async (chainId) => {\n const viemClient = await getPublicClient(client, chainId)\n // get allowances for current chain and token list\n return getAllowanceMulticall(\n client,\n viemClient,\n chainId,\n tokenDataByChain[chainId],\n ownerAddress\n )\n })\n )\n ).flat()\n\n return allowances\n}\n"],"mappings":";;;;;;;;AAcA,MAAa,eAAe,OAC1B,QACA,YACA,cACA,cACA,mBACoB;CACpB,IAAI;EAaF,OAAO,MAZgBA,oCAAAA,sBACrB,QACA,YACAC,aAAAA,cACA,gBACA;GACE,SAAS;GACT,KAAKC,kBAAAA;GACL,cAAc;GACd,MAAM,CAAC,cAAc,cAAc;EACrC,CACF;CAEF,SAAS,IAAI;EACX,OAAO;CACT;AACF;AAEA,MAAa,wBAAwB,OACnC,QACA,YACA,SACA,QACA,iBACqC;CACrC,IAAI,CAAC,OAAO,QACV,OAAO,CAAC;CAEV,MAAM,mBAAmB,MAAMC,oCAAAA,oBAAoB,QAAQ,OAAO;CAClE,IAAI,CAAC,kBACH,MAAM,IAAI,MAAM,+CAA+C,QAAQ,EAAE;CAS3E,MAAM,UAAU,MAAMH,oCAAAA,sBACpB,QACA,YACAI,aAAAA,WACA,aACA;EACE,WAbc,OAAO,KAAK,WAAW;GACvC,SAAS,MAAM,MAAM;GACrB,KAAKF,kBAAAA;GACL,cAAc;GACd,MAAM,CAAC,cAAc,MAAM,cAAc;EAC3C,EAQY;EACU;CACpB,CACF;CAEA,IAAI,CAAC,QAAQ,QACX,MAAM,IAAI,MACR,wCAAwC,QAAQ,kBAClD;CAGF,OAAO,OAAO,KAAK,EAAE,OAAO,kBAAkB,OAAe;EAC3D;EACA;EACA,WAAW,QAAQ,EAAE,CAAC;CACxB,EAAE;AACJ;;;;;;;;;AAUA,MAAa,oBAAoB,OAC/B,QACA,OACA,cACA,mBACgC;CAEhC,IAAIG,4BAAAA,cAAc,MAAM,OAAO,GAC7B;CAYF,OAAO,MAPgB,aACrB,QACA,MAJuBC,4BAAAA,gBAAgB,QAAQ,MAAM,OAAO,GAK5D,MAAM,SACN,cACA,cACF;AAEF;;;;;;;;AASA,MAAa,6BAA6B,OACxC,QACA,cACA,WAC8B;CAE9B,MAAM,iBAAiB,OAAO,QAC3B,EAAE,YAAY,CAACD,4BAAAA,cAAc,MAAM,OAAO,CAC7C;CAGA,MAAM,mBAA0D,CAAC;CACjE,KAAK,MAAM,QAAQ,gBAAgB;EACjC,IAAI,CAAC,iBAAiB,KAAK,MAAM,UAC/B,iBAAiB,KAAK,MAAM,WAAW,CAAC;EAE1C,iBAAiB,KAAK,MAAM,QAAQ,CAAC,KAAK,IAAI;CAChD;CAEA,MAAM,YAAY,OAAO,KAAK,gBAAgB,CAAC,CAAC,IAAI,OAAO,QAAQ;CAkBnE,QAfE,MAAM,QAAQ,IACZ,UAAU,IAAI,OAAO,YAAY;EAG/B,OAAO,sBACL,QACA,MAJuBC,4BAAAA,gBAAgB,QAAQ,OAAO,GAKtD,SACA,iBAAiB,UACjB,YACF;CACF,CAAC,CACH,EAAA,CACA,KAEc;AAClB"}
1
+ {"version":3,"file":"getAllowance.js","names":["getActionWithFallback","readContract","allowanceAbi","getMulticallAddress","multicall","isZeroAddress","getPublicClient"],"sources":["../../../src/actions/getAllowance.ts"],"sourcesContent":["import type { BaseToken, ChainId, SDKClient } from '@lifi/sdk'\nimport type { Address, Client } from 'viem'\nimport { multicall, readContract } from 'viem/actions'\nimport { getPublicClient } from '../client/publicClient.js'\nimport type {\n TokenAllowance,\n TokenSpender,\n TokenSpenderAllowance,\n} from '../types.js'\nimport { allowanceAbi } from '../utils/abi.js'\nimport { getActionWithFallback } from '../utils/getActionWithFallback.js'\nimport { isZeroAddress } from '../utils/isZeroAddress.js'\nimport { getMulticallAddress } from './getMulticallAddress.js'\n\nexport const getAllowance = async (\n client: SDKClient,\n viemClient: Client,\n tokenAddress: Address,\n ownerAddress: Address,\n spenderAddress: Address\n): Promise<bigint> => {\n try {\n const approved = await getActionWithFallback(\n client,\n viemClient,\n readContract,\n 'readContract',\n {\n address: tokenAddress as Address,\n abi: allowanceAbi,\n functionName: 'allowance' as const,\n args: [ownerAddress, spenderAddress] as const,\n }\n )\n return approved as bigint\n } catch (_e) {\n return 0n\n }\n}\n\nexport const getAllowanceMulticall = async (\n client: SDKClient,\n viemClient: Client,\n chainId: ChainId,\n tokens: TokenSpender[],\n ownerAddress: Address\n): Promise<TokenSpenderAllowance[]> => {\n if (!tokens.length) {\n return []\n }\n const multicallAddress = await getMulticallAddress(client, chainId)\n if (!multicallAddress) {\n throw new Error(`No multicall address configured for chainId ${chainId}.`)\n }\n const contracts = tokens.map((token) => ({\n address: token.token.address as Address,\n abi: allowanceAbi,\n functionName: 'allowance',\n args: [ownerAddress, token.spenderAddress],\n }))\n\n const results = await getActionWithFallback(\n client,\n viemClient,\n multicall,\n 'multicall',\n {\n contracts,\n multicallAddress: multicallAddress as Address,\n }\n )\n\n if (!results.length) {\n throw new Error(\n `Couldn't load allowance from chainId ${chainId} using multicall.`\n )\n }\n\n return tokens.map(({ token, spenderAddress }, i: number) => ({\n token,\n spenderAddress,\n allowance: results[i].result as bigint,\n }))\n}\n\n/**\n * Get the current allowance for a certain token.\n * @param client - The SDK client\n * @param token - The token that should be checked\n * @param ownerAddress - The owner of the token\n * @param spenderAddress - The spender address that has to be approved\n * @returns Returns allowance\n */\nexport const getTokenAllowance = async (\n client: SDKClient,\n token: BaseToken,\n ownerAddress: Address,\n spenderAddress: Address\n): Promise<bigint | undefined> => {\n // native token don't need approval\n if (isZeroAddress(token.address)) {\n return\n }\n\n const viemClient = await getPublicClient(client, token.chainId)\n\n const approved = await getAllowance(\n client,\n viemClient,\n token.address as Address,\n ownerAddress,\n spenderAddress\n )\n return approved\n}\n\n/**\n * Get the current allowance for a list of token/spender address pairs.\n * @param client - The SDK client\n * @param ownerAddress - The owner of the tokens\n * @param tokens - A list of token and spender address pairs\n * @returns Returns array of tokens and their allowance\n */\nexport const getTokenAllowanceMulticall = async (\n client: SDKClient,\n ownerAddress: Address,\n tokens: TokenSpender[]\n): Promise<TokenAllowance[]> => {\n // filter out native tokens\n const filteredTokens = tokens.filter(\n ({ token }) => !isZeroAddress(token.address)\n )\n\n // group by chain\n const tokenDataByChain: { [chainId: number]: TokenSpender[] } = {}\n for (const data of filteredTokens) {\n if (!tokenDataByChain[data.token.chainId]) {\n tokenDataByChain[data.token.chainId] = []\n }\n tokenDataByChain[data.token.chainId].push(data)\n }\n\n const chainKeys = Object.keys(tokenDataByChain).map(Number.parseInt)\n\n const allowances = (\n await Promise.all(\n chainKeys.map(async (chainId) => {\n const viemClient = await getPublicClient(client, chainId)\n // get allowances for current chain and token list\n return getAllowanceMulticall(\n client,\n viemClient,\n chainId,\n tokenDataByChain[chainId],\n ownerAddress\n )\n })\n )\n ).flat()\n\n return allowances\n}\n"],"mappings":";;;;;;;;AAcA,MAAa,eAAe,OAC1B,QACA,YACA,cACA,cACA,mBACoB;CACpB,IAAI;EAaF,OAAO,MAZgBA,oCAAAA,sBACrB,QACA,YACAC,aAAAA,cACA,gBACA;GACE,SAAS;GACT,KAAKC,kBAAAA;GACL,cAAc;GACd,MAAM,CAAC,cAAc,cAAc;EACrC,CACF;CAEF,SAAS,IAAI;EACX,OAAO;CACT;AACF;AAEA,MAAa,wBAAwB,OACnC,QACA,YACA,SACA,QACA,iBACqC;CACrC,IAAI,CAAC,OAAO,QACV,OAAO,CAAC;CAEV,MAAM,mBAAmB,MAAMC,oCAAAA,oBAAoB,QAAQ,OAAO;CAClE,IAAI,CAAC,kBACH,MAAM,IAAI,MAAM,+CAA+C,QAAQ,EAAE;CAS3E,MAAM,UAAU,MAAMH,oCAAAA,sBACpB,QACA,YACAI,aAAAA,WACA,aACA;EACE,WAbc,OAAO,KAAK,WAAW;GACvC,SAAS,MAAM,MAAM;GACrB,KAAKF,kBAAAA;GACL,cAAc;GACd,MAAM,CAAC,cAAc,MAAM,cAAc;EAC3C,EAQY;EACU;CACpB,CACF;CAEA,IAAI,CAAC,QAAQ,QACX,MAAM,IAAI,MACR,wCAAwC,QAAQ,kBAClD;CAGF,OAAO,OAAO,KAAK,EAAE,OAAO,kBAAkB,OAAe;EAC3D;EACA;EACA,WAAW,QAAQ,EAAE,CAAC;CACxB,EAAE;AACJ;;;;;;;;;AAUA,MAAa,oBAAoB,OAC/B,QACA,OACA,cACA,mBACgC;CAEhC,IAAIG,4BAAAA,cAAc,MAAM,OAAO,GAC7B;CAGF,MAAM,aAAa,MAAMC,4BAAAA,gBAAgB,QAAQ,MAAM,OAAO;CAS9D,OAAO,MAPgB,aACrB,QACA,YACA,MAAM,SACN,cACA,cACF;AAEF;;;;;;;;AASA,MAAa,6BAA6B,OACxC,QACA,cACA,WAC8B;CAE9B,MAAM,iBAAiB,OAAO,QAC3B,EAAE,YAAY,CAACD,4BAAAA,cAAc,MAAM,OAAO,CAC7C;CAGA,MAAM,mBAA0D,CAAC;CACjE,KAAK,MAAM,QAAQ,gBAAgB;EACjC,IAAI,CAAC,iBAAiB,KAAK,MAAM,UAC/B,iBAAiB,KAAK,MAAM,WAAW,CAAC;EAE1C,iBAAiB,KAAK,MAAM,QAAQ,CAAC,KAAK,IAAI;CAChD;CAEA,MAAM,YAAY,OAAO,KAAK,gBAAgB,CAAC,CAAC,IAAI,OAAO,QAAQ;CAkBnE,QAfE,MAAM,QAAQ,IACZ,UAAU,IAAI,OAAO,YAAY;EAC/B,MAAM,aAAa,MAAMC,4BAAAA,gBAAgB,QAAQ,OAAO;EAExD,OAAO,sBACL,QACA,YACA,SACA,iBAAiB,UACjB,YACF;CACF,CAAC,CACH,EAAA,CACA,KAEc;AAClB"}
@@ -35,9 +35,10 @@ const getPublicClient = async (client, chainId) => {
35
35
  unsProxyReader: { address: unsProxyAddress }
36
36
  };
37
37
  }
38
+ const provider = client.getProvider(_lifi_sdk.ChainType.EVM);
38
39
  publicClients[chainId] = (0, viem.createClient)({
39
40
  chain,
40
- transport: (0, viem.fallback)(fallbackTransports, client.getProvider(_lifi_sdk.ChainType.EVM)?.options?.fallbackTransportConfig),
41
+ transport: (0, viem.fallback)(fallbackTransports, provider?.options?.fallbackTransportConfig),
41
42
  batch: { multicall: true }
42
43
  });
43
44
  return publicClients[chainId];
@@ -1 +1 @@
1
- {"version":3,"file":"publicClient.js","names":["ChainId","mainnet","UNS_PROXY_READER_ADDRESSES","ChainType"],"sources":["../../../src/client/publicClient.ts"],"sourcesContent":["import { ChainId, ChainType, type SDKClient } from '@lifi/sdk'\nimport type { Client } from 'viem'\nimport { type Address, createClient, fallback, http, webSocket } from 'viem'\nimport { type Chain, mainnet } from 'viem/chains'\nimport { UNS_PROXY_READER_ADDRESSES } from '../actions/constants.js'\nimport type { EthereumSDKProvider } from '../types.js'\n\n// cached providers\nconst publicClients: Record<number, Client> = {}\n\n/**\n * Get an instance of a provider for a specific chain\n * @param client - The SDK client\n * @param chainId - Id of the chain the provider is for\n * @returns The public client for the given chain\n */\nexport const getPublicClient = async (\n client: SDKClient,\n chainId: number\n): Promise<Client> => {\n if (publicClients[chainId]) {\n return publicClients[chainId]\n }\n\n const urls = await client.getRpcUrlsByChainId(chainId)\n const fallbackTransports = urls.map((url) =>\n url.startsWith('wss')\n ? webSocket(url)\n : http(url, {\n batch: {\n batchSize: 64,\n },\n })\n )\n const _chain = await client.getChainById(chainId)\n const chain: Chain = {\n ..._chain,\n ..._chain.metamask,\n name: _chain.metamask.chainName,\n rpcUrls: {\n default: { http: _chain.metamask.rpcUrls },\n public: { http: _chain.metamask.rpcUrls },\n },\n }\n // Add ENS contracts\n if (chain.id === ChainId.ETH) {\n chain.contracts = {\n ...mainnet.contracts,\n ...chain.contracts,\n }\n }\n\n // Add UNS contracts for supported chains\n if (chain.id === ChainId.ETH || chain.id === ChainId.POL) {\n const unsProxyAddress = UNS_PROXY_READER_ADDRESSES[chain.id]\n\n chain.contracts = {\n ...chain.contracts,\n unsProxyReader: { address: unsProxyAddress as Address },\n }\n }\n\n const provider = client.getProvider(ChainType.EVM) as\n | EthereumSDKProvider\n | undefined\n publicClients[chainId] = createClient({\n chain: chain,\n transport: fallback(\n fallbackTransports,\n provider?.options?.fallbackTransportConfig\n ),\n batch: {\n multicall: true,\n },\n })\n\n return publicClients[chainId]\n}\n"],"mappings":";;;;;;AAQA,MAAM,gBAAwC,CAAC;;;;;;;AAQ/C,MAAa,kBAAkB,OAC7B,QACA,YACoB;CACpB,IAAI,cAAc,UAChB,OAAO,cAAc;CAIvB,MAAM,sBAAqB,MADR,OAAO,oBAAoB,OAAO,EAAA,CACrB,KAAK,QACnC,IAAI,WAAW,KAAK,KAAA,GAAA,KAAA,UAAA,CACN,GAAG,KAAA,GAAA,KAAA,KAAA,CACR,KAAK,EACR,OAAO,EACL,WAAW,GACb,EACF,CAAC,CACP;CACA,MAAM,SAAS,MAAM,OAAO,aAAa,OAAO;CAChD,MAAM,QAAe;EACnB,GAAG;EACH,GAAG,OAAO;EACV,MAAM,OAAO,SAAS;EACtB,SAAS;GACP,SAAS,EAAE,MAAM,OAAO,SAAS,QAAQ;GACzC,QAAQ,EAAE,MAAM,OAAO,SAAS,QAAQ;EAC1C;CACF;CAEA,IAAI,MAAM,OAAOA,UAAAA,QAAQ,KACvB,MAAM,YAAY;EAChB,GAAGC,YAAAA,QAAQ;EACX,GAAG,MAAM;CACX;CAIF,IAAI,MAAM,OAAOD,UAAAA,QAAQ,OAAO,MAAM,OAAOA,UAAAA,QAAQ,KAAK;EACxD,MAAM,kBAAkBE,0BAAAA,2BAA2B,MAAM;EAEzD,MAAM,YAAY;GAChB,GAAG,MAAM;GACT,gBAAgB,EAAE,SAAS,gBAA2B;EACxD;CACF;CAKA,cAAc,YAAA,GAAA,KAAA,aAAA,CAAwB;EAC7B;EACP,YAAA,GAAA,KAAA,SAAA,CACE,oBANa,OAAO,YAAYC,UAAAA,UAAU,GAOnC,CAAC,EAAE,SAAS,uBACrB;EACA,OAAO,EACL,WAAW,KACb;CACF,CAAC;CAED,OAAO,cAAc;AACvB"}
1
+ {"version":3,"file":"publicClient.js","names":["ChainId","mainnet","UNS_PROXY_READER_ADDRESSES","ChainType"],"sources":["../../../src/client/publicClient.ts"],"sourcesContent":["import { ChainId, ChainType, type SDKClient } from '@lifi/sdk'\nimport type { Client } from 'viem'\nimport { type Address, createClient, fallback, http, webSocket } from 'viem'\nimport { type Chain, mainnet } from 'viem/chains'\nimport { UNS_PROXY_READER_ADDRESSES } from '../actions/constants.js'\nimport type { EthereumSDKProvider } from '../types.js'\n\n// cached providers\nconst publicClients: Record<number, Client> = {}\n\n/**\n * Get an instance of a provider for a specific chain\n * @param client - The SDK client\n * @param chainId - Id of the chain the provider is for\n * @returns The public client for the given chain\n */\nexport const getPublicClient = async (\n client: SDKClient,\n chainId: number\n): Promise<Client> => {\n if (publicClients[chainId]) {\n return publicClients[chainId]\n }\n\n const urls = await client.getRpcUrlsByChainId(chainId)\n const fallbackTransports = urls.map((url) =>\n url.startsWith('wss')\n ? webSocket(url)\n : http(url, {\n batch: {\n batchSize: 64,\n },\n })\n )\n const _chain = await client.getChainById(chainId)\n const chain: Chain = {\n ..._chain,\n ..._chain.metamask,\n name: _chain.metamask.chainName,\n rpcUrls: {\n default: { http: _chain.metamask.rpcUrls },\n public: { http: _chain.metamask.rpcUrls },\n },\n }\n // Add ENS contracts\n if (chain.id === ChainId.ETH) {\n chain.contracts = {\n ...mainnet.contracts,\n ...chain.contracts,\n }\n }\n\n // Add UNS contracts for supported chains\n if (chain.id === ChainId.ETH || chain.id === ChainId.POL) {\n const unsProxyAddress = UNS_PROXY_READER_ADDRESSES[chain.id]\n\n chain.contracts = {\n ...chain.contracts,\n unsProxyReader: { address: unsProxyAddress as Address },\n }\n }\n\n const provider = client.getProvider(ChainType.EVM) as\n | EthereumSDKProvider\n | undefined\n publicClients[chainId] = createClient({\n chain: chain,\n transport: fallback(\n fallbackTransports,\n provider?.options?.fallbackTransportConfig\n ),\n batch: {\n multicall: true,\n },\n })\n\n return publicClients[chainId]\n}\n"],"mappings":";;;;;;AAQA,MAAM,gBAAwC,CAAC;;;;;;;AAQ/C,MAAa,kBAAkB,OAC7B,QACA,YACoB;CACpB,IAAI,cAAc,UAChB,OAAO,cAAc;CAIvB,MAAM,sBAAqB,MADR,OAAO,oBAAoB,OAAO,EAAA,CACrB,KAAK,QACnC,IAAI,WAAW,KAAK,KAAA,GAAA,KAAA,UAAA,CACN,GAAG,KAAA,GAAA,KAAA,KAAA,CACR,KAAK,EACR,OAAO,EACL,WAAW,GACb,EACF,CAAC,CACP;CACA,MAAM,SAAS,MAAM,OAAO,aAAa,OAAO;CAChD,MAAM,QAAe;EACnB,GAAG;EACH,GAAG,OAAO;EACV,MAAM,OAAO,SAAS;EACtB,SAAS;GACP,SAAS,EAAE,MAAM,OAAO,SAAS,QAAQ;GACzC,QAAQ,EAAE,MAAM,OAAO,SAAS,QAAQ;EAC1C;CACF;CAEA,IAAI,MAAM,OAAOA,UAAAA,QAAQ,KACvB,MAAM,YAAY;EAChB,GAAGC,YAAAA,QAAQ;EACX,GAAG,MAAM;CACX;CAIF,IAAI,MAAM,OAAOD,UAAAA,QAAQ,OAAO,MAAM,OAAOA,UAAAA,QAAQ,KAAK;EACxD,MAAM,kBAAkBE,0BAAAA,2BAA2B,MAAM;EAEzD,MAAM,YAAY;GAChB,GAAG,MAAM;GACT,gBAAgB,EAAE,SAAS,gBAA2B;EACxD;CACF;CAEA,MAAM,WAAW,OAAO,YAAYC,UAAAA,UAAU,GAAG;CAGjD,cAAc,YAAA,GAAA,KAAA,aAAA,CAAwB;EAC7B;EACP,YAAA,GAAA,KAAA,SAAA,CACE,oBACA,UAAU,SAAS,uBACrB;EACA,OAAO,EACL,WAAW,KACb;CACF,CAAC;CAED,OAAO,cAAc;AACvB"}
@@ -1,5 +1,6 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  const require_utils_getDomainChainId = require("../../utils/getDomainChainId.js");
3
+ const require_utils_isValidSignature = require("../../utils/isValidSignature.js");
3
4
  let _lifi_sdk = require("@lifi/sdk");
4
5
  let viem_actions = require("viem/actions");
5
6
  let viem_utils = require("viem/utils");
@@ -31,6 +32,7 @@ var EthereumCheckPermitsTask = class extends _lifi_sdk.BaseStepExecutionTask {
31
32
  primaryType: typedData.primaryType,
32
33
  message: typedData.message
33
34
  });
35
+ require_utils_isValidSignature.assertValidSignature(signature);
34
36
  const signedPermit = {
35
37
  ...typedData,
36
38
  signature
@@ -1 +1 @@
1
- {"version":3,"file":"EthereumCheckPermitsTask.js","names":["BaseStepExecutionTask","getDomainChainId","signTypedData"],"sources":["../../../../src/core/tasks/EthereumCheckPermitsTask.ts"],"sourcesContent":["import {\n BaseStepExecutionTask,\n type SignedTypedData,\n type TaskResult,\n} from '@lifi/sdk'\nimport { signTypedData } from 'viem/actions'\nimport { getAction } from 'viem/utils'\nimport type { EthereumStepExecutorContext } from '../../types.js'\nimport { getDomainChainId } from '../../utils/getDomainChainId.js'\n\nexport class EthereumCheckPermitsTask extends BaseStepExecutionTask {\n override async shouldRun(\n context: EthereumStepExecutorContext\n ): Promise<boolean> {\n const { step, disableMessageSigning } = context\n\n const permitTypedData = step.typedData?.filter(\n (typedData) => typedData.primaryType === 'Permit'\n )\n\n return !!permitTypedData?.length && !disableMessageSigning\n }\n\n async run(context: EthereumStepExecutorContext): Promise<TaskResult> {\n const {\n step,\n statusManager,\n allowUserInteraction,\n checkClient,\n signedTypedData: currentSignedTypedData,\n } = context\n\n const action = statusManager.initializeAction({\n step,\n type: 'PERMIT',\n chainId: step.action.fromChainId,\n status: 'STARTED',\n })\n\n // First, try to sign all permits in step.typedData\n const permitTypedData =\n step.typedData?.filter(\n (typedData) => typedData.primaryType === 'Permit'\n ) ?? []\n\n const signedTypedData = [...currentSignedTypedData]\n for (const typedData of permitTypedData) {\n statusManager.updateAction(step, action.type, 'ACTION_REQUIRED')\n\n if (!allowUserInteraction) {\n return { status: 'PAUSED' }\n }\n\n const typedDataChainId =\n getDomainChainId(typedData.domain) || step.action.fromChainId\n\n // Switch to the permit's chain if needed\n const permitClient = await checkClient(step, typedDataChainId)\n if (!permitClient) {\n return { status: 'PAUSED' }\n }\n\n const signature = await getAction(\n permitClient,\n signTypedData,\n 'signTypedData'\n )({\n account: permitClient.account!,\n domain: typedData.domain,\n types: typedData.types,\n primaryType: typedData.primaryType,\n message: typedData.message,\n })\n const signedPermit: SignedTypedData = {\n ...typedData,\n signature,\n }\n signedTypedData.push(signedPermit)\n }\n\n // Check if there's a signed permit for the source transaction chain\n const matchingPermit = signedTypedData.find(\n (signedTypedData) =>\n getDomainChainId(signedTypedData.domain) === step.action.fromChainId\n )\n\n statusManager.updateAction(step, action.type, 'DONE')\n\n return {\n status: 'COMPLETED',\n context: { signedTypedData, hasMatchingPermit: !!matchingPermit },\n }\n }\n}\n"],"mappings":";;;;;;AAUA,IAAa,2BAAb,cAA8CA,UAAAA,sBAAsB;CAClE,MAAe,UACb,SACkB;EAClB,MAAM,EAAE,MAAM,0BAA0B;EAMxC,OAAO,CAAC,EAJgB,KAAK,WAAW,QACrC,cAAc,UAAU,gBAAgB,QAC3C,EAAA,EAE0B,UAAU,CAAC;CACvC;CAEA,MAAM,IAAI,SAA2D;EACnE,MAAM,EACJ,MACA,eACA,sBACA,aACA,iBAAiB,2BACf;EAEJ,MAAM,SAAS,cAAc,iBAAiB;GAC5C;GACA,MAAM;GACN,SAAS,KAAK,OAAO;GACrB,QAAQ;EACV,CAAC;EAGD,MAAM,kBACJ,KAAK,WAAW,QACb,cAAc,UAAU,gBAAgB,QAC3C,KAAK,CAAC;EAER,MAAM,kBAAkB,CAAC,GAAG,sBAAsB;EAClD,KAAK,MAAM,aAAa,iBAAiB;GACvC,cAAc,aAAa,MAAM,OAAO,MAAM,iBAAiB;GAE/D,IAAI,CAAC,sBACH,OAAO,EAAE,QAAQ,SAAS;GAO5B,MAAM,eAAe,MAAM,YAAY,MAHrCC,+BAAAA,iBAAiB,UAAU,MAAM,KAAK,KAAK,OAAO,WAGS;GAC7D,IAAI,CAAC,cACH,OAAO,EAAE,QAAQ,SAAS;GAG5B,MAAM,YAAY,OAAA,GAAA,WAAA,UAAA,CAChB,cACAC,aAAAA,eACA,eACF,CAAC,CAAC;IACA,SAAS,aAAa;IACtB,QAAQ,UAAU;IAClB,OAAO,UAAU;IACjB,aAAa,UAAU;IACvB,SAAS,UAAU;GACrB,CAAC;GACD,MAAM,eAAgC;IACpC,GAAG;IACH;GACF;GACA,gBAAgB,KAAK,YAAY;EACnC;EAGA,MAAM,iBAAiB,gBAAgB,MACpC,oBACCD,+BAAAA,iBAAiB,gBAAgB,MAAM,MAAM,KAAK,OAAO,WAC7D;EAEA,cAAc,aAAa,MAAM,OAAO,MAAM,MAAM;EAEpD,OAAO;GACL,QAAQ;GACR,SAAS;IAAE;IAAiB,mBAAmB,CAAC,CAAC;GAAe;EAClE;CACF;AACF"}
1
+ {"version":3,"file":"EthereumCheckPermitsTask.js","names":["BaseStepExecutionTask","getDomainChainId","signTypedData"],"sources":["../../../../src/core/tasks/EthereumCheckPermitsTask.ts"],"sourcesContent":["import {\n BaseStepExecutionTask,\n type SignedTypedData,\n type TaskResult,\n} from '@lifi/sdk'\nimport { signTypedData } from 'viem/actions'\nimport { getAction } from 'viem/utils'\nimport type { EthereumStepExecutorContext } from '../../types.js'\nimport { getDomainChainId } from '../../utils/getDomainChainId.js'\nimport { assertValidSignature } from '../../utils/isValidSignature.js'\n\nexport class EthereumCheckPermitsTask extends BaseStepExecutionTask {\n override async shouldRun(\n context: EthereumStepExecutorContext\n ): Promise<boolean> {\n const { step, disableMessageSigning } = context\n\n const permitTypedData = step.typedData?.filter(\n (typedData) => typedData.primaryType === 'Permit'\n )\n\n return !!permitTypedData?.length && !disableMessageSigning\n }\n\n async run(context: EthereumStepExecutorContext): Promise<TaskResult> {\n const {\n step,\n statusManager,\n allowUserInteraction,\n checkClient,\n signedTypedData: currentSignedTypedData,\n } = context\n\n const action = statusManager.initializeAction({\n step,\n type: 'PERMIT',\n chainId: step.action.fromChainId,\n status: 'STARTED',\n })\n\n // First, try to sign all permits in step.typedData\n const permitTypedData =\n step.typedData?.filter(\n (typedData) => typedData.primaryType === 'Permit'\n ) ?? []\n\n const signedTypedData = [...currentSignedTypedData]\n for (const typedData of permitTypedData) {\n statusManager.updateAction(step, action.type, 'ACTION_REQUIRED')\n\n if (!allowUserInteraction) {\n return { status: 'PAUSED' }\n }\n\n const typedDataChainId =\n getDomainChainId(typedData.domain) || step.action.fromChainId\n\n // Switch to the permit's chain if needed\n const permitClient = await checkClient(step, typedDataChainId)\n if (!permitClient) {\n return { status: 'PAUSED' }\n }\n\n const signature = await getAction(\n permitClient,\n signTypedData,\n 'signTypedData'\n )({\n account: permitClient.account!,\n domain: typedData.domain,\n types: typedData.types,\n primaryType: typedData.primaryType,\n message: typedData.message,\n })\n assertValidSignature(signature)\n const signedPermit: SignedTypedData = {\n ...typedData,\n signature,\n }\n signedTypedData.push(signedPermit)\n }\n\n // Check if there's a signed permit for the source transaction chain\n const matchingPermit = signedTypedData.find(\n (signedTypedData) =>\n getDomainChainId(signedTypedData.domain) === step.action.fromChainId\n )\n\n statusManager.updateAction(step, action.type, 'DONE')\n\n return {\n status: 'COMPLETED',\n context: { signedTypedData, hasMatchingPermit: !!matchingPermit },\n }\n }\n}\n"],"mappings":";;;;;;;AAWA,IAAa,2BAAb,cAA8CA,UAAAA,sBAAsB;CAClE,MAAe,UACb,SACkB;EAClB,MAAM,EAAE,MAAM,0BAA0B;EAMxC,OAAO,CAAC,EAJgB,KAAK,WAAW,QACrC,cAAc,UAAU,gBAAgB,QAC3C,EAAA,EAE0B,UAAU,CAAC;CACvC;CAEA,MAAM,IAAI,SAA2D;EACnE,MAAM,EACJ,MACA,eACA,sBACA,aACA,iBAAiB,2BACf;EAEJ,MAAM,SAAS,cAAc,iBAAiB;GAC5C;GACA,MAAM;GACN,SAAS,KAAK,OAAO;GACrB,QAAQ;EACV,CAAC;EAGD,MAAM,kBACJ,KAAK,WAAW,QACb,cAAc,UAAU,gBAAgB,QAC3C,KAAK,CAAC;EAER,MAAM,kBAAkB,CAAC,GAAG,sBAAsB;EAClD,KAAK,MAAM,aAAa,iBAAiB;GACvC,cAAc,aAAa,MAAM,OAAO,MAAM,iBAAiB;GAE/D,IAAI,CAAC,sBACH,OAAO,EAAE,QAAQ,SAAS;GAO5B,MAAM,eAAe,MAAM,YAAY,MAHrCC,+BAAAA,iBAAiB,UAAU,MAAM,KAAK,KAAK,OAAO,WAGS;GAC7D,IAAI,CAAC,cACH,OAAO,EAAE,QAAQ,SAAS;GAG5B,MAAM,YAAY,OAAA,GAAA,WAAA,UAAA,CAChB,cACAC,aAAAA,eACA,eACF,CAAC,CAAC;IACA,SAAS,aAAa;IACtB,QAAQ,UAAU;IAClB,OAAO,UAAU;IACjB,aAAa,UAAU;IACvB,SAAS,UAAU;GACrB,CAAC;GACD,+BAAA,qBAAqB,SAAS;GAC9B,MAAM,eAAgC;IACpC,GAAG;IACH;GACF;GACA,gBAAgB,KAAK,YAAY;EACnC;EAGA,MAAM,iBAAiB,gBAAgB,MACpC,oBACCD,+BAAAA,iBAAiB,gBAAgB,MAAM,MAAM,KAAK,OAAO,WAC7D;EAEA,cAAc,aAAa,MAAM,OAAO,MAAM,MAAM;EAEpD,OAAO;GACL,QAAQ;GACR,SAAS;IAAE;IAAiB,mBAAmB,CAAC,CAAC;GAAe;EAClE;CACF;AACF"}
@@ -1,6 +1,7 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  const require_utils_getActionWithFallback = require("../../utils/getActionWithFallback.js");
3
3
  const require_core_tasks_helpers_getEthereumExecutionStrategy = require("./helpers/getEthereumExecutionStrategy.js");
4
+ const require_utils_isValidSignature = require("../../utils/isValidSignature.js");
4
5
  const require_permits_getNativePermit = require("../../permits/getNativePermit.js");
5
6
  const require_permits_isNativePermitValid = require("../../permits/isNativePermitValid.js");
6
7
  let _lifi_sdk = require("@lifi/sdk");
@@ -48,6 +49,10 @@ var EthereumNativePermitTask = class extends _lifi_sdk.BaseStepExecutionTask {
48
49
  primaryType: nativePermitData.primaryType,
49
50
  message: nativePermitData.message
50
51
  });
52
+ if (!require_utils_isValidSignature.isValidSignature(signature)) {
53
+ statusManager.updateAction(step, action.type, "DONE");
54
+ return { status: "COMPLETED" };
55
+ }
51
56
  const signedPermit = {
52
57
  ...nativePermitData,
53
58
  signature
@@ -1 +1 @@
1
- {"version":3,"file":"EthereumNativePermitTask.js","names":["BaseStepExecutionTask","getEthereumExecutionStrategy","getActionWithFallback","getNativePermit","isNativePermitValid","signTypedData"],"sources":["../../../../src/core/tasks/EthereumNativePermitTask.ts"],"sourcesContent":["import {\n BaseStepExecutionTask,\n type SignedTypedData,\n type TaskResult,\n} from '@lifi/sdk'\nimport type { Address } from 'viem'\nimport { signTypedData } from 'viem/actions'\nimport { getAction } from 'viem/utils'\nimport { getNativePermit } from '../../permits/getNativePermit.js'\nimport { isNativePermitValid } from '../../permits/isNativePermitValid.js'\nimport type { EthereumStepExecutorContext } from '../../types.js'\nimport { getActionWithFallback } from '../../utils/getActionWithFallback.js'\nimport { getEthereumExecutionStrategy } from './helpers/getEthereumExecutionStrategy.js'\n\nexport class EthereumNativePermitTask extends BaseStepExecutionTask {\n override async shouldRun(\n context: EthereumStepExecutorContext\n ): Promise<boolean> {\n const {\n step,\n fromChain,\n hasMatchingPermit,\n hasSufficientAllowance,\n disableMessageSigning,\n } = context\n\n if (hasMatchingPermit || hasSufficientAllowance) {\n return false\n }\n\n const executionStrategy = await getEthereumExecutionStrategy(context)\n const batchingSupported = executionStrategy === 'batched'\n // Check if proxy contract is available and message signing is not disabled, also not available for atomic batch\n const isNativePermitAvailable =\n !!fromChain.permit2Proxy &&\n !batchingSupported &&\n !disableMessageSigning &&\n !step.estimate.skipPermit\n return isNativePermitAvailable\n }\n\n async run(context: EthereumStepExecutorContext): Promise<TaskResult> {\n const {\n step,\n client,\n fromChain,\n statusManager,\n allowUserInteraction,\n checkClient,\n signedTypedData: currentSignedTypedData,\n } = context\n\n const action = statusManager.initializeAction({\n step,\n type: 'NATIVE_PERMIT',\n chainId: step.action.fromChainId,\n status: 'STARTED',\n })\n\n const updatedClient = await checkClient(step)\n if (!updatedClient) {\n return { status: 'PAUSED' }\n }\n\n const fromAmount = BigInt(step.action.fromAmount)\n\n const nativePermitData = await getActionWithFallback(\n client,\n updatedClient,\n getNativePermit,\n 'getNativePermit',\n {\n client,\n viemClient: updatedClient,\n chainId: fromChain.id,\n tokenAddress: step.action.fromToken.address as Address,\n spenderAddress: fromChain.permit2Proxy as Address,\n amount: fromAmount,\n }\n )\n\n if (!nativePermitData) {\n statusManager.updateAction(step, action.type, 'DONE')\n return { status: 'COMPLETED' }\n }\n\n const signedTypedData = [...currentSignedTypedData]\n\n // Check if we already have a valid permit for this chain and requirements\n const signedTypedDataForChain = signedTypedData.find((signedTypedData) =>\n isNativePermitValid(signedTypedData, nativePermitData)\n )\n\n if (!signedTypedDataForChain) {\n statusManager.updateAction(step, action.type, 'ACTION_REQUIRED')\n\n if (!allowUserInteraction) {\n return { status: 'PAUSED' }\n }\n\n // Sign the permit\n const signature = await getAction(\n updatedClient,\n signTypedData,\n 'signTypedData'\n )({\n account: updatedClient.account!,\n domain: nativePermitData.domain,\n types: nativePermitData.types,\n primaryType: nativePermitData.primaryType,\n message: nativePermitData.message,\n })\n\n // Add the new permit to the signed permits array\n const signedPermit: SignedTypedData = {\n ...nativePermitData,\n signature,\n }\n signedTypedData.push(signedPermit)\n }\n\n statusManager.updateAction(step, action.type, 'DONE')\n\n return {\n status: 'COMPLETED',\n context: { signedTypedData, hasMatchingPermit: true },\n }\n }\n}\n"],"mappings":";;;;;;;;;AAcA,IAAa,2BAAb,cAA8CA,UAAAA,sBAAsB;CAClE,MAAe,UACb,SACkB;EAClB,MAAM,EACJ,MACA,WACA,mBACA,wBACA,0BACE;EAEJ,IAAI,qBAAqB,wBACvB,OAAO;EAIT,MAAM,oBAAoB,MADMC,wDAAAA,6BAA6B,OAAO,MACpB;EAOhD,OAJE,CAAC,CAAC,UAAU,gBACZ,CAAC,qBACD,CAAC,yBACD,CAAC,KAAK,SAAS;CAEnB;CAEA,MAAM,IAAI,SAA2D;EACnE,MAAM,EACJ,MACA,QACA,WACA,eACA,sBACA,aACA,iBAAiB,2BACf;EAEJ,MAAM,SAAS,cAAc,iBAAiB;GAC5C;GACA,MAAM;GACN,SAAS,KAAK,OAAO;GACrB,QAAQ;EACV,CAAC;EAED,MAAM,gBAAgB,MAAM,YAAY,IAAI;EAC5C,IAAI,CAAC,eACH,OAAO,EAAE,QAAQ,SAAS;EAG5B,MAAM,aAAa,OAAO,KAAK,OAAO,UAAU;EAEhD,MAAM,mBAAmB,MAAMC,oCAAAA,sBAC7B,QACA,eACAC,gCAAAA,iBACA,mBACA;GACE;GACA,YAAY;GACZ,SAAS,UAAU;GACnB,cAAc,KAAK,OAAO,UAAU;GACpC,gBAAgB,UAAU;GAC1B,QAAQ;EACV,CACF;EAEA,IAAI,CAAC,kBAAkB;GACrB,cAAc,aAAa,MAAM,OAAO,MAAM,MAAM;GACpD,OAAO,EAAE,QAAQ,YAAY;EAC/B;EAEA,MAAM,kBAAkB,CAAC,GAAG,sBAAsB;EAOlD,IAAI,CAJ4B,gBAAgB,MAAM,oBACpDC,oCAAAA,oBAAoB,iBAAiB,gBAAgB,CAG5B,GAAG;GAC5B,cAAc,aAAa,MAAM,OAAO,MAAM,iBAAiB;GAE/D,IAAI,CAAC,sBACH,OAAO,EAAE,QAAQ,SAAS;GAI5B,MAAM,YAAY,OAAA,GAAA,WAAA,UAAA,CAChB,eACAC,aAAAA,eACA,eACF,CAAC,CAAC;IACA,SAAS,cAAc;IACvB,QAAQ,iBAAiB;IACzB,OAAO,iBAAiB;IACxB,aAAa,iBAAiB;IAC9B,SAAS,iBAAiB;GAC5B,CAAC;GAGD,MAAM,eAAgC;IACpC,GAAG;IACH;GACF;GACA,gBAAgB,KAAK,YAAY;EACnC;EAEA,cAAc,aAAa,MAAM,OAAO,MAAM,MAAM;EAEpD,OAAO;GACL,QAAQ;GACR,SAAS;IAAE;IAAiB,mBAAmB;GAAK;EACtD;CACF;AACF"}
1
+ {"version":3,"file":"EthereumNativePermitTask.js","names":["BaseStepExecutionTask","getEthereumExecutionStrategy","getActionWithFallback","getNativePermit","isNativePermitValid","signTypedData","isValidSignature"],"sources":["../../../../src/core/tasks/EthereumNativePermitTask.ts"],"sourcesContent":["import {\n BaseStepExecutionTask,\n type SignedTypedData,\n type TaskResult,\n} from '@lifi/sdk'\nimport type { Address } from 'viem'\nimport { signTypedData } from 'viem/actions'\nimport { getAction } from 'viem/utils'\nimport { getNativePermit } from '../../permits/getNativePermit.js'\nimport { isNativePermitValid } from '../../permits/isNativePermitValid.js'\nimport type { EthereumStepExecutorContext } from '../../types.js'\nimport { getActionWithFallback } from '../../utils/getActionWithFallback.js'\nimport { isValidSignature } from '../../utils/isValidSignature.js'\nimport { getEthereumExecutionStrategy } from './helpers/getEthereumExecutionStrategy.js'\n\nexport class EthereumNativePermitTask extends BaseStepExecutionTask {\n override async shouldRun(\n context: EthereumStepExecutorContext\n ): Promise<boolean> {\n const {\n step,\n fromChain,\n hasMatchingPermit,\n hasSufficientAllowance,\n disableMessageSigning,\n } = context\n\n if (hasMatchingPermit || hasSufficientAllowance) {\n return false\n }\n\n const executionStrategy = await getEthereumExecutionStrategy(context)\n const batchingSupported = executionStrategy === 'batched'\n // Check if proxy contract is available and message signing is not disabled, also not available for atomic batch\n const isNativePermitAvailable =\n !!fromChain.permit2Proxy &&\n !batchingSupported &&\n !disableMessageSigning &&\n !step.estimate.skipPermit\n return isNativePermitAvailable\n }\n\n async run(context: EthereumStepExecutorContext): Promise<TaskResult> {\n const {\n step,\n client,\n fromChain,\n statusManager,\n allowUserInteraction,\n checkClient,\n signedTypedData: currentSignedTypedData,\n } = context\n\n const action = statusManager.initializeAction({\n step,\n type: 'NATIVE_PERMIT',\n chainId: step.action.fromChainId,\n status: 'STARTED',\n })\n\n const updatedClient = await checkClient(step)\n if (!updatedClient) {\n return { status: 'PAUSED' }\n }\n\n const fromAmount = BigInt(step.action.fromAmount)\n\n const nativePermitData = await getActionWithFallback(\n client,\n updatedClient,\n getNativePermit,\n 'getNativePermit',\n {\n client,\n viemClient: updatedClient,\n chainId: fromChain.id,\n tokenAddress: step.action.fromToken.address as Address,\n spenderAddress: fromChain.permit2Proxy as Address,\n amount: fromAmount,\n }\n )\n\n if (!nativePermitData) {\n statusManager.updateAction(step, action.type, 'DONE')\n return { status: 'COMPLETED' }\n }\n\n const signedTypedData = [...currentSignedTypedData]\n\n // Check if we already have a valid permit for this chain and requirements\n const signedTypedDataForChain = signedTypedData.find((signedTypedData) =>\n isNativePermitValid(signedTypedData, nativePermitData)\n )\n\n if (!signedTypedDataForChain) {\n statusManager.updateAction(step, action.type, 'ACTION_REQUIRED')\n\n if (!allowUserInteraction) {\n return { status: 'PAUSED' }\n }\n\n // Sign the permit\n const signature = await getAction(\n updatedClient,\n signTypedData,\n 'signTypedData'\n )({\n account: updatedClient.account!,\n domain: nativePermitData.domain,\n types: nativePermitData.types,\n primaryType: nativePermitData.primaryType,\n message: nativePermitData.message,\n })\n\n // Some wallets resolve signTypedData with a nullish or empty value\n // instead of rejecting — skip the permit and fall back to the\n // Permit2/standard approval flow\n if (!isValidSignature(signature)) {\n statusManager.updateAction(step, action.type, 'DONE')\n return { status: 'COMPLETED' }\n }\n\n // Add the new permit to the signed permits array\n const signedPermit: SignedTypedData = {\n ...nativePermitData,\n signature,\n }\n signedTypedData.push(signedPermit)\n }\n\n statusManager.updateAction(step, action.type, 'DONE')\n\n return {\n status: 'COMPLETED',\n context: { signedTypedData, hasMatchingPermit: true },\n }\n }\n}\n"],"mappings":";;;;;;;;;;AAeA,IAAa,2BAAb,cAA8CA,UAAAA,sBAAsB;CAClE,MAAe,UACb,SACkB;EAClB,MAAM,EACJ,MACA,WACA,mBACA,wBACA,0BACE;EAEJ,IAAI,qBAAqB,wBACvB,OAAO;EAIT,MAAM,oBAAoB,MADMC,wDAAAA,6BAA6B,OAAO,MACpB;EAOhD,OAJE,CAAC,CAAC,UAAU,gBACZ,CAAC,qBACD,CAAC,yBACD,CAAC,KAAK,SAAS;CAEnB;CAEA,MAAM,IAAI,SAA2D;EACnE,MAAM,EACJ,MACA,QACA,WACA,eACA,sBACA,aACA,iBAAiB,2BACf;EAEJ,MAAM,SAAS,cAAc,iBAAiB;GAC5C;GACA,MAAM;GACN,SAAS,KAAK,OAAO;GACrB,QAAQ;EACV,CAAC;EAED,MAAM,gBAAgB,MAAM,YAAY,IAAI;EAC5C,IAAI,CAAC,eACH,OAAO,EAAE,QAAQ,SAAS;EAG5B,MAAM,aAAa,OAAO,KAAK,OAAO,UAAU;EAEhD,MAAM,mBAAmB,MAAMC,oCAAAA,sBAC7B,QACA,eACAC,gCAAAA,iBACA,mBACA;GACE;GACA,YAAY;GACZ,SAAS,UAAU;GACnB,cAAc,KAAK,OAAO,UAAU;GACpC,gBAAgB,UAAU;GAC1B,QAAQ;EACV,CACF;EAEA,IAAI,CAAC,kBAAkB;GACrB,cAAc,aAAa,MAAM,OAAO,MAAM,MAAM;GACpD,OAAO,EAAE,QAAQ,YAAY;EAC/B;EAEA,MAAM,kBAAkB,CAAC,GAAG,sBAAsB;EAOlD,IAAI,CAJ4B,gBAAgB,MAAM,oBACpDC,oCAAAA,oBAAoB,iBAAiB,gBAAgB,CAG5B,GAAG;GAC5B,cAAc,aAAa,MAAM,OAAO,MAAM,iBAAiB;GAE/D,IAAI,CAAC,sBACH,OAAO,EAAE,QAAQ,SAAS;GAI5B,MAAM,YAAY,OAAA,GAAA,WAAA,UAAA,CAChB,eACAC,aAAAA,eACA,eACF,CAAC,CAAC;IACA,SAAS,cAAc;IACvB,QAAQ,iBAAiB;IACzB,OAAO,iBAAiB;IACxB,aAAa,iBAAiB;IAC9B,SAAS,iBAAiB;GAC5B,CAAC;GAKD,IAAI,CAACC,+BAAAA,iBAAiB,SAAS,GAAG;IAChC,cAAc,aAAa,MAAM,OAAO,MAAM,MAAM;IACpD,OAAO,EAAE,QAAQ,YAAY;GAC/B;GAGA,MAAM,eAAgC;IACpC,GAAG;IACH;GACF;GACA,gBAAgB,KAAK,YAAY;EACnC;EAEA,cAAc,aAAa,MAAM,OAAO,MAAM,MAAM;EAEpD,OAAO;GACL,QAAQ;GACR,SAAS;IAAE;IAAiB,mBAAmB;GAAK;EACtD;CACF;AACF"}
@@ -1,5 +1,6 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  const require_utils_getDomainChainId = require("../../utils/getDomainChainId.js");
3
+ const require_utils_isValidSignature = require("../../utils/isValidSignature.js");
3
4
  const require_permits_isNativePermitValid = require("../../permits/isNativePermitValid.js");
4
5
  const require_hyperliquid_isHyperliquidAgentStep = require("../../hyperliquid/isHyperliquidAgentStep.js");
5
6
  const require_core_tasks_helpers_signHyperliquidTypedData = require("./helpers/signHyperliquidTypedData.js");
@@ -31,6 +32,7 @@ var EthereumRelayedSignAndExecuteTask = class extends _lifi_sdk.BaseStepExecutio
31
32
  types: typedData.types,
32
33
  message: typedData.message
33
34
  });
35
+ require_utils_isValidSignature.assertValidSignature(signature);
34
36
  signedTypedData.push({
35
37
  ...typedData,
36
38
  signature
@@ -1 +1 @@
1
- {"version":3,"file":"EthereumRelayedSignAndExecuteTask.js","names":["BaseStepExecutionTask","TransactionError","LiFiErrorCode","isNativePermitValid","isHyperliquidAgentStep","signHyperliquidTypedData","getDomainChainId","signTypedData"],"sources":["../../../../src/core/tasks/EthereumRelayedSignAndExecuteTask.ts"],"sourcesContent":["import {\n BaseStepExecutionTask,\n LiFiErrorCode,\n relayTransaction,\n type TaskResult,\n TransactionError,\n} from '@lifi/sdk'\nimport type { Hash } from 'viem'\nimport { signTypedData } from 'viem/actions'\nimport { getAction } from 'viem/utils'\nimport { isHyperliquidAgentStep } from '../../hyperliquid/isHyperliquidAgentStep.js'\nimport { isNativePermitValid } from '../../permits/isNativePermitValid.js'\nimport type { EthereumStepExecutorContext } from '../../types.js'\nimport { getDomainChainId } from '../../utils/getDomainChainId.js'\nimport { signHyperliquidTypedData } from './helpers/signHyperliquidTypedData.js'\n\nexport class EthereumRelayedSignAndExecuteTask extends BaseStepExecutionTask {\n async run(context: EthereumStepExecutorContext): Promise<TaskResult> {\n const {\n step,\n fromChain,\n client,\n statusManager,\n allowUserInteraction,\n checkClient,\n isBridgeExecution,\n signedTypedData: currentSignedTypedData,\n } = context\n\n const signedTypedData = [...currentSignedTypedData]\n\n const action = statusManager.findAction(\n step,\n isBridgeExecution ? 'CROSS_CHAIN' : 'SWAP'\n )\n\n if (!action) {\n throw new TransactionError(\n LiFiErrorCode.TransactionUnprepared,\n 'Unable to prepare transaction. Action not found.'\n )\n }\n\n const intentTypedData = step.typedData?.filter(\n (typedData) =>\n !signedTypedData.some((signedPermit) =>\n isNativePermitValid(signedPermit, typedData)\n )\n )\n if (!intentTypedData?.length) {\n throw new TransactionError(\n LiFiErrorCode.TransactionUnprepared,\n 'Unable to prepare transaction. Typed data for transfer is not found.'\n )\n }\n\n statusManager.updateAction(step, action.type, 'MESSAGE_REQUIRED')\n\n if (isHyperliquidAgentStep(step)) {\n const signedResults = await signHyperliquidTypedData(\n context,\n intentTypedData\n )\n\n if (!signedResults) {\n return { status: 'PAUSED' }\n }\n\n signedTypedData.push(...signedResults)\n } else {\n for (const typedData of intentTypedData) {\n if (!allowUserInteraction) {\n return { status: 'PAUSED' }\n }\n\n const typedDataChainId =\n getDomainChainId(typedData.domain) || fromChain.id\n\n // Switch to the typed data's chain if needed\n const updatedClient = await checkClient(step, typedDataChainId)\n if (!updatedClient) {\n return { status: 'PAUSED' }\n }\n\n const signature = await getAction(\n updatedClient,\n signTypedData,\n 'signTypedData'\n )({\n account: updatedClient.account!,\n primaryType: typedData.primaryType,\n domain: typedData.domain,\n types: typedData.types,\n message: typedData.message,\n })\n\n signedTypedData.push({\n ...typedData,\n signature: signature,\n })\n }\n }\n\n statusManager.updateAction(step, action.type, 'PENDING')\n\n const { execution, ...stepBase } = step\n const relayedTransaction = await relayTransaction(client, {\n ...stepBase,\n typedData: signedTypedData,\n })\n\n statusManager.updateAction(step, action.type, 'PENDING', {\n taskId: relayedTransaction.taskId as Hash,\n txType: 'relayed',\n txLink: relayedTransaction.txLink,\n signedAt: Date.now(),\n })\n\n return { status: 'COMPLETED', context: { signedTypedData } }\n }\n}\n"],"mappings":";;;;;;;;;AAgBA,IAAa,oCAAb,cAAuDA,UAAAA,sBAAsB;CAC3E,MAAM,IAAI,SAA2D;EACnE,MAAM,EACJ,MACA,WACA,QACA,eACA,sBACA,aACA,mBACA,iBAAiB,2BACf;EAEJ,MAAM,kBAAkB,CAAC,GAAG,sBAAsB;EAElD,MAAM,SAAS,cAAc,WAC3B,MACA,oBAAoB,gBAAgB,MACtC;EAEA,IAAI,CAAC,QACH,MAAM,IAAIC,UAAAA,iBACRC,UAAAA,cAAc,uBACd,kDACF;EAGF,MAAM,kBAAkB,KAAK,WAAW,QACrC,cACC,CAAC,gBAAgB,MAAM,iBACrBC,oCAAAA,oBAAoB,cAAc,SAAS,CAC7C,CACJ;EACA,IAAI,CAAC,iBAAiB,QACpB,MAAM,IAAIF,UAAAA,iBACRC,UAAAA,cAAc,uBACd,sEACF;EAGF,cAAc,aAAa,MAAM,OAAO,MAAM,kBAAkB;EAEhE,IAAIE,2CAAAA,uBAAuB,IAAI,GAAG;GAChC,MAAM,gBAAgB,MAAMC,oDAAAA,yBAC1B,SACA,eACF;GAEA,IAAI,CAAC,eACH,OAAO,EAAE,QAAQ,SAAS;GAG5B,gBAAgB,KAAK,GAAG,aAAa;EACvC,OACE,KAAK,MAAM,aAAa,iBAAiB;GACvC,IAAI,CAAC,sBACH,OAAO,EAAE,QAAQ,SAAS;GAO5B,MAAM,gBAAgB,MAAM,YAAY,MAHtCC,+BAAAA,iBAAiB,UAAU,MAAM,KAAK,UAAU,EAGY;GAC9D,IAAI,CAAC,eACH,OAAO,EAAE,QAAQ,SAAS;GAG5B,MAAM,YAAY,OAAA,GAAA,WAAA,UAAA,CAChB,eACAC,aAAAA,eACA,eACF,CAAC,CAAC;IACA,SAAS,cAAc;IACvB,aAAa,UAAU;IACvB,QAAQ,UAAU;IAClB,OAAO,UAAU;IACjB,SAAS,UAAU;GACrB,CAAC;GAED,gBAAgB,KAAK;IACnB,GAAG;IACQ;GACb,CAAC;EACH;EAGF,cAAc,aAAa,MAAM,OAAO,MAAM,SAAS;EAEvD,MAAM,EAAE,WAAW,GAAG,aAAa;EACnC,MAAM,qBAAqB,OAAA,GAAA,UAAA,iBAAA,CAAuB,QAAQ;GACxD,GAAG;GACH,WAAW;EACb,CAAC;EAED,cAAc,aAAa,MAAM,OAAO,MAAM,WAAW;GACvD,QAAQ,mBAAmB;GAC3B,QAAQ;GACR,QAAQ,mBAAmB;GAC3B,UAAU,KAAK,IAAI;EACrB,CAAC;EAED,OAAO;GAAE,QAAQ;GAAa,SAAS,EAAE,gBAAgB;EAAE;CAC7D;AACF"}
1
+ {"version":3,"file":"EthereumRelayedSignAndExecuteTask.js","names":["BaseStepExecutionTask","TransactionError","LiFiErrorCode","isNativePermitValid","isHyperliquidAgentStep","signHyperliquidTypedData","getDomainChainId","signTypedData"],"sources":["../../../../src/core/tasks/EthereumRelayedSignAndExecuteTask.ts"],"sourcesContent":["import {\n BaseStepExecutionTask,\n LiFiErrorCode,\n relayTransaction,\n type TaskResult,\n TransactionError,\n} from '@lifi/sdk'\nimport type { Hash } from 'viem'\nimport { signTypedData } from 'viem/actions'\nimport { getAction } from 'viem/utils'\nimport { isHyperliquidAgentStep } from '../../hyperliquid/isHyperliquidAgentStep.js'\nimport { isNativePermitValid } from '../../permits/isNativePermitValid.js'\nimport type { EthereumStepExecutorContext } from '../../types.js'\nimport { getDomainChainId } from '../../utils/getDomainChainId.js'\nimport { assertValidSignature } from '../../utils/isValidSignature.js'\nimport { signHyperliquidTypedData } from './helpers/signHyperliquidTypedData.js'\n\nexport class EthereumRelayedSignAndExecuteTask extends BaseStepExecutionTask {\n async run(context: EthereumStepExecutorContext): Promise<TaskResult> {\n const {\n step,\n fromChain,\n client,\n statusManager,\n allowUserInteraction,\n checkClient,\n isBridgeExecution,\n signedTypedData: currentSignedTypedData,\n } = context\n\n const signedTypedData = [...currentSignedTypedData]\n\n const action = statusManager.findAction(\n step,\n isBridgeExecution ? 'CROSS_CHAIN' : 'SWAP'\n )\n\n if (!action) {\n throw new TransactionError(\n LiFiErrorCode.TransactionUnprepared,\n 'Unable to prepare transaction. Action not found.'\n )\n }\n\n const intentTypedData = step.typedData?.filter(\n (typedData) =>\n !signedTypedData.some((signedPermit) =>\n isNativePermitValid(signedPermit, typedData)\n )\n )\n if (!intentTypedData?.length) {\n throw new TransactionError(\n LiFiErrorCode.TransactionUnprepared,\n 'Unable to prepare transaction. Typed data for transfer is not found.'\n )\n }\n\n statusManager.updateAction(step, action.type, 'MESSAGE_REQUIRED')\n\n if (isHyperliquidAgentStep(step)) {\n const signedResults = await signHyperliquidTypedData(\n context,\n intentTypedData\n )\n\n if (!signedResults) {\n return { status: 'PAUSED' }\n }\n\n signedTypedData.push(...signedResults)\n } else {\n for (const typedData of intentTypedData) {\n if (!allowUserInteraction) {\n return { status: 'PAUSED' }\n }\n\n const typedDataChainId =\n getDomainChainId(typedData.domain) || fromChain.id\n\n // Switch to the typed data's chain if needed\n const updatedClient = await checkClient(step, typedDataChainId)\n if (!updatedClient) {\n return { status: 'PAUSED' }\n }\n\n const signature = await getAction(\n updatedClient,\n signTypedData,\n 'signTypedData'\n )({\n account: updatedClient.account!,\n primaryType: typedData.primaryType,\n domain: typedData.domain,\n types: typedData.types,\n message: typedData.message,\n })\n\n assertValidSignature(signature)\n\n signedTypedData.push({\n ...typedData,\n signature: signature,\n })\n }\n }\n\n statusManager.updateAction(step, action.type, 'PENDING')\n\n const { execution, ...stepBase } = step\n const relayedTransaction = await relayTransaction(client, {\n ...stepBase,\n typedData: signedTypedData,\n })\n\n statusManager.updateAction(step, action.type, 'PENDING', {\n taskId: relayedTransaction.taskId as Hash,\n txType: 'relayed',\n txLink: relayedTransaction.txLink,\n signedAt: Date.now(),\n })\n\n return { status: 'COMPLETED', context: { signedTypedData } }\n }\n}\n"],"mappings":";;;;;;;;;;AAiBA,IAAa,oCAAb,cAAuDA,UAAAA,sBAAsB;CAC3E,MAAM,IAAI,SAA2D;EACnE,MAAM,EACJ,MACA,WACA,QACA,eACA,sBACA,aACA,mBACA,iBAAiB,2BACf;EAEJ,MAAM,kBAAkB,CAAC,GAAG,sBAAsB;EAElD,MAAM,SAAS,cAAc,WAC3B,MACA,oBAAoB,gBAAgB,MACtC;EAEA,IAAI,CAAC,QACH,MAAM,IAAIC,UAAAA,iBACRC,UAAAA,cAAc,uBACd,kDACF;EAGF,MAAM,kBAAkB,KAAK,WAAW,QACrC,cACC,CAAC,gBAAgB,MAAM,iBACrBC,oCAAAA,oBAAoB,cAAc,SAAS,CAC7C,CACJ;EACA,IAAI,CAAC,iBAAiB,QACpB,MAAM,IAAIF,UAAAA,iBACRC,UAAAA,cAAc,uBACd,sEACF;EAGF,cAAc,aAAa,MAAM,OAAO,MAAM,kBAAkB;EAEhE,IAAIE,2CAAAA,uBAAuB,IAAI,GAAG;GAChC,MAAM,gBAAgB,MAAMC,oDAAAA,yBAC1B,SACA,eACF;GAEA,IAAI,CAAC,eACH,OAAO,EAAE,QAAQ,SAAS;GAG5B,gBAAgB,KAAK,GAAG,aAAa;EACvC,OACE,KAAK,MAAM,aAAa,iBAAiB;GACvC,IAAI,CAAC,sBACH,OAAO,EAAE,QAAQ,SAAS;GAO5B,MAAM,gBAAgB,MAAM,YAAY,MAHtCC,+BAAAA,iBAAiB,UAAU,MAAM,KAAK,UAAU,EAGY;GAC9D,IAAI,CAAC,eACH,OAAO,EAAE,QAAQ,SAAS;GAG5B,MAAM,YAAY,OAAA,GAAA,WAAA,UAAA,CAChB,eACAC,aAAAA,eACA,eACF,CAAC,CAAC;IACA,SAAS,cAAc;IACvB,aAAa,UAAU;IACvB,QAAQ,UAAU;IAClB,OAAO,UAAU;IACjB,SAAS,UAAU;GACrB,CAAC;GAED,+BAAA,qBAAqB,SAAS;GAE9B,gBAAgB,KAAK;IACnB,GAAG;IACQ;GACb,CAAC;EACH;EAGF,cAAc,aAAa,MAAM,OAAO,MAAM,SAAS;EAEvD,MAAM,EAAE,WAAW,GAAG,aAAa;EACnC,MAAM,qBAAqB,OAAA,GAAA,UAAA,iBAAA,CAAuB,QAAQ;GACxD,GAAG;GACH,WAAW;EACb,CAAC;EAED,cAAc,aAAa,MAAM,OAAO,MAAM,WAAW;GACvD,QAAQ,mBAAmB;GAC3B,QAAQ;GACR,QAAQ,mBAAmB;GAC3B,UAAU,KAAK,IAAI;EACrB,CAAC;EAED,OAAO;GAAE,QAAQ;GAAa,SAAS,EAAE,gBAAgB;EAAE;CAC7D;AACF"}
@@ -1,6 +1,7 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  const require_core_tasks_helpers_isPermit2Supported = require("./helpers/isPermit2Supported.js");
3
3
  const require_utils_getDomainChainId = require("../../utils/getDomainChainId.js");
4
+ const require_utils_isValidSignature = require("../../utils/isValidSignature.js");
4
5
  const require_actions_resolveTransactionHash = require("../../actions/resolveTransactionHash.js");
5
6
  const require_core_tasks_helpers_getTxLink = require("./helpers/getTxLink.js");
6
7
  const require_permits_encodeNativePermitData = require("../../permits/encodeNativePermitData.js");
@@ -21,7 +22,7 @@ var EthereumStandardSignAndExecuteTask = class extends _lifi_sdk.BaseStepExecuti
21
22
  const updatedClient = await checkClient(step);
22
23
  if (!updatedClient) return { status: "PAUSED" };
23
24
  const permit2Supported = require_core_tasks_helpers_isPermit2Supported.isPermit2Supported(step, fromChain, isFromNativeToken, disableMessageSigning, "standard");
24
- const signedNativePermitTypedData = signedTypedData.find((p) => p.primaryType === "Permit" && require_utils_getDomainChainId.getDomainChainId(p.domain) === fromChain.id);
25
+ const signedNativePermitTypedData = signedTypedData.find((p) => p.primaryType === "Permit" && require_utils_getDomainChainId.getDomainChainId(p.domain) === fromChain.id && require_utils_isValidSignature.isValidSignature(p.signature));
25
26
  if (signedNativePermitTypedData) transactionRequest.data = require_permits_encodeNativePermitData.encodeNativePermitData(step.action.fromToken.address, BigInt(step.action.fromAmount), signedNativePermitTypedData.message.deadline, signedNativePermitTypedData.signature, transactionRequest.data);
26
27
  else if (permit2Supported) {
27
28
  statusManager.updateAction(step, action.type, "MESSAGE_REQUIRED");
@@ -1 +1 @@
1
- {"version":3,"file":"EthereumStandardSignAndExecuteTask.js","names":["BaseStepExecutionTask","TransactionError","LiFiErrorCode","isPermit2Supported","getDomainChainId","encodeNativePermitData","signPermit2Message","encodePermit2Data","estimateTransactionRequest","resolveTransactionHash","sendTransaction","convertExtendedChain","getTxLink"],"sources":["../../../../src/core/tasks/EthereumStandardSignAndExecuteTask.ts"],"sourcesContent":["import {\n BaseStepExecutionTask,\n LiFiErrorCode,\n type TaskResult,\n TransactionError,\n} from '@lifi/sdk'\nimport type { Address, Hex, SendTransactionParameters } from 'viem'\nimport { sendTransaction } from 'viem/actions'\nimport { getAction } from 'viem/utils'\nimport { resolveTransactionHash } from '../../actions/resolveTransactionHash.js'\nimport { encodeNativePermitData } from '../../permits/encodeNativePermitData.js'\nimport { encodePermit2Data } from '../../permits/encodePermit2Data.js'\nimport { signPermit2Message } from '../../permits/signPermit2Message.js'\nimport type { EthereumStepExecutorContext } from '../../types.js'\nimport { convertExtendedChain } from '../../utils/convertExtendedChain.js'\nimport { getDomainChainId } from '../../utils/getDomainChainId.js'\nimport { estimateTransactionRequest } from './helpers/estimateTransactionRequest.js'\nimport { getTxLink } from './helpers/getTxLink.js'\nimport { isPermit2Supported } from './helpers/isPermit2Supported.js'\n\nexport class EthereumStandardSignAndExecuteTask extends BaseStepExecutionTask {\n async run(context: EthereumStepExecutorContext): Promise<TaskResult> {\n const {\n step,\n client,\n fromChain,\n statusManager,\n isFromNativeToken,\n checkClient,\n transactionRequest,\n signedTypedData,\n allowUserInteraction,\n isBridgeExecution,\n disableMessageSigning,\n } = context\n\n if (!transactionRequest) {\n throw new TransactionError(\n LiFiErrorCode.TransactionUnprepared,\n 'Unable to prepare transaction. Transaction request is not found.'\n )\n }\n\n const action = statusManager.findAction(\n step,\n isBridgeExecution ? 'CROSS_CHAIN' : 'SWAP'\n )\n if (!action) {\n throw new TransactionError(\n LiFiErrorCode.TransactionUnprepared,\n 'Unable to prepare transaction. Action not found.'\n )\n }\n\n // Make sure that the chain is still correct\n const updatedClient = await checkClient(step)\n if (!updatedClient) {\n return { status: 'PAUSED' }\n }\n\n const permit2Supported = isPermit2Supported(\n step,\n fromChain,\n isFromNativeToken,\n disableMessageSigning,\n 'standard'\n )\n const signedNativePermitTypedData = signedTypedData.find(\n (p) =>\n p.primaryType === 'Permit' &&\n getDomainChainId(p.domain) === fromChain.id\n )\n if (signedNativePermitTypedData) {\n transactionRequest.data = encodeNativePermitData(\n step.action.fromToken.address as Address,\n BigInt(step.action.fromAmount),\n signedNativePermitTypedData.message.deadline,\n signedNativePermitTypedData.signature,\n transactionRequest.data as Hex\n )\n } else if (permit2Supported) {\n statusManager.updateAction(step, action.type, 'MESSAGE_REQUIRED')\n if (!allowUserInteraction) {\n return { status: 'PAUSED' }\n }\n const permit2Signature = await signPermit2Message(client, {\n client: updatedClient,\n chain: fromChain,\n tokenAddress: step.action.fromToken.address as Address,\n amount: BigInt(step.action.fromAmount),\n data: transactionRequest.data as Hex,\n })\n transactionRequest.data = encodePermit2Data(\n step.action.fromToken.address as Address,\n BigInt(step.action.fromAmount),\n permit2Signature.message.nonce,\n permit2Signature.message.deadline,\n transactionRequest.data as Hex,\n permit2Signature.signature\n )\n statusManager.updateAction(step, action.type, 'ACTION_REQUIRED')\n if (!allowUserInteraction) {\n return { status: 'PAUSED' }\n }\n }\n\n let finalTransactionRequest = transactionRequest\n if (signedNativePermitTypedData || permit2Supported) {\n // Target address should be the Permit2 proxy contract in case of native permit or Permit2\n finalTransactionRequest = {\n ...transactionRequest,\n to: fromChain.permit2Proxy as Address,\n }\n finalTransactionRequest = await estimateTransactionRequest(\n client,\n updatedClient,\n finalTransactionRequest\n )\n }\n\n const txHash = await getAction(\n updatedClient,\n sendTransaction,\n 'sendTransaction'\n )({\n to: finalTransactionRequest.to as Address,\n account: updatedClient.account!,\n data: finalTransactionRequest.data as Hex,\n value: finalTransactionRequest.value,\n gas: finalTransactionRequest.gas,\n gasPrice: finalTransactionRequest.gasPrice,\n maxFeePerGas: finalTransactionRequest.maxFeePerGas,\n maxPriorityFeePerGas: finalTransactionRequest.maxPriorityFeePerGas,\n chain: convertExtendedChain(fromChain),\n } as SendTransactionParameters)\n\n const resolvedTxHash = await resolveTransactionHash(\n client,\n updatedClient,\n txHash,\n fromChain.id\n )\n\n statusManager.updateAction(step, action.type, 'PENDING', {\n txHash: resolvedTxHash,\n txLink: getTxLink(fromChain, resolvedTxHash),\n txType: 'standard',\n signedAt: Date.now(),\n })\n\n return {\n status: 'COMPLETED',\n context: {\n transactionRequest: finalTransactionRequest,\n },\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;AAoBA,IAAa,qCAAb,cAAwDA,UAAAA,sBAAsB;CAC5E,MAAM,IAAI,SAA2D;EACnE,MAAM,EACJ,MACA,QACA,WACA,eACA,mBACA,aACA,oBACA,iBACA,sBACA,mBACA,0BACE;EAEJ,IAAI,CAAC,oBACH,MAAM,IAAIC,UAAAA,iBACRC,UAAAA,cAAc,uBACd,kEACF;EAGF,MAAM,SAAS,cAAc,WAC3B,MACA,oBAAoB,gBAAgB,MACtC;EACA,IAAI,CAAC,QACH,MAAM,IAAID,UAAAA,iBACRC,UAAAA,cAAc,uBACd,kDACF;EAIF,MAAM,gBAAgB,MAAM,YAAY,IAAI;EAC5C,IAAI,CAAC,eACH,OAAO,EAAE,QAAQ,SAAS;EAG5B,MAAM,mBAAmBC,8CAAAA,mBACvB,MACA,WACA,mBACA,uBACA,UACF;EACA,MAAM,8BAA8B,gBAAgB,MACjD,MACC,EAAE,gBAAgB,YAClBC,+BAAAA,iBAAiB,EAAE,MAAM,MAAM,UAAU,EAC7C;EACA,IAAI,6BACF,mBAAmB,OAAOC,uCAAAA,uBACxB,KAAK,OAAO,UAAU,SACtB,OAAO,KAAK,OAAO,UAAU,GAC7B,4BAA4B,QAAQ,UACpC,4BAA4B,WAC5B,mBAAmB,IACrB;OACK,IAAI,kBAAkB;GAC3B,cAAc,aAAa,MAAM,OAAO,MAAM,kBAAkB;GAChE,IAAI,CAAC,sBACH,OAAO,EAAE,QAAQ,SAAS;GAE5B,MAAM,mBAAmB,MAAMC,mCAAAA,mBAAmB,QAAQ;IACxD,QAAQ;IACR,OAAO;IACP,cAAc,KAAK,OAAO,UAAU;IACpC,QAAQ,OAAO,KAAK,OAAO,UAAU;IACrC,MAAM,mBAAmB;GAC3B,CAAC;GACD,mBAAmB,OAAOC,kCAAAA,kBACxB,KAAK,OAAO,UAAU,SACtB,OAAO,KAAK,OAAO,UAAU,GAC7B,iBAAiB,QAAQ,OACzB,iBAAiB,QAAQ,UACzB,mBAAmB,MACnB,iBAAiB,SACnB;GACA,cAAc,aAAa,MAAM,OAAO,MAAM,iBAAiB;GAC/D,IAAI,CAAC,sBACH,OAAO,EAAE,QAAQ,SAAS;EAE9B;EAEA,IAAI,0BAA0B;EAC9B,IAAI,+BAA+B,kBAAkB;GAEnD,0BAA0B;IACxB,GAAG;IACH,IAAI,UAAU;GAChB;GACA,0BAA0B,MAAMC,sDAAAA,2BAC9B,QACA,eACA,uBACF;EACF;EAkBA,MAAM,iBAAiB,MAAMC,uCAAAA,uBAC3B,QACA,eACA,OAAA,GAAA,WAAA,UAAA,CAlBA,eACAC,aAAAA,iBACA,iBACF,CAAC,CAAC;GACA,IAAI,wBAAwB;GAC5B,SAAS,cAAc;GACvB,MAAM,wBAAwB;GAC9B,OAAO,wBAAwB;GAC/B,KAAK,wBAAwB;GAC7B,UAAU,wBAAwB;GAClC,cAAc,wBAAwB;GACtC,sBAAsB,wBAAwB;GAC9C,OAAOC,mCAAAA,qBAAqB,SAAS;EACvC,CAA8B,GAM5B,UAAU,EACZ;EAEA,cAAc,aAAa,MAAM,OAAO,MAAM,WAAW;GACvD,QAAQ;GACR,QAAQC,qCAAAA,UAAU,WAAW,cAAc;GAC3C,QAAQ;GACR,UAAU,KAAK,IAAI;EACrB,CAAC;EAED,OAAO;GACL,QAAQ;GACR,SAAS,EACP,oBAAoB,wBACtB;EACF;CACF;AACF"}
1
+ {"version":3,"file":"EthereumStandardSignAndExecuteTask.js","names":["BaseStepExecutionTask","TransactionError","LiFiErrorCode","isPermit2Supported","getDomainChainId","isValidSignature","encodeNativePermitData","signPermit2Message","encodePermit2Data","estimateTransactionRequest","resolveTransactionHash","sendTransaction","convertExtendedChain","getTxLink"],"sources":["../../../../src/core/tasks/EthereumStandardSignAndExecuteTask.ts"],"sourcesContent":["import {\n BaseStepExecutionTask,\n LiFiErrorCode,\n type TaskResult,\n TransactionError,\n} from '@lifi/sdk'\nimport type { Address, Hex, SendTransactionParameters } from 'viem'\nimport { sendTransaction } from 'viem/actions'\nimport { getAction } from 'viem/utils'\nimport { resolveTransactionHash } from '../../actions/resolveTransactionHash.js'\nimport { encodeNativePermitData } from '../../permits/encodeNativePermitData.js'\nimport { encodePermit2Data } from '../../permits/encodePermit2Data.js'\nimport { signPermit2Message } from '../../permits/signPermit2Message.js'\nimport type { EthereumStepExecutorContext } from '../../types.js'\nimport { convertExtendedChain } from '../../utils/convertExtendedChain.js'\nimport { getDomainChainId } from '../../utils/getDomainChainId.js'\nimport { isValidSignature } from '../../utils/isValidSignature.js'\nimport { estimateTransactionRequest } from './helpers/estimateTransactionRequest.js'\nimport { getTxLink } from './helpers/getTxLink.js'\nimport { isPermit2Supported } from './helpers/isPermit2Supported.js'\n\nexport class EthereumStandardSignAndExecuteTask extends BaseStepExecutionTask {\n async run(context: EthereumStepExecutorContext): Promise<TaskResult> {\n const {\n step,\n client,\n fromChain,\n statusManager,\n isFromNativeToken,\n checkClient,\n transactionRequest,\n signedTypedData,\n allowUserInteraction,\n isBridgeExecution,\n disableMessageSigning,\n } = context\n\n if (!transactionRequest) {\n throw new TransactionError(\n LiFiErrorCode.TransactionUnprepared,\n 'Unable to prepare transaction. Transaction request is not found.'\n )\n }\n\n const action = statusManager.findAction(\n step,\n isBridgeExecution ? 'CROSS_CHAIN' : 'SWAP'\n )\n if (!action) {\n throw new TransactionError(\n LiFiErrorCode.TransactionUnprepared,\n 'Unable to prepare transaction. Action not found.'\n )\n }\n\n // Make sure that the chain is still correct\n const updatedClient = await checkClient(step)\n if (!updatedClient) {\n return { status: 'PAUSED' }\n }\n\n const permit2Supported = isPermit2Supported(\n step,\n fromChain,\n isFromNativeToken,\n disableMessageSigning,\n 'standard'\n )\n const signedNativePermitTypedData = signedTypedData.find(\n (p) =>\n p.primaryType === 'Permit' &&\n getDomainChainId(p.domain) === fromChain.id &&\n isValidSignature(p.signature)\n )\n if (signedNativePermitTypedData) {\n transactionRequest.data = encodeNativePermitData(\n step.action.fromToken.address as Address,\n BigInt(step.action.fromAmount),\n signedNativePermitTypedData.message.deadline,\n signedNativePermitTypedData.signature,\n transactionRequest.data as Hex\n )\n } else if (permit2Supported) {\n statusManager.updateAction(step, action.type, 'MESSAGE_REQUIRED')\n if (!allowUserInteraction) {\n return { status: 'PAUSED' }\n }\n const permit2Signature = await signPermit2Message(client, {\n client: updatedClient,\n chain: fromChain,\n tokenAddress: step.action.fromToken.address as Address,\n amount: BigInt(step.action.fromAmount),\n data: transactionRequest.data as Hex,\n })\n transactionRequest.data = encodePermit2Data(\n step.action.fromToken.address as Address,\n BigInt(step.action.fromAmount),\n permit2Signature.message.nonce,\n permit2Signature.message.deadline,\n transactionRequest.data as Hex,\n permit2Signature.signature\n )\n statusManager.updateAction(step, action.type, 'ACTION_REQUIRED')\n if (!allowUserInteraction) {\n return { status: 'PAUSED' }\n }\n }\n\n let finalTransactionRequest = transactionRequest\n if (signedNativePermitTypedData || permit2Supported) {\n // Target address should be the Permit2 proxy contract in case of native permit or Permit2\n finalTransactionRequest = {\n ...transactionRequest,\n to: fromChain.permit2Proxy as Address,\n }\n finalTransactionRequest = await estimateTransactionRequest(\n client,\n updatedClient,\n finalTransactionRequest\n )\n }\n\n const txHash = await getAction(\n updatedClient,\n sendTransaction,\n 'sendTransaction'\n )({\n to: finalTransactionRequest.to as Address,\n account: updatedClient.account!,\n data: finalTransactionRequest.data as Hex,\n value: finalTransactionRequest.value,\n gas: finalTransactionRequest.gas,\n gasPrice: finalTransactionRequest.gasPrice,\n maxFeePerGas: finalTransactionRequest.maxFeePerGas,\n maxPriorityFeePerGas: finalTransactionRequest.maxPriorityFeePerGas,\n chain: convertExtendedChain(fromChain),\n } as SendTransactionParameters)\n\n const resolvedTxHash = await resolveTransactionHash(\n client,\n updatedClient,\n txHash,\n fromChain.id\n )\n\n statusManager.updateAction(step, action.type, 'PENDING', {\n txHash: resolvedTxHash,\n txLink: getTxLink(fromChain, resolvedTxHash),\n txType: 'standard',\n signedAt: Date.now(),\n })\n\n return {\n status: 'COMPLETED',\n context: {\n transactionRequest: finalTransactionRequest,\n },\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;AAqBA,IAAa,qCAAb,cAAwDA,UAAAA,sBAAsB;CAC5E,MAAM,IAAI,SAA2D;EACnE,MAAM,EACJ,MACA,QACA,WACA,eACA,mBACA,aACA,oBACA,iBACA,sBACA,mBACA,0BACE;EAEJ,IAAI,CAAC,oBACH,MAAM,IAAIC,UAAAA,iBACRC,UAAAA,cAAc,uBACd,kEACF;EAGF,MAAM,SAAS,cAAc,WAC3B,MACA,oBAAoB,gBAAgB,MACtC;EACA,IAAI,CAAC,QACH,MAAM,IAAID,UAAAA,iBACRC,UAAAA,cAAc,uBACd,kDACF;EAIF,MAAM,gBAAgB,MAAM,YAAY,IAAI;EAC5C,IAAI,CAAC,eACH,OAAO,EAAE,QAAQ,SAAS;EAG5B,MAAM,mBAAmBC,8CAAAA,mBACvB,MACA,WACA,mBACA,uBACA,UACF;EACA,MAAM,8BAA8B,gBAAgB,MACjD,MACC,EAAE,gBAAgB,YAClBC,+BAAAA,iBAAiB,EAAE,MAAM,MAAM,UAAU,MACzCC,+BAAAA,iBAAiB,EAAE,SAAS,CAChC;EACA,IAAI,6BACF,mBAAmB,OAAOC,uCAAAA,uBACxB,KAAK,OAAO,UAAU,SACtB,OAAO,KAAK,OAAO,UAAU,GAC7B,4BAA4B,QAAQ,UACpC,4BAA4B,WAC5B,mBAAmB,IACrB;OACK,IAAI,kBAAkB;GAC3B,cAAc,aAAa,MAAM,OAAO,MAAM,kBAAkB;GAChE,IAAI,CAAC,sBACH,OAAO,EAAE,QAAQ,SAAS;GAE5B,MAAM,mBAAmB,MAAMC,mCAAAA,mBAAmB,QAAQ;IACxD,QAAQ;IACR,OAAO;IACP,cAAc,KAAK,OAAO,UAAU;IACpC,QAAQ,OAAO,KAAK,OAAO,UAAU;IACrC,MAAM,mBAAmB;GAC3B,CAAC;GACD,mBAAmB,OAAOC,kCAAAA,kBACxB,KAAK,OAAO,UAAU,SACtB,OAAO,KAAK,OAAO,UAAU,GAC7B,iBAAiB,QAAQ,OACzB,iBAAiB,QAAQ,UACzB,mBAAmB,MACnB,iBAAiB,SACnB;GACA,cAAc,aAAa,MAAM,OAAO,MAAM,iBAAiB;GAC/D,IAAI,CAAC,sBACH,OAAO,EAAE,QAAQ,SAAS;EAE9B;EAEA,IAAI,0BAA0B;EAC9B,IAAI,+BAA+B,kBAAkB;GAEnD,0BAA0B;IACxB,GAAG;IACH,IAAI,UAAU;GAChB;GACA,0BAA0B,MAAMC,sDAAAA,2BAC9B,QACA,eACA,uBACF;EACF;EAkBA,MAAM,iBAAiB,MAAMC,uCAAAA,uBAC3B,QACA,eACA,OAAA,GAAA,WAAA,UAAA,CAlBA,eACAC,aAAAA,iBACA,iBACF,CAAC,CAAC;GACA,IAAI,wBAAwB;GAC5B,SAAS,cAAc;GACvB,MAAM,wBAAwB;GAC9B,OAAO,wBAAwB;GAC/B,KAAK,wBAAwB;GAC7B,UAAU,wBAAwB;GAClC,cAAc,wBAAwB;GACtC,sBAAsB,wBAAwB;GAC9C,OAAOC,mCAAAA,qBAAqB,SAAS;EACvC,CAA8B,GAM5B,UAAU,EACZ;EAEA,cAAc,aAAa,MAAM,OAAO,MAAM,WAAW;GACvD,QAAQ;GACR,QAAQC,qCAAAA,UAAU,WAAW,cAAc;GAC3C,QAAQ;GACR,UAAU,KAAK,IAAI;EACrB,CAAC;EAED,OAAO;GACL,QAAQ;GACR,SAAS,EACP,oBAAoB,wBACtB;EACF;CACF;AACF"}
@@ -1,5 +1,6 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  const require_utils_getDomainChainId = require("../../../utils/getDomainChainId.js");
3
+ const require_utils_isValidSignature = require("../../../utils/isValidSignature.js");
3
4
  const require_hyperliquid_isHyperliquidAgentStep = require("../../../hyperliquid/isHyperliquidAgentStep.js");
4
5
  const require_hyperliquid_agentWallet = require("../../../hyperliquid/agentWallet.js");
5
6
  let viem_actions = require("viem/actions");
@@ -29,6 +30,7 @@ const signHyperliquidTypedData = async (context, intentTypedData) => {
29
30
  types: typedData.types,
30
31
  message
31
32
  });
33
+ require_utils_isValidSignature.assertValidSignature(signature);
32
34
  signedResults.push({
33
35
  ...typedData,
34
36
  message,
@@ -44,6 +46,7 @@ const signHyperliquidTypedData = async (context, intentTypedData) => {
44
46
  types: typedData.types,
45
47
  message: typedData.message
46
48
  });
49
+ require_utils_isValidSignature.assertValidSignature(signature);
47
50
  signedResults.push({
48
51
  ...typedData,
49
52
  signature
@@ -1 +1 @@
1
- {"version":3,"file":"signHyperliquidTypedData.js","names":["isApproveAgentMessage","getOrCreateAgentWallet","getDomainChainId","signTypedData","isApproveBuilderFeeMessage","isHyperliquidOrderMessage"],"sources":["../../../../../src/core/tasks/helpers/signHyperliquidTypedData.ts"],"sourcesContent":["import type { SignedTypedData, TypedData } from '@lifi/sdk'\nimport { signTypedData } from 'viem/actions'\nimport { getAction } from 'viem/utils'\nimport { getOrCreateAgentWallet } from '../../../hyperliquid/agentWallet.js'\nimport {\n isApproveAgentMessage,\n isApproveBuilderFeeMessage,\n isHyperliquidOrderMessage,\n} from '../../../hyperliquid/isHyperliquidAgentStep.js'\nimport type { EthereumStepExecutorContext } from '../../../types.js'\nimport { getDomainChainId } from '../../../utils/getDomainChainId.js'\n\nexport const signHyperliquidTypedData = async (\n context: EthereumStepExecutorContext,\n intentTypedData: TypedData[]\n): Promise<SignedTypedData[] | undefined> => {\n const {\n step,\n fromChain,\n client,\n allowUserInteraction,\n checkClient,\n ethereumClient,\n getStorage,\n } = context\n\n if (!allowUserInteraction) {\n return\n }\n\n const signedResults: SignedTypedData[] = []\n const ownerAddress = ethereumClient.account!.address\n const storage = getStorage(client)\n\n const approveMessage = intentTypedData.find(isApproveAgentMessage)\n const existingAgentAddress = approveMessage?.message.agentAddress as\n | string\n | undefined\n\n const {\n account: agentAccount,\n needsApproval,\n expiresAt,\n } = await getOrCreateAgentWallet(storage, ownerAddress, existingAgentAddress)\n\n for (const typedData of intentTypedData) {\n if (isApproveAgentMessage(typedData)) {\n if (!needsApproval) {\n continue\n }\n\n const message = {\n ...typedData.message,\n agentAddress: agentAccount.address.toLowerCase(),\n agentName: `${typedData.message.agentName} valid_until ${expiresAt}`,\n }\n const typedDataChainId =\n getDomainChainId(typedData.domain) || fromChain.id\n\n const updatedClient = await checkClient(step, typedDataChainId)\n if (!updatedClient) {\n return\n }\n\n const signature = await getAction(\n updatedClient,\n signTypedData,\n 'signTypedData'\n )({\n account: updatedClient.account!,\n primaryType: typedData.primaryType,\n domain: typedData.domain,\n types: typedData.types,\n message,\n })\n signedResults.push({ ...typedData, message, signature })\n } else if (isApproveBuilderFeeMessage(typedData)) {\n const typedDataChainId =\n getDomainChainId(typedData.domain) || fromChain.id\n\n const updatedClient = await checkClient(step, typedDataChainId)\n if (!updatedClient) {\n return\n }\n\n const signature = await getAction(\n updatedClient,\n signTypedData,\n 'signTypedData'\n )({\n account: updatedClient.account!,\n primaryType: typedData.primaryType,\n domain: typedData.domain,\n types: typedData.types,\n message: typedData.message,\n })\n signedResults.push({ ...typedData, signature })\n } else if (isHyperliquidOrderMessage(typedData)) {\n const signature = await agentAccount.signTypedData({\n domain: typedData.domain,\n types: typedData.types,\n primaryType: typedData.primaryType,\n message: typedData.message,\n })\n signedResults.push({ ...typedData, signature })\n }\n }\n\n return signedResults\n}\n"],"mappings":";;;;;;;AAYA,MAAa,2BAA2B,OACtC,SACA,oBAC2C;CAC3C,MAAM,EACJ,MACA,WACA,QACA,sBACA,aACA,gBACA,eACE;CAEJ,IAAI,CAAC,sBACH;CAGF,MAAM,gBAAmC,CAAC;CAC1C,MAAM,eAAe,eAAe,QAAS;CAC7C,MAAM,UAAU,WAAW,MAAM;CAGjC,MAAM,uBADiB,gBAAgB,KAAKA,2CAAAA,qBACF,CAAC,EAAE,QAAQ;CAIrD,MAAM,EACJ,SAAS,cACT,eACA,cACE,MAAMC,gCAAAA,uBAAuB,SAAS,cAAc,oBAAoB;CAE5E,KAAK,MAAM,aAAa,iBACtB,IAAID,2CAAAA,sBAAsB,SAAS,GAAG;EACpC,IAAI,CAAC,eACH;EAGF,MAAM,UAAU;GACd,GAAG,UAAU;GACb,cAAc,aAAa,QAAQ,YAAY;GAC/C,WAAW,GAAG,UAAU,QAAQ,UAAU,eAAe;EAC3D;EAIA,MAAM,gBAAgB,MAAM,YAAY,MAFtCE,+BAAAA,iBAAiB,UAAU,MAAM,KAAK,UAAU,EAEY;EAC9D,IAAI,CAAC,eACH;EAGF,MAAM,YAAY,OAAA,GAAA,WAAA,UAAA,CAChB,eACAC,aAAAA,eACA,eACF,CAAC,CAAC;GACA,SAAS,cAAc;GACvB,aAAa,UAAU;GACvB,QAAQ,UAAU;GAClB,OAAO,UAAU;GACjB;EACF,CAAC;EACD,cAAc,KAAK;GAAE,GAAG;GAAW;GAAS;EAAU,CAAC;CACzD,OAAO,IAAIC,2CAAAA,2BAA2B,SAAS,GAAG;EAIhD,MAAM,gBAAgB,MAAM,YAAY,MAFtCF,+BAAAA,iBAAiB,UAAU,MAAM,KAAK,UAAU,EAEY;EAC9D,IAAI,CAAC,eACH;EAGF,MAAM,YAAY,OAAA,GAAA,WAAA,UAAA,CAChB,eACAC,aAAAA,eACA,eACF,CAAC,CAAC;GACA,SAAS,cAAc;GACvB,aAAa,UAAU;GACvB,QAAQ,UAAU;GAClB,OAAO,UAAU;GACjB,SAAS,UAAU;EACrB,CAAC;EACD,cAAc,KAAK;GAAE,GAAG;GAAW;EAAU,CAAC;CAChD,OAAO,IAAIE,2CAAAA,0BAA0B,SAAS,GAAG;EAC/C,MAAM,YAAY,MAAM,aAAa,cAAc;GACjD,QAAQ,UAAU;GAClB,OAAO,UAAU;GACjB,aAAa,UAAU;GACvB,SAAS,UAAU;EACrB,CAAC;EACD,cAAc,KAAK;GAAE,GAAG;GAAW;EAAU,CAAC;CAChD;CAGF,OAAO;AACT"}
1
+ {"version":3,"file":"signHyperliquidTypedData.js","names":["isApproveAgentMessage","getOrCreateAgentWallet","getDomainChainId","signTypedData","isApproveBuilderFeeMessage","isHyperliquidOrderMessage"],"sources":["../../../../../src/core/tasks/helpers/signHyperliquidTypedData.ts"],"sourcesContent":["import type { SignedTypedData, TypedData } from '@lifi/sdk'\nimport { signTypedData } from 'viem/actions'\nimport { getAction } from 'viem/utils'\nimport { getOrCreateAgentWallet } from '../../../hyperliquid/agentWallet.js'\nimport {\n isApproveAgentMessage,\n isApproveBuilderFeeMessage,\n isHyperliquidOrderMessage,\n} from '../../../hyperliquid/isHyperliquidAgentStep.js'\nimport type { EthereumStepExecutorContext } from '../../../types.js'\nimport { getDomainChainId } from '../../../utils/getDomainChainId.js'\nimport { assertValidSignature } from '../../../utils/isValidSignature.js'\n\nexport const signHyperliquidTypedData = async (\n context: EthereumStepExecutorContext,\n intentTypedData: TypedData[]\n): Promise<SignedTypedData[] | undefined> => {\n const {\n step,\n fromChain,\n client,\n allowUserInteraction,\n checkClient,\n ethereumClient,\n getStorage,\n } = context\n\n if (!allowUserInteraction) {\n return\n }\n\n const signedResults: SignedTypedData[] = []\n const ownerAddress = ethereumClient.account!.address\n const storage = getStorage(client)\n\n const approveMessage = intentTypedData.find(isApproveAgentMessage)\n const existingAgentAddress = approveMessage?.message.agentAddress as\n | string\n | undefined\n\n const {\n account: agentAccount,\n needsApproval,\n expiresAt,\n } = await getOrCreateAgentWallet(storage, ownerAddress, existingAgentAddress)\n\n for (const typedData of intentTypedData) {\n if (isApproveAgentMessage(typedData)) {\n if (!needsApproval) {\n continue\n }\n\n const message = {\n ...typedData.message,\n agentAddress: agentAccount.address.toLowerCase(),\n agentName: `${typedData.message.agentName} valid_until ${expiresAt}`,\n }\n const typedDataChainId =\n getDomainChainId(typedData.domain) || fromChain.id\n\n const updatedClient = await checkClient(step, typedDataChainId)\n if (!updatedClient) {\n return\n }\n\n const signature = await getAction(\n updatedClient,\n signTypedData,\n 'signTypedData'\n )({\n account: updatedClient.account!,\n primaryType: typedData.primaryType,\n domain: typedData.domain,\n types: typedData.types,\n message,\n })\n assertValidSignature(signature)\n signedResults.push({ ...typedData, message, signature })\n } else if (isApproveBuilderFeeMessage(typedData)) {\n const typedDataChainId =\n getDomainChainId(typedData.domain) || fromChain.id\n\n const updatedClient = await checkClient(step, typedDataChainId)\n if (!updatedClient) {\n return\n }\n\n const signature = await getAction(\n updatedClient,\n signTypedData,\n 'signTypedData'\n )({\n account: updatedClient.account!,\n primaryType: typedData.primaryType,\n domain: typedData.domain,\n types: typedData.types,\n message: typedData.message,\n })\n assertValidSignature(signature)\n signedResults.push({ ...typedData, signature })\n } else if (isHyperliquidOrderMessage(typedData)) {\n const signature = await agentAccount.signTypedData({\n domain: typedData.domain,\n types: typedData.types,\n primaryType: typedData.primaryType,\n message: typedData.message,\n })\n signedResults.push({ ...typedData, signature })\n }\n }\n\n return signedResults\n}\n"],"mappings":";;;;;;;;AAaA,MAAa,2BAA2B,OACtC,SACA,oBAC2C;CAC3C,MAAM,EACJ,MACA,WACA,QACA,sBACA,aACA,gBACA,eACE;CAEJ,IAAI,CAAC,sBACH;CAGF,MAAM,gBAAmC,CAAC;CAC1C,MAAM,eAAe,eAAe,QAAS;CAC7C,MAAM,UAAU,WAAW,MAAM;CAGjC,MAAM,uBADiB,gBAAgB,KAAKA,2CAAAA,qBACF,CAAC,EAAE,QAAQ;CAIrD,MAAM,EACJ,SAAS,cACT,eACA,cACE,MAAMC,gCAAAA,uBAAuB,SAAS,cAAc,oBAAoB;CAE5E,KAAK,MAAM,aAAa,iBACtB,IAAID,2CAAAA,sBAAsB,SAAS,GAAG;EACpC,IAAI,CAAC,eACH;EAGF,MAAM,UAAU;GACd,GAAG,UAAU;GACb,cAAc,aAAa,QAAQ,YAAY;GAC/C,WAAW,GAAG,UAAU,QAAQ,UAAU,eAAe;EAC3D;EAIA,MAAM,gBAAgB,MAAM,YAAY,MAFtCE,+BAAAA,iBAAiB,UAAU,MAAM,KAAK,UAAU,EAEY;EAC9D,IAAI,CAAC,eACH;EAGF,MAAM,YAAY,OAAA,GAAA,WAAA,UAAA,CAChB,eACAC,aAAAA,eACA,eACF,CAAC,CAAC;GACA,SAAS,cAAc;GACvB,aAAa,UAAU;GACvB,QAAQ,UAAU;GAClB,OAAO,UAAU;GACjB;EACF,CAAC;EACD,+BAAA,qBAAqB,SAAS;EAC9B,cAAc,KAAK;GAAE,GAAG;GAAW;GAAS;EAAU,CAAC;CACzD,OAAO,IAAIC,2CAAAA,2BAA2B,SAAS,GAAG;EAIhD,MAAM,gBAAgB,MAAM,YAAY,MAFtCF,+BAAAA,iBAAiB,UAAU,MAAM,KAAK,UAAU,EAEY;EAC9D,IAAI,CAAC,eACH;EAGF,MAAM,YAAY,OAAA,GAAA,WAAA,UAAA,CAChB,eACAC,aAAAA,eACA,eACF,CAAC,CAAC;GACA,SAAS,cAAc;GACvB,aAAa,UAAU;GACvB,QAAQ,UAAU;GAClB,OAAO,UAAU;GACjB,SAAS,UAAU;EACrB,CAAC;EACD,+BAAA,qBAAqB,SAAS;EAC9B,cAAc,KAAK;GAAE,GAAG;GAAW;EAAU,CAAC;CAChD,OAAO,IAAIE,2CAAAA,0BAA0B,SAAS,GAAG;EAC/C,MAAM,YAAY,MAAM,aAAa,cAAc;GACjD,QAAQ,UAAU;GAClB,OAAO,UAAU;GACjB,aAAa,UAAU;GACvB,SAAS,UAAU;EACrB,CAAC;EACD,cAAc,KAAK;GAAE,GAAG;GAAW;EAAU,CAAC;CAChD;CAGF,OAAO;AACT"}
@@ -1,9 +1,11 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ const require_utils_isValidSignature = require("../utils/isValidSignature.js");
2
3
  //#region src/permits/isNativePermitValid.ts
3
4
  /**
4
5
  * Checks if an existing native permit is valid for the given requirements
5
6
  */
6
7
  const isNativePermitValid = (permit, typedData) => {
8
+ if (!require_utils_isValidSignature.isValidSignature(permit.signature)) return false;
7
9
  if (permit.primaryType !== "Permit") return false;
8
10
  if (Number(permit.domain.chainId) !== Number(typedData.domain.chainId) || permit.domain.salt && permit.domain.salt !== typedData.domain.salt) return false;
9
11
  const message = permit.message;
@@ -1 +1 @@
1
- {"version":3,"file":"isNativePermitValid.js","names":[],"sources":["../../../src/permits/isNativePermitValid.ts"],"sourcesContent":["import type { SignedTypedData, TypedData } from '@lifi/sdk'\n\n/**\n * Checks if an existing native permit is valid for the given requirements\n */\nexport const isNativePermitValid = (\n permit: SignedTypedData,\n typedData: TypedData\n): boolean => {\n // Only check native permits (EIP-2612)\n if (permit.primaryType !== 'Permit') {\n return false\n }\n\n // Check if the permit is for the correct chain\n if (\n Number(permit.domain.chainId) !== Number(typedData.domain.chainId) ||\n (permit.domain.salt && permit.domain.salt !== typedData.domain.salt)\n ) {\n return false\n }\n\n // Check if the permit message has the required fields\n const message = permit.message as any\n if (!message) {\n return false\n }\n\n // Check spender\n if (\n message.spender?.toLowerCase() !== typedData.message.spender?.toLowerCase()\n ) {\n return false\n }\n\n // Check owner\n if (message.owner?.toLowerCase() !== typedData.message.owner?.toLowerCase()) {\n return false\n }\n\n // Check amount (value field in native permits)\n const permitAmount = BigInt(message.value || 0)\n if (permitAmount < BigInt(typedData.message.value || 0)) {\n return false\n }\n\n // Check deadline (must have at least 5 minutes remaining)\n const deadlineTimestamp = parseInt(message.deadline || 0, 10)\n // Add 5 minutes bufferto the current timestamp\n const allowedTimestamp = Math.floor(Date.now() / 1000) + 5 * 60\n\n if (deadlineTimestamp <= allowedTimestamp) {\n return false\n }\n\n return true\n}\n"],"mappings":";;;;;AAKA,MAAa,uBACX,QACA,cACY;CAEZ,IAAI,OAAO,gBAAgB,UACzB,OAAO;CAIT,IACE,OAAO,OAAO,OAAO,OAAO,MAAM,OAAO,UAAU,OAAO,OAAO,KAChE,OAAO,OAAO,QAAQ,OAAO,OAAO,SAAS,UAAU,OAAO,MAE/D,OAAO;CAIT,MAAM,UAAU,OAAO;CACvB,IAAI,CAAC,SACH,OAAO;CAIT,IACE,QAAQ,SAAS,YAAY,MAAM,UAAU,QAAQ,SAAS,YAAY,GAE1E,OAAO;CAIT,IAAI,QAAQ,OAAO,YAAY,MAAM,UAAU,QAAQ,OAAO,YAAY,GACxE,OAAO;CAKT,IADqB,OAAO,QAAQ,SAAS,CAC9B,IAAI,OAAO,UAAU,QAAQ,SAAS,CAAC,GACpD,OAAO;CAQT,IAJ0B,SAAS,QAAQ,YAAY,GAAG,EAItC,KAFK,KAAK,MAAM,KAAK,IAAI,IAAI,GAAI,IAAI,KAGvD,OAAO;CAGT,OAAO;AACT"}
1
+ {"version":3,"file":"isNativePermitValid.js","names":["isValidSignature"],"sources":["../../../src/permits/isNativePermitValid.ts"],"sourcesContent":["import type { SignedTypedData, TypedData } from '@lifi/sdk'\nimport { isValidSignature } from '../utils/isValidSignature.js'\n\n/**\n * Checks if an existing native permit is valid for the given requirements\n */\nexport const isNativePermitValid = (\n permit: SignedTypedData,\n typedData: TypedData\n): boolean => {\n // Check if the permit has a usable signature\n if (!isValidSignature(permit.signature)) {\n return false\n }\n\n // Only check native permits (EIP-2612)\n if (permit.primaryType !== 'Permit') {\n return false\n }\n\n // Check if the permit is for the correct chain\n if (\n Number(permit.domain.chainId) !== Number(typedData.domain.chainId) ||\n (permit.domain.salt && permit.domain.salt !== typedData.domain.salt)\n ) {\n return false\n }\n\n // Check if the permit message has the required fields\n const message = permit.message as any\n if (!message) {\n return false\n }\n\n // Check spender\n if (\n message.spender?.toLowerCase() !== typedData.message.spender?.toLowerCase()\n ) {\n return false\n }\n\n // Check owner\n if (message.owner?.toLowerCase() !== typedData.message.owner?.toLowerCase()) {\n return false\n }\n\n // Check amount (value field in native permits)\n const permitAmount = BigInt(message.value || 0)\n if (permitAmount < BigInt(typedData.message.value || 0)) {\n return false\n }\n\n // Check deadline (must have at least 5 minutes remaining)\n const deadlineTimestamp = parseInt(message.deadline || 0, 10)\n // Add 5 minutes bufferto the current timestamp\n const allowedTimestamp = Math.floor(Date.now() / 1000) + 5 * 60\n\n if (deadlineTimestamp <= allowedTimestamp) {\n return false\n }\n\n return true\n}\n"],"mappings":";;;;;;AAMA,MAAa,uBACX,QACA,cACY;CAEZ,IAAI,CAACA,+BAAAA,iBAAiB,OAAO,SAAS,GACpC,OAAO;CAIT,IAAI,OAAO,gBAAgB,UACzB,OAAO;CAIT,IACE,OAAO,OAAO,OAAO,OAAO,MAAM,OAAO,UAAU,OAAO,OAAO,KAChE,OAAO,OAAO,QAAQ,OAAO,OAAO,SAAS,UAAU,OAAO,MAE/D,OAAO;CAIT,MAAM,UAAU,OAAO;CACvB,IAAI,CAAC,SACH,OAAO;CAIT,IACE,QAAQ,SAAS,YAAY,MAAM,UAAU,QAAQ,SAAS,YAAY,GAE1E,OAAO;CAIT,IAAI,QAAQ,OAAO,YAAY,MAAM,UAAU,QAAQ,OAAO,YAAY,GACxE,OAAO;CAKT,IADqB,OAAO,QAAQ,SAAS,CAC9B,IAAI,OAAO,UAAU,QAAQ,SAAS,CAAC,GACpD,OAAO;CAQT,IAJ0B,SAAS,QAAQ,YAAY,GAAG,EAItC,KAFK,KAAK,MAAM,KAAK,IAAI,IAAI,GAAI,IAAI,KAGvD,OAAO;CAGT,OAAO;AACT"}
@@ -1,4 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ const require_utils_isValidSignature = require("../utils/isValidSignature.js");
2
3
  const require_permits_getPermitTransferFromValues = require("./getPermitTransferFromValues.js");
3
4
  const require_permits_signatureTransfer = require("./signatureTransfer.js");
4
5
  let viem = require("viem");
@@ -31,6 +32,7 @@ async function signPermit2Message(client, params) {
31
32
  types: permitData.types,
32
33
  message: permitData.message
33
34
  });
35
+ require_utils_isValidSignature.assertValidSignature(signature);
34
36
  return {
35
37
  ...permitData,
36
38
  primaryType,
@@ -1 +1 @@
1
- {"version":3,"file":"signPermit2Message.js","names":["getPermitTransferFromValues","getPermitData","signTypedData"],"sources":["../../../src/permits/signPermit2Message.ts"],"sourcesContent":["import type { ExtendedChain, SDKClient, SignedTypedData } from '@lifi/sdk'\nimport type { Address, Client, Hex } from 'viem'\nimport { keccak256 } from 'viem'\nimport { signTypedData } from 'viem/actions'\nimport { getAction } from 'viem/utils'\nimport { getPermitTransferFromValues } from './getPermitTransferFromValues.js'\nimport { getPermitData } from './signatureTransfer.js'\n\ninterface SignPermit2MessageParams {\n client: Client\n chain: ExtendedChain\n tokenAddress: Address\n amount: bigint\n data: Hex\n witness?: boolean\n}\n\nexport async function signPermit2Message(\n client: SDKClient,\n params: SignPermit2MessageParams\n): Promise<SignedTypedData> {\n const {\n client: viemClient,\n chain,\n tokenAddress,\n amount,\n data,\n witness,\n } = params\n\n const permitTransferFrom = await getPermitTransferFromValues(\n client,\n viemClient,\n chain,\n tokenAddress,\n amount\n )\n\n // Create witness data for the LI.FI call\n const _witness = witness\n ? {\n witness: {\n diamondAddress: chain.diamondAddress as Address,\n diamondCalldataHash: keccak256(data),\n },\n witnessTypeName: 'LiFiCall',\n witnessType: {\n LiFiCall: [\n { name: 'diamondAddress', type: 'address' },\n { name: 'diamondCalldataHash', type: 'bytes32' },\n ],\n },\n }\n : undefined\n\n const permitData = getPermitData(\n permitTransferFrom,\n chain.permit2 as Address,\n chain.id,\n _witness\n )\n\n const primaryType = witness\n ? 'PermitWitnessTransferFrom'\n : 'PermitTransferFrom'\n\n const signature = await getAction(\n viemClient,\n signTypedData,\n 'signTypedData'\n )({\n account: viemClient.account!,\n primaryType,\n domain: permitData.domain,\n types: permitData.types,\n message: permitData.message,\n })\n\n return {\n ...permitData,\n primaryType,\n signature,\n }\n}\n"],"mappings":";;;;;;;AAiBA,eAAsB,mBACpB,QACA,QAC0B;CAC1B,MAAM,EACJ,QAAQ,YACR,OACA,cACA,QACA,MACA,YACE;CAEJ,MAAM,qBAAqB,MAAMA,4CAAAA,4BAC/B,QACA,YACA,OACA,cACA,MACF;CAGA,MAAM,WAAW,UACb;EACE,SAAS;GACP,gBAAgB,MAAM;GACtB,sBAAA,GAAA,KAAA,UAAA,CAA+B,IAAI;EACrC;EACA,iBAAiB;EACjB,aAAa,EACX,UAAU,CACR;GAAE,MAAM;GAAkB,MAAM;EAAU,GAC1C;GAAE,MAAM;GAAuB,MAAM;EAAU,CACjD,EACF;CACF,IACA,KAAA;CAEJ,MAAM,aAAaC,kCAAAA,cACjB,oBACA,MAAM,SACN,MAAM,IACN,QACF;CAEA,MAAM,cAAc,UAChB,8BACA;CAEJ,MAAM,YAAY,OAAA,GAAA,WAAA,UAAA,CAChB,YACAC,aAAAA,eACA,eACF,CAAC,CAAC;EACA,SAAS,WAAW;EACpB;EACA,QAAQ,WAAW;EACnB,OAAO,WAAW;EAClB,SAAS,WAAW;CACtB,CAAC;CAED,OAAO;EACL,GAAG;EACH;EACA;CACF;AACF"}
1
+ {"version":3,"file":"signPermit2Message.js","names":["getPermitTransferFromValues","getPermitData","signTypedData"],"sources":["../../../src/permits/signPermit2Message.ts"],"sourcesContent":["import type { ExtendedChain, SDKClient, SignedTypedData } from '@lifi/sdk'\nimport type { Address, Client, Hex } from 'viem'\nimport { keccak256 } from 'viem'\nimport { signTypedData } from 'viem/actions'\nimport { getAction } from 'viem/utils'\nimport { assertValidSignature } from '../utils/isValidSignature.js'\nimport { getPermitTransferFromValues } from './getPermitTransferFromValues.js'\nimport { getPermitData } from './signatureTransfer.js'\n\ninterface SignPermit2MessageParams {\n client: Client\n chain: ExtendedChain\n tokenAddress: Address\n amount: bigint\n data: Hex\n witness?: boolean\n}\n\nexport async function signPermit2Message(\n client: SDKClient,\n params: SignPermit2MessageParams\n): Promise<SignedTypedData> {\n const {\n client: viemClient,\n chain,\n tokenAddress,\n amount,\n data,\n witness,\n } = params\n\n const permitTransferFrom = await getPermitTransferFromValues(\n client,\n viemClient,\n chain,\n tokenAddress,\n amount\n )\n\n // Create witness data for the LI.FI call\n const _witness = witness\n ? {\n witness: {\n diamondAddress: chain.diamondAddress as Address,\n diamondCalldataHash: keccak256(data),\n },\n witnessTypeName: 'LiFiCall',\n witnessType: {\n LiFiCall: [\n { name: 'diamondAddress', type: 'address' },\n { name: 'diamondCalldataHash', type: 'bytes32' },\n ],\n },\n }\n : undefined\n\n const permitData = getPermitData(\n permitTransferFrom,\n chain.permit2 as Address,\n chain.id,\n _witness\n )\n\n const primaryType = witness\n ? 'PermitWitnessTransferFrom'\n : 'PermitTransferFrom'\n\n const signature = await getAction(\n viemClient,\n signTypedData,\n 'signTypedData'\n )({\n account: viemClient.account!,\n primaryType,\n domain: permitData.domain,\n types: permitData.types,\n message: permitData.message,\n })\n\n assertValidSignature(signature)\n\n return {\n ...permitData,\n primaryType,\n signature,\n }\n}\n"],"mappings":";;;;;;;;AAkBA,eAAsB,mBACpB,QACA,QAC0B;CAC1B,MAAM,EACJ,QAAQ,YACR,OACA,cACA,QACA,MACA,YACE;CAEJ,MAAM,qBAAqB,MAAMA,4CAAAA,4BAC/B,QACA,YACA,OACA,cACA,MACF;CAGA,MAAM,WAAW,UACb;EACE,SAAS;GACP,gBAAgB,MAAM;GACtB,sBAAA,GAAA,KAAA,UAAA,CAA+B,IAAI;EACrC;EACA,iBAAiB;EACjB,aAAa,EACX,UAAU,CACR;GAAE,MAAM;GAAkB,MAAM;EAAU,GAC1C;GAAE,MAAM;GAAuB,MAAM;EAAU,CACjD,EACF;CACF,IACA,KAAA;CAEJ,MAAM,aAAaC,kCAAAA,cACjB,oBACA,MAAM,SACN,MAAM,IACN,QACF;CAEA,MAAM,cAAc,UAChB,8BACA;CAEJ,MAAM,YAAY,OAAA,GAAA,WAAA,UAAA,CAChB,YACAC,aAAAA,eACA,eACF,CAAC,CAAC;EACA,SAAS,WAAW;EACpB;EACA,QAAQ,WAAW;EACnB,OAAO,WAAW;EAClB,SAAS,WAAW;CACtB,CAAC;CAED,+BAAA,qBAAqB,SAAS;CAE9B,OAAO;EACL,GAAG;EACH;EACA;CACF;AACF"}
@@ -0,0 +1,15 @@
1
+ import { Hex } from "viem";
2
+
3
+ //#region src/utils/isValidSignature.d.ts
4
+ /**
5
+ * Checks that a wallet-returned signature is a usable hex string.
6
+ * Some wallets can resolve `signTypedData` with a nullish or empty ('0x')
7
+ * value instead of rejecting.
8
+ * Signature length is intentionally not validated: 65-byte, EIP-2098 compact
9
+ * and arbitrary-length smart account (ERC-1271) signatures are all valid.
10
+ */
11
+ declare function isValidSignature(signature: Hex | null | undefined): signature is Hex;
12
+ declare function assertValidSignature(signature: Hex | null | undefined): asserts signature is Hex;
13
+ //#endregion
14
+ export { assertValidSignature, isValidSignature };
15
+ //# sourceMappingURL=isValidSignature.d.ts.map
@@ -0,0 +1,22 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ let _lifi_sdk = require("@lifi/sdk");
3
+ let viem = require("viem");
4
+ //#region src/utils/isValidSignature.ts
5
+ /**
6
+ * Checks that a wallet-returned signature is a usable hex string.
7
+ * Some wallets can resolve `signTypedData` with a nullish or empty ('0x')
8
+ * value instead of rejecting.
9
+ * Signature length is intentionally not validated: 65-byte, EIP-2098 compact
10
+ * and arbitrary-length smart account (ERC-1271) signatures are all valid.
11
+ */
12
+ function isValidSignature(signature) {
13
+ return (0, viem.isHex)(signature) && signature !== "0x";
14
+ }
15
+ function assertValidSignature(signature) {
16
+ if (!isValidSignature(signature)) throw new _lifi_sdk.TransactionError(_lifi_sdk.LiFiErrorCode.SignatureRejected, "Wallet did not return a valid signature.");
17
+ }
18
+ //#endregion
19
+ exports.assertValidSignature = assertValidSignature;
20
+ exports.isValidSignature = isValidSignature;
21
+
22
+ //# sourceMappingURL=isValidSignature.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"isValidSignature.js","names":["TransactionError","LiFiErrorCode"],"sources":["../../../src/utils/isValidSignature.ts"],"sourcesContent":["import { LiFiErrorCode, TransactionError } from '@lifi/sdk'\nimport { type Hex, isHex } from 'viem'\n\n/**\n * Checks that a wallet-returned signature is a usable hex string.\n * Some wallets can resolve `signTypedData` with a nullish or empty ('0x')\n * value instead of rejecting.\n * Signature length is intentionally not validated: 65-byte, EIP-2098 compact\n * and arbitrary-length smart account (ERC-1271) signatures are all valid.\n */\nexport function isValidSignature(\n signature: Hex | null | undefined\n): signature is Hex {\n return isHex(signature) && signature !== '0x'\n}\n\nexport function assertValidSignature(\n signature: Hex | null | undefined\n): asserts signature is Hex {\n if (!isValidSignature(signature)) {\n throw new TransactionError(\n LiFiErrorCode.SignatureRejected,\n 'Wallet did not return a valid signature.'\n )\n }\n}\n"],"mappings":";;;;;;;;;;;AAUA,SAAgB,iBACd,WACkB;CAClB,QAAA,GAAA,KAAA,MAAA,CAAa,SAAS,KAAK,cAAc;AAC3C;AAEA,SAAgB,qBACd,WAC0B;CAC1B,IAAI,CAAC,iBAAiB,SAAS,GAC7B,MAAM,IAAIA,UAAAA,iBACRC,UAAAA,cAAc,mBACd,0CACF;AAEJ"}
@@ -1,6 +1,6 @@
1
1
  //#region src/version.d.ts
2
2
  declare const name = "@lifi/sdk-provider-ethereum";
3
- declare const version = "4.0.3";
3
+ declare const version = "4.0.5";
4
4
  //#endregion
5
5
  export { name, version };
6
6
  //# sourceMappingURL=version.d.ts.map
@@ -1,7 +1,7 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  //#region src/version.ts
3
3
  const name = "@lifi/sdk-provider-ethereum";
4
- const version = "4.0.3";
4
+ const version = "4.0.5";
5
5
  //#endregion
6
6
  exports.name = name;
7
7
  exports.version = version;
@@ -1 +1 @@
1
- {"version":3,"file":"version.js","names":[],"sources":["../../src/version.ts"],"sourcesContent":["export const name = '@lifi/sdk-provider-ethereum'\nexport const version = '4.0.3'\n"],"mappings":";;AAAA,MAAa,OAAO;AACpB,MAAa,UAAU"}
1
+ {"version":3,"file":"version.js","names":[],"sources":["../../src/version.ts"],"sourcesContent":["export const name = '@lifi/sdk-provider-ethereum'\nexport const version = '4.0.5'\n"],"mappings":";;AAAA,MAAa,OAAO;AACpB,MAAa,UAAU"}
@@ -47,7 +47,8 @@ const getAllowanceMulticall = async (client, viemClient, chainId, tokens, ownerA
47
47
  */
48
48
  const getTokenAllowance = async (client, token, ownerAddress, spenderAddress) => {
49
49
  if (isZeroAddress(token.address)) return;
50
- return await getAllowance(client, await getPublicClient(client, token.chainId), token.address, ownerAddress, spenderAddress);
50
+ const viemClient = await getPublicClient(client, token.chainId);
51
+ return await getAllowance(client, viemClient, token.address, ownerAddress, spenderAddress);
51
52
  };
52
53
  /**
53
54
  * Get the current allowance for a list of token/spender address pairs.
@@ -65,7 +66,8 @@ const getTokenAllowanceMulticall = async (client, ownerAddress, tokens) => {
65
66
  }
66
67
  const chainKeys = Object.keys(tokenDataByChain).map(Number.parseInt);
67
68
  return (await Promise.all(chainKeys.map(async (chainId) => {
68
- return getAllowanceMulticall(client, await getPublicClient(client, chainId), chainId, tokenDataByChain[chainId], ownerAddress);
69
+ const viemClient = await getPublicClient(client, chainId);
70
+ return getAllowanceMulticall(client, viemClient, chainId, tokenDataByChain[chainId], ownerAddress);
69
71
  }))).flat();
70
72
  };
71
73
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"getAllowance.js","names":[],"sources":["../../../src/actions/getAllowance.ts"],"sourcesContent":["import type { BaseToken, ChainId, SDKClient } from '@lifi/sdk'\nimport type { Address, Client } from 'viem'\nimport { multicall, readContract } from 'viem/actions'\nimport { getPublicClient } from '../client/publicClient.js'\nimport type {\n TokenAllowance,\n TokenSpender,\n TokenSpenderAllowance,\n} from '../types.js'\nimport { allowanceAbi } from '../utils/abi.js'\nimport { getActionWithFallback } from '../utils/getActionWithFallback.js'\nimport { isZeroAddress } from '../utils/isZeroAddress.js'\nimport { getMulticallAddress } from './getMulticallAddress.js'\n\nexport const getAllowance = async (\n client: SDKClient,\n viemClient: Client,\n tokenAddress: Address,\n ownerAddress: Address,\n spenderAddress: Address\n): Promise<bigint> => {\n try {\n const approved = await getActionWithFallback(\n client,\n viemClient,\n readContract,\n 'readContract',\n {\n address: tokenAddress as Address,\n abi: allowanceAbi,\n functionName: 'allowance' as const,\n args: [ownerAddress, spenderAddress] as const,\n }\n )\n return approved as bigint\n } catch (_e) {\n return 0n\n }\n}\n\nexport const getAllowanceMulticall = async (\n client: SDKClient,\n viemClient: Client,\n chainId: ChainId,\n tokens: TokenSpender[],\n ownerAddress: Address\n): Promise<TokenSpenderAllowance[]> => {\n if (!tokens.length) {\n return []\n }\n const multicallAddress = await getMulticallAddress(client, chainId)\n if (!multicallAddress) {\n throw new Error(`No multicall address configured for chainId ${chainId}.`)\n }\n const contracts = tokens.map((token) => ({\n address: token.token.address as Address,\n abi: allowanceAbi,\n functionName: 'allowance',\n args: [ownerAddress, token.spenderAddress],\n }))\n\n const results = await getActionWithFallback(\n client,\n viemClient,\n multicall,\n 'multicall',\n {\n contracts,\n multicallAddress: multicallAddress as Address,\n }\n )\n\n if (!results.length) {\n throw new Error(\n `Couldn't load allowance from chainId ${chainId} using multicall.`\n )\n }\n\n return tokens.map(({ token, spenderAddress }, i: number) => ({\n token,\n spenderAddress,\n allowance: results[i].result as bigint,\n }))\n}\n\n/**\n * Get the current allowance for a certain token.\n * @param client - The SDK client\n * @param token - The token that should be checked\n * @param ownerAddress - The owner of the token\n * @param spenderAddress - The spender address that has to be approved\n * @returns Returns allowance\n */\nexport const getTokenAllowance = async (\n client: SDKClient,\n token: BaseToken,\n ownerAddress: Address,\n spenderAddress: Address\n): Promise<bigint | undefined> => {\n // native token don't need approval\n if (isZeroAddress(token.address)) {\n return\n }\n\n const viemClient = await getPublicClient(client, token.chainId)\n\n const approved = await getAllowance(\n client,\n viemClient,\n token.address as Address,\n ownerAddress,\n spenderAddress\n )\n return approved\n}\n\n/**\n * Get the current allowance for a list of token/spender address pairs.\n * @param client - The SDK client\n * @param ownerAddress - The owner of the tokens\n * @param tokens - A list of token and spender address pairs\n * @returns Returns array of tokens and their allowance\n */\nexport const getTokenAllowanceMulticall = async (\n client: SDKClient,\n ownerAddress: Address,\n tokens: TokenSpender[]\n): Promise<TokenAllowance[]> => {\n // filter out native tokens\n const filteredTokens = tokens.filter(\n ({ token }) => !isZeroAddress(token.address)\n )\n\n // group by chain\n const tokenDataByChain: { [chainId: number]: TokenSpender[] } = {}\n for (const data of filteredTokens) {\n if (!tokenDataByChain[data.token.chainId]) {\n tokenDataByChain[data.token.chainId] = []\n }\n tokenDataByChain[data.token.chainId].push(data)\n }\n\n const chainKeys = Object.keys(tokenDataByChain).map(Number.parseInt)\n\n const allowances = (\n await Promise.all(\n chainKeys.map(async (chainId) => {\n const viemClient = await getPublicClient(client, chainId)\n // get allowances for current chain and token list\n return getAllowanceMulticall(\n client,\n viemClient,\n chainId,\n tokenDataByChain[chainId],\n ownerAddress\n )\n })\n )\n ).flat()\n\n return allowances\n}\n"],"mappings":";;;;;;;AAcA,MAAa,eAAe,OAC1B,QACA,YACA,cACA,cACA,mBACoB;CACpB,IAAI;EAaF,OAAO,MAZgB,sBACrB,QACA,YACA,cACA,gBACA;GACE,SAAS;GACT,KAAK;GACL,cAAc;GACd,MAAM,CAAC,cAAc,cAAc;EACrC,CACF;CAEF,SAAS,IAAI;EACX,OAAO;CACT;AACF;AAEA,MAAa,wBAAwB,OACnC,QACA,YACA,SACA,QACA,iBACqC;CACrC,IAAI,CAAC,OAAO,QACV,OAAO,CAAC;CAEV,MAAM,mBAAmB,MAAM,oBAAoB,QAAQ,OAAO;CAClE,IAAI,CAAC,kBACH,MAAM,IAAI,MAAM,+CAA+C,QAAQ,EAAE;CAS3E,MAAM,UAAU,MAAM,sBACpB,QACA,YACA,WACA,aACA;EACE,WAbc,OAAO,KAAK,WAAW;GACvC,SAAS,MAAM,MAAM;GACrB,KAAK;GACL,cAAc;GACd,MAAM,CAAC,cAAc,MAAM,cAAc;EAC3C,EAQY;EACU;CACpB,CACF;CAEA,IAAI,CAAC,QAAQ,QACX,MAAM,IAAI,MACR,wCAAwC,QAAQ,kBAClD;CAGF,OAAO,OAAO,KAAK,EAAE,OAAO,kBAAkB,OAAe;EAC3D;EACA;EACA,WAAW,QAAQ,EAAE,CAAC;CACxB,EAAE;AACJ;;;;;;;;;AAUA,MAAa,oBAAoB,OAC/B,QACA,OACA,cACA,mBACgC;CAEhC,IAAI,cAAc,MAAM,OAAO,GAC7B;CAYF,OAAO,MAPgB,aACrB,QACA,MAJuB,gBAAgB,QAAQ,MAAM,OAAO,GAK5D,MAAM,SACN,cACA,cACF;AAEF;;;;;;;;AASA,MAAa,6BAA6B,OACxC,QACA,cACA,WAC8B;CAE9B,MAAM,iBAAiB,OAAO,QAC3B,EAAE,YAAY,CAAC,cAAc,MAAM,OAAO,CAC7C;CAGA,MAAM,mBAA0D,CAAC;CACjE,KAAK,MAAM,QAAQ,gBAAgB;EACjC,IAAI,CAAC,iBAAiB,KAAK,MAAM,UAC/B,iBAAiB,KAAK,MAAM,WAAW,CAAC;EAE1C,iBAAiB,KAAK,MAAM,QAAQ,CAAC,KAAK,IAAI;CAChD;CAEA,MAAM,YAAY,OAAO,KAAK,gBAAgB,CAAC,CAAC,IAAI,OAAO,QAAQ;CAkBnE,QAfE,MAAM,QAAQ,IACZ,UAAU,IAAI,OAAO,YAAY;EAG/B,OAAO,sBACL,QACA,MAJuB,gBAAgB,QAAQ,OAAO,GAKtD,SACA,iBAAiB,UACjB,YACF;CACF,CAAC,CACH,EAAA,CACA,KAEc;AAClB"}
1
+ {"version":3,"file":"getAllowance.js","names":[],"sources":["../../../src/actions/getAllowance.ts"],"sourcesContent":["import type { BaseToken, ChainId, SDKClient } from '@lifi/sdk'\nimport type { Address, Client } from 'viem'\nimport { multicall, readContract } from 'viem/actions'\nimport { getPublicClient } from '../client/publicClient.js'\nimport type {\n TokenAllowance,\n TokenSpender,\n TokenSpenderAllowance,\n} from '../types.js'\nimport { allowanceAbi } from '../utils/abi.js'\nimport { getActionWithFallback } from '../utils/getActionWithFallback.js'\nimport { isZeroAddress } from '../utils/isZeroAddress.js'\nimport { getMulticallAddress } from './getMulticallAddress.js'\n\nexport const getAllowance = async (\n client: SDKClient,\n viemClient: Client,\n tokenAddress: Address,\n ownerAddress: Address,\n spenderAddress: Address\n): Promise<bigint> => {\n try {\n const approved = await getActionWithFallback(\n client,\n viemClient,\n readContract,\n 'readContract',\n {\n address: tokenAddress as Address,\n abi: allowanceAbi,\n functionName: 'allowance' as const,\n args: [ownerAddress, spenderAddress] as const,\n }\n )\n return approved as bigint\n } catch (_e) {\n return 0n\n }\n}\n\nexport const getAllowanceMulticall = async (\n client: SDKClient,\n viemClient: Client,\n chainId: ChainId,\n tokens: TokenSpender[],\n ownerAddress: Address\n): Promise<TokenSpenderAllowance[]> => {\n if (!tokens.length) {\n return []\n }\n const multicallAddress = await getMulticallAddress(client, chainId)\n if (!multicallAddress) {\n throw new Error(`No multicall address configured for chainId ${chainId}.`)\n }\n const contracts = tokens.map((token) => ({\n address: token.token.address as Address,\n abi: allowanceAbi,\n functionName: 'allowance',\n args: [ownerAddress, token.spenderAddress],\n }))\n\n const results = await getActionWithFallback(\n client,\n viemClient,\n multicall,\n 'multicall',\n {\n contracts,\n multicallAddress: multicallAddress as Address,\n }\n )\n\n if (!results.length) {\n throw new Error(\n `Couldn't load allowance from chainId ${chainId} using multicall.`\n )\n }\n\n return tokens.map(({ token, spenderAddress }, i: number) => ({\n token,\n spenderAddress,\n allowance: results[i].result as bigint,\n }))\n}\n\n/**\n * Get the current allowance for a certain token.\n * @param client - The SDK client\n * @param token - The token that should be checked\n * @param ownerAddress - The owner of the token\n * @param spenderAddress - The spender address that has to be approved\n * @returns Returns allowance\n */\nexport const getTokenAllowance = async (\n client: SDKClient,\n token: BaseToken,\n ownerAddress: Address,\n spenderAddress: Address\n): Promise<bigint | undefined> => {\n // native token don't need approval\n if (isZeroAddress(token.address)) {\n return\n }\n\n const viemClient = await getPublicClient(client, token.chainId)\n\n const approved = await getAllowance(\n client,\n viemClient,\n token.address as Address,\n ownerAddress,\n spenderAddress\n )\n return approved\n}\n\n/**\n * Get the current allowance for a list of token/spender address pairs.\n * @param client - The SDK client\n * @param ownerAddress - The owner of the tokens\n * @param tokens - A list of token and spender address pairs\n * @returns Returns array of tokens and their allowance\n */\nexport const getTokenAllowanceMulticall = async (\n client: SDKClient,\n ownerAddress: Address,\n tokens: TokenSpender[]\n): Promise<TokenAllowance[]> => {\n // filter out native tokens\n const filteredTokens = tokens.filter(\n ({ token }) => !isZeroAddress(token.address)\n )\n\n // group by chain\n const tokenDataByChain: { [chainId: number]: TokenSpender[] } = {}\n for (const data of filteredTokens) {\n if (!tokenDataByChain[data.token.chainId]) {\n tokenDataByChain[data.token.chainId] = []\n }\n tokenDataByChain[data.token.chainId].push(data)\n }\n\n const chainKeys = Object.keys(tokenDataByChain).map(Number.parseInt)\n\n const allowances = (\n await Promise.all(\n chainKeys.map(async (chainId) => {\n const viemClient = await getPublicClient(client, chainId)\n // get allowances for current chain and token list\n return getAllowanceMulticall(\n client,\n viemClient,\n chainId,\n tokenDataByChain[chainId],\n ownerAddress\n )\n })\n )\n ).flat()\n\n return allowances\n}\n"],"mappings":";;;;;;;AAcA,MAAa,eAAe,OAC1B,QACA,YACA,cACA,cACA,mBACoB;CACpB,IAAI;EAaF,OAAO,MAZgB,sBACrB,QACA,YACA,cACA,gBACA;GACE,SAAS;GACT,KAAK;GACL,cAAc;GACd,MAAM,CAAC,cAAc,cAAc;EACrC,CACF;CAEF,SAAS,IAAI;EACX,OAAO;CACT;AACF;AAEA,MAAa,wBAAwB,OACnC,QACA,YACA,SACA,QACA,iBACqC;CACrC,IAAI,CAAC,OAAO,QACV,OAAO,CAAC;CAEV,MAAM,mBAAmB,MAAM,oBAAoB,QAAQ,OAAO;CAClE,IAAI,CAAC,kBACH,MAAM,IAAI,MAAM,+CAA+C,QAAQ,EAAE;CAS3E,MAAM,UAAU,MAAM,sBACpB,QACA,YACA,WACA,aACA;EACE,WAbc,OAAO,KAAK,WAAW;GACvC,SAAS,MAAM,MAAM;GACrB,KAAK;GACL,cAAc;GACd,MAAM,CAAC,cAAc,MAAM,cAAc;EAC3C,EAQY;EACU;CACpB,CACF;CAEA,IAAI,CAAC,QAAQ,QACX,MAAM,IAAI,MACR,wCAAwC,QAAQ,kBAClD;CAGF,OAAO,OAAO,KAAK,EAAE,OAAO,kBAAkB,OAAe;EAC3D;EACA;EACA,WAAW,QAAQ,EAAE,CAAC;CACxB,EAAE;AACJ;;;;;;;;;AAUA,MAAa,oBAAoB,OAC/B,QACA,OACA,cACA,mBACgC;CAEhC,IAAI,cAAc,MAAM,OAAO,GAC7B;CAGF,MAAM,aAAa,MAAM,gBAAgB,QAAQ,MAAM,OAAO;CAS9D,OAAO,MAPgB,aACrB,QACA,YACA,MAAM,SACN,cACA,cACF;AAEF;;;;;;;;AASA,MAAa,6BAA6B,OACxC,QACA,cACA,WAC8B;CAE9B,MAAM,iBAAiB,OAAO,QAC3B,EAAE,YAAY,CAAC,cAAc,MAAM,OAAO,CAC7C;CAGA,MAAM,mBAA0D,CAAC;CACjE,KAAK,MAAM,QAAQ,gBAAgB;EACjC,IAAI,CAAC,iBAAiB,KAAK,MAAM,UAC/B,iBAAiB,KAAK,MAAM,WAAW,CAAC;EAE1C,iBAAiB,KAAK,MAAM,QAAQ,CAAC,KAAK,IAAI;CAChD;CAEA,MAAM,YAAY,OAAO,KAAK,gBAAgB,CAAC,CAAC,IAAI,OAAO,QAAQ;CAkBnE,QAfE,MAAM,QAAQ,IACZ,UAAU,IAAI,OAAO,YAAY;EAC/B,MAAM,aAAa,MAAM,gBAAgB,QAAQ,OAAO;EAExD,OAAO,sBACL,QACA,YACA,SACA,iBAAiB,UACjB,YACF;CACF,CAAC,CACH,EAAA,CACA,KAEc;AAClB"}
@@ -34,9 +34,10 @@ const getPublicClient = async (client, chainId) => {
34
34
  unsProxyReader: { address: unsProxyAddress }
35
35
  };
36
36
  }
37
+ const provider = client.getProvider(ChainType.EVM);
37
38
  publicClients[chainId] = createClient({
38
39
  chain,
39
- transport: fallback(fallbackTransports, client.getProvider(ChainType.EVM)?.options?.fallbackTransportConfig),
40
+ transport: fallback(fallbackTransports, provider?.options?.fallbackTransportConfig),
40
41
  batch: { multicall: true }
41
42
  });
42
43
  return publicClients[chainId];
@@ -1 +1 @@
1
- {"version":3,"file":"publicClient.js","names":[],"sources":["../../../src/client/publicClient.ts"],"sourcesContent":["import { ChainId, ChainType, type SDKClient } from '@lifi/sdk'\nimport type { Client } from 'viem'\nimport { type Address, createClient, fallback, http, webSocket } from 'viem'\nimport { type Chain, mainnet } from 'viem/chains'\nimport { UNS_PROXY_READER_ADDRESSES } from '../actions/constants.js'\nimport type { EthereumSDKProvider } from '../types.js'\n\n// cached providers\nconst publicClients: Record<number, Client> = {}\n\n/**\n * Get an instance of a provider for a specific chain\n * @param client - The SDK client\n * @param chainId - Id of the chain the provider is for\n * @returns The public client for the given chain\n */\nexport const getPublicClient = async (\n client: SDKClient,\n chainId: number\n): Promise<Client> => {\n if (publicClients[chainId]) {\n return publicClients[chainId]\n }\n\n const urls = await client.getRpcUrlsByChainId(chainId)\n const fallbackTransports = urls.map((url) =>\n url.startsWith('wss')\n ? webSocket(url)\n : http(url, {\n batch: {\n batchSize: 64,\n },\n })\n )\n const _chain = await client.getChainById(chainId)\n const chain: Chain = {\n ..._chain,\n ..._chain.metamask,\n name: _chain.metamask.chainName,\n rpcUrls: {\n default: { http: _chain.metamask.rpcUrls },\n public: { http: _chain.metamask.rpcUrls },\n },\n }\n // Add ENS contracts\n if (chain.id === ChainId.ETH) {\n chain.contracts = {\n ...mainnet.contracts,\n ...chain.contracts,\n }\n }\n\n // Add UNS contracts for supported chains\n if (chain.id === ChainId.ETH || chain.id === ChainId.POL) {\n const unsProxyAddress = UNS_PROXY_READER_ADDRESSES[chain.id]\n\n chain.contracts = {\n ...chain.contracts,\n unsProxyReader: { address: unsProxyAddress as Address },\n }\n }\n\n const provider = client.getProvider(ChainType.EVM) as\n | EthereumSDKProvider\n | undefined\n publicClients[chainId] = createClient({\n chain: chain,\n transport: fallback(\n fallbackTransports,\n provider?.options?.fallbackTransportConfig\n ),\n batch: {\n multicall: true,\n },\n })\n\n return publicClients[chainId]\n}\n"],"mappings":";;;;;AAQA,MAAM,gBAAwC,CAAC;;;;;;;AAQ/C,MAAa,kBAAkB,OAC7B,QACA,YACoB;CACpB,IAAI,cAAc,UAChB,OAAO,cAAc;CAIvB,MAAM,sBAAqB,MADR,OAAO,oBAAoB,OAAO,EAAA,CACrB,KAAK,QACnC,IAAI,WAAW,KAAK,IAChB,UAAU,GAAG,IACb,KAAK,KAAK,EACR,OAAO,EACL,WAAW,GACb,EACF,CAAC,CACP;CACA,MAAM,SAAS,MAAM,OAAO,aAAa,OAAO;CAChD,MAAM,QAAe;EACnB,GAAG;EACH,GAAG,OAAO;EACV,MAAM,OAAO,SAAS;EACtB,SAAS;GACP,SAAS,EAAE,MAAM,OAAO,SAAS,QAAQ;GACzC,QAAQ,EAAE,MAAM,OAAO,SAAS,QAAQ;EAC1C;CACF;CAEA,IAAI,MAAM,OAAO,QAAQ,KACvB,MAAM,YAAY;EAChB,GAAG,QAAQ;EACX,GAAG,MAAM;CACX;CAIF,IAAI,MAAM,OAAO,QAAQ,OAAO,MAAM,OAAO,QAAQ,KAAK;EACxD,MAAM,kBAAkB,2BAA2B,MAAM;EAEzD,MAAM,YAAY;GAChB,GAAG,MAAM;GACT,gBAAgB,EAAE,SAAS,gBAA2B;EACxD;CACF;CAKA,cAAc,WAAW,aAAa;EAC7B;EACP,WAAW,SACT,oBANa,OAAO,YAAY,UAAU,GAOnC,CAAC,EAAE,SAAS,uBACrB;EACA,OAAO,EACL,WAAW,KACb;CACF,CAAC;CAED,OAAO,cAAc;AACvB"}
1
+ {"version":3,"file":"publicClient.js","names":[],"sources":["../../../src/client/publicClient.ts"],"sourcesContent":["import { ChainId, ChainType, type SDKClient } from '@lifi/sdk'\nimport type { Client } from 'viem'\nimport { type Address, createClient, fallback, http, webSocket } from 'viem'\nimport { type Chain, mainnet } from 'viem/chains'\nimport { UNS_PROXY_READER_ADDRESSES } from '../actions/constants.js'\nimport type { EthereumSDKProvider } from '../types.js'\n\n// cached providers\nconst publicClients: Record<number, Client> = {}\n\n/**\n * Get an instance of a provider for a specific chain\n * @param client - The SDK client\n * @param chainId - Id of the chain the provider is for\n * @returns The public client for the given chain\n */\nexport const getPublicClient = async (\n client: SDKClient,\n chainId: number\n): Promise<Client> => {\n if (publicClients[chainId]) {\n return publicClients[chainId]\n }\n\n const urls = await client.getRpcUrlsByChainId(chainId)\n const fallbackTransports = urls.map((url) =>\n url.startsWith('wss')\n ? webSocket(url)\n : http(url, {\n batch: {\n batchSize: 64,\n },\n })\n )\n const _chain = await client.getChainById(chainId)\n const chain: Chain = {\n ..._chain,\n ..._chain.metamask,\n name: _chain.metamask.chainName,\n rpcUrls: {\n default: { http: _chain.metamask.rpcUrls },\n public: { http: _chain.metamask.rpcUrls },\n },\n }\n // Add ENS contracts\n if (chain.id === ChainId.ETH) {\n chain.contracts = {\n ...mainnet.contracts,\n ...chain.contracts,\n }\n }\n\n // Add UNS contracts for supported chains\n if (chain.id === ChainId.ETH || chain.id === ChainId.POL) {\n const unsProxyAddress = UNS_PROXY_READER_ADDRESSES[chain.id]\n\n chain.contracts = {\n ...chain.contracts,\n unsProxyReader: { address: unsProxyAddress as Address },\n }\n }\n\n const provider = client.getProvider(ChainType.EVM) as\n | EthereumSDKProvider\n | undefined\n publicClients[chainId] = createClient({\n chain: chain,\n transport: fallback(\n fallbackTransports,\n provider?.options?.fallbackTransportConfig\n ),\n batch: {\n multicall: true,\n },\n })\n\n return publicClients[chainId]\n}\n"],"mappings":";;;;;AAQA,MAAM,gBAAwC,CAAC;;;;;;;AAQ/C,MAAa,kBAAkB,OAC7B,QACA,YACoB;CACpB,IAAI,cAAc,UAChB,OAAO,cAAc;CAIvB,MAAM,sBAAqB,MADR,OAAO,oBAAoB,OAAO,EAAA,CACrB,KAAK,QACnC,IAAI,WAAW,KAAK,IAChB,UAAU,GAAG,IACb,KAAK,KAAK,EACR,OAAO,EACL,WAAW,GACb,EACF,CAAC,CACP;CACA,MAAM,SAAS,MAAM,OAAO,aAAa,OAAO;CAChD,MAAM,QAAe;EACnB,GAAG;EACH,GAAG,OAAO;EACV,MAAM,OAAO,SAAS;EACtB,SAAS;GACP,SAAS,EAAE,MAAM,OAAO,SAAS,QAAQ;GACzC,QAAQ,EAAE,MAAM,OAAO,SAAS,QAAQ;EAC1C;CACF;CAEA,IAAI,MAAM,OAAO,QAAQ,KACvB,MAAM,YAAY;EAChB,GAAG,QAAQ;EACX,GAAG,MAAM;CACX;CAIF,IAAI,MAAM,OAAO,QAAQ,OAAO,MAAM,OAAO,QAAQ,KAAK;EACxD,MAAM,kBAAkB,2BAA2B,MAAM;EAEzD,MAAM,YAAY;GAChB,GAAG,MAAM;GACT,gBAAgB,EAAE,SAAS,gBAA2B;EACxD;CACF;CAEA,MAAM,WAAW,OAAO,YAAY,UAAU,GAAG;CAGjD,cAAc,WAAW,aAAa;EAC7B;EACP,WAAW,SACT,oBACA,UAAU,SAAS,uBACrB;EACA,OAAO,EACL,WAAW,KACb;CACF,CAAC;CAED,OAAO,cAAc;AACvB"}
@@ -1 +1 @@
1
- {"version":3,"file":"EthereumCheckPermitsTask.d.ts","names":[],"sources":["../../../../src/core/tasks/EthereumCheckPermitsTask.ts"],"mappings":";;;;cAUa,wBAAA,SAAiC,qBAAA;EAAA,SAC7B,SAAA,CACb,OAAA,EAAS,2BAAA,GACR,OAAA;EAUH,GAAA,CAAU,OAAA,EAAS,2BAAA,GAA8B,OAAA,CAAQ,UAAA;AAAA"}
1
+ {"version":3,"file":"EthereumCheckPermitsTask.d.ts","names":[],"sources":["../../../../src/core/tasks/EthereumCheckPermitsTask.ts"],"mappings":";;;;cAWa,wBAAA,SAAiC,qBAAA;EAAA,SAC7B,SAAA,CACb,OAAA,EAAS,2BAAA,GACR,OAAA;EAUH,GAAA,CAAU,OAAA,EAAS,2BAAA,GAA8B,OAAA,CAAQ,UAAA;AAAA"}
@@ -1,4 +1,5 @@
1
1
  import { getDomainChainId } from "../../utils/getDomainChainId.js";
2
+ import { assertValidSignature } from "../../utils/isValidSignature.js";
2
3
  import { BaseStepExecutionTask } from "@lifi/sdk";
3
4
  import { signTypedData } from "viem/actions";
4
5
  import { getAction } from "viem/utils";
@@ -30,6 +31,7 @@ var EthereumCheckPermitsTask = class extends BaseStepExecutionTask {
30
31
  primaryType: typedData.primaryType,
31
32
  message: typedData.message
32
33
  });
34
+ assertValidSignature(signature);
33
35
  const signedPermit = {
34
36
  ...typedData,
35
37
  signature