@dynamic-labs-sdk/evm 1.3.0 → 1.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (113) hide show
  1. package/dist/{addEIP6963Extension-6q4uKJ2S.cjs → addEIP6963Extension-C-2D7v76.cjs} +3 -3
  2. package/dist/{addEIP6963Extension-6q4uKJ2S.cjs.map → addEIP6963Extension-C-2D7v76.cjs.map} +1 -1
  3. package/dist/{addEIP6963Extension-C_IKf5DD.native.esm.js → addEIP6963Extension-CrpzqtkA.native.esm.js} +1 -1
  4. package/dist/{addEIP6963Extension-C_IKf5DD.native.esm.js.map → addEIP6963Extension-CrpzqtkA.native.esm.js.map} +1 -1
  5. package/dist/{addEIP6963Extension-CSo4PZ83.esm.js → addEIP6963Extension-Dt582bCZ.esm.js} +3 -3
  6. package/dist/{addEIP6963Extension-CSo4PZ83.esm.js.map → addEIP6963Extension-Dt582bCZ.esm.js.map} +1 -1
  7. package/dist/{addWaasEvmExtension-L8dUNmj8.native.esm.js → addWaasEvmExtension-CrLafMzM.native.esm.js} +3 -3
  8. package/dist/{addWaasEvmExtension-L8dUNmj8.native.esm.js.map → addWaasEvmExtension-CrLafMzM.native.esm.js.map} +1 -1
  9. package/dist/{addWaasEvmExtension-DTmPsJ-R.esm.js → addWaasEvmExtension-CzyCQ7fp.esm.js} +3 -3
  10. package/dist/{addWaasEvmExtension-DTmPsJ-R.esm.js.map → addWaasEvmExtension-CzyCQ7fp.esm.js.map} +1 -1
  11. package/dist/{addWaasEvmExtension-FyQx6Qlo.cjs → addWaasEvmExtension-D8O6IjQG.cjs} +3 -3
  12. package/dist/{addWaasEvmExtension-FyQx6Qlo.cjs.map → addWaasEvmExtension-D8O6IjQG.cjs.map} +1 -1
  13. package/dist/baseAccount.cjs +3 -3
  14. package/dist/baseAccount.esm.js +3 -3
  15. package/dist/baseAccount.native.esm.js +4 -4
  16. package/dist/{createWalletClientForWalletAccount-CKBR4V6M.cjs → createWalletClientForWalletAccount-CTDnbreU.cjs} +8 -2
  17. package/dist/{createWalletClientForWalletAccount-CKBR4V6M.cjs.map → createWalletClientForWalletAccount-CTDnbreU.cjs.map} +1 -1
  18. package/dist/{createWalletClientForWalletAccount-BotF25Kn.native.esm.js → createWalletClientForWalletAccount-CuakQYYA.native.esm.js} +2 -2
  19. package/dist/{createWalletClientForWalletAccount-BotF25Kn.native.esm.js.map → createWalletClientForWalletAccount-CuakQYYA.native.esm.js.map} +1 -1
  20. package/dist/{createWalletClientForWalletAccount-DRs8Ja_I.esm.js → createWalletClientForWalletAccount-CzeWTBwv.esm.js} +3 -3
  21. package/dist/{createWalletClientForWalletAccount-DRs8Ja_I.esm.js.map → createWalletClientForWalletAccount-CzeWTBwv.esm.js.map} +1 -1
  22. package/dist/{createWalletProviderFromEIP1193Provider-CWWLWjod.native.esm.js → createWalletProviderFromEIP1193Provider-B8doAYSi.native.esm.js} +2 -2
  23. package/dist/{createWalletProviderFromEIP1193Provider-CWWLWjod.native.esm.js.map → createWalletProviderFromEIP1193Provider-B8doAYSi.native.esm.js.map} +1 -1
  24. package/dist/{createWalletProviderFromEIP1193Provider-p3Aa46Bi.esm.js → createWalletProviderFromEIP1193Provider-Di6l7mjB.esm.js} +2 -2
  25. package/dist/{createWalletProviderFromEIP1193Provider-p3Aa46Bi.esm.js.map → createWalletProviderFromEIP1193Provider-Di6l7mjB.esm.js.map} +1 -1
  26. package/dist/{createWalletProviderFromEIP1193Provider-D-6PlGdy.cjs → createWalletProviderFromEIP1193Provider-_EtpThZ6.cjs} +2 -2
  27. package/dist/{createWalletProviderFromEIP1193Provider-D-6PlGdy.cjs.map → createWalletProviderFromEIP1193Provider-_EtpThZ6.cjs.map} +1 -1
  28. package/dist/eip6963.cjs +4 -4
  29. package/dist/eip6963.esm.js +4 -4
  30. package/dist/eip6963.native.esm.js +2 -2
  31. package/dist/evmTransferAmount-3m9QeANI.esm.js +875 -0
  32. package/dist/evmTransferAmount-3m9QeANI.esm.js.map +1 -0
  33. package/dist/evmTransferAmount-BQDSXSva.native.esm.js +875 -0
  34. package/dist/evmTransferAmount-BQDSXSva.native.esm.js.map +1 -0
  35. package/dist/evmTransferAmount-Bb1YvuCX.cjs +964 -0
  36. package/dist/evmTransferAmount-Bb1YvuCX.cjs.map +1 -0
  37. package/dist/exports/metamask.d.ts +6 -0
  38. package/dist/exports/metamask.d.ts.map +1 -0
  39. package/dist/gasless/relaySponsoredTransaction/relaySponsoredTransaction.d.ts +6 -0
  40. package/dist/gasless/relaySponsoredTransaction/relaySponsoredTransaction.d.ts.map +1 -1
  41. package/dist/gasless/sendSponsoredTransaction/sendSponsoredTransaction.d.ts +6 -0
  42. package/dist/gasless/sendSponsoredTransaction/sendSponsoredTransaction.d.ts.map +1 -1
  43. package/dist/gasless/signSponsoredTransaction/signSponsoredTransaction.d.ts +11 -1
  44. package/dist/gasless/signSponsoredTransaction/signSponsoredTransaction.d.ts.map +1 -1
  45. package/dist/index.cjs +15 -531
  46. package/dist/index.cjs.map +1 -1
  47. package/dist/index.esm.js +7 -523
  48. package/dist/index.esm.js.map +1 -1
  49. package/dist/index.native.esm.js +7 -523
  50. package/dist/index.native.esm.js.map +1 -1
  51. package/dist/metamask/connectAndVerifyWithMetaMaskUriEvm/connectAndVerifyWithMetaMaskUriEvm.d.ts +17 -0
  52. package/dist/metamask/connectAndVerifyWithMetaMaskUriEvm/connectAndVerifyWithMetaMaskUriEvm.d.ts.map +1 -0
  53. package/dist/metamask/connectAndVerifyWithMetaMaskUriEvm/index.d.ts +2 -0
  54. package/dist/metamask/connectAndVerifyWithMetaMaskUriEvm/index.d.ts.map +1 -0
  55. package/dist/metamask/connectWithMetaMaskUriEvm/connectWithMetaMaskUriEvm.d.ts +17 -0
  56. package/dist/metamask/connectWithMetaMaskUriEvm/connectWithMetaMaskUriEvm.d.ts.map +1 -0
  57. package/dist/metamask/connectWithMetaMaskUriEvm/index.d.ts +3 -0
  58. package/dist/metamask/connectWithMetaMaskUriEvm/index.d.ts.map +1 -0
  59. package/dist/metamask/createMetaMaskEvmWalletProvider/createMetaMaskEvmWalletProvider.d.ts +7 -12
  60. package/dist/metamask/createMetaMaskEvmWalletProvider/createMetaMaskEvmWalletProvider.d.ts.map +1 -1
  61. package/dist/metamask/createMetaMaskEvmWalletProvider/index.d.ts +0 -1
  62. package/dist/metamask/createMetaMaskEvmWalletProvider/index.d.ts.map +1 -1
  63. package/dist/metamask/getMetaMaskEvmExtensionWalletProviderKey/getMetaMaskEvmExtensionWalletProviderKey.d.ts +10 -0
  64. package/dist/metamask/getMetaMaskEvmExtensionWalletProviderKey/getMetaMaskEvmExtensionWalletProviderKey.d.ts.map +1 -0
  65. package/dist/metamask/getMetaMaskEvmExtensionWalletProviderKey/index.d.ts +2 -0
  66. package/dist/metamask/getMetaMaskEvmExtensionWalletProviderKey/index.d.ts.map +1 -0
  67. package/dist/metamask/metamask.types.d.ts +8 -36
  68. package/dist/metamask/metamask.types.d.ts.map +1 -1
  69. package/dist/metamask/utils/createMetaMaskEvmController/createMetaMaskEvmController.d.ts +5 -27
  70. package/dist/metamask/utils/createMetaMaskEvmController/createMetaMaskEvmController.d.ts.map +1 -1
  71. package/dist/metamask.cjs +317 -0
  72. package/dist/metamask.cjs.map +1 -0
  73. package/dist/metamask.esm.js +309 -0
  74. package/dist/metamask.esm.js.map +1 -0
  75. package/dist/metamask.native.esm.js +310 -0
  76. package/dist/metamask.native.esm.js.map +1 -0
  77. package/dist/{package-DGj3wg-e.native.esm.js → package-CVMy4p36.native.esm.js} +2 -2
  78. package/dist/package-CVMy4p36.native.esm.js.map +1 -0
  79. package/dist/tsconfig.lib.tsbuildinfo +1 -1
  80. package/dist/utils/evmExecuteSponsoredSwapTransaction/evmExecuteSponsoredSwapTransaction.d.ts +31 -0
  81. package/dist/utils/evmExecuteSponsoredSwapTransaction/evmExecuteSponsoredSwapTransaction.d.ts.map +1 -0
  82. package/dist/utils/evmExecuteSponsoredSwapTransaction/index.d.ts +2 -0
  83. package/dist/utils/evmExecuteSponsoredSwapTransaction/index.d.ts.map +1 -0
  84. package/dist/utils/evmExecuteSwapTransaction/evmExecuteSwapTransaction.d.ts +10 -6
  85. package/dist/utils/evmExecuteSwapTransaction/evmExecuteSwapTransaction.d.ts.map +1 -1
  86. package/dist/viem.cjs +1 -1
  87. package/dist/viem.esm.js +1 -1
  88. package/dist/viem.native.esm.js +2 -2
  89. package/dist/waas.cjs +3 -3
  90. package/dist/waas.esm.js +3 -3
  91. package/dist/waas.native.esm.js +4 -4
  92. package/dist/walletConnect.cjs +2 -2
  93. package/dist/walletConnect.esm.js +2 -2
  94. package/dist/walletConnect.native.esm.js +3 -3
  95. package/dist/windowInjected.cjs +3 -3
  96. package/dist/windowInjected.esm.js +3 -3
  97. package/dist/windowInjected.native.esm.js +4 -4
  98. package/package.json +10 -4
  99. package/dist/evmTransferAmount-BJswh1ID.esm.js +0 -289
  100. package/dist/evmTransferAmount-BJswh1ID.esm.js.map +0 -1
  101. package/dist/evmTransferAmount-BY0rW4dg.native.esm.js +0 -289
  102. package/dist/evmTransferAmount-BY0rW4dg.native.esm.js.map +0 -1
  103. package/dist/evmTransferAmount-CkF4KIge.cjs +0 -324
  104. package/dist/evmTransferAmount-CkF4KIge.cjs.map +0 -1
  105. package/dist/metamask/utils/clearMetaMaskEvmSessionStorage/clearMetaMaskEvmSessionStorage.d.ts +0 -34
  106. package/dist/metamask/utils/clearMetaMaskEvmSessionStorage/clearMetaMaskEvmSessionStorage.d.ts.map +0 -1
  107. package/dist/metamask/utils/clearMetaMaskEvmSessionStorage/index.d.ts +0 -2
  108. package/dist/metamask/utils/clearMetaMaskEvmSessionStorage/index.d.ts.map +0 -1
  109. package/dist/metamask/utils/isConnectShapedResponse/index.d.ts +0 -3
  110. package/dist/metamask/utils/isConnectShapedResponse/index.d.ts.map +0 -1
  111. package/dist/metamask/utils/isConnectShapedResponse/isConnectShapedResponse.d.ts +0 -21
  112. package/dist/metamask/utils/isConnectShapedResponse/isConnectShapedResponse.d.ts.map +0 -1
  113. package/dist/package-DGj3wg-e.native.esm.js.map +0 -1
