@dynamic-labs-sdk/evm 1.3.0 → 1.5.0

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 (113) hide show
  1. package/dist/{addEIP6963Extension-6q4uKJ2S.cjs → addEIP6963Extension-C-2D7v76.cjs} +3 -3
  2. package/dist/{addEIP6963Extension-6q4uKJ2S.cjs.map → addEIP6963Extension-C-2D7v76.cjs.map} +1 -1
  3. package/dist/{addEIP6963Extension-C_IKf5DD.native.esm.js → addEIP6963Extension-CrpzqtkA.native.esm.js} +1 -1
  4. package/dist/{addEIP6963Extension-C_IKf5DD.native.esm.js.map → addEIP6963Extension-CrpzqtkA.native.esm.js.map} +1 -1
  5. package/dist/{addEIP6963Extension-CSo4PZ83.esm.js → addEIP6963Extension-Dt582bCZ.esm.js} +3 -3
  6. package/dist/{addEIP6963Extension-CSo4PZ83.esm.js.map → addEIP6963Extension-Dt582bCZ.esm.js.map} +1 -1
  7. package/dist/{addWaasEvmExtension-L8dUNmj8.native.esm.js → addWaasEvmExtension-CrLafMzM.native.esm.js} +3 -3
  8. package/dist/{addWaasEvmExtension-L8dUNmj8.native.esm.js.map → addWaasEvmExtension-CrLafMzM.native.esm.js.map} +1 -1
  9. package/dist/{addWaasEvmExtension-DTmPsJ-R.esm.js → addWaasEvmExtension-CzyCQ7fp.esm.js} +3 -3
  10. package/dist/{addWaasEvmExtension-DTmPsJ-R.esm.js.map → addWaasEvmExtension-CzyCQ7fp.esm.js.map} +1 -1
  11. package/dist/{addWaasEvmExtension-FyQx6Qlo.cjs → addWaasEvmExtension-D8O6IjQG.cjs} +3 -3
  12. package/dist/{addWaasEvmExtension-FyQx6Qlo.cjs.map → addWaasEvmExtension-D8O6IjQG.cjs.map} +1 -1
  13. package/dist/baseAccount.cjs +3 -3
  14. package/dist/baseAccount.esm.js +3 -3
  15. package/dist/baseAccount.native.esm.js +4 -4
  16. package/dist/{createWalletClientForWalletAccount-CKBR4V6M.cjs → createWalletClientForWalletAccount-CTDnbreU.cjs} +8 -2
  17. package/dist/{createWalletClientForWalletAccount-CKBR4V6M.cjs.map → createWalletClientForWalletAccount-CTDnbreU.cjs.map} +1 -1
  18. package/dist/{createWalletClientForWalletAccount-BotF25Kn.native.esm.js → createWalletClientForWalletAccount-CuakQYYA.native.esm.js} +2 -2
  19. package/dist/{createWalletClientForWalletAccount-BotF25Kn.native.esm.js.map → createWalletClientForWalletAccount-CuakQYYA.native.esm.js.map} +1 -1
  20. package/dist/{createWalletClientForWalletAccount-DRs8Ja_I.esm.js → createWalletClientForWalletAccount-CzeWTBwv.esm.js} +3 -3
  21. package/dist/{createWalletClientForWalletAccount-DRs8Ja_I.esm.js.map → createWalletClientForWalletAccount-CzeWTBwv.esm.js.map} +1 -1
  22. package/dist/{createWalletProviderFromEIP1193Provider-CWWLWjod.native.esm.js → createWalletProviderFromEIP1193Provider-B8doAYSi.native.esm.js} +2 -2
  23. package/dist/{createWalletProviderFromEIP1193Provider-CWWLWjod.native.esm.js.map → createWalletProviderFromEIP1193Provider-B8doAYSi.native.esm.js.map} +1 -1
  24. package/dist/{createWalletProviderFromEIP1193Provider-p3Aa46Bi.esm.js → createWalletProviderFromEIP1193Provider-Di6l7mjB.esm.js} +2 -2
  25. package/dist/{createWalletProviderFromEIP1193Provider-p3Aa46Bi.esm.js.map → createWalletProviderFromEIP1193Provider-Di6l7mjB.esm.js.map} +1 -1
  26. package/dist/{createWalletProviderFromEIP1193Provider-D-6PlGdy.cjs → createWalletProviderFromEIP1193Provider-_EtpThZ6.cjs} +2 -2
  27. package/dist/{createWalletProviderFromEIP1193Provider-D-6PlGdy.cjs.map → createWalletProviderFromEIP1193Provider-_EtpThZ6.cjs.map} +1 -1
  28. package/dist/eip6963.cjs +4 -4
  29. package/dist/eip6963.esm.js +4 -4
  30. package/dist/eip6963.native.esm.js +2 -2
  31. package/dist/evmTransferAmount-3m9QeANI.esm.js +875 -0
  32. package/dist/evmTransferAmount-3m9QeANI.esm.js.map +1 -0
  33. package/dist/evmTransferAmount-BQDSXSva.native.esm.js +875 -0
  34. package/dist/evmTransferAmount-BQDSXSva.native.esm.js.map +1 -0
  35. package/dist/evmTransferAmount-Bb1YvuCX.cjs +964 -0
  36. package/dist/evmTransferAmount-Bb1YvuCX.cjs.map +1 -0
  37. package/dist/exports/metamask.d.ts +6 -0
  38. package/dist/exports/metamask.d.ts.map +1 -0
  39. package/dist/gasless/relaySponsoredTransaction/relaySponsoredTransaction.d.ts +6 -0
  40. package/dist/gasless/relaySponsoredTransaction/relaySponsoredTransaction.d.ts.map +1 -1
  41. package/dist/gasless/sendSponsoredTransaction/sendSponsoredTransaction.d.ts +6 -0
  42. package/dist/gasless/sendSponsoredTransaction/sendSponsoredTransaction.d.ts.map +1 -1
  43. package/dist/gasless/signSponsoredTransaction/signSponsoredTransaction.d.ts +11 -1
  44. package/dist/gasless/signSponsoredTransaction/signSponsoredTransaction.d.ts.map +1 -1
  45. package/dist/index.cjs +15 -531
  46. package/dist/index.cjs.map +1 -1
  47. package/dist/index.esm.js +7 -523
  48. package/dist/index.esm.js.map +1 -1
  49. package/dist/index.native.esm.js +7 -523
  50. package/dist/index.native.esm.js.map +1 -1
  51. package/dist/metamask/connectAndVerifyWithMetaMaskUriEvm/connectAndVerifyWithMetaMaskUriEvm.d.ts +17 -0
  52. package/dist/metamask/connectAndVerifyWithMetaMaskUriEvm/connectAndVerifyWithMetaMaskUriEvm.d.ts.map +1 -0
  53. package/dist/metamask/connectAndVerifyWithMetaMaskUriEvm/index.d.ts +2 -0
  54. package/dist/metamask/connectAndVerifyWithMetaMaskUriEvm/index.d.ts.map +1 -0
  55. package/dist/metamask/connectWithMetaMaskUriEvm/connectWithMetaMaskUriEvm.d.ts +17 -0
  56. package/dist/metamask/connectWithMetaMaskUriEvm/connectWithMetaMaskUriEvm.d.ts.map +1 -0
  57. package/dist/metamask/connectWithMetaMaskUriEvm/index.d.ts +3 -0
  58. package/dist/metamask/connectWithMetaMaskUriEvm/index.d.ts.map +1 -0
  59. package/dist/metamask/createMetaMaskEvmWalletProvider/createMetaMaskEvmWalletProvider.d.ts +7 -12
  60. package/dist/metamask/createMetaMaskEvmWalletProvider/createMetaMaskEvmWalletProvider.d.ts.map +1 -1
  61. package/dist/metamask/createMetaMaskEvmWalletProvider/index.d.ts +0 -1
  62. package/dist/metamask/createMetaMaskEvmWalletProvider/index.d.ts.map +1 -1
  63. package/dist/metamask/getMetaMaskEvmExtensionWalletProviderKey/getMetaMaskEvmExtensionWalletProviderKey.d.ts +10 -0
  64. package/dist/metamask/getMetaMaskEvmExtensionWalletProviderKey/getMetaMaskEvmExtensionWalletProviderKey.d.ts.map +1 -0
  65. package/dist/metamask/getMetaMaskEvmExtensionWalletProviderKey/index.d.ts +2 -0
  66. package/dist/metamask/getMetaMaskEvmExtensionWalletProviderKey/index.d.ts.map +1 -0
  67. package/dist/metamask/metamask.types.d.ts +8 -36
  68. package/dist/metamask/metamask.types.d.ts.map +1 -1
  69. package/dist/metamask/utils/createMetaMaskEvmController/createMetaMaskEvmController.d.ts +5 -27
  70. package/dist/metamask/utils/createMetaMaskEvmController/createMetaMaskEvmController.d.ts.map +1 -1
  71. package/dist/metamask.cjs +317 -0
  72. package/dist/metamask.cjs.map +1 -0
  73. package/dist/metamask.esm.js +309 -0
  74. package/dist/metamask.esm.js.map +1 -0
  75. package/dist/metamask.native.esm.js +310 -0
  76. package/dist/metamask.native.esm.js.map +1 -0
  77. package/dist/{package-DGj3wg-e.native.esm.js → package-CVMy4p36.native.esm.js} +2 -2
  78. package/dist/package-CVMy4p36.native.esm.js.map +1 -0
  79. package/dist/tsconfig.lib.tsbuildinfo +1 -1
  80. package/dist/utils/evmExecuteSponsoredSwapTransaction/evmExecuteSponsoredSwapTransaction.d.ts +31 -0
  81. package/dist/utils/evmExecuteSponsoredSwapTransaction/evmExecuteSponsoredSwapTransaction.d.ts.map +1 -0
  82. package/dist/utils/evmExecuteSponsoredSwapTransaction/index.d.ts +2 -0
  83. package/dist/utils/evmExecuteSponsoredSwapTransaction/index.d.ts.map +1 -0
  84. package/dist/utils/evmExecuteSwapTransaction/evmExecuteSwapTransaction.d.ts +10 -6
  85. package/dist/utils/evmExecuteSwapTransaction/evmExecuteSwapTransaction.d.ts.map +1 -1
  86. package/dist/viem.cjs +1 -1
  87. package/dist/viem.esm.js +1 -1
  88. package/dist/viem.native.esm.js +2 -2
  89. package/dist/waas.cjs +3 -3
  90. package/dist/waas.esm.js +3 -3
  91. package/dist/waas.native.esm.js +4 -4
  92. package/dist/walletConnect.cjs +2 -2
  93. package/dist/walletConnect.esm.js +2 -2
  94. package/dist/walletConnect.native.esm.js +3 -3
  95. package/dist/windowInjected.cjs +3 -3
  96. package/dist/windowInjected.esm.js +3 -3
  97. package/dist/windowInjected.native.esm.js +4 -4
  98. package/package.json +10 -4
  99. package/dist/evmTransferAmount-BJswh1ID.esm.js +0 -289
  100. package/dist/evmTransferAmount-BJswh1ID.esm.js.map +0 -1
  101. package/dist/evmTransferAmount-BY0rW4dg.native.esm.js +0 -289
  102. package/dist/evmTransferAmount-BY0rW4dg.native.esm.js.map +0 -1
  103. package/dist/evmTransferAmount-CkF4KIge.cjs +0 -324
  104. package/dist/evmTransferAmount-CkF4KIge.cjs.map +0 -1
  105. package/dist/metamask/utils/clearMetaMaskEvmSessionStorage/clearMetaMaskEvmSessionStorage.d.ts +0 -34
  106. package/dist/metamask/utils/clearMetaMaskEvmSessionStorage/clearMetaMaskEvmSessionStorage.d.ts.map +0 -1
  107. package/dist/metamask/utils/clearMetaMaskEvmSessionStorage/index.d.ts +0 -2
  108. package/dist/metamask/utils/clearMetaMaskEvmSessionStorage/index.d.ts.map +0 -1
  109. package/dist/metamask/utils/isConnectShapedResponse/index.d.ts +0 -3
  110. package/dist/metamask/utils/isConnectShapedResponse/index.d.ts.map +0 -1
  111. package/dist/metamask/utils/isConnectShapedResponse/isConnectShapedResponse.d.ts +0 -21
  112. package/dist/metamask/utils/isConnectShapedResponse/isConnectShapedResponse.d.ts.map +0 -1
  113. package/dist/package-DGj3wg-e.native.esm.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"index.native.esm.js","names":["DELEGATION_CONTRACT_ADDRESS: Hex","BATCH_CALL_OPDATA_AUTH_MODE: Hex","data: { relayerAddress?: string }","getDefaultClient","getDefaultClient","getDefaultClient","getDefaultClient","data: { requestId?: string }","getDefaultClient","data: {\n errorMessage?: string;\n status: SponsoredTransactionStatus;\n transactionHash?: string;\n }","getDefaultClient","maxFeePerGas: bigint | undefined","maxPriorityFeePerGas: bigint | undefined","gasPrice: bigint | undefined","nativeAmount: bigint","feeData: EvmSimulationResult['feeData']","packageName","packageVersion"],"sources":["../src/errors/SponsorTransactionError/SponsorTransactionError.ts","../src/gasless/constants.ts","../src/gasless/generateRandomNonce/generateRandomNonce.ts","../src/gasless/generateIntentNonce/generateIntentNonce.ts","../src/gasless/getAvailableEvmGaslessRelayer/getAvailableEvmGaslessRelayer.ts","../src/gasless/create7702DelegationRegistry/create7702DelegationRegistry.ts","../src/gasless/get7702DelegationRegistry/get7702DelegationRegistry.ts","../src/gasless/is7702DelegationActive/is7702DelegationActive.ts","../src/gasless/resolveChainId/resolveChainId.ts","../src/gasless/sign7702Authorization/sign7702Authorization.ts","../src/gasless/resolveAuthorization/resolveAuthorization.ts","../src/gasless/toSerializedAuthorization/toSerializedAuthorization.ts","../src/gasless/signSponsoredTransaction/signSponsoredTransaction.ts","../src/gasless/relaySponsoredTransaction/relaySponsoredTransaction.ts","../src/gasless/getEVMSponsoredTransactionStatus/getEVMSponsoredTransactionStatus.ts","../src/gasless/waitForSponsoredTransaction/waitForSponsoredTransaction.ts","../src/gasless/sendSponsoredTransaction/sendSponsoredTransaction.ts","../src/gasless/activate7702Delegation/activate7702Delegation.ts","../src/addEvmExtension/addEvmExtension.ts","../src/errors/EvmGasSponsorshipNotEnabledError/EvmGasSponsorshipNotEnabledError.ts","../src/gasless/isEvmGasSponsorshipEnabled/isEvmGasSponsorshipEnabled.ts","../src/isEvmNetworkProvider/isEvmNetworkProvider.ts","../src/utils/calculateEvmTransactionFee/calculateEvmTransactionFee.ts","../src/simulateEvmTransaction/simulateEvmTransaction.ts","../src/exports/index.ts"],"sourcesContent":["import { BaseError } from '@dynamic-labs-sdk/client';\n\nexport class SponsorTransactionError extends BaseError {\n // eslint-disable-next-line custom-rules/require-single-object-param -- mirrors viem-style error constructors: (cause, details)\n constructor(cause?: Error | null, details?: string) {\n super({\n cause: cause ?? null,\n code: 'sponsor_transaction_error',\n details,\n docsUrl: null,\n name: 'SponsorTransactionError',\n shortMessage: 'Failed to sponsor EVM transaction',\n });\n }\n}\n","import type { Hex } from 'viem';\n\n/** The Fireblocks Universal Gasless Delegate (UGD) contract address used for EIP-7702 delegation. */\nexport const DELEGATION_CONTRACT_ADDRESS: Hex =\n '0x0000Fb7702036ff9f76044a501ac1aA74cbab16b';\n\n/** Default sponsored transaction validity duration in seconds (10 minutes). */\nexport const DEFAULT_VALID_FOR_SECONDS = 600;\n\n/** EIP-7702 delegation code prefix used to identify delegated accounts. */\nexport const DELEGATION_CODE_PREFIX = '0xef0100';\n\n/** ERC-7579 batch call with opData and auth mode identifier. */\nexport const BATCH_CALL_OPDATA_AUTH_MODE: Hex =\n '0x0100000000007821000100000000000000000000000000000000000000000000';\n\n/** EIP-712 typed data types for UGD AuthorizedExecutions signing. */\nexport const AUTHORIZED_EXECUTIONS_TYPES = {\n AuthorizedExecutions: [\n { name: 'calls', type: 'Execution[]' },\n { name: 'deadline', type: 'uint256' },\n { name: 'mode', type: 'bytes32' },\n { name: 'nonce', type: 'uint256' },\n { name: 'relayer', type: 'address' },\n ],\n Execution: [\n { name: 'target', type: 'address' },\n { name: 'value', type: 'uint256' },\n { name: 'data', type: 'bytes' },\n ],\n} as const;\n\n/** Minimal ABI for the UGD contract's nonce validation function. */\nexport const UGD_ABI = [\n {\n inputs: [{ name: 'nonce', type: 'uint256' }],\n name: 'isNonceUsed',\n outputs: [{ name: '', type: 'bool' }],\n stateMutability: 'view',\n type: 'function',\n },\n] as const;\n","/**\n * Generates a cryptographically random 256-bit nonce.\n *\n * @returns A random bigint nonce.\n * @not-instrumented\n */\nexport const generateRandomNonce = (): bigint => {\n const bytes = new Uint8Array(32);\n crypto.getRandomValues(bytes);\n\n return bytes.reduce((acc, byte) => (acc << 8n) | BigInt(byte), 0n);\n};\n","import type { DynamicClient } from '@dynamic-labs-sdk/client';\nimport { getActiveNetworkData } from '@dynamic-labs-sdk/client';\nimport { assertDefined } from '@dynamic-labs-sdk/client/core';\nimport type { Hex } from 'viem';\n\nimport type { EvmWalletAccount } from '../../EvmWalletAccount.types';\nimport { createPublicClientFromNetworkData } from '../../viem/createPublicClientFromNetworkData';\nimport { UGD_ABI } from '../constants';\nimport { generateRandomNonce } from '../generateRandomNonce';\n\ntype GenerateIntentNonceParams = {\n walletAccount: EvmWalletAccount;\n};\n\n/**\n * Generates a random bitmap nonce for UGD AuthorizedExecutions signing.\n *\n * Uses crypto.getRandomValues() for 256-bit randomness. Validates against\n * the on-chain isNonceUsed check as a safety measure, although collision\n * is essentially impossible with 256-bit random values.\n *\n * @param params.walletAccount - The wallet account whose delegation contract is checked.\n * @param [client] - The Dynamic client instance.\n * @returns A unique bigint nonce for the EIP-712 intent.\n * @not-instrumented\n */\nexport const generateIntentNonce = async (\n { walletAccount }: GenerateIntentNonceParams,\n client: DynamicClient\n): Promise<bigint> => {\n const nonce = generateRandomNonce();\n\n const { networkData } = await getActiveNetworkData(\n { walletAccount },\n client\n );\n\n assertDefined(\n networkData,\n `No network data found for wallet account ${walletAccount.address}`\n );\n\n const publicClient = createPublicClientFromNetworkData({ networkData });\n\n try {\n // Call isNonceUsed on the wallet address because UGD code is\n // delegated to the EOA via EIP-7702\n const isUsed = await publicClient.readContract({\n abi: UGD_ABI,\n address: walletAccount.address as Hex,\n args: [nonce],\n functionName: 'isNonceUsed',\n });\n\n if (isUsed) {\n return generateRandomNonce();\n }\n } catch {\n // Contract call may fail if delegation is not yet active —\n // the nonce is still safe to use since it was randomly generated\n }\n\n return nonce;\n};\n","import type { DynamicClient } from '@dynamic-labs-sdk/client';\nimport { createApiClient, getCore } from '@dynamic-labs-sdk/client/core';\nimport type { Hex } from 'viem';\n\nimport { SponsorTransactionError } from '../../errors/SponsorTransactionError';\n\ntype GetAvailableEvmGaslessRelayerParams = {\n /** The EVM chain ID the sponsored transaction will target. */\n chainId: number;\n};\n\ntype GetAvailableEvmGaslessRelayerResult = {\n /** Relayer EOA that will broadcast the sponsored transaction on-chain. */\n relayerAddress: Hex;\n};\n\n/**\n * Fetches the relayer address to embed in the EIP-712 sponsored-transaction\n * intent for the given chain.\n *\n * The returned address is owned by the project's relay backend and is the\n * eventual `from` of the on-chain broadcast. It must be set as the `relayer`\n * field of the EIP-712 intent before signing — the on-chain delegate validates\n * the signature against this address.\n *\n * @param params.chainId - The EVM chain ID the sponsored transaction targets.\n * @param client - The Dynamic client instance.\n * @returns The relayer address to embed in the EIP-712 intent.\n * @throws {SponsorTransactionError} If the API call fails or returns no relayer address.\n * @not-instrumented\n */\nexport const getAvailableEvmGaslessRelayer = async (\n { chainId }: GetAvailableEvmGaslessRelayerParams,\n client: DynamicClient,\n): Promise<GetAvailableEvmGaslessRelayerResult> => {\n const core = getCore(client);\n const apiClient = createApiClient({}, client);\n\n let data: { relayerAddress?: string };\n\n try {\n data = await apiClient.getAvailableEVMGaslessRelayer({\n chainId,\n environmentId: core.environmentId,\n });\n } catch (error) {\n const cause = error instanceof Error ? error : null;\n throw new SponsorTransactionError(cause);\n }\n\n if (!data.relayerAddress) {\n throw new SponsorTransactionError();\n }\n\n return { relayerAddress: data.relayerAddress as Hex };\n};\n","type Delegation7702Registry = {\n /** Returns true if delegation is known to be active for this wallet+chain. */\n isDelegated: (params: { chainId: number; walletAddress: string }) => boolean;\n /** Marks delegation as active for this wallet+chain. */\n markDelegated: (params: {\n chainId: number;\n walletAddress: string;\n }) => void;\n};\n\n/**\n * Creates an in-memory registry that tracks which wallet+chain combinations\n * have active EIP-7702 delegation. Only active delegations are cached —\n * a missing entry means the status is unknown and should be checked via RPC.\n *\n * @not-instrumented\n */\nexport const create7702DelegationRegistry = (): Delegation7702Registry => {\n const delegated = new Map<string, true>();\n\n const buildKey = ({\n chainId,\n walletAddress,\n }: {\n chainId: number;\n walletAddress: string;\n }): string => `${walletAddress.toLowerCase()}:${chainId}`;\n\n return {\n isDelegated: (params) => delegated.has(buildKey(params)),\n markDelegated: (params) => {\n delegated.set(buildKey(params), true);\n },\n };\n};\n\nexport type { Delegation7702Registry };\n","import { createRuntimeServiceAccessKey } from '@dynamic-labs-sdk/client/core';\n\nimport { create7702DelegationRegistry } from '../create7702DelegationRegistry';\n\n/**\n * Returns the per-client EIP-7702 delegation registry, creating it on first access.\n *\n * @not-instrumented\n */\nexport const get7702DelegationRegistry = createRuntimeServiceAccessKey(\n 'evm-7702-delegation-registry',\n () => create7702DelegationRegistry()\n);\n","import { getActiveNetworkData } from '@dynamic-labs-sdk/client';\nimport { assertDefined, getDefaultClient } from '@dynamic-labs-sdk/client/core';\nimport type { Hex } from 'viem';\n\nimport type { EvmWalletAccount } from '../../EvmWalletAccount.types';\nimport { createPublicClientFromNetworkData } from '../../viem/createPublicClientFromNetworkData';\nimport { mapNetworkDataToViemChain } from '../../viem/utils/mapNetworkDataToViemChain';\nimport {\n DELEGATION_CODE_PREFIX,\n DELEGATION_CONTRACT_ADDRESS,\n} from '../constants';\nimport { get7702DelegationRegistry } from '../get7702DelegationRegistry';\n\ntype Is7702DelegationActiveParams = {\n walletAccount: EvmWalletAccount;\n};\n\n/**\n * Checks whether EIP-7702 delegation to the Dynamic gasless contract is active\n * for the given wallet account on its current network.\n *\n * Results are cached per wallet+chain in an in-memory registry\n *\n * @param params.walletAccount - The EVM wallet account to check delegation status for.\n * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.\n * @returns True if the wallet has an active delegation to the gasless contract.\n * @not-instrumented\n */\nexport const is7702DelegationActive = async (\n { walletAccount }: Is7702DelegationActiveParams,\n client = getDefaultClient()\n): Promise<boolean> => {\n const { networkData } = await getActiveNetworkData({ walletAccount }, client);\n\n assertDefined(\n networkData,\n `No network data found for wallet account ${walletAccount.address}`\n );\n\n const chainId = mapNetworkDataToViemChain(networkData).id;\n const registry = get7702DelegationRegistry(client);\n\n if (registry.isDelegated({ chainId, walletAddress: walletAccount.address })) {\n return true;\n }\n\n const publicClient = createPublicClientFromNetworkData({ networkData });\n\n const bytecode = await publicClient.getCode({\n address: walletAccount.address as Hex,\n });\n\n if (!bytecode) {\n return false;\n }\n\n const expectedPrefix =\n DELEGATION_CODE_PREFIX + DELEGATION_CONTRACT_ADDRESS.slice(2).toLowerCase();\n\n const isActive = bytecode.toLowerCase().startsWith(expectedPrefix);\n\n if (isActive) {\n registry.markDelegated({ chainId, walletAddress: walletAccount.address });\n }\n\n return isActive;\n};\n","import { getActiveNetworkData } from '@dynamic-labs-sdk/client';\nimport { assertDefined } from '@dynamic-labs-sdk/client/core';\nimport type { DynamicClient } from '@dynamic-labs-sdk/client';\n\nimport type { EvmWalletAccount } from '../../EvmWalletAccount.types';\nimport { mapNetworkDataToViemChain } from '../../viem/utils/mapNetworkDataToViemChain';\n\ntype ResolveChainIdParams = {\n chainId?: number;\n walletAccount: EvmWalletAccount;\n};\n\n/**\n * Resolves a chain ID from either an explicit override or the wallet's active network.\n *\n * @param params.chainId - Explicit chain ID override.\n * @param params.walletAccount - The wallet account to resolve the chain from.\n * @param client - The Dynamic client instance.\n * @returns The resolved chain ID.\n * @not-instrumented\n */\nexport const resolveChainId = async (\n { chainId, walletAccount }: ResolveChainIdParams,\n client: DynamicClient\n): Promise<number> => {\n if (chainId !== undefined) {\n return chainId;\n }\n\n const { networkData } = await getActiveNetworkData(\n { walletAccount },\n client\n );\n\n assertDefined(\n networkData,\n `No network data found for wallet account ${walletAccount.address}`\n );\n\n return mapNetworkDataToViemChain(networkData).id;\n};\n","import { getDefaultClient } from '@dynamic-labs-sdk/client/core';\nimport type { SignAuthorizationReturnType } from 'viem/accounts';\nimport { signAuthorization } from 'viem/actions';\n\nimport type { EvmWalletAccount } from '../../EvmWalletAccount.types';\nimport { DELEGATION_CONTRACT_ADDRESS } from '../constants';\nimport { resolveChainId } from '../resolveChainId';\nimport { createWalletClientForWalletAccount } from '../../viem/createWalletClientForWalletAccount';\n\ntype Sign7702AuthorizationParams = {\n chainId?: number;\n walletAccount: EvmWalletAccount;\n};\n\n/**\n * Signs an EIP-7702 authorization to delegate the wallet to the Dynamic\n * gasless delegation contract.\n *\n * The signed authorization can be included in a sponsored transaction to\n * activate the delegation on-chain. If no chainId is provided, the wallet's\n * active network chain ID is used.\n *\n * @param params.walletAccount - The EVM wallet account to sign the authorization for.\n * @param [params.chainId] - Override chain ID. Defaults to the wallet's active network.\n * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.\n * @returns The signed EIP-7702 authorization.\n * @not-instrumented\n */\nexport const sign7702Authorization = async (\n { walletAccount, chainId }: Sign7702AuthorizationParams,\n client = getDefaultClient()\n): Promise<SignAuthorizationReturnType> => {\n const walletClient = await createWalletClientForWalletAccount(\n { walletAccount },\n client\n );\n\n const resolvedChainId = await resolveChainId(\n { chainId, walletAccount },\n client\n );\n\n return signAuthorization(walletClient, {\n chainId: resolvedChainId,\n contractAddress: DELEGATION_CONTRACT_ADDRESS,\n });\n};\n","import type { getDefaultClient } from '@dynamic-labs-sdk/client/core';\nimport type { SignAuthorizationReturnType } from 'viem/accounts';\n\nimport type { EvmWalletAccount } from '../../EvmWalletAccount.types';\nimport { is7702DelegationActive } from '../is7702DelegationActive';\nimport { sign7702Authorization } from '../sign7702Authorization';\n\ntype ResolveAuthorizationParams = {\n authorization?: SignAuthorizationReturnType;\n autoDelegate: boolean;\n walletAccount: EvmWalletAccount;\n};\n\n/**\n * Resolves the EIP-7702 authorization for a sponsored transaction.\n *\n * Returns the provided authorization if given, auto-signs one if needed\n * and autoDelegate is true, or returns undefined if the wallet is already\n * delegated or autoDelegate is false.\n *\n * @not-instrumented\n */\nexport const resolveAuthorization = async (\n {\n authorization,\n autoDelegate,\n walletAccount,\n }: ResolveAuthorizationParams,\n client: ReturnType<typeof getDefaultClient>\n): Promise<SignAuthorizationReturnType | undefined> => {\n // Explicit authorization always takes priority\n if (authorization) {\n return authorization;\n }\n\n // When autoDelegate is false, user manages delegation separately\n if (!autoDelegate) {\n return undefined;\n }\n\n // Auto-delegate: check if delegation is already active\n const isDelegated = await is7702DelegationActive({ walletAccount }, client);\n\n if (isDelegated) {\n return undefined;\n }\n\n return sign7702Authorization({ walletAccount }, client);\n};\n","import { assertDefined } from '@dynamic-labs-sdk/client/core';\nimport type { Hex } from 'viem';\nimport type { SignAuthorizationReturnType } from 'viem/accounts';\n\nimport type { SerializedAuthorization } from '../gasless.types';\n\n/**\n * Converts a viem SignAuthorizationReturnType into a plain serializable object\n * suitable for JSON transport to the sponsorship API.\n *\n * @not-instrumented\n */\nexport const toSerializedAuthorization = (\n auth: SignAuthorizationReturnType\n): SerializedAuthorization => {\n // viem's Signature type allows legacy v-only signatures without yParity.\n // Our signing flow should always produce yParity, but a wrong value would silently produce invalid authorizations.\n assertDefined(auth.yParity, 'Signed authorization is missing yParity');\n\n return {\n address: auth.address,\n chainId: auth.chainId,\n nonce: auth.nonce,\n r: auth.r as Hex,\n s: auth.s as Hex,\n yParity: auth.yParity,\n };\n};\n","import { getActiveNetworkData } from '@dynamic-labs-sdk/client';\nimport {\n assertDefined,\n getDefaultClient,\n} from '@dynamic-labs-sdk/client/core';\nimport type { Hex } from 'viem';\nimport type { SignAuthorizationReturnType } from 'viem/accounts';\n\nimport type { EvmWalletAccount } from '../../EvmWalletAccount.types';\nimport {\n AUTHORIZED_EXECUTIONS_TYPES,\n BATCH_CALL_OPDATA_AUTH_MODE,\n DEFAULT_VALID_FOR_SECONDS,\n DELEGATION_CONTRACT_ADDRESS,\n} from '../constants';\nimport { generateIntentNonce } from '../generateIntentNonce';\nimport { getAvailableEvmGaslessRelayer } from '../getAvailableEvmGaslessRelayer';\nimport { resolveAuthorization } from '../resolveAuthorization';\nimport { toSerializedAuthorization } from '../toSerializedAuthorization';\nimport type {\n SignedSponsoredTransaction,\n SponsoredTransactionCall,\n} from '../gasless.types';\nimport { createWalletClientForWalletAccount } from '../../viem/createWalletClientForWalletAccount';\nimport { mapNetworkDataToViemChain } from '../../viem/utils/mapNetworkDataToViemChain';\n\ntype SignSponsoredTransactionParams = {\n /** Pre-signed EIP-7702 authorization. Takes priority over autoDelegate. */\n authorization?: SignAuthorizationReturnType;\n /** Whether to automatically sign 7702 authorization if not delegated. Defaults to true. */\n autoDelegate?: boolean;\n /** The batch of calls to execute. */\n calls: SponsoredTransactionCall[];\n /** How long the signed intent remains valid, in seconds. Defaults to 600 (10 minutes). */\n validForSeconds?: number;\n /** The EVM wallet account to sign the transaction for. */\n walletAccount: EvmWalletAccount;\n};\n\n/**\n * Signs a sponsored transaction by creating an EIP-712 intent signature.\n *\n * This function handles the complete signing flow:\n * - If an authorization is provided, it is included in the payload.\n * - If autoDelegate is true (default) and no authorization is provided,\n * checks whether delegation is active and signs a 7702 authorization if needed.\n * - If autoDelegate is false and no authorization is provided, the intent\n * is signed without any authorization (user manages delegation separately).\n *\n * @param params.walletAccount - The EVM wallet account to sign with.\n * @param params.calls - The batch of calls to execute.\n * @param [params.authorization] - Pre-signed EIP-7702 authorization. Takes priority over autoDelegate.\n * @param [params.autoDelegate] - Whether to auto-sign 7702 if not delegated. Defaults to true.\n * @param [params.validForSeconds] - How long the signed intent remains valid, in seconds. Defaults to 600 (10 minutes).\n * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.\n * @returns The signed sponsored transaction payload ready to be sent to the API.\n * @not-instrumented\n */\nexport const signSponsoredTransaction = async (\n {\n walletAccount,\n calls,\n authorization,\n autoDelegate = true,\n validForSeconds = DEFAULT_VALID_FOR_SECONDS,\n }: SignSponsoredTransactionParams,\n client = getDefaultClient()\n): Promise<SignedSponsoredTransaction> => {\n const { networkData } = await getActiveNetworkData(\n { walletAccount },\n client\n );\n\n assertDefined(\n networkData,\n `No network data found for wallet account ${walletAccount.address}`\n );\n\n const resolvedAuthorization = await resolveAuthorization(\n { authorization, autoDelegate, walletAccount },\n client\n );\n\n const nonce = await generateIntentNonce({ walletAccount }, client);\n\n const deadline = BigInt(\n Math.floor(Date.now() / 1000) + validForSeconds\n );\n\n const chainId = mapNetworkDataToViemChain(networkData).id;\n\n const { relayerAddress } = await getAvailableEvmGaslessRelayer(\n { chainId },\n client\n );\n\n const walletClient = await createWalletClientForWalletAccount(\n { walletAccount },\n client\n );\n\n const signature = await walletClient.signTypedData({\n domain: {\n chainId,\n verifyingContract: DELEGATION_CONTRACT_ADDRESS,\n },\n message: {\n calls: calls.map((c) => ({\n data: c.data,\n target: c.target,\n value: c.value,\n })),\n deadline,\n mode: BATCH_CALL_OPDATA_AUTH_MODE,\n nonce,\n relayer: relayerAddress,\n },\n primaryType: 'AuthorizedExecutions',\n types: AUTHORIZED_EXECUTIONS_TYPES,\n });\n\n return {\n authorization: resolvedAuthorization\n ? toSerializedAuthorization(resolvedAuthorization)\n : undefined,\n calls,\n chainId,\n deadline: deadline.toString(),\n nonce: nonce.toString(),\n relayer: relayerAddress,\n signature: signature as Hex,\n walletAddress: walletAccount.address as Hex,\n };\n};\n","import {\n createApiClient,\n getCore,\n getDefaultClient,\n} from '@dynamic-labs-sdk/client/core';\nimport type { SignAuthorizationReturnType } from 'viem/accounts';\n\nimport type { EvmWalletAccount } from '../../EvmWalletAccount.types';\nimport { SponsorTransactionError } from '../../errors/SponsorTransactionError';\nimport { DEFAULT_VALID_FOR_SECONDS } from '../constants';\nimport type {\n SignedSponsoredTransaction,\n SponsoredTransactionCall,\n} from '../gasless.types';\nimport { signSponsoredTransaction } from '../signSponsoredTransaction';\n\ntype RelaySponsoredTransactionWithCallsParams = {\n /** Pre-signed EIP-7702 authorization. Takes priority over autoDelegate. */\n authorization?: SignAuthorizationReturnType;\n /** Whether to automatically sign 7702 authorization if not delegated. Defaults to true. */\n autoDelegate?: boolean;\n /** The batch of calls to execute. */\n calls: SponsoredTransactionCall[];\n /** How long the signed intent remains valid, in seconds. Defaults to 600 (10 minutes). */\n validForSeconds?: number;\n /** The EVM wallet account to sign and relay the transaction for. */\n walletAccount: EvmWalletAccount;\n};\n\ntype RelaySponsoredTransactionWithSignedTxParams = {\n /** A pre-signed sponsored transaction payload from signSponsoredTransaction. */\n signedTransaction: SignedSponsoredTransaction;\n};\n\ntype RelaySponsoredTransactionParams =\n | RelaySponsoredTransactionWithCallsParams\n | RelaySponsoredTransactionWithSignedTxParams;\n\nconst isSignedTransactionParams = (\n params: RelaySponsoredTransactionParams,\n): params is RelaySponsoredTransactionWithSignedTxParams =>\n 'signedTransaction' in params;\n\n/**\n * Relays a sponsored EVM transaction to the Dynamic backend.\n *\n * Accepts either a pre-signed transaction or unsigned calls. When given\n * unsigned calls, signs the transaction first via signSponsoredTransaction.\n *\n * The backend encodes the transaction, submits it to the relay provider,\n * and returns a request ID for tracking. The relay may retry the on-chain\n * submission, so the request ID (not a transaction hash) is the stable\n * identifier for the sponsored transaction.\n *\n * @param params - Either { signedTransaction } or { walletAccount, calls, ... }.\n * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.\n * @returns An object containing the request ID for tracking the relayed transaction.\n * @throws {SponsorTransactionError} If the API call fails or returns an unexpected response.\n * @not-instrumented\n */\nexport const relaySponsoredTransaction = async (\n params: RelaySponsoredTransactionParams,\n client = getDefaultClient(),\n): Promise<{ requestId: string }> => {\n const signedTransaction = isSignedTransactionParams(params)\n ? params.signedTransaction\n : await signSponsoredTransaction(\n {\n authorization: params.authorization,\n autoDelegate: params.autoDelegate,\n calls: params.calls,\n validForSeconds: params.validForSeconds ?? DEFAULT_VALID_FOR_SECONDS,\n walletAccount: params.walletAccount,\n },\n client,\n );\n\n const core = getCore(client);\n const apiClient = createApiClient({}, client);\n\n let data: { requestId?: string };\n\n try {\n data = await apiClient.sponsorEVMTransaction({\n environmentId: core.environmentId,\n sponsorEVMTransactionRequest: {\n authorization: signedTransaction.authorization,\n calls: signedTransaction.calls.map((c) => ({\n data: c.data,\n target: c.target,\n value: c.value.toString(),\n })),\n chainId: signedTransaction.chainId,\n deadline: signedTransaction.deadline,\n nonce: signedTransaction.nonce,\n relayer: signedTransaction.relayer,\n signature: signedTransaction.signature,\n walletAddress: signedTransaction.walletAddress,\n },\n });\n } catch (error) {\n const cause = error instanceof Error ? error : null;\n throw new SponsorTransactionError(cause);\n }\n\n if (!data.requestId) {\n throw new SponsorTransactionError();\n }\n\n return { requestId: data.requestId };\n};\n","import {\n createApiClient,\n getCore,\n getDefaultClient,\n} from '@dynamic-labs-sdk/client/core';\nimport type { Hex } from 'viem';\n\nimport { SponsorTransactionError } from '../../errors/SponsorTransactionError';\nimport type {\n SponsoredTransactionStatus,\n SponsoredTransactionStatusResult,\n} from '../gasless.types';\n\ntype GetEVMSponsoredTransactionStatusParams = {\n /** The request ID returned by `relaySponsoredTransaction` / `sendSponsoredTransaction`. */\n requestId: string;\n};\n\n/**\n * Fetches the current relay state for a sponsored EVM transaction.\n *\n * Returns the lifecycle status, the on-chain transaction hash (when the relay\n * has broadcast it), and any terminal-failure error message. Use this as the\n * building block for custom polling flows; for the common \"wait until done\"\n * case prefer `waitForSponsoredTransaction`.\n *\n * @param params.requestId - The request ID returned when the transaction was relayed.\n * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.\n * @returns The current status, optional transaction hash, and optional error message.\n * @throws {SponsorTransactionError} If the API call fails.\n * @not-instrumented\n */\nexport const getEVMSponsoredTransactionStatus = async (\n { requestId }: GetEVMSponsoredTransactionStatusParams,\n client = getDefaultClient(),\n): Promise<SponsoredTransactionStatusResult> => {\n const core = getCore(client);\n const apiClient = createApiClient({}, client);\n\n let data: {\n errorMessage?: string;\n status: SponsoredTransactionStatus;\n transactionHash?: string;\n };\n\n try {\n data = await apiClient.getEVMSponsoredTransactionStatus({\n environmentId: core.environmentId,\n requestId,\n });\n } catch (error) {\n const cause = error instanceof Error ? error : null;\n throw new SponsorTransactionError(cause);\n }\n\n return {\n errorMessage: data.errorMessage,\n status: data.status,\n transactionHash: data.transactionHash as Hex | undefined,\n };\n};\n","import { getDefaultClient } from '@dynamic-labs-sdk/client';\nimport type { Hex } from 'viem';\n\nimport { SponsorTransactionError } from '../../errors/SponsorTransactionError';\nimport type { SponsoredTransactionStatus } from '../gasless.types';\nimport { getEVMSponsoredTransactionStatus } from '../getEVMSponsoredTransactionStatus';\n\nconst POLL_INTERVAL_MS = 2_000;\nconst TIMEOUT_MS = 60_000;\nconst MAX_POLLING_ATTEMPTS = TIMEOUT_MS / POLL_INTERVAL_MS;\n\nconst TERMINAL_FAILURE_STATUSES = new Set<SponsoredTransactionStatus>([\n 'failure',\n]);\n\ntype WaitForSponsoredTransactionParams = {\n /** The request ID returned by `relaySponsoredTransaction` / `sendSponsoredTransaction`. */\n requestId: string;\n};\n\n/**\n * Polls `getEVMSponsoredTransactionStatus` until the relay reports the\n * transaction has been included on-chain, then returns the transaction hash.\n *\n * @param params.requestId - The request ID returned when the transaction was relayed.\n * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.\n * @returns An object containing the on-chain transaction hash.\n * @throws {SponsorTransactionError} If the relay returns a terminal failure or polling times out.\n * @not-instrumented\n */\nexport const waitForSponsoredTransaction = async (\n { requestId }: WaitForSponsoredTransactionParams,\n client = getDefaultClient()\n): Promise<{ transactionHash: Hex }> => {\n for (let attempt = 0; attempt < MAX_POLLING_ATTEMPTS; attempt++) {\n const result = await getEVMSponsoredTransactionStatus(\n { requestId },\n client\n );\n\n if (TERMINAL_FAILURE_STATUSES.has(result.status)) {\n throw new SponsorTransactionError(null, result.errorMessage);\n }\n\n if (result.transactionHash) {\n return { transactionHash: result.transactionHash };\n }\n\n if (attempt < MAX_POLLING_ATTEMPTS - 1) {\n await new Promise<void>((resolve) =>\n setTimeout(resolve, POLL_INTERVAL_MS)\n );\n }\n }\n\n throw new SponsorTransactionError(\n null,\n `Timed out waiting for sponsored transaction ${requestId}`\n );\n};\n","import { getDefaultClient } from '@dynamic-labs-sdk/client';\nimport type { Hex } from 'viem';\nimport type { SignAuthorizationReturnType } from 'viem/accounts';\n\nimport type { EvmWalletAccount } from '../../EvmWalletAccount.types';\nimport type {\n SignedSponsoredTransaction,\n SponsoredTransactionCall,\n} from '../gasless.types';\nimport { relaySponsoredTransaction } from '../relaySponsoredTransaction';\nimport { waitForSponsoredTransaction } from '../waitForSponsoredTransaction';\n\ntype SendSponsoredTransactionWithCallsParams = {\n /** Pre-signed EIP-7702 authorization. Takes priority over autoDelegate. */\n authorization?: SignAuthorizationReturnType;\n /** Whether to automatically sign 7702 authorization if not delegated. Defaults to true. */\n autoDelegate?: boolean;\n /** The batch of calls to execute. */\n calls: SponsoredTransactionCall[];\n /** How long the signed intent remains valid, in seconds. Defaults to 600 (10 minutes). */\n validForSeconds?: number;\n /** The EVM wallet account to sign and send the transaction for. */\n walletAccount: EvmWalletAccount;\n};\n\ntype SendSponsoredTransactionWithSignedTxParams = {\n /** A pre-signed sponsored transaction payload from signSponsoredTransaction. */\n signedTransaction: SignedSponsoredTransaction;\n};\n\ntype SendSponsoredTransactionParams =\n | SendSponsoredTransactionWithCallsParams\n | SendSponsoredTransactionWithSignedTxParams;\n\n/**\n * Sends a sponsored EVM transaction and waits for on-chain inclusion.\n *\n * Accepts either a pre-signed transaction or unsigned calls. When given\n * unsigned calls, signs the transaction first via signSponsoredTransaction.\n * Relays the transaction and resolves as soon as the relay reports the\n * transaction has been included on-chain.\n *\n * @param params - Either { signedTransaction } or { walletAccount, calls, ... }.\n * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.\n * @returns An object containing the on-chain transaction hash.\n * @throws {SponsorTransactionError} If the relay returns a terminal failure or polling times out.\n * @not-instrumented\n */\nexport const sendSponsoredTransaction = async (\n params: SendSponsoredTransactionParams,\n client = getDefaultClient()\n): Promise<{ transactionHash: Hex }> => {\n const { requestId } = await relaySponsoredTransaction(params, client);\n return waitForSponsoredTransaction({ requestId }, client);\n};\n","import { getDefaultClient } from '@dynamic-labs-sdk/client';\nimport type { Hex } from 'viem';\nimport type { SignAuthorizationReturnType } from 'viem/accounts';\n\nimport type { EvmWalletAccount } from '../../EvmWalletAccount.types';\nimport { sendSponsoredTransaction } from '../sendSponsoredTransaction';\n\ntype Activate7702DelegationParams = {\n /** Pre-signed EIP-7702 authorization. If not provided, one will be signed automatically. */\n authorization?: SignAuthorizationReturnType;\n /** The EVM wallet account to activate delegation for. */\n walletAccount: EvmWalletAccount;\n};\n\n/**\n * Activates EIP-7702 delegation for a wallet by sending a sponsored\n * transaction that only contains the 7702 authorization.\n *\n * After activation, the wallet's delegation is persisted on-chain and\n * subsequent sponsored transactions no longer need to include the\n * authorization.\n *\n * @param params.walletAccount - The EVM wallet account to activate delegation for.\n * @param [params.authorization] - Pre-signed authorization. If omitted, signs one automatically.\n * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.\n * @returns An object containing the on-chain transaction hash.\n * @throws {SponsorTransactionError} If the relay returns a terminal failure or polling times out.\n * @not-instrumented\n */\nexport const activate7702Delegation = async (\n { walletAccount, authorization }: Activate7702DelegationParams,\n client = getDefaultClient()\n): Promise<{ transactionHash: Hex }> =>\n sendSponsoredTransaction(\n { authorization, calls: [], walletAccount },\n client\n );\n","import { getDefaultClient } from '@dynamic-labs-sdk/client/core';\n\nimport { addEIP6963Extension } from '../eip6963/addEIP6963Extension';\nimport { addWaasEvmExtension } from '../waas/addWaasEvmExtension';\n\n/**\n * Adds the EVM extension to the Dynamic client.\n *\n * This is a convenience function that adds both the EIP-6963 extension\n * and the Dynamic WaaS EVM extension, enabling support for all EVM wallet types\n * including standard wallets and embedded wallets managed by Dynamic's infrastructure.\n *\n * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.\n * @not-instrumented\n */\nexport const addEvmExtension = (client = getDefaultClient()): void => {\n addEIP6963Extension(client);\n addWaasEvmExtension(client);\n};\n","import { BaseError } from '@dynamic-labs-sdk/client';\n\nexport class EvmGasSponsorshipNotEnabledError extends BaseError {\n constructor() {\n super({\n cause: null,\n code: 'evm_gas_sponsorship_not_enabled_error',\n docsUrl: null,\n name: 'EvmGasSponsorshipNotEnabledError',\n shortMessage: 'EVM gas sponsorship is not enabled for this project',\n });\n }\n}\n","import { getDefaultClient } from '@dynamic-labs-sdk/client';\nimport { assertDefined } from '@dynamic-labs-sdk/client/core';\n\n/**\n * Checks if EVM gas sponsorship is enabled for the current project.\n *\n * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.\n * @returns True if EVM gas sponsorship is enabled, false otherwise.\n * @not-instrumented\n */\nexport const isEvmGasSponsorshipEnabled = (\n client = getDefaultClient()\n): boolean => {\n assertDefined(client.projectSettings, 'Project settings are not defined');\n\n return (\n client.projectSettings.sdk.embeddedWallets?.evmGasSponsorshipEnabled ??\n false\n );\n};\n","import type { NetworkProvider } from '@dynamic-labs-sdk/client';\n\nimport type { EvmNetworkProvider } from '../EvmNetworkProvider';\n\n/**\n * Type guard function to check if a network provider is an EVM network provider.\n *\n * @param networkProvider - The network provider to check.\n * @returns True if the network provider is an EVM network provider, false otherwise.\n * @not-instrumented\n */\nexport const isEvmNetworkProvider = (\n networkProvider: NetworkProvider\n): networkProvider is EvmNetworkProvider => networkProvider.chain === 'EVM';\n","import type { NetworkData } from '@dynamic-labs-sdk/client';\nimport { FeeEstimationFailedError } from '@dynamic-labs-sdk/client';\nimport { formatEther } from 'viem';\n\nimport type {\n EvmTransactionFeeData,\n EvmTransactionToSimulate,\n} from '../../transactionSimulation.types';\nimport { createPublicClientFromNetworkData } from '../../viem/createPublicClientFromNetworkData';\n\ntype CalculateEvmTransactionFeeParams = {\n nativeTokenPriceUsd?: number;\n networkData: NetworkData;\n transaction: EvmTransactionToSimulate;\n};\n\n/**\n * Calculates the estimated fee for an EVM transaction.\n *\n * This function estimates gas usage and calculates the total transaction fee\n * using either legacy gas pricing or EIP-1559 pricing. The fee is returned\n * in both native units (wei) and human-readable format (ETH).\n *\n * @param params.transaction - The transaction to estimate fees for.\n * @param params.networkData - Network configuration for RPC connection.\n * @param params.nativeTokenPriceUsd - Optional USD price of the native token for fee conversion.\n * @returns Fee data including gas estimates and human-readable amounts.\n * @throws {FeeEstimationFailedError} If gas estimation or fee retrieval fails.\n * @not-instrumented\n */\nexport const calculateEvmTransactionFee = async ({\n transaction,\n networkData,\n nativeTokenPriceUsd,\n}: CalculateEvmTransactionFeeParams): Promise<EvmTransactionFeeData> => {\n try {\n const publicClient = createPublicClientFromNetworkData({ networkData });\n\n // Estimate gas for the transaction\n const gasEstimate = await publicClient.estimateGas({\n account: transaction.from,\n data: transaction.data,\n to: transaction.to,\n value: transaction.value,\n });\n\n // Try to get EIP-1559 fees first, fallback to legacy gas price\n let maxFeePerGas: bigint | undefined;\n let maxPriorityFeePerGas: bigint | undefined;\n let gasPrice: bigint | undefined;\n let nativeAmount: bigint;\n\n try {\n const feeData = await publicClient.estimateFeesPerGas();\n maxFeePerGas = feeData.maxFeePerGas;\n maxPriorityFeePerGas = feeData.maxPriorityFeePerGas;\n\n // Calculate fee using EIP-1559 pricing\n nativeAmount = gasEstimate * maxFeePerGas;\n } catch {\n // Fallback to legacy gas pricing\n gasPrice = await publicClient.getGasPrice();\n nativeAmount = gasEstimate * gasPrice;\n }\n\n // Format to human-readable ETH\n const humanReadableAmount = formatEther(nativeAmount);\n\n // Calculate USD amount if price data available\n const usdAmount = nativeTokenPriceUsd\n ? (Number(humanReadableAmount) * nativeTokenPriceUsd).toFixed(2)\n : undefined;\n\n return {\n gasEstimate,\n gasPrice,\n humanReadableAmount,\n maxFeePerGas,\n maxPriorityFeePerGas,\n nativeAmount,\n usdAmount,\n };\n } catch (error) {\n throw new FeeEstimationFailedError({\n cause: error instanceof Error ? error : undefined,\n message: 'Failed to estimate EVM transaction fee',\n });\n }\n};\n","import {\n FeeEstimationFailedError,\n InvalidParamError,\n SimulationFailedError,\n getDefaultClient,\n getNetworksData,\n} from '@dynamic-labs-sdk/client';\nimport { createApiClient, getCore } from '@dynamic-labs-sdk/client/core';\nimport type { SimulateEVMTransactionRequest } from '@dynamic-labs/sdk-api-core';\n\nimport type { EvmWalletAccount } from '../EvmWalletAccount.types';\nimport type {\n EvmSimulationResult,\n EvmTransactionToSimulate,\n} from '../transactionSimulation.types';\nimport { calculateEvmTransactionFee } from '../utils/calculateEvmTransactionFee';\nimport { isEvmWalletAccount } from '../utils/isEvmWalletAccount';\n\ntype SimulateEvmTransactionParams = {\n includeFees?: boolean;\n transaction: EvmTransactionToSimulate;\n walletAccount: EvmWalletAccount;\n};\n\n/**\n * Simulates an EVM transaction to preview its effects before execution.\n *\n * This function uses the Blockaid API to analyze the transaction and returns\n * information about asset transfers, security validation, and optionally fee estimates.\n * The simulation shows what will happen when the transaction is executed without\n * actually sending it to the blockchain.\n *\n * @param params.walletAccount - The EVM wallet account that will sign the transaction.\n * @param params.transaction - The transaction to simulate, including network ID.\n * @param params.includeFees - Whether to calculate transaction fees (default: false).\n * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.\n * @returns Simulation result with asset diffs, security validation, and optional fee data.\n * @throws {InvalidParamError} If wallet account is not an EVM account or network ID is not configured.\n * @throws {SimulationFailedError} If the simulation API call fails.\n * @throws {FeeEstimationFailedError} If includeFees is true and fee calculation fails.\n * @not-instrumented\n */\nexport const simulateEvmTransaction = async (\n {\n walletAccount,\n transaction,\n includeFees = false,\n }: SimulateEvmTransactionParams,\n client = getDefaultClient()\n): Promise<EvmSimulationResult> => {\n // Validate wallet account type\n if (!isEvmWalletAccount(walletAccount)) {\n throw new InvalidParamError('Wallet account must be an EVM wallet account');\n }\n\n // Get network data for the specified network\n const networksData = getNetworksData(client);\n const networkData = networksData.find(\n (data) => data.networkId === transaction.networkId && data.chain === 'EVM'\n );\n\n if (!networkData) {\n throw new InvalidParamError(\n `Network with ID ${transaction.networkId} is not configured in project settings`\n );\n }\n\n try {\n // Create API client and call simulation endpoint\n const core = getCore(client);\n const apiClient = createApiClient({}, client);\n\n const simulateEVMTransactionRequest = {\n chainId: transaction.networkId,\n data: transaction.data || '0x',\n from: transaction.from,\n to: transaction.to,\n } as SimulateEVMTransactionRequest;\n\n if (transaction.value !== undefined) {\n simulateEVMTransactionRequest.value = transaction.value.toString();\n }\n\n const response = await apiClient.simulateEVMTransaction({\n environmentId: core.environmentId,\n simulateEVMTransactionRequest,\n });\n\n // Calculate fees if requested\n let feeData: EvmSimulationResult['feeData'];\n\n if (includeFees) {\n feeData = await calculateEvmTransactionFee({\n nativeTokenPriceUsd: response.priceData?.nativeTokenUsdPrice,\n networkData,\n transaction,\n });\n }\n\n // Map API response to simulation result\n return {\n counterparties: response.counterparties,\n feeData,\n inAssets: response.inAssets || [],\n outAssets: response.outAssets || [],\n priceData: response.priceData,\n showTotalFiat: response.showTotalFiat,\n validation: response.validation\n ? {\n description: response.validation.description,\n reason: response.validation.reason,\n result: response.validation.result as\n | 'benign'\n | 'warning'\n | 'malicious',\n }\n : undefined,\n };\n } catch (error) {\n // Re-throw FeeEstimationFailedError as-is\n if (error instanceof FeeEstimationFailedError) {\n throw error;\n }\n\n throw new SimulationFailedError({\n cause: error instanceof Error ? error : undefined,\n message: 'Failed to simulate EVM transaction',\n });\n }\n};\n","import { assertPackageVersion } from '@dynamic-labs-sdk/assert-package-version';\n\nimport {\n name as packageName,\n version as packageVersion,\n} from '../../package.json';\nassertPackageVersion(packageName, packageVersion);\n\nexport { activate7702Delegation } from '../gasless/activate7702Delegation';\nexport { addEvmExtension } from '../addEvmExtension';\nexport { EvmGasSponsorshipNotEnabledError } from '../errors/EvmGasSponsorshipNotEnabledError';\nexport { RpcError } from '../errors/RpcError';\nexport { SponsorTransactionError } from '../errors/SponsorTransactionError';\nexport type { EvmNetworkProvider } from '../EvmNetworkProvider';\nexport type { EvmWalletAccount } from '../EvmWalletAccount.types';\nexport type { EvmWalletProvider } from '../EvmWalletProvider.types';\nexport type {\n SerializedAuthorization,\n SignedSponsoredTransaction,\n SponsoredTransactionCall,\n SponsoredTransactionStatus,\n SponsoredTransactionStatusResult,\n} from '../gasless/gasless.types';\nexport { getEVMSponsoredTransactionStatus } from '../gasless/getEVMSponsoredTransactionStatus';\nexport { is7702DelegationActive } from '../gasless/is7702DelegationActive';\nexport { isEvmGasSponsorshipEnabled } from '../gasless/isEvmGasSponsorshipEnabled';\nexport { isEvmNetworkProvider } from '../isEvmNetworkProvider';\nexport { simulateEvmTransaction } from '../simulateEvmTransaction';\nexport type {\n EvmSimulationResult,\n EvmTransactionFeeData,\n EvmTransactionToSimulate,\n} from '../transactionSimulation.types';\nexport { calculateEvmTransactionFee } from '../utils/calculateEvmTransactionFee';\nexport { isEvmWalletAccount } from '../utils/isEvmWalletAccount';\nexport { relaySponsoredTransaction } from '../gasless/relaySponsoredTransaction';\nexport { sendSponsoredTransaction } from '../gasless/sendSponsoredTransaction';\nexport { sign7702Authorization } from '../gasless/sign7702Authorization';\nexport { signSponsoredTransaction } from '../gasless/signSponsoredTransaction';\nexport { waitForSponsoredTransaction } from '../gasless/waitForSponsoredTransaction';\n"],"mappings":";;;;;;;;;;;;AAEA,IAAa,0BAAb,cAA6C,UAAU;CAErD,YAAY,OAAsB,SAAkB;AAClD,QAAM;GACJ,OAAO,SAAS;GAChB,MAAM;GACN;GACA,SAAS;GACT,MAAM;GACN,cAAc;GACf,CAAC;;;;;;;ACTN,MAAaA,8BACX;;AAGF,MAAa,4BAA4B;;AAGzC,MAAa,yBAAyB;;AAGtC,MAAaC,8BACX;;AAGF,MAAa,8BAA8B;CACzC,sBAAsB;EACpB;GAAE,MAAM;GAAS,MAAM;GAAe;EACtC;GAAE,MAAM;GAAY,MAAM;GAAW;EACrC;GAAE,MAAM;GAAQ,MAAM;GAAW;EACjC;GAAE,MAAM;GAAS,MAAM;GAAW;EAClC;GAAE,MAAM;GAAW,MAAM;GAAW;EACrC;CACD,WAAW;EACT;GAAE,MAAM;GAAU,MAAM;GAAW;EACnC;GAAE,MAAM;GAAS,MAAM;GAAW;EAClC;GAAE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I,CAAC,mBAAmB,cAAc,CACpC,OAAM,IAAI,kBAAkB,+CAA+C;CAK7E,MAAM,cADe,gBAAgB,OAAO,CACX,MAC9B,SAAS,KAAK,cAAc,YAAY,aAAa,KAAK,UAAU,MACtE;AAED,KAAI,CAAC,YACH,OAAM,IAAI,kBACR,mBAAmB,YAAY,UAAU,wCAC1C;AAGH,KAAI;EAEF,MAAM,OAAO,QAAQ,OAAO;EAC5B,MAAM,YAAY,gBAAgB,EAAE,EAAE,OAAO;EAE7C,MAAM,gCAAgC;GACpC,SAAS,YAAY;GACrB,MAAM,YAAY,QAAQ;GAC1B,MAAM,YAAY;GAClB,IAAI,YAAY;GACjB;AAED,MAAI,YAAY,UAAU,OACxB,+BAA8B,QAAQ,YAAY,MAAM,UAAU;EAGpE,MAAM,WAAW,MAAM,UAAU,uBAAuB;GACtD,eAAe,KAAK;GACpB;GACD,CAAC;EAGF,IAAIC;AAEJ,MAAI,YACF,WAAU,MAAM,2BAA2B;GACzC,qBAAqB,SAAS,WAAW;GACzC;GACA;GACD,CAAC;AAIJ,SAAO;GACL,gBAAgB,SAAS;GACzB;GACA,UAAU,SAAS,YAAY,EAAE;GACjC,WAAW,SAAS,aAAa,EAAE;GACnC,WAAW,SAAS;GACpB,eAAe,SAAS;GACxB,YAAY,SAAS,aACjB;IACE,aAAa,SAAS,WAAW;IACjC,QAAQ,SAAS,WAAW;IAC5B,QAAQ,SAAS,WAAW;IAI7B,GACD;GACL;UACM,OAAO;AAEd,MAAI,iBAAiB,yBACnB,OAAM;AAGR,QAAM,IAAI,sBAAsB;GAC9B,OAAO,iBAAiB,QAAQ,QAAQ;GACxC,SAAS;GACV,CAAC;;;;;;ACzHN,qBAAqBC,MAAaC,QAAe"}
