@dynamic-labs-sdk/client 0.18.0 → 0.19.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{InvalidParamError-Bxg4p9zQ.cjs.js → InvalidParamError-6MugNXi3.cjs.js} +4 -4
- package/dist/{InvalidParamError-Bxg4p9zQ.cjs.js.map → InvalidParamError-6MugNXi3.cjs.js.map} +1 -1
- package/dist/{InvalidParamError-ByAOflE2.esm.js → InvalidParamError-CnPeSjBW.esm.js} +3 -3
- package/dist/{InvalidParamError-ByAOflE2.esm.js.map → InvalidParamError-CnPeSjBW.esm.js.map} +1 -1
- package/dist/{NotWaasWalletAccountError-DMFf5i7j.esm.js → NotWaasWalletAccountError-B5QkZWrs.esm.js} +3 -3
- package/dist/{NotWaasWalletAccountError-DMFf5i7j.esm.js.map → NotWaasWalletAccountError-B5QkZWrs.esm.js.map} +1 -1
- package/dist/{NotWaasWalletAccountError-2CU35ult.cjs.js → NotWaasWalletAccountError-C204z_SH.cjs.js} +3 -3
- package/dist/{NotWaasWalletAccountError-2CU35ult.cjs.js.map → NotWaasWalletAccountError-C204z_SH.cjs.js.map} +1 -1
- package/dist/core.cjs.js +5 -5
- package/dist/core.cjs.js.map +1 -1
- package/dist/core.esm.js +5 -5
- package/dist/core.esm.js.map +1 -1
- package/dist/exports/core.d.ts +1 -1
- package/dist/exports/core.d.ts.map +1 -1
- package/dist/exports/index.d.ts +11 -1
- package/dist/exports/index.d.ts.map +1 -1
- package/dist/{getNetworkProviderFromNetworkId-BXH2tfrn.cjs.js → getNetworkProviderFromNetworkId-CoAKJyXQ.cjs.js} +23 -14
- package/dist/getNetworkProviderFromNetworkId-CoAKJyXQ.cjs.js.map +1 -0
- package/dist/{getNetworkProviderFromNetworkId-6QbuR0_i.esm.js → getNetworkProviderFromNetworkId-VEDzpV8Z.esm.js} +23 -14
- package/dist/getNetworkProviderFromNetworkId-VEDzpV8Z.esm.js.map +1 -0
- package/dist/{getSignedSessionId-KSSnmfwN.cjs.js → getSignedSessionId-BZL8lFjp.cjs.js} +5 -7
- package/dist/getSignedSessionId-BZL8lFjp.cjs.js.map +1 -0
- package/dist/{getSignedSessionId-yWd9_5u4.esm.js → getSignedSessionId-CgoBQlYG.esm.js} +5 -7
- package/dist/{getSignedSessionId-yWd9_5u4.esm.js.map → getSignedSessionId-CgoBQlYG.esm.js.map} +1 -1
- package/dist/{getVerifiedCredentialForWalletAccount-DbfbxLr9.esm.js → getVerifiedCredentialForWalletAccount-B58hODrW.esm.js} +2 -2
- package/dist/{getVerifiedCredentialForWalletAccount-DbfbxLr9.esm.js.map → getVerifiedCredentialForWalletAccount-B58hODrW.esm.js.map} +1 -1
- package/dist/{getVerifiedCredentialForWalletAccount-CJAgL4AJ.cjs.js → getVerifiedCredentialForWalletAccount-Zu778J_y.cjs.js} +3 -3
- package/dist/{getVerifiedCredentialForWalletAccount-CJAgL4AJ.cjs.js.map → getVerifiedCredentialForWalletAccount-Zu778J_y.cjs.js.map} +1 -1
- package/dist/index.cjs.js +235 -39
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +232 -40
- package/dist/index.esm.js.map +1 -1
- package/dist/{isMfaRequiredForAction-DnZ2ZWUB.cjs.js → isMfaRequiredForAction-D7amEpqp.cjs.js} +2 -2
- package/dist/{isMfaRequiredForAction-DnZ2ZWUB.cjs.js.map → isMfaRequiredForAction-D7amEpqp.cjs.js.map} +1 -1
- package/dist/{isMfaRequiredForAction-CG5JbTh1.esm.js → isMfaRequiredForAction-Dkj_caxl.esm.js} +2 -2
- package/dist/{isMfaRequiredForAction-CG5JbTh1.esm.js.map → isMfaRequiredForAction-Dkj_caxl.esm.js.map} +1 -1
- package/dist/modules/auth/checkStepUpAuth/checkStepUpAuth.d.ts +35 -0
- package/dist/modules/auth/checkStepUpAuth/checkStepUpAuth.d.ts.map +1 -0
- package/dist/modules/auth/checkStepUpAuth/index.d.ts +2 -0
- package/dist/modules/auth/checkStepUpAuth/index.d.ts.map +1 -0
- package/dist/modules/auth/events.d.ts +6 -2
- package/dist/modules/auth/events.d.ts.map +1 -1
- package/dist/modules/auth/handleSessionExpiration/handleSessionExpiration.d.ts +11 -0
- package/dist/modules/auth/handleSessionExpiration/handleSessionExpiration.d.ts.map +1 -0
- package/dist/modules/auth/handleSessionExpiration/index.d.ts +2 -0
- package/dist/modules/auth/handleSessionExpiration/index.d.ts.map +1 -0
- package/dist/modules/auth/logout/logout.d.ts +1 -1
- package/dist/modules/auth/logout/logout.d.ts.map +1 -1
- package/dist/modules/auth/logoutReason.d.ts +11 -0
- package/dist/modules/auth/logoutReason.d.ts.map +1 -0
- package/dist/modules/auth/performLogout/index.d.ts +2 -0
- package/dist/modules/auth/performLogout/index.d.ts.map +1 -0
- package/dist/modules/auth/performLogout/performLogout.d.ts +12 -0
- package/dist/modules/auth/performLogout/performLogout.d.ts.map +1 -0
- package/dist/modules/auth/social/oauth/completeSocialAuthentication/completeSocialAuthentication.d.ts +4 -1
- package/dist/modules/auth/social/oauth/completeSocialAuthentication/completeSocialAuthentication.d.ts.map +1 -1
- package/dist/modules/checkout/submitCheckoutTransaction/submitCheckoutTransaction.d.ts +2 -2
- package/dist/modules/checkout/submitCheckoutTransaction/submitCheckoutTransaction.d.ts.map +1 -1
- package/dist/modules/sessionKeys/getSignedSessionId/getSignedSessionId.d.ts.map +1 -1
- package/dist/modules/swap/constants.d.ts +2 -0
- package/dist/modules/swap/constants.d.ts.map +1 -0
- package/dist/modules/swap/executeSwapTransaction/executeSwapTransaction.d.ts +32 -0
- package/dist/modules/swap/executeSwapTransaction/executeSwapTransaction.d.ts.map +1 -0
- package/dist/modules/swap/executeSwapTransaction/index.d.ts +3 -0
- package/dist/modules/swap/executeSwapTransaction/index.d.ts.map +1 -0
- package/dist/modules/swap/getSwapQuote/getSwapQuote.d.ts +53 -0
- package/dist/modules/swap/getSwapQuote/getSwapQuote.d.ts.map +1 -0
- package/dist/modules/swap/getSwapQuote/index.d.ts +3 -0
- package/dist/modules/swap/getSwapQuote/index.d.ts.map +1 -0
- package/dist/modules/swap/getSwapStatus/getSwapStatus.d.ts +23 -0
- package/dist/modules/swap/getSwapStatus/getSwapStatus.d.ts.map +1 -0
- package/dist/modules/swap/getSwapStatus/index.d.ts +3 -0
- package/dist/modules/swap/getSwapStatus/index.d.ts.map +1 -0
- package/dist/modules/swap/swap.types.d.ts +14 -0
- package/dist/modules/swap/swap.types.d.ts.map +1 -0
- package/dist/modules/waas/createWaasProvider/createWaasProvider.d.ts.map +1 -1
- package/dist/modules/waas/waas.types.d.ts +4 -1
- package/dist/modules/waas/waas.types.d.ts.map +1 -1
- package/dist/modules/wallets/disconnectAndTerminateWalletProviders/disconnectAndTerminateWalletProviders.d.ts +5 -2
- package/dist/modules/wallets/disconnectAndTerminateWalletProviders/disconnectAndTerminateWalletProviders.d.ts.map +1 -1
- package/dist/modules/wallets/walletProvider/index.d.ts +1 -1
- package/dist/modules/wallets/walletProvider/index.d.ts.map +1 -1
- package/dist/modules/wallets/walletProvider/walletProvider.types.d.ts +17 -8
- package/dist/modules/wallets/walletProvider/walletProvider.types.d.ts.map +1 -1
- package/dist/services/keychain/createIndexedDBKeychainService/createIndexedDBKeychainService.d.ts.map +1 -1
- package/dist/tsconfig.lib.tsbuildinfo +1 -1
- package/dist/waas.cjs.js +4 -4
- package/dist/waas.esm.js +3 -3
- package/dist/waasCore.cjs.js +7 -6
- package/dist/waasCore.cjs.js.map +1 -1
- package/dist/waasCore.esm.js +6 -5
- package/dist/waasCore.esm.js.map +1 -1
- package/package.json +3 -3
- package/dist/getNetworkProviderFromNetworkId-6QbuR0_i.esm.js.map +0 -1
- package/dist/getNetworkProviderFromNetworkId-BXH2tfrn.cjs.js.map +0 -1
- package/dist/getSignedSessionId-KSSnmfwN.cjs.js.map +0 -1
package/dist/index.cjs.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
const require_getNetworkProviderFromNetworkId = require('./getNetworkProviderFromNetworkId-
|
|
2
|
-
const require_InvalidParamError = require('./InvalidParamError-
|
|
3
|
-
const require_getVerifiedCredentialForWalletAccount = require('./getVerifiedCredentialForWalletAccount-
|
|
4
|
-
const require_NotWaasWalletAccountError = require('./NotWaasWalletAccountError-
|
|
5
|
-
const require_isMfaRequiredForAction = require('./isMfaRequiredForAction-
|
|
1
|
+
const require_getNetworkProviderFromNetworkId = require('./getNetworkProviderFromNetworkId-CoAKJyXQ.cjs.js');
|
|
2
|
+
const require_InvalidParamError = require('./InvalidParamError-6MugNXi3.cjs.js');
|
|
3
|
+
const require_getVerifiedCredentialForWalletAccount = require('./getVerifiedCredentialForWalletAccount-Zu778J_y.cjs.js');
|
|
4
|
+
const require_NotWaasWalletAccountError = require('./NotWaasWalletAccountError-C204z_SH.cjs.js');
|
|
5
|
+
const require_isMfaRequiredForAction = require('./isMfaRequiredForAction-D7amEpqp.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/
|
|
192
|
+
//#region src/modules/auth/performLogout/performLogout.ts
|
|
193
193
|
/**
|
|
194
|
-
*
|
|
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
|
-
* @
|
|
197
|
-
* @returns A promise that resolves when the logout process is complete.
|
|
198
|
-
* @instrumented
|
|
197
|
+
* @not-instrumented
|
|
199
198
|
*/
|
|
200
|
-
const
|
|
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({
|
|
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
|
-
|
|
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
|
/**
|
|
@@ -1559,6 +1588,65 @@ var WalletProviderMethodUnavailableError = class extends require_InvalidParamErr
|
|
|
1559
1588
|
}
|
|
1560
1589
|
};
|
|
1561
1590
|
|
|
1591
|
+
//#endregion
|
|
1592
|
+
//#region src/modules/auth/checkStepUpAuth/checkStepUpAuth.ts
|
|
1593
|
+
const STEP_UP_REQUIRED_DEFAULT = {
|
|
1594
|
+
credentials: [],
|
|
1595
|
+
isRequired: true
|
|
1596
|
+
};
|
|
1597
|
+
/**
|
|
1598
|
+
* Checks whether step-up authentication is required for a given scope
|
|
1599
|
+
* and returns the available credentials to satisfy it.
|
|
1600
|
+
*
|
|
1601
|
+
* First performs a fast local check — if a valid elevated access token already
|
|
1602
|
+
* exists for the scope, returns `{ isRequired: false }` immediately without
|
|
1603
|
+
* an API call.
|
|
1604
|
+
*
|
|
1605
|
+
* Otherwise, calls the backend `stepUp/check` endpoint which evaluates
|
|
1606
|
+
* feature flags, SDK version, MFA settings, and action-based requirements
|
|
1607
|
+
* to determine if step-up is needed. The response includes the available
|
|
1608
|
+
* credentials and a recommended default credential.
|
|
1609
|
+
*
|
|
1610
|
+
* If the request fails for any reason, defaults to `{ isRequired: true }`
|
|
1611
|
+
* as a safety measure.
|
|
1612
|
+
*
|
|
1613
|
+
* @param params.scope - The scope to check (e.g., 'wallet:export').
|
|
1614
|
+
* @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
|
|
1615
|
+
* @returns The step-up check result with `isRequired`, `credentials`, and `defaultCredentialId`.
|
|
1616
|
+
*
|
|
1617
|
+
* @example
|
|
1618
|
+
* ```typescript
|
|
1619
|
+
* const result = await checkStepUpAuth({ scope: TokenScope.Walletexport });
|
|
1620
|
+
* if (result.isRequired) {
|
|
1621
|
+
* // Show step-up auth UI using result.credentials
|
|
1622
|
+
* }
|
|
1623
|
+
* ```
|
|
1624
|
+
* @instrumented
|
|
1625
|
+
*/
|
|
1626
|
+
const checkStepUpAuth = async ({ scope }, client = require_InvalidParamError.getDefaultClient()) => {
|
|
1627
|
+
if (require_InvalidParamError.getElevatedAccessToken({
|
|
1628
|
+
consume: false,
|
|
1629
|
+
scope
|
|
1630
|
+
}, client)) return {
|
|
1631
|
+
credentials: [],
|
|
1632
|
+
isRequired: false
|
|
1633
|
+
};
|
|
1634
|
+
try {
|
|
1635
|
+
const core = require_InvalidParamError.getCore(client);
|
|
1636
|
+
const response = await require_InvalidParamError.createApiClient({}, client).stepUpCheck({
|
|
1637
|
+
environmentId: core.environmentId,
|
|
1638
|
+
stepUpCheckRequest: { scope }
|
|
1639
|
+
});
|
|
1640
|
+
return {
|
|
1641
|
+
credentials: response.credentials ?? [],
|
|
1642
|
+
defaultCredentialId: response.defaultCredentialId,
|
|
1643
|
+
isRequired: response.isRequired
|
|
1644
|
+
};
|
|
1645
|
+
} catch {
|
|
1646
|
+
return STEP_UP_REQUIRED_DEFAULT;
|
|
1647
|
+
}
|
|
1648
|
+
};
|
|
1649
|
+
|
|
1562
1650
|
//#endregion
|
|
1563
1651
|
//#region src/modules/auth/externalAuth/requestExternalAuthElevatedToken/requestExternalAuthElevatedToken.ts
|
|
1564
1652
|
/**
|
|
@@ -1959,13 +2047,14 @@ const authenticateWithSocial = async ({ provider, redirectUrl }, client = requir
|
|
|
1959
2047
|
* and completes the user authentication with the social provider.
|
|
1960
2048
|
*
|
|
1961
2049
|
* @param params.url - The callback URL containing OAuth response parameters.
|
|
2050
|
+
* @param [params.requestedScopes] - Optional scopes to request an elevated access token when verifying (linking) a social account.
|
|
1962
2051
|
* @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
|
|
1963
2052
|
* @returns A promise that resolves to the authenticated user or null.
|
|
1964
2053
|
* @throws MissingSocialUrlParamError If required OAuth parameters are missing.
|
|
1965
2054
|
* @throws InvalidRedirectStorageStateError If the stored state doesn't match.
|
|
1966
2055
|
* @instrumented
|
|
1967
2056
|
*/
|
|
1968
|
-
const completeSocialAuthentication = async ({ url }, client = require_InvalidParamError.getDefaultClient()) => {
|
|
2057
|
+
const completeSocialAuthentication = async ({ url, requestedScopes }, client = require_InvalidParamError.getDefaultClient()) => {
|
|
1969
2058
|
const core = require_InvalidParamError.getCore(client);
|
|
1970
2059
|
const apiClient = require_InvalidParamError.createApiClient({}, client);
|
|
1971
2060
|
await core.initTrack.waitForAll();
|
|
@@ -1984,6 +2073,7 @@ const completeSocialAuthentication = async ({ url }, client = require_InvalidPar
|
|
|
1984
2073
|
oauthRequest: {
|
|
1985
2074
|
code: dynamicOauthCode,
|
|
1986
2075
|
codeVerifier,
|
|
2076
|
+
requestedScopes,
|
|
1987
2077
|
state: dynamicOauthState
|
|
1988
2078
|
},
|
|
1989
2079
|
providerType: provider
|
|
@@ -2337,6 +2427,43 @@ function assertWalletProviderMethodDefined(walletProvider, methodName) {
|
|
|
2337
2427
|
});
|
|
2338
2428
|
}
|
|
2339
2429
|
|
|
2430
|
+
//#endregion
|
|
2431
|
+
//#region src/modules/swap/constants.ts
|
|
2432
|
+
const SWAP_SUPPORTED_CHAINS = [
|
|
2433
|
+
"BTC",
|
|
2434
|
+
"EVM",
|
|
2435
|
+
"SOL",
|
|
2436
|
+
"SUI",
|
|
2437
|
+
"TRON"
|
|
2438
|
+
];
|
|
2439
|
+
|
|
2440
|
+
//#endregion
|
|
2441
|
+
//#region src/modules/swap/executeSwapTransaction/executeSwapTransaction.ts
|
|
2442
|
+
/**
|
|
2443
|
+
* Executes a swap transaction
|
|
2444
|
+
*
|
|
2445
|
+
* @param params ExecuteSwapTransactionParams - The parameters for the swap transaction.
|
|
2446
|
+
* @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
|
|
2447
|
+
* @returns The transaction hash.
|
|
2448
|
+
* @instrumented
|
|
2449
|
+
*/
|
|
2450
|
+
const executeSwapTransaction = async ({ walletAccount, signingPayload, onStepChange }, client = require_InvalidParamError.getDefaultClient()) => {
|
|
2451
|
+
if (!SWAP_SUPPORTED_CHAINS.includes(walletAccount.chain)) throw new require_InvalidParamError.InvalidParamError(`Chain ${walletAccount.chain} is not supported for swap transactions`);
|
|
2452
|
+
const walletProvider = require_getVerifiedCredentialForWalletAccount.getWalletProviderFromWalletAccount({ walletAccount }, client);
|
|
2453
|
+
assertWalletProviderMethodDefined(walletProvider, "executeSwapTransaction");
|
|
2454
|
+
const requiredNetworkId = signingPayload.chainId;
|
|
2455
|
+
if (requiredNetworkId && walletProvider.switchActiveNetwork) {
|
|
2456
|
+
const { networkId: activeNetworkId } = await walletProvider.getActiveNetworkId();
|
|
2457
|
+
if (activeNetworkId !== requiredNetworkId) await walletProvider.switchActiveNetwork({ networkId: requiredNetworkId });
|
|
2458
|
+
}
|
|
2459
|
+
const { transactionHash } = await walletProvider.executeSwapTransaction({
|
|
2460
|
+
onStepChange,
|
|
2461
|
+
signingPayload,
|
|
2462
|
+
walletAccount
|
|
2463
|
+
});
|
|
2464
|
+
return { transactionHash };
|
|
2465
|
+
};
|
|
2466
|
+
|
|
2340
2467
|
//#endregion
|
|
2341
2468
|
//#region src/modules/checkout/submitCheckoutTransaction/submitCheckoutTransaction.ts
|
|
2342
2469
|
/**
|
|
@@ -2345,7 +2472,7 @@ function assertWalletProviderMethodDefined(walletProvider, methodName) {
|
|
|
2345
2472
|
* Orchestrates the full submission flow:
|
|
2346
2473
|
* 1. Calls prepareCheckoutTransaction to advance to signing state and lock the quote
|
|
2347
2474
|
* 2. Ensures the wallet is on the correct network for the transaction
|
|
2348
|
-
* 3. Delegates on-chain signing to the wallet provider's
|
|
2475
|
+
* 3. Delegates on-chain signing to the wallet provider's executeSwapTransaction method
|
|
2349
2476
|
* 4. Calls broadcastCheckoutTransaction with the resulting txHash
|
|
2350
2477
|
*
|
|
2351
2478
|
* @param params SubmitCheckoutTransactionParams - The transaction ID, wallet account, and optional step callback.
|
|
@@ -2356,14 +2483,7 @@ function assertWalletProviderMethodDefined(walletProvider, methodName) {
|
|
|
2356
2483
|
const submitCheckoutTransaction = async ({ onStepChange, transactionId, walletAccount }, client = require_InvalidParamError.getDefaultClient()) => {
|
|
2357
2484
|
const prepared = await prepareCheckoutTransaction({ transactionId }, client);
|
|
2358
2485
|
require_InvalidParamError.assertDefined(prepared.signingPayload, "No signing payload returned from prepare — quote may be missing transaction data");
|
|
2359
|
-
const
|
|
2360
|
-
assertWalletProviderMethodDefined(walletProvider, "executeCheckoutTransaction");
|
|
2361
|
-
const requiredNetworkId = prepared.signingPayload.chainId;
|
|
2362
|
-
if (requiredNetworkId && walletProvider.switchActiveNetwork) {
|
|
2363
|
-
const { networkId: activeNetworkId } = await walletProvider.getActiveNetworkId();
|
|
2364
|
-
if (activeNetworkId !== requiredNetworkId) await walletProvider.switchActiveNetwork({ networkId: requiredNetworkId });
|
|
2365
|
-
}
|
|
2366
|
-
const { transactionHash } = await walletProvider.executeCheckoutTransaction({
|
|
2486
|
+
const { transactionHash } = await executeSwapTransaction({
|
|
2367
2487
|
onStepChange,
|
|
2368
2488
|
signingPayload: prepared.signingPayload,
|
|
2369
2489
|
walletAccount
|
|
@@ -2727,30 +2847,30 @@ const getKrakenWhitelistedAddresses = async (client = require_InvalidParamError.
|
|
|
2727
2847
|
};
|
|
2728
2848
|
|
|
2729
2849
|
//#endregion
|
|
2730
|
-
//#region src/modules/
|
|
2850
|
+
//#region src/modules/initializeClient/waitForClientInitialized/waitForClientInitialized.ts
|
|
2731
2851
|
/**
|
|
2732
|
-
*
|
|
2852
|
+
* Allows waiting until all modules of the client have been properly initialized
|
|
2853
|
+
* and are ready for use.
|
|
2733
2854
|
*
|
|
2734
|
-
*
|
|
2735
|
-
* instrumented function call. When disabled, instrumented functions run
|
|
2736
|
-
* normally but emit no telemetry.
|
|
2855
|
+
* @returns a promise that resolves once the client is fully initialized.
|
|
2737
2856
|
* @instrumented
|
|
2738
2857
|
*/
|
|
2739
|
-
const
|
|
2740
|
-
require_InvalidParamError.getCore(client).
|
|
2858
|
+
const waitForClientInitialized = async (client = require_InvalidParamError.getDefaultClient()) => {
|
|
2859
|
+
await require_InvalidParamError.getCore(client).initTrack.waitForAll();
|
|
2741
2860
|
};
|
|
2742
2861
|
|
|
2743
2862
|
//#endregion
|
|
2744
|
-
//#region src/modules/
|
|
2863
|
+
//#region src/modules/instrumentation/setInstrumentationEnabled/setInstrumentationEnabled.ts
|
|
2745
2864
|
/**
|
|
2746
|
-
*
|
|
2747
|
-
* and are ready for use.
|
|
2865
|
+
* Enables or disables event collection for the client's instrumentation service.
|
|
2748
2866
|
*
|
|
2749
|
-
*
|
|
2867
|
+
* When enabled, events are forwarded to the configured transport on every
|
|
2868
|
+
* instrumented function call. When disabled, instrumented functions run
|
|
2869
|
+
* normally but emit no telemetry.
|
|
2750
2870
|
* @instrumented
|
|
2751
2871
|
*/
|
|
2752
|
-
const
|
|
2753
|
-
|
|
2872
|
+
const setInstrumentationEnabled = (enabled, client = require_InvalidParamError.getDefaultClient()) => {
|
|
2873
|
+
require_InvalidParamError.getCore(client).instrumentation.setEnabled(enabled);
|
|
2754
2874
|
};
|
|
2755
2875
|
|
|
2756
2876
|
//#endregion
|
|
@@ -4621,6 +4741,78 @@ const verifyOTP = async ({ otpVerification, verificationToken, requestedScopes }
|
|
|
4621
4741
|
return response;
|
|
4622
4742
|
};
|
|
4623
4743
|
|
|
4744
|
+
//#endregion
|
|
4745
|
+
//#region src/modules/swap/getSwapQuote/getSwapQuote.ts
|
|
4746
|
+
/**
|
|
4747
|
+
* Gets a swap quote
|
|
4748
|
+
*
|
|
4749
|
+
* @param params GetSwapQuoteParams - The parameters for the swap quote.
|
|
4750
|
+
* @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
|
|
4751
|
+
* @returns The swap quote details. Use the `signingPayload` field to get the transaction data for the wallet to sign.
|
|
4752
|
+
* @instrumented
|
|
4753
|
+
*/
|
|
4754
|
+
const getSwapQuote = async (params, client = require_InvalidParamError.getDefaultClient()) => {
|
|
4755
|
+
const core = require_InvalidParamError.getCore(client);
|
|
4756
|
+
const apiClient = require_InvalidParamError.createApiClient({}, client);
|
|
4757
|
+
if (!params.from.amount && !params.to.amount) throw new require_InvalidParamError.InvalidParamError("Either from.amount or to.amount is required");
|
|
4758
|
+
if (params.from.amount && params.to.amount) throw new require_InvalidParamError.InvalidParamError("Only one of from.amount or to.amount is allowed");
|
|
4759
|
+
return await apiClient.swapQuote({
|
|
4760
|
+
environmentId: core.environmentId,
|
|
4761
|
+
swapQuoteRequest: {
|
|
4762
|
+
from: {
|
|
4763
|
+
...params.from,
|
|
4764
|
+
chainId: params.from.networkId,
|
|
4765
|
+
chainName: params.from.chain
|
|
4766
|
+
},
|
|
4767
|
+
maxPriceImpact: params.maxPriceImpact,
|
|
4768
|
+
order: params.order,
|
|
4769
|
+
slippage: params.slippage,
|
|
4770
|
+
to: {
|
|
4771
|
+
...params.to,
|
|
4772
|
+
chainId: params.to.networkId,
|
|
4773
|
+
chainName: params.to.chain
|
|
4774
|
+
}
|
|
4775
|
+
}
|
|
4776
|
+
});
|
|
4777
|
+
};
|
|
4778
|
+
|
|
4779
|
+
//#endregion
|
|
4780
|
+
//#region src/modules/swap/getSwapStatus/getSwapStatus.ts
|
|
4781
|
+
/**
|
|
4782
|
+
* Gets the status of a swap
|
|
4783
|
+
*
|
|
4784
|
+
* @param params GetSwapStatusParams - The parameters for the swap status.
|
|
4785
|
+
* @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
|
|
4786
|
+
* @returns The swap status.
|
|
4787
|
+
* @instrumented
|
|
4788
|
+
*/
|
|
4789
|
+
const getSwapStatus = async (params, client = require_InvalidParamError.getDefaultClient()) => {
|
|
4790
|
+
const core = require_InvalidParamError.getCore(client);
|
|
4791
|
+
const apiClient = require_InvalidParamError.createApiClient({}, client);
|
|
4792
|
+
let from;
|
|
4793
|
+
if (params.from) from = {
|
|
4794
|
+
chainId: params.from.networkId,
|
|
4795
|
+
chainName: params.from.chain
|
|
4796
|
+
};
|
|
4797
|
+
let to;
|
|
4798
|
+
if (params.to) to = {
|
|
4799
|
+
chainId: params.to.networkId,
|
|
4800
|
+
chainName: params.to.chain
|
|
4801
|
+
};
|
|
4802
|
+
const response = await apiClient.swapStatus({
|
|
4803
|
+
environmentId: core.environmentId,
|
|
4804
|
+
swapStatusRequest: {
|
|
4805
|
+
from,
|
|
4806
|
+
to,
|
|
4807
|
+
txHash: params.txHash
|
|
4808
|
+
}
|
|
4809
|
+
});
|
|
4810
|
+
return {
|
|
4811
|
+
status: response.status,
|
|
4812
|
+
substatus: response.substatus
|
|
4813
|
+
};
|
|
4814
|
+
};
|
|
4815
|
+
|
|
4624
4816
|
//#endregion
|
|
4625
4817
|
//#region src/modules/user/deleteUser/deleteUser.ts
|
|
4626
4818
|
/**
|
|
@@ -5624,6 +5816,7 @@ exports.authenticateWithSocial = authenticateWithSocial;
|
|
|
5624
5816
|
exports.broadcastCheckoutTransaction = broadcastCheckoutTransaction;
|
|
5625
5817
|
exports.canConnectWithHardwareWallet = canConnectWithHardwareWallet;
|
|
5626
5818
|
exports.cancelCheckoutTransaction = cancelCheckoutTransaction;
|
|
5819
|
+
exports.checkStepUpAuth = checkStepUpAuth;
|
|
5627
5820
|
exports.completeDeviceRegistration = completeDeviceRegistration;
|
|
5628
5821
|
exports.completeSocialAuthentication = completeSocialAuthentication;
|
|
5629
5822
|
exports.connectAndVerifyWithWalletProvider = connectAndVerifyWithWalletProvider;
|
|
@@ -5640,6 +5833,7 @@ exports.deletePasskey = deletePasskey;
|
|
|
5640
5833
|
exports.deleteUser = deleteUser;
|
|
5641
5834
|
exports.detectDeviceRegistrationRedirect = detectDeviceRegistrationRedirect;
|
|
5642
5835
|
exports.detectOAuthRedirect = detectOAuthRedirect;
|
|
5836
|
+
exports.executeSwapTransaction = executeSwapTransaction;
|
|
5643
5837
|
exports.fetchProjectSettings = fetchProjectSettings;
|
|
5644
5838
|
exports.getActiveNetworkData = getActiveNetworkData;
|
|
5645
5839
|
exports.getActiveNetworkId = getActiveNetworkId;
|
|
@@ -5666,6 +5860,8 @@ exports.getOwnerWalletAccountForSmartWalletAccount = getOwnerWalletAccountForSma
|
|
|
5666
5860
|
exports.getPasskeys = getPasskeys;
|
|
5667
5861
|
exports.getPrimaryWalletAccount = getPrimaryWalletAccount;
|
|
5668
5862
|
exports.getRegisteredDevices = getRegisteredDevices;
|
|
5863
|
+
exports.getSwapQuote = getSwapQuote;
|
|
5864
|
+
exports.getSwapStatus = getSwapStatus;
|
|
5669
5865
|
exports.getTransactionHistory = getTransactionHistory;
|
|
5670
5866
|
exports.getUserSocialAccounts = getUserSocialAccounts;
|
|
5671
5867
|
exports.getWalletAccountAddressByType = getWalletAccountAddressByType;
|