@dynamic-labs-sdk/client 0.18.1 → 0.20.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/{InvalidParamError-CGBIFNgP.esm.js → InvalidParamError-C8i6ExCF.esm.js} +3 -3
  2. package/dist/{InvalidParamError-CGBIFNgP.esm.js.map → InvalidParamError-C8i6ExCF.esm.js.map} +1 -1
  3. package/dist/{InvalidParamError-0w8-q2f3.cjs.js → InvalidParamError-C9egR24p.cjs.js} +4 -4
  4. package/dist/{InvalidParamError-0w8-q2f3.cjs.js.map → InvalidParamError-C9egR24p.cjs.js.map} +1 -1
  5. package/dist/{NotWaasWalletAccountError-CT_IUD-3.esm.js → NotWaasWalletAccountError-BI9ZiEz_.esm.js} +3 -3
  6. package/dist/{NotWaasWalletAccountError-CT_IUD-3.esm.js.map → NotWaasWalletAccountError-BI9ZiEz_.esm.js.map} +1 -1
  7. package/dist/{NotWaasWalletAccountError-CyvI1KtC.cjs.js → NotWaasWalletAccountError-DoCmrSvg.cjs.js} +3 -3
  8. package/dist/{NotWaasWalletAccountError-CyvI1KtC.cjs.js.map → NotWaasWalletAccountError-DoCmrSvg.cjs.js.map} +1 -1
  9. package/dist/core.cjs.js +6 -5
  10. package/dist/core.cjs.js.map +1 -1
  11. package/dist/core.esm.js +8 -7
  12. package/dist/core.esm.js.map +1 -1
  13. package/dist/errors/TokenSwapError.d.ts +10 -0
  14. package/dist/errors/TokenSwapError.d.ts.map +1 -0
  15. package/dist/exports/core.d.ts +1 -1
  16. package/dist/exports/core.d.ts.map +1 -1
  17. package/dist/exports/index.d.ts +18 -5
  18. package/dist/exports/index.d.ts.map +1 -1
  19. package/dist/{getNetworkProviderFromNetworkId-KrwFxKlq.cjs.js → getNetworkProviderFromNetworkId-Bd5KJOTp.cjs.js} +58 -27
  20. package/dist/getNetworkProviderFromNetworkId-Bd5KJOTp.cjs.js.map +1 -0
  21. package/dist/{getNetworkProviderFromNetworkId-C9PJejYH.esm.js → getNetworkProviderFromNetworkId-CwHLK1vS.esm.js} +62 -31
  22. package/dist/getNetworkProviderFromNetworkId-CwHLK1vS.esm.js.map +1 -0
  23. package/dist/{getSignedSessionId-DhCbpycv.esm.js → getSignedSessionId-BMJxU50H.esm.js} +5 -7
  24. package/dist/{getSignedSessionId-DhCbpycv.esm.js.map → getSignedSessionId-BMJxU50H.esm.js.map} +1 -1
  25. package/dist/{getSignedSessionId-Cqp6g3pY.cjs.js → getSignedSessionId-CHIq5TnT.cjs.js} +5 -7
  26. package/dist/getSignedSessionId-CHIq5TnT.cjs.js.map +1 -0
  27. package/dist/{getVerifiedCredentialForWalletAccount-Bffr91SM.cjs.js → getVerifiedCredentialForWalletAccount-CsJEjM3D.cjs.js} +3 -3
  28. package/dist/{getVerifiedCredentialForWalletAccount-Bffr91SM.cjs.js.map → getVerifiedCredentialForWalletAccount-CsJEjM3D.cjs.js.map} +1 -1
  29. package/dist/{getVerifiedCredentialForWalletAccount-BdoPoNic.esm.js → getVerifiedCredentialForWalletAccount-DBJ_U78Y.esm.js} +2 -2
  30. package/dist/{getVerifiedCredentialForWalletAccount-BdoPoNic.esm.js.map → getVerifiedCredentialForWalletAccount-DBJ_U78Y.esm.js.map} +1 -1
  31. package/dist/index.cjs.js +239 -26
  32. package/dist/index.cjs.js.map +1 -1
  33. package/dist/index.esm.js +237 -30
  34. package/dist/index.esm.js.map +1 -1
  35. package/dist/{isMfaRequiredForAction-Vo0fCwzo.esm.js → isMfaRequiredForAction-Bc6KzFrM.esm.js} +2 -2
  36. package/dist/{isMfaRequiredForAction-Vo0fCwzo.esm.js.map → isMfaRequiredForAction-Bc6KzFrM.esm.js.map} +1 -1
  37. package/dist/{isMfaRequiredForAction-cPUOtGku.cjs.js → isMfaRequiredForAction-D5Mgfi6K.cjs.js} +2 -2
  38. package/dist/{isMfaRequiredForAction-cPUOtGku.cjs.js.map → isMfaRequiredForAction-D5Mgfi6K.cjs.js.map} +1 -1
  39. package/dist/modules/auth/events.d.ts +6 -2
  40. package/dist/modules/auth/events.d.ts.map +1 -1
  41. package/dist/modules/auth/handleSessionExpiration/handleSessionExpiration.d.ts +11 -0
  42. package/dist/modules/auth/handleSessionExpiration/handleSessionExpiration.d.ts.map +1 -0
  43. package/dist/modules/auth/handleSessionExpiration/index.d.ts +2 -0
  44. package/dist/modules/auth/handleSessionExpiration/index.d.ts.map +1 -0
  45. package/dist/modules/auth/logout/logout.d.ts +1 -1
  46. package/dist/modules/auth/logout/logout.d.ts.map +1 -1
  47. package/dist/modules/auth/logoutReason.d.ts +11 -0
  48. package/dist/modules/auth/logoutReason.d.ts.map +1 -0
  49. package/dist/modules/auth/performLogout/index.d.ts +2 -0
  50. package/dist/modules/auth/performLogout/index.d.ts.map +1 -0
  51. package/dist/modules/auth/performLogout/performLogout.d.ts +12 -0
  52. package/dist/modules/auth/performLogout/performLogout.d.ts.map +1 -0
  53. package/dist/modules/auth/social/oauth/completeSocialAuthentication/completeSocialAuthentication.d.ts +4 -1
  54. package/dist/modules/auth/social/oauth/completeSocialAuthentication/completeSocialAuthentication.d.ts.map +1 -1
  55. package/dist/modules/checkout/createCheckoutTransaction/createCheckoutTransaction.d.ts +11 -0
  56. package/dist/modules/checkout/createCheckoutTransaction/createCheckoutTransaction.d.ts.map +1 -1
  57. package/dist/modules/checkout/submitCheckoutTransaction/submitCheckoutTransaction.d.ts +2 -2
  58. package/dist/modules/checkout/submitCheckoutTransaction/submitCheckoutTransaction.d.ts.map +1 -1
  59. package/dist/modules/checkout/utils/requiresConversion/index.d.ts +2 -0
  60. package/dist/modules/checkout/utils/requiresConversion/index.d.ts.map +1 -0
  61. package/dist/modules/checkout/utils/requiresConversion/requiresConversion.d.ts +20 -0
  62. package/dist/modules/checkout/utils/requiresConversion/requiresConversion.d.ts.map +1 -0
  63. package/dist/modules/sessionKeys/getSignedSessionId/getSignedSessionId.d.ts.map +1 -1
  64. package/dist/modules/swap/constants.d.ts +2 -0
  65. package/dist/modules/swap/constants.d.ts.map +1 -0
  66. package/dist/modules/swap/executeSwapTransaction/executeSwapTransaction.d.ts +32 -0
  67. package/dist/modules/swap/executeSwapTransaction/executeSwapTransaction.d.ts.map +1 -0
  68. package/dist/modules/swap/executeSwapTransaction/index.d.ts +3 -0
  69. package/dist/modules/swap/executeSwapTransaction/index.d.ts.map +1 -0
  70. package/dist/modules/swap/getSwapQuote/getSwapQuote.d.ts +53 -0
  71. package/dist/modules/swap/getSwapQuote/getSwapQuote.d.ts.map +1 -0
  72. package/dist/modules/swap/getSwapQuote/index.d.ts +3 -0
  73. package/dist/modules/swap/getSwapQuote/index.d.ts.map +1 -0
  74. package/dist/modules/swap/getSwapStatus/getSwapStatus.d.ts +23 -0
  75. package/dist/modules/swap/getSwapStatus/getSwapStatus.d.ts.map +1 -0
  76. package/dist/modules/swap/getSwapStatus/index.d.ts +3 -0
  77. package/dist/modules/swap/getSwapStatus/index.d.ts.map +1 -0
  78. package/dist/modules/swap/swap.types.d.ts +14 -0
  79. package/dist/modules/swap/swap.types.d.ts.map +1 -0
  80. package/dist/modules/waas/createWaasProvider/createWaasProvider.d.ts.map +1 -1
  81. package/dist/modules/waas/waas.types.d.ts +4 -1
  82. package/dist/modules/waas/waas.types.d.ts.map +1 -1
  83. package/dist/modules/wallets/confirmTransaction/confirmTransaction.d.ts +17 -0
  84. package/dist/modules/wallets/confirmTransaction/confirmTransaction.d.ts.map +1 -0
  85. package/dist/modules/wallets/confirmTransaction/index.d.ts +2 -0
  86. package/dist/modules/wallets/confirmTransaction/index.d.ts.map +1 -0
  87. package/dist/modules/wallets/disconnectAndTerminateWalletProviders/disconnectAndTerminateWalletProviders.d.ts +5 -2
  88. package/dist/modules/wallets/disconnectAndTerminateWalletProviders/disconnectAndTerminateWalletProviders.d.ts.map +1 -1
  89. package/dist/modules/wallets/networks/createBaseNetworkProvider/createBaseNetworkProvider.d.ts.map +1 -1
  90. package/dist/modules/wallets/networks/getNetworksData/getNetworksData.d.ts +1 -1
  91. package/dist/modules/wallets/networks/getNetworksData/getNetworksData.d.ts.map +1 -1
  92. package/dist/modules/wallets/networks/networkProvider/networkProvider.types.d.ts +4 -0
  93. package/dist/modules/wallets/networks/networkProvider/networkProvider.types.d.ts.map +1 -1
  94. package/dist/modules/wallets/walletProvider/index.d.ts +1 -1
  95. package/dist/modules/wallets/walletProvider/index.d.ts.map +1 -1
  96. package/dist/modules/wallets/walletProvider/walletProvider.types.d.ts +17 -8
  97. package/dist/modules/wallets/walletProvider/walletProvider.types.d.ts.map +1 -1
  98. package/dist/services/keychain/createIndexedDBKeychainService/createIndexedDBKeychainService.d.ts.map +1 -1
  99. package/dist/services/keychain/createIndexedDBKeychainService/utils/withDatabase/index.d.ts +2 -0
  100. package/dist/services/keychain/createIndexedDBKeychainService/utils/withDatabase/index.d.ts.map +1 -0
  101. package/dist/services/keychain/createIndexedDBKeychainService/utils/withDatabase/withDatabase.d.ts +13 -0
  102. package/dist/services/keychain/createIndexedDBKeychainService/utils/withDatabase/withDatabase.d.ts.map +1 -0
  103. package/dist/tsconfig.lib.tsbuildinfo +1 -1
  104. package/dist/waas.cjs.js +4 -4
  105. package/dist/waas.esm.js +3 -3
  106. package/dist/waasCore.cjs.js +7 -6
  107. package/dist/waasCore.cjs.js.map +1 -1
  108. package/dist/waasCore.esm.js +6 -5
  109. package/dist/waasCore.esm.js.map +1 -1
  110. package/package.json +3 -3
  111. package/dist/getNetworkProviderFromNetworkId-C9PJejYH.esm.js.map +0 -1
  112. package/dist/getNetworkProviderFromNetworkId-KrwFxKlq.cjs.js.map +0 -1
  113. package/dist/getSignedSessionId-Cqp6g3pY.cjs.js.map +0 -1