package/dist/index.cjs CHANGED
@@ -1,515 +1,13 @@
1
- const require_createWalletClientForWalletAccount = require('./createWalletClientForWalletAccount-CKBR4V6M.cjs');
2
- const require_evmTransferAmount = require('./evmTransferAmount-CkF4KIge.cjs');
3
- require('./createWalletProviderFromEIP1193Provider-D-6PlGdy.cjs');
4
- const require_addEIP6963Extension = require('./addEIP6963Extension-6q4uKJ2S.cjs');
5
- const require_addWaasEvmExtension = require('./addWaasEvmExtension-FyQx6Qlo.cjs');
1
+ const require_createWalletClientForWalletAccount = require('./createWalletClientForWalletAccount-CTDnbreU.cjs');
2
+ const require_evmTransferAmount = require('./evmTransferAmount-Bb1YvuCX.cjs');
3
+ require('./createWalletProviderFromEIP1193Provider-_EtpThZ6.cjs');
4
+ const require_addEIP6963Extension = require('./addEIP6963Extension-C-2D7v76.cjs');
5
+ const require_addWaasEvmExtension = require('./addWaasEvmExtension-D8O6IjQG.cjs');
6
6
  let _dynamic_labs_sdk_assert_package_version = require("@dynamic-labs-sdk/assert-package-version");
