@dynamic-labs-sdk/evm 0.26.10 → 0.27.1
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-BGiaYPZ8.esm.js → addEIP6963Extension-DY_uBbsl.esm.js} +3 -3
- package/dist/{addEIP6963Extension-BGiaYPZ8.esm.js.map → addEIP6963Extension-DY_uBbsl.esm.js.map} +1 -1
- package/dist/{addEIP6963Extension-XLk4ZCzv.cjs → addEIP6963Extension-JRJ5n0gz.cjs} +3 -3
- package/dist/{addEIP6963Extension-XLk4ZCzv.cjs.map → addEIP6963Extension-JRJ5n0gz.cjs.map} +1 -1
- package/dist/{addWaasEvmExtension-Dcqn8tuk.esm.js → addWaasEvmExtension-C3PagcGV.esm.js} +11 -9
- package/dist/addWaasEvmExtension-C3PagcGV.esm.js.map +1 -0
- package/dist/{addWaasEvmExtension-ByAFCvSO.cjs → addWaasEvmExtension-CyA9mAdv.cjs} +9 -7
- package/dist/addWaasEvmExtension-CyA9mAdv.cjs.map +1 -0
- package/dist/{addWaasEvmExtension-BV00iC4G.native.esm.js → addWaasEvmExtension-U4DO_WKC.native.esm.js} +9 -7
- package/dist/addWaasEvmExtension-U4DO_WKC.native.esm.js.map +1 -0
- package/dist/baseAccount.cjs +3 -3
- package/dist/baseAccount.esm.js +3 -3
- package/dist/baseAccount.native.esm.js +2 -2
- package/dist/{createWalletClientForWalletAccount-CdPqgZ9Z.cjs → createWalletClientForWalletAccount-BHIvXpr4.cjs} +2 -2
- package/dist/{createWalletClientForWalletAccount-CdPqgZ9Z.cjs.map → createWalletClientForWalletAccount-BHIvXpr4.cjs.map} +1 -1
- package/dist/{createWalletClientForWalletAccount-v2L0zaTG.esm.js → createWalletClientForWalletAccount-CZV3vNed.esm.js} +2 -2
- package/dist/{createWalletClientForWalletAccount-v2L0zaTG.esm.js.map → createWalletClientForWalletAccount-CZV3vNed.esm.js.map} +1 -1
- package/dist/{createWalletProviderFromEIP1193Provider-bineK7Q2.cjs → createWalletProviderFromEIP1193Provider-BTqRU-9M.cjs} +12 -11
- package/dist/createWalletProviderFromEIP1193Provider-BTqRU-9M.cjs.map +1 -0
- package/dist/{createWalletProviderFromEIP1193Provider-C4fMHK3w.esm.js → createWalletProviderFromEIP1193Provider-BjUbWLgv.esm.js} +13 -12
- package/dist/createWalletProviderFromEIP1193Provider-BjUbWLgv.esm.js.map +1 -0
- package/dist/{createWalletProviderFromEIP1193Provider-RVjz6Jte.native.esm.js → createWalletProviderFromEIP1193Provider-DnPhiRmj.native.esm.js} +12 -11
- package/dist/createWalletProviderFromEIP1193Provider-DnPhiRmj.native.esm.js.map +1 -0
- package/dist/eip6963.cjs +4 -4
- package/dist/eip6963.esm.js +4 -4
- package/dist/eip6963.native.esm.js +1 -1
- package/dist/errors/EvmGasSponsorshipNotEnabledError/EvmGasSponsorshipNotEnabledError.d.ts +5 -0
- package/dist/errors/EvmGasSponsorshipNotEnabledError/EvmGasSponsorshipNotEnabledError.d.ts.map +1 -0
- package/dist/errors/EvmGasSponsorshipNotEnabledError/index.d.ts +2 -0
- package/dist/errors/EvmGasSponsorshipNotEnabledError/index.d.ts.map +1 -0
- package/dist/errors/SponsorTransactionError/SponsorTransactionError.d.ts +5 -0
- package/dist/errors/SponsorTransactionError/SponsorTransactionError.d.ts.map +1 -0
- package/dist/errors/SponsorTransactionError/index.d.ts +2 -0
- package/dist/errors/SponsorTransactionError/index.d.ts.map +1 -0
- package/dist/{evmTransferAmount-C7eeBuhc.cjs → evmTransferAmount-CW-6opOL.cjs} +2 -2
- package/dist/{evmTransferAmount-C7eeBuhc.cjs.map → evmTransferAmount-CW-6opOL.cjs.map} +1 -1
- package/dist/{evmTransferAmount-tTUJbYcr.esm.js → evmTransferAmount-DpvL2yet.esm.js} +2 -2
- package/dist/{evmTransferAmount-tTUJbYcr.esm.js.map → evmTransferAmount-DpvL2yet.esm.js.map} +1 -1
- package/dist/exports/index.d.ts +9 -0
- package/dist/exports/index.d.ts.map +1 -1
- package/dist/gasless/constants.d.ts +55 -0
- package/dist/gasless/constants.d.ts.map +1 -0
- package/dist/gasless/gasless.types.d.ts +61 -0
- package/dist/gasless/gasless.types.d.ts.map +1 -0
- package/dist/gasless/generateIntentNonce/generateIntentNonce.d.ts +20 -0
- package/dist/gasless/generateIntentNonce/generateIntentNonce.d.ts.map +1 -0
- package/dist/gasless/generateIntentNonce/index.d.ts +2 -0
- package/dist/gasless/generateIntentNonce/index.d.ts.map +1 -0
- package/dist/gasless/generateRandomNonce/generateRandomNonce.d.ts +8 -0
- package/dist/gasless/generateRandomNonce/generateRandomNonce.d.ts.map +1 -0
- package/dist/gasless/generateRandomNonce/index.d.ts +2 -0
- package/dist/gasless/generateRandomNonce/index.d.ts.map +1 -0
- package/dist/gasless/getEVMSponsoredTransactionStatus/getEVMSponsoredTransactionStatus.d.ts +22 -0
- package/dist/gasless/getEVMSponsoredTransactionStatus/getEVMSponsoredTransactionStatus.d.ts.map +1 -0
- package/dist/gasless/getEVMSponsoredTransactionStatus/index.d.ts +2 -0
- package/dist/gasless/getEVMSponsoredTransactionStatus/index.d.ts.map +1 -0
- package/dist/gasless/isEvmGasSponsorshipEnabled/index.d.ts +2 -0
- package/dist/gasless/isEvmGasSponsorshipEnabled/index.d.ts.map +1 -0
- package/dist/gasless/isEvmGasSponsorshipEnabled/isEvmGasSponsorshipEnabled.d.ts +9 -0
- package/dist/gasless/isEvmGasSponsorshipEnabled/isEvmGasSponsorshipEnabled.d.ts.map +1 -0
- package/dist/gasless/relaySponsoredTransaction/index.d.ts +2 -0
- package/dist/gasless/relaySponsoredTransaction/index.d.ts.map +1 -0
- package/dist/gasless/relaySponsoredTransaction/relaySponsoredTransaction.d.ts +40 -0
- package/dist/gasless/relaySponsoredTransaction/relaySponsoredTransaction.d.ts.map +1 -0
- package/dist/gasless/resolveChainId/index.d.ts +2 -0
- package/dist/gasless/resolveChainId/index.d.ts.map +1 -0
- package/dist/gasless/resolveChainId/resolveChainId.d.ts +18 -0
- package/dist/gasless/resolveChainId/resolveChainId.d.ts.map +1 -0
- package/dist/gasless/sendSponsoredTransaction/index.d.ts +2 -0
- package/dist/gasless/sendSponsoredTransaction/index.d.ts.map +1 -0
- package/dist/gasless/sendSponsoredTransaction/sendSponsoredTransaction.d.ts +38 -0
- package/dist/gasless/sendSponsoredTransaction/sendSponsoredTransaction.d.ts.map +1 -0
- package/dist/gasless/signSponsoredTransaction/index.d.ts +2 -0
- package/dist/gasless/signSponsoredTransaction/index.d.ts.map +1 -0
- package/dist/gasless/signSponsoredTransaction/signSponsoredTransaction.d.ts +31 -0
- package/dist/gasless/signSponsoredTransaction/signSponsoredTransaction.d.ts.map +1 -0
- package/dist/gasless/toSerializedAuthorization/index.d.ts +2 -0
- package/dist/gasless/toSerializedAuthorization/index.d.ts.map +1 -0
- package/dist/gasless/toSerializedAuthorization/toSerializedAuthorization.d.ts +10 -0
- package/dist/gasless/toSerializedAuthorization/toSerializedAuthorization.d.ts.map +1 -0
- package/dist/gasless/waitForSponsoredTransaction/index.d.ts +2 -0
- package/dist/gasless/waitForSponsoredTransaction/index.d.ts.map +1 -0
- package/dist/gasless/waitForSponsoredTransaction/waitForSponsoredTransaction.d.ts +24 -0
- package/dist/gasless/waitForSponsoredTransaction/waitForSponsoredTransaction.d.ts.map +1 -0
- package/dist/index.cjs +387 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.esm.js +382 -8
- package/dist/index.esm.js.map +1 -1
- package/dist/index.native.esm.js +380 -6
- package/dist/index.native.esm.js.map +1 -1
- package/dist/{package-CFCOfOsa.native.esm.js → package-BhhgtLsT.native.esm.js} +2 -2
- package/dist/package-BhhgtLsT.native.esm.js.map +1 -0
- package/dist/tsconfig.lib.tsbuildinfo +1 -1
- package/dist/utils/createWalletProviderFromEIP1193Provider/createWalletProviderFromEIP1193Provider.d.ts.map +1 -1
- package/dist/viem.cjs +1 -1
- package/dist/viem.esm.js +1 -1
- package/dist/viem.native.esm.js +1 -1
- package/dist/waas/utils/createWalletProviderForWaasEvm/createWalletProviderForWaasEvm.d.ts.map +1 -1
- package/dist/waas/utils/createWalletProviderForWaasEvm/signAuthorization/signAuthorization.d.ts.map +1 -1
- package/dist/waas/utils/createWalletProviderForWaasEvm/signTypedData/signTypedData.d.ts.map +1 -1
- package/dist/waas.cjs +3 -3
- package/dist/waas.esm.js +3 -3
- package/dist/waas.native.esm.js +2 -2
- package/dist/walletConnect/createWalletProviderFromEIP155Session/createWalletProviderFromEIP155Session.d.ts.map +1 -1
- package/dist/walletConnect.cjs +17 -14
- package/dist/walletConnect.cjs.map +1 -1
- package/dist/walletConnect.esm.js +17 -14
- package/dist/walletConnect.esm.js.map +1 -1
- package/dist/walletConnect.native.esm.js +16 -13
- package/dist/walletConnect.native.esm.js.map +1 -1
- package/dist/windowInjected.cjs +3 -3
- package/dist/windowInjected.esm.js +3 -3
- package/dist/windowInjected.native.esm.js +2 -2
- package/package.json +6 -6
- package/dist/addWaasEvmExtension-BV00iC4G.native.esm.js.map +0 -1
- package/dist/addWaasEvmExtension-ByAFCvSO.cjs.map +0 -1
- package/dist/addWaasEvmExtension-Dcqn8tuk.esm.js.map +0 -1
- package/dist/createWalletProviderFromEIP1193Provider-C4fMHK3w.esm.js.map +0 -1
- package/dist/createWalletProviderFromEIP1193Provider-RVjz6Jte.native.esm.js.map +0 -1
- package/dist/createWalletProviderFromEIP1193Provider-bineK7Q2.cjs.map +0 -1
- package/dist/package-CFCOfOsa.native.esm.js.map +0 -1
package/dist/{evmTransferAmount-tTUJbYcr.esm.js.map → evmTransferAmount-DpvL2yet.esm.js.map}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"evmTransferAmount-tTUJbYcr.esm.js","names":["gasParams: Record<string, bigint>"],"sources":["../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/utils/approveErc20/approveErc20.ts","../src/utils/getErc20Allowance/getErc20Allowance.ts","../src/utils/approveErc20IfRequiredAndWaitReceipt/approveErc20IfRequiredAndWaitReceipt.ts","../src/utils/evmExecuteSwapTransaction/evmExecuteSwapTransaction.ts","../src/utils/evmTransferAmount/evmTransferAmount.ts"],"sourcesContent":["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/** @not-instrumented */\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/** @not-instrumented */\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/** @not-instrumented */\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 * @param walletAccount - The wallet account to check.\n * @returns True if the wallet account is an EVM wallet account, false otherwise.\n * @not-instrumented\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 * @not-instrumented\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 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 * @not-instrumented\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 * @not-instrumented\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 * @not-instrumented\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 {\n ExecuteSwapTransactionParams,\n ExecuteSwapTransactionResult,\n} from '@dynamic-labs-sdk/client/core';\n\nimport { createWalletClientForWalletAccount } from '../../viem/createWalletClientForWalletAccount';\nimport { approveErc20IfRequiredAndWaitReceipt } from '../approveErc20IfRequiredAndWaitReceipt';\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. If the signing payload includes an `evmApproval`, checks the current\n * ERC-20 allowance and sends an approve transaction when insufficient\n * 3. 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 client - The Dynamic client instance.\n * @returns The main transaction hash and, if an approval was sent, the approval transaction hash.\n * @not-instrumented\n */\nexport const evmExecuteSwapTransaction = async (\n { onStepChange, signingPayload, walletAccount }: 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 { 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/** @not-instrumented */\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":";;;;;;AAKA,IAAa,WAAb,cAA8B,UAAU;CACtC,YAAY,MAA0B;AACpC,QAAM;GACJ,OAAO,KAAK,SAAS;GACrB,MAAM,KAAK,QAAQ;GACnB,SAAS,KAAK;GACd,SAAS,KAAK,WAAW;GACzB,cAAc,KAAK;GACnB,MAAM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AC7D,GAAI,eAAe,YAAY,EAAE,KAAK,OAAO,eAAe,SAAS,EAAE;EACvE,GAAG;EACH,GAAI,eAAe,SAAS,EAAE,OAAO,eAAe,OAAO;EAC5D,CAAC,EAEwB;;;;;AC7E5B,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
|
+
{"version":3,"file":"evmTransferAmount-DpvL2yet.esm.js","names":["gasParams: Record<string, bigint>"],"sources":["../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/utils/approveErc20/approveErc20.ts","../src/utils/getErc20Allowance/getErc20Allowance.ts","../src/utils/approveErc20IfRequiredAndWaitReceipt/approveErc20IfRequiredAndWaitReceipt.ts","../src/utils/evmExecuteSwapTransaction/evmExecuteSwapTransaction.ts","../src/utils/evmTransferAmount/evmTransferAmount.ts"],"sourcesContent":["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/** @not-instrumented */\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/** @not-instrumented */\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/** @not-instrumented */\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 * @param walletAccount - The wallet account to check.\n * @returns True if the wallet account is an EVM wallet account, false otherwise.\n * @not-instrumented\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 * @not-instrumented\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 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 * @not-instrumented\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 * @not-instrumented\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 * @not-instrumented\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 {\n ExecuteSwapTransactionParams,\n ExecuteSwapTransactionResult,\n} from '@dynamic-labs-sdk/client/core';\n\nimport { createWalletClientForWalletAccount } from '../../viem/createWalletClientForWalletAccount';\nimport { approveErc20IfRequiredAndWaitReceipt } from '../approveErc20IfRequiredAndWaitReceipt';\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. If the signing payload includes an `evmApproval`, checks the current\n * ERC-20 allowance and sends an approve transaction when insufficient\n * 3. 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 client - The Dynamic client instance.\n * @returns The main transaction hash and, if an approval was sent, the approval transaction hash.\n * @not-instrumented\n */\nexport const evmExecuteSwapTransaction = async (\n { onStepChange, signingPayload, walletAccount }: 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 { 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/** @not-instrumented */\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":";;;;;;AAKA,IAAa,WAAb,cAA8B,UAAU;CACtC,YAAY,MAA0B;AACpC,QAAM;GACJ,OAAO,KAAK,SAAS;GACrB,MAAM,KAAK,QAAQ;GACnB,SAAS,KAAK;GACd,SAAS,KAAK,WAAW;GACzB,cAAc,KAAK;GACnB,MAAM,KAAK,QAAQ;GACnB,cAAc,KAAK;GACpB,CAAC;;;;;;;ACJN,MAAa,kBAAkB,OAC7B,EAAE,SAAS,eACX,WAC2B;CAC3B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Ae,OAAO;EAC5D,CAAC,EAEwB;;;;;AC7E5B,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"}
|
package/dist/exports/index.d.ts
CHANGED
|
@@ -1,11 +1,20 @@
|
|
|
1
1
|
export { addEvmExtension } from '../addEvmExtension';
|
|
2
|
+
export { EvmGasSponsorshipNotEnabledError } from '../errors/EvmGasSponsorshipNotEnabledError';
|
|
2
3
|
export { RpcError } from '../errors/RpcError';
|
|
4
|
+
export { SponsorTransactionError } from '../errors/SponsorTransactionError';
|
|
3
5
|
export type { EvmNetworkProvider } from '../EvmNetworkProvider';
|
|
4
6
|
export type { EvmWalletAccount } from '../EvmWalletAccount.types';
|
|
5
7
|
export type { EvmWalletProvider } from '../EvmWalletProvider.types';
|
|
8
|
+
export type { SerializedAuthorization, SignedSponsoredTransaction, SponsoredTransactionCall, SponsoredTransactionStatus, SponsoredTransactionStatusResult, } from '../gasless/gasless.types';
|
|
9
|
+
export { getEVMSponsoredTransactionStatus } from '../gasless/getEVMSponsoredTransactionStatus';
|
|
10
|
+
export { isEvmGasSponsorshipEnabled } from '../gasless/isEvmGasSponsorshipEnabled';
|
|
6
11
|
export { isEvmNetworkProvider } from '../isEvmNetworkProvider';
|
|
7
12
|
export { simulateEvmTransaction } from '../simulateEvmTransaction';
|
|
8
13
|
export type { EvmSimulationResult, EvmTransactionFeeData, EvmTransactionToSimulate, } from '../transactionSimulation.types';
|
|
9
14
|
export { calculateEvmTransactionFee } from '../utils/calculateEvmTransactionFee';
|
|
10
15
|
export { isEvmWalletAccount } from '../utils/isEvmWalletAccount';
|
|
16
|
+
export { relaySponsoredTransaction } from '../gasless/relaySponsoredTransaction';
|
|
17
|
+
export { sendSponsoredTransaction } from '../gasless/sendSponsoredTransaction';
|
|
18
|
+
export { signSponsoredTransaction } from '../gasless/signSponsoredTransaction';
|
|
19
|
+
export { waitForSponsoredTransaction } from '../gasless/waitForSponsoredTransaction';
|
|
11
20
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/exports/index.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,YAAY,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAChE,YAAY,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAClE,YAAY,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AACpE,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAC/D,OAAO,EAAE,sBAAsB,EAAE,MAAM,2BAA2B,CAAC;AACnE,YAAY,EACV,mBAAmB,EACnB,qBAAqB,EACrB,wBAAwB,GAC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MAAM,qCAAqC,CAAC;AAC/E,OAAO,EAAE,2BAA2B,EAAE,MAAM,wCAAwC,CAAC"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import type { Hex } from 'viem';
|
|
2
|
+
/** The Fireblocks Universal Gasless Delegate (UGD) contract address used for EIP-7702 delegation. */
|
|
3
|
+
export declare const DELEGATION_CONTRACT_ADDRESS: Hex;
|
|
4
|
+
/** The ERC-7821 Forwarder contract address that relays calls to the delegated wallet. */
|
|
5
|
+
export declare const RELAYER_CONTRACT_ADDRESS: Hex;
|
|
6
|
+
/** Default sponsored transaction validity duration in seconds (10 minutes). */
|
|
7
|
+
export declare const DEFAULT_VALID_FOR_SECONDS = 600;
|
|
8
|
+
/** EIP-7702 delegation code prefix used to identify delegated accounts. */
|
|
9
|
+
export declare const DELEGATION_CODE_PREFIX = "0xef0100";
|
|
10
|
+
/** ERC-7579 batch call with opData and auth mode identifier. */
|
|
11
|
+
export declare const BATCH_CALL_OPDATA_AUTH_MODE: Hex;
|
|
12
|
+
/** EIP-712 typed data types for UGD AuthorizedExecutions signing. */
|
|
13
|
+
export declare const AUTHORIZED_EXECUTIONS_TYPES: {
|
|
14
|
+
readonly AuthorizedExecutions: readonly [{
|
|
15
|
+
readonly name: "calls";
|
|
16
|
+
readonly type: "Execution[]";
|
|
17
|
+
}, {
|
|
18
|
+
readonly name: "deadline";
|
|
19
|
+
readonly type: "uint256";
|
|
20
|
+
}, {
|
|
21
|
+
readonly name: "mode";
|
|
22
|
+
readonly type: "bytes32";
|
|
23
|
+
}, {
|
|
24
|
+
readonly name: "nonce";
|
|
25
|
+
readonly type: "uint256";
|
|
26
|
+
}, {
|
|
27
|
+
readonly name: "relayer";
|
|
28
|
+
readonly type: "address";
|
|
29
|
+
}];
|
|
30
|
+
readonly Execution: readonly [{
|
|
31
|
+
readonly name: "target";
|
|
32
|
+
readonly type: "address";
|
|
33
|
+
}, {
|
|
34
|
+
readonly name: "value";
|
|
35
|
+
readonly type: "uint256";
|
|
36
|
+
}, {
|
|
37
|
+
readonly name: "data";
|
|
38
|
+
readonly type: "bytes";
|
|
39
|
+
}];
|
|
40
|
+
};
|
|
41
|
+
/** Minimal ABI for the UGD contract's nonce validation function. */
|
|
42
|
+
export declare const UGD_ABI: readonly [{
|
|
43
|
+
readonly inputs: readonly [{
|
|
44
|
+
readonly name: "nonce";
|
|
45
|
+
readonly type: "uint256";
|
|
46
|
+
}];
|
|
47
|
+
readonly name: "isNonceUsed";
|
|
48
|
+
readonly outputs: readonly [{
|
|
49
|
+
readonly name: "";
|
|
50
|
+
readonly type: "bool";
|
|
51
|
+
}];
|
|
52
|
+
readonly stateMutability: "view";
|
|
53
|
+
readonly type: "function";
|
|
54
|
+
}];
|
|
55
|
+
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/gasless/constants.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,MAAM,CAAC;AAEhC,qGAAqG;AACrG,eAAO,MAAM,2BAA2B,EAAE,GACI,CAAC;AAE/C,yFAAyF;AACzF,eAAO,MAAM,wBAAwB,EAAE,GACO,CAAC;AAE/C,+EAA+E;AAC/E,eAAO,MAAM,yBAAyB,MAAM,CAAC;AAE7C,2EAA2E;AAC3E,eAAO,MAAM,sBAAsB,aAAa,CAAC;AAEjD,gEAAgE;AAChE,eAAO,MAAM,2BAA2B,EAAE,GAC4B,CAAC;AAEvE,qEAAqE;AACrE,eAAO,MAAM,2BAA2B;;;;;;;;;;;;;;;;;;;;;;;;;;;CAa9B,CAAC;AAEX,oEAAoE;AACpE,eAAO,MAAM,OAAO;;;;;;;;;;;;EAQV,CAAC"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import type { Hex } from 'viem';
|
|
2
|
+
/** A single call within a sponsored transaction batch. */
|
|
3
|
+
export type SponsoredTransactionCall = {
|
|
4
|
+
/** Hex-encoded calldata to execute on the target. */
|
|
5
|
+
data: Hex;
|
|
6
|
+
/** Target contract address. */
|
|
7
|
+
target: Hex;
|
|
8
|
+
/** Amount of native token (in wei) to send with the call. */
|
|
9
|
+
value: bigint;
|
|
10
|
+
};
|
|
11
|
+
/** Serialized EIP-7702 authorization for JSON transport. */
|
|
12
|
+
export type SerializedAuthorization = {
|
|
13
|
+
/** Contract address to delegate to. */
|
|
14
|
+
address: Hex;
|
|
15
|
+
/** Chain ID the authorization is valid for. */
|
|
16
|
+
chainId: number;
|
|
17
|
+
/** EOA transaction nonce at signing time. */
|
|
18
|
+
nonce: number;
|
|
19
|
+
/** ECDSA signature r component. */
|
|
20
|
+
r: Hex;
|
|
21
|
+
/** ECDSA signature s component. */
|
|
22
|
+
s: Hex;
|
|
23
|
+
/** ECDSA signature y-parity. */
|
|
24
|
+
yParity: number;
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* Lifecycle status of a sponsored transaction relay request.
|
|
28
|
+
*
|
|
29
|
+
* Mirrors the redcoast `getEVMSponsoredTransactionStatus` enum so the SDK's
|
|
30
|
+
* polling logic stays decoupled from any specific underlying relayer.
|
|
31
|
+
*/
|
|
32
|
+
export type SponsoredTransactionStatus = 'CANCELED' | 'CONFIRMED' | 'EXPIRED' | 'FAILED' | 'PENDING' | 'REJECTED' | 'SENT' | 'SUBMITTED';
|
|
33
|
+
/** Result of a `getEVMSponsoredTransactionStatus` lookup. */
|
|
34
|
+
export type SponsoredTransactionStatusResult = {
|
|
35
|
+
/** Error message when the status is a terminal failure. */
|
|
36
|
+
errorMessage?: string;
|
|
37
|
+
/** Current relay state for the request. */
|
|
38
|
+
status: SponsoredTransactionStatus;
|
|
39
|
+
/** On-chain transaction hash once the relay has broadcast / confirmed it. */
|
|
40
|
+
transactionHash?: Hex;
|
|
41
|
+
};
|
|
42
|
+
/** The signed payload ready to be sent to the sponsorship API. */
|
|
43
|
+
export type SignedSponsoredTransaction = {
|
|
44
|
+
/** EIP-7702 authorization for delegation, if needed. */
|
|
45
|
+
authorization?: SerializedAuthorization;
|
|
46
|
+
/** The batch of calls to execute. */
|
|
47
|
+
calls: SponsoredTransactionCall[];
|
|
48
|
+
/** Target chain ID. */
|
|
49
|
+
chainId: number;
|
|
50
|
+
/** Intent expiration as a unix timestamp string. */
|
|
51
|
+
deadline: string;
|
|
52
|
+
/** Bitmap nonce as a string (uint256). */
|
|
53
|
+
nonce: string;
|
|
54
|
+
/** The relayer contract address signed in the EIP-712 intent. */
|
|
55
|
+
relayer: Hex;
|
|
56
|
+
/** EIP-712 signature over the AuthorizedExecutions typed data. */
|
|
57
|
+
signature: Hex;
|
|
58
|
+
/** The user's wallet address. */
|
|
59
|
+
walletAddress: Hex;
|
|
60
|
+
};
|
|
61
|
+
//# sourceMappingURL=gasless.types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gasless.types.d.ts","sourceRoot":"","sources":["../../src/gasless/gasless.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,MAAM,CAAC;AAEhC,0DAA0D;AAC1D,MAAM,MAAM,wBAAwB,GAAG;IACrC,qDAAqD;IACrD,IAAI,EAAE,GAAG,CAAC;IACV,+BAA+B;IAC/B,MAAM,EAAE,GAAG,CAAC;IACZ,6DAA6D;IAC7D,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,4DAA4D;AAC5D,MAAM,MAAM,uBAAuB,GAAG;IACpC,uCAAuC;IACvC,OAAO,EAAE,GAAG,CAAC;IACb,+CAA+C;IAC/C,OAAO,EAAE,MAAM,CAAC;IAChB,6CAA6C;IAC7C,KAAK,EAAE,MAAM,CAAC;IACd,mCAAmC;IACnC,CAAC,EAAE,GAAG,CAAC;IACP,mCAAmC;IACnC,CAAC,EAAE,GAAG,CAAC;IACP,gCAAgC;IAChC,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF;;;;;GAKG;AACH,MAAM,MAAM,0BAA0B,GAClC,UAAU,GACV,WAAW,GACX,SAAS,GACT,QAAQ,GACR,SAAS,GACT,UAAU,GACV,MAAM,GACN,WAAW,CAAC;AAEhB,6DAA6D;AAC7D,MAAM,MAAM,gCAAgC,GAAG;IAC7C,2DAA2D;IAC3D,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,2CAA2C;IAC3C,MAAM,EAAE,0BAA0B,CAAC;IACnC,6EAA6E;IAC7E,eAAe,CAAC,EAAE,GAAG,CAAC;CACvB,CAAC;AAEF,kEAAkE;AAClE,MAAM,MAAM,0BAA0B,GAAG;IACvC,wDAAwD;IACxD,aAAa,CAAC,EAAE,uBAAuB,CAAC;IACxC,qCAAqC;IACrC,KAAK,EAAE,wBAAwB,EAAE,CAAC;IAClC,uBAAuB;IACvB,OAAO,EAAE,MAAM,CAAC;IAChB,oDAAoD;IACpD,QAAQ,EAAE,MAAM,CAAC;IACjB,0CAA0C;IAC1C,KAAK,EAAE,MAAM,CAAC;IACd,iEAAiE;IACjE,OAAO,EAAE,GAAG,CAAC;IACb,kEAAkE;IAClE,SAAS,EAAE,GAAG,CAAC;IACf,iCAAiC;IACjC,aAAa,EAAE,GAAG,CAAC;CACpB,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { DynamicClient } from '@dynamic-labs-sdk/client';
|
|
2
|
+
import type { EvmWalletAccount } from '../../EvmWalletAccount.types';
|
|
3
|
+
type GenerateIntentNonceParams = {
|
|
4
|
+
walletAccount: EvmWalletAccount;
|
|
5
|
+
};
|
|
6
|
+
/**
|
|
7
|
+
* Generates a random bitmap nonce for UGD AuthorizedExecutions signing.
|
|
8
|
+
*
|
|
9
|
+
* Uses crypto.getRandomValues() for 256-bit randomness. Validates against
|
|
10
|
+
* the on-chain isNonceUsed check as a safety measure, although collision
|
|
11
|
+
* is essentially impossible with 256-bit random values.
|
|
12
|
+
*
|
|
13
|
+
* @param params.walletAccount - The wallet account whose delegation contract is checked.
|
|
14
|
+
* @param [client] - The Dynamic client instance.
|
|
15
|
+
* @returns A unique bigint nonce for the EIP-712 intent.
|
|
16
|
+
* @not-instrumented
|
|
17
|
+
*/
|
|
18
|
+
export declare const generateIntentNonce: ({ walletAccount }: GenerateIntentNonceParams, client: DynamicClient) => Promise<bigint>;
|
|
19
|
+
export {};
|
|
20
|
+
//# sourceMappingURL=generateIntentNonce.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generateIntentNonce.d.ts","sourceRoot":"","sources":["../../../src/gasless/generateIntentNonce/generateIntentNonce.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAK9D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAKrE,KAAK,yBAAyB,GAAG;IAC/B,aAAa,EAAE,gBAAgB,CAAC;CACjC,CAAC;AAEF;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,mBAAmB,sBACX,yBAAyB,UACpC,aAAa,KACpB,OAAO,CAAC,MAAM,CAkChB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/gasless/generateIntentNonce/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generateRandomNonce.d.ts","sourceRoot":"","sources":["../../../src/gasless/generateRandomNonce/generateRandomNonce.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,eAAO,MAAM,mBAAmB,QAAO,MAKtC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/gasless/generateRandomNonce/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { SponsoredTransactionStatusResult } from '../gasless.types';
|
|
2
|
+
type GetEVMSponsoredTransactionStatusParams = {
|
|
3
|
+
/** The request ID returned by `relaySponsoredTransaction` / `sendSponsoredTransaction`. */
|
|
4
|
+
requestId: string;
|
|
5
|
+
};
|
|
6
|
+
/**
|
|
7
|
+
* Fetches the current relay state for a sponsored EVM transaction.
|
|
8
|
+
*
|
|
9
|
+
* Returns the lifecycle status, the on-chain transaction hash (when the relay
|
|
10
|
+
* has broadcast it), and any terminal-failure error message. Use this as the
|
|
11
|
+
* building block for custom polling flows; for the common "wait until done"
|
|
12
|
+
* case prefer `waitForSponsoredTransaction`.
|
|
13
|
+
*
|
|
14
|
+
* @param params.requestId - The request ID returned when the transaction was relayed.
|
|
15
|
+
* @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
|
|
16
|
+
* @returns The current status, optional transaction hash, and optional error message.
|
|
17
|
+
* @throws {SponsorTransactionError} If the API call fails.
|
|
18
|
+
* @not-instrumented
|
|
19
|
+
*/
|
|
20
|
+
export declare const getEVMSponsoredTransactionStatus: ({ requestId }: GetEVMSponsoredTransactionStatusParams, client?: import("@dynamic-labs-sdk/client").DynamicClient) => Promise<SponsoredTransactionStatusResult>;
|
|
21
|
+
export {};
|
|
22
|
+
//# sourceMappingURL=getEVMSponsoredTransactionStatus.d.ts.map
|
package/dist/gasless/getEVMSponsoredTransactionStatus/getEVMSponsoredTransactionStatus.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getEVMSponsoredTransactionStatus.d.ts","sourceRoot":"","sources":["../../../src/gasless/getEVMSponsoredTransactionStatus/getEVMSponsoredTransactionStatus.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAEV,gCAAgC,EACjC,MAAM,kBAAkB,CAAC;AAE1B,KAAK,sCAAsC,GAAG;IAC5C,2FAA2F;IAC3F,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,gCAAgC,kBAC5B,sCAAsC,gEAEpD,OAAO,CAAC,gCAAgC,CA2B1C,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/gasless/getEVMSponsoredTransactionStatus/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gCAAgC,EAAE,MAAM,oCAAoC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/gasless/isEvmGasSponsorshipEnabled/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,0BAA0B,EAAE,MAAM,8BAA8B,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Checks if EVM gas sponsorship is enabled for the current project.
|
|
3
|
+
*
|
|
4
|
+
* @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
|
|
5
|
+
* @returns True if EVM gas sponsorship is enabled, false otherwise.
|
|
6
|
+
* @not-instrumented
|
|
7
|
+
*/
|
|
8
|
+
export declare const isEvmGasSponsorshipEnabled: (client?: import("@dynamic-labs-sdk/client").DynamicClient) => boolean;
|
|
9
|
+
//# sourceMappingURL=isEvmGasSponsorshipEnabled.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isEvmGasSponsorshipEnabled.d.ts","sourceRoot":"","sources":["../../../src/gasless/isEvmGasSponsorshipEnabled/isEvmGasSponsorshipEnabled.ts"],"names":[],"mappings":"AAGA;;;;;;GAMG;AACH,eAAO,MAAM,0BAA0B,iEAEpC,OAOF,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/gasless/relaySponsoredTransaction/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,MAAM,6BAA6B,CAAC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { SignAuthorizationReturnType } from 'viem/accounts';
|
|
2
|
+
import type { EvmWalletAccount } from '../../EvmWalletAccount.types';
|
|
3
|
+
import type { SignedSponsoredTransaction, SponsoredTransactionCall } from '../gasless.types';
|
|
4
|
+
type RelaySponsoredTransactionWithCallsParams = {
|
|
5
|
+
/** Pre-signed EIP-7702 authorization to include in the payload. */
|
|
6
|
+
authorization?: SignAuthorizationReturnType;
|
|
7
|
+
/** The batch of calls to execute. */
|
|
8
|
+
calls: SponsoredTransactionCall[];
|
|
9
|
+
/** How long the signed intent remains valid, in seconds. Defaults to 600 (10 minutes). */
|
|
10
|
+
validForSeconds?: number;
|
|
11
|
+
/** The EVM wallet account to sign and relay the transaction for. */
|
|
12
|
+
walletAccount: EvmWalletAccount;
|
|
13
|
+
};
|
|
14
|
+
type RelaySponsoredTransactionWithSignedTxParams = {
|
|
15
|
+
/** A pre-signed sponsored transaction payload from signSponsoredTransaction. */
|
|
16
|
+
signedTransaction: SignedSponsoredTransaction;
|
|
17
|
+
};
|
|
18
|
+
type RelaySponsoredTransactionParams = RelaySponsoredTransactionWithCallsParams | RelaySponsoredTransactionWithSignedTxParams;
|
|
19
|
+
/**
|
|
20
|
+
* Relays a sponsored EVM transaction to the Dynamic backend.
|
|
21
|
+
*
|
|
22
|
+
* Accepts either a pre-signed transaction or unsigned calls. When given
|
|
23
|
+
* unsigned calls, signs the transaction first via signSponsoredTransaction.
|
|
24
|
+
*
|
|
25
|
+
* The backend encodes the transaction, submits it to the relay provider,
|
|
26
|
+
* and returns a request ID for tracking. The relay may retry the on-chain
|
|
27
|
+
* submission, so the request ID (not a transaction hash) is the stable
|
|
28
|
+
* identifier for the sponsored transaction.
|
|
29
|
+
*
|
|
30
|
+
* @param params - Either { signedTransaction } or { walletAccount, calls, ... }.
|
|
31
|
+
* @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
|
|
32
|
+
* @returns An object containing the request ID for tracking the relayed transaction.
|
|
33
|
+
* @throws {SponsorTransactionError} If the API call fails or returns an unexpected response.
|
|
34
|
+
* @not-instrumented
|
|
35
|
+
*/
|
|
36
|
+
export declare const relaySponsoredTransaction: (params: RelaySponsoredTransactionParams, client?: import("@dynamic-labs-sdk/client").DynamicClient) => Promise<{
|
|
37
|
+
requestId: string;
|
|
38
|
+
}>;
|
|
39
|
+
export {};
|
|
40
|
+
//# sourceMappingURL=relaySponsoredTransaction.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"relaySponsoredTransaction.d.ts","sourceRoot":"","sources":["../../../src/gasless/relaySponsoredTransaction/relaySponsoredTransaction.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,eAAe,CAAC;AAEjE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAGrE,OAAO,KAAK,EACV,0BAA0B,EAC1B,wBAAwB,EACzB,MAAM,kBAAkB,CAAC;AAG1B,KAAK,wCAAwC,GAAG;IAC9C,mEAAmE;IACnE,aAAa,CAAC,EAAE,2BAA2B,CAAC;IAC5C,qCAAqC;IACrC,KAAK,EAAE,wBAAwB,EAAE,CAAC;IAClC,0FAA0F;IAC1F,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,oEAAoE;IACpE,aAAa,EAAE,gBAAgB,CAAC;CACjC,CAAC;AAEF,KAAK,2CAA2C,GAAG;IACjD,gFAAgF;IAChF,iBAAiB,EAAE,0BAA0B,CAAC;CAC/C,CAAC;AAEF,KAAK,+BAA+B,GAChC,wCAAwC,GACxC,2CAA2C,CAAC;AAOhD;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,yBAAyB,WAC5B,+BAA+B,gEAEtC,OAAO,CAAC;IAAE,SAAS,EAAE,MAAM,CAAA;CAAE,CA8C/B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/gasless/resolveChainId/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { DynamicClient } from '@dynamic-labs-sdk/client';
|
|
2
|
+
import type { EvmWalletAccount } from '../../EvmWalletAccount.types';
|
|
3
|
+
type ResolveChainIdParams = {
|
|
4
|
+
chainId?: number;
|
|
5
|
+
walletAccount: EvmWalletAccount;
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* Resolves a chain ID from either an explicit override or the wallet's active network.
|
|
9
|
+
*
|
|
10
|
+
* @param params.chainId - Explicit chain ID override.
|
|
11
|
+
* @param params.walletAccount - The wallet account to resolve the chain from.
|
|
12
|
+
* @param client - The Dynamic client instance.
|
|
13
|
+
* @returns The resolved chain ID.
|
|
14
|
+
* @not-instrumented
|
|
15
|
+
*/
|
|
16
|
+
export declare const resolveChainId: ({ chainId, walletAccount }: ResolveChainIdParams, client: DynamicClient) => Promise<number>;
|
|
17
|
+
export {};
|
|
18
|
+
//# sourceMappingURL=resolveChainId.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolveChainId.d.ts","sourceRoot":"","sources":["../../../src/gasless/resolveChainId/resolveChainId.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAE9D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAGrE,KAAK,oBAAoB,GAAG;IAC1B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,aAAa,EAAE,gBAAgB,CAAC;CACjC,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,cAAc,+BACG,oBAAoB,UACxC,aAAa,KACpB,OAAO,CAAC,MAAM,CAgBhB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/gasless/sendSponsoredTransaction/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { Hex } from 'viem';
|
|
2
|
+
import type { SignAuthorizationReturnType } from 'viem/accounts';
|
|
3
|
+
import type { EvmWalletAccount } from '../../EvmWalletAccount.types';
|
|
4
|
+
import type { SignedSponsoredTransaction, SponsoredTransactionCall } from '../gasless.types';
|
|
5
|
+
type SendSponsoredTransactionWithCallsParams = {
|
|
6
|
+
/** Pre-signed EIP-7702 authorization to include in the payload. */
|
|
7
|
+
authorization?: SignAuthorizationReturnType;
|
|
8
|
+
/** The batch of calls to execute. */
|
|
9
|
+
calls: SponsoredTransactionCall[];
|
|
10
|
+
/** How long the signed intent remains valid, in seconds. Defaults to 600 (10 minutes). */
|
|
11
|
+
validForSeconds?: number;
|
|
12
|
+
/** The EVM wallet account to sign and send the transaction for. */
|
|
13
|
+
walletAccount: EvmWalletAccount;
|
|
14
|
+
};
|
|
15
|
+
type SendSponsoredTransactionWithSignedTxParams = {
|
|
16
|
+
/** A pre-signed sponsored transaction payload from signSponsoredTransaction. */
|
|
17
|
+
signedTransaction: SignedSponsoredTransaction;
|
|
18
|
+
};
|
|
19
|
+
type SendSponsoredTransactionParams = SendSponsoredTransactionWithCallsParams | SendSponsoredTransactionWithSignedTxParams;
|
|
20
|
+
/**
|
|
21
|
+
* Sends a sponsored EVM transaction and waits for the on-chain transaction hash.
|
|
22
|
+
*
|
|
23
|
+
* Accepts either a pre-signed transaction or unsigned calls. When given
|
|
24
|
+
* unsigned calls, signs the transaction first via signSponsoredTransaction.
|
|
25
|
+
* Relays the transaction and polls until the relay reports a CONFIRMED
|
|
26
|
+
* status, then returns the resulting transaction hash.
|
|
27
|
+
*
|
|
28
|
+
* @param params - Either { signedTransaction } or { walletAccount, calls, ... }.
|
|
29
|
+
* @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
|
|
30
|
+
* @returns An object containing the on-chain transaction hash.
|
|
31
|
+
* @throws {SponsorTransactionError} If the relay returns a terminal failure or polling times out.
|
|
32
|
+
* @not-instrumented
|
|
33
|
+
*/
|
|
34
|
+
export declare const sendSponsoredTransaction: (params: SendSponsoredTransactionParams, client?: import("@dynamic-labs-sdk/client").DynamicClient) => Promise<{
|
|
35
|
+
transactionHash: Hex;
|
|
36
|
+
}>;
|
|
37
|
+
export {};
|
|
38
|
+
//# sourceMappingURL=sendSponsoredTransaction.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sendSponsoredTransaction.d.ts","sourceRoot":"","sources":["../../../src/gasless/sendSponsoredTransaction/sendSponsoredTransaction.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,MAAM,CAAC;AAChC,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,eAAe,CAAC;AAEjE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AACrE,OAAO,KAAK,EACV,0BAA0B,EAC1B,wBAAwB,EACzB,MAAM,kBAAkB,CAAC;AAI1B,KAAK,uCAAuC,GAAG;IAC7C,mEAAmE;IACnE,aAAa,CAAC,EAAE,2BAA2B,CAAC;IAC5C,qCAAqC;IACrC,KAAK,EAAE,wBAAwB,EAAE,CAAC;IAClC,0FAA0F;IAC1F,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,mEAAmE;IACnE,aAAa,EAAE,gBAAgB,CAAC;CACjC,CAAC;AAEF,KAAK,0CAA0C,GAAG;IAChD,gFAAgF;IAChF,iBAAiB,EAAE,0BAA0B,CAAC;CAC/C,CAAC;AAEF,KAAK,8BAA8B,GAC/B,uCAAuC,GACvC,0CAA0C,CAAC;AAE/C;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,wBAAwB,WAC3B,8BAA8B,gEAErC,OAAO,CAAC;IAAE,eAAe,EAAE,GAAG,CAAA;CAAE,CAGlC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/gasless/signSponsoredTransaction/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { SignAuthorizationReturnType } from 'viem/accounts';
|
|
2
|
+
import type { EvmWalletAccount } from '../../EvmWalletAccount.types';
|
|
3
|
+
import type { SignedSponsoredTransaction, SponsoredTransactionCall } from '../gasless.types';
|
|
4
|
+
type SignSponsoredTransactionParams = {
|
|
5
|
+
/** Pre-signed EIP-7702 authorization to include in the payload. */
|
|
6
|
+
authorization?: SignAuthorizationReturnType;
|
|
7
|
+
/** The batch of calls to execute. */
|
|
8
|
+
calls: SponsoredTransactionCall[];
|
|
9
|
+
/** How long the signed intent remains valid, in seconds. Defaults to 600 (10 minutes). */
|
|
10
|
+
validForSeconds?: number;
|
|
11
|
+
/** The EVM wallet account to sign the transaction for. */
|
|
12
|
+
walletAccount: EvmWalletAccount;
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* Signs a sponsored transaction by creating an EIP-712 intent signature.
|
|
16
|
+
*
|
|
17
|
+
* If an authorization is provided, it is serialized and included in the
|
|
18
|
+
* payload. Otherwise the intent is signed without any authorization
|
|
19
|
+
* (caller manages delegation separately).
|
|
20
|
+
*
|
|
21
|
+
* @param params.walletAccount - The EVM wallet account to sign with.
|
|
22
|
+
* @param params.calls - The batch of calls to execute.
|
|
23
|
+
* @param [params.authorization] - Pre-signed EIP-7702 authorization to include.
|
|
24
|
+
* @param [params.validForSeconds] - How long the signed intent remains valid, in seconds. Defaults to 600 (10 minutes).
|
|
25
|
+
* @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
|
|
26
|
+
* @returns The signed sponsored transaction payload ready to be sent to the API.
|
|
27
|
+
* @not-instrumented
|
|
28
|
+
*/
|
|
29
|
+
export declare const signSponsoredTransaction: ({ walletAccount, calls, authorization, validForSeconds, }: SignSponsoredTransactionParams, client?: import("@dynamic-labs-sdk/client").DynamicClient) => Promise<SignedSponsoredTransaction>;
|
|
30
|
+
export {};
|
|
31
|
+
//# sourceMappingURL=signSponsoredTransaction.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"signSponsoredTransaction.d.ts","sourceRoot":"","sources":["../../../src/gasless/signSponsoredTransaction/signSponsoredTransaction.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,eAAe,CAAC;AAEjE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAUrE,OAAO,KAAK,EACV,0BAA0B,EAC1B,wBAAwB,EACzB,MAAM,kBAAkB,CAAC;AAI1B,KAAK,8BAA8B,GAAG;IACpC,mEAAmE;IACnE,aAAa,CAAC,EAAE,2BAA2B,CAAC;IAC5C,qCAAqC;IACrC,KAAK,EAAE,wBAAwB,EAAE,CAAC;IAClC,0FAA0F;IAC1F,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,0DAA0D;IAC1D,aAAa,EAAE,gBAAgB,CAAC;CACjC,CAAC;AAEF;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,wBAAwB,8DAMhC,8BAA8B,gEAEhC,OAAO,CAAC,0BAA0B,CAwDpC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/gasless/toSerializedAuthorization/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,MAAM,6BAA6B,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { SignAuthorizationReturnType } from 'viem/accounts';
|
|
2
|
+
import type { SerializedAuthorization } from '../gasless.types';
|
|
3
|
+
/**
|
|
4
|
+
* Converts a viem SignAuthorizationReturnType into a plain serializable object
|
|
5
|
+
* suitable for JSON transport to the sponsorship API.
|
|
6
|
+
*
|
|
7
|
+
* @not-instrumented
|
|
8
|
+
*/
|
|
9
|
+
export declare const toSerializedAuthorization: (auth: SignAuthorizationReturnType) => SerializedAuthorization;
|
|
10
|
+
//# sourceMappingURL=toSerializedAuthorization.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"toSerializedAuthorization.d.ts","sourceRoot":"","sources":["../../../src/gasless/toSerializedAuthorization/toSerializedAuthorization.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,eAAe,CAAC;AAEjE,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,kBAAkB,CAAC;AAEhE;;;;;GAKG;AACH,eAAO,MAAM,yBAAyB,SAC9B,2BAA2B,KAChC,uBAaF,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/gasless/waitForSponsoredTransaction/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,2BAA2B,EAAE,MAAM,+BAA+B,CAAC"}
|