@dynamic-labs/sdk-react-core 4.18.5 → 4.18.6
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/CHANGELOG.md +14 -0
- package/package.cjs +2 -2
- package/package.js +2 -2
- package/package.json +12 -12
- package/src/index.cjs +2 -1
- package/src/index.js +2 -1
- package/src/lib/context/DynamicContext/DynamicContext.cjs +7 -0
- package/src/lib/context/DynamicContext/DynamicContext.js +8 -1
- package/src/lib/context/DynamicContext/hooks/useHandleLogout/useHandleLogout.cjs +1 -0
- package/src/lib/context/DynamicContext/hooks/useHandleLogout/useHandleLogout.js +2 -1
- package/src/lib/context/OnrampContext/OnrampContext.cjs +30 -24
- package/src/lib/context/OnrampContext/OnrampContext.d.ts +1 -1
- package/src/lib/context/OnrampContext/OnrampContext.js +30 -24
- package/src/lib/data/api/embeddedWallets/embeddedWallets.cjs +8 -0
- package/src/lib/data/api/embeddedWallets/embeddedWallets.js +9 -1
- package/src/lib/locale/en/translation.cjs +1 -1
- package/src/lib/locale/en/translation.js +1 -1
- package/src/lib/store/state/user/user.cjs +0 -7
- package/src/lib/store/state/user/user.js +0 -7
- package/src/lib/styles/index.shadow.cjs +1 -1
- package/src/lib/styles/index.shadow.js +1 -1
- package/src/lib/utils/functions/getOauthLoginUrl/getOauthLoginUrl.cjs +3 -0
- package/src/lib/utils/functions/getOauthLoginUrl/getOauthLoginUrl.js +3 -0
- package/src/lib/utils/hooks/useEmbeddedWalletSessionKeys/useEmbeddedWalletSessionKeys.cjs +30 -3
- package/src/lib/utils/hooks/useEmbeddedWalletSessionKeys/useEmbeddedWalletSessionKeys.js +31 -4
- package/src/lib/utils/hooks/useGlobalLoading/useGlobalLoading.cjs +7 -0
- package/src/lib/utils/hooks/useGlobalLoading/useGlobalLoading.js +7 -0
- package/src/lib/utils/hooks/useSocialAuth/useSocialAuth.cjs +8 -0
- package/src/lib/utils/hooks/useSocialAuth/useSocialAuth.js +9 -1
- package/src/lib/views/EmbeddedReveal/EmbeddedRevealView/EmbeddedRevealView.cjs +98 -14
- package/src/lib/views/EmbeddedReveal/EmbeddedRevealView/EmbeddedRevealView.js +98 -14
- package/src/lib/views/EmbeddedReveal/utils/waasExport/index.d.ts +1 -0
- package/src/lib/views/EmbeddedReveal/utils/waasExport/waasExport.cjs +53 -0
- package/src/lib/views/EmbeddedReveal/utils/waasExport/waasExport.d.ts +11 -0
- package/src/lib/views/EmbeddedReveal/utils/waasExport/waasExport.js +48 -0
- package/src/lib/widgets/DynamicWidget/views/AccountAndSecuritySettingsView/AccountAndSecuritySettingsView.cjs +3 -2
- package/src/lib/widgets/DynamicWidget/views/AccountAndSecuritySettingsView/AccountAndSecuritySettingsView.js +3 -2
- package/src/lib/widgets/DynamicWidget/views/SettingsView/SettingsView.cjs +5 -2
- package/src/lib/widgets/DynamicWidget/views/SettingsView/SettingsView.js +5 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,18 @@
|
|
|
1
1
|
|
|
2
|
+
### [4.18.6](https://github.com/dynamic-labs/dynamic-auth/compare/v4.18.5...v4.18.6) (2025-05-16)
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
### Features
|
|
6
|
+
|
|
7
|
+
* remove alert on wallet icon fail errors ([#8719](https://github.com/dynamic-labs/dynamic-auth/issues/8719)) ([3257160](https://github.com/dynamic-labs/dynamic-auth/commit/3257160ec2ce422e76ccf5e5adc10f92e73c3c61))
|
|
8
|
+
* evm export waas ([#8669](https://github.com/dynamic-labs/dynamic-auth/issues/8669)) ([c8f6199](https://github.com/dynamic-labs/dynamic-auth/commit/c8f6199914c5c0791996e0dfad1ac5642c327bea))
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
* onramps hook ([#8700](https://github.com/dynamic-labs/dynamic-auth/issues/8700)) ([33d0fb5](https://github.com/dynamic-labs/dynamic-auth/commit/33d0fb5e83db627aeea5ce2f07871cd4029c118a))
|
|
14
|
+
* use mainnet as default SVM cluster ([#8721](https://github.com/dynamic-labs/dynamic-auth/issues/8721)) ([5408f9a](https://github.com/dynamic-labs/dynamic-auth/commit/5408f9afbd2b4c6dfaf041c661cc3fb4802b6c05))
|
|
15
|
+
|
|
2
16
|
### [4.18.5](https://github.com/dynamic-labs/dynamic-auth/compare/v4.18.4...v4.18.5) (2025-05-15)
|
|
3
17
|
|
|
4
18
|
|
package/package.cjs
CHANGED
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
|
|
4
4
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
5
|
|
|
6
|
-
var version = "4.18.
|
|
6
|
+
var version = "4.18.6";
|
|
7
7
|
var dependencies = {
|
|
8
|
-
"@dynamic-labs/sdk-api-core": "0.0.
|
|
8
|
+
"@dynamic-labs/sdk-api-core": "0.0.669",
|
|
9
9
|
"@hcaptcha/react-hcaptcha": "1.4.4",
|
|
10
10
|
"@thumbmarkjs/thumbmarkjs": "0.16.0",
|
|
11
11
|
"country-list": "2.3.0",
|
package/package.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use client'
|
|
2
|
-
var version = "4.18.
|
|
2
|
+
var version = "4.18.6";
|
|
3
3
|
var dependencies = {
|
|
4
|
-
"@dynamic-labs/sdk-api-core": "0.0.
|
|
4
|
+
"@dynamic-labs/sdk-api-core": "0.0.669",
|
|
5
5
|
"@hcaptcha/react-hcaptcha": "1.4.4",
|
|
6
6
|
"@thumbmarkjs/thumbmarkjs": "0.16.0",
|
|
7
7
|
"country-list": "2.3.0",
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dynamic-labs/sdk-react-core",
|
|
3
|
-
"version": "4.18.
|
|
3
|
+
"version": "4.18.6",
|
|
4
4
|
"dependencies": {
|
|
5
|
-
"@dynamic-labs/sdk-api-core": "0.0.
|
|
5
|
+
"@dynamic-labs/sdk-api-core": "0.0.669",
|
|
6
6
|
"@hcaptcha/react-hcaptcha": "1.4.4",
|
|
7
7
|
"@thumbmarkjs/thumbmarkjs": "0.16.0",
|
|
8
8
|
"country-list": "2.3.0",
|
|
@@ -14,16 +14,16 @@
|
|
|
14
14
|
"yup": "0.32.11",
|
|
15
15
|
"react-international-phone": "4.2.5",
|
|
16
16
|
"bs58": "5.0.0",
|
|
17
|
-
"@dynamic-labs/assert-package-version": "4.18.
|
|
18
|
-
"@dynamic-labs/iconic": "4.18.
|
|
19
|
-
"@dynamic-labs/logger": "4.18.
|
|
20
|
-
"@dynamic-labs/multi-wallet": "4.18.
|
|
21
|
-
"@dynamic-labs/rpc-providers": "4.18.
|
|
22
|
-
"@dynamic-labs/store": "4.18.
|
|
23
|
-
"@dynamic-labs/types": "4.18.
|
|
24
|
-
"@dynamic-labs/utils": "4.18.
|
|
25
|
-
"@dynamic-labs/wallet-book": "4.18.
|
|
26
|
-
"@dynamic-labs/wallet-connector-core": "4.18.
|
|
17
|
+
"@dynamic-labs/assert-package-version": "4.18.6",
|
|
18
|
+
"@dynamic-labs/iconic": "4.18.6",
|
|
19
|
+
"@dynamic-labs/logger": "4.18.6",
|
|
20
|
+
"@dynamic-labs/multi-wallet": "4.18.6",
|
|
21
|
+
"@dynamic-labs/rpc-providers": "4.18.6",
|
|
22
|
+
"@dynamic-labs/store": "4.18.6",
|
|
23
|
+
"@dynamic-labs/types": "4.18.6",
|
|
24
|
+
"@dynamic-labs/utils": "4.18.6",
|
|
25
|
+
"@dynamic-labs/wallet-book": "4.18.6",
|
|
26
|
+
"@dynamic-labs/wallet-connector-core": "4.18.6",
|
|
27
27
|
"eventemitter3": "5.0.1"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
package/src/index.cjs
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
5
|
|
|
6
6
|
var assertPackageVersion = require('@dynamic-labs/assert-package-version');
|
|
7
|
+
var utils = require('@dynamic-labs/utils');
|
|
7
8
|
var _package = require('../package.cjs');
|
|
8
9
|
require('./lib/shared/utils/functions/getInitialUrl/getInitialUrl.cjs');
|
|
9
10
|
var version = require('./version.cjs');
|
|
@@ -31,7 +32,6 @@ var getChainIcon = require('./lib/shared/utils/functions/chain/getChainIcon.cjs'
|
|
|
31
32
|
var getChainDisplayName = require('./lib/shared/utils/functions/chain/getChainDisplayName.cjs');
|
|
32
33
|
var createWallet = require('./lib/shared/utils/functions/wallet/createWallet.cjs');
|
|
33
34
|
var index = require('./lib/shared/utils/functions/getValueByKey/index.cjs');
|
|
34
|
-
require('@dynamic-labs/utils');
|
|
35
35
|
require('./lib/utils/constants/colors.cjs');
|
|
36
36
|
require('./lib/utils/constants/values.cjs');
|
|
37
37
|
require('@dynamic-labs/wallet-connector-core');
|
|
@@ -186,6 +186,7 @@ var useSwitchNetwork = require('./lib/utils/hooks/useSwitchNetwork/useSwitchNetw
|
|
|
186
186
|
var ReinitializeContextProvider = require('./lib/context/ReinitializeContext/ReinitializeContextProvider.cjs');
|
|
187
187
|
|
|
188
188
|
assertPackageVersion.assertPackageVersion('@dynamic-labs/sdk-react-core', _package.version);
|
|
189
|
+
utils.tracing.logEvent('sdk-react-core.initialization', 'script-loaded');
|
|
189
190
|
|
|
190
191
|
exports.VERSION = version.VERSION;
|
|
191
192
|
exports.getWallets = data.getWallets;
|
package/src/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
'use client'
|
|
2
2
|
import { assertPackageVersion } from '@dynamic-labs/assert-package-version';
|
|
3
|
+
import { tracing } from '@dynamic-labs/utils';
|
|
3
4
|
import { version } from '../package.js';
|
|
4
5
|
import './lib/shared/utils/functions/getInitialUrl/getInitialUrl.js';
|
|
5
6
|
export { VERSION } from './version.js';
|
|
@@ -27,7 +28,6 @@ export { getChainIcon } from './lib/shared/utils/functions/chain/getChainIcon.js
|
|
|
27
28
|
export { getChainDisplayName } from './lib/shared/utils/functions/chain/getChainDisplayName.js';
|
|
28
29
|
export { createWallet } from './lib/shared/utils/functions/wallet/createWallet.js';
|
|
29
30
|
export { getValueByKey } from './lib/shared/utils/functions/getValueByKey/index.js';
|
|
30
|
-
import '@dynamic-labs/utils';
|
|
31
31
|
import './lib/utils/constants/colors.js';
|
|
32
32
|
import './lib/utils/constants/values.js';
|
|
33
33
|
import '@dynamic-labs/wallet-connector-core';
|
|
@@ -182,3 +182,4 @@ export { useSwitchNetwork } from './lib/utils/hooks/useSwitchNetwork/useSwitchNe
|
|
|
182
182
|
export { useReinitialize } from './lib/context/ReinitializeContext/ReinitializeContextProvider.js';
|
|
183
183
|
|
|
184
184
|
assertPackageVersion('@dynamic-labs/sdk-react-core', version);
|
|
185
|
+
tracing.logEvent('sdk-react-core.initialization', 'script-loaded');
|
|
@@ -212,6 +212,12 @@ const InnerDynamicContextProvider = (props) => {
|
|
|
212
212
|
const [showBridgeWidget, setShowBridgeWidget] = React.useState(false);
|
|
213
213
|
const [isSingleWalletAccount, setIsSingleWalletAccount] = React.useState(false);
|
|
214
214
|
const { user: user$1, userWithMissingInfo } = user.useUser();
|
|
215
|
+
if (user$1) {
|
|
216
|
+
logger.Logger.globalMetaData.set('user', user$1);
|
|
217
|
+
}
|
|
218
|
+
else {
|
|
219
|
+
logger.Logger.globalMetaData.set('user', undefined);
|
|
220
|
+
}
|
|
215
221
|
// Calculates and stores a device fingerprint
|
|
216
222
|
useDeviceFingerprint.useDeviceFingerprint();
|
|
217
223
|
const isAuthenticated = Boolean(user$1);
|
|
@@ -334,6 +340,7 @@ const InnerDynamicContextProvider = (props) => {
|
|
|
334
340
|
connectors: walletConnectors,
|
|
335
341
|
});
|
|
336
342
|
const removeSessionStorageSessionKeys = () => {
|
|
343
|
+
utils.tracing.logEvent('session-key', 'removeSessionStorageSessionKeys');
|
|
337
344
|
utils.StorageService.removeItem(localStorage.SECURE_ENCLAVE_WALLET_SESSION_KEYS, localStorage.SECURE_ENCLAVE_WALLET_SESSION_KEYS_STORAGE_OPTIONS);
|
|
338
345
|
walletConnectors.forEach((connector) => {
|
|
339
346
|
if (walletConnectorCore.isSessionKeyCompatibleWalletConnector(connector) &&
|
|
@@ -5,7 +5,7 @@ import { createContext, useEffect, useState, useMemo, useCallback } from 'react'
|
|
|
5
5
|
import { I18nextProvider } from 'react-i18next';
|
|
6
6
|
import { getIconicSpriteUrl } from '@dynamic-labs/iconic';
|
|
7
7
|
import { Logger } from '@dynamic-labs/logger';
|
|
8
|
-
import { MissingEnvironmentIdError, getEnvVarWithFallback, StorageService } from '@dynamic-labs/utils';
|
|
8
|
+
import { MissingEnvironmentIdError, getEnvVarWithFallback, StorageService, tracing } from '@dynamic-labs/utils';
|
|
9
9
|
import { useWalletBookCdn, getWalletBookCdnUrl, WalletBookContextProvider } from '@dynamic-labs/wallet-book';
|
|
10
10
|
import { setChainInfoOverrides, logger as logger$1, isSessionKeyCompatibleWalletConnector } from '@dynamic-labs/wallet-connector-core';
|
|
11
11
|
import { VERSION } from '../../../version.js';
|
|
@@ -208,6 +208,12 @@ const InnerDynamicContextProvider = (props) => {
|
|
|
208
208
|
const [showBridgeWidget, setShowBridgeWidget] = useState(false);
|
|
209
209
|
const [isSingleWalletAccount, setIsSingleWalletAccount] = useState(false);
|
|
210
210
|
const { user, userWithMissingInfo } = useUser();
|
|
211
|
+
if (user) {
|
|
212
|
+
Logger.globalMetaData.set('user', user);
|
|
213
|
+
}
|
|
214
|
+
else {
|
|
215
|
+
Logger.globalMetaData.set('user', undefined);
|
|
216
|
+
}
|
|
211
217
|
// Calculates and stores a device fingerprint
|
|
212
218
|
useDeviceFingerprint();
|
|
213
219
|
const isAuthenticated = Boolean(user);
|
|
@@ -330,6 +336,7 @@ const InnerDynamicContextProvider = (props) => {
|
|
|
330
336
|
connectors: walletConnectors,
|
|
331
337
|
});
|
|
332
338
|
const removeSessionStorageSessionKeys = () => {
|
|
339
|
+
tracing.logEvent('session-key', 'removeSessionStorageSessionKeys');
|
|
333
340
|
StorageService.removeItem(SECURE_ENCLAVE_WALLET_SESSION_KEYS, SECURE_ENCLAVE_WALLET_SESSION_KEYS_STORAGE_OPTIONS);
|
|
334
341
|
walletConnectors.forEach((connector) => {
|
|
335
342
|
if (isSessionKeyCompatibleWalletConnector(connector) &&
|
|
@@ -105,6 +105,7 @@ const useHandleLogout = (params) => {
|
|
|
105
105
|
logger.logger.logVerboseTroubleshootingMessage('useHandleLogout called', {
|
|
106
106
|
params: paramsRef.current,
|
|
107
107
|
});
|
|
108
|
+
utils.tracing.logEvent('logout', 'useHandleLogout called');
|
|
108
109
|
const p = paramsRef.current;
|
|
109
110
|
p.setSelectedWalletConnectorKey(null);
|
|
110
111
|
p.clearAllWalletConnectSessions();
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use client'
|
|
2
2
|
import { __awaiter } from '../../../../../../_virtual/_tslib.js';
|
|
3
3
|
import { useRef, useCallback, useEffect } from 'react';
|
|
4
|
-
import { StorageService } from '@dynamic-labs/utils';
|
|
4
|
+
import { tracing, StorageService } from '@dynamic-labs/utils';
|
|
5
5
|
import '@dynamic-labs/sdk-api-core';
|
|
6
6
|
import '../../../../config/ApiEndpoint.js';
|
|
7
7
|
import '../../../../store/state/projectSettings/projectSettings.js';
|
|
@@ -101,6 +101,7 @@ const useHandleLogout = (params) => {
|
|
|
101
101
|
logger.logVerboseTroubleshootingMessage('useHandleLogout called', {
|
|
102
102
|
params: paramsRef.current,
|
|
103
103
|
});
|
|
104
|
+
tracing.logEvent('logout', 'useHandleLogout called');
|
|
104
105
|
const p = paramsRef.current;
|
|
105
106
|
p.setSelectedWalletConnectorKey(null);
|
|
106
107
|
p.clearAllWalletConnectSessions();
|
|
@@ -150,20 +150,19 @@ const OnrampContextProvider = ({ children, }) => {
|
|
|
150
150
|
onrampOverrides.length,
|
|
151
151
|
overrides === null || overrides === void 0 ? void 0 : overrides.onrampOptions,
|
|
152
152
|
]);
|
|
153
|
-
const
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
return promiseRef.current.promise;
|
|
153
|
+
const hasPrimaryWallet = React.useMemo(() => Boolean(primaryWallet), [primaryWallet]);
|
|
154
|
+
const setSelectedAndShowOnramp = React.useCallback((provider, wallet) => {
|
|
155
|
+
var _a;
|
|
156
|
+
if (hasPrimaryWallet) {
|
|
157
|
+
setSelectedOnrampProvider(provider.id);
|
|
159
158
|
}
|
|
160
|
-
promiseRef.current = new utils.DeferredPromise();
|
|
161
|
-
if (address || token)
|
|
162
|
-
setEnabledOnrampProvidersTarget({ address, token });
|
|
163
|
-
setSelectedOnrampProvider(onrampProvider);
|
|
164
159
|
setShowOnramp(true);
|
|
165
|
-
|
|
166
|
-
|
|
160
|
+
const shouldOpenPopup = provider.openMode === 'popup' && provider.url && setShowOnramp;
|
|
161
|
+
if (!shouldOpenPopup) {
|
|
162
|
+
return;
|
|
163
|
+
}
|
|
164
|
+
return openOnrampPopup.openOnrampPopup((_a = provider.url) !== null && _a !== void 0 ? _a : '', wallet, setShowOnramp, provider.id);
|
|
165
|
+
}, [hasPrimaryWallet, setShowOnramp]);
|
|
167
166
|
const enabledOnrampProviders = React.useMemo(() => {
|
|
168
167
|
// If we have explicit overrides (even empty array), use them
|
|
169
168
|
if ((overrides === null || overrides === void 0 ? void 0 : overrides.onrampOptions) !== undefined) {
|
|
@@ -176,26 +175,33 @@ const OnrampContextProvider = ({ children, }) => {
|
|
|
176
175
|
onrampOverrides,
|
|
177
176
|
overrides === null || overrides === void 0 ? void 0 : overrides.onrampOptions,
|
|
178
177
|
]);
|
|
178
|
+
const openOnramp = React.useCallback((_f) => _tslib.__awaiter(void 0, [_f], void 0, function* ({ onrampProvider, address, token }) {
|
|
179
|
+
if (!onrampEnabled) {
|
|
180
|
+
throw new Error('Onramp is not enabled');
|
|
181
|
+
}
|
|
182
|
+
if (promiseRef.current) {
|
|
183
|
+
return promiseRef.current.promise;
|
|
184
|
+
}
|
|
185
|
+
promiseRef.current = new utils.DeferredPromise();
|
|
186
|
+
if (address || token)
|
|
187
|
+
setEnabledOnrampProvidersTarget({ address, token });
|
|
188
|
+
const onrampOption = enabledOnrampProviders.find((p) => p.id === onrampProvider);
|
|
189
|
+
if (!onrampOption) {
|
|
190
|
+
throw new Error('Onramp provider not found');
|
|
191
|
+
}
|
|
192
|
+
setSelectedAndShowOnramp(onrampOption);
|
|
193
|
+
return promiseRef.current.promise;
|
|
194
|
+
}), [enabledOnrampProviders, onrampEnabled, setSelectedAndShowOnramp]);
|
|
179
195
|
const selectedOnramp = React.useMemo(() => enabledOnrampProviders.length
|
|
180
196
|
? enabledOnrampProviders.find((p) => p.id === selectedOnrampProvider)
|
|
181
197
|
: undefined, [enabledOnrampProviders, selectedOnrampProvider]);
|
|
182
|
-
const hasPrimaryWallet = React.useMemo(() => Boolean(primaryWallet), [primaryWallet]);
|
|
183
198
|
const selectOnrampProvider = React.useCallback(({ provider, wallet }) => {
|
|
184
|
-
var _a;
|
|
185
199
|
if (provider.onClick) {
|
|
186
200
|
provider.onClick({ wallet });
|
|
187
201
|
return;
|
|
188
202
|
}
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
}
|
|
192
|
-
setShowOnramp(true);
|
|
193
|
-
const shouldOpenPopup = provider.openMode === 'popup' && provider.url && setShowOnramp;
|
|
194
|
-
if (!shouldOpenPopup) {
|
|
195
|
-
return;
|
|
196
|
-
}
|
|
197
|
-
return openOnrampPopup.openOnrampPopup((_a = provider.url) !== null && _a !== void 0 ? _a : '', wallet, setShowOnramp, provider.id);
|
|
198
|
-
}, [hasPrimaryWallet, setShowOnramp]);
|
|
203
|
+
setSelectedAndShowOnramp(provider, wallet);
|
|
204
|
+
}, [setSelectedAndShowOnramp]);
|
|
199
205
|
const value = React.useMemo(() => ({
|
|
200
206
|
enabledOnrampProviders,
|
|
201
207
|
onrampEnabled,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type ReactNode } from 'react';
|
|
2
2
|
import type { OnrampProviders } from '@dynamic-labs/sdk-api-core';
|
|
3
|
-
import { Wallet } from '@dynamic-labs/wallet-connector-core';
|
|
3
|
+
import type { Wallet } from '@dynamic-labs/wallet-connector-core';
|
|
4
4
|
import type { OnrampOption } from '../DynamicContext';
|
|
5
5
|
type OpenOnrampProps = {
|
|
6
6
|
address?: string;
|
|
@@ -146,20 +146,19 @@ const OnrampContextProvider = ({ children, }) => {
|
|
|
146
146
|
onrampOverrides.length,
|
|
147
147
|
overrides === null || overrides === void 0 ? void 0 : overrides.onrampOptions,
|
|
148
148
|
]);
|
|
149
|
-
const
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
return promiseRef.current.promise;
|
|
149
|
+
const hasPrimaryWallet = useMemo(() => Boolean(primaryWallet), [primaryWallet]);
|
|
150
|
+
const setSelectedAndShowOnramp = useCallback((provider, wallet) => {
|
|
151
|
+
var _a;
|
|
152
|
+
if (hasPrimaryWallet) {
|
|
153
|
+
setSelectedOnrampProvider(provider.id);
|
|
155
154
|
}
|
|
156
|
-
promiseRef.current = new DeferredPromise();
|
|
157
|
-
if (address || token)
|
|
158
|
-
setEnabledOnrampProvidersTarget({ address, token });
|
|
159
|
-
setSelectedOnrampProvider(onrampProvider);
|
|
160
155
|
setShowOnramp(true);
|
|
161
|
-
|
|
162
|
-
|
|
156
|
+
const shouldOpenPopup = provider.openMode === 'popup' && provider.url && setShowOnramp;
|
|
157
|
+
if (!shouldOpenPopup) {
|
|
158
|
+
return;
|
|
159
|
+
}
|
|
160
|
+
return openOnrampPopup((_a = provider.url) !== null && _a !== void 0 ? _a : '', wallet, setShowOnramp, provider.id);
|
|
161
|
+
}, [hasPrimaryWallet, setShowOnramp]);
|
|
163
162
|
const enabledOnrampProviders = useMemo(() => {
|
|
164
163
|
// If we have explicit overrides (even empty array), use them
|
|
165
164
|
if ((overrides === null || overrides === void 0 ? void 0 : overrides.onrampOptions) !== undefined) {
|
|
@@ -172,26 +171,33 @@ const OnrampContextProvider = ({ children, }) => {
|
|
|
172
171
|
onrampOverrides,
|
|
173
172
|
overrides === null || overrides === void 0 ? void 0 : overrides.onrampOptions,
|
|
174
173
|
]);
|
|
174
|
+
const openOnramp = useCallback((_f) => __awaiter(void 0, [_f], void 0, function* ({ onrampProvider, address, token }) {
|
|
175
|
+
if (!onrampEnabled) {
|
|
176
|
+
throw new Error('Onramp is not enabled');
|
|
177
|
+
}
|
|
178
|
+
if (promiseRef.current) {
|
|
179
|
+
return promiseRef.current.promise;
|
|
180
|
+
}
|
|
181
|
+
promiseRef.current = new DeferredPromise();
|
|
182
|
+
if (address || token)
|
|
183
|
+
setEnabledOnrampProvidersTarget({ address, token });
|
|
184
|
+
const onrampOption = enabledOnrampProviders.find((p) => p.id === onrampProvider);
|
|
185
|
+
if (!onrampOption) {
|
|
186
|
+
throw new Error('Onramp provider not found');
|
|
187
|
+
}
|
|
188
|
+
setSelectedAndShowOnramp(onrampOption);
|
|
189
|
+
return promiseRef.current.promise;
|
|
190
|
+
}), [enabledOnrampProviders, onrampEnabled, setSelectedAndShowOnramp]);
|
|
175
191
|
const selectedOnramp = useMemo(() => enabledOnrampProviders.length
|
|
176
192
|
? enabledOnrampProviders.find((p) => p.id === selectedOnrampProvider)
|
|
177
193
|
: undefined, [enabledOnrampProviders, selectedOnrampProvider]);
|
|
178
|
-
const hasPrimaryWallet = useMemo(() => Boolean(primaryWallet), [primaryWallet]);
|
|
179
194
|
const selectOnrampProvider = useCallback(({ provider, wallet }) => {
|
|
180
|
-
var _a;
|
|
181
195
|
if (provider.onClick) {
|
|
182
196
|
provider.onClick({ wallet });
|
|
183
197
|
return;
|
|
184
198
|
}
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
}
|
|
188
|
-
setShowOnramp(true);
|
|
189
|
-
const shouldOpenPopup = provider.openMode === 'popup' && provider.url && setShowOnramp;
|
|
190
|
-
if (!shouldOpenPopup) {
|
|
191
|
-
return;
|
|
192
|
-
}
|
|
193
|
-
return openOnrampPopup((_a = provider.url) !== null && _a !== void 0 ? _a : '', wallet, setShowOnramp, provider.id);
|
|
194
|
-
}, [hasPrimaryWallet, setShowOnramp]);
|
|
199
|
+
setSelectedAndShowOnramp(provider, wallet);
|
|
200
|
+
}, [setSelectedAndShowOnramp]);
|
|
195
201
|
const value = useMemo(() => ({
|
|
196
202
|
enabledOnrampProviders,
|
|
197
203
|
onrampEnabled,
|
|
@@ -162,6 +162,14 @@ const registerSessionKey = (_h) => _tslib.__awaiter(void 0, [_h], void 0, functi
|
|
|
162
162
|
message: 'Error register session key',
|
|
163
163
|
});
|
|
164
164
|
logger.logger.error(responseError, { prevSessionKeySignature, publicKey });
|
|
165
|
+
utils.tracing.logEvent('session-key', 'Error registering session key', utils.tracing.formatObject({
|
|
166
|
+
prevSessionKeySignature,
|
|
167
|
+
publicKey,
|
|
168
|
+
walletId,
|
|
169
|
+
}));
|
|
170
|
+
if (utils.PlatformService.isNativeMobile) {
|
|
171
|
+
logger.logger.instrument(utils.tracing.packScopes());
|
|
172
|
+
}
|
|
165
173
|
if (responseError.response.status === 422) {
|
|
166
174
|
if (responseError.json.code ===
|
|
167
175
|
sdkApiCore.UnprocessableEntityErrorCode.InvalidSessionPublicKey) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use client'
|
|
2
2
|
import { __awaiter } from '../../../../../_virtual/_tslib.js';
|
|
3
3
|
import { UnprocessableEntityErrorCode, EmbeddedWalletProviderEnum, EmbeddedWalletChainEnum } from '@dynamic-labs/sdk-api-core';
|
|
4
|
-
import { DynamicError, ResponseError, InvalidEmbeddedWalletSessionKeyError } from '@dynamic-labs/utils';
|
|
4
|
+
import { DynamicError, ResponseError, tracing, PlatformService, InvalidEmbeddedWalletSessionKeyError } from '@dynamic-labs/utils';
|
|
5
5
|
import { storeAuthTokenAndUser } from '../../../store/state/user/storeAuthTokenAndUser/storeAuthTokenAndUser.js';
|
|
6
6
|
import '../../../store/state/user/user.js';
|
|
7
7
|
import { sdkApi } from '../api.js';
|
|
@@ -158,6 +158,14 @@ const registerSessionKey = (_h) => __awaiter(void 0, [_h], void 0, function* ({
|
|
|
158
158
|
message: 'Error register session key',
|
|
159
159
|
});
|
|
160
160
|
logger.error(responseError, { prevSessionKeySignature, publicKey });
|
|
161
|
+
tracing.logEvent('session-key', 'Error registering session key', tracing.formatObject({
|
|
162
|
+
prevSessionKeySignature,
|
|
163
|
+
publicKey,
|
|
164
|
+
walletId,
|
|
165
|
+
}));
|
|
166
|
+
if (PlatformService.isNativeMobile) {
|
|
167
|
+
logger.instrument(tracing.packScopes());
|
|
168
|
+
}
|
|
161
169
|
if (responseError.response.status === 422) {
|
|
162
170
|
if (responseError.json.code ===
|
|
163
171
|
UnprocessableEntityErrorCode.InvalidSessionPublicKey) {
|
|
@@ -892,7 +892,7 @@ const translation = {
|
|
|
892
892
|
title: 'Export wallet',
|
|
893
893
|
agreement_title: 'Agree to continue',
|
|
894
894
|
prompt_for_export_title: 'Back up wallet key',
|
|
895
|
-
private_key_title: '
|
|
895
|
+
private_key_title: 'Export Key',
|
|
896
896
|
recovery_phrase_title: 'Secret recovery phrase',
|
|
897
897
|
badge_label: 'Sensitive information',
|
|
898
898
|
prompt_for_export_description: 'Your wallet is ready. Back up your key to protect your assets.',
|
|
@@ -888,7 +888,7 @@ const translation = {
|
|
|
888
888
|
title: 'Export wallet',
|
|
889
889
|
agreement_title: 'Agree to continue',
|
|
890
890
|
prompt_for_export_title: 'Back up wallet key',
|
|
891
|
-
private_key_title: '
|
|
891
|
+
private_key_title: 'Export Key',
|
|
892
892
|
recovery_phrase_title: 'Secret recovery phrase',
|
|
893
893
|
badge_label: 'Sensitive information',
|
|
894
894
|
prompt_for_export_description: 'Your wallet is ready. Back up your key to protect your assets.',
|
|
@@ -4,19 +4,12 @@
|
|
|
4
4
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
5
|
|
|
6
6
|
var React = require('react');
|
|
7
|
-
var logger = require('../../../shared/logger.cjs');
|
|
8
7
|
var hasPendingRequirements = require('../../../shared/utils/functions/hasPendingRequirements/hasPendingRequirements.cjs');
|
|
9
8
|
var createStoreState = require('../../internalImplementation/utils/createStoreState/createStoreState.cjs');
|
|
10
9
|
var raiseUserProfileEvent = require('./raiseUserProfileEvent/raiseUserProfileEvent.cjs');
|
|
11
10
|
|
|
12
11
|
const { getUser, setUser: setUserRaw, useUser: useUserRaw, } = createStoreState.createStoreState('user');
|
|
13
12
|
const setUser = (user) => {
|
|
14
|
-
if (user) {
|
|
15
|
-
logger.logger.metaData.set('user', user);
|
|
16
|
-
}
|
|
17
|
-
else {
|
|
18
|
-
logger.logger.metaData.set('user', undefined);
|
|
19
|
-
}
|
|
20
13
|
const oldUser = getUser();
|
|
21
14
|
setUserRaw(user);
|
|
22
15
|
if (user && oldUser)
|
|
@@ -1,18 +1,11 @@
|
|
|
1
1
|
'use client'
|
|
2
2
|
import { useRef } from 'react';
|
|
3
|
-
import { logger } from '../../../shared/logger.js';
|
|
4
3
|
import { hasPendingRequirements } from '../../../shared/utils/functions/hasPendingRequirements/hasPendingRequirements.js';
|
|
5
4
|
import { createStoreState } from '../../internalImplementation/utils/createStoreState/createStoreState.js';
|
|
6
5
|
import { raiseUserProfileEvent } from './raiseUserProfileEvent/raiseUserProfileEvent.js';
|
|
7
6
|
|
|
8
7
|
const { getUser, setUser: setUserRaw, useUser: useUserRaw, } = createStoreState('user');
|
|
9
8
|
const setUser = (user) => {
|
|
10
|
-
if (user) {
|
|
11
|
-
logger.metaData.set('user', user);
|
|
12
|
-
}
|
|
13
|
-
else {
|
|
14
|
-
logger.metaData.set('user', undefined);
|
|
15
|
-
}
|
|
16
9
|
const oldUser = getUser();
|
|
17
10
|
setUserRaw(user);
|
|
18
11
|
if (user && oldUser)
|