@dynamic-labs-sdk/evm 1.17.1 → 1.19.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.
- package/dist/{addEIP6963Extension-Nz8vTj11.esm.js → addEIP6963Extension-BjucaEgu.esm.js} +3 -3
- package/dist/{addEIP6963Extension-Nz8vTj11.esm.js.map → addEIP6963Extension-BjucaEgu.esm.js.map} +1 -1
- package/dist/{addEIP6963Extension-5tjpOHPi.cjs → addEIP6963Extension-ButCTeIE.cjs} +3 -3
- package/dist/{addEIP6963Extension-5tjpOHPi.cjs.map → addEIP6963Extension-ButCTeIE.cjs.map} +1 -1
- package/dist/addEvmExtension/addEvmExtension.d.ts +10 -1
- package/dist/addEvmExtension/addEvmExtension.d.ts.map +1 -1
- package/dist/{addWaasEvmExtension-CexieTAz.cjs → addWaasEvmExtension-CIBwjebr.cjs} +3 -3
- package/dist/{addWaasEvmExtension-CexieTAz.cjs.map → addWaasEvmExtension-CIBwjebr.cjs.map} +1 -1
- package/dist/{addWaasEvmExtension-JRgUEac2.esm.js → addWaasEvmExtension-D47UG4zQ.esm.js} +3 -3
- package/dist/{addWaasEvmExtension-JRgUEac2.esm.js.map → addWaasEvmExtension-D47UG4zQ.esm.js.map} +1 -1
- package/dist/{addWaasEvmExtension-CJD8D1Sf.native.esm.js → addWaasEvmExtension-V3vwSfx0.native.esm.js} +2 -2
- package/dist/{addWaasEvmExtension-CJD8D1Sf.native.esm.js.map → addWaasEvmExtension-V3vwSfx0.native.esm.js.map} +1 -1
- package/dist/baseAccount.cjs +4 -4
- package/dist/baseAccount.esm.js +4 -4
- package/dist/baseAccount.native.esm.js +3 -3
- package/dist/{createWalletClientForWalletAccount-CRcI7k6-.esm.js → createWalletClientForWalletAccount-CSV76RdP.esm.js} +2 -2
- package/dist/{createWalletClientForWalletAccount-CRcI7k6-.esm.js.map → createWalletClientForWalletAccount-CSV76RdP.esm.js.map} +1 -1
- package/dist/{createWalletClientForWalletAccount-Cb2uMZxJ.cjs → createWalletClientForWalletAccount-DZ1SUxot.cjs} +2 -2
- package/dist/{createWalletClientForWalletAccount-Cb2uMZxJ.cjs.map → createWalletClientForWalletAccount-DZ1SUxot.cjs.map} +1 -1
- package/dist/{createWalletProviderFromEIP1193Provider-DIplPkf4.cjs → createWalletProviderFromEIP1193Provider-BfIxWk-1.cjs} +2 -2
- package/dist/{createWalletProviderFromEIP1193Provider-DIplPkf4.cjs.map → createWalletProviderFromEIP1193Provider-BfIxWk-1.cjs.map} +1 -1
- package/dist/{createWalletProviderFromEIP1193Provider-D4aKomjq.native.esm.js → createWalletProviderFromEIP1193Provider-BoNh5_kO.native.esm.js} +2 -2
- package/dist/{createWalletProviderFromEIP1193Provider-D4aKomjq.native.esm.js.map → createWalletProviderFromEIP1193Provider-BoNh5_kO.native.esm.js.map} +1 -1
- package/dist/{createWalletProviderFromEIP1193Provider-BQ0d8crZ.esm.js → createWalletProviderFromEIP1193Provider-Dhruqg0P.esm.js} +2 -2
- package/dist/{createWalletProviderFromEIP1193Provider-BQ0d8crZ.esm.js.map → createWalletProviderFromEIP1193Provider-Dhruqg0P.esm.js.map} +1 -1
- package/dist/eip6963.cjs +5 -5
- package/dist/eip6963.esm.js +5 -5
- package/dist/eip6963.native.esm.js +1 -1
- package/dist/{evmTransferAmount-B2lXHyW3.native.esm.js → evmTransferAmount-D9Sygfbl.native.esm.js} +87 -2
- package/dist/evmTransferAmount-D9Sygfbl.native.esm.js.map +1 -0
- package/dist/{evmTransferAmount-C1msMTNe.cjs → evmTransferAmount-bPkkINFr.cjs} +89 -4
- package/dist/evmTransferAmount-bPkkINFr.cjs.map +1 -0
- package/dist/{evmTransferAmount-ebnRuHex.esm.js → evmTransferAmount-zNYlT8-b.esm.js} +89 -4
- package/dist/evmTransferAmount-zNYlT8-b.esm.js.map +1 -0
- package/dist/gasless/activate7702Delegation/activate7702Delegation.d.ts +9 -0
- package/dist/gasless/activate7702Delegation/activate7702Delegation.d.ts.map +1 -1
- package/dist/gasless/getEVMSponsoredTransactionStatus/getEVMSponsoredTransactionStatus.d.ts +10 -0
- package/dist/gasless/getEVMSponsoredTransactionStatus/getEVMSponsoredTransactionStatus.d.ts.map +1 -1
- package/dist/gasless/is7702DelegationActive/is7702DelegationActive.d.ts +11 -1
- package/dist/gasless/is7702DelegationActive/is7702DelegationActive.d.ts.map +1 -1
- package/dist/gasless/isEvmGasSponsorshipEnabled/isEvmGasSponsorshipEnabled.d.ts +9 -0
- package/dist/gasless/isEvmGasSponsorshipEnabled/isEvmGasSponsorshipEnabled.d.ts.map +1 -1
- package/dist/gasless/relaySponsoredTransaction/relaySponsoredTransaction.d.ts +11 -0
- package/dist/gasless/relaySponsoredTransaction/relaySponsoredTransaction.d.ts.map +1 -1
- package/dist/gasless/sendSponsoredTransaction/sendSponsoredTransaction.d.ts +10 -0
- package/dist/gasless/sendSponsoredTransaction/sendSponsoredTransaction.d.ts.map +1 -1
- package/dist/gasless/sign7702Authorization/sign7702Authorization.d.ts +8 -0
- package/dist/gasless/sign7702Authorization/sign7702Authorization.d.ts.map +1 -1
- package/dist/gasless/signSponsoredTransaction/signSponsoredTransaction.d.ts +11 -0
- package/dist/gasless/signSponsoredTransaction/signSponsoredTransaction.d.ts.map +1 -1
- package/dist/gasless/waitForSponsoredTransaction/waitForSponsoredTransaction.d.ts +8 -0
- package/dist/gasless/waitForSponsoredTransaction/waitForSponsoredTransaction.d.ts.map +1 -1
- package/dist/index.cjs +55 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.esm.js +55 -6
- package/dist/index.esm.js.map +1 -1
- package/dist/index.native.esm.js +52 -3
- package/dist/index.native.esm.js.map +1 -1
- package/dist/isEvmNetworkProvider/isEvmNetworkProvider.d.ts +10 -1
- package/dist/isEvmNetworkProvider/isEvmNetworkProvider.d.ts.map +1 -1
- package/dist/{mapNetworkDataToViemChain-6r3qQgSG.esm.js → mapNetworkDataToViemChain-DXy4yka7.esm.js} +2 -2
- package/dist/{mapNetworkDataToViemChain-6r3qQgSG.esm.js.map → mapNetworkDataToViemChain-DXy4yka7.esm.js.map} +1 -1
- package/dist/{mapNetworkDataToViemChain-DHni6ErD.cjs → mapNetworkDataToViemChain-y9sq6Oak.cjs} +2 -2
- package/dist/{mapNetworkDataToViemChain-DHni6ErD.cjs.map → mapNetworkDataToViemChain-y9sq6Oak.cjs.map} +1 -1
- package/dist/metamask.cjs +4 -4
- package/dist/metamask.esm.js +4 -4
- package/dist/metamask.native.esm.js +3 -3
- package/dist/{package-Dt8Q4Vtr.native.esm.js → package-YT_Fw3US.native.esm.js} +2 -2
- package/dist/package-YT_Fw3US.native.esm.js.map +1 -0
- package/dist/simulateEvmTransaction/simulateEvmTransaction.d.ts +12 -1
- package/dist/simulateEvmTransaction/simulateEvmTransaction.d.ts.map +1 -1
- package/dist/tempo.cjs +1 -1
- package/dist/tempo.esm.js +1 -1
- package/dist/tempo.native.esm.js +1 -1
- package/dist/tsconfig.lib.tsbuildinfo +1 -1
- package/dist/utils/calculateEvmTransactionFee/calculateEvmTransactionFee.d.ts +12 -1
- package/dist/utils/calculateEvmTransactionFee/calculateEvmTransactionFee.d.ts.map +1 -1
- package/dist/utils/isEvmWalletAccount/isEvmWalletAccount.d.ts +9 -1
- package/dist/utils/isEvmWalletAccount/isEvmWalletAccount.d.ts.map +1 -1
- package/dist/viem.cjs +2 -2
- package/dist/viem.esm.js +2 -2
- package/dist/viem.native.esm.js +1 -1
- package/dist/waas.cjs +4 -4
- package/dist/waas.esm.js +4 -4
- package/dist/waas.native.esm.js +3 -3
- package/dist/walletConnect.cjs +3 -3
- package/dist/walletConnect.esm.js +3 -3
- package/dist/walletConnect.native.esm.js +2 -2
- package/dist/windowInjected.cjs +4 -4
- package/dist/windowInjected.esm.js +4 -4
- package/dist/windowInjected.native.esm.js +3 -3
- package/package.json +6 -6
- package/dist/evmTransferAmount-B2lXHyW3.native.esm.js.map +0 -1
- package/dist/evmTransferAmount-C1msMTNe.cjs.map +0 -1
- package/dist/evmTransferAmount-ebnRuHex.esm.js.map +0 -1
- package/dist/package-Dt8Q4Vtr.native.esm.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"evmTransferAmount-D9Sygfbl.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 }","calls: SponsoredTransactionCall[]","gasParams: Record<string, bigint>"],"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/errors/RpcError.ts","../src/utils/fetchEvmBalance/fetchEvmBalance.ts","../src/utils/createEvmNetworkProvider/createEvmNetworkProvider.ts","../src/registerEvmNetworkProviderBuilder/registerEvmNetworkProviderBuilder.ts","../src/utils/isEvmWalletAccount/isEvmWalletAccount.ts","../src/utils/evmConfirmTransaction/evmConfirmTransaction.ts","../src/gasless/isEvmGasSponsorshipEnabled/isEvmGasSponsorshipEnabled.ts","../src/utils/approveErc20/approveErc20.ts","../src/utils/getErc20Allowance/getErc20Allowance.ts","../src/utils/approveErc20IfRequiredAndWaitReceipt/approveErc20IfRequiredAndWaitReceipt.ts","../src/utils/evmExecuteSponsoredSwapTransaction/evmExecuteSponsoredSwapTransaction.ts","../src/utils/evmExecuteSwapTransaction/evmExecuteSwapTransaction.ts","../src/utils/evmTransferAmount/evmTransferAmount.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 * @notInstrumented\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 * @notInstrumented\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 * @notInstrumented\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 * @notInstrumented\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 * @notInstrumented\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 * @example\n * ```ts\n * const isDelegated = await is7702DelegationActive({ walletAccount: evmAccount });\n * if (!isDelegated) {\n * await activate7702Delegation({ walletAccount: evmAccount });\n * }\n * ```\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 * @see activate7702Delegation\n * @see sign7702Authorization\n * @notInstrumented\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 * @notInstrumented\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 * @example\n * ```ts\n * const authorization = await sign7702Authorization({ walletAccount: evmAccount });\n * await activate7702Delegation({ walletAccount: evmAccount, authorization });\n * ```\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 * @see activate7702Delegation\n * @see is7702DelegationActive\n * @notInstrumented\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 * @notInstrumented\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 * @notInstrumented\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 /**\n * Optional bitmap nonce to sign the intent with. When provided, intent nonce\n * generation is skipped entirely (no on-chain `isNonceUsed` check) and the\n * supplied value is used as-is. Matches the `nonce` field returned on the\n * signed-transaction result so callers can reuse it. Useful for\n * mutually-exclusive / cancel-replace intents: signing multiple intents with\n * the same nonce so at most one can ever land on-chain.\n */\n nonce?: bigint;\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 * @example\n * ```ts\n * const signedTx = await signSponsoredTransaction({\n * walletAccount: evmAccount,\n * calls: [{ target: '0x...', data: '0x...', value: 0n }],\n * });\n * const { requestId } = await relaySponsoredTransaction({ signedTransaction: signedTx });\n * ```\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.nonce] - Optional bitmap nonce. When provided, nonce generation (and its on-chain check) is skipped and the supplied value is used.\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 * @see sendSponsoredTransaction\n * @see relaySponsoredTransaction\n * @notInstrumented\n */\nexport const signSponsoredTransaction = async (\n {\n walletAccount,\n calls,\n authorization,\n autoDelegate = true,\n nonce: providedNonce,\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 =\n providedNonce ?? (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 /**\n * Optional bitmap nonce to sign the intent with. When provided, nonce\n * generation (and its on-chain check) is skipped and the supplied value is\n * used as-is. Useful for mutually-exclusive / cancel-replace intents.\n */\n nonce?: bigint;\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 * @example\n * ```ts\n * const { requestId } = await relaySponsoredTransaction({\n * walletAccount: evmAccount,\n * calls: [{ target: '0x...', data: '0x...', value: 0n }],\n * });\n * const { transactionHash } = await waitForSponsoredTransaction({ requestId });\n * ```\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 * @see waitForSponsoredTransaction\n * @see signSponsoredTransaction\n * @notInstrumented\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 nonce: params.nonce,\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 * @example\n * ```ts\n * const status = await getEVMSponsoredTransactionStatus({ requestId });\n * if (status.transactionHash) {\n * console.log('On-chain:', status.transactionHash);\n * }\n * ```\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 * @see waitForSponsoredTransaction\n * @see relaySponsoredTransaction\n * @notInstrumented\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 * @example\n * ```ts\n * const { requestId } = await relaySponsoredTransaction({ signedTransaction });\n * const { transactionHash } = await waitForSponsoredTransaction({ requestId });\n * ```\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 * @see relaySponsoredTransaction\n * @see getEVMSponsoredTransactionStatus\n * @notInstrumented\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 /**\n * Optional bitmap nonce to sign the intent with. When provided, nonce\n * generation (and its on-chain check) is skipped and the supplied value is\n * used as-is. Useful for mutually-exclusive / cancel-replace intents.\n */\n nonce?: bigint;\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 * @example\n * ```ts\n * const { transactionHash } = await sendSponsoredTransaction({\n * walletAccount: evmAccount,\n * calls: [{ target: '0x...', data: '0x...', value: 0n }],\n * });\n * ```\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 * @see signSponsoredTransaction\n * @see relaySponsoredTransaction\n * @notInstrumented\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 { BaseError, type BaseErrorParameters } from '@dynamic-labs-sdk/client';\n\nexport type RpcErrorParameters = Pick<BaseErrorParameters, 'shortMessage'> &\n Partial<Omit<BaseErrorParameters, 'shortMessage'>>;\n\nexport class RpcError extends BaseError {\n constructor(args: RpcErrorParameters) {\n super({\n cause: args.cause ?? null,\n code: args.code ?? 'rpc_error',\n details: args.details,\n docsUrl: args.docsUrl ?? null,\n metaMessages: args.metaMessages,\n name: args.name ?? 'RpcError',\n shortMessage: args.shortMessage,\n });\n }\n}\n","import type { DynamicClient, NetworkData } from '@dynamic-labs-sdk/client';\nimport { getCore } from '@dynamic-labs-sdk/client/core';\n\nimport { RpcError } from '../../errors/RpcError';\n\ntype FetchEvmBalanceParams = {\n address: string;\n networkData: NetworkData;\n};\n\n/** @notInstrumented */\nexport const fetchEvmBalance = async (\n { address, networkData }: FetchEvmBalanceParams,\n client: DynamicClient\n): Promise<string | null> => {\n const rpcUrl = networkData.rpcUrls.http[0];\n const core = getCore(client);\n\n try {\n // Perform a POST request to the RPC URL with the JSON-RPC payload\n const response = await core.fetch(rpcUrl, {\n /**\n * The JSON-RPC method 'eth_getBalance' takes the address and a block tag ('latest' is the most recent)\n * See EIP-1474: https://eips.ethereum.org/EIPS/eip-1474\n * See eth_getBalance spec: https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_getbalance\n */\n body: JSON.stringify({\n id: Math.floor(Date.now() + Math.random() * 1000),\n jsonrpc: '2.0',\n method: 'eth_getBalance',\n params: [address, 'latest'],\n }),\n\n headers: {\n 'Content-Type': 'application/json',\n },\n\n method: 'POST',\n });\n\n // Check if the network response was successful\n if (!response.ok) {\n throw new RpcError({\n code: 'http_error',\n shortMessage: `HTTP error! status: ${response.status}`,\n });\n }\n\n const data = await response.json();\n\n // Check for a JSON-RPC error in the response\n if (data.error) {\n throw new RpcError({\n cause: data.error instanceof Error ? data.error : undefined,\n code: 'json_rpc_error',\n shortMessage: `RPC Error: ${data.error.message}`,\n });\n }\n\n // The result is a hexadecimal string representing the balance in Wei\n const balanceWeiHex = data.result;\n\n // Convert the hexadecimal string to a BigInt\n const balanceWei = BigInt(balanceWeiHex);\n\n // Convert the balance from Wei to Ether (1 Ether = 10^18 Wei)\n // We use a BigInt for the conversion to maintain precision with large numbers\n const oneEther = BigInt(1e18);\n\n // Perform the division and return the result as a number\n // Note: This conversion can lose precision for very small amounts, but is generally fine for display purposes.\n const balanceEther = Number(balanceWei) / Number(oneEther);\n\n return balanceEther.toString();\n } catch (error) {\n if (error instanceof Error) {\n throw new RpcError({\n cause: error,\n code: 'rpc_error',\n shortMessage: `Failed to fetch balance for address ${address}`,\n });\n }\n\n throw error;\n }\n};\n","import type { DynamicClient, NetworkData } from '@dynamic-labs-sdk/client';\nimport { createBaseNetworkProvider } from '@dynamic-labs-sdk/client/core';\n\nimport type { EvmNetworkProvider } from '../../EvmNetworkProvider';\nimport { fetchEvmBalance } from '../fetchEvmBalance';\n\n/** @notInstrumented */\nexport const createEvmNetworkProvider = (\n networkData: NetworkData,\n client: DynamicClient\n): EvmNetworkProvider => ({\n ...createBaseNetworkProvider('EVM', networkData),\n\n getBalance: async ({ address }) => ({\n balance: await fetchEvmBalance(\n {\n address,\n networkData,\n },\n client\n ),\n }),\n});\n","import { type DynamicClient } from '@dynamic-labs-sdk/client';\nimport { getNetworkProviderBuilderRegistry } from '@dynamic-labs-sdk/client/core';\n\nimport { createEvmNetworkProvider } from '../utils/createEvmNetworkProvider';\n\n/** @notInstrumented */\nexport const registerEvmNetworkProviderBuilder = (\n client: DynamicClient\n): void => {\n const networkProviderBuilderRegistry =\n getNetworkProviderBuilderRegistry(client);\n\n /**\n * If the Ethereum network provider builder is already registered, return.\n */\n if (networkProviderBuilderRegistry.get().get('EVM')) {\n return;\n }\n\n networkProviderBuilderRegistry.register({\n builder: (networkData) => createEvmNetworkProvider(networkData, client),\n chain: 'EVM',\n });\n};\n","import type { WalletAccount } from '@dynamic-labs-sdk/client';\n\nimport type { EvmWalletAccount } from '../../EvmWalletAccount.types';\n\n/**\n * Type guard function to check if a wallet account is an EVM wallet account.\n *\n * @example\n * ```ts\n * const accounts = getWalletAccounts();\n * const evmAccounts = accounts.filter(isEvmWalletAccount);\n * ```\n *\n * @param walletAccount - The wallet account to check.\n * @returns True if the wallet account is an EVM wallet account, false otherwise.\n * @see isEvmNetworkProvider\n * @see addEvmExtension\n * @notInstrumented\n */\nexport const isEvmWalletAccount = (\n walletAccount: WalletAccount\n): walletAccount is EvmWalletAccount => walletAccount.chain === 'EVM';\n","import {\n type DynamicClient,\n InvalidParamError,\n getActiveNetworkData,\n} from '@dynamic-labs-sdk/client';\nimport type { ConfirmTransactionParams } from '@dynamic-labs-sdk/client/core';\nimport { assertDefined } from '@dynamic-labs-sdk/client/core';\n\nimport { createPublicClientFromNetworkData } from '../../viem/createPublicClientFromNetworkData';\nimport { isEvmWalletAccount } from '../isEvmWalletAccount';\n\n/**\n * Waits for an EVM transaction to be confirmed on-chain.\n *\n * @param params.transactionHash - The transaction hash to wait for.\n * @param params.walletAccount - The EVM wallet account used to resolve the active network.\n * @param client - The Dynamic client instance.\n * @notInstrumented\n */\nexport const evmConfirmTransaction = async (\n { transactionHash, walletAccount }: ConfirmTransactionParams,\n client: DynamicClient\n): Promise<void> => {\n if (!isEvmWalletAccount(walletAccount)) {\n throw new InvalidParamError('Wallet account is not an EVM wallet account');\n }\n\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 publicClient = createPublicClientFromNetworkData({ networkData });\n\n await publicClient.waitForTransactionReceipt({\n hash: transactionHash as `0x${string}`,\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 * @example\n * ```ts\n * if (isEvmGasSponsorshipEnabled()) {\n * await sendSponsoredTransaction({ walletAccount, calls });\n * }\n * ```\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 * @see sendSponsoredTransaction\n * @see activate7702Delegation\n * @notInstrumented\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 { DynamicClient } from '@dynamic-labs-sdk/client';\nimport { encodeFunctionData, erc20Abi } from 'viem';\n\nimport type { EvmWalletAccount } from '../../EvmWalletAccount.types';\nimport { createWalletClientForWalletAccount } from '../../viem/createWalletClientForWalletAccount';\n\ntype ApproveErc20Params = {\n amount: bigint;\n spenderAddress: string;\n tokenAddress: string;\n walletAccount: EvmWalletAccount;\n};\n\n/**\n * Sends an ERC-20 `approve` transaction, granting a spender an allowance\n * to transfer tokens on behalf of the wallet account.\n *\n * Encodes the `approve(spender, amount)` call using viem's `encodeFunctionData`\n * and sends it through the wallet account's viem wallet client.\n *\n * @param params.amount - The amount to approve in the token's smallest unit.\n * @param params.spenderAddress - The address being granted the allowance.\n * @param params.tokenAddress - The ERC-20 token contract address.\n * @param params.walletAccount - The EVM wallet account sending the approval.\n * @param client - The Dynamic client instance.\n * @returns The approval transaction hash.\n * @notInstrumented\n */\nexport const approveErc20 = async (\n { amount, spenderAddress, tokenAddress, walletAccount }: ApproveErc20Params,\n client: DynamicClient\n): Promise<{ transactionHash: string }> => {\n const walletClient = await createWalletClientForWalletAccount(\n { walletAccount },\n client\n );\n\n const data = encodeFunctionData({\n abi: erc20Abi,\n args: [spenderAddress as `0x${string}`, amount],\n functionName: 'approve',\n });\n\n const hash = await walletClient.sendTransaction({\n data,\n to: tokenAddress as `0x${string}`,\n });\n\n return { transactionHash: hash };\n};\n","import {\n type DynamicClient,\n type NetworkData,\n getActiveNetworkData,\n} from '@dynamic-labs-sdk/client';\nimport { assertDefined } from '@dynamic-labs-sdk/client/core';\nimport { erc20Abi } from 'viem';\n\nimport type { EvmWalletAccount } from '../../EvmWalletAccount.types';\nimport { createPublicClientFromNetworkData } from '../../viem/createPublicClientFromNetworkData';\n\ntype GetErc20AllowanceParams = {\n networkData?: NetworkData;\n ownerAddress: string;\n spenderAddress: string;\n tokenAddress: string;\n walletAccount: EvmWalletAccount;\n};\n\n/**\n * Reads the current ERC-20 token allowance granted by an owner to a spender.\n *\n * Uses a viem public client derived from the wallet account's active network\n * to call the `allowance(owner, spender)` method on the token contract.\n *\n * @param params.tokenAddress - The ERC-20 token contract address.\n * @param params.ownerAddress - The address that granted the allowance.\n * @param params.spenderAddress - The address allowed to spend the tokens.\n * @param params.walletAccount - The EVM wallet account used to resolve the active network.\n * @param [params.networkData] - The network data to use for the public client. If not provided, the active network data will be used.\n * @param client - The Dynamic client instance.\n * @returns The current allowance as a bigint in the token's smallest unit.\n * @notInstrumented\n */\nexport const getErc20Allowance = async (\n {\n networkData,\n ownerAddress,\n spenderAddress,\n tokenAddress,\n walletAccount,\n }: GetErc20AllowanceParams,\n client: DynamicClient\n): Promise<bigint> => {\n if (!networkData) {\n const activeNetworkData = await getActiveNetworkData(\n { walletAccount },\n client\n );\n networkData = activeNetworkData.networkData;\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 return publicClient.readContract({\n abi: erc20Abi,\n address: tokenAddress as `0x${string}`,\n args: [ownerAddress as `0x${string}`, spenderAddress as `0x${string}`],\n functionName: 'allowance',\n });\n};\n","import {\n type DynamicClient,\n getActiveNetworkData,\n} from '@dynamic-labs-sdk/client';\nimport { assertDefined } from '@dynamic-labs-sdk/client/core';\nimport type { TransactionReceipt } from 'viem';\n\nimport type { EvmWalletAccount } from '../../EvmWalletAccount.types';\nimport { createPublicClientFromNetworkData } from '../../viem/createPublicClientFromNetworkData';\nimport { approveErc20 } from '../approveErc20';\nimport { getErc20Allowance } from '../getErc20Allowance';\n\ntype ApproveErc20IfRequiredAndWaitReceiptParams = {\n amount: string;\n spenderAddress: string;\n tokenAddress: string;\n walletAccount: EvmWalletAccount;\n};\n\n/**\n * Approves an ERC-20 token if the current allowance is insufficient and waits for the transaction receipt.\n *\n * @param params.amount - The amount of tokens to approve.\n * @param params.ownerAddress - The address that granted the allowance.\n * @param params.spenderAddress - The address allowed to spend the tokens.\n * @param params.tokenAddress - The ERC-20 token contract address.\n * @param params.walletAccount - The EVM wallet account used to resolve the active network.\n * @param client - The Dynamic client instance.\n * @returns The transaction receipt if an approval was sent, otherwise undefined.\n * @notInstrumented\n */\nexport const approveErc20IfRequiredAndWaitReceipt = async (\n {\n amount,\n spenderAddress,\n tokenAddress,\n walletAccount,\n }: ApproveErc20IfRequiredAndWaitReceiptParams,\n client: DynamicClient\n): Promise<{ receipt: TransactionReceipt } | undefined> => {\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 currentAllowance = await getErc20Allowance(\n {\n networkData,\n ownerAddress: walletAccount.address,\n spenderAddress,\n tokenAddress,\n walletAccount,\n },\n client\n );\n\n const approvalAmount = BigInt(amount);\n\n if (currentAllowance >= approvalAmount) {\n return undefined;\n }\n\n const result = await approveErc20(\n {\n amount: approvalAmount,\n spenderAddress,\n tokenAddress,\n walletAccount,\n },\n client\n );\n const approvalTransactionHash = result.transactionHash;\n\n const publicClient = createPublicClientFromNetworkData({ networkData });\n\n const receipt = await publicClient.waitForTransactionReceipt({\n hash: approvalTransactionHash as `0x${string}`,\n });\n\n return { receipt };\n};\n","import {\n type DynamicClient,\n InvalidParamError,\n} from '@dynamic-labs-sdk/client';\nimport type { ExecuteSwapTransactionResult } from '@dynamic-labs-sdk/client/core';\nimport type { SwapSigningPayload } from '@dynamic-labs/sdk-api-core';\nimport { type Hex, encodeFunctionData, erc20Abi } from 'viem';\n\nimport type { EvmWalletAccount } from '../../EvmWalletAccount.types';\nimport type { SponsoredTransactionCall } from '../../gasless/gasless.types';\nimport { sendSponsoredTransaction } from '../../gasless/sendSponsoredTransaction';\nimport { getErc20Allowance } from '../getErc20Allowance';\n\ntype EvmExecuteSponsoredSwapTransactionParams = {\n onStepChange?: (step: 'approval' | 'transaction') => void;\n signingPayload: SwapSigningPayload;\n walletAccount: EvmWalletAccount;\n};\n\n/**\n * Executes an EVM swap as a single gas-sponsored transaction.\n *\n * Unlike the user-paid path, the optional ERC-20 approval and the swap call\n * are batched into one sponsored transaction (EVM gas sponsorship supports\n * call batching), so there is no separate approval transaction hash.\n *\n * 1. If the signing payload includes an `evmApproval`, reads the current\n * allowance and prepends an `approve` call only when it is insufficient\n * 2. Appends the main swap call (gas fields are dropped — the relayer pays gas)\n * 3. Relays the batch via `sendSponsoredTransaction` and waits for inclusion\n *\n * @param params.signingPayload - The signing payload containing `evmTransaction` and optional `evmApproval`.\n * @param params.walletAccount - The embedded EVM wallet account whose gas is sponsored.\n * @param params.onStepChange - Optional callback invoked with `'approval'` or `'transaction'` as each step begins.\n * @param client - The Dynamic client instance.\n * @returns The on-chain transaction hash of the sponsored swap.\n * @notInstrumented\n */\nexport const evmExecuteSponsoredSwapTransaction = async (\n {\n onStepChange,\n signingPayload,\n walletAccount,\n }: EvmExecuteSponsoredSwapTransactionParams,\n client: DynamicClient\n): Promise<ExecuteSwapTransactionResult> => {\n const { evmTransaction, evmApproval } = signingPayload;\n\n if (!evmTransaction) {\n throw new InvalidParamError(\n 'Signing payload is missing EVM transaction data'\n );\n }\n\n const calls: SponsoredTransactionCall[] = [];\n\n if (evmApproval) {\n const approvalAmount = BigInt(evmApproval.amount);\n\n const currentAllowance = await getErc20Allowance(\n {\n ownerAddress: walletAccount.address,\n spenderAddress: evmApproval.spenderAddress,\n tokenAddress: evmApproval.tokenAddress,\n walletAccount,\n },\n client\n );\n\n // Only batch an approval call when the existing allowance is insufficient,\n // matching the user-paid path's allowance check.\n if (currentAllowance < approvalAmount) {\n onStepChange?.('approval');\n\n calls.push({\n data: encodeFunctionData({\n abi: erc20Abi,\n args: [evmApproval.spenderAddress as Hex, approvalAmount],\n functionName: 'approve',\n }),\n target: evmApproval.tokenAddress as Hex,\n value: 0n,\n });\n }\n }\n\n onStepChange?.('transaction');\n\n // Gas fields from the quote are intentionally omitted — the relayer funds gas.\n calls.push({\n data: evmTransaction.data as Hex,\n target: evmTransaction.to as Hex,\n value: evmTransaction.value ? BigInt(evmTransaction.value) : 0n,\n });\n\n const { transactionHash } = await sendSponsoredTransaction(\n { calls, walletAccount },\n client\n );\n\n return { transactionHash };\n};\n","import {\n type DynamicClient,\n InvalidParamError,\n} from '@dynamic-labs-sdk/client';\nimport {\n type ExecuteSwapTransactionParams,\n type ExecuteSwapTransactionResult,\n getWalletProviderFromWalletAccount,\n} from '@dynamic-labs-sdk/client/core';\n\nimport { isEvmGasSponsorshipEnabled } from '../../gasless/isEvmGasSponsorshipEnabled';\nimport { createWalletClientForWalletAccount } from '../../viem/createWalletClientForWalletAccount';\nimport { isEvmWalletProviderWithCustomViemClient } from '../../viem/utils/walletProviderHasCustomWalletClient';\nimport { approveErc20IfRequiredAndWaitReceipt } from '../approveErc20IfRequiredAndWaitReceipt';\nimport { evmExecuteSponsoredSwapTransaction } from '../evmExecuteSponsoredSwapTransaction';\nimport { isEvmWalletAccount } from '../isEvmWalletAccount';\n\n/**\n * Executes an EVM checkout transaction by handling optional ERC-20 approval\n * and sending the main swap transaction on-chain.\n *\n * 1. Validates that the wallet account is an EVM wallet account\n * 2. When EVM gas sponsorship is enabled and the wallet is a Dynamic embedded\n * wallet (and `sponsorshipMode` is not `'off'`), routes the swap through the\n * gas-sponsored path, batching any required approval with the swap call\n * 3. Otherwise, if the signing payload includes an `evmApproval`, checks the\n * current ERC-20 allowance and sends an approve transaction when insufficient\n * 4. Sends the main transaction using the viem wallet client\n *\n * @param params.signingPayload - The chain-aware signing payload containing `evmTransaction` and optional `evmApproval`.\n * @param params.walletAccount - The wallet account used to sign and send transactions.\n * @param params.onStepChange - Optional callback invoked with `'approval'` or `'transaction'` as each step begins.\n * @param params.sponsorshipMode - `'auto'` (default) sponsors when eligible; `'off'` never sponsors.\n * @param client - The Dynamic client instance.\n * @returns The main transaction hash and, if a separate approval was sent, the approval transaction hash.\n * @notInstrumented\n */\nexport const evmExecuteSwapTransaction = async (\n {\n onStepChange,\n signingPayload,\n sponsorshipMode = 'auto',\n walletAccount,\n }: ExecuteSwapTransactionParams,\n client: DynamicClient\n): Promise<ExecuteSwapTransactionResult> => {\n if (!isEvmWalletAccount(walletAccount)) {\n throw new InvalidParamError('Wallet account is not an EVM wallet account');\n }\n\n const walletProvider = getWalletProviderFromWalletAccount(\n { walletAccount },\n client\n );\n\n // Sponsorship requires an embedded wallet (custom viem client) so the\n // EIP-7702 authorization can be signed; external wallets fall through to the\n // user-paid path below.\n if (\n sponsorshipMode === 'auto' &&\n isEvmGasSponsorshipEnabled(client) &&\n isEvmWalletProviderWithCustomViemClient(walletProvider)\n ) {\n return evmExecuteSponsoredSwapTransaction(\n { onStepChange, signingPayload, walletAccount },\n client\n );\n }\n\n const { evmTransaction, evmApproval } = signingPayload;\n\n if (!evmTransaction) {\n throw new InvalidParamError(\n 'Signing payload is missing EVM transaction data'\n );\n }\n\n if (evmApproval) {\n onStepChange?.('approval');\n\n await approveErc20IfRequiredAndWaitReceipt(\n {\n amount: evmApproval.amount,\n spenderAddress: evmApproval.spenderAddress,\n tokenAddress: evmApproval.tokenAddress,\n walletAccount,\n },\n client\n );\n }\n\n onStepChange?.('transaction');\n\n const walletClient = await createWalletClientForWalletAccount(\n { walletAccount },\n client\n );\n\n // sendTransaction expects gasPrice or maxFeePerGas and maxPriorityFeePerGas\n let gasParams: Record<string, bigint> = {};\n if (evmTransaction.maxFeePerGas && evmTransaction.maxPriorityFeePerGas) {\n gasParams = {\n maxFeePerGas: BigInt(evmTransaction.maxFeePerGas),\n maxPriorityFeePerGas: BigInt(evmTransaction.maxPriorityFeePerGas),\n };\n } else {\n gasParams = {\n ...(evmTransaction.gasPrice && {\n gasPrice: BigInt(evmTransaction.gasPrice),\n }),\n };\n }\n\n const transactionHash = await walletClient.sendTransaction({\n data: evmTransaction.data as `0x${string}`,\n to: evmTransaction.to as `0x${string}`,\n value: evmTransaction.value ? BigInt(evmTransaction.value) : 0n,\n ...(evmTransaction.gasLimit && { gas: BigInt(evmTransaction.gasLimit) }),\n ...gasParams,\n ...(evmTransaction.nonce && { nonce: evmTransaction.nonce }),\n });\n\n return { transactionHash };\n};\n","import {\n type DynamicClient,\n InvalidParamError,\n getActiveNetworkData,\n} from '@dynamic-labs-sdk/client';\nimport { assertDefined } from '@dynamic-labs-sdk/client/core';\nimport type { TransferAmountParams } from '@dynamic-labs-sdk/client/core';\nimport { encodeFunctionData, erc20Abi, parseEther, parseUnits } from 'viem';\n\nimport { createPublicClientFromNetworkData } from '../../viem/createPublicClientFromNetworkData';\nimport { createWalletClientForWalletAccount } from '../../viem/createWalletClientForWalletAccount';\nimport { isEvmWalletAccount } from '../isEvmWalletAccount';\n\nconst DEFAULT_DECIMALS = 18;\n\n/** @notInstrumented */\nexport const evmTransferAmount = async (\n { amount, recipient, token, walletAccount }: TransferAmountParams,\n client: DynamicClient\n): Promise<{ transactionHash: string }> => {\n if (!isEvmWalletAccount(walletAccount)) {\n throw new InvalidParamError('Wallet account is not an EVM wallet account');\n }\n\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 publicClient = createPublicClientFromNetworkData({ networkData });\n const nonce = await publicClient.getTransactionCount({\n address: walletAccount.address as `0x${string}`,\n });\n\n const walletClient = await createWalletClientForWalletAccount(\n { walletAccount },\n client\n );\n\n // non-native token transfers\n if (token) {\n const decimals = token.decimals ?? DEFAULT_DECIMALS;\n\n const data = encodeFunctionData({\n abi: erc20Abi,\n args: [recipient as `0x${string}`, parseUnits(amount, decimals)],\n functionName: 'transfer',\n });\n\n const hash = await walletClient.sendTransaction({\n data,\n nonce,\n to: token.address as `0x${string}`,\n });\n\n return { transactionHash: hash };\n }\n\n // native token transfers\n const hash = await walletClient.sendTransaction({\n nonce,\n to: recipient as `0x${string}`,\n value: parseEther(amount),\n });\n\n return { transactionHash: hash };\n};\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;GAA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AAU,OAAO,eAAe,SAAS,EAC1C,EACF;AAYH,QAAO,EAAE,iBATe,MAAM,aAAa,gBAAgB;EACzD,MAAM,eAAe;EACrB,IAAI,eAAe;EACnB,OAAO,eAAe,QAAQ,OAAO,eAAe,MAAM,GAAG;EAC7D,GAAI,eAAe,YAAY,EAAE,KAAK,OAAO,eAAe,SAAS,EAAE;EACvE,GAAG;EACH,GAAI,eAAe,SAAS,EAAE,OAAO,eAAe,OAAO;EAC5D,CAAC,EAEwB;;;;;AC7G5B,MAAM,mBAAmB;;AAGzB,MAAa,oBAAoB,OAC/B,EAAE,QAAQ,WAAW,OAAO,iBAC5B,WACyC;AACzC,KAAI,CAAC,mBAAmB,cAAc,CACpC,OAAM,IAAI,kBAAkB,8CAA8C;CAG5E,MAAM,EAAE,gBAAgB,MAAM,qBAAqB,EAAE,eAAe,EAAE,OAAO;AAE7E,eACE,aACA,4CAA4C,cAAc,UAC3D;CAGD,MAAM,QAAQ,MADO,kCAAkC,EAAE,aAAa,CAAC,CACtC,oBAAoB,EACnD,SAAS,cAAc,SACxB,CAAC;CAEF,MAAM,eAAe,MAAM,mCACzB,EAAE,eAAe,EACjB,OACD;AAGD,KAAI,OAAO;EAGT,MAAM,OAAO,mBAAmB;GAC9B,KAAK;GACL,MAAM,CAAC,WAA4B,WAAW,QAJ/B,MAAM,YAAY,iBAI8B,CAAC;GAChE,cAAc;GACf,CAAC;AAQF,SAAO,EAAE,iBANI,MAAM,aAAa,gBAAgB;GAC9C;GACA;GACA,IAAI,MAAM;GACX,CAAC,EAE8B;;AAUlC,QAAO,EAAE,iBANI,MAAM,aAAa,gBAAgB;EAC9C;EACA,IAAI;EACJ,OAAO,WAAW,OAAO;EAC1B,CAAC,EAE8B"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const require_mapNetworkDataToViemChain = require('./mapNetworkDataToViemChain-
|
|
2
|
-
const require_createWalletClientForWalletAccount = require('./createWalletClientForWalletAccount-
|
|
1
|
+
const require_mapNetworkDataToViemChain = require('./mapNetworkDataToViemChain-y9sq6Oak.cjs');
|
|
2
|
+
const require_createWalletClientForWalletAccount = require('./createWalletClientForWalletAccount-DZ1SUxot.cjs');
|
|
3
3
|
let _dynamic_labs_sdk_client = require("@dynamic-labs-sdk/client");
|
|
4
4
|
let _dynamic_labs_sdk_client_core = require("@dynamic-labs-sdk/client/core");
|
|
5
5
|
let viem = require("viem");
|
|
@@ -195,11 +195,21 @@ const get7702DelegationRegistry = (0, _dynamic_labs_sdk_client_core.createRuntim
|
|
|
195
195
|
* Checks whether EIP-7702 delegation to the Dynamic gasless contract is active
|
|
196
196
|
* for the given wallet account on its current network.
|
|
197
197
|
*
|
|
198
|
-
* Results are cached per wallet+chain in an in-memory registry
|
|
198
|
+
* Results are cached per wallet+chain in an in-memory registry.
|
|
199
|
+
*
|
|
200
|
+
* @example
|
|
201
|
+
* ```ts
|
|
202
|
+
* const isDelegated = await is7702DelegationActive({ walletAccount: evmAccount });
|
|
203
|
+
* if (!isDelegated) {
|
|
204
|
+
* await activate7702Delegation({ walletAccount: evmAccount });
|
|
205
|
+
* }
|
|
206
|
+
* ```
|
|
199
207
|
*
|
|
200
208
|
* @param params.walletAccount - The EVM wallet account to check delegation status for.
|
|
201
209
|
* @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
|
|
202
210
|
* @returns True if the wallet has an active delegation to the gasless contract.
|
|
211
|
+
* @see activate7702Delegation
|
|
212
|
+
* @see sign7702Authorization
|
|
203
213
|
* @notInstrumented
|
|
204
214
|
*/
|
|
205
215
|
const is7702DelegationActive = async ({ walletAccount }, client = (0, _dynamic_labs_sdk_client_core.getDefaultClient)()) => {
|
|
@@ -250,10 +260,18 @@ const resolveChainId = async ({ chainId, walletAccount }, client) => {
|
|
|
250
260
|
* activate the delegation on-chain. If no chainId is provided, the wallet's
|
|
251
261
|
* active network chain ID is used.
|
|
252
262
|
*
|
|
263
|
+
* @example
|
|
264
|
+
* ```ts
|
|
265
|
+
* const authorization = await sign7702Authorization({ walletAccount: evmAccount });
|
|
266
|
+
* await activate7702Delegation({ walletAccount: evmAccount, authorization });
|
|
267
|
+
* ```
|
|
268
|
+
*
|
|
253
269
|
* @param params.walletAccount - The EVM wallet account to sign the authorization for.
|
|
254
270
|
* @param [params.chainId] - Override chain ID. Defaults to the wallet's active network.
|
|
255
271
|
* @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
|
|
256
272
|
* @returns The signed EIP-7702 authorization.
|
|
273
|
+
* @see activate7702Delegation
|
|
274
|
+
* @see is7702DelegationActive
|
|
257
275
|
* @notInstrumented
|
|
258
276
|
*/
|
|
259
277
|
const sign7702Authorization = async ({ walletAccount, chainId }, client = (0, _dynamic_labs_sdk_client_core.getDefaultClient)()) => {
|
|
@@ -316,6 +334,15 @@ const toSerializedAuthorization = (auth) => {
|
|
|
316
334
|
* - If autoDelegate is false and no authorization is provided, the intent
|
|
317
335
|
* is signed without any authorization (user manages delegation separately).
|
|
318
336
|
*
|
|
337
|
+
* @example
|
|
338
|
+
* ```ts
|
|
339
|
+
* const signedTx = await signSponsoredTransaction({
|
|
340
|
+
* walletAccount: evmAccount,
|
|
341
|
+
* calls: [{ target: '0x...', data: '0x...', value: 0n }],
|
|
342
|
+
* });
|
|
343
|
+
* const { requestId } = await relaySponsoredTransaction({ signedTransaction: signedTx });
|
|
344
|
+
* ```
|
|
345
|
+
*
|
|
319
346
|
* @param params.walletAccount - The EVM wallet account to sign with.
|
|
320
347
|
* @param params.calls - The batch of calls to execute.
|
|
321
348
|
* @param [params.authorization] - Pre-signed EIP-7702 authorization. Takes priority over autoDelegate.
|
|
@@ -324,6 +351,8 @@ const toSerializedAuthorization = (auth) => {
|
|
|
324
351
|
* @param [params.validForSeconds] - How long the signed intent remains valid, in seconds. Defaults to 600 (10 minutes).
|
|
325
352
|
* @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
|
|
326
353
|
* @returns The signed sponsored transaction payload ready to be sent to the API.
|
|
354
|
+
* @see sendSponsoredTransaction
|
|
355
|
+
* @see relaySponsoredTransaction
|
|
327
356
|
* @notInstrumented
|
|
328
357
|
*/
|
|
329
358
|
const signSponsoredTransaction = async ({ walletAccount, calls, authorization, autoDelegate = true, nonce: providedNonce, validForSeconds = DEFAULT_VALID_FOR_SECONDS }, client = (0, _dynamic_labs_sdk_client_core.getDefaultClient)()) => {
|
|
@@ -383,10 +412,21 @@ const isSignedTransactionParams = (params) => "signedTransaction" in params;
|
|
|
383
412
|
* submission, so the request ID (not a transaction hash) is the stable
|
|
384
413
|
* identifier for the sponsored transaction.
|
|
385
414
|
*
|
|
415
|
+
* @example
|
|
416
|
+
* ```ts
|
|
417
|
+
* const { requestId } = await relaySponsoredTransaction({
|
|
418
|
+
* walletAccount: evmAccount,
|
|
419
|
+
* calls: [{ target: '0x...', data: '0x...', value: 0n }],
|
|
420
|
+
* });
|
|
421
|
+
* const { transactionHash } = await waitForSponsoredTransaction({ requestId });
|
|
422
|
+
* ```
|
|
423
|
+
*
|
|
386
424
|
* @param params - Either { signedTransaction } or { walletAccount, calls, ... }.
|
|
387
425
|
* @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
|
|
388
426
|
* @returns An object containing the request ID for tracking the relayed transaction.
|
|
389
427
|
* @throws {SponsorTransactionError} If the API call fails or returns an unexpected response.
|
|
428
|
+
* @see waitForSponsoredTransaction
|
|
429
|
+
* @see signSponsoredTransaction
|
|
390
430
|
* @notInstrumented
|
|
391
431
|
*/
|
|
392
432
|
const relaySponsoredTransaction = async (params, client = (0, _dynamic_labs_sdk_client_core.getDefaultClient)()) => {
|
|
@@ -436,10 +476,20 @@ const relaySponsoredTransaction = async (params, client = (0, _dynamic_labs_sdk_
|
|
|
436
476
|
* building block for custom polling flows; for the common "wait until done"
|
|
437
477
|
* case prefer `waitForSponsoredTransaction`.
|
|
438
478
|
*
|
|
479
|
+
* @example
|
|
480
|
+
* ```ts
|
|
481
|
+
* const status = await getEVMSponsoredTransactionStatus({ requestId });
|
|
482
|
+
* if (status.transactionHash) {
|
|
483
|
+
* console.log('On-chain:', status.transactionHash);
|
|
484
|
+
* }
|
|
485
|
+
* ```
|
|
486
|
+
*
|
|
439
487
|
* @param params.requestId - The request ID returned when the transaction was relayed.
|
|
440
488
|
* @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
|
|
441
489
|
* @returns The current status, optional transaction hash, and optional error message.
|
|
442
490
|
* @throws {SponsorTransactionError} If the API call fails.
|
|
491
|
+
* @see waitForSponsoredTransaction
|
|
492
|
+
* @see relaySponsoredTransaction
|
|
443
493
|
* @notInstrumented
|
|
444
494
|
*/
|
|
445
495
|
const getEVMSponsoredTransactionStatus = async ({ requestId }, client = (0, _dynamic_labs_sdk_client_core.getDefaultClient)()) => {
|
|
@@ -470,10 +520,18 @@ const TERMINAL_FAILURE_STATUSES = new Set(["failure"]);
|
|
|
470
520
|
* Polls `getEVMSponsoredTransactionStatus` until the relay reports the
|
|
471
521
|
* transaction has been included on-chain, then returns the transaction hash.
|
|
472
522
|
*
|
|
523
|
+
* @example
|
|
524
|
+
* ```ts
|
|
525
|
+
* const { requestId } = await relaySponsoredTransaction({ signedTransaction });
|
|
526
|
+
* const { transactionHash } = await waitForSponsoredTransaction({ requestId });
|
|
527
|
+
* ```
|
|
528
|
+
*
|
|
473
529
|
* @param params.requestId - The request ID returned when the transaction was relayed.
|
|
474
530
|
* @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
|
|
475
531
|
* @returns An object containing the on-chain transaction hash.
|
|
476
532
|
* @throws {SponsorTransactionError} If the relay returns a terminal failure or polling times out.
|
|
533
|
+
* @see relaySponsoredTransaction
|
|
534
|
+
* @see getEVMSponsoredTransactionStatus
|
|
477
535
|
* @notInstrumented
|
|
478
536
|
*/
|
|
479
537
|
const waitForSponsoredTransaction = async ({ requestId }, client = (0, _dynamic_labs_sdk_client.getDefaultClient)()) => {
|
|
@@ -496,10 +554,20 @@ const waitForSponsoredTransaction = async ({ requestId }, client = (0, _dynamic_
|
|
|
496
554
|
* Relays the transaction and resolves as soon as the relay reports the
|
|
497
555
|
* transaction has been included on-chain.
|
|
498
556
|
*
|
|
557
|
+
* @example
|
|
558
|
+
* ```ts
|
|
559
|
+
* const { transactionHash } = await sendSponsoredTransaction({
|
|
560
|
+
* walletAccount: evmAccount,
|
|
561
|
+
* calls: [{ target: '0x...', data: '0x...', value: 0n }],
|
|
562
|
+
* });
|
|
563
|
+
* ```
|
|
564
|
+
*
|
|
499
565
|
* @param params - Either { signedTransaction } or { walletAccount, calls, ... }.
|
|
500
566
|
* @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
|
|
501
567
|
* @returns An object containing the on-chain transaction hash.
|
|
502
568
|
* @throws {SponsorTransactionError} If the relay returns a terminal failure or polling times out.
|
|
569
|
+
* @see signSponsoredTransaction
|
|
570
|
+
* @see relaySponsoredTransaction
|
|
503
571
|
* @notInstrumented
|
|
504
572
|
*/
|
|
505
573
|
const sendSponsoredTransaction = async (params, client = (0, _dynamic_labs_sdk_client.getDefaultClient)()) => {
|
|
@@ -595,8 +663,16 @@ const registerEvmNetworkProviderBuilder = (client) => {
|
|
|
595
663
|
/**
|
|
596
664
|
* Type guard function to check if a wallet account is an EVM wallet account.
|
|
597
665
|
*
|
|
666
|
+
* @example
|
|
667
|
+
* ```ts
|
|
668
|
+
* const accounts = getWalletAccounts();
|
|
669
|
+
* const evmAccounts = accounts.filter(isEvmWalletAccount);
|
|
670
|
+
* ```
|
|
671
|
+
*
|
|
598
672
|
* @param walletAccount - The wallet account to check.
|
|
599
673
|
* @returns True if the wallet account is an EVM wallet account, false otherwise.
|
|
674
|
+
* @see isEvmNetworkProvider
|
|
675
|
+
* @see addEvmExtension
|
|
600
676
|
* @notInstrumented
|
|
601
677
|
*/
|
|
602
678
|
const isEvmWalletAccount = (walletAccount) => walletAccount.chain === "EVM";
|
|
@@ -623,8 +699,17 @@ const evmConfirmTransaction = async ({ transactionHash, walletAccount }, client)
|
|
|
623
699
|
/**
|
|
624
700
|
* Checks if EVM gas sponsorship is enabled for the current project.
|
|
625
701
|
*
|
|
702
|
+
* @example
|
|
703
|
+
* ```ts
|
|
704
|
+
* if (isEvmGasSponsorshipEnabled()) {
|
|
705
|
+
* await sendSponsoredTransaction({ walletAccount, calls });
|
|
706
|
+
* }
|
|
707
|
+
* ```
|
|
708
|
+
*
|
|
626
709
|
* @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
|
|
627
710
|
* @returns True if EVM gas sponsorship is enabled, false otherwise.
|
|
711
|
+
* @see sendSponsoredTransaction
|
|
712
|
+
* @see activate7702Delegation
|
|
628
713
|
* @notInstrumented
|
|
629
714
|
*/
|
|
630
715
|
const isEvmGasSponsorshipEnabled = (client = (0, _dynamic_labs_sdk_client.getDefaultClient)()) => {
|
|
@@ -962,4 +1047,4 @@ Object.defineProperty(exports, 'waitForSponsoredTransaction', {
|
|
|
962
1047
|
return waitForSponsoredTransaction;
|
|
963
1048
|
}
|
|
964
1049
|
});
|
|
965
|
-
//# sourceMappingURL=evmTransferAmount-
|
|
1050
|
+
//# sourceMappingURL=evmTransferAmount-bPkkINFr.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"evmTransferAmount-bPkkINFr.cjs","names":["BaseError","DELEGATION_CONTRACT_ADDRESS: Hex","BATCH_CALL_OPDATA_AUTH_MODE: Hex","createPublicClientFromNetworkData","data: { relayerAddress?: string }","mapNetworkDataToViemChain","createPublicClientFromNetworkData","mapNetworkDataToViemChain","createWalletClientForWalletAccount","mapNetworkDataToViemChain","createWalletClientForWalletAccount","data: { requestId?: string }","data: {\n errorMessage?: string;\n status: SponsoredTransactionStatus;\n transactionHash?: string;\n }","BaseError","InvalidParamError","createPublicClientFromNetworkData","createWalletClientForWalletAccount","erc20Abi","createPublicClientFromNetworkData","erc20Abi","createPublicClientFromNetworkData","InvalidParamError","calls: SponsoredTransactionCall[]","erc20Abi","InvalidParamError","isEvmWalletProviderWithCustomViemClient","createWalletClientForWalletAccount","gasParams: Record<string, bigint>","InvalidParamError","createPublicClientFromNetworkData","createWalletClientForWalletAccount","erc20Abi"],"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/errors/RpcError.ts","../src/utils/fetchEvmBalance/fetchEvmBalance.ts","../src/utils/createEvmNetworkProvider/createEvmNetworkProvider.ts","../src/registerEvmNetworkProviderBuilder/registerEvmNetworkProviderBuilder.ts","../src/utils/isEvmWalletAccount/isEvmWalletAccount.ts","../src/utils/evmConfirmTransaction/evmConfirmTransaction.ts","../src/gasless/isEvmGasSponsorshipEnabled/isEvmGasSponsorshipEnabled.ts","../src/utils/approveErc20/approveErc20.ts","../src/utils/getErc20Allowance/getErc20Allowance.ts","../src/utils/approveErc20IfRequiredAndWaitReceipt/approveErc20IfRequiredAndWaitReceipt.ts","../src/utils/evmExecuteSponsoredSwapTransaction/evmExecuteSponsoredSwapTransaction.ts","../src/utils/evmExecuteSwapTransaction/evmExecuteSwapTransaction.ts","../src/utils/evmTransferAmount/evmTransferAmount.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 * @notInstrumented\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 * @notInstrumented\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 * @notInstrumented\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 * @notInstrumented\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 * @notInstrumented\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 * @example\n * ```ts\n * const isDelegated = await is7702DelegationActive({ walletAccount: evmAccount });\n * if (!isDelegated) {\n * await activate7702Delegation({ walletAccount: evmAccount });\n * }\n * ```\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 * @see activate7702Delegation\n * @see sign7702Authorization\n * @notInstrumented\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 * @notInstrumented\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 * @example\n * ```ts\n * const authorization = await sign7702Authorization({ walletAccount: evmAccount });\n * await activate7702Delegation({ walletAccount: evmAccount, authorization });\n * ```\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 * @see activate7702Delegation\n * @see is7702DelegationActive\n * @notInstrumented\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 * @notInstrumented\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 * @notInstrumented\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 /**\n * Optional bitmap nonce to sign the intent with. When provided, intent nonce\n * generation is skipped entirely (no on-chain `isNonceUsed` check) and the\n * supplied value is used as-is. Matches the `nonce` field returned on the\n * signed-transaction result so callers can reuse it. Useful for\n * mutually-exclusive / cancel-replace intents: signing multiple intents with\n * the same nonce so at most one can ever land on-chain.\n */\n nonce?: bigint;\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 * @example\n * ```ts\n * const signedTx = await signSponsoredTransaction({\n * walletAccount: evmAccount,\n * calls: [{ target: '0x...', data: '0x...', value: 0n }],\n * });\n * const { requestId } = await relaySponsoredTransaction({ signedTransaction: signedTx });\n * ```\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.nonce] - Optional bitmap nonce. When provided, nonce generation (and its on-chain check) is skipped and the supplied value is used.\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 * @see sendSponsoredTransaction\n * @see relaySponsoredTransaction\n * @notInstrumented\n */\nexport const signSponsoredTransaction = async (\n {\n walletAccount,\n calls,\n authorization,\n autoDelegate = true,\n nonce: providedNonce,\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 =\n providedNonce ?? (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 /**\n * Optional bitmap nonce to sign the intent with. When provided, nonce\n * generation (and its on-chain check) is skipped and the supplied value is\n * used as-is. Useful for mutually-exclusive / cancel-replace intents.\n */\n nonce?: bigint;\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 * @example\n * ```ts\n * const { requestId } = await relaySponsoredTransaction({\n * walletAccount: evmAccount,\n * calls: [{ target: '0x...', data: '0x...', value: 0n }],\n * });\n * const { transactionHash } = await waitForSponsoredTransaction({ requestId });\n * ```\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 * @see waitForSponsoredTransaction\n * @see signSponsoredTransaction\n * @notInstrumented\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 nonce: params.nonce,\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 * @example\n * ```ts\n * const status = await getEVMSponsoredTransactionStatus({ requestId });\n * if (status.transactionHash) {\n * console.log('On-chain:', status.transactionHash);\n * }\n * ```\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 * @see waitForSponsoredTransaction\n * @see relaySponsoredTransaction\n * @notInstrumented\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 * @example\n * ```ts\n * const { requestId } = await relaySponsoredTransaction({ signedTransaction });\n * const { transactionHash } = await waitForSponsoredTransaction({ requestId });\n * ```\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 * @see relaySponsoredTransaction\n * @see getEVMSponsoredTransactionStatus\n * @notInstrumented\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 /**\n * Optional bitmap nonce to sign the intent with. When provided, nonce\n * generation (and its on-chain check) is skipped and the supplied value is\n * used as-is. Useful for mutually-exclusive / cancel-replace intents.\n */\n nonce?: bigint;\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 * @example\n * ```ts\n * const { transactionHash } = await sendSponsoredTransaction({\n * walletAccount: evmAccount,\n * calls: [{ target: '0x...', data: '0x...', value: 0n }],\n * });\n * ```\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 * @see signSponsoredTransaction\n * @see relaySponsoredTransaction\n * @notInstrumented\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 { BaseError, type BaseErrorParameters } from '@dynamic-labs-sdk/client';\n\nexport type RpcErrorParameters = Pick<BaseErrorParameters, 'shortMessage'> &\n Partial<Omit<BaseErrorParameters, 'shortMessage'>>;\n\nexport class RpcError extends BaseError {\n constructor(args: RpcErrorParameters) {\n super({\n cause: args.cause ?? null,\n code: args.code ?? 'rpc_error',\n details: args.details,\n docsUrl: args.docsUrl ?? null,\n metaMessages: args.metaMessages,\n name: args.name ?? 'RpcError',\n shortMessage: args.shortMessage,\n });\n }\n}\n","import type { DynamicClient, NetworkData } from '@dynamic-labs-sdk/client';\nimport { getCore } from '@dynamic-labs-sdk/client/core';\n\nimport { RpcError } from '../../errors/RpcError';\n\ntype FetchEvmBalanceParams = {\n address: string;\n networkData: NetworkData;\n};\n\n/** @notInstrumented */\nexport const fetchEvmBalance = async (\n { address, networkData }: FetchEvmBalanceParams,\n client: DynamicClient\n): Promise<string | null> => {\n const rpcUrl = networkData.rpcUrls.http[0];\n const core = getCore(client);\n\n try {\n // Perform a POST request to the RPC URL with the JSON-RPC payload\n const response = await core.fetch(rpcUrl, {\n /**\n * The JSON-RPC method 'eth_getBalance' takes the address and a block tag ('latest' is the most recent)\n * See EIP-1474: https://eips.ethereum.org/EIPS/eip-1474\n * See eth_getBalance spec: https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_getbalance\n */\n body: JSON.stringify({\n id: Math.floor(Date.now() + Math.random() * 1000),\n jsonrpc: '2.0',\n method: 'eth_getBalance',\n params: [address, 'latest'],\n }),\n\n headers: {\n 'Content-Type': 'application/json',\n },\n\n method: 'POST',\n });\n\n // Check if the network response was successful\n if (!response.ok) {\n throw new RpcError({\n code: 'http_error',\n shortMessage: `HTTP error! status: ${response.status}`,\n });\n }\n\n const data = await response.json();\n\n // Check for a JSON-RPC error in the response\n if (data.error) {\n throw new RpcError({\n cause: data.error instanceof Error ? data.error : undefined,\n code: 'json_rpc_error',\n shortMessage: `RPC Error: ${data.error.message}`,\n });\n }\n\n // The result is a hexadecimal string representing the balance in Wei\n const balanceWeiHex = data.result;\n\n // Convert the hexadecimal string to a BigInt\n const balanceWei = BigInt(balanceWeiHex);\n\n // Convert the balance from Wei to Ether (1 Ether = 10^18 Wei)\n // We use a BigInt for the conversion to maintain precision with large numbers\n const oneEther = BigInt(1e18);\n\n // Perform the division and return the result as a number\n // Note: This conversion can lose precision for very small amounts, but is generally fine for display purposes.\n const balanceEther = Number(balanceWei) / Number(oneEther);\n\n return balanceEther.toString();\n } catch (error) {\n if (error instanceof Error) {\n throw new RpcError({\n cause: error,\n code: 'rpc_error',\n shortMessage: `Failed to fetch balance for address ${address}`,\n });\n }\n\n throw error;\n }\n};\n","import type { DynamicClient, NetworkData } from '@dynamic-labs-sdk/client';\nimport { createBaseNetworkProvider } from '@dynamic-labs-sdk/client/core';\n\nimport type { EvmNetworkProvider } from '../../EvmNetworkProvider';\nimport { fetchEvmBalance } from '../fetchEvmBalance';\n\n/** @notInstrumented */\nexport const createEvmNetworkProvider = (\n networkData: NetworkData,\n client: DynamicClient\n): EvmNetworkProvider => ({\n ...createBaseNetworkProvider('EVM', networkData),\n\n getBalance: async ({ address }) => ({\n balance: await fetchEvmBalance(\n {\n address,\n networkData,\n },\n client\n ),\n }),\n});\n","import { type DynamicClient } from '@dynamic-labs-sdk/client';\nimport { getNetworkProviderBuilderRegistry } from '@dynamic-labs-sdk/client/core';\n\nimport { createEvmNetworkProvider } from '../utils/createEvmNetworkProvider';\n\n/** @notInstrumented */\nexport const registerEvmNetworkProviderBuilder = (\n client: DynamicClient\n): void => {\n const networkProviderBuilderRegistry =\n getNetworkProviderBuilderRegistry(client);\n\n /**\n * If the Ethereum network provider builder is already registered, return.\n */\n if (networkProviderBuilderRegistry.get().get('EVM')) {\n return;\n }\n\n networkProviderBuilderRegistry.register({\n builder: (networkData) => createEvmNetworkProvider(networkData, client),\n chain: 'EVM',\n });\n};\n","import type { WalletAccount } from '@dynamic-labs-sdk/client';\n\nimport type { EvmWalletAccount } from '../../EvmWalletAccount.types';\n\n/**\n * Type guard function to check if a wallet account is an EVM wallet account.\n *\n * @example\n * ```ts\n * const accounts = getWalletAccounts();\n * const evmAccounts = accounts.filter(isEvmWalletAccount);\n * ```\n *\n * @param walletAccount - The wallet account to check.\n * @returns True if the wallet account is an EVM wallet account, false otherwise.\n * @see isEvmNetworkProvider\n * @see addEvmExtension\n * @notInstrumented\n */\nexport const isEvmWalletAccount = (\n walletAccount: WalletAccount\n): walletAccount is EvmWalletAccount => walletAccount.chain === 'EVM';\n","import {\n type DynamicClient,\n InvalidParamError,\n getActiveNetworkData,\n} from '@dynamic-labs-sdk/client';\nimport type { ConfirmTransactionParams } from '@dynamic-labs-sdk/client/core';\nimport { assertDefined } from '@dynamic-labs-sdk/client/core';\n\nimport { createPublicClientFromNetworkData } from '../../viem/createPublicClientFromNetworkData';\nimport { isEvmWalletAccount } from '../isEvmWalletAccount';\n\n/**\n * Waits for an EVM transaction to be confirmed on-chain.\n *\n * @param params.transactionHash - The transaction hash to wait for.\n * @param params.walletAccount - The EVM wallet account used to resolve the active network.\n * @param client - The Dynamic client instance.\n * @notInstrumented\n */\nexport const evmConfirmTransaction = async (\n { transactionHash, walletAccount }: ConfirmTransactionParams,\n client: DynamicClient\n): Promise<void> => {\n if (!isEvmWalletAccount(walletAccount)) {\n throw new InvalidParamError('Wallet account is not an EVM wallet account');\n }\n\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 publicClient = createPublicClientFromNetworkData({ networkData });\n\n await publicClient.waitForTransactionReceipt({\n hash: transactionHash as `0x${string}`,\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 * @example\n * ```ts\n * if (isEvmGasSponsorshipEnabled()) {\n * await sendSponsoredTransaction({ walletAccount, calls });\n * }\n * ```\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 * @see sendSponsoredTransaction\n * @see activate7702Delegation\n * @notInstrumented\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 { DynamicClient } from '@dynamic-labs-sdk/client';\nimport { encodeFunctionData, erc20Abi } from 'viem';\n\nimport type { EvmWalletAccount } from '../../EvmWalletAccount.types';\nimport { createWalletClientForWalletAccount } from '../../viem/createWalletClientForWalletAccount';\n\ntype ApproveErc20Params = {\n amount: bigint;\n spenderAddress: string;\n tokenAddress: string;\n walletAccount: EvmWalletAccount;\n};\n\n/**\n * Sends an ERC-20 `approve` transaction, granting a spender an allowance\n * to transfer tokens on behalf of the wallet account.\n *\n * Encodes the `approve(spender, amount)` call using viem's `encodeFunctionData`\n * and sends it through the wallet account's viem wallet client.\n *\n * @param params.amount - The amount to approve in the token's smallest unit.\n * @param params.spenderAddress - The address being granted the allowance.\n * @param params.tokenAddress - The ERC-20 token contract address.\n * @param params.walletAccount - The EVM wallet account sending the approval.\n * @param client - The Dynamic client instance.\n * @returns The approval transaction hash.\n * @notInstrumented\n */\nexport const approveErc20 = async (\n { amount, spenderAddress, tokenAddress, walletAccount }: ApproveErc20Params,\n client: DynamicClient\n): Promise<{ transactionHash: string }> => {\n const walletClient = await createWalletClientForWalletAccount(\n { walletAccount },\n client\n );\n\n const data = encodeFunctionData({\n abi: erc20Abi,\n args: [spenderAddress as `0x${string}`, amount],\n functionName: 'approve',\n });\n\n const hash = await walletClient.sendTransaction({\n data,\n to: tokenAddress as `0x${string}`,\n });\n\n return { transactionHash: hash };\n};\n","import {\n type DynamicClient,\n type NetworkData,\n getActiveNetworkData,\n} from '@dynamic-labs-sdk/client';\nimport { assertDefined } from '@dynamic-labs-sdk/client/core';\nimport { erc20Abi } from 'viem';\n\nimport type { EvmWalletAccount } from '../../EvmWalletAccount.types';\nimport { createPublicClientFromNetworkData } from '../../viem/createPublicClientFromNetworkData';\n\ntype GetErc20AllowanceParams = {\n networkData?: NetworkData;\n ownerAddress: string;\n spenderAddress: string;\n tokenAddress: string;\n walletAccount: EvmWalletAccount;\n};\n\n/**\n * Reads the current ERC-20 token allowance granted by an owner to a spender.\n *\n * Uses a viem public client derived from the wallet account's active network\n * to call the `allowance(owner, spender)` method on the token contract.\n *\n * @param params.tokenAddress - The ERC-20 token contract address.\n * @param params.ownerAddress - The address that granted the allowance.\n * @param params.spenderAddress - The address allowed to spend the tokens.\n * @param params.walletAccount - The EVM wallet account used to resolve the active network.\n * @param [params.networkData] - The network data to use for the public client. If not provided, the active network data will be used.\n * @param client - The Dynamic client instance.\n * @returns The current allowance as a bigint in the token's smallest unit.\n * @notInstrumented\n */\nexport const getErc20Allowance = async (\n {\n networkData,\n ownerAddress,\n spenderAddress,\n tokenAddress,\n walletAccount,\n }: GetErc20AllowanceParams,\n client: DynamicClient\n): Promise<bigint> => {\n if (!networkData) {\n const activeNetworkData = await getActiveNetworkData(\n { walletAccount },\n client\n );\n networkData = activeNetworkData.networkData;\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 return publicClient.readContract({\n abi: erc20Abi,\n address: tokenAddress as `0x${string}`,\n args: [ownerAddress as `0x${string}`, spenderAddress as `0x${string}`],\n functionName: 'allowance',\n });\n};\n","import {\n type DynamicClient,\n getActiveNetworkData,\n} from '@dynamic-labs-sdk/client';\nimport { assertDefined } from '@dynamic-labs-sdk/client/core';\nimport type { TransactionReceipt } from 'viem';\n\nimport type { EvmWalletAccount } from '../../EvmWalletAccount.types';\nimport { createPublicClientFromNetworkData } from '../../viem/createPublicClientFromNetworkData';\nimport { approveErc20 } from '../approveErc20';\nimport { getErc20Allowance } from '../getErc20Allowance';\n\ntype ApproveErc20IfRequiredAndWaitReceiptParams = {\n amount: string;\n spenderAddress: string;\n tokenAddress: string;\n walletAccount: EvmWalletAccount;\n};\n\n/**\n * Approves an ERC-20 token if the current allowance is insufficient and waits for the transaction receipt.\n *\n * @param params.amount - The amount of tokens to approve.\n * @param params.ownerAddress - The address that granted the allowance.\n * @param params.spenderAddress - The address allowed to spend the tokens.\n * @param params.tokenAddress - The ERC-20 token contract address.\n * @param params.walletAccount - The EVM wallet account used to resolve the active network.\n * @param client - The Dynamic client instance.\n * @returns The transaction receipt if an approval was sent, otherwise undefined.\n * @notInstrumented\n */\nexport const approveErc20IfRequiredAndWaitReceipt = async (\n {\n amount,\n spenderAddress,\n tokenAddress,\n walletAccount,\n }: ApproveErc20IfRequiredAndWaitReceiptParams,\n client: DynamicClient\n): Promise<{ receipt: TransactionReceipt } | undefined> => {\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 currentAllowance = await getErc20Allowance(\n {\n networkData,\n ownerAddress: walletAccount.address,\n spenderAddress,\n tokenAddress,\n walletAccount,\n },\n client\n );\n\n const approvalAmount = BigInt(amount);\n\n if (currentAllowance >= approvalAmount) {\n return undefined;\n }\n\n const result = await approveErc20(\n {\n amount: approvalAmount,\n spenderAddress,\n tokenAddress,\n walletAccount,\n },\n client\n );\n const approvalTransactionHash = result.transactionHash;\n\n const publicClient = createPublicClientFromNetworkData({ networkData });\n\n const receipt = await publicClient.waitForTransactionReceipt({\n hash: approvalTransactionHash as `0x${string}`,\n });\n\n return { receipt };\n};\n","import {\n type DynamicClient,\n InvalidParamError,\n} from '@dynamic-labs-sdk/client';\nimport type { ExecuteSwapTransactionResult } from '@dynamic-labs-sdk/client/core';\nimport type { SwapSigningPayload } from '@dynamic-labs/sdk-api-core';\nimport { type Hex, encodeFunctionData, erc20Abi } from 'viem';\n\nimport type { EvmWalletAccount } from '../../EvmWalletAccount.types';\nimport type { SponsoredTransactionCall } from '../../gasless/gasless.types';\nimport { sendSponsoredTransaction } from '../../gasless/sendSponsoredTransaction';\nimport { getErc20Allowance } from '../getErc20Allowance';\n\ntype EvmExecuteSponsoredSwapTransactionParams = {\n onStepChange?: (step: 'approval' | 'transaction') => void;\n signingPayload: SwapSigningPayload;\n walletAccount: EvmWalletAccount;\n};\n\n/**\n * Executes an EVM swap as a single gas-sponsored transaction.\n *\n * Unlike the user-paid path, the optional ERC-20 approval and the swap call\n * are batched into one sponsored transaction (EVM gas sponsorship supports\n * call batching), so there is no separate approval transaction hash.\n *\n * 1. If the signing payload includes an `evmApproval`, reads the current\n * allowance and prepends an `approve` call only when it is insufficient\n * 2. Appends the main swap call (gas fields are dropped — the relayer pays gas)\n * 3. Relays the batch via `sendSponsoredTransaction` and waits for inclusion\n *\n * @param params.signingPayload - The signing payload containing `evmTransaction` and optional `evmApproval`.\n * @param params.walletAccount - The embedded EVM wallet account whose gas is sponsored.\n * @param params.onStepChange - Optional callback invoked with `'approval'` or `'transaction'` as each step begins.\n * @param client - The Dynamic client instance.\n * @returns The on-chain transaction hash of the sponsored swap.\n * @notInstrumented\n */\nexport const evmExecuteSponsoredSwapTransaction = async (\n {\n onStepChange,\n signingPayload,\n walletAccount,\n }: EvmExecuteSponsoredSwapTransactionParams,\n client: DynamicClient\n): Promise<ExecuteSwapTransactionResult> => {\n const { evmTransaction, evmApproval } = signingPayload;\n\n if (!evmTransaction) {\n throw new InvalidParamError(\n 'Signing payload is missing EVM transaction data'\n );\n }\n\n const calls: SponsoredTransactionCall[] = [];\n\n if (evmApproval) {\n const approvalAmount = BigInt(evmApproval.amount);\n\n const currentAllowance = await getErc20Allowance(\n {\n ownerAddress: walletAccount.address,\n spenderAddress: evmApproval.spenderAddress,\n tokenAddress: evmApproval.tokenAddress,\n walletAccount,\n },\n client\n );\n\n // Only batch an approval call when the existing allowance is insufficient,\n // matching the user-paid path's allowance check.\n if (currentAllowance < approvalAmount) {\n onStepChange?.('approval');\n\n calls.push({\n data: encodeFunctionData({\n abi: erc20Abi,\n args: [evmApproval.spenderAddress as Hex, approvalAmount],\n functionName: 'approve',\n }),\n target: evmApproval.tokenAddress as Hex,\n value: 0n,\n });\n }\n }\n\n onStepChange?.('transaction');\n\n // Gas fields from the quote are intentionally omitted — the relayer funds gas.\n calls.push({\n data: evmTransaction.data as Hex,\n target: evmTransaction.to as Hex,\n value: evmTransaction.value ? BigInt(evmTransaction.value) : 0n,\n });\n\n const { transactionHash } = await sendSponsoredTransaction(\n { calls, walletAccount },\n client\n );\n\n return { transactionHash };\n};\n","import {\n type DynamicClient,\n InvalidParamError,\n} from '@dynamic-labs-sdk/client';\nimport {\n type ExecuteSwapTransactionParams,\n type ExecuteSwapTransactionResult,\n getWalletProviderFromWalletAccount,\n} from '@dynamic-labs-sdk/client/core';\n\nimport { isEvmGasSponsorshipEnabled } from '../../gasless/isEvmGasSponsorshipEnabled';\nimport { createWalletClientForWalletAccount } from '../../viem/createWalletClientForWalletAccount';\nimport { isEvmWalletProviderWithCustomViemClient } from '../../viem/utils/walletProviderHasCustomWalletClient';\nimport { approveErc20IfRequiredAndWaitReceipt } from '../approveErc20IfRequiredAndWaitReceipt';\nimport { evmExecuteSponsoredSwapTransaction } from '../evmExecuteSponsoredSwapTransaction';\nimport { isEvmWalletAccount } from '../isEvmWalletAccount';\n\n/**\n * Executes an EVM checkout transaction by handling optional ERC-20 approval\n * and sending the main swap transaction on-chain.\n *\n * 1. Validates that the wallet account is an EVM wallet account\n * 2. When EVM gas sponsorship is enabled and the wallet is a Dynamic embedded\n * wallet (and `sponsorshipMode` is not `'off'`), routes the swap through the\n * gas-sponsored path, batching any required approval with the swap call\n * 3. Otherwise, if the signing payload includes an `evmApproval`, checks the\n * current ERC-20 allowance and sends an approve transaction when insufficient\n * 4. Sends the main transaction using the viem wallet client\n *\n * @param params.signingPayload - The chain-aware signing payload containing `evmTransaction` and optional `evmApproval`.\n * @param params.walletAccount - The wallet account used to sign and send transactions.\n * @param params.onStepChange - Optional callback invoked with `'approval'` or `'transaction'` as each step begins.\n * @param params.sponsorshipMode - `'auto'` (default) sponsors when eligible; `'off'` never sponsors.\n * @param client - The Dynamic client instance.\n * @returns The main transaction hash and, if a separate approval was sent, the approval transaction hash.\n * @notInstrumented\n */\nexport const evmExecuteSwapTransaction = async (\n {\n onStepChange,\n signingPayload,\n sponsorshipMode = 'auto',\n walletAccount,\n }: ExecuteSwapTransactionParams,\n client: DynamicClient\n): Promise<ExecuteSwapTransactionResult> => {\n if (!isEvmWalletAccount(walletAccount)) {\n throw new InvalidParamError('Wallet account is not an EVM wallet account');\n }\n\n const walletProvider = getWalletProviderFromWalletAccount(\n { walletAccount },\n client\n );\n\n // Sponsorship requires an embedded wallet (custom viem client) so the\n // EIP-7702 authorization can be signed; external wallets fall through to the\n // user-paid path below.\n if (\n sponsorshipMode === 'auto' &&\n isEvmGasSponsorshipEnabled(client) &&\n isEvmWalletProviderWithCustomViemClient(walletProvider)\n ) {\n return evmExecuteSponsoredSwapTransaction(\n { onStepChange, signingPayload, walletAccount },\n client\n );\n }\n\n const { evmTransaction, evmApproval } = signingPayload;\n\n if (!evmTransaction) {\n throw new InvalidParamError(\n 'Signing payload is missing EVM transaction data'\n );\n }\n\n if (evmApproval) {\n onStepChange?.('approval');\n\n await approveErc20IfRequiredAndWaitReceipt(\n {\n amount: evmApproval.amount,\n spenderAddress: evmApproval.spenderAddress,\n tokenAddress: evmApproval.tokenAddress,\n walletAccount,\n },\n client\n );\n }\n\n onStepChange?.('transaction');\n\n const walletClient = await createWalletClientForWalletAccount(\n { walletAccount },\n client\n );\n\n // sendTransaction expects gasPrice or maxFeePerGas and maxPriorityFeePerGas\n let gasParams: Record<string, bigint> = {};\n if (evmTransaction.maxFeePerGas && evmTransaction.maxPriorityFeePerGas) {\n gasParams = {\n maxFeePerGas: BigInt(evmTransaction.maxFeePerGas),\n maxPriorityFeePerGas: BigInt(evmTransaction.maxPriorityFeePerGas),\n };\n } else {\n gasParams = {\n ...(evmTransaction.gasPrice && {\n gasPrice: BigInt(evmTransaction.gasPrice),\n }),\n };\n }\n\n const transactionHash = await walletClient.sendTransaction({\n data: evmTransaction.data as `0x${string}`,\n to: evmTransaction.to as `0x${string}`,\n value: evmTransaction.value ? BigInt(evmTransaction.value) : 0n,\n ...(evmTransaction.gasLimit && { gas: BigInt(evmTransaction.gasLimit) }),\n ...gasParams,\n ...(evmTransaction.nonce && { nonce: evmTransaction.nonce }),\n });\n\n return { transactionHash };\n};\n","import {\n type DynamicClient,\n InvalidParamError,\n getActiveNetworkData,\n} from '@dynamic-labs-sdk/client';\nimport { assertDefined } from '@dynamic-labs-sdk/client/core';\nimport type { TransferAmountParams } from '@dynamic-labs-sdk/client/core';\nimport { encodeFunctionData, erc20Abi, parseEther, parseUnits } from 'viem';\n\nimport { createPublicClientFromNetworkData } from '../../viem/createPublicClientFromNetworkData';\nimport { createWalletClientForWalletAccount } from '../../viem/createWalletClientForWalletAccount';\nimport { isEvmWalletAccount } from '../isEvmWalletAccount';\n\nconst DEFAULT_DECIMALS = 18;\n\n/** @notInstrumented */\nexport const evmTransferAmount = async (\n { amount, recipient, token, walletAccount }: TransferAmountParams,\n client: DynamicClient\n): Promise<{ transactionHash: string }> => {\n if (!isEvmWalletAccount(walletAccount)) {\n throw new InvalidParamError('Wallet account is not an EVM wallet account');\n }\n\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 publicClient = createPublicClientFromNetworkData({ networkData });\n const nonce = await publicClient.getTransactionCount({\n address: walletAccount.address as `0x${string}`,\n });\n\n const walletClient = await createWalletClientForWalletAccount(\n { walletAccount },\n client\n );\n\n // non-native token transfers\n if (token) {\n const decimals = token.decimals ?? DEFAULT_DECIMALS;\n\n const data = encodeFunctionData({\n abi: erc20Abi,\n args: [recipient as `0x${string}`, parseUnits(amount, decimals)],\n functionName: 'transfer',\n });\n\n const hash = await walletClient.sendTransaction({\n data,\n nonce,\n to: token.address as `0x${string}`,\n });\n\n return { transactionHash: hash };\n }\n\n // native token transfers\n const hash = await walletClient.sendTransaction({\n nonce,\n to: recipient as `0x${string}`,\n value: parseEther(amount),\n });\n\n return { transactionHash: hash };\n};\n"],"mappings":";;;;;;;;AAEA,IAAa,0BAAb,cAA6CA,mCAAU;CAErD,YAAY,OAAsB,SAAkB;AAClD,QAAM;GACJ,OAAO,SAAS;GAChB,MAAM;GACN;GACA,SAAS;GACT,MAAM;GACN,cAAc;GACf,CAAC;;;;;;;ACTN,MAAaC,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,MAAM;GAAQ,MAAM;GAAS;EAChC;CACF;;AAGD,MAAa,UAAU,CACrB;CACE,QAAQ,CAAC;EAAE,MAAM;EAAS,MAAM;EAAW,CAAC;CAC5C,MAAM;CACN,SAAS,CAAC;EAAE,MAAM;EAAI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