package/dist/index.cjs.js CHANGED
@@ -1,8 +1,8 @@
1
- const require_getNetworkProviderFromNetworkId = require('./getNetworkProviderFromNetworkId-KrwFxKlq.cjs.js');
2
- const require_InvalidParamError = require('./InvalidParamError-0w8-q2f3.cjs.js');
3
- const require_getVerifiedCredentialForWalletAccount = require('./getVerifiedCredentialForWalletAccount-Bffr91SM.cjs.js');
4
- const require_NotWaasWalletAccountError = require('./NotWaasWalletAccountError-CyvI1KtC.cjs.js');
5
- const require_isMfaRequiredForAction = require('./isMfaRequiredForAction-cPUOtGku.cjs.js');
1
+ const require_getNetworkProviderFromNetworkId = require('./getNetworkProviderFromNetworkId-Bd5KJOTp.cjs.js');
2
+ const require_InvalidParamError = require('./InvalidParamError-C9egR24p.cjs.js');
3
+ const require_getVerifiedCredentialForWalletAccount = require('./getVerifiedCredentialForWalletAccount-CsJEjM3D.cjs.js');
4
+ const require_NotWaasWalletAccountError = require('./NotWaasWalletAccountError-DoCmrSvg.cjs.js');
5
+ const require_isMfaRequiredForAction = require('./isMfaRequiredForAction-D5Mgfi6K.cjs.js');
6
6
  let _dynamic_labs_sdk_assert_package_version = require("@dynamic-labs-sdk/assert-package-version");