1
+ {"version":3,"file":"index.native.esm.js","names":["getDefaultClient","maxFeePerGas: bigint | undefined","maxPriorityFeePerGas: bigint | undefined","gasPrice: bigint | undefined","nativeAmount: bigint","feeData: EvmSimulationResult['feeData']","packageName","packageVersion"],"sources":["../src/gasless/activate7702Delegation/activate7702Delegation.ts","../src/addEvmExtension/addEvmExtension.ts","../src/errors/EvmGasSponsorshipNotEnabledError/EvmGasSponsorshipNotEnabledError.ts","../src/isEvmNetworkProvider/isEvmNetworkProvider.ts","../src/utils/calculateEvmTransactionFee/calculateEvmTransactionFee.ts","../src/simulateEvmTransaction/simulateEvmTransaction.ts","../src/exports/index.ts"],"sourcesContent":["import { getDefaultClient } from '@dynamic-labs-sdk/client';\nimport type { Hex } from 'viem';\nimport type { SignAuthorizationReturnType } from 'viem/accounts';\n\nimport type { EvmWalletAccount } from '../../EvmWalletAccount.types';\nimport { sendSponsoredTransaction } from '../sendSponsoredTransaction';\n\ntype Activate7702DelegationParams = {\n /** Pre-signed EIP-7702 authorization. If not provided, one will be signed automatically. */\n authorization?: SignAuthorizationReturnType;\n /** The EVM wallet account to activate delegation for. */\n walletAccount: EvmWalletAccount;\n};\n\n/**\n * Activates EIP-7702 delegation for a wallet by sending a sponsored\n * transaction that only contains the 7702 authorization.\n *\n * After activation, the wallet's delegation is persisted on-chain and\n * subsequent sponsored transactions no longer need to include the\n * authorization.\n *\n * @param params.walletAccount - The EVM wallet account to activate delegation for.\n * @param [params.authorization] - Pre-signed authorization. If omitted, signs one automatically.\n * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.\n * @returns An object containing the on-chain transaction hash.\n * @throws {SponsorTransactionError} If the relay returns a terminal failure or polling times out.\n * @not-instrumented\n */\nexport const activate7702Delegation = async (\n { walletAccount, authorization }: Activate7702DelegationParams,\n client = getDefaultClient()\n): Promise<{ transactionHash: Hex }> =>\n sendSponsoredTransaction(\n { authorization, calls: [], walletAccount },\n client\n );\n","import { getDefaultClient } from '@dynamic-labs-sdk/client/core';\n\nimport { addEIP6963Extension } from '../eip6963/addEIP6963Extension';\nimport { addWaasEvmExtension } from '../waas/addWaasEvmExtension';\n\n/**\n * Adds the EVM extension to the Dynamic client.\n *\n * This is a convenience function that adds both the EIP-6963 extension\n * and the Dynamic WaaS EVM extension, enabling support for all EVM wallet types\n * including standard wallets and embedded wallets managed by Dynamic's infrastructure.\n *\n * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.\n * @not-instrumented\n */\nexport const addEvmExtension = (client = getDefaultClient()): void => {\n addEIP6963Extension(client);\n addWaasEvmExtension(client);\n};\n","import { BaseError } from '@dynamic-labs-sdk/client';\n\nexport class EvmGasSponsorshipNotEnabledError extends BaseError {\n constructor() {\n super({\n cause: null,\n code: 'evm_gas_sponsorship_not_enabled_error',\n docsUrl: null,\n name: 'EvmGasSponsorshipNotEnabledError',\n shortMessage: 'EVM gas sponsorship is not enabled for this project',\n });\n }\n}\n","import type { NetworkProvider } from '@dynamic-labs-sdk/client';\n\nimport type { EvmNetworkProvider } from '../EvmNetworkProvider';\n\n/**\n * Type guard function to check if a network provider is an EVM network provider.\n *\n * @param networkProvider - The network provider to check.\n * @returns True if the network provider is an EVM network provider, false otherwise.\n * @not-instrumented\n */\nexport const isEvmNetworkProvider = (\n networkProvider: NetworkProvider\n): networkProvider is EvmNetworkProvider => networkProvider.chain === 'EVM';\n","import type { NetworkData } from '@dynamic-labs-sdk/client';\nimport { FeeEstimationFailedError } from '@dynamic-labs-sdk/client';\nimport { formatEther } from 'viem';\n\nimport type {\n EvmTransactionFeeData,\n EvmTransactionToSimulate,\n} from '../../transactionSimulation.types';\nimport { createPublicClientFromNetworkData } from '../../viem/createPublicClientFromNetworkData';\n\ntype CalculateEvmTransactionFeeParams = {\n nativeTokenPriceUsd?: number;\n networkData: NetworkData;\n transaction: EvmTransactionToSimulate;\n};\n\n/**\n * Calculates the estimated fee for an EVM transaction.\n *\n * This function estimates gas usage and calculates the total transaction fee\n * using either legacy gas pricing or EIP-1559 pricing. The fee is returned\n * in both native units (wei) and human-readable format (ETH).\n *\n * @param params.transaction - The transaction to estimate fees for.\n * @param params.networkData - Network configuration for RPC connection.\n * @param params.nativeTokenPriceUsd - Optional USD price of the native token for fee conversion.\n * @returns Fee data including gas estimates and human-readable amounts.\n * @throws {FeeEstimationFailedError} If gas estimation or fee retrieval fails.\n * @not-instrumented\n */\nexport const calculateEvmTransactionFee = async ({\n transaction,\n networkData,\n nativeTokenPriceUsd,\n}: CalculateEvmTransactionFeeParams): Promise<EvmTransactionFeeData> => {\n try {\n const publicClient = createPublicClientFromNetworkData({ networkData });\n\n // Estimate gas for the transaction\n const gasEstimate = await publicClient.estimateGas({\n account: transaction.from,\n data: transaction.data,\n to: transaction.to,\n value: transaction.value,\n });\n\n // Try to get EIP-1559 fees first, fallback to legacy gas price\n let maxFeePerGas: bigint | undefined;\n let maxPriorityFeePerGas: bigint | undefined;\n let gasPrice: bigint | undefined;\n let nativeAmount: bigint;\n\n try {\n const feeData = await publicClient.estimateFeesPerGas();\n maxFeePerGas = feeData.maxFeePerGas;\n maxPriorityFeePerGas = feeData.maxPriorityFeePerGas;\n\n // Calculate fee using EIP-1559 pricing\n nativeAmount = gasEstimate * maxFeePerGas;\n } catch {\n // Fallback to legacy gas pricing\n gasPrice = await publicClient.getGasPrice();\n nativeAmount = gasEstimate * gasPrice;\n }\n\n // Format to human-readable ETH\n const humanReadableAmount = formatEther(nativeAmount);\n\n // Calculate USD amount if price data available\n const usdAmount = nativeTokenPriceUsd\n ? (Number(humanReadableAmount) * nativeTokenPriceUsd).toFixed(2)\n : undefined;\n\n return {\n gasEstimate,\n gasPrice,\n humanReadableAmount,\n maxFeePerGas,\n maxPriorityFeePerGas,\n nativeAmount,\n usdAmount,\n };\n } catch (error) {\n throw new FeeEstimationFailedError({\n cause: error instanceof Error ? error : undefined,\n message: 'Failed to estimate EVM transaction fee',\n });\n }\n};\n","import {\n FeeEstimationFailedError,\n InvalidParamError,\n SimulationFailedError,\n getDefaultClient,\n getNetworksData,\n} from '@dynamic-labs-sdk/client';\nimport { createApiClient, getCore } from '@dynamic-labs-sdk/client/core';\nimport type { SimulateEVMTransactionRequest } from '@dynamic-labs/sdk-api-core';\n\nimport type { EvmWalletAccount } from '../EvmWalletAccount.types';\nimport type {\n EvmSimulationResult,\n EvmTransactionToSimulate,\n} from '../transactionSimulation.types';\nimport { calculateEvmTransactionFee } from '../utils/calculateEvmTransactionFee';\nimport { isEvmWalletAccount } from '../utils/isEvmWalletAccount';\n\ntype SimulateEvmTransactionParams = {\n includeFees?: boolean;\n transaction: EvmTransactionToSimulate;\n walletAccount: EvmWalletAccount;\n};\n\n/**\n * Simulates an EVM transaction to preview its effects before execution.\n *\n * This function uses the Blockaid API to analyze the transaction and returns\n * information about asset transfers, security validation, and optionally fee estimates.\n * The simulation shows what will happen when the transaction is executed without\n * actually sending it to the blockchain.\n *\n * @param params.walletAccount - The EVM wallet account that will sign the transaction.\n * @param params.transaction - The transaction to simulate, including network ID.\n * @param params.includeFees - Whether to calculate transaction fees (default: false).\n * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.\n * @returns Simulation result with asset diffs, security validation, and optional fee data.\n * @throws {InvalidParamError} If wallet account is not an EVM account or network ID is not configured.\n * @throws {SimulationFailedError} If the simulation API call fails.\n * @throws {FeeEstimationFailedError} If includeFees is true and fee calculation fails.\n * @not-instrumented\n */\nexport const simulateEvmTransaction = async (\n {\n walletAccount,\n transaction,\n includeFees = false,\n }: SimulateEvmTransactionParams,\n client = getDefaultClient()\n): Promise<EvmSimulationResult> => {\n // Validate wallet account type\n if (!isEvmWalletAccount(walletAccount)) {\n throw new InvalidParamError('Wallet account must be an EVM wallet account');\n }\n\n // Get network data for the specified network\n const networksData = getNetworksData(client);\n const networkData = networksData.find(\n (data) => data.networkId === transaction.networkId && data.chain === 'EVM'\n );\n\n if (!networkData) {\n throw new InvalidParamError(\n `Network with ID ${transaction.networkId} is not configured in project settings`\n );\n }\n\n try {\n // Create API client and call simulation endpoint\n const core = getCore(client);\n const apiClient = createApiClient({}, client);\n\n const simulateEVMTransactionRequest = {\n chainId: transaction.networkId,\n data: transaction.data || '0x',\n from: transaction.from,\n to: transaction.to,\n } as SimulateEVMTransactionRequest;\n\n if (transaction.value !== undefined) {\n simulateEVMTransactionRequest.value = transaction.value.toString();\n }\n\n const response = await apiClient.simulateEVMTransaction({\n environmentId: core.environmentId,\n simulateEVMTransactionRequest,\n });\n\n // Calculate fees if requested\n let feeData: EvmSimulationResult['feeData'];\n\n if (includeFees) {\n feeData = await calculateEvmTransactionFee({\n nativeTokenPriceUsd: response.priceData?.nativeTokenUsdPrice,\n networkData,\n transaction,\n });\n }\n\n // Map API response to simulation result\n return {\n counterparties: response.counterparties,\n feeData,\n inAssets: response.inAssets || [],\n outAssets: response.outAssets || [],\n priceData: response.priceData,\n showTotalFiat: response.showTotalFiat,\n validation: response.validation\n ? {\n description: response.validation.description,\n reason: response.validation.reason,\n result: response.validation.result as\n | 'benign'\n | 'warning'\n | 'malicious',\n }\n : undefined,\n };\n } catch (error) {\n // Re-throw FeeEstimationFailedError as-is\n if (error instanceof FeeEstimationFailedError) {\n throw error;\n }\n\n throw new SimulationFailedError({\n cause: error instanceof Error ? error : undefined,\n message: 'Failed to simulate EVM transaction',\n });\n }\n};\n","import { assertPackageVersion } from '@dynamic-labs-sdk/assert-package-version';\n\nimport {\n name as packageName,\n version as packageVersion,\n} from '../../package.json';\nassertPackageVersion(packageName, packageVersion);\n\nexport { activate7702Delegation } from '../gasless/activate7702Delegation';\nexport { addEvmExtension } from '../addEvmExtension';\nexport { EvmGasSponsorshipNotEnabledError } from '../errors/EvmGasSponsorshipNotEnabledError';\nexport { RpcError } from '../errors/RpcError';\nexport { SponsorTransactionError } from '../errors/SponsorTransactionError';\nexport type { EvmNetworkProvider } from '../EvmNetworkProvider';\nexport type { EvmWalletAccount } from '../EvmWalletAccount.types';\nexport type { EvmWalletProvider } from '../EvmWalletProvider.types';\nexport type {\n SerializedAuthorization,\n SignedSponsoredTransaction,\n SponsoredTransactionCall,\n SponsoredTransactionStatus,\n SponsoredTransactionStatusResult,\n} from '../gasless/gasless.types';\nexport { getEVMSponsoredTransactionStatus } from '../gasless/getEVMSponsoredTransactionStatus';\nexport { is7702DelegationActive } from '../gasless/is7702DelegationActive';\nexport { isEvmGasSponsorshipEnabled } from '../gasless/isEvmGasSponsorshipEnabled';\nexport { isEvmNetworkProvider } from '../isEvmNetworkProvider';\nexport { simulateEvmTransaction } from '../simulateEvmTransaction';\nexport type {\n EvmSimulationResult,\n EvmTransactionFeeData,\n EvmTransactionToSimulate,\n} from '../transactionSimulation.types';\nexport { calculateEvmTransactionFee } from '../utils/calculateEvmTransactionFee';\nexport { isEvmWalletAccount } from '../utils/isEvmWalletAccount';\nexport { relaySponsoredTransaction } from '../gasless/relaySponsoredTransaction';\nexport { sendSponsoredTransaction } from '../gasless/sendSponsoredTransaction';\nexport { sign7702Authorization } from '../gasless/sign7702Authorization';\nexport { signSponsoredTransaction } from '../gasless/signSponsoredTransaction';\nexport { waitForSponsoredTransaction } from '../gasless/waitForSponsoredTransaction';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AA6BA,MAAa,yBAAyB,OACpC,EAAE,eAAe,iBACjB,SAAS,kBAAkB,KAE3B,yBACE;CAAE;CAAe,OAAO,EAAE;CAAE;CAAe,EAC3C,OACD;;;;;;;;;;;;;;ACrBH,MAAa,mBAAmB,SAASA,oBAAkB,KAAW;AACpE,qBAAoB,OAAO;AAC3B,qBAAoB,OAAO;;;;;ACf7B,IAAa,mCAAb,cAAsD,UAAU;CAC9D,cAAc;AACZ,QAAM;GACJ,OAAO;GACP,MAAM;GACN,SAAS;GACT,MAAM;GACN,cAAc;GACf,CAAC;;;;;;;;;;;;;ACCN,MAAa,wBACX,oBAC0C,gBAAgB,UAAU;;;;;;;;;;;;;;;;;;ACiBtE,MAAa,6BAA6B,OAAO,EAC/C,aACA,aACA,0BACsE;AACtE,KAAI;EACF,MAAM,eAAe,kCAAkC,EAAE,aAAa,CAAC;EAGvE,MAAM,cAAc,MAAM,aAAa,YAAY;GACjD,SAAS,YAAY;GACrB,MAAM,YAAY;GAClB,IAAI,YAAY;GAChB,OAAO,YAAY;GACpB,CAAC;EAGF,IAAIC;E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IJ,SAAO;GACL,gBAAgB,SAAS;GACzB;GACA,UAAU,SAAS,YAAY,EAAE;GACjC,WAAW,SAAS,aAAa,EAAE;GACnC,WAAW,SAAS;GACpB,eAAe,SAAS;GACxB,YAAY,SAAS,aACjB;IACE,aAAa,SAAS,WAAW;IACjC,QAAQ,SAAS,WAAW;IAC5B,QAAQ,SAAS,WAAW;IAI7B,GACD;GACL;UACM,OAAO;AAEd,MAAI,iBAAiB,yBACnB,OAAM;AAGR,QAAM,IAAI,sBAAsB;GAC9B,OAAO,iBAAiB,QAAQ,QAAQ;GACxC,SAAS;GACV,CAAC;;;;;;ACzHN,qBAAqBC,MAAaC,QAAe"}
@@ -0,0 +1,17 @@
1
+ import { type WalletProviderUriConnectionResult } from '@dynamic-labs-sdk/client';
2
+ /**
3
+ * Drives a MetaMask SDK URI pairing for EVM and verifies ownership of the
4
+ * paired wallet account through message signing, returning `{ approval, uri }`
5
+ * so consumers can render the QR / hand the URI to a deeplink.
6
+ *
7
+ * Unlike `connectAndVerifyWithWalletConnectEvm`, the MetaMask SDK does not
8
+ * expose a single-round-trip authenticate primitive, so this drives two
9
+ * sequential interactions on the wallet side: the user first approves the
10
+ * pairing, then approves a sign-in message. The wallet account is added to
11
+ * the Dynamic client as a verified credential (not as an unverified
12
+ * account).
13
+ *
14
+ * @not-instrumented
15
+ */
16
+ export declare const connectAndVerifyWithMetaMaskUriEvm: (client?: import("@dynamic-labs-sdk/client").DynamicClient) => Promise<WalletProviderUriConnectionResult>;
17
+ //# sourceMappingURL=connectAndVerifyWithMetaMaskUriEvm.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"connectAndVerifyWithMetaMaskUriEvm.d.ts","sourceRoot":"","sources":["../../../src/metamask/connectAndVerifyWithMetaMaskUriEvm/connectAndVerifyWithMetaMaskUriEvm.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,iCAAiC,EAGvC,MAAM,0BAA0B,CAAC;AAOlC;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,kCAAkC,iEAE5C,OAAO,CAAC,iCAAiC,CAgC3C,CAAC"}
@@ -0,0 +1,2 @@
1
+ export { connectAndVerifyWithMetaMaskUriEvm } from './connectAndVerifyWithMetaMaskUriEvm';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/metamask/connectAndVerifyWithMetaMaskUriEvm/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kCAAkC,EAAE,MAAM,sCAAsC,CAAC"}
@@ -0,0 +1,17 @@
1
+ import type { WalletProviderUriConnectionResult } from '@dynamic-labs-sdk/client';
2
+ export type ConnectWithMetaMaskUriEvmParams = {
3
+ /** Whether to add the connected wallet account to the Dynamic client. Defaults to `true`. */
4
+ addToDynamicWalletAccounts?: boolean;
5
+ };
6
+ /**
7
+ * Drives a MetaMask SDK URI pairing for EVM and returns `{ approval, uri }` so
8
+ * consumers can render the QR / hand the URI to a deeplink. Logs an advisory
9
+ * warning when the MetaMask extension is announced via EIP-6963; pairing still
10
+ * proceeds, but the consumer is told which announced provider key to route
11
+ * through for the best UX. The resulting wallet provider registers for signing
12
+ * only and is never surfaced in the wallet picker.
13
+ *
14
+ * @not-instrumented
15
+ */
16
+ export declare const connectWithMetaMaskUriEvm: ({ addToDynamicWalletAccounts }?: ConnectWithMetaMaskUriEvmParams, client?: import("@dynamic-labs-sdk/client").DynamicClient) => Promise<WalletProviderUriConnectionResult>;
17
+ //# sourceMappingURL=connectWithMetaMaskUriEvm.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"connectWithMetaMaskUriEvm.d.ts","sourceRoot":"","sources":["../../../src/metamask/connectWithMetaMaskUriEvm/connectWithMetaMaskUriEvm.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iCAAiC,EAAE,MAAM,0BAA0B,CAAC;AAOlF,MAAM,MAAM,+BAA+B,GAAG;IAC5C,6FAA6F;IAC7F,0BAA0B,CAAC,EAAE,OAAO,CAAC;CACtC,CAAC;AAEF;;;;;;;;;GASG;AACH,eAAO,MAAM,yBAAyB,oCACG,+BAA+B,gEAErE,OAAO,CAAC,iCAAiC,CAY3C,CAAC"}
@@ -0,0 +1,3 @@
1
+ export { connectWithMetaMaskUriEvm } from './connectWithMetaMaskUriEvm';
2
+ export type { ConnectWithMetaMaskUriEvmParams } from './connectWithMetaMaskUriEvm';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/metamask/connectWithMetaMaskUriEvm/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,MAAM,6BAA6B,CAAC;AACxE,YAAY,EAAE,+BAA+B,EAAE,MAAM,6BAA6B,CAAC"}
@@ -1,19 +1,14 @@
1
1
  import type { DynamicClient } from '@dynamic-labs-sdk/client';
2
- import { WalletProviderEnum } from '@dynamic-labs/sdk-api-core';
3
2
  import type { EvmWalletProvider } from '../../EvmWalletProvider.types';
4
- export type CreateMetaMaskEvmWalletProviderParams = {
5
- walletProviderType?: WalletProviderEnum;
6
- };
7
3
  /**
8
- * Builds an `EvmWalletProvider` backed by `@metamask/connect-evm`,
9
- * adapting the SDK's provider to the Dynamic `EIP1193Provider` contract
10
- * (`disconnect` → `disconnected` event bridge, `removeAllListeners`
11
- * shim, and unwrapping the `{ accounts, chainId }` response from
12
- * `eth_requestAccounts` / `wallet_requestPermissions`). Defaults
13
- * `walletProviderType` to `QrCode`; `addMetaMaskEvmExtension` upgrades
14
- * it to `BrowserExtension` once EIP-6963 `io.metamask` is announced.
4
+ * Builds the `EvmWalletProvider` registered AFTER a successful MetaMask
5
+ * SDK URI pairing. Wraps the SDK's EIP-1193 provider behind the Dynamic
6
+ * facade (`disconnect` → `disconnected` event bridge, `removeAllListeners`
7
+ * shim) and drops `connect` so the provider is filtered out of the
8
+ * wallet picker by `getAvailableWalletProvidersData` — mirroring how
9
+ * WalletConnect URI sessions register a signing-only provider.
15
10
  *
16
11
  * @not-instrumented
17
12
  */
18
- export declare const createMetaMaskEvmWalletProvider: ({ walletProviderType, }: CreateMetaMaskEvmWalletProviderParams, client: DynamicClient) => EvmWalletProvider;
13
+ export declare const createMetaMaskEvmWalletProvider: (client: DynamicClient) => Promise<EvmWalletProvider>;
19
14
  //# sourceMappingURL=createMetaMaskEvmWalletProvider.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"createMetaMaskEvmWalletProvider.d.ts","sourceRoot":"","sources":["../../../src/metamask/createMetaMaskEvmWalletProvider/createMetaMaskEvmWalletProvider.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAK9D,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAMhE,OAAO,KAAK,EAIV,iBAAiB,EAClB,MAAM,+BAA+B,CAAC;AAOvC,MAAM,MAAM,qCAAqC,GAAG;IAClD,kBAAkB,CAAC,EAAE,kBAAkB,CAAC;CACzC,CAAC;AAOF;;;;;;;;;;GAUG;AACH,eAAO,MAAM,+BAA+B,4BAGvC,qCAAqC,UAChC,aAAa,KACpB,iBA0GF,CAAC"}
1
+ {"version":3,"file":"createMetaMaskEvmWalletProvider.d.ts","sourceRoot":"","sources":["../../../src/metamask/createMetaMaskEvmWalletProvider/createMetaMaskEvmWalletProvider.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAQ9D,OAAO,KAAK,EAIV,iBAAiB,EAClB,MAAM,+BAA+B,CAAC;AASvC;;;;;;;;;GASG;AACH,eAAO,MAAM,+BAA+B,WAClC,aAAa,KACpB,OAAO,CAAC,iBAAiB,CAwD3B,CAAC"}
@@ -1,3 +1,2 @@
1
1
  export { createMetaMaskEvmWalletProvider } from './createMetaMaskEvmWalletProvider';
2
- export type { CreateMetaMaskEvmWalletProviderParams } from './createMetaMaskEvmWalletProvider';
3
2
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/metamask/createMetaMaskEvmWalletProvider/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,+BAA+B,EAAE,MAAM,mCAAmC,CAAC;AACpF,YAAY,EAAE,qCAAqC,EAAE,MAAM,mCAAmC,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/metamask/createMetaMaskEvmWalletProvider/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,+BAA+B,EAAE,MAAM,mCAAmC,CAAC"}
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Returns the wallet provider key of the MetaMask browser extension announced
3
+ * for EVM, or `undefined` when none is announced. Pass the returned key to
4
+ * `connectWithWalletProvider` to route through the announced provider; fall
5
+ * back to `connectWithMetaMaskUriEvm` when `undefined`.
6
+ *
7
+ * @not-instrumented
8
+ */
9
+ export declare const getMetaMaskEvmExtensionWalletProviderKey: (client?: import("@dynamic-labs-sdk/client").DynamicClient) => string | undefined;
10
+ //# sourceMappingURL=getMetaMaskEvmExtensionWalletProviderKey.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getMetaMaskEvmExtensionWalletProviderKey.d.ts","sourceRoot":"","sources":["../../../src/metamask/getMetaMaskEvmExtensionWalletProviderKey/getMetaMaskEvmExtensionWalletProviderKey.ts"],"names":[],"mappings":"AAGA;;;;;;;GAOG;AACH,eAAO,MAAM,wCAAwC,iEAElD,MAAM,GAAG,SACqD,CAAC"}
@@ -0,0 +1,2 @@
1
+ export { getMetaMaskEvmExtensionWalletProviderKey } from './getMetaMaskEvmExtensionWalletProviderKey';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/metamask/getMetaMaskEvmExtensionWalletProviderKey/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wCAAwC,EAAE,MAAM,4CAA4C,CAAC"}
@@ -1,42 +1,14 @@
1
+ import type { MetaMaskController } from '@dynamic-labs-sdk/metamask';
1
2
  import type { MetamaskConnectEVM } from '@metamask/connect-evm';
2
- export type DisplayUriListener = (uri: string) => void;
3
3
  /**
4
- * Per-Dynamic-client wrapper around `@metamask/connect-evm`. Owns the SDK
5
- * instance and the bookkeeping required to surface the SDK's `display_uri`
6
- * event to multiple Dynamic-side consumers without races: a cache of the
7
- * latest URI plus a small listener registry.
8
- *
9
- * Returned by `createMetaMaskEvmController` and cached per Dynamic client by
10
- * `getOrCreateMetaMaskEvmController`.
4
+ * Per-Dynamic-client EVM-flavoured `MetaMaskController`. Extends the
5
+ * chain-agnostic surface with the typed `@metamask/connect-evm` SDK
6
+ * handle so the EIP-1193 facade can reach the SDK provider directly for
7
+ * signing. Returned by `createMetaMaskEvmController` and cached per
8
+ * Dynamic client by `getOrCreateMetaMaskEvmController`.
11
9
  */
12
- export type MetaMaskEvmController = {
13
- /**
14
- * Drops the cached `display_uri` value without touching the SDK. Used
15
- * by `disconnectMetaMaskEvm` to make sure a torn-down pairing's URI is
16
- * not replayed to late subscribers — the SDK's own `disconnect` event
17
- * handler is best-effort and may not fire (or may not fire
18
- * synchronously) when we abort a pairing that the wallet never
19
- * accepted.
20
- */
21
- clearCachedDisplayUri: () => void;
22
- /**
23
- * The latest URI captured by `eventHandlers.displayUri`, or `undefined`
24
- * if no pairing URI has been emitted yet (or the SDK routed to the
25
- * browser extension instead of the QR / deep-link transport, or a
26
- * pairing session just completed).
27
- */
28
- getLatestDisplayUri: () => string | undefined;
29
- /**
30
- * Subscribes a listener for `display_uri` events. The listener is
31
- * invoked immediately with the cached URI when one is already available
32
- * — so consumers that subscribe after the SDK has already started the
33
- * pairing flow do not need to coordinate timing with the connection
34
- * call. Returns a function that removes the listener.
35
- */
36
- onDisplayUri: (listener: DisplayUriListener) => () => void;
37
- /**
38
- * The underlying `@metamask/connect-evm` SDK instance.
39
- */
10
+ export type MetaMaskEvmController = MetaMaskController & {
11
+ /** The underlying `@metamask/connect-evm` SDK instance. */
40
12
  sdk: MetamaskConnectEVM;
41
13
  };
42
14
  //# sourceMappingURL=metamask.types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"metamask.types.d.ts","sourceRoot":"","sources":["../../src/metamask/metamask.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAEhE,MAAM,MAAM,kBAAkB,GAAG,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;AAEvD;;;;;;;;GAQG;AACH,MAAM,MAAM,qBAAqB,GAAG;IAClC;;;;;;;OAOG;IACH,qBAAqB,EAAE,MAAM,IAAI,CAAC;IAElC;;;;;OAKG;IACH,mBAAmB,EAAE,MAAM,MAAM,GAAG,SAAS,CAAC;IAE9C;;;;;;OAMG;IACH,YAAY,EAAE,CAAC,QAAQ,EAAE,kBAAkB,KAAK,MAAM,IAAI,CAAC;IAE3D;;OAEG;IACH,GAAG,EAAE,kBAAkB,CAAC;CACzB,CAAC"}
1
+ {"version":3,"file":"metamask.types.d.ts","sourceRoot":"","sources":["../../src/metamask/metamask.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AACrE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAEhE;;;;;;GAMG;AACH,MAAM,MAAM,qBAAqB,GAAG,kBAAkB,GAAG;IACvD,2DAA2D;IAC3D,GAAG,EAAE,kBAAkB,CAAC;CACzB,CAAC"}
@@ -2,33 +2,11 @@ import type { DynamicClient } from '@dynamic-labs-sdk/client';
2
2
  import type { MetaMaskEvmController } from '../../metamask.types';
3
3
  /**
4
4
  * Builds a fully-initialised `MetaMaskEvmController` for the given Dynamic
5
- * client. Used internally by `getOrCreateMetaMaskEvmController`; not part
6
- * of the public API.
7
- *
8
- * Runs the SDK in headless mode (`ui.headless: true`) the SDK does not
9
- * render any built-in UI; consumers subscribe via `onDisplayUri` (or the
10
- * public `onMetaMaskEvmDisplayUri` helper) to render their own QR /
11
- * deep-link surface. `ui.preferExtension` is always `true`, so the SDK
12
- * auto-routes to the installed MetaMask browser extension whenever
13
- * available and only falls back to QR / deep-link when it isn't.
14
- *
15
- * `display_uri` handling is registered as an `eventHandlers` callback at
16
- * SDK construction time (rather than via `provider.on(...)` after the
17
- * fact) so the first URI emission can never be lost to a race between
18
- * subscription and the SDK's transport selection. The handler caches the
19
- * URI and broadcasts it to every subscribed listener. The `connect` /
20
- * `disconnect` handlers clear the cached URI so that a brand-new pairing
21
- * does not replay a stale URI.
22
- *
23
- * Dapp metadata is sourced from the Dynamic client's app metadata
24
- * (`getAppMetadata`) — name, icon, native scheme, and universal link. No
25
- * other configuration is exposed; the function is intentionally
26
- * parameterless aside from the client to keep the integration's behaviour
27
- * predictable across consumers.
28
- *
29
- * Only ever invoked from a browser context: the function sits behind the
30
- * lazy façade in `createMetaMaskEvmWalletProvider`, which only constructs
31
- * the SDK when the user clicks the MetaMask entry in the wallet picker.
5
+ * client. Runs the SDK in headless mode so consumers render their own QR /
6
+ * deep-link surface, and registers `display_uri` handling as an
7
+ * `eventHandlers` callback at construction time so the first URI emission
8
+ * cannot be lost to a subscription race. Dapp metadata is sourced from the
9
+ * client's `getAppMetadata`. Browser-only.
32
10
  *
33
11
  * @not-instrumented
34
12
  */
@@ -1 +1 @@
1
- {"version":3,"file":"createMetaMaskEvmController.d.ts","sourceRoot":"","sources":["../../../../src/metamask/utils/createMetaMaskEvmController/createMetaMaskEvmController.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAI9D,OAAO,KAAK,EAEV,qBAAqB,EACtB,MAAM,sBAAsB,CAAC;AAI9B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,eAAO,MAAM,2BAA2B,WAC9B,aAAa,KACpB,OAAO,CAAC,qBAAqB,CAwE/B,CAAC"}
1
+ {"version":3,"file":"createMetaMaskEvmController.d.ts","sourceRoot":"","sources":["../../../../src/metamask/utils/createMetaMaskEvmController/createMetaMaskEvmController.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAW9D,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAGlE;;;;;;;;;GASG;AACH,eAAO,MAAM,2BAA2B,WAC9B,aAAa,KACpB,OAAO,CAAC,qBAAqB,CAoH/B,CAAC"}