7
7
  let _dynamic_labs_sdk_client = require("@dynamic-labs-sdk/client");
8
8
  let _dynamic_labs_sdk_client_core = require("@dynamic-labs-sdk/client/core");
9
9
  let viem = require("viem");
10
- let viem_actions = require("viem/actions");
11
10
 
12
- //#region src/errors/SponsorTransactionError/SponsorTransactionError.ts
13
- var SponsorTransactionError = class extends _dynamic_labs_sdk_client.BaseError {
14
- constructor(cause, details) {
15
- super({
16
- cause: cause ?? null,
17
- code: "sponsor_transaction_error",
18
- details,
19
- docsUrl: null,
20
- name: "SponsorTransactionError",
21
- shortMessage: "Failed to sponsor EVM transaction"
22
- });
23
- }
24
- };
25
-
26
- //#endregion
27
- //#region src/gasless/constants.ts
28
- /** The Fireblocks Universal Gasless Delegate (UGD) contract address used for EIP-7702 delegation. */
29
- const DELEGATION_CONTRACT_ADDRESS = "0x0000Fb7702036ff9f76044a501ac1aA74cbab16b";
30
- /** Default sponsored transaction validity duration in seconds (10 minutes). */
31
- const DEFAULT_VALID_FOR_SECONDS = 600;
32
- /** EIP-7702 delegation code prefix used to identify delegated accounts. */
33
- const DELEGATION_CODE_PREFIX = "0xef0100";
34
- /** ERC-7579 batch call with opData and auth mode identifier. */
35
- const BATCH_CALL_OPDATA_AUTH_MODE = "0x0100000000007821000100000000000000000000000000000000000000000000";
36
- /** EIP-712 typed data types for UGD AuthorizedExecutions signing. */
37
- const AUTHORIZED_EXECUTIONS_TYPES = {
38
- AuthorizedExecutions: [
39
- {
40
- name: "calls",
41
- type: "Execution[]"
42
- },
43
- {
44
- name: "deadline",
45
- type: "uint256"
46
- },
47
- {
48
- name: "mode",
49
- type: "bytes32"
50
- },
51
- {
52
- name: "nonce",
53
- type: "uint256"
54
- },
55
- {
56
- name: "relayer",
57
- type: "address"
58
- }
59
- ],
60
- Execution: [
61
- {
62
- name: "target",
63
- type: "address"
64
- },
65
- {
66
- name: "value",
67
- type: "uint256"
68
- },
69
- {
70
- name: "data",
71
- type: "bytes"
72
- }
73
- ]
74
- };
75
- /** Minimal ABI for the UGD contract's nonce validation function. */
76
- const UGD_ABI = [{
77
- inputs: [{
78
- name: "nonce",
79
- type: "uint256"
80
- }],
81
- name: "isNonceUsed",
82
- outputs: [{
83
- name: "",
84
- type: "bool"
85
- }],
86
- stateMutability: "view",
87
- type: "function"
88
- }];
89
-
90
- //#endregion
91
- //#region src/gasless/generateRandomNonce/generateRandomNonce.ts
92
- /**
93
- * Generates a cryptographically random 256-bit nonce.
94
- *
95
- * @returns A random bigint nonce.
96
- * @not-instrumented
97
- */
98
- const generateRandomNonce = () => {
99
- const bytes = new Uint8Array(32);
100
- crypto.getRandomValues(bytes);
101
- return bytes.reduce((acc, byte) => acc << 8n | BigInt(byte), 0n);
102
- };
103
-
104
- //#endregion
105
- //#region src/gasless/generateIntentNonce/generateIntentNonce.ts
106
- /**
107
- * Generates a random bitmap nonce for UGD AuthorizedExecutions signing.
108
- *
109
- * Uses crypto.getRandomValues() for 256-bit randomness. Validates against
110
- * the on-chain isNonceUsed check as a safety measure, although collision
111
- * is essentially impossible with 256-bit random values.
112
- *
113
- * @param params.walletAccount - The wallet account whose delegation contract is checked.
114
- * @param [client] - The Dynamic client instance.
115
- * @returns A unique bigint nonce for the EIP-712 intent.
116
- * @not-instrumented
117
- */
118
- const generateIntentNonce = async ({ walletAccount }, client) => {
119
- const nonce = generateRandomNonce();
120
- const { networkData } = await (0, _dynamic_labs_sdk_client.getActiveNetworkData)({ walletAccount }, client);
121
- (0, _dynamic_labs_sdk_client_core.assertDefined)(networkData, `No network data found for wallet account ${walletAccount.address}`);
122
- const publicClient = require_createWalletClientForWalletAccount.createPublicClientFromNetworkData({ networkData });
123
- try {
124
- if (await publicClient.readContract({
125
- abi: UGD_ABI,
126
- address: walletAccount.address,
127
- args: [nonce],
128
- functionName: "isNonceUsed"
129
- })) return generateRandomNonce();
130
- } catch {}
131
- return nonce;
132
- };
133
-
134
- //#endregion
135
- //#region src/gasless/getAvailableEvmGaslessRelayer/getAvailableEvmGaslessRelayer.ts
136
- /**
137
- * Fetches the relayer address to embed in the EIP-712 sponsored-transaction
138
- * intent for the given chain.
139
- *
140
- * The returned address is owned by the project's relay backend and is the
141
- * eventual `from` of the on-chain broadcast. It must be set as the `relayer`
142
- * field of the EIP-712 intent before signing — the on-chain delegate validates
143
- * the signature against this address.
144
- *
145
- * @param params.chainId - The EVM chain ID the sponsored transaction targets.
146
- * @param client - The Dynamic client instance.
147
- * @returns The relayer address to embed in the EIP-712 intent.
148
- * @throws {SponsorTransactionError} If the API call fails or returns no relayer address.
149
- * @not-instrumented
150
- */
151
- const getAvailableEvmGaslessRelayer = async ({ chainId }, client) => {
152
- const core = (0, _dynamic_labs_sdk_client_core.getCore)(client);
153
- const apiClient = (0, _dynamic_labs_sdk_client_core.createApiClient)({}, client);
154
- let data;
155
- try {
156
- data = await apiClient.getAvailableEVMGaslessRelayer({
157
- chainId,
158
- environmentId: core.environmentId
159
- });
160
- } catch (error) {
161
- throw new SponsorTransactionError(error instanceof Error ? error : null);
162
- }
163
- if (!data.relayerAddress) throw new SponsorTransactionError();
164
- return { relayerAddress: data.relayerAddress };
165
- };
166
-
167
- //#endregion
168
- //#region src/gasless/create7702DelegationRegistry/create7702DelegationRegistry.ts
169
- /**
170
- * Creates an in-memory registry that tracks which wallet+chain combinations
171
- * have active EIP-7702 delegation. Only active delegations are cached —
172
- * a missing entry means the status is unknown and should be checked via RPC.
173
- *
174
- * @not-instrumented
175
- */
176
- const create7702DelegationRegistry = () => {
177
- const delegated = /* @__PURE__ */ new Map();
178
- const buildKey = ({ chainId, walletAddress }) => `${walletAddress.toLowerCase()}:${chainId}`;
179
- return {
180
- isDelegated: (params) => delegated.has(buildKey(params)),
181
- markDelegated: (params) => {
182
- delegated.set(buildKey(params), true);
183
- }
184
- };
185
- };
186
-
187
- //#endregion
188
- //#region src/gasless/get7702DelegationRegistry/get7702DelegationRegistry.ts
189
- /**
190
- * Returns the per-client EIP-7702 delegation registry, creating it on first access.
191
- *
192
- * @not-instrumented
193
- */
194
- const get7702DelegationRegistry = (0, _dynamic_labs_sdk_client_core.createRuntimeServiceAccessKey)("evm-7702-delegation-registry", () => create7702DelegationRegistry());
195
-
196
- //#endregion
197
- //#region src/gasless/is7702DelegationActive/is7702DelegationActive.ts
198
- /**
199
- * Checks whether EIP-7702 delegation to the Dynamic gasless contract is active
200
- * for the given wallet account on its current network.
201
- *
202
- * Results are cached per wallet+chain in an in-memory registry
203
- *
204
- * @param params.walletAccount - The EVM wallet account to check delegation status for.
205
- * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
206
- * @returns True if the wallet has an active delegation to the gasless contract.
207
- * @not-instrumented
208
- */
209
- const is7702DelegationActive = async ({ walletAccount }, client = (0, _dynamic_labs_sdk_client_core.getDefaultClient)()) => {
210
- const { networkData } = await (0, _dynamic_labs_sdk_client.getActiveNetworkData)({ walletAccount }, client);
211
- (0, _dynamic_labs_sdk_client_core.assertDefined)(networkData, `No network data found for wallet account ${walletAccount.address}`);
212
- const chainId = require_createWalletClientForWalletAccount.mapNetworkDataToViemChain(networkData).id;
213
- const registry = get7702DelegationRegistry(client);
214
- if (registry.isDelegated({
215
- chainId,
216
- walletAddress: walletAccount.address
217
- })) return true;
218
- const bytecode = await require_createWalletClientForWalletAccount.createPublicClientFromNetworkData({ networkData }).getCode({ address: walletAccount.address });
219
- if (!bytecode) return false;
220
- const expectedPrefix = DELEGATION_CODE_PREFIX + DELEGATION_CONTRACT_ADDRESS.slice(2).toLowerCase();
221
- const isActive = bytecode.toLowerCase().startsWith(expectedPrefix);
222
- if (isActive) registry.markDelegated({
223
- chainId,
224
- walletAddress: walletAccount.address
225
- });
226
- return isActive;
227
- };
228
-
229
- //#endregion
230
- //#region src/gasless/resolveChainId/resolveChainId.ts
231
- /**
232
- * Resolves a chain ID from either an explicit override or the wallet's active network.
233
- *
234
- * @param params.chainId - Explicit chain ID override.
235
- * @param params.walletAccount - The wallet account to resolve the chain from.
236
- * @param client - The Dynamic client instance.
237
- * @returns The resolved chain ID.
238
- * @not-instrumented
239
- */
240
- const resolveChainId = async ({ chainId, walletAccount }, client) => {
241
- if (chainId !== void 0) return chainId;
242
- const { networkData } = await (0, _dynamic_labs_sdk_client.getActiveNetworkData)({ walletAccount }, client);
243
- (0, _dynamic_labs_sdk_client_core.assertDefined)(networkData, `No network data found for wallet account ${walletAccount.address}`);
244
- return require_createWalletClientForWalletAccount.mapNetworkDataToViemChain(networkData).id;
245
- };
246
-
247
- //#endregion
248
- //#region src/gasless/sign7702Authorization/sign7702Authorization.ts
249
- /**
250
- * Signs an EIP-7702 authorization to delegate the wallet to the Dynamic
251
- * gasless delegation contract.
252
- *
253
- * The signed authorization can be included in a sponsored transaction to
254
- * activate the delegation on-chain. If no chainId is provided, the wallet's
255
- * active network chain ID is used.
256
- *
257
- * @param params.walletAccount - The EVM wallet account to sign the authorization for.
258
- * @param [params.chainId] - Override chain ID. Defaults to the wallet's active network.
259
- * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
260
- * @returns The signed EIP-7702 authorization.
261
- * @not-instrumented
262
- */
263
- const sign7702Authorization = async ({ walletAccount, chainId }, client = (0, _dynamic_labs_sdk_client_core.getDefaultClient)()) => {
264
- return (0, viem_actions.signAuthorization)(await require_createWalletClientForWalletAccount.createWalletClientForWalletAccount({ walletAccount }, client), {
265
- chainId: await resolveChainId({
266
- chainId,
267
- walletAccount
268
- }, client),
269
- contractAddress: DELEGATION_CONTRACT_ADDRESS
270
- });
271
- };
272
-
273
- //#endregion
274
- //#region src/gasless/resolveAuthorization/resolveAuthorization.ts
275
- /**
276
- * Resolves the EIP-7702 authorization for a sponsored transaction.
277
- *
278
- * Returns the provided authorization if given, auto-signs one if needed
279
- * and autoDelegate is true, or returns undefined if the wallet is already
280
- * delegated or autoDelegate is false.
281
- *
282
- * @not-instrumented
283
- */
284
- const resolveAuthorization = async ({ authorization, autoDelegate, walletAccount }, client) => {
285
- if (authorization) return authorization;
286
- if (!autoDelegate) return;
287
- if (await is7702DelegationActive({ walletAccount }, client)) return;
288
- return sign7702Authorization({ walletAccount }, client);
289
- };
290
-
291
- //#endregion
292
- //#region src/gasless/toSerializedAuthorization/toSerializedAuthorization.ts
293
- /**
294
- * Converts a viem SignAuthorizationReturnType into a plain serializable object
295
- * suitable for JSON transport to the sponsorship API.
296
- *
297
- * @not-instrumented
298
- */
299
- const toSerializedAuthorization = (auth) => {
300
- (0, _dynamic_labs_sdk_client_core.assertDefined)(auth.yParity, "Signed authorization is missing yParity");
301
- return {
302
- address: auth.address,
303
- chainId: auth.chainId,
304
- nonce: auth.nonce,
305
- r: auth.r,
306
- s: auth.s,
307
- yParity: auth.yParity
308
- };
309
- };
310
-
311
- //#endregion
312
- //#region src/gasless/signSponsoredTransaction/signSponsoredTransaction.ts
313
- /**
314
- * Signs a sponsored transaction by creating an EIP-712 intent signature.
315
- *
316
- * This function handles the complete signing flow:
317
- * - If an authorization is provided, it is included in the payload.
318
- * - If autoDelegate is true (default) and no authorization is provided,
319
- * checks whether delegation is active and signs a 7702 authorization if needed.
320
- * - If autoDelegate is false and no authorization is provided, the intent
321
- * is signed without any authorization (user manages delegation separately).
322
- *
323
- * @param params.walletAccount - The EVM wallet account to sign with.
324
- * @param params.calls - The batch of calls to execute.
325
- * @param [params.authorization] - Pre-signed EIP-7702 authorization. Takes priority over autoDelegate.
326
- * @param [params.autoDelegate] - Whether to auto-sign 7702 if not delegated. Defaults to true.
327
- * @param [params.validForSeconds] - How long the signed intent remains valid, in seconds. Defaults to 600 (10 minutes).
328
- * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
329
- * @returns The signed sponsored transaction payload ready to be sent to the API.
330
- * @not-instrumented
331
- */
332
- const signSponsoredTransaction = async ({ walletAccount, calls, authorization, autoDelegate = true, validForSeconds = DEFAULT_VALID_FOR_SECONDS }, client = (0, _dynamic_labs_sdk_client_core.getDefaultClient)()) => {
333
- const { networkData } = await (0, _dynamic_labs_sdk_client.getActiveNetworkData)({ walletAccount }, client);
334
- (0, _dynamic_labs_sdk_client_core.assertDefined)(networkData, `No network data found for wallet account ${walletAccount.address}`);
335
- const resolvedAuthorization = await resolveAuthorization({
336
- authorization,
337
- autoDelegate,
338
- walletAccount
339
- }, client);
340
- const nonce = await generateIntentNonce({ walletAccount }, client);
341
- const deadline = BigInt(Math.floor(Date.now() / 1e3) + validForSeconds);
342
- const chainId = require_createWalletClientForWalletAccount.mapNetworkDataToViemChain(networkData).id;
343
- const { relayerAddress } = await getAvailableEvmGaslessRelayer({ chainId }, client);
344
- const signature = await (await require_createWalletClientForWalletAccount.createWalletClientForWalletAccount({ walletAccount }, client)).signTypedData({
345
- domain: {
346
- chainId,
347
- verifyingContract: DELEGATION_CONTRACT_ADDRESS
348
- },
349
- message: {
350
- calls: calls.map((c) => ({
351
- data: c.data,
352
- target: c.target,
353
- value: c.value
354
- })),
355
- deadline,
356
- mode: BATCH_CALL_OPDATA_AUTH_MODE,
357
- nonce,
358
- relayer: relayerAddress
359
- },
360
- primaryType: "AuthorizedExecutions",
361
- types: AUTHORIZED_EXECUTIONS_TYPES
362
- });
363
- return {
364
- authorization: resolvedAuthorization ? toSerializedAuthorization(resolvedAuthorization) : void 0,
365
- calls,
366
- chainId,
367
- deadline: deadline.toString(),
368
- nonce: nonce.toString(),
369
- relayer: relayerAddress,
370
- signature,
371
- walletAddress: walletAccount.address
372
- };
373
- };
374
-
375
- //#endregion
376
- //#region src/gasless/relaySponsoredTransaction/relaySponsoredTransaction.ts
377
- const isSignedTransactionParams = (params) => "signedTransaction" in params;
378
- /**
379
- * Relays a sponsored EVM transaction to the Dynamic backend.
380
- *
381
- * Accepts either a pre-signed transaction or unsigned calls. When given
382
- * unsigned calls, signs the transaction first via signSponsoredTransaction.
383
- *
384
- * The backend encodes the transaction, submits it to the relay provider,
385
- * and returns a request ID for tracking. The relay may retry the on-chain
386
- * submission, so the request ID (not a transaction hash) is the stable
387
- * identifier for the sponsored transaction.
388
- *
389
- * @param params - Either { signedTransaction } or { walletAccount, calls, ... }.
390
- * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
391
- * @returns An object containing the request ID for tracking the relayed transaction.
392
- * @throws {SponsorTransactionError} If the API call fails or returns an unexpected response.
393
- * @not-instrumented
394
- */
395
- const relaySponsoredTransaction = async (params, client = (0, _dynamic_labs_sdk_client_core.getDefaultClient)()) => {
396
- const signedTransaction = isSignedTransactionParams(params) ? params.signedTransaction : await signSponsoredTransaction({
397
- authorization: params.authorization,
398
- autoDelegate: params.autoDelegate,
399
- calls: params.calls,
400
- validForSeconds: params.validForSeconds ?? DEFAULT_VALID_FOR_SECONDS,
401
- walletAccount: params.walletAccount
402
- }, client);
403
- const core = (0, _dynamic_labs_sdk_client_core.getCore)(client);
404
- const apiClient = (0, _dynamic_labs_sdk_client_core.createApiClient)({}, client);
405
- let data;
406
- try {
407
- data = await apiClient.sponsorEVMTransaction({
408
- environmentId: core.environmentId,
409
- sponsorEVMTransactionRequest: {
410
- authorization: signedTransaction.authorization,
411
- calls: signedTransaction.calls.map((c) => ({
412
- data: c.data,
413
- target: c.target,
414
- value: c.value.toString()
415
- })),
416
- chainId: signedTransaction.chainId,
417
- deadline: signedTransaction.deadline,
418
- nonce: signedTransaction.nonce,
419
- relayer: signedTransaction.relayer,
420
- signature: signedTransaction.signature,
421
- walletAddress: signedTransaction.walletAddress
422
- }
423
- });
424
- } catch (error) {
425
- throw new SponsorTransactionError(error instanceof Error ? error : null);
426
- }
427
- if (!data.requestId) throw new SponsorTransactionError();
428
- return { requestId: data.requestId };
429
- };
430
-
431
- //#endregion
432
- //#region src/gasless/getEVMSponsoredTransactionStatus/getEVMSponsoredTransactionStatus.ts
433
- /**
434
- * Fetches the current relay state for a sponsored EVM transaction.
435
- *
436
- * Returns the lifecycle status, the on-chain transaction hash (when the relay
437
- * has broadcast it), and any terminal-failure error message. Use this as the
438
- * building block for custom polling flows; for the common "wait until done"
439
- * case prefer `waitForSponsoredTransaction`.
440
- *
441
- * @param params.requestId - The request ID returned when the transaction was relayed.
442
- * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
443
- * @returns The current status, optional transaction hash, and optional error message.
444
- * @throws {SponsorTransactionError} If the API call fails.
445
- * @not-instrumented
446
- */
447
- const getEVMSponsoredTransactionStatus = async ({ requestId }, client = (0, _dynamic_labs_sdk_client_core.getDefaultClient)()) => {
448
- const core = (0, _dynamic_labs_sdk_client_core.getCore)(client);
449
- const apiClient = (0, _dynamic_labs_sdk_client_core.createApiClient)({}, client);
450
- let data;
451
- try {
452
- data = await apiClient.getEVMSponsoredTransactionStatus({
453
- environmentId: core.environmentId,
454
- requestId
455
- });
456
- } catch (error) {
457
- throw new SponsorTransactionError(error instanceof Error ? error : null);
458
- }
459
- return {
460
- errorMessage: data.errorMessage,
461
- status: data.status,
462
- transactionHash: data.transactionHash
463
- };
464
- };
465
-
466
- //#endregion
467
- //#region src/gasless/waitForSponsoredTransaction/waitForSponsoredTransaction.ts
468
- const POLL_INTERVAL_MS = 2e3;
469
- const MAX_POLLING_ATTEMPTS = 6e4 / POLL_INTERVAL_MS;
470
- const TERMINAL_FAILURE_STATUSES = new Set(["failure"]);
471
- /**
472
- * Polls `getEVMSponsoredTransactionStatus` until the relay reports the
473
- * transaction has been included on-chain, then returns the transaction hash.
474
- *
475
- * @param params.requestId - The request ID returned when the transaction was relayed.
476
- * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
477
- * @returns An object containing the on-chain transaction hash.
478
- * @throws {SponsorTransactionError} If the relay returns a terminal failure or polling times out.
479
- * @not-instrumented
480
- */
481
- const waitForSponsoredTransaction = async ({ requestId }, client = (0, _dynamic_labs_sdk_client.getDefaultClient)()) => {
482
- for (let attempt = 0; attempt < MAX_POLLING_ATTEMPTS; attempt++) {
483
- const result = await getEVMSponsoredTransactionStatus({ requestId }, client);
484
- if (TERMINAL_FAILURE_STATUSES.has(result.status)) throw new SponsorTransactionError(null, result.errorMessage);
485
- if (result.transactionHash) return { transactionHash: result.transactionHash };
486
- if (attempt < MAX_POLLING_ATTEMPTS - 1) await new Promise((resolve) => setTimeout(resolve, POLL_INTERVAL_MS));
487
- }
488
- throw new SponsorTransactionError(null, `Timed out waiting for sponsored transaction ${requestId}`);
489
- };
490
-
491
- //#endregion
492
- //#region src/gasless/sendSponsoredTransaction/sendSponsoredTransaction.ts
493
- /**
494
- * Sends a sponsored EVM transaction and waits for on-chain inclusion.
495
- *
496
- * Accepts either a pre-signed transaction or unsigned calls. When given
497
- * unsigned calls, signs the transaction first via signSponsoredTransaction.
498
- * Relays the transaction and resolves as soon as the relay reports the
499
- * transaction has been included on-chain.
500
- *
501
- * @param params - Either { signedTransaction } or { walletAccount, calls, ... }.
502
- * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
503
- * @returns An object containing the on-chain transaction hash.
504
- * @throws {SponsorTransactionError} If the relay returns a terminal failure or polling times out.
505
- * @not-instrumented
506
- */
507
- const sendSponsoredTransaction = async (params, client = (0, _dynamic_labs_sdk_client.getDefaultClient)()) => {
508
- const { requestId } = await relaySponsoredTransaction(params, client);
509
- return waitForSponsoredTransaction({ requestId }, client);
510
- };
511
-
512
- //#endregion
513
11
  //#region src/gasless/activate7702Delegation/activate7702Delegation.ts