7
7
  let _dynamic_labs_sdk_api_core = require("@dynamic-labs/sdk-api-core");
8
8
  let zod_mini = require("zod/mini");
@@ -175,11 +175,11 @@ const getAvailableWalletProvidersFromWalletAccounts = (client) => {
175
175
  * Disconnect and terminate each wallet provider, if available.
176
176
  * @not-instrumented
177
177
  */
178
- const disconnectAndTerminateWalletProviders = async (client) => {
178
+ const disconnectAndTerminateWalletProviders = async ({ reason }, client) => {
179
179
  const core = require_InvalidParamError.getCore(client);
180
180
  const walletProviders = getAvailableWalletProvidersFromWalletAccounts(client);
181
181
  await Promise.all(walletProviders.map(async (walletProvider) => {
182
- if (walletProvider.terminate) await walletProvider.terminate();
182
+ if (walletProvider.terminate) await walletProvider.terminate({ reason });
183
183
  if (walletProvider.disconnect) try {
184
184
  await walletProvider.disconnect();
185
185
  } catch (err) {
@@ -189,18 +189,17 @@ const disconnectAndTerminateWalletProviders = async (client) => {
189
189
  };
190
190
 
191
191
  //#endregion
192
- //#region src/modules/auth/logout/logout.ts
192
+ //#region src/modules/auth/performLogout/performLogout.ts
193
193
  /**
194
- * Logs out the current user and clears all authentication data.
194
+ * Shared logout implementation that revokes the session, clears auth state,
195
+ * terminates wallet providers, and emits the logout event with the given reason.
195
196
  *
196
- * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
197
- * @returns A promise that resolves when the logout process is complete.
198
- * @instrumented
197
+ * @not-instrumented
199
198
  */
200
- const logout = async (client = require_InvalidParamError.getDefaultClient()) => {
199
+ const performLogout = async ({ reason }, client) => {
201
200
  const core = require_InvalidParamError.getCore(client);
202
201
  core.logger.debug("[logout] Logging out...");
203
- await disconnectAndTerminateWalletProviders(client);
202
+ await disconnectAndTerminateWalletProviders({ reason }, client);
204
203
  if (client.user !== null) {
205
204
  const apiClient = require_InvalidParamError.createApiClient({}, client);
206
205
  try {
@@ -226,11 +225,28 @@ const logout = async (client = require_InvalidParamError.getDefaultClient()) =>
226
225
  unverifiedWalletAccounts: [],
227
226
  user: null
228
227
  });
229
- require_getVerifiedCredentialForWalletAccount.emitEvent({ event: "logout" }, client);
228
+ require_getVerifiedCredentialForWalletAccount.emitEvent({
229
+ args: { reason },
230
+ event: "logout"
231
+ }, client);
230
232
  fetchProjectSettings(client);
231
233
  require_getNetworkProviderFromNetworkId.generateSessionKeys(client);
232
234
  };
233
235
 
236
+ //#endregion
237
+ //#region src/modules/auth/handleSessionExpiration/handleSessionExpiration.ts
238
+ /**
239
+ * Logs out due to session expiry with a token-expired reason,
240
+ * allowing downstream providers to decide their own cleanup behavior.
241
+ *
242
+ * @param client - The Dynamic client instance.
243
+ * @returns A promise that resolves when the logout process is complete.
244
+ * @instrumented
245
+ */
246
+ const handleSessionExpiration = async (client) => {
247
+ return performLogout({ reason: "token-expired" }, client);
248
+ };
249
+
234
250
  //#endregion
235
251
  //#region src/modules/auth/initializeAuth/setLongTimeout/setLongTimeout.ts
236
252
  /**
@@ -271,7 +287,7 @@ const initializeAuth = (client) => {
271
287
  const now = /* @__PURE__ */ new Date();
272
288
  const timeUntilExpiration = expiration.getTime() - now.getTime();
273
289
  if (timeUntilExpiration <= 0) {
274
- logout(client);
290
+ handleSessionExpiration(client);
275
291
  return;
276
292
  }
277
293
  clearExpirationTimeout = setLongTimeout(checkExpiration, timeUntilExpiration);
@@ -280,6 +296,19 @@ const initializeAuth = (client) => {
280
296
  checkExpiration();
281
297
  };
282
298
 
299
+ //#endregion
300
+ //#region src/modules/auth/logout/logout.ts
301
+ /**
302
+ * Logs out the current user and clears all authentication data.
303
+ *
304
+ * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
305
+ * @returns A promise that resolves when the logout process is complete.
306
+ * @instrumented
307
+ */
308
+ const logout = async (client = require_InvalidParamError.getDefaultClient()) => {
309
+ return performLogout({ reason: "user-intent" }, client);
310
+ };
311
+
283
312
  //#endregion
284
313
  //#region src/modules/crossTabEventSync/setupCrossTabEventSync/setupCrossTabEventSync.ts
285
314
  /**
@@ -1468,6 +1497,21 @@ var SimulationFailedError = class extends require_InvalidParamError.BaseError {
1468
1497
  }
1469
1498
  };
1470
1499
 
1500
+ //#endregion
1501
+ //#region src/errors/TokenSwapError.ts
1502
+ var TokenSwapError = class extends require_InvalidParamError.BaseError {
1503
+ constructor({ message, originalError }) {
1504
+ const cause = originalError && originalError instanceof Error ? originalError : null;
1505
+ super({
1506
+ cause,
1507
+ code: "token_swap_error",
1508
+ docsUrl: null,
1509
+ name: "TokenSwapError",
1510
+ shortMessage: message
1511
+ });
1512
+ }
1513
+ };
1514
+
1471
1515
  //#endregion
1472
1516
  //#region src/errors/UnrecognizedNetworkError.ts
1473
1517
  var UnrecognizedNetworkError = class extends require_InvalidParamError.BaseError {
@@ -2018,13 +2062,14 @@ const authenticateWithSocial = async ({ provider, redirectUrl }, client = requir
2018
2062
  * and completes the user authentication with the social provider.
2019
2063
  *
2020
2064
  * @param params.url - The callback URL containing OAuth response parameters.
2065
+ * @param [params.requestedScopes] - Optional scopes to request an elevated access token when verifying (linking) a social account.
2021
2066
  * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
2022
2067
  * @returns A promise that resolves to the authenticated user or null.
2023
2068
  * @throws MissingSocialUrlParamError If required OAuth parameters are missing.
2024
2069
  * @throws InvalidRedirectStorageStateError If the stored state doesn't match.
2025
2070
  * @instrumented
2026
2071
  */
2027
- const completeSocialAuthentication = async ({ url }, client = require_InvalidParamError.getDefaultClient()) => {
2072
+ const completeSocialAuthentication = async ({ url, requestedScopes }, client = require_InvalidParamError.getDefaultClient()) => {
2028
2073
  const core = require_InvalidParamError.getCore(client);
2029
2074
  const apiClient = require_InvalidParamError.createApiClient({}, client);
2030
2075
  await core.initTrack.waitForAll();
@@ -2043,6 +2088,7 @@ const completeSocialAuthentication = async ({ url }, client = require_InvalidPar
2043
2088
  oauthRequest: {
2044
2089
  code: dynamicOauthCode,
2045
2090
  codeVerifier,
2091
+ requestedScopes,
2046
2092
  state: dynamicOauthState
2047
2093
  },
2048
2094
  providerType: provider
@@ -2300,6 +2346,10 @@ const createCheckoutTransaction = async (params, client = require_InvalidParamEr
2300
2346
  checkoutTransactionCreateRequest: {
2301
2347
  amount: params.amount,
2302
2348
  currency: params.currency,
2349
+ destinationAddresses: params.destinationAddresses?.map((address) => ({
2350
+ address: address.address,
2351
+ chainName: address.chain
2352
+ })),
2303
2353
  expiresIn: params.expiresIn,
2304
2354
  memo: params.memo
2305
2355
  },
@@ -2396,6 +2446,43 @@ function assertWalletProviderMethodDefined(walletProvider, methodName) {
2396
2446
  });
2397
2447
  }
2398
2448
 
2449
+ //#endregion
2450
+ //#region src/modules/swap/constants.ts
2451
+ const SWAP_SUPPORTED_CHAINS = [
2452
+ "BTC",
2453
+ "EVM",
2454
+ "SOL",
2455
+ "SUI",
2456
+ "TRON"
2457
+ ];
2458
+
2459
+ //#endregion
2460
+ //#region src/modules/swap/executeSwapTransaction/executeSwapTransaction.ts
2461
+ /**
2462
+ * Executes a swap transaction
2463
+ *
2464
+ * @param params ExecuteSwapTransactionParams - The parameters for the swap transaction.
2465
+ * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
2466
+ * @returns The transaction hash.
2467
+ * @instrumented
2468
+ */
2469
+ const executeSwapTransaction = async ({ walletAccount, signingPayload, onStepChange }, client = require_InvalidParamError.getDefaultClient()) => {
2470
+ if (!SWAP_SUPPORTED_CHAINS.includes(walletAccount.chain)) throw new require_InvalidParamError.InvalidParamError(`Chain ${walletAccount.chain} is not supported for swap transactions`);
2471
+ const walletProvider = require_getVerifiedCredentialForWalletAccount.getWalletProviderFromWalletAccount({ walletAccount }, client);
2472
+ assertWalletProviderMethodDefined(walletProvider, "executeSwapTransaction");
2473
+ const requiredNetworkId = signingPayload.chainId;
2474
+ if (requiredNetworkId && walletProvider.switchActiveNetwork) {
2475
+ const { networkId: activeNetworkId } = await walletProvider.getActiveNetworkId();
2476
+ if (activeNetworkId !== requiredNetworkId) await walletProvider.switchActiveNetwork({ networkId: requiredNetworkId });
2477
+ }
2478
+ const { transactionHash } = await walletProvider.executeSwapTransaction({
2479
+ onStepChange,
2480
+ signingPayload,
2481
+ walletAccount
2482
+ });
2483
+ return { transactionHash };
2484
+ };
2485
+
2399
2486
  //#endregion
2400
2487
  //#region src/modules/checkout/submitCheckoutTransaction/submitCheckoutTransaction.ts
2401
2488
  /**
@@ -2404,7 +2491,7 @@ function assertWalletProviderMethodDefined(walletProvider, methodName) {
2404
2491
  * Orchestrates the full submission flow:
2405
2492
  * 1. Calls prepareCheckoutTransaction to advance to signing state and lock the quote
2406
2493
  * 2. Ensures the wallet is on the correct network for the transaction
2407
- * 3. Delegates on-chain signing to the wallet provider's executeCheckoutTransaction method
2494
+ * 3. Delegates on-chain signing to the wallet provider's executeSwapTransaction method
2408
2495
  * 4. Calls broadcastCheckoutTransaction with the resulting txHash
2409
2496
  *
2410
2497
  * @param params SubmitCheckoutTransactionParams - The transaction ID, wallet account, and optional step callback.
@@ -2415,14 +2502,7 @@ function assertWalletProviderMethodDefined(walletProvider, methodName) {
2415
2502
  const submitCheckoutTransaction = async ({ onStepChange, transactionId, walletAccount }, client = require_InvalidParamError.getDefaultClient()) => {
2416
2503
  const prepared = await prepareCheckoutTransaction({ transactionId }, client);
2417
2504
  require_InvalidParamError.assertDefined(prepared.signingPayload, "No signing payload returned from prepare — quote may be missing transaction data");
2418
- const walletProvider = require_getVerifiedCredentialForWalletAccount.getWalletProviderFromWalletAccount({ walletAccount }, client);
2419
- assertWalletProviderMethodDefined(walletProvider, "executeCheckoutTransaction");
2420
- const requiredNetworkId = prepared.signingPayload.chainId;
2421
- if (requiredNetworkId && walletProvider.switchActiveNetwork) {
2422
- const { networkId: activeNetworkId } = await walletProvider.getActiveNetworkId();
2423
- if (activeNetworkId !== requiredNetworkId) await walletProvider.switchActiveNetwork({ networkId: requiredNetworkId });
2424
- }
2425
- const { transactionHash } = await walletProvider.executeCheckoutTransaction({
2505
+ const { transactionHash } = await executeSwapTransaction({
2426
2506
  onStepChange,
2427
2507
  signingPayload: prepared.signingPayload,
2428
2508
  walletAccount
@@ -2433,6 +2513,29 @@ const submitCheckoutTransaction = async ({ onStepChange, transactionId, walletAc
2433
2513
  }, client);
2434
2514
  };
2435
2515
 
2516
+ //#endregion
2517
+ //#region src/modules/checkout/utils/requiresConversion/requiresConversion.ts
2518
+ /**
2519
+ * Determines whether a token conversion (swap/bridge) is required for a checkout transaction.
2520
+ *
2521
+ * Returns `true` when the from token does not match any settlement token defined in
2522
+ * the checkout's settlement config for the given chain — meaning the asset must be
2523
+ * converted before it can settle.
2524
+ * Returns `false` when the from token already matches a settlement token, so no
2525
+ * conversion is needed.
2526
+ *
2527
+ * @param params - The from token details and the checkout's settlement config.
2528
+ * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
2529
+ * @returns Whether a token conversion is required
2530
+ * @instrumented
2531
+ */
2532
+ const requiresConversion = async ({ transaction }, client = require_InvalidParamError.getDefaultClient()) => {
2533
+ if (!transaction.fromChainId || !transaction.fromChainName || !transaction.fromToken) throw new require_InvalidParamError.InvalidParamError("Transaction is missing source information. Make sure that attachCheckoutTransactionSource has been called before calling this function.");
2534
+ const checkout = (await getCheckouts(client)).find((checkout$1) => checkout$1.id === transaction.checkoutId);
2535
+ require_InvalidParamError.assertDefined(checkout, "Could not find checkout associated with transaction.");
2536
+ return !checkout.settlementConfig.settlements.some((settlement) => settlement.chainName === transaction.fromChainName && settlement.chainId === transaction.fromChainId && settlement.tokenAddress === transaction.fromToken);
2537
+ };
2538
+
2436
2539
  //#endregion
2437
2540
  //#region src/modules/deviceRegistration/completeDeviceRegistration/completeDeviceRegistration.ts
2438
2541
  const DEVICE_REGISTRATION_TOKEN_HEADER = "x-dynamic-device-registration-token";
@@ -4680,6 +4783,85 @@ const verifyOTP = async ({ otpVerification, verificationToken, requestedScopes }
4680
4783
  return response;
4681
4784
  };
4682
4785
 
4786
+ //#endregion
4787
+ //#region src/modules/swap/getSwapQuote/getSwapQuote.ts
4788
+ /**
4789
+ * Gets a swap quote
4790
+ *
4791
+ * @param params GetSwapQuoteParams - The parameters for the swap quote.
4792
+ * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
4793
+ * @returns The swap quote details. Use the `signingPayload` field to get the transaction data for the wallet to sign.
4794
+ * @instrumented
4795
+ */
4796
+ const getSwapQuote = async (params, client = require_InvalidParamError.getDefaultClient()) => {
4797
+ const core = require_InvalidParamError.getCore(client);
4798
+ const apiClient = require_InvalidParamError.createApiClient({}, client);
4799
+ if (!params.from.amount && !params.to.amount) throw new require_InvalidParamError.InvalidParamError("Either from.amount or to.amount is required");
4800
+ if (params.from.amount && params.to.amount) throw new require_InvalidParamError.InvalidParamError("Only one of from.amount or to.amount is allowed");
4801
+ return await apiClient.swapQuote({
4802
+ environmentId: core.environmentId,
4803
+ swapQuoteRequest: {
4804
+ from: {
4805
+ ...params.from,
4806
+ chainId: params.from.networkId,
4807
+ chainName: params.from.chain
4808
+ },
4809
+ maxPriceImpact: params.maxPriceImpact,
4810
+ order: params.order,
4811
+ slippage: params.slippage,
4812
+ to: {
4813
+ ...params.to,
4814
+ chainId: params.to.networkId,
4815
+ chainName: params.to.chain
4816
+ }
4817
+ }
4818
+ });
4819
+ };
4820
+
4821
+ //#endregion
4822
+ //#region src/modules/swap/getSwapStatus/getSwapStatus.ts
4823
+ /**
4824
+ * Gets the status of a swap
4825
+ *
4826
+ * @param params GetSwapStatusParams - The parameters for the swap status.
4827
+ * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
4828
+ * @returns The swap status.
4829
+ * @instrumented
4830
+ */
4831
+ const getSwapStatus = async (params, client = require_InvalidParamError.getDefaultClient()) => {
4832
+ const core = require_InvalidParamError.getCore(client);
4833
+ const apiClient = require_InvalidParamError.createApiClient({}, client);
4834
+ let from;
4835
+ if (params.from) from = {
4836
+ chainId: params.from.networkId,
4837
+ chainName: params.from.chain
4838
+ };
4839
+ let to;
4840
+ if (params.to) to = {
4841
+ chainId: params.to.networkId,
4842
+ chainName: params.to.chain
4843
+ };
4844
+ try {
4845
+ const response = await apiClient.swapStatus({
4846
+ environmentId: core.environmentId,
4847
+ swapStatusRequest: {
4848
+ from,
4849
+ to,
4850
+ txHash: params.txHash
4851
+ }
4852
+ });
4853
+ return {
4854
+ status: response.status,
4855
+ substatus: response.substatus
4856
+ };
4857
+ } catch (error) {
4858
+ throw new TokenSwapError({
4859
+ message: "Failed to get swap status",
4860
+ originalError: error
4861
+ });
4862
+ }
4863
+ };
4864
+
4683
4865
  //#endregion
4684
4866
  //#region src/modules/user/deleteUser/deleteUser.ts
4685
4867
  /**
@@ -4767,6 +4949,31 @@ const assertWalletAccountSigningAvailability = async ({ walletAccount }, client
4767
4949
  });
4768
4950
  };
4769
4951
 
4952
+ //#endregion
4953
+ //#region src/modules/wallets/confirmTransaction/confirmTransaction.ts
4954
+ /**
4955
+ * Waits for a transaction to be confirmed on-chain.
4956
+ *
4957
+ * Delegates to the wallet provider's `confirmTransaction` implementation,
4958
+ * which polls the appropriate chain API until the transaction is included
4959
+ * in a block or the maximum wait time is exceeded.
4960
+ *
4961
+ * @param params.walletAccount - The wallet account that submitted the transaction.
4962
+ * @param params.transactionHash - The transaction hash to wait for.
4963
+ * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
4964
+ * @returns A promise that resolves when the transaction is confirmed.
4965
+ * @throws If the wallet provider does not support the confirmTransaction method.
4966
+ * @instrumented
4967
+ */
4968
+ const confirmTransaction = async ({ walletAccount, transactionHash }, client = require_InvalidParamError.getDefaultClient()) => {
4969
+ const walletProvider = require_getVerifiedCredentialForWalletAccount.getWalletProviderFromWalletAccount({ walletAccount }, client);
4970
+ assertWalletProviderMethodDefined(walletProvider, "confirmTransaction");
4971
+ await walletProvider.confirmTransaction({
4972
+ transactionHash,
4973
+ walletAccount
4974
+ });
4975
+ };
4976
+
4770
4977
  //#endregion
4771
4978
  //#region src/utils/isMobile/isMobile.ts
4772
4979
  /**
@@ -5661,6 +5868,7 @@ exports.NoWebAuthNSupportError = NoWebAuthNSupportError;
5661
5868
  exports.NotWaasWalletAccountError = require_NotWaasWalletAccountError.NotWaasWalletAccountError;
5662
5869
  exports.SandboxMaximumThresholdReachedError = require_InvalidParamError.SandboxMaximumThresholdReachedError;
5663
5870
  exports.SimulationFailedError = SimulationFailedError;
5871
+ exports.TokenSwapError = TokenSwapError;
5664
5872
  exports.UnauthorizedError = require_InvalidParamError.UnauthorizedError;
5665
5873
  exports.UnavailableInServerSideError = UnavailableInServerSideError;
5666
5874
  exports.UnrecognizedNetworkError = UnrecognizedNetworkError;
@@ -5686,6 +5894,7 @@ exports.cancelCheckoutTransaction = cancelCheckoutTransaction;
5686
5894
  exports.checkStepUpAuth = checkStepUpAuth;
5687
5895
  exports.completeDeviceRegistration = completeDeviceRegistration;
5688
5896
  exports.completeSocialAuthentication = completeSocialAuthentication;
5897
+ exports.confirmTransaction = confirmTransaction;
5689
5898
  exports.connectAndVerifyWithWalletProvider = connectAndVerifyWithWalletProvider;
5690
5899
  exports.connectWithWalletProvider = connectWithWalletProvider;
5691
5900
  exports.consumeMfaToken = require_isMfaRequiredForAction.consumeMfaToken;
@@ -5700,6 +5909,7 @@ exports.deletePasskey = deletePasskey;
5700
5909
  exports.deleteUser = deleteUser;
5701
5910
  exports.detectDeviceRegistrationRedirect = detectDeviceRegistrationRedirect;
5702
5911
  exports.detectOAuthRedirect = detectOAuthRedirect;
5912
+ exports.executeSwapTransaction = executeSwapTransaction;
5703
5913
  exports.fetchProjectSettings = fetchProjectSettings;
5704
5914
  exports.getActiveNetworkData = getActiveNetworkData;
5705
5915
  exports.getActiveNetworkId = getActiveNetworkId;
@@ -5726,6 +5936,8 @@ exports.getOwnerWalletAccountForSmartWalletAccount = getOwnerWalletAccountForSma
5726
5936
  exports.getPasskeys = getPasskeys;
5727
5937
  exports.getPrimaryWalletAccount = getPrimaryWalletAccount;
5728
5938
  exports.getRegisteredDevices = getRegisteredDevices;
5939
+ exports.getSwapQuote = getSwapQuote;
5940
+ exports.getSwapStatus = getSwapStatus;
5729
5941
  exports.getTransactionHistory = getTransactionHistory;
5730
5942
  exports.getUserSocialAccounts = getUserSocialAccounts;
5731
5943
  exports.getWalletAccountAddressByType = getWalletAccountAddressByType;
@@ -5763,6 +5975,7 @@ exports.registerPasskey = registerPasskey;
5763
5975
  exports.registerTotpMfaDevice = registerTotpMfaDevice;
5764
5976
  exports.removeWalletAccount = removeWalletAccount;
5765
5977
  exports.requestExternalAuthElevatedToken = requestExternalAuthElevatedToken;
5978
+ exports.requiresConversion = requiresConversion;
5766
5979
  exports.revokeAllRegisteredDevices = revokeAllRegisteredDevices;
5767
5980
  exports.revokeRegisteredDevice = revokeRegisteredDevice;
5768
5981
  exports.selectPrimaryWalletAccount = selectPrimaryWalletAccount;