@dynamic-labs/sdk-react-core 4.0.0-alpha.6 → 4.0.0-alpha.7
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 +18 -0
- package/package.cjs +1 -1
- package/package.js +1 -1
- package/package.json +11 -11
- package/src/lib/components/SendBalancePageLayout/SendBalancePageLayout.cjs +24 -4
- package/src/lib/components/SendBalancePageLayout/SendBalancePageLayout.js +24 -4
- package/src/lib/context/DynamicContext/DynamicContext.cjs +1 -1
- package/src/lib/context/DynamicContext/DynamicContext.js +1 -1
- package/src/lib/context/SocialRedirectContext/hooks/useRedirectSocialHandler/useRedirectSocialHandler.cjs +15 -8
- package/src/lib/context/SocialRedirectContext/hooks/useRedirectSocialHandler/useRedirectSocialHandler.js +15 -8
- package/src/lib/shared/assets/embedded-wallet-icon.cjs +11 -10
- package/src/lib/shared/assets/embedded-wallet-icon.js +11 -10
- package/src/lib/utils/functions/networksAndChains/networksAndChains.cjs +8 -22
- package/src/lib/utils/functions/networksAndChains/networksAndChains.d.ts +10 -3
- package/src/lib/utils/functions/networksAndChains/networksAndChains.js +8 -22
- package/src/lib/utils/functions/socialStorage/socialStorage.d.ts +3 -0
- package/src/lib/utils/functions/walletListBuilder/walletListBuilder.cjs +1 -1
- package/src/lib/utils/functions/walletListBuilder/walletListBuilder.js +1 -1
- package/src/lib/utils/hooks/useSocialAuth/useSocialAuth.cjs +1 -0
- package/src/lib/utils/hooks/useSocialAuth/useSocialAuth.js +1 -0
- package/src/lib/widgets/DynamicWidget/hooks/useFetchChain/index.d.ts +1 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,22 @@
|
|
|
1
1
|
|
|
2
|
+
## [4.0.0-alpha.7](https://github.com/dynamic-labs/dynamic-auth/compare/v4.0.0-alpha.6...v4.0.0-alpha.7) (2024-10-03)
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
### Features
|
|
6
|
+
|
|
7
|
+
* add account abstraction module to client ([#7002](https://github.com/dynamic-labs/dynamic-auth/issues/7002)) ([2f06975](https://github.com/dynamic-labs/dynamic-auth/commit/2f06975083dfa9d40537ef4a99b414eda1a68e01))
|
|
8
|
+
* add support for wallet events in rn ([#7061](https://github.com/dynamic-labs/dynamic-auth/issues/7061)) ([c7c4ce5](https://github.com/dynamic-labs/dynamic-auth/commit/c7c4ce51f27a2b84a1710c120d7006a00920c1e7))
|
|
9
|
+
* add zerodev extension for react native ([#7028](https://github.com/dynamic-labs/dynamic-auth/issues/7028)) ([858b8a8](https://github.com/dynamic-labs/dynamic-auth/commit/858b8a851cfa0cddc8e4559541b03992cf5ccdfc))
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
### Bug Fixes
|
|
13
|
+
|
|
14
|
+
* do not modify sol tx blockhash as tx could have been signed already ([#7050](https://github.com/dynamic-labs/dynamic-auth/issues/7050)) ([770edb4](https://github.com/dynamic-labs/dynamic-auth/commit/770edb49ddc231b75fb45a9f6d563f22e5185df2))
|
|
15
|
+
* ensure the correct auth mode is used on social redirect ([#7047](https://github.com/dynamic-labs/dynamic-auth/issues/7047)) ([7c27172](https://github.com/dynamic-labs/dynamic-auth/commit/7c271721d5ddf19e3fd1bf56ddb1d49e0e2bca07))
|
|
16
|
+
* prevent react native message timeout before sdk is ready ([#7051](https://github.com/dynamic-labs/dynamic-auth/issues/7051)) ([6421237](https://github.com/dynamic-labs/dynamic-auth/commit/6421237d677d788b824d53432c1a75b9d571aa78))
|
|
17
|
+
* update version error text ([#7054](https://github.com/dynamic-labs/dynamic-auth/issues/7054)) ([713dacb](https://github.com/dynamic-labs/dynamic-auth/commit/713dacb79c2513323c2e6840d7418716011c2dcd))
|
|
18
|
+
* use project settings sdk network for send flow ([#7011](https://github.com/dynamic-labs/dynamic-auth/issues/7011)) ([983e796](https://github.com/dynamic-labs/dynamic-auth/commit/983e79632762f71ee0502c92057a32ea985ae19c))
|
|
19
|
+
|
|
2
20
|
## [4.0.0-alpha.6](https://github.com/dynamic-labs/dynamic-auth/compare/v4.0.0-alpha.5...v4.0.0-alpha.6) (2024-10-01)
|
|
3
21
|
|
|
4
22
|
|
package/package.cjs
CHANGED
package/package.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dynamic-labs/sdk-react-core",
|
|
3
|
-
"version": "4.0.0-alpha.
|
|
3
|
+
"version": "4.0.0-alpha.7",
|
|
4
4
|
"dependencies": {
|
|
5
5
|
"@dynamic-labs/sdk-api-core": "0.0.535",
|
|
6
6
|
"@hcaptcha/react-hcaptcha": "1.4.4",
|
|
@@ -12,16 +12,16 @@
|
|
|
12
12
|
"react-i18next": "13.5.0",
|
|
13
13
|
"yup": "0.32.11",
|
|
14
14
|
"react-international-phone": "4.2.5",
|
|
15
|
-
"@dynamic-labs/assert-package-version": "4.0.0-alpha.
|
|
16
|
-
"@dynamic-labs/iconic": "4.0.0-alpha.
|
|
17
|
-
"@dynamic-labs/logger": "4.0.0-alpha.
|
|
18
|
-
"@dynamic-labs/multi-wallet": "4.0.0-alpha.
|
|
19
|
-
"@dynamic-labs/rpc-providers": "4.0.0-alpha.
|
|
20
|
-
"@dynamic-labs/store": "4.0.0-alpha.
|
|
21
|
-
"@dynamic-labs/types": "4.0.0-alpha.
|
|
22
|
-
"@dynamic-labs/utils": "4.0.0-alpha.
|
|
23
|
-
"@dynamic-labs/wallet-book": "4.0.0-alpha.
|
|
24
|
-
"@dynamic-labs/wallet-connector-core": "4.0.0-alpha.
|
|
15
|
+
"@dynamic-labs/assert-package-version": "4.0.0-alpha.7",
|
|
16
|
+
"@dynamic-labs/iconic": "4.0.0-alpha.7",
|
|
17
|
+
"@dynamic-labs/logger": "4.0.0-alpha.7",
|
|
18
|
+
"@dynamic-labs/multi-wallet": "4.0.0-alpha.7",
|
|
19
|
+
"@dynamic-labs/rpc-providers": "4.0.0-alpha.7",
|
|
20
|
+
"@dynamic-labs/store": "4.0.0-alpha.7",
|
|
21
|
+
"@dynamic-labs/types": "4.0.0-alpha.7",
|
|
22
|
+
"@dynamic-labs/utils": "4.0.0-alpha.7",
|
|
23
|
+
"@dynamic-labs/wallet-book": "4.0.0-alpha.7",
|
|
24
|
+
"@dynamic-labs/wallet-connector-core": "4.0.0-alpha.7",
|
|
25
25
|
"eventemitter3": "5.0.1"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
@@ -9,7 +9,7 @@ var React = require('react');
|
|
|
9
9
|
var reactI18next = require('react-i18next');
|
|
10
10
|
require('../../context/DynamicContext/DynamicContext.cjs');
|
|
11
11
|
require('@dynamic-labs/sdk-api-core');
|
|
12
|
-
require('../../shared/logger.cjs');
|
|
12
|
+
var logger = require('../../shared/logger.cjs');
|
|
13
13
|
require('@dynamic-labs/iconic');
|
|
14
14
|
require('@dynamic-labs/wallet-connector-core');
|
|
15
15
|
require('../../context/ViewContext/ViewContext.cjs');
|
|
@@ -73,6 +73,7 @@ require('../Popper/PopperContext/PopperContext.cjs');
|
|
|
73
73
|
require('react-focus-lock');
|
|
74
74
|
var PoweredByDynamic = require('../PoweredByDynamic/PoweredByDynamic.cjs');
|
|
75
75
|
require('qrcode');
|
|
76
|
+
var useFetchChain = require('../../widgets/DynamicWidget/hooks/useFetchChain/useFetchChain.cjs');
|
|
76
77
|
require('formik');
|
|
77
78
|
require('../../context/FooterAnimationContext/index.cjs');
|
|
78
79
|
require('../../context/WalletGroupContext/WalletGroupContext.cjs');
|
|
@@ -84,6 +85,7 @@ require('../../context/IpConfigurationContext/IpConfigurationContext.cjs');
|
|
|
84
85
|
require('../../context/PasskeyContext/PasskeyContext.cjs');
|
|
85
86
|
var sendBalances = require('../../store/state/sendBalances.cjs');
|
|
86
87
|
var SendBalanceForm = require('../SendBalanceForm/SendBalanceForm.cjs');
|
|
88
|
+
var useNetworkConfigurationsFromProjectSettings = require('../../utils/hooks/useNetworkConfigurationsFromProjectSettings/useNetworkConfigurationsFromProjectSettings.cjs');
|
|
87
89
|
var constants = require('./components/TokensBalanceDropdown/constants.cjs');
|
|
88
90
|
require('../../widgets/DynamicWidget/components/DynamicWidgetHeader/DynamicWidgetHeader.cjs');
|
|
89
91
|
require('../../views/TransactionConfirmationView/helpers/transactionErrorMessage.cjs');
|
|
@@ -95,8 +97,13 @@ var useInternalDynamicContext = require('../../context/DynamicContext/useDynamic
|
|
|
95
97
|
const SendBalancePageLayout = ({ error, onClickClose, onClickBack, onSubmit, displayPoweredByDynamicFooter = false, transaction, networkCurrencyDecimals, tokenBalances, currentToken, setCurrentToken, isLoading, isNativeToken, }) => {
|
|
96
98
|
var _a;
|
|
97
99
|
const { t } = reactI18next.useTranslation();
|
|
98
|
-
const { primaryWallet } = useInternalDynamicContext.useInternalDynamicContext();
|
|
100
|
+
const { primaryWallet, projectSettings } = useInternalDynamicContext.useInternalDynamicContext();
|
|
99
101
|
const { chainName } = sendBalances.useSendBalanceState();
|
|
102
|
+
const networkInfo = useNetworkConfigurationsFromProjectSettings.useNetworkConfigurationsFromProjectSettings({
|
|
103
|
+
projectSettings,
|
|
104
|
+
});
|
|
105
|
+
const walletConnector = primaryWallet === null || primaryWallet === void 0 ? void 0 : primaryWallet.connector;
|
|
106
|
+
const { chain } = useFetchChain.useFetchChain(walletConnector);
|
|
100
107
|
const closeButton = onClickClose && (jsxRuntime.jsx(IconButton.IconButton, { type: 'button', onClick: onClickClose, "data-testid": 'close-button', children: jsxRuntime.jsx(close.ReactComponent, {}) }));
|
|
101
108
|
const backButton = onClickBack && (jsxRuntime.jsx(IconButton.IconButton, { type: 'button', onClick: onClickBack, "data-testid": 'back-button', children: jsxRuntime.jsx(arrowLeft.ReactComponent, {}) }));
|
|
102
109
|
const { data: balance } = usePromise.usePromise(() => transaction.getBalance(), {
|
|
@@ -104,7 +111,20 @@ const SendBalancePageLayout = ({ error, onClickClose, onClickBack, onSubmit, dis
|
|
|
104
111
|
});
|
|
105
112
|
React.useEffect(() => {
|
|
106
113
|
const getNativeTokenAndFetchBalance = () => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
107
|
-
const
|
|
114
|
+
const nativeTokenInfo = networksAndChains.getNativeTokenInfo(chain, networkInfo);
|
|
115
|
+
if (!nativeTokenInfo) {
|
|
116
|
+
logger.logger.error('Token info not found. Please make sure you are on a supported chain and it is enabled. See https://docs.dynamic.xyz/chains/enabling-chains');
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
const token = {
|
|
120
|
+
address: chainName === 'Solana' ? constants.nativeSolanaAddress : constants.zeroAddress,
|
|
121
|
+
balance: 0,
|
|
122
|
+
decimals: nativeTokenInfo.nativeCurrency.decimals,
|
|
123
|
+
logoURI: nativeTokenInfo.iconUrls[0],
|
|
124
|
+
name: nativeTokenInfo.name,
|
|
125
|
+
rawBalance: 0,
|
|
126
|
+
symbol: nativeTokenInfo.nativeCurrency.symbol,
|
|
127
|
+
};
|
|
108
128
|
const tokenBalance = yield (primaryWallet === null || primaryWallet === void 0 ? void 0 : primaryWallet.getBalance());
|
|
109
129
|
if (tokenBalance) {
|
|
110
130
|
token.balance = Number(tokenBalance);
|
|
@@ -125,7 +145,7 @@ const SendBalancePageLayout = ({ error, onClickClose, onClickBack, onSubmit, dis
|
|
|
125
145
|
});
|
|
126
146
|
updateTokenBalances();
|
|
127
147
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
128
|
-
}, [tokenBalances]);
|
|
148
|
+
}, [tokenBalances, chain]);
|
|
129
149
|
const getAmount = () => {
|
|
130
150
|
if (isNativeToken) {
|
|
131
151
|
return transaction.value ? transaction.format(transaction.value) : '';
|
|
@@ -5,7 +5,7 @@ import { useEffect } from 'react';
|
|
|
5
5
|
import { useTranslation } from 'react-i18next';
|
|
6
6
|
import '../../context/DynamicContext/DynamicContext.js';
|
|
7
7
|
import '@dynamic-labs/sdk-api-core';
|
|
8
|
-
import '../../shared/logger.js';
|
|
8
|
+
import { logger } from '../../shared/logger.js';
|
|
9
9
|
import '@dynamic-labs/iconic';
|
|
10
10
|
import '@dynamic-labs/wallet-connector-core';
|
|
11
11
|
import '../../context/ViewContext/ViewContext.js';
|
|
@@ -69,6 +69,7 @@ import '../Popper/PopperContext/PopperContext.js';
|
|
|
69
69
|
import 'react-focus-lock';
|
|
70
70
|
import { PoweredByDynamic } from '../PoweredByDynamic/PoweredByDynamic.js';
|
|
71
71
|
import 'qrcode';
|
|
72
|
+
import { useFetchChain } from '../../widgets/DynamicWidget/hooks/useFetchChain/useFetchChain.js';
|
|
72
73
|
import 'formik';
|
|
73
74
|
import '../../context/FooterAnimationContext/index.js';
|
|
74
75
|
import '../../context/WalletGroupContext/WalletGroupContext.js';
|
|
@@ -80,6 +81,7 @@ import '../../context/IpConfigurationContext/IpConfigurationContext.js';
|
|
|
80
81
|
import '../../context/PasskeyContext/PasskeyContext.js';
|
|
81
82
|
import { useSendBalanceState } from '../../store/state/sendBalances.js';
|
|
82
83
|
import { SendBalanceForm } from '../SendBalanceForm/SendBalanceForm.js';
|
|
84
|
+
import { useNetworkConfigurationsFromProjectSettings } from '../../utils/hooks/useNetworkConfigurationsFromProjectSettings/useNetworkConfigurationsFromProjectSettings.js';
|
|
83
85
|
import { nativeSolanaAddress, zeroAddress } from './components/TokensBalanceDropdown/constants.js';
|
|
84
86
|
import '../../widgets/DynamicWidget/components/DynamicWidgetHeader/DynamicWidgetHeader.js';
|
|
85
87
|
import '../../views/TransactionConfirmationView/helpers/transactionErrorMessage.js';
|
|
@@ -91,8 +93,13 @@ import { useInternalDynamicContext } from '../../context/DynamicContext/useDynam
|
|
|
91
93
|
const SendBalancePageLayout = ({ error, onClickClose, onClickBack, onSubmit, displayPoweredByDynamicFooter = false, transaction, networkCurrencyDecimals, tokenBalances, currentToken, setCurrentToken, isLoading, isNativeToken, }) => {
|
|
92
94
|
var _a;
|
|
93
95
|
const { t } = useTranslation();
|
|
94
|
-
const { primaryWallet } = useInternalDynamicContext();
|
|
96
|
+
const { primaryWallet, projectSettings } = useInternalDynamicContext();
|
|
95
97
|
const { chainName } = useSendBalanceState();
|
|
98
|
+
const networkInfo = useNetworkConfigurationsFromProjectSettings({
|
|
99
|
+
projectSettings,
|
|
100
|
+
});
|
|
101
|
+
const walletConnector = primaryWallet === null || primaryWallet === void 0 ? void 0 : primaryWallet.connector;
|
|
102
|
+
const { chain } = useFetchChain(walletConnector);
|
|
96
103
|
const closeButton = onClickClose && (jsx(IconButton, { type: 'button', onClick: onClickClose, "data-testid": 'close-button', children: jsx(SvgClose, {}) }));
|
|
97
104
|
const backButton = onClickBack && (jsx(IconButton, { type: 'button', onClick: onClickBack, "data-testid": 'back-button', children: jsx(SvgArrowLeft, {}) }));
|
|
98
105
|
const { data: balance } = usePromise(() => transaction.getBalance(), {
|
|
@@ -100,7 +107,20 @@ const SendBalancePageLayout = ({ error, onClickClose, onClickBack, onSubmit, dis
|
|
|
100
107
|
});
|
|
101
108
|
useEffect(() => {
|
|
102
109
|
const getNativeTokenAndFetchBalance = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
103
|
-
const
|
|
110
|
+
const nativeTokenInfo = getNativeTokenInfo(chain, networkInfo);
|
|
111
|
+
if (!nativeTokenInfo) {
|
|
112
|
+
logger.error('Token info not found. Please make sure you are on a supported chain and it is enabled. See https://docs.dynamic.xyz/chains/enabling-chains');
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
const token = {
|
|
116
|
+
address: chainName === 'Solana' ? nativeSolanaAddress : zeroAddress,
|
|
117
|
+
balance: 0,
|
|
118
|
+
decimals: nativeTokenInfo.nativeCurrency.decimals,
|
|
119
|
+
logoURI: nativeTokenInfo.iconUrls[0],
|
|
120
|
+
name: nativeTokenInfo.name,
|
|
121
|
+
rawBalance: 0,
|
|
122
|
+
symbol: nativeTokenInfo.nativeCurrency.symbol,
|
|
123
|
+
};
|
|
104
124
|
const tokenBalance = yield (primaryWallet === null || primaryWallet === void 0 ? void 0 : primaryWallet.getBalance());
|
|
105
125
|
if (tokenBalance) {
|
|
106
126
|
token.balance = Number(tokenBalance);
|
|
@@ -121,7 +141,7 @@ const SendBalancePageLayout = ({ error, onClickClose, onClickBack, onSubmit, dis
|
|
|
121
141
|
});
|
|
122
142
|
updateTokenBalances();
|
|
123
143
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
124
|
-
}, [tokenBalances]);
|
|
144
|
+
}, [tokenBalances, chain]);
|
|
125
145
|
const getAmount = () => {
|
|
126
146
|
if (isNativeToken) {
|
|
127
147
|
return transaction.value ? transaction.format(transaction.value) : '';
|
|
@@ -92,6 +92,7 @@ var DynamicWidgetContext = require('../../widgets/DynamicWidget/context/DynamicW
|
|
|
92
92
|
var IpConfigurationContext = require('../IpConfigurationContext/IpConfigurationContext.cjs');
|
|
93
93
|
var PasskeyContext = require('../PasskeyContext/PasskeyContext.cjs');
|
|
94
94
|
require('../../store/state/sendBalances.cjs');
|
|
95
|
+
var useNetworkConfigurationsFromProjectSettings = require('../../utils/hooks/useNetworkConfigurationsFromProjectSettings/useNetworkConfigurationsFromProjectSettings.cjs');
|
|
95
96
|
var SyncAuthFlow = require('../../components/SyncAuthFlow/SyncAuthFlow.cjs');
|
|
96
97
|
var Toolkit = require('../../components/Toolkit/Toolkit.cjs');
|
|
97
98
|
var store = require('../../store/internalImplementation/store.cjs');
|
|
@@ -122,7 +123,6 @@ var PhantomRedirectContext = require('../PhantomRedirectContext/PhantomRedirectC
|
|
|
122
123
|
var ReinitializeContextProvider = require('../ReinitializeContext/ReinitializeContextProvider.cjs');
|
|
123
124
|
var SendBalanceContext = require('../SendBalanceContext/SendBalanceContext.cjs');
|
|
124
125
|
var UseNetworkValidation = require('../UseNetworkValidation/UseNetworkValidation.cjs');
|
|
125
|
-
var useNetworkConfigurationsFromProjectSettings = require('../../utils/hooks/useNetworkConfigurationsFromProjectSettings/useNetworkConfigurationsFromProjectSettings.cjs');
|
|
126
126
|
var helpers = require('./helpers/helpers.cjs');
|
|
127
127
|
var useDisplayOrderState = require('./hooks/useDisplayOrderState/useDisplayOrderState.cjs');
|
|
128
128
|
var useEmailLoginState = require('./hooks/useEmailLoginState/useEmailLoginState.cjs');
|
|
@@ -88,6 +88,7 @@ import { DynamicWidgetContextProvider } from '../../widgets/DynamicWidget/contex
|
|
|
88
88
|
import { IpConfigurationContextProvider } from '../IpConfigurationContext/IpConfigurationContext.js';
|
|
89
89
|
import { PasskeyContextProvider } from '../PasskeyContext/PasskeyContext.js';
|
|
90
90
|
import '../../store/state/sendBalances.js';
|
|
91
|
+
import { useNetworkConfigurationsFromProjectSettings } from '../../utils/hooks/useNetworkConfigurationsFromProjectSettings/useNetworkConfigurationsFromProjectSettings.js';
|
|
91
92
|
import { SyncAuthFlow } from '../../components/SyncAuthFlow/SyncAuthFlow.js';
|
|
92
93
|
import { Toolkit } from '../../components/Toolkit/Toolkit.js';
|
|
93
94
|
import { removeStoreInstance, initializeStore } from '../../store/internalImplementation/store.js';
|
|
@@ -118,7 +119,6 @@ import { PhantomRedirectContextProvider } from '../PhantomRedirectContext/Phanto
|
|
|
118
119
|
import { ReinitializeContextProvider } from '../ReinitializeContext/ReinitializeContextProvider.js';
|
|
119
120
|
import { SendBalanceContextProvider } from '../SendBalanceContext/SendBalanceContext.js';
|
|
120
121
|
import { UseNetworkValidation } from '../UseNetworkValidation/UseNetworkValidation.js';
|
|
121
|
-
import { useNetworkConfigurationsFromProjectSettings } from '../../utils/hooks/useNetworkConfigurationsFromProjectSettings/useNetworkConfigurationsFromProjectSettings.js';
|
|
122
122
|
import { resolveNetworkValidationMode, initExpirationTime, getInitialView, getDeepLinkPreference } from './helpers/helpers.js';
|
|
123
123
|
import { useDisplayOrderState } from './hooks/useDisplayOrderState/useDisplayOrderState.js';
|
|
124
124
|
import { useEmailLoginState } from './hooks/useEmailLoginState/useEmailLoginState.js';
|
|
@@ -5,15 +5,15 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
5
5
|
|
|
6
6
|
var _tslib = require('../../../../../../_virtual/_tslib.cjs');
|
|
7
7
|
var React = require('react');
|
|
8
|
+
var utils = require('@dynamic-labs/utils');
|
|
8
9
|
require('@dynamic-labs/sdk-api-core');
|
|
9
|
-
require('../../../../shared/logger.cjs');
|
|
10
|
+
var logger = require('../../../../shared/logger.cjs');
|
|
10
11
|
require('@dynamic-labs/iconic');
|
|
11
12
|
require('@dynamic-labs/wallet-connector-core');
|
|
12
13
|
require('react/jsx-runtime');
|
|
13
14
|
var ViewContext = require('../../../ViewContext/ViewContext.cjs');
|
|
14
15
|
require('@dynamic-labs/wallet-book');
|
|
15
16
|
var isSSR = require('../../../../shared/utils/functions/isSSR/isSSR.cjs');
|
|
16
|
-
require('@dynamic-labs/utils');
|
|
17
17
|
require('../../../../utils/constants/colors.cjs');
|
|
18
18
|
require('../../../../utils/constants/values.cjs');
|
|
19
19
|
var useEffectOnce = require('../../../../shared/utils/hooks/useEffectOnce/useEffectOnce.cjs');
|
|
@@ -29,7 +29,7 @@ require('react-international-phone');
|
|
|
29
29
|
var socialStorage = require('../../../../utils/functions/socialStorage/socialStorage.cjs');
|
|
30
30
|
var getSocialSignInProviderForProviderEnum = require('../../../../utils/functions/getSocialSignInProviderForProviderEnum/getSocialSignInProviderForProviderEnum.cjs');
|
|
31
31
|
require('../../../../config/ApiEndpoint.cjs');
|
|
32
|
-
require('../../../../store/state/user/user.cjs');
|
|
32
|
+
var user = require('../../../../store/state/user/user.cjs');
|
|
33
33
|
require('../../../../locale/locale.cjs');
|
|
34
34
|
require('../../../../store/state/projectSettings/projectSettings.cjs');
|
|
35
35
|
require('../../../AccessDeniedContext/AccessDeniedContext.cjs');
|
|
@@ -91,7 +91,7 @@ const useRedirectSocialHandler = ({ setSocialProvider, }) => {
|
|
|
91
91
|
const { setView } = ViewContext.useViewContext();
|
|
92
92
|
const { setDynamicWidgetView } = DynamicWidgetContext.useWidgetContext();
|
|
93
93
|
const [socialStorageItem, setSocialStorageItem] = React.useState(null);
|
|
94
|
-
const { sdkHasLoaded,
|
|
94
|
+
const { sdkHasLoaded, setShowAuthFlow, isRenderingEmbeddedAuthFlow, setShowDynamicUserProfile, } = useInternalDynamicContext.useInternalDynamicContext();
|
|
95
95
|
const { completeConnection } = useSocialAuth.useSocialAuth({
|
|
96
96
|
sessionTimeout: 10000,
|
|
97
97
|
});
|
|
@@ -130,17 +130,24 @@ const useRedirectSocialHandler = ({ setSocialProvider, }) => {
|
|
|
130
130
|
useEffectOnceCondition.useEffectOnceCondition(() => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
131
131
|
if (!socialStorageItem)
|
|
132
132
|
return;
|
|
133
|
-
const authMode = user ? 'link' : 'signin';
|
|
134
133
|
// Update UI to reflect the original state
|
|
135
|
-
if (
|
|
134
|
+
if (socialStorageItem.mode === 'signin') {
|
|
135
|
+
if (user.getUser()) {
|
|
136
|
+
logger.logger.error(new utils.DynamicError('User is already logged in'));
|
|
137
|
+
return;
|
|
138
|
+
}
|
|
136
139
|
updateInterfaceStateForSignIn(socialStorageItem);
|
|
137
140
|
}
|
|
138
|
-
else if (
|
|
141
|
+
else if (socialStorageItem.mode === 'link') {
|
|
142
|
+
if (!user.getUser()) {
|
|
143
|
+
logger.logger.error(new utils.DynamicError('User not logged in'));
|
|
144
|
+
return;
|
|
145
|
+
}
|
|
139
146
|
updateInterfaceStateForLink();
|
|
140
147
|
}
|
|
141
148
|
yield completeConnection({
|
|
142
149
|
authCode: socialStorageItem.code,
|
|
143
|
-
authMode,
|
|
150
|
+
authMode: socialStorageItem.mode,
|
|
144
151
|
captchaToken: socialStorageItem.captchaToken,
|
|
145
152
|
provider: socialStorageItem.provider,
|
|
146
153
|
state: socialStorageItem.state,
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
'use client'
|
|
2
2
|
import { __awaiter } from '../../../../../../_virtual/_tslib.js';
|
|
3
3
|
import { useState, useCallback } from 'react';
|
|
4
|
+
import { DynamicError } from '@dynamic-labs/utils';
|
|
4
5
|
import '@dynamic-labs/sdk-api-core';
|
|
5
|
-
import '../../../../shared/logger.js';
|
|
6
|
+
import { logger } from '../../../../shared/logger.js';
|
|
6
7
|
import '@dynamic-labs/iconic';
|
|
7
8
|
import '@dynamic-labs/wallet-connector-core';
|
|
8
9
|
import 'react/jsx-runtime';
|
|
9
10
|
import { useViewContext } from '../../../ViewContext/ViewContext.js';
|
|
10
11
|
import '@dynamic-labs/wallet-book';
|
|
11
12
|
import { isSSR } from '../../../../shared/utils/functions/isSSR/isSSR.js';
|
|
12
|
-
import '@dynamic-labs/utils';
|
|
13
13
|
import '../../../../utils/constants/colors.js';
|
|
14
14
|
import '../../../../utils/constants/values.js';
|
|
15
15
|
import { useEffectOnce } from '../../../../shared/utils/hooks/useEffectOnce/useEffectOnce.js';
|
|
@@ -25,7 +25,7 @@ import 'react-international-phone';
|
|
|
25
25
|
import { searchSocialStorageByState, deleteSocialStorage } from '../../../../utils/functions/socialStorage/socialStorage.js';
|
|
26
26
|
import { getSocialSignInProviderForProviderEnum } from '../../../../utils/functions/getSocialSignInProviderForProviderEnum/getSocialSignInProviderForProviderEnum.js';
|
|
27
27
|
import '../../../../config/ApiEndpoint.js';
|
|
28
|
-
import '../../../../store/state/user/user.js';
|
|
28
|
+
import { getUser } from '../../../../store/state/user/user.js';
|
|
29
29
|
import '../../../../locale/locale.js';
|
|
30
30
|
import '../../../../store/state/projectSettings/projectSettings.js';
|
|
31
31
|
import '../../../AccessDeniedContext/AccessDeniedContext.js';
|
|
@@ -87,7 +87,7 @@ const useRedirectSocialHandler = ({ setSocialProvider, }) => {
|
|
|
87
87
|
const { setView } = useViewContext();
|
|
88
88
|
const { setDynamicWidgetView } = useWidgetContext();
|
|
89
89
|
const [socialStorageItem, setSocialStorageItem] = useState(null);
|
|
90
|
-
const { sdkHasLoaded,
|
|
90
|
+
const { sdkHasLoaded, setShowAuthFlow, isRenderingEmbeddedAuthFlow, setShowDynamicUserProfile, } = useInternalDynamicContext();
|
|
91
91
|
const { completeConnection } = useSocialAuth({
|
|
92
92
|
sessionTimeout: 10000,
|
|
93
93
|
});
|
|
@@ -126,17 +126,24 @@ const useRedirectSocialHandler = ({ setSocialProvider, }) => {
|
|
|
126
126
|
useEffectOnceCondition(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
127
127
|
if (!socialStorageItem)
|
|
128
128
|
return;
|
|
129
|
-
const authMode = user ? 'link' : 'signin';
|
|
130
129
|
// Update UI to reflect the original state
|
|
131
|
-
if (
|
|
130
|
+
if (socialStorageItem.mode === 'signin') {
|
|
131
|
+
if (getUser()) {
|
|
132
|
+
logger.error(new DynamicError('User is already logged in'));
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
132
135
|
updateInterfaceStateForSignIn(socialStorageItem);
|
|
133
136
|
}
|
|
134
|
-
else if (
|
|
137
|
+
else if (socialStorageItem.mode === 'link') {
|
|
138
|
+
if (!getUser()) {
|
|
139
|
+
logger.error(new DynamicError('User not logged in'));
|
|
140
|
+
return;
|
|
141
|
+
}
|
|
135
142
|
updateInterfaceStateForLink();
|
|
136
143
|
}
|
|
137
144
|
yield completeConnection({
|
|
138
145
|
authCode: socialStorageItem.code,
|
|
139
|
-
authMode,
|
|
146
|
+
authMode: socialStorageItem.mode,
|
|
140
147
|
captchaToken: socialStorageItem.captchaToken,
|
|
141
148
|
provider: socialStorageItem.provider,
|
|
142
149
|
state: socialStorageItem.state,
|
|
@@ -25,7 +25,7 @@ function _interopNamespace(e) {
|
|
|
25
25
|
|
|
26
26
|
var React__namespace = /*#__PURE__*/_interopNamespace(React);
|
|
27
27
|
|
|
28
|
-
var
|
|
28
|
+
var _path;
|
|
29
29
|
var _excluded = ["title", "titleId"];
|
|
30
30
|
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
31
31
|
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
@@ -35,20 +35,21 @@ var SvgEmbeddedWalletIcon = function SvgEmbeddedWalletIcon(_ref) {
|
|
|
35
35
|
titleId = _ref.titleId,
|
|
36
36
|
props = _objectWithoutProperties(_ref, _excluded);
|
|
37
37
|
return /*#__PURE__*/React__namespace.createElement("svg", _extends({
|
|
38
|
-
width:
|
|
39
|
-
height:
|
|
40
|
-
viewBox: "0 0
|
|
38
|
+
width: 64,
|
|
39
|
+
height: 64,
|
|
40
|
+
viewBox: "0 0 64 64",
|
|
41
41
|
fill: "none",
|
|
42
42
|
xmlns: "http://www.w3.org/2000/svg",
|
|
43
43
|
"aria-labelledby": titleId
|
|
44
44
|
}, props), title ? /*#__PURE__*/React__namespace.createElement("title", {
|
|
45
45
|
id: titleId
|
|
46
|
-
}, title) : null,
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
46
|
+
}, title) : null, _path || (_path = /*#__PURE__*/React__namespace.createElement("path", {
|
|
47
|
+
fillRule: "evenodd",
|
|
48
|
+
clipRule: "evenodd",
|
|
49
|
+
d: "M32 64c17.673 0 32-14.327 32-32C64 14.327 49.673 0 32 0 14.327 0 0 14.327 0 32c0 17.673 14.327 32 32 32Zm8.334-45.333a3.333 3.333 0 0 0-3.333-3.334h-15a6.669 6.669 0 0 0-6.56 5.473 6.649 6.649 0 0 1 4.893-2.14h20ZM42 22a6.667 6.667 0 0 1 6.667 6.667V42A6.667 6.667 0 0 1 42 48.667H22A6.667 6.667 0 0 1 15.334 42V28.667A6.667 6.667 0 0 1 22 22h20Z",
|
|
50
|
+
fill: "#4779FF",
|
|
51
|
+
"data-testid": "wallet-icon-embedded"
|
|
52
|
+
})));
|
|
52
53
|
};
|
|
53
54
|
|
|
54
55
|
exports.ReactComponent = SvgEmbeddedWalletIcon;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use client'
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
|
|
4
|
-
var
|
|
4
|
+
var _path;
|
|
5
5
|
var _excluded = ["title", "titleId"];
|
|
6
6
|
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
7
7
|
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
@@ -11,20 +11,21 @@ var SvgEmbeddedWalletIcon = function SvgEmbeddedWalletIcon(_ref) {
|
|
|
11
11
|
titleId = _ref.titleId,
|
|
12
12
|
props = _objectWithoutProperties(_ref, _excluded);
|
|
13
13
|
return /*#__PURE__*/React.createElement("svg", _extends({
|
|
14
|
-
width:
|
|
15
|
-
height:
|
|
16
|
-
viewBox: "0 0
|
|
14
|
+
width: 64,
|
|
15
|
+
height: 64,
|
|
16
|
+
viewBox: "0 0 64 64",
|
|
17
17
|
fill: "none",
|
|
18
18
|
xmlns: "http://www.w3.org/2000/svg",
|
|
19
19
|
"aria-labelledby": titleId
|
|
20
20
|
}, props), title ? /*#__PURE__*/React.createElement("title", {
|
|
21
21
|
id: titleId
|
|
22
|
-
}, title) : null,
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
22
|
+
}, title) : null, _path || (_path = /*#__PURE__*/React.createElement("path", {
|
|
23
|
+
fillRule: "evenodd",
|
|
24
|
+
clipRule: "evenodd",
|
|
25
|
+
d: "M32 64c17.673 0 32-14.327 32-32C64 14.327 49.673 0 32 0 14.327 0 0 14.327 0 32c0 17.673 14.327 32 32 32Zm8.334-45.333a3.333 3.333 0 0 0-3.333-3.334h-15a6.669 6.669 0 0 0-6.56 5.473 6.649 6.649 0 0 1 4.893-2.14h20ZM42 22a6.667 6.667 0 0 1 6.667 6.667V42A6.667 6.667 0 0 1 42 48.667H22A6.667 6.667 0 0 1 15.334 42V28.667A6.667 6.667 0 0 1 22 22h20Z",
|
|
26
|
+
fill: "#4779FF",
|
|
27
|
+
"data-testid": "wallet-icon-embedded"
|
|
28
|
+
})));
|
|
28
29
|
};
|
|
29
30
|
|
|
30
31
|
export { SvgEmbeddedWalletIcon as ReactComponent };
|
|
@@ -3,29 +3,15 @@
|
|
|
3
3
|
|
|
4
4
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
5
|
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
const getNativeTokenInfo = (chain, networkInfo) => {
|
|
7
|
+
if (!chain || !chain.name) {
|
|
8
|
+
return;
|
|
9
|
+
}
|
|
10
|
+
const networkData = networkInfo[chain.name.toLowerCase()] || networkInfo['evm'];
|
|
11
|
+
if (!networkData)
|
|
12
|
+
return;
|
|
13
|
+
return networkData.find((e) => e.chainId === (chain === null || chain === void 0 ? void 0 : chain.chainId));
|
|
10
14
|
};
|
|
11
|
-
const networkMap = {
|
|
12
|
-
avalanche: {
|
|
13
|
-
logoURI: 'https://app.dynamic.xyz/assets/networks/avax.svg',
|
|
14
|
-
name: 'Avalanche',
|
|
15
|
-
symbol: 'AVAX',
|
|
16
|
-
},
|
|
17
|
-
polygon: {
|
|
18
|
-
logoURI: 'https://app.dynamic.xyz/assets/networks/polygon.svg',
|
|
19
|
-
name: 'Polygon',
|
|
20
|
-
symbol: 'MATIC',
|
|
21
|
-
},
|
|
22
|
-
solana: {
|
|
23
|
-
logoURI: 'https://app.dynamic.xyz/assets/networks/solana.svg',
|
|
24
|
-
name: 'Solana',
|
|
25
|
-
symbol: 'SOL',
|
|
26
|
-
},
|
|
27
|
-
};
|
|
28
|
-
const getNativeTokenInfo = (blockchain = 'eth') => networkMap[blockchain] || eth;
|
|
29
15
|
const allowedChains = {
|
|
30
16
|
'arbitrum one': 'arbitrum',
|
|
31
17
|
avalanche: 'avalanche',
|
|
@@ -1,9 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { ChainWithIcon } from '../../../widgets/DynamicWidget/hooks/useFetchChain';
|
|
2
|
+
interface NativeCurrency {
|
|
3
|
+
decimals: number;
|
|
3
4
|
name: string;
|
|
4
5
|
symbol: string;
|
|
5
6
|
}
|
|
6
|
-
export
|
|
7
|
+
export interface NetworkInfoEntry {
|
|
8
|
+
chainId: number;
|
|
9
|
+
nativeCurrency: NativeCurrency;
|
|
10
|
+
iconUrls: string[];
|
|
11
|
+
name: string;
|
|
12
|
+
}
|
|
13
|
+
export declare const getNativeTokenInfo: (chain: ChainWithIcon | undefined, networkInfo: Record<string, NetworkInfoEntry[]>) => NetworkInfoEntry | undefined;
|
|
7
14
|
export declare const allowedChains: {
|
|
8
15
|
[key: string]: string;
|
|
9
16
|
};
|
|
@@ -1,27 +1,13 @@
|
|
|
1
1
|
'use client'
|
|
2
|
-
const
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
const getNativeTokenInfo = (chain, networkInfo) => {
|
|
3
|
+
if (!chain || !chain.name) {
|
|
4
|
+
return;
|
|
5
|
+
}
|
|
6
|
+
const networkData = networkInfo[chain.name.toLowerCase()] || networkInfo['evm'];
|
|
7
|
+
if (!networkData)
|
|
8
|
+
return;
|
|
9
|
+
return networkData.find((e) => e.chainId === (chain === null || chain === void 0 ? void 0 : chain.chainId));
|
|
6
10
|
};
|
|
7
|
-
const networkMap = {
|
|
8
|
-
avalanche: {
|
|
9
|
-
logoURI: 'https://app.dynamic.xyz/assets/networks/avax.svg',
|
|
10
|
-
name: 'Avalanche',
|
|
11
|
-
symbol: 'AVAX',
|
|
12
|
-
},
|
|
13
|
-
polygon: {
|
|
14
|
-
logoURI: 'https://app.dynamic.xyz/assets/networks/polygon.svg',
|
|
15
|
-
name: 'Polygon',
|
|
16
|
-
symbol: 'MATIC',
|
|
17
|
-
},
|
|
18
|
-
solana: {
|
|
19
|
-
logoURI: 'https://app.dynamic.xyz/assets/networks/solana.svg',
|
|
20
|
-
name: 'Solana',
|
|
21
|
-
symbol: 'SOL',
|
|
22
|
-
},
|
|
23
|
-
};
|
|
24
|
-
const getNativeTokenInfo = (blockchain = 'eth') => networkMap[blockchain] || eth;
|
|
25
11
|
const allowedChains = {
|
|
26
12
|
'arbitrum one': 'arbitrum',
|
|
27
13
|
avalanche: 'avalanche',
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { ProviderEnum } from '@dynamic-labs/sdk-api-core';
|
|
2
|
+
import { SocialAuthMode } from '../../hooks/useSocialAuth';
|
|
2
3
|
export declare const SOCIAL_STORAGE_KEY = "dynamic_social_storage";
|
|
3
4
|
export type SocialStorageItem = {
|
|
4
5
|
provider: ProviderEnum;
|
|
@@ -10,6 +11,8 @@ export type SocialStorageItem = {
|
|
|
10
11
|
captchaToken?: string;
|
|
11
12
|
/** Oauth code from redirect from oauth provider, this will be provided on response from redirect endpoint **/
|
|
12
13
|
code?: string;
|
|
14
|
+
/** Social auth mode, either sign-in or link */
|
|
15
|
+
mode: SocialAuthMode;
|
|
13
16
|
};
|
|
14
17
|
export type SocialStorage = Partial<Record<ProviderEnum, SocialStorageItem>>;
|
|
15
18
|
export declare const searchSocialStorageByState: (targetState: string) => SocialStorageItem | undefined;
|
|
@@ -362,6 +362,7 @@ const useSocialAuth = ({ sessionTimeout, onSettled, onError, onFarcasterUrl, })
|
|
|
362
362
|
socialStorage.setSocialStorageFor(provider, {
|
|
363
363
|
captchaToken,
|
|
364
364
|
codeVerifier: usingPkce ? verifier : undefined,
|
|
365
|
+
mode: authMode,
|
|
365
366
|
state,
|
|
366
367
|
});
|
|
367
368
|
const loginUrlString = getOauthLoginUrl.getOauthLoginUrl((_d = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.providers) !== null && _d !== void 0 ? _d : [], provider);
|
|
@@ -358,6 +358,7 @@ const useSocialAuth = ({ sessionTimeout, onSettled, onError, onFarcasterUrl, })
|
|
|
358
358
|
setSocialStorageFor(provider, {
|
|
359
359
|
captchaToken,
|
|
360
360
|
codeVerifier: usingPkce ? verifier : undefined,
|
|
361
|
+
mode: authMode,
|
|
361
362
|
state,
|
|
362
363
|
});
|
|
363
364
|
const loginUrlString = getOauthLoginUrl((_d = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.providers) !== null && _d !== void 0 ? _d : [], provider);
|