514
12
  /**
515
13
  * Activates EIP-7702 delegation for a wallet by sending a sponsored
@@ -526,7 +24,7 @@ const sendSponsoredTransaction = async (params, client = (0, _dynamic_labs_sdk_c
526
24
  * @throws {SponsorTransactionError} If the relay returns a terminal failure or polling times out.
527
25
  * @not-instrumented
528
26
  */
529
- const activate7702Delegation = async ({ walletAccount, authorization }, client = (0, _dynamic_labs_sdk_client.getDefaultClient)()) => sendSponsoredTransaction({
27
+ const activate7702Delegation = async ({ walletAccount, authorization }, client = (0, _dynamic_labs_sdk_client.getDefaultClient)()) => require_evmTransferAmount.sendSponsoredTransaction({
530
28
  authorization,
531
29
  calls: [],
532
30
  walletAccount
@@ -563,20 +61,6 @@ var EvmGasSponsorshipNotEnabledError = class extends _dynamic_labs_sdk_client.Ba
563
61
  }
564
62
  };
565
63
 
566
- //#endregion
567
- //#region src/gasless/isEvmGasSponsorshipEnabled/isEvmGasSponsorshipEnabled.ts
568
- /**
569
- * Checks if EVM gas sponsorship is enabled for the current project.
570
- *
571
- * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
572
- * @returns True if EVM gas sponsorship is enabled, false otherwise.
573
- * @not-instrumented
574
- */
575
- const isEvmGasSponsorshipEnabled = (client = (0, _dynamic_labs_sdk_client.getDefaultClient)()) => {
576
- (0, _dynamic_labs_sdk_client_core.assertDefined)(client.projectSettings, "Project settings are not defined");
577
- return client.projectSettings.sdk.embeddedWallets?.evmGasSponsorshipEnabled ?? false;
578
- };
579
-
580
64
  //#endregion
581
65
  //#region src/isEvmNetworkProvider/isEvmNetworkProvider.ts
582
66
  /**
@@ -718,19 +202,19 @@ const simulateEvmTransaction = async ({ walletAccount, transaction, includeFees
718
202
  //#endregion
719
203
  exports.EvmGasSponsorshipNotEnabledError = EvmGasSponsorshipNotEnabledError;
720
204
  exports.RpcError = require_evmTransferAmount.RpcError;
721
- exports.SponsorTransactionError = SponsorTransactionError;
205
+ exports.SponsorTransactionError = require_evmTransferAmount.SponsorTransactionError;
722
206
  exports.activate7702Delegation = activate7702Delegation;
723
207
  exports.addEvmExtension = addEvmExtension;
724
208
  exports.calculateEvmTransactionFee = calculateEvmTransactionFee;
725
- exports.getEVMSponsoredTransactionStatus = getEVMSponsoredTransactionStatus;
726
- exports.is7702DelegationActive = is7702DelegationActive;
727
- exports.isEvmGasSponsorshipEnabled = isEvmGasSponsorshipEnabled;
209
+ exports.getEVMSponsoredTransactionStatus = require_evmTransferAmount.getEVMSponsoredTransactionStatus;
210
+ exports.is7702DelegationActive = require_evmTransferAmount.is7702DelegationActive;
211
+ exports.isEvmGasSponsorshipEnabled = require_evmTransferAmount.isEvmGasSponsorshipEnabled;
728
212
  exports.isEvmNetworkProvider = isEvmNetworkProvider;
729
213
  exports.isEvmWalletAccount = require_evmTransferAmount.isEvmWalletAccount;
730
- exports.relaySponsoredTransaction = relaySponsoredTransaction;
731
- exports.sendSponsoredTransaction = sendSponsoredTransaction;
732
- exports.sign7702Authorization = sign7702Authorization;
733
- exports.signSponsoredTransaction = signSponsoredTransaction;
214
+ exports.relaySponsoredTransaction = require_evmTransferAmount.relaySponsoredTransaction;
215
+ exports.sendSponsoredTransaction = require_evmTransferAmount.sendSponsoredTransaction;
216
+ exports.sign7702Authorization = require_evmTransferAmount.sign7702Authorization;
217
+ exports.signSponsoredTransaction = require_evmTransferAmount.signSponsoredTransaction;
734
218
  exports.simulateEvmTransaction = simulateEvmTransaction;
735
- exports.waitForSponsoredTransaction = waitForSponsoredTransaction;
219
+ exports.waitForSponsoredTransaction = require_evmTransferAmount.waitForSponsoredTransaction;
736
220
  //# sourceMappingURL=index.cjs.map