@dynamic-labs-sdk/client 1.0.0 → 1.2.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-DQ1ABzoy.esm.js → InvalidParamError-BWWTxQ9d.esm.js} +4 -3
- package/dist/{InvalidParamError-DQ1ABzoy.esm.js.map → InvalidParamError-BWWTxQ9d.esm.js.map} +1 -1
- package/dist/{InvalidParamError-WOyVlLys.cjs → InvalidParamError-CPzPxL0l.cjs} +5 -4
- package/dist/{InvalidParamError-WOyVlLys.cjs.map → InvalidParamError-CPzPxL0l.cjs.map} +1 -1
- package/dist/{InvalidParamError-p9-9P-lf.native.esm.js → InvalidParamError-Dhv4EhOy.native.esm.js} +4 -3
- package/dist/{InvalidParamError-p9-9P-lf.native.esm.js.map → InvalidParamError-Dhv4EhOy.native.esm.js.map} +1 -1
- package/dist/{NotWaasWalletAccountError-CM_mmb18.cjs → NotWaasWalletAccountError-BcIbGm0s.cjs} +3 -3
- package/dist/{NotWaasWalletAccountError-CM_mmb18.cjs.map → NotWaasWalletAccountError-BcIbGm0s.cjs.map} +1 -1
- package/dist/{NotWaasWalletAccountError-PrroboxR.esm.js → NotWaasWalletAccountError-D1EuiYyR.esm.js} +3 -3
- package/dist/{NotWaasWalletAccountError-PrroboxR.esm.js.map → NotWaasWalletAccountError-D1EuiYyR.esm.js.map} +1 -1
- package/dist/{NotWaasWalletAccountError-DXS6Quo_.native.esm.js → NotWaasWalletAccountError-D_mLDrYD.native.esm.js} +3 -3
- package/dist/{NotWaasWalletAccountError-DXS6Quo_.native.esm.js.map → NotWaasWalletAccountError-D_mLDrYD.native.esm.js.map} +1 -1
- package/dist/core.cjs +5 -5
- package/dist/core.esm.js +7 -7
- package/dist/core.esm.js.map +1 -1
- package/dist/core.native.esm.js +5 -5
- package/dist/{getNetworkProviderFromNetworkId-D9h1iRX7.esm.js → getNetworkProviderFromNetworkId-C9QzgcLs.esm.js} +7 -7
- package/dist/getNetworkProviderFromNetworkId-C9QzgcLs.esm.js.map +1 -0
- package/dist/{getNetworkProviderFromNetworkId-CLf4WTzA.cjs → getNetworkProviderFromNetworkId-D26TNjm4.cjs} +3 -3
- package/dist/{getNetworkProviderFromNetworkId-CLf4WTzA.cjs.map → getNetworkProviderFromNetworkId-D26TNjm4.cjs.map} +1 -1
- package/dist/{getNetworkProviderFromNetworkId-CKxfzZDr.native.esm.js → getNetworkProviderFromNetworkId-VkHaRqMa.native.esm.js} +3 -3
- package/dist/{getNetworkProviderFromNetworkId-CKxfzZDr.native.esm.js.map → getNetworkProviderFromNetworkId-VkHaRqMa.native.esm.js.map} +1 -1
- package/dist/{getSignedSessionId-Amzjohh4.cjs → getSignedSessionId-D52QC0hh.cjs} +3 -3
- package/dist/{getSignedSessionId-Amzjohh4.cjs.map → getSignedSessionId-D52QC0hh.cjs.map} +1 -1
- package/dist/{getSignedSessionId-C4COaxNK.esm.js → getSignedSessionId-DcJl2sy8.esm.js} +3 -3
- package/dist/{getSignedSessionId-C4COaxNK.esm.js.map → getSignedSessionId-DcJl2sy8.esm.js.map} +1 -1
- package/dist/{getSignedSessionId-BfoAvhGi.native.esm.js → getSignedSessionId-L0T26uTy.native.esm.js} +3 -3
- package/dist/{getSignedSessionId-BfoAvhGi.native.esm.js.map → getSignedSessionId-L0T26uTy.native.esm.js.map} +1 -1
- package/dist/{getVerifiedCredentialForWalletAccount-QkdDRxzf.cjs → getVerifiedCredentialForWalletAccount-C94BZhqL.cjs} +3 -3
- package/dist/{getVerifiedCredentialForWalletAccount-QkdDRxzf.cjs.map → getVerifiedCredentialForWalletAccount-C94BZhqL.cjs.map} +1 -1
- package/dist/{getVerifiedCredentialForWalletAccount-DUzAvFYd.native.esm.js → getVerifiedCredentialForWalletAccount-CMEe9e1b.native.esm.js} +2 -2
- package/dist/{getVerifiedCredentialForWalletAccount-DUzAvFYd.native.esm.js.map → getVerifiedCredentialForWalletAccount-CMEe9e1b.native.esm.js.map} +1 -1
- package/dist/{getVerifiedCredentialForWalletAccount-CFLGCivi.esm.js → getVerifiedCredentialForWalletAccount-Cm2e3Boz.esm.js} +2 -2
- package/dist/{getVerifiedCredentialForWalletAccount-CFLGCivi.esm.js.map → getVerifiedCredentialForWalletAccount-Cm2e3Boz.esm.js.map} +1 -1
- package/dist/index.cjs +40 -11
- package/dist/index.cjs.map +1 -1
- package/dist/index.esm.js +43 -14
- package/dist/index.esm.js.map +1 -1
- package/dist/index.native.esm.js +40 -11
- package/dist/index.native.esm.js.map +1 -1
- package/dist/{isMfaRequiredForAction-C7PeETG7.native.esm.js → isMfaRequiredForAction-B6kjcIA2.native.esm.js} +2 -2
- package/dist/{isMfaRequiredForAction-C7PeETG7.native.esm.js.map → isMfaRequiredForAction-B6kjcIA2.native.esm.js.map} +1 -1
- package/dist/{isMfaRequiredForAction-zlHmSSKB.cjs → isMfaRequiredForAction-kxGzZLB_.cjs} +2 -2
- package/dist/{isMfaRequiredForAction-zlHmSSKB.cjs.map → isMfaRequiredForAction-kxGzZLB_.cjs.map} +1 -1
- package/dist/{isMfaRequiredForAction-DLo5DjM6.esm.js → isMfaRequiredForAction-vbGFqLFc.esm.js} +2 -2
- package/dist/{isMfaRequiredForAction-DLo5DjM6.esm.js.map → isMfaRequiredForAction-vbGFqLFc.esm.js.map} +1 -1
- package/dist/modules/checkout/getCheckoutTransactionQuote/getCheckoutTransactionQuote.d.ts +9 -1
- package/dist/modules/checkout/getCheckoutTransactionQuote/getCheckoutTransactionQuote.d.ts.map +1 -1
- package/dist/modules/swap/executeSwapTransaction/executeSwapTransaction.d.ts.map +1 -1
- package/dist/modules/swap/utils/ensureCorrectActiveNetwork/ensureCorrectActiveNetwork.d.ts +15 -0
- package/dist/modules/swap/utils/ensureCorrectActiveNetwork/ensureCorrectActiveNetwork.d.ts.map +1 -0
- package/dist/modules/swap/utils/ensureCorrectActiveNetwork/index.d.ts +2 -0
- package/dist/modules/swap/utils/ensureCorrectActiveNetwork/index.d.ts.map +1 -0
- package/dist/tsconfig.lib.tsbuildinfo +1 -1
- package/dist/waas.cjs +4 -4
- package/dist/waas.esm.js +3 -3
- package/dist/waas.native.esm.js +3 -3
- package/dist/waasCore.cjs +4 -4
- package/dist/waasCore.esm.js +3 -3
- package/dist/waasCore.native.esm.js +3 -3
- package/package.json +5 -4
- package/dist/getNetworkProviderFromNetworkId-D9h1iRX7.esm.js.map +0 -1
package/dist/index.native.esm.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { A as extractSessionId, B as name, C as isCookieEnabled, D as instrumentFunction, E as __getElevatedAccessToken_wrapped, F as getDefaultClient, I as setDefaultClient, O as DEFAULT_PII_FIELDS, P as NONCE_POOL_SIZE, R as BaseError, T as ValueMustBeDefinedError, V as version, _ as MfaRateLimitedError, a as DYNAMIC_ICONIC_SPRITE_URL, b as InvalidExternalAuthError, c as CHAINS_INFO_MAP, d as UnauthorizedError, g as SandboxMaximumThresholdReachedError, h as getNonce, j as randomString, k as getUserAgent, l as fetchAndStoreNonces, o as SDK_API_CORE_VERSION, s as getChainFromVerifiedCredentialChain, t as InvalidParamError, u as createApiClient, v as MfaInvalidOtpError, w as assertDefined, x as APIError, y as LinkCredentialError, z as getCore } from "./InvalidParamError-
|
|
2
|
-
import { A as INITIALIZE_STORAGE_SYNC_TRACKER_KEY, C as createLogger, D as createDeferredPromise, E as CannotTrackError, F as __logoutWithReason_wrapped, G as isEqualShallow, H as isSignedIn, I as generateSessionKeys, L as fetchProjectSettings, M as REFRESH_USER_STATE_FROM_VALID_TOKEN_TRACKER_KEY, N as isServerSideRendering, O as FETCH_PROJECT_SETTINGS_TRACKER_KEY, P as getBuffer, R as createStorageKeySchema, U as retryOnFail, V as createLocalStorageAdapter, W as subscribeWithSelector, _ as WalletAlreadyLinkedToAnotherUserError, a as updateWalletProviderKeysForVerifiedCredentials, b as createRealtimeService, c as createSignInMessageStatement, d as createVisit, f as hasExtension, g as MethodNotImplementedError, h as isCaptchaRequired, i as getNetworksData, j as REFRESH_USER_STATE_FROM_COOKIE_TRACKER_KEY, k as GENERATE_SESSION_KEYS_TRACKER_KEY, l as formatSignInMessage, m as consumeCaptchaToken, o as verifyMessageSignatureOwnership, p as __setCaptchaToken_wrapped, s as removeUnverifiedWalletAccount, t as getNetworkProviderFromNetworkId, u as setUnverifiedWalletAccounts, v as NoNetworkProvidersError, w as createCrossTabBroadcast, x as createKeychainService, y as getKeychainIndexedDBName, z as createStorage } from "./getNetworkProviderFromNetworkId-
|
|
3
|
-
import { A as onceEvent, C as formatWalletAccountId, D as emitEvent, O as offEvent, T as splitWalletProviderKey, a as parseElevatedAccessToken, b as getWalletAccounts, d as isUserMissingMfaAuth, f as checkAndRaiseWalletAccountsChangedEvent, h as getWalletProviderFromWalletAccount, i as upsertElevatedAccessToken, k as onEvent, n as getWalletProviderByKey, o as restoreUserSharesForAllWalletAccounts, p as emitWalletAccountsChangedEvent, r as updateAuthFromVerifyResponse, t as getVerifiedCredentialForWalletAccount, u as getWalletProviders, w as normalizeAddress, y as NoWalletProviderFoundError } from "./getVerifiedCredentialForWalletAccount-
|
|
4
|
-
import { n as __refreshAuth_wrapped, t as NotWaasWalletAccountError } from "./NotWaasWalletAccountError-
|
|
5
|
-
import { n as getMfaMethods, r as __consumeMfaToken_wrapped, t as isMfaRequiredForAction } from "./isMfaRequiredForAction-
|
|
1
|
+
import { A as extractSessionId, B as name, C as isCookieEnabled, D as instrumentFunction, E as __getElevatedAccessToken_wrapped, F as getDefaultClient, I as setDefaultClient, O as DEFAULT_PII_FIELDS, P as NONCE_POOL_SIZE, R as BaseError, T as ValueMustBeDefinedError, V as version, _ as MfaRateLimitedError, a as DYNAMIC_ICONIC_SPRITE_URL, b as InvalidExternalAuthError, c as CHAINS_INFO_MAP, d as UnauthorizedError, g as SandboxMaximumThresholdReachedError, h as getNonce, j as randomString, k as getUserAgent, l as fetchAndStoreNonces, o as SDK_API_CORE_VERSION, s as getChainFromVerifiedCredentialChain, t as InvalidParamError, u as createApiClient, v as MfaInvalidOtpError, w as assertDefined, x as APIError, y as LinkCredentialError, z as getCore } from "./InvalidParamError-Dhv4EhOy.native.esm.js";
|
|
2
|
+
import { A as INITIALIZE_STORAGE_SYNC_TRACKER_KEY, C as createLogger, D as createDeferredPromise, E as CannotTrackError, F as __logoutWithReason_wrapped, G as isEqualShallow, H as isSignedIn, I as generateSessionKeys, L as fetchProjectSettings, M as REFRESH_USER_STATE_FROM_VALID_TOKEN_TRACKER_KEY, N as isServerSideRendering, O as FETCH_PROJECT_SETTINGS_TRACKER_KEY, P as getBuffer, R as createStorageKeySchema, U as retryOnFail, V as createLocalStorageAdapter, W as subscribeWithSelector, _ as WalletAlreadyLinkedToAnotherUserError, a as updateWalletProviderKeysForVerifiedCredentials, b as createRealtimeService, c as createSignInMessageStatement, d as createVisit, f as hasExtension, g as MethodNotImplementedError, h as isCaptchaRequired, i as getNetworksData, j as REFRESH_USER_STATE_FROM_COOKIE_TRACKER_KEY, k as GENERATE_SESSION_KEYS_TRACKER_KEY, l as formatSignInMessage, m as consumeCaptchaToken, o as verifyMessageSignatureOwnership, p as __setCaptchaToken_wrapped, s as removeUnverifiedWalletAccount, t as getNetworkProviderFromNetworkId, u as setUnverifiedWalletAccounts, v as NoNetworkProvidersError, w as createCrossTabBroadcast, x as createKeychainService, y as getKeychainIndexedDBName, z as createStorage } from "./getNetworkProviderFromNetworkId-VkHaRqMa.native.esm.js";
|
|
3
|
+
import { A as onceEvent, C as formatWalletAccountId, D as emitEvent, O as offEvent, T as splitWalletProviderKey, a as parseElevatedAccessToken, b as getWalletAccounts, d as isUserMissingMfaAuth, f as checkAndRaiseWalletAccountsChangedEvent, h as getWalletProviderFromWalletAccount, i as upsertElevatedAccessToken, k as onEvent, n as getWalletProviderByKey, o as restoreUserSharesForAllWalletAccounts, p as emitWalletAccountsChangedEvent, r as updateAuthFromVerifyResponse, t as getVerifiedCredentialForWalletAccount, u as getWalletProviders, w as normalizeAddress, y as NoWalletProviderFoundError } from "./getVerifiedCredentialForWalletAccount-CMEe9e1b.native.esm.js";
|
|
4
|
+
import { n as __refreshAuth_wrapped, t as NotWaasWalletAccountError } from "./NotWaasWalletAccountError-D_mLDrYD.native.esm.js";
|
|
5
|
+
import { n as getMfaMethods, r as __consumeMfaToken_wrapped, t as isMfaRequiredForAction } from "./isMfaRequiredForAction-B6kjcIA2.native.esm.js";
|
|
6
6
|
import { assertPackageVersion } from "@dynamic-labs-sdk/assert-package-version";
|
|
7
7
|
import { AuthModeEnum, ExchangeKeyEnum, JwtVerifiedCredentialFormatEnum, MFAAction, MfaBackupCodeAcknowledgement, ProviderEnum, TokenScope, WaasBackupOptionsEnum, WalletProviderEnum } from "@dynamic-labs/sdk-api-core";
|
|
8
8
|
import * as z from "zod/mini";
|
|
@@ -2639,11 +2639,12 @@ const getCheckoutTransaction = async ({ transactionId }, client = getDefaultClie
|
|
|
2639
2639
|
* @returns The updated checkout transaction with quote data
|
|
2640
2640
|
* @not-instrumented
|
|
2641
2641
|
*/
|
|
2642
|
-
const getCheckoutTransactionQuote = async ({ fromTokenAddress, slippage, transactionId }, client = getDefaultClient()) => {
|
|
2642
|
+
const getCheckoutTransactionQuote = async ({ fromChainId, fromTokenAddress, slippage, transactionId }, client = getDefaultClient()) => {
|
|
2643
2643
|
const { apiClient, environmentId, sessionToken } = await createCheckoutApiClient({ transactionId }, client);
|
|
2644
2644
|
return apiClient.quoteCheckoutTransaction({
|
|
2645
2645
|
environmentId,
|
|
2646
2646
|
quoteRequest: {
|
|
2647
|
+
fromChainId,
|
|
2647
2648
|
fromTokenAddress,
|
|
2648
2649
|
slippage
|
|
2649
2650
|
},
|
|
@@ -2724,6 +2725,35 @@ const SWAP_SUPPORTED_CHAINS = [
|
|
|
2724
2725
|
"TRON"
|
|
2725
2726
|
];
|
|
2726
2727
|
|
|
2728
|
+
//#endregion
|
|
2729
|
+
//#region src/modules/swap/utils/ensureCorrectActiveNetwork/ensureCorrectActiveNetwork.ts
|
|
2730
|
+
/**
|
|
2731
|
+
* Ensures the wallet provider is on the correct active network if possible.
|
|
2732
|
+
* If the wallet provider is not on the correct active network, it will try to switch to the correct active network.
|
|
2733
|
+
* It's not a blocker, so it will just log the error and skip the step if it fails.
|
|
2734
|
+
*
|
|
2735
|
+
* @not-instrumented
|
|
2736
|
+
*/
|
|
2737
|
+
const ensureCorrectActiveNetwork = async ({ requiredNetworkId, walletProvider }, client) => {
|
|
2738
|
+
const { logger } = getCore(client);
|
|
2739
|
+
if (!requiredNetworkId || !walletProvider.switchActiveNetwork) return;
|
|
2740
|
+
logger.debug("[ensureCorrectActiveNetwork] Required network id", requiredNetworkId);
|
|
2741
|
+
try {
|
|
2742
|
+
const { networkId: activeNetworkId } = await walletProvider.getActiveNetworkId();
|
|
2743
|
+
logger.debug("[ensureCorrectActiveNetwork] Check if should switch network", {
|
|
2744
|
+
activeNetworkId,
|
|
2745
|
+
requiredNetworkId
|
|
2746
|
+
});
|
|
2747
|
+
if (!activeNetworkId || activeNetworkId === requiredNetworkId) {
|
|
2748
|
+
logger.debug("[ensureCorrectActiveNetwork] No active network id found or active network id is the same as the required network id - skipping this step");
|
|
2749
|
+
return;
|
|
2750
|
+
}
|
|
2751
|
+
await walletProvider.switchActiveNetwork({ networkId: requiredNetworkId });
|
|
2752
|
+
} catch (error) {
|
|
2753
|
+
logger.debug("[ensureCorrectActiveNetwork] Error getting active network id or switching network - skipping this step", error);
|
|
2754
|
+
}
|
|
2755
|
+
};
|
|
2756
|
+
|
|
2727
2757
|
//#endregion
|
|
2728
2758
|
//#region src/modules/swap/executeSwapTransaction/executeSwapTransaction.ts
|
|
2729
2759
|
/**
|
|
@@ -2738,11 +2768,10 @@ const executeSwapTransaction = async ({ walletAccount, signingPayload, onStepCha
|
|
|
2738
2768
|
if (!SWAP_SUPPORTED_CHAINS.includes(walletAccount.chain)) throw new InvalidParamError(`Chain ${walletAccount.chain} is not supported for swap transactions`);
|
|
2739
2769
|
const walletProvider = getWalletProviderFromWalletAccount({ walletAccount }, client);
|
|
2740
2770
|
assertWalletProviderMethodDefined(walletProvider, "executeSwapTransaction");
|
|
2741
|
-
|
|
2742
|
-
|
|
2743
|
-
|
|
2744
|
-
|
|
2745
|
-
}
|
|
2771
|
+
await ensureCorrectActiveNetwork({
|
|
2772
|
+
requiredNetworkId: signingPayload.chainId,
|
|
2773
|
+
walletProvider
|
|
2774
|
+
}, client);
|
|
2746
2775
|
const { transactionHash } = await walletProvider.executeSwapTransaction({
|
|
2747
2776
|
onStepChange,
|
|
2748
2777
|
signingPayload,
|