@dynamic-labs/sdk-react-core 0.18.0-RC.23 → 0.18.0-RC.25
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 +25 -0
- package/package.cjs +1 -1
- package/package.js +1 -1
- package/package.json +8 -8
- package/src/lib/context/DynamicContext/DynamicContext.cjs +5 -7
- package/src/lib/context/DynamicContext/DynamicContext.d.ts +1 -1
- package/src/lib/context/DynamicContext/DynamicContext.js +6 -8
- package/src/lib/context/DynamicContext/types/index.d.ts +1 -1
- package/src/lib/context/SocialRedirectContext/SocialRedirectContext.cjs +2 -2
- package/src/lib/context/SocialRedirectContext/SocialRedirectContext.js +2 -2
- package/src/lib/shared/types/index.d.ts +2 -2
- package/src/lib/utils/functions/generateMessages/index.cjs +3 -3
- package/src/lib/utils/functions/generateMessages/index.d.ts +1 -1
- package/src/lib/utils/functions/generateMessages/index.js +3 -3
- package/src/lib/utils/functions/getVerifyArgs/getVerifyArgs.cjs +2 -2
- package/src/lib/utils/functions/getVerifyArgs/getVerifyArgs.d.ts +3 -3
- package/src/lib/utils/functions/getVerifyArgs/getVerifyArgs.js +2 -2
- package/src/lib/utils/hooks/authenticationHooks/useConnectAndSign/useConnectAndSign.cjs +2 -2
- package/src/lib/utils/hooks/authenticationHooks/useConnectAndSign/useConnectAndSign.js +2 -2
- package/src/lib/utils/hooks/authenticationHooks/useConnectAndSignSplitSteps/useConnectAndSignSplitSteps.cjs +2 -2
- package/src/lib/utils/hooks/authenticationHooks/useConnectAndSignSplitSteps/useConnectAndSignSplitSteps.js +2 -2
- package/src/lib/utils/hooks/authenticationHooks/useSignConnectOnlyUser/useSignConnectOnlyUser.cjs +2 -2
- package/src/lib/utils/hooks/authenticationHooks/useSignConnectOnlyUser/useSignConnectOnlyUser.js +2 -2
- package/src/lib/utils/hooks/useConnectWallet/useConnectWallet.cjs +18 -1
- package/src/lib/utils/hooks/useConnectWallet/useConnectWallet.js +18 -1
- package/src/lib/utils/hooks/useVerifyWallet/useVerifyWallet.cjs +2 -2
- package/src/lib/utils/hooks/useVerifyWallet/useVerifyWallet.d.ts +2 -2
- package/src/lib/utils/hooks/useVerifyWallet/useVerifyWallet.js +2 -2
- package/src/lib/views/CaptchaVerifyUser/CaptchaVerifyUser.cjs +2 -2
- package/src/lib/views/CaptchaVerifyUser/CaptchaVerifyUser.js +2 -2
- package/src/lib/views/WalletUsedView/WalletUsedView.cjs +2 -2
- package/src/lib/views/WalletUsedView/WalletUsedView.js +2 -2
- package/src/lib/widgets/DynamicBridgeWidget/DynamicBridgeWidget.cjs +5 -5
- package/src/lib/widgets/DynamicBridgeWidget/DynamicBridgeWidget.js +5 -5
- package/src/lib/widgets/DynamicBridgeWidget/views/WalletsView/WalletsView.cjs +13 -10
- package/src/lib/widgets/DynamicBridgeWidget/views/WalletsView/WalletsView.js +13 -10
package/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,29 @@
|
|
|
1
1
|
|
|
2
|
+
## [0.18.0-RC.25](https://github.com/dynamic-labs/DynamicAuth/compare/v0.18.0-RC.24...v0.18.0-RC.25) (2023-08-01)
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
### ⚠ BREAKING CHANGES
|
|
6
|
+
|
|
7
|
+
* displayTermsOfService prop set to false breaks message verfication (#2790)
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* always call onBeforeConnectSuccess callback when wallet state ch… ([#2792](https://github.com/dynamic-labs/DynamicAuth/issues/2792)) ([ecc6a7b](https://github.com/dynamic-labs/DynamicAuth/commit/ecc6a7bf3cbee2720860294561ff8dea03d1936e)), closes [#2786](https://github.com/dynamic-labs/DynamicAuth/issues/2786)
|
|
12
|
+
* displayTermsOfService prop set to false breaks message verfication ([#2790](https://github.com/dynamic-labs/DynamicAuth/issues/2790)) ([816e276](https://github.com/dynamic-labs/DynamicAuth/commit/816e276827ac6a89e6ab49afcca00705a07b2ad2)), closes [#2751](https://github.com/dynamic-labs/DynamicAuth/issues/2751)
|
|
13
|
+
* ensure auto-redirect back to dapp after message signing ([#2783](https://github.com/dynamic-labs/DynamicAuth/issues/2783)) ([dba4664](https://github.com/dynamic-labs/DynamicAuth/commit/dba466473ecc2afd808cdae0fd9023d38676b01f))
|
|
14
|
+
|
|
15
|
+
## [0.18.0-RC.24](https://github.com/dynamic-labs/DynamicAuth/compare/v0.18.0-RC.23...v0.18.0-RC.24) (2023-08-01)
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
### Features
|
|
19
|
+
|
|
20
|
+
* **QNTM-156:** onBeforeConnectSuccessConfirmation on account change ([#2782](https://github.com/dynamic-labs/DynamicAuth/issues/2782)) ([eeabcd0](https://github.com/dynamic-labs/DynamicAuth/commit/eeabcd07889b7284680dc92a83bfa1b8321fa0f5))
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
### Bug Fixes
|
|
24
|
+
|
|
25
|
+
* **bridge:** reordering not mess connected wallets ([#2758](https://github.com/dynamic-labs/DynamicAuth/issues/2758)) ([2cdc240](https://github.com/dynamic-labs/DynamicAuth/commit/2cdc240b1f5b401880d776174646ebc9383506d2))
|
|
26
|
+
|
|
2
27
|
## [0.18.0-RC.23](https://github.com/dynamic-labs/DynamicAuth/compare/v0.18.0-RC.22...v0.18.0-RC.23) (2023-07-31)
|
|
3
28
|
|
|
4
29
|
|
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": "0.18.0-RC.
|
|
3
|
+
"version": "0.18.0-RC.25",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/dynamic-labs/DynamicAuth.git",
|
|
@@ -16,13 +16,13 @@
|
|
|
16
16
|
"formik": "2.2.9",
|
|
17
17
|
"qrcode": "1.5.1",
|
|
18
18
|
"ethers": "5.7.2",
|
|
19
|
-
"@dynamic-labs/logger": "0.18.0-RC.
|
|
20
|
-
"@dynamic-labs/multi-wallet": "0.18.0-RC.
|
|
21
|
-
"@dynamic-labs/rpc-providers": "0.18.0-RC.
|
|
22
|
-
"@dynamic-labs/types": "0.18.0-RC.
|
|
23
|
-
"@dynamic-labs/utils": "0.18.0-RC.
|
|
24
|
-
"@dynamic-labs/wallet-book": "0.18.0-RC.
|
|
25
|
-
"@dynamic-labs/wallet-connector-core": "0.18.0-RC.
|
|
19
|
+
"@dynamic-labs/logger": "0.18.0-RC.25",
|
|
20
|
+
"@dynamic-labs/multi-wallet": "0.18.0-RC.25",
|
|
21
|
+
"@dynamic-labs/rpc-providers": "0.18.0-RC.25",
|
|
22
|
+
"@dynamic-labs/types": "0.18.0-RC.25",
|
|
23
|
+
"@dynamic-labs/utils": "0.18.0-RC.25",
|
|
24
|
+
"@dynamic-labs/wallet-book": "0.18.0-RC.25",
|
|
25
|
+
"@dynamic-labs/wallet-connector-core": "0.18.0-RC.25"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
28
|
"semver": "7.3.8"
|
|
@@ -21,7 +21,6 @@ var localStorage = require('../../shared/utils/classes/storage/localStorage.cjs'
|
|
|
21
21
|
require('ethers');
|
|
22
22
|
var useLocalStorage = require('../../shared/utils/hooks/useLocalStorage/useLocalStorage.cjs');
|
|
23
23
|
var useGlobalLoading = require('../../shared/utils/hooks/useGlobalLoading/useGlobalLoading.cjs');
|
|
24
|
-
var useEffectOnce = require('../../shared/utils/hooks/useEffectOnce/useEffectOnce.cjs');
|
|
25
24
|
require('../../shared/consts/index.cjs');
|
|
26
25
|
require('react-dom');
|
|
27
26
|
require('react-focus-lock');
|
|
@@ -80,7 +79,6 @@ require('../../views/CollectUserDataView/fieldsConfig.cjs');
|
|
|
80
79
|
require('../../components/UserProfile/parts/UserProfileField/components/VerifiedEmailIcon/VerifiedEmailIcon.cjs');
|
|
81
80
|
var FundingWidget = require('../../widgets/FundingWidget/FundingWidget.cjs');
|
|
82
81
|
var DynamicBridgeWidgetContext = require('../../widgets/DynamicBridgeWidget/context/DynamicBridgeWidgetContext/DynamicBridgeWidgetContext.cjs');
|
|
83
|
-
require('../../widgets/DynamicBridgeWidget/views/WalletsView/components/SecondaryWallets/SecondaryWallets.cjs');
|
|
84
82
|
var EmailVerificationContext = require('../EmailVerificationContext/EmailVerificationContext.cjs');
|
|
85
83
|
var FundingContext = require('../FundingContext/FundingContext.cjs');
|
|
86
84
|
var SendBalanceContext = require('../SendBalanceContext/SendBalanceContext.cjs');
|
|
@@ -101,7 +99,7 @@ const EMPTY_INITIAL_USER = undefined;
|
|
|
101
99
|
const DynamicContext = React.createContext(undefined);
|
|
102
100
|
const DynamicContextProvider = ({ children, theme, settings, }) => {
|
|
103
101
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
104
|
-
const { accessDeniedMessagePrimary, accessDeniedMessageSecondary, accessDeniedButton, apiBaseUrl, walletsByChain, cssOverrides, defaultNumberOfWalletsToShow = values.DEFAULT_NUMBER_OF_WALLETS_TO_SHOW, flowNetwork, initialAuthenticationMode = 'connect-and-sign', debugError = false,
|
|
102
|
+
const { accessDeniedMessagePrimary, accessDeniedMessageSecondary, accessDeniedButton, apiBaseUrl, walletsByChain, cssOverrides, defaultNumberOfWalletsToShow = values.DEFAULT_NUMBER_OF_WALLETS_TO_SHOW, flowNetwork, initialAuthenticationMode = 'connect-and-sign', debugError = false, displaySiweStatement = true, newToWeb3WalletChainMap, enableVisitTrackingOnConnectOnly = true, environmentId, localStorageSuffix, eventsCallbacks, evmNetworks, walletsFilter, logLevel = 'WARN', multiWallet: deprecatedMultiWallet, notInTheListImageUrl, onboardingImageUrl, policiesConsentInnerComponent, customPrivacyPolicy, privacyPolicyUrl, signWithEmailWalletName, socialMediaLinkText, socialMediaIconUrl, socialMediaUrl, customTermsOfServices, termsOfServiceUrl, toolkitEnabled, siweStatement, shadowDOMEnabled = true, walletConnectors: walletConnectorsProp, socialProvidersFilter, } = settings;
|
|
105
103
|
let { walletConnectV1Bridge, appLogoUrl = 'https://demo.dynamic.xyz/assets/dynamic-logo.svg', appName = 'Dynamic Example', } = settings;
|
|
106
104
|
if (!environmentId) {
|
|
107
105
|
throw new utils.MissingEnvironmentIdError();
|
|
@@ -199,10 +197,10 @@ const DynamicContextProvider = ({ children, theme, settings, }) => {
|
|
|
199
197
|
setShowAuthFlow,
|
|
200
198
|
wallets,
|
|
201
199
|
});
|
|
202
|
-
|
|
200
|
+
React.useEffect(() => {
|
|
203
201
|
const missingChains = getMissingChains.getMissingChains(walletsByChain, connectedWalletsInfo);
|
|
204
202
|
setWalletsToConnectByChain(missingChains);
|
|
205
|
-
});
|
|
203
|
+
}, [walletsByChain]);
|
|
206
204
|
const [selectedWalletConnector, setSelectedWalletConnector] = React.useState(null);
|
|
207
205
|
//selected wallet to perform an action (become primary, unlink, etc)
|
|
208
206
|
const [selectedWalletWithAction, setSelectedWalletWithAction] = React.useState(null);
|
|
@@ -428,7 +426,7 @@ const DynamicContextProvider = ({ children, theme, settings, }) => {
|
|
|
428
426
|
decodedOnboardingOnlyToken: decodeJwt.decodeJwt(onboardingOnlyJwt),
|
|
429
427
|
defaultNumberOfWalletsToShow,
|
|
430
428
|
desktopUri,
|
|
431
|
-
|
|
429
|
+
displaySiweStatement,
|
|
432
430
|
environmentId,
|
|
433
431
|
eventsCallbacks,
|
|
434
432
|
getConnectedWalletById,
|
|
@@ -542,7 +540,7 @@ const DynamicContextProvider = ({ children, theme, settings, }) => {
|
|
|
542
540
|
onboardingOnlyJwt,
|
|
543
541
|
defaultNumberOfWalletsToShow,
|
|
544
542
|
desktopUri,
|
|
545
|
-
|
|
543
|
+
displaySiweStatement,
|
|
546
544
|
environmentId,
|
|
547
545
|
eventsCallbacks,
|
|
548
546
|
getConnectedWalletById,
|
|
@@ -20,7 +20,7 @@ export interface DynamicContextProps {
|
|
|
20
20
|
cssOverrides?: string | JSX.Element;
|
|
21
21
|
debugError?: boolean;
|
|
22
22
|
defaultNumberOfWalletsToShow?: number;
|
|
23
|
-
|
|
23
|
+
displaySiweStatement?: boolean;
|
|
24
24
|
enableVisitTrackingOnConnectOnly?: boolean;
|
|
25
25
|
environmentId: string;
|
|
26
26
|
localStorageSuffix?: string;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { __awaiter } from '../../../../_virtual/_tslib.js';
|
|
2
2
|
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
3
|
-
import { createContext, useState,
|
|
3
|
+
import { createContext, useState, useEffect, useCallback, useMemo } from 'react';
|
|
4
4
|
import { ICONIC_SPRITE_URL } from '@dynamic-labs/iconic';
|
|
5
5
|
import { MissingEnvironmentIdError } from '@dynamic-labs/utils';
|
|
6
6
|
import { useWalletBookCdn, getWalletBookCdnUrl, WalletBookContextProvider } from '@dynamic-labs/wallet-book';
|
|
@@ -17,7 +17,6 @@ import { LocalStorage } from '../../shared/utils/classes/storage/localStorage.js
|
|
|
17
17
|
import 'ethers';
|
|
18
18
|
import { useLocalStorage } from '../../shared/utils/hooks/useLocalStorage/useLocalStorage.js';
|
|
19
19
|
import { useGlobalLoading } from '../../shared/utils/hooks/useGlobalLoading/useGlobalLoading.js';
|
|
20
|
-
import { useEffectOnce } from '../../shared/utils/hooks/useEffectOnce/useEffectOnce.js';
|
|
21
20
|
import '../../shared/consts/index.js';
|
|
22
21
|
import 'react-dom';
|
|
23
22
|
import 'react-focus-lock';
|
|
@@ -76,7 +75,6 @@ import '../../views/CollectUserDataView/fieldsConfig.js';
|
|
|
76
75
|
import '../../components/UserProfile/parts/UserProfileField/components/VerifiedEmailIcon/VerifiedEmailIcon.js';
|
|
77
76
|
import { FundingWidget } from '../../widgets/FundingWidget/FundingWidget.js';
|
|
78
77
|
import { DynamicBridgeWidgetContextProvider } from '../../widgets/DynamicBridgeWidget/context/DynamicBridgeWidgetContext/DynamicBridgeWidgetContext.js';
|
|
79
|
-
import '../../widgets/DynamicBridgeWidget/views/WalletsView/components/SecondaryWallets/SecondaryWallets.js';
|
|
80
78
|
import { EmailVerificationContextProvider } from '../EmailVerificationContext/EmailVerificationContext.js';
|
|
81
79
|
import { FundingContextProvider } from '../FundingContext/FundingContext.js';
|
|
82
80
|
import { SendBalanceContextProvider } from '../SendBalanceContext/SendBalanceContext.js';
|
|
@@ -97,7 +95,7 @@ const EMPTY_INITIAL_USER = undefined;
|
|
|
97
95
|
const DynamicContext = createContext(undefined);
|
|
98
96
|
const DynamicContextProvider = ({ children, theme, settings, }) => {
|
|
99
97
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
100
|
-
const { accessDeniedMessagePrimary, accessDeniedMessageSecondary, accessDeniedButton, apiBaseUrl, walletsByChain, cssOverrides, defaultNumberOfWalletsToShow = DEFAULT_NUMBER_OF_WALLETS_TO_SHOW, flowNetwork, initialAuthenticationMode = 'connect-and-sign', debugError = false,
|
|
98
|
+
const { accessDeniedMessagePrimary, accessDeniedMessageSecondary, accessDeniedButton, apiBaseUrl, walletsByChain, cssOverrides, defaultNumberOfWalletsToShow = DEFAULT_NUMBER_OF_WALLETS_TO_SHOW, flowNetwork, initialAuthenticationMode = 'connect-and-sign', debugError = false, displaySiweStatement = true, newToWeb3WalletChainMap, enableVisitTrackingOnConnectOnly = true, environmentId, localStorageSuffix, eventsCallbacks, evmNetworks, walletsFilter, logLevel = 'WARN', multiWallet: deprecatedMultiWallet, notInTheListImageUrl, onboardingImageUrl, policiesConsentInnerComponent, customPrivacyPolicy, privacyPolicyUrl, signWithEmailWalletName, socialMediaLinkText, socialMediaIconUrl, socialMediaUrl, customTermsOfServices, termsOfServiceUrl, toolkitEnabled, siweStatement, shadowDOMEnabled = true, walletConnectors: walletConnectorsProp, socialProvidersFilter, } = settings;
|
|
101
99
|
let { walletConnectV1Bridge, appLogoUrl = 'https://demo.dynamic.xyz/assets/dynamic-logo.svg', appName = 'Dynamic Example', } = settings;
|
|
102
100
|
if (!environmentId) {
|
|
103
101
|
throw new MissingEnvironmentIdError();
|
|
@@ -195,10 +193,10 @@ const DynamicContextProvider = ({ children, theme, settings, }) => {
|
|
|
195
193
|
setShowAuthFlow,
|
|
196
194
|
wallets,
|
|
197
195
|
});
|
|
198
|
-
|
|
196
|
+
useEffect(() => {
|
|
199
197
|
const missingChains = getMissingChains(walletsByChain, connectedWalletsInfo);
|
|
200
198
|
setWalletsToConnectByChain(missingChains);
|
|
201
|
-
});
|
|
199
|
+
}, [walletsByChain]);
|
|
202
200
|
const [selectedWalletConnector, setSelectedWalletConnector] = useState(null);
|
|
203
201
|
//selected wallet to perform an action (become primary, unlink, etc)
|
|
204
202
|
const [selectedWalletWithAction, setSelectedWalletWithAction] = useState(null);
|
|
@@ -424,7 +422,7 @@ const DynamicContextProvider = ({ children, theme, settings, }) => {
|
|
|
424
422
|
decodedOnboardingOnlyToken: decodeJwt(onboardingOnlyJwt),
|
|
425
423
|
defaultNumberOfWalletsToShow,
|
|
426
424
|
desktopUri,
|
|
427
|
-
|
|
425
|
+
displaySiweStatement,
|
|
428
426
|
environmentId,
|
|
429
427
|
eventsCallbacks,
|
|
430
428
|
getConnectedWalletById,
|
|
@@ -538,7 +536,7 @@ const DynamicContextProvider = ({ children, theme, settings, }) => {
|
|
|
538
536
|
onboardingOnlyJwt,
|
|
539
537
|
defaultNumberOfWalletsToShow,
|
|
540
538
|
desktopUri,
|
|
541
|
-
|
|
539
|
+
displaySiweStatement,
|
|
542
540
|
environmentId,
|
|
543
541
|
eventsCallbacks,
|
|
544
542
|
getConnectedWalletById,
|
|
@@ -47,7 +47,7 @@ export interface IDynamicContext {
|
|
|
47
47
|
walletsToConnectByChain: ChainsToConnect[] | undefined;
|
|
48
48
|
setWalletsToConnectByChain: Dispatch<SetStateAction<ChainsToConnect[] | undefined>>;
|
|
49
49
|
desktopUri: string;
|
|
50
|
-
|
|
50
|
+
displaySiweStatement: boolean;
|
|
51
51
|
environmentId: string;
|
|
52
52
|
eventsCallbacks?: DynamicEventsCallbacks;
|
|
53
53
|
getConnectedWalletById: (walletId: string) => Wallet | undefined;
|
|
@@ -46,12 +46,12 @@ require('../../utils/hooks/useUserUpdateRequest/useUserUpdateRequest.cjs');
|
|
|
46
46
|
const SocialRedirectContext = React.createContext(undefined);
|
|
47
47
|
const SocialRedirectContextProvider = ({ children, }) => {
|
|
48
48
|
var _a, _b;
|
|
49
|
-
const { setShowAuthFlow, wallets, setSelectedWalletConnector, walletUiUtils, consumeNonce,
|
|
49
|
+
const { setShowAuthFlow, wallets, setSelectedWalletConnector, walletUiUtils, consumeNonce, displaySiweStatement, environmentId, projectSettings, setIsSingleWalletAccount, setShowDynamicUserProfile, isAuthenticated, setPrimaryWalletId, secondaryWallets, sdkHasLoaded, authToken, } = useInternalDynamicContext.useInternalDynamicContext();
|
|
50
50
|
const { setErrorMessage } = ErrorContext.useErrorContext();
|
|
51
51
|
const { setView } = ViewContext.useViewContext();
|
|
52
52
|
const verifyWallet = useVerifyWallet.useVerifyWallet({
|
|
53
53
|
consumeNonce,
|
|
54
|
-
|
|
54
|
+
displaySiweStatement,
|
|
55
55
|
environmentId,
|
|
56
56
|
projectSettings,
|
|
57
57
|
setIsSingleWalletAccount,
|
|
@@ -42,12 +42,12 @@ import '../../utils/hooks/useUserUpdateRequest/useUserUpdateRequest.js';
|
|
|
42
42
|
const SocialRedirectContext = createContext(undefined);
|
|
43
43
|
const SocialRedirectContextProvider = ({ children, }) => {
|
|
44
44
|
var _a, _b;
|
|
45
|
-
const { setShowAuthFlow, wallets, setSelectedWalletConnector, walletUiUtils, consumeNonce,
|
|
45
|
+
const { setShowAuthFlow, wallets, setSelectedWalletConnector, walletUiUtils, consumeNonce, displaySiweStatement, environmentId, projectSettings, setIsSingleWalletAccount, setShowDynamicUserProfile, isAuthenticated, setPrimaryWalletId, secondaryWallets, sdkHasLoaded, authToken, } = useInternalDynamicContext();
|
|
46
46
|
const { setErrorMessage } = useErrorContext();
|
|
47
47
|
const { setView } = useViewContext();
|
|
48
48
|
const verifyWallet = useVerifyWallet({
|
|
49
49
|
consumeNonce,
|
|
50
|
-
|
|
50
|
+
displaySiweStatement,
|
|
51
51
|
environmentId,
|
|
52
52
|
projectSettings,
|
|
53
53
|
setIsSingleWalletAccount,
|
|
@@ -80,7 +80,7 @@ export interface ProjectSettingsProps {
|
|
|
80
80
|
export type WalletProvider = `${WalletProviderEnum}`;
|
|
81
81
|
export interface VerifyWallet {
|
|
82
82
|
captchaToken?: string;
|
|
83
|
-
chain: string;
|
|
83
|
+
chain: string | undefined;
|
|
84
84
|
messageToSign: string;
|
|
85
85
|
network: string | number | undefined;
|
|
86
86
|
oauth?: OauthProviderRequest;
|
|
@@ -102,7 +102,7 @@ export type OnAuthSuccess = (params: {
|
|
|
102
102
|
export type OnConnectSuccess = (params: {
|
|
103
103
|
walletConnector: WalletConnector | null;
|
|
104
104
|
}) => void;
|
|
105
|
-
export type OnBeforeConnectSuccessConfirmation = (
|
|
105
|
+
export type OnBeforeConnectSuccessConfirmation = (wallet: Partial<Wallet>) => Promise<boolean>;
|
|
106
106
|
export type OnUserProfileUpdate = (user: UserProfile) => void;
|
|
107
107
|
export type MultiWalletWidgetState = 'idle' | 'awaiting_account_switch' | 'awaiting_connection' | 'awaiting_signature' | 'detected_new_wallet';
|
|
108
108
|
export type AccountSwitchState = 'idle' | 'linking_new_wallet' | 'switching_primary' | 'primary_not_connected';
|
|
@@ -6,7 +6,7 @@ var _tslib = require('../../../../../_virtual/_tslib.cjs');
|
|
|
6
6
|
var multiWallet = require('@dynamic-labs/multi-wallet');
|
|
7
7
|
var utils = require('@dynamic-labs/utils');
|
|
8
8
|
|
|
9
|
-
const generateMessages = (publicWalletAddress, walletConnector, nonce, projectEnvironmentId,
|
|
9
|
+
const generateMessages = (publicWalletAddress, walletConnector, nonce, projectEnvironmentId, displaySiweStatement, siweStatement) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
10
10
|
if (publicWalletAddress === undefined) {
|
|
11
11
|
throw new utils.DynamicError('Unable to fetch the public address from the wallet');
|
|
12
12
|
}
|
|
@@ -30,9 +30,9 @@ const generateMessages = (publicWalletAddress, walletConnector, nonce, projectEn
|
|
|
30
30
|
publicKey: publicWalletAddress,
|
|
31
31
|
requestId: projectEnvironmentId,
|
|
32
32
|
resources: walletConnector.providerResources,
|
|
33
|
-
statement:
|
|
33
|
+
statement: displaySiweStatement
|
|
34
34
|
? siweStatement.replace(/(\r\n|\n|\r)/gm, ' ').trim()
|
|
35
|
-
:
|
|
35
|
+
: undefined,
|
|
36
36
|
uri: window.location.href,
|
|
37
37
|
});
|
|
38
38
|
const signedMessage = yield walletConnector.proveOwnership(messageToSign);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { WalletConnector } from '@dynamic-labs/wallet-connector-core';
|
|
2
|
-
export declare const generateMessages: (publicWalletAddress: string | undefined, walletConnector: WalletConnector, nonce: string, projectEnvironmentId: string,
|
|
2
|
+
export declare const generateMessages: (publicWalletAddress: string | undefined, walletConnector: WalletConnector, nonce: string, projectEnvironmentId: string, displaySiweStatement: boolean, siweStatement: string) => Promise<{
|
|
3
3
|
messageToSign: string;
|
|
4
4
|
signedMessage: string;
|
|
5
5
|
}>;
|
|
@@ -2,7 +2,7 @@ import { __awaiter } from '../../../../../_virtual/_tslib.js';
|
|
|
2
2
|
import { generateMessageToSign } from '@dynamic-labs/multi-wallet';
|
|
3
3
|
import { DynamicError } from '@dynamic-labs/utils';
|
|
4
4
|
|
|
5
|
-
const generateMessages = (publicWalletAddress, walletConnector, nonce, projectEnvironmentId,
|
|
5
|
+
const generateMessages = (publicWalletAddress, walletConnector, nonce, projectEnvironmentId, displaySiweStatement, siweStatement) => __awaiter(void 0, void 0, void 0, function* () {
|
|
6
6
|
if (publicWalletAddress === undefined) {
|
|
7
7
|
throw new DynamicError('Unable to fetch the public address from the wallet');
|
|
8
8
|
}
|
|
@@ -26,9 +26,9 @@ const generateMessages = (publicWalletAddress, walletConnector, nonce, projectEn
|
|
|
26
26
|
publicKey: publicWalletAddress,
|
|
27
27
|
requestId: projectEnvironmentId,
|
|
28
28
|
resources: walletConnector.providerResources,
|
|
29
|
-
statement:
|
|
29
|
+
statement: displaySiweStatement
|
|
30
30
|
? siweStatement.replace(/(\r\n|\n|\r)/gm, ' ').trim()
|
|
31
|
-
:
|
|
31
|
+
: undefined,
|
|
32
32
|
uri: window.location.href,
|
|
33
33
|
});
|
|
34
34
|
const signedMessage = yield walletConnector.proveOwnership(messageToSign);
|
|
@@ -6,7 +6,7 @@ var _tslib = require('../../../../../_virtual/_tslib.cjs');
|
|
|
6
6
|
var index = require('../generateMessages/index.cjs');
|
|
7
7
|
|
|
8
8
|
// TODO - This function is doing too much we should split it up.
|
|
9
|
-
const getVerifyArgs = ({ walletConnector, nonce, walletProvider, environmentId,
|
|
9
|
+
const getVerifyArgs = ({ walletConnector, nonce, walletProvider, environmentId, displaySiweStatement, skipEmptyAccountCheck, siweStatement, publicWalletAddress, }) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
10
10
|
// WARNING - PLEASE READ!
|
|
11
11
|
// DO NOT ADD ANY NEW ASYNC WORK WITH AWAIT!
|
|
12
12
|
// Deep linking could break with too many blocking awaits
|
|
@@ -15,7 +15,7 @@ const getVerifyArgs = ({ walletConnector, nonce, walletProvider, environmentId,
|
|
|
15
15
|
// instead of the actual wallet app.
|
|
16
16
|
const chain = walletConnector.connectedChain;
|
|
17
17
|
// generate message to sign and then initiate signing step to prove ownership
|
|
18
|
-
const { messageToSign, signedMessage } = yield index.generateMessages(publicWalletAddress, walletConnector, nonce, environmentId,
|
|
18
|
+
const { messageToSign, signedMessage } = yield index.generateMessages(publicWalletAddress, walletConnector, nonce, environmentId, displaySiweStatement, siweStatement);
|
|
19
19
|
const network = String(yield walletConnector.getNetwork());
|
|
20
20
|
return {
|
|
21
21
|
chain,
|
|
@@ -2,7 +2,7 @@ import { FetchPublicAddressOpts } from '@dynamic-labs/wallet-connector-core';
|
|
|
2
2
|
import { WalletConnector } from '../../../..';
|
|
3
3
|
import { WalletProvider } from '../../../shared';
|
|
4
4
|
type Props = {
|
|
5
|
-
|
|
5
|
+
displaySiweStatement: boolean;
|
|
6
6
|
environmentId: string;
|
|
7
7
|
fetchPublicAddressOpts?: FetchPublicAddressOpts;
|
|
8
8
|
nonce: string;
|
|
@@ -12,8 +12,8 @@ type Props = {
|
|
|
12
12
|
walletConnector: WalletConnector;
|
|
13
13
|
walletProvider: WalletProvider;
|
|
14
14
|
};
|
|
15
|
-
export declare const getVerifyArgs: ({ walletConnector, nonce, walletProvider, environmentId,
|
|
16
|
-
chain: "ETH" | "FLOW" | "SOL" | "EVM" | "ALGO" | "STARK" | "ATOM" | "COSMOS";
|
|
15
|
+
export declare const getVerifyArgs: ({ walletConnector, nonce, walletProvider, environmentId, displaySiweStatement, skipEmptyAccountCheck, siweStatement, publicWalletAddress, }: Props) => Promise<{
|
|
16
|
+
chain: "ETH" | "FLOW" | "SOL" | "EVM" | "ALGO" | "STARK" | "ATOM" | "COSMOS" | undefined;
|
|
17
17
|
messageToSign: string;
|
|
18
18
|
network: string;
|
|
19
19
|
publicWalletAddress: string;
|
|
@@ -2,7 +2,7 @@ import { __awaiter } from '../../../../../_virtual/_tslib.js';
|
|
|
2
2
|
import { generateMessages } from '../generateMessages/index.js';
|
|
3
3
|
|
|
4
4
|
// TODO - This function is doing too much we should split it up.
|
|
5
|
-
const getVerifyArgs = ({ walletConnector, nonce, walletProvider, environmentId,
|
|
5
|
+
const getVerifyArgs = ({ walletConnector, nonce, walletProvider, environmentId, displaySiweStatement, skipEmptyAccountCheck, siweStatement, publicWalletAddress, }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
6
6
|
// WARNING - PLEASE READ!
|
|
7
7
|
// DO NOT ADD ANY NEW ASYNC WORK WITH AWAIT!
|
|
8
8
|
// Deep linking could break with too many blocking awaits
|
|
@@ -11,7 +11,7 @@ const getVerifyArgs = ({ walletConnector, nonce, walletProvider, environmentId,
|
|
|
11
11
|
// instead of the actual wallet app.
|
|
12
12
|
const chain = walletConnector.connectedChain;
|
|
13
13
|
// generate message to sign and then initiate signing step to prove ownership
|
|
14
|
-
const { messageToSign, signedMessage } = yield generateMessages(publicWalletAddress, walletConnector, nonce, environmentId,
|
|
14
|
+
const { messageToSign, signedMessage } = yield generateMessages(publicWalletAddress, walletConnector, nonce, environmentId, displaySiweStatement, siweStatement);
|
|
15
15
|
const network = String(yield walletConnector.getNetwork());
|
|
16
16
|
return {
|
|
17
17
|
chain,
|
|
@@ -32,11 +32,11 @@ const useConnectAndSign = () => {
|
|
|
32
32
|
const { setView, goToInitialView } = ViewContext.useViewContext();
|
|
33
33
|
const { setErrorMessage } = ErrorContext.useErrorContext();
|
|
34
34
|
const { captchaToken } = CaptchaContext.useCaptchaContext();
|
|
35
|
-
const { authMode, connectWallet, consumeNonce,
|
|
35
|
+
const { authMode, connectWallet, consumeNonce, displaySiweStatement, environmentId, projectSettings, setIsSingleWalletAccount, user, walletUiUtils, setCallback, setIsVerificationInProgress, isFullyConnected, } = useInternalDynamicContext.useInternalDynamicContext();
|
|
36
36
|
const { handleWalletsToConnect } = useHandleWalletsToConnect.useHandleWalletsToConnect();
|
|
37
37
|
const verifyWallet = useVerifyWallet.useVerifyWallet({
|
|
38
38
|
consumeNonce,
|
|
39
|
-
|
|
39
|
+
displaySiweStatement,
|
|
40
40
|
environmentId,
|
|
41
41
|
projectSettings,
|
|
42
42
|
setIsSingleWalletAccount,
|
|
@@ -28,11 +28,11 @@ const useConnectAndSign = () => {
|
|
|
28
28
|
const { setView, goToInitialView } = useViewContext();
|
|
29
29
|
const { setErrorMessage } = useErrorContext();
|
|
30
30
|
const { captchaToken } = useCaptchaContext();
|
|
31
|
-
const { authMode, connectWallet, consumeNonce,
|
|
31
|
+
const { authMode, connectWallet, consumeNonce, displaySiweStatement, environmentId, projectSettings, setIsSingleWalletAccount, user, walletUiUtils, setCallback, setIsVerificationInProgress, isFullyConnected, } = useInternalDynamicContext();
|
|
32
32
|
const { handleWalletsToConnect } = useHandleWalletsToConnect();
|
|
33
33
|
const verifyWallet = useVerifyWallet({
|
|
34
34
|
consumeNonce,
|
|
35
|
-
|
|
35
|
+
displaySiweStatement,
|
|
36
36
|
environmentId,
|
|
37
37
|
projectSettings,
|
|
38
38
|
setIsSingleWalletAccount,
|
|
@@ -29,11 +29,11 @@ const useConnectAndSignSplitSteps = () => {
|
|
|
29
29
|
const { setView, goToInitialView } = ViewContext.useViewContext();
|
|
30
30
|
const { setErrorMessage } = ErrorContext.useErrorContext();
|
|
31
31
|
const { captchaToken } = CaptchaContext.useCaptchaContext();
|
|
32
|
-
const { connectWallet, consumeNonce,
|
|
32
|
+
const { connectWallet, consumeNonce, displaySiweStatement, projectSettings, environmentId, setIsSingleWalletAccount, setShowAuthFlow, user, authMode, setCallback, setIsVerificationInProgress, } = useInternalDynamicContext.useInternalDynamicContext();
|
|
33
33
|
const { handleWalletsToConnect } = useHandleWalletsToConnect.useHandleWalletsToConnect();
|
|
34
34
|
const verifyWallet = useVerifyWallet.useVerifyWallet({
|
|
35
35
|
consumeNonce,
|
|
36
|
-
|
|
36
|
+
displaySiweStatement,
|
|
37
37
|
environmentId,
|
|
38
38
|
projectSettings,
|
|
39
39
|
setIsSingleWalletAccount,
|
|
@@ -25,11 +25,11 @@ const useConnectAndSignSplitSteps = () => {
|
|
|
25
25
|
const { setView, goToInitialView } = useViewContext();
|
|
26
26
|
const { setErrorMessage } = useErrorContext();
|
|
27
27
|
const { captchaToken } = useCaptchaContext();
|
|
28
|
-
const { connectWallet, consumeNonce,
|
|
28
|
+
const { connectWallet, consumeNonce, displaySiweStatement, projectSettings, environmentId, setIsSingleWalletAccount, setShowAuthFlow, user, authMode, setCallback, setIsVerificationInProgress, } = useInternalDynamicContext();
|
|
29
29
|
const { handleWalletsToConnect } = useHandleWalletsToConnect();
|
|
30
30
|
const verifyWallet = useVerifyWallet({
|
|
31
31
|
consumeNonce,
|
|
32
|
-
|
|
32
|
+
displaySiweStatement,
|
|
33
33
|
environmentId,
|
|
34
34
|
projectSettings,
|
|
35
35
|
setIsSingleWalletAccount,
|
package/src/lib/utils/hooks/authenticationHooks/useSignConnectOnlyUser/useSignConnectOnlyUser.cjs
CHANGED
|
@@ -23,10 +23,10 @@ require('../../../../shared/consts/index.cjs');
|
|
|
23
23
|
const useSignConnectOnlyUser = () => {
|
|
24
24
|
const { setView } = ViewContext.useViewContext();
|
|
25
25
|
const { setErrorMessage } = ErrorContext.useErrorContext();
|
|
26
|
-
const { connectWallet, consumeNonce,
|
|
26
|
+
const { connectWallet, consumeNonce, displaySiweStatement, projectSettings, environmentId, setIsSingleWalletAccount, setShowAuthFlow, setSelectedWalletConnector, } = useInternalDynamicContext.useInternalDynamicContext();
|
|
27
27
|
const verifyWallet = useVerifyWallet.useVerifyWallet({
|
|
28
28
|
consumeNonce,
|
|
29
|
-
|
|
29
|
+
displaySiweStatement,
|
|
30
30
|
environmentId,
|
|
31
31
|
projectSettings,
|
|
32
32
|
setIsSingleWalletAccount,
|
package/src/lib/utils/hooks/authenticationHooks/useSignConnectOnlyUser/useSignConnectOnlyUser.js
CHANGED
|
@@ -19,10 +19,10 @@ import '../../../../shared/consts/index.js';
|
|
|
19
19
|
const useSignConnectOnlyUser = () => {
|
|
20
20
|
const { setView } = useViewContext();
|
|
21
21
|
const { setErrorMessage } = useErrorContext();
|
|
22
|
-
const { connectWallet, consumeNonce,
|
|
22
|
+
const { connectWallet, consumeNonce, displaySiweStatement, projectSettings, environmentId, setIsSingleWalletAccount, setShowAuthFlow, setSelectedWalletConnector, } = useInternalDynamicContext();
|
|
23
23
|
const verifyWallet = useVerifyWallet({
|
|
24
24
|
consumeNonce,
|
|
25
|
-
|
|
25
|
+
displaySiweStatement,
|
|
26
26
|
environmentId,
|
|
27
27
|
projectSettings,
|
|
28
28
|
setIsSingleWalletAccount,
|
|
@@ -107,6 +107,19 @@ const useConnectWallet = ({ authMode, clearPrimaryWalletId, enableVisitTrackingO
|
|
|
107
107
|
yield walletConnector.connect();
|
|
108
108
|
}
|
|
109
109
|
const currentWalletConnectorAddress = yield walletConnector.fetchPublicAddress();
|
|
110
|
+
if (onBeforeConnectSuccessConfirmation) {
|
|
111
|
+
const shouldProceedWithConnection = yield onBeforeConnectSuccessConfirmation({
|
|
112
|
+
address: currentWalletConnectorAddress,
|
|
113
|
+
chain: walletConnector.connectedChain,
|
|
114
|
+
connector: walletConnector,
|
|
115
|
+
});
|
|
116
|
+
if (!shouldProceedWithConnection) {
|
|
117
|
+
walletConnectorCore.logger.info('Connection was not established because onBeforeConnectSuccessConfirmation returned false');
|
|
118
|
+
unlinkConnectedWallet(walletId);
|
|
119
|
+
setShowAuthFlow(false);
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
110
123
|
if (!currentWalletConnectorAddress) {
|
|
111
124
|
walletConnectorCore.logger.error('Could not refresh the wallet. The wallet address is not available');
|
|
112
125
|
return;
|
|
@@ -127,7 +140,11 @@ const useConnectWallet = ({ authMode, clearPrimaryWalletId, enableVisitTrackingO
|
|
|
127
140
|
throw error;
|
|
128
141
|
}
|
|
129
142
|
if (onBeforeConnectSuccessConfirmation) {
|
|
130
|
-
const shouldProceedWithConnection = yield onBeforeConnectSuccessConfirmation(
|
|
143
|
+
const shouldProceedWithConnection = yield onBeforeConnectSuccessConfirmation({
|
|
144
|
+
address: publicWalletAddress,
|
|
145
|
+
chain: walletConnector.connectedChain,
|
|
146
|
+
connector: walletConnector,
|
|
147
|
+
});
|
|
131
148
|
if (!shouldProceedWithConnection) {
|
|
132
149
|
walletConnectorCore.logger.info('Connection was not established because onBeforeConnectSuccessConfirmation returned false');
|
|
133
150
|
setShowAuthFlow(false);
|
|
@@ -103,6 +103,19 @@ const useConnectWallet = ({ authMode, clearPrimaryWalletId, enableVisitTrackingO
|
|
|
103
103
|
yield walletConnector.connect();
|
|
104
104
|
}
|
|
105
105
|
const currentWalletConnectorAddress = yield walletConnector.fetchPublicAddress();
|
|
106
|
+
if (onBeforeConnectSuccessConfirmation) {
|
|
107
|
+
const shouldProceedWithConnection = yield onBeforeConnectSuccessConfirmation({
|
|
108
|
+
address: currentWalletConnectorAddress,
|
|
109
|
+
chain: walletConnector.connectedChain,
|
|
110
|
+
connector: walletConnector,
|
|
111
|
+
});
|
|
112
|
+
if (!shouldProceedWithConnection) {
|
|
113
|
+
logger.info('Connection was not established because onBeforeConnectSuccessConfirmation returned false');
|
|
114
|
+
unlinkConnectedWallet(walletId);
|
|
115
|
+
setShowAuthFlow(false);
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
106
119
|
if (!currentWalletConnectorAddress) {
|
|
107
120
|
logger.error('Could not refresh the wallet. The wallet address is not available');
|
|
108
121
|
return;
|
|
@@ -123,7 +136,11 @@ const useConnectWallet = ({ authMode, clearPrimaryWalletId, enableVisitTrackingO
|
|
|
123
136
|
throw error;
|
|
124
137
|
}
|
|
125
138
|
if (onBeforeConnectSuccessConfirmation) {
|
|
126
|
-
const shouldProceedWithConnection = yield onBeforeConnectSuccessConfirmation(
|
|
139
|
+
const shouldProceedWithConnection = yield onBeforeConnectSuccessConfirmation({
|
|
140
|
+
address: publicWalletAddress,
|
|
141
|
+
chain: walletConnector.connectedChain,
|
|
142
|
+
connector: walletConnector,
|
|
143
|
+
});
|
|
127
144
|
if (!shouldProceedWithConnection) {
|
|
128
145
|
logger.info('Connection was not established because onBeforeConnectSuccessConfirmation returned false');
|
|
129
146
|
setShowAuthFlow(false);
|
|
@@ -33,7 +33,7 @@ var AccountExistsContext = require('../../../context/AccountExistsContext/Accoun
|
|
|
33
33
|
// This logic is used to both verify or link a wallet
|
|
34
34
|
// Since we are re-using the different screens to authenticate or link the wallet.
|
|
35
35
|
// This logic is the best place to determine whether we should verify or verify and link.
|
|
36
|
-
const useVerifyWallet = ({ consumeNonce,
|
|
36
|
+
const useVerifyWallet = ({ consumeNonce, displaySiweStatement, environmentId, projectSettings, setIsSingleWalletAccount, }) => {
|
|
37
37
|
const { setDeniedAddress, setDeniedOauthProvider } = AccessDeniedContext.useAccessDeniedContext();
|
|
38
38
|
const { setExistentAccountData } = AccountExistsContext.useAccountExistsContext();
|
|
39
39
|
const { setView, goToInitialView } = ViewContext.useViewContext();
|
|
@@ -49,7 +49,7 @@ const useVerifyWallet = ({ consumeNonce, displayTermsOfService, environmentId, p
|
|
|
49
49
|
if (nonce === undefined)
|
|
50
50
|
throw new utils.DynamicError('Missing nonce');
|
|
51
51
|
const verifyArgs = yield getVerifyArgs.getVerifyArgs({
|
|
52
|
-
|
|
52
|
+
displaySiweStatement,
|
|
53
53
|
environmentId,
|
|
54
54
|
fetchPublicAddressOpts,
|
|
55
55
|
nonce,
|
|
@@ -2,8 +2,8 @@ import { Dispatch, SetStateAction } from 'react';
|
|
|
2
2
|
import { ProjectSettingsProps, VerifyProps, VerifyCallbackArgs } from '../../../shared/types';
|
|
3
3
|
type UseVerifyWalletArgs = VerifyProps & ProjectSettingsProps & {
|
|
4
4
|
consumeNonce: () => string | undefined;
|
|
5
|
-
|
|
5
|
+
displaySiweStatement: boolean;
|
|
6
6
|
setIsSingleWalletAccount: Dispatch<SetStateAction<boolean>>;
|
|
7
7
|
};
|
|
8
|
-
export declare const useVerifyWallet: ({ consumeNonce,
|
|
8
|
+
export declare const useVerifyWallet: ({ consumeNonce, displaySiweStatement, environmentId, projectSettings, setIsSingleWalletAccount, }: UseVerifyWalletArgs) => ({ walletConnector, fetchPublicAddressOpts, publicWalletAddress, captchaToken, oauth, }: VerifyCallbackArgs) => Promise<void>;
|
|
9
9
|
export {};
|
|
@@ -29,7 +29,7 @@ import { useAccountExistsContext } from '../../../context/AccountExistsContext/A
|
|
|
29
29
|
// This logic is used to both verify or link a wallet
|
|
30
30
|
// Since we are re-using the different screens to authenticate or link the wallet.
|
|
31
31
|
// This logic is the best place to determine whether we should verify or verify and link.
|
|
32
|
-
const useVerifyWallet = ({ consumeNonce,
|
|
32
|
+
const useVerifyWallet = ({ consumeNonce, displaySiweStatement, environmentId, projectSettings, setIsSingleWalletAccount, }) => {
|
|
33
33
|
const { setDeniedAddress, setDeniedOauthProvider } = useAccessDeniedContext();
|
|
34
34
|
const { setExistentAccountData } = useAccountExistsContext();
|
|
35
35
|
const { setView, goToInitialView } = useViewContext();
|
|
@@ -45,7 +45,7 @@ const useVerifyWallet = ({ consumeNonce, displayTermsOfService, environmentId, p
|
|
|
45
45
|
if (nonce === undefined)
|
|
46
46
|
throw new DynamicError('Missing nonce');
|
|
47
47
|
const verifyArgs = yield getVerifyArgs({
|
|
48
|
-
|
|
48
|
+
displaySiweStatement,
|
|
49
49
|
environmentId,
|
|
50
50
|
fetchPublicAddressOpts,
|
|
51
51
|
nonce,
|
|
@@ -47,12 +47,12 @@ require('../../components/MenuList/Dropdown/Dropdown.cjs');
|
|
|
47
47
|
var Captcha = require('../../components/Captcha/Captcha.cjs');
|
|
48
48
|
|
|
49
49
|
const CaptchaVerifyUser = () => {
|
|
50
|
-
const { consumeNonce,
|
|
50
|
+
const { consumeNonce, displaySiweStatement, environmentId, projectSettings, setIsSingleWalletAccount, selectedWalletConnector: walletConnector, } = useInternalDynamicContext.useInternalDynamicContext();
|
|
51
51
|
const { setView } = ViewContext.useViewContext();
|
|
52
52
|
const { setCaptchaToken } = CaptchaContext.useCaptchaContext();
|
|
53
53
|
const verifyWallet = useVerifyWallet.useVerifyWallet({
|
|
54
54
|
consumeNonce,
|
|
55
|
-
|
|
55
|
+
displaySiweStatement,
|
|
56
56
|
environmentId,
|
|
57
57
|
projectSettings,
|
|
58
58
|
setIsSingleWalletAccount,
|
|
@@ -43,12 +43,12 @@ import '../../components/MenuList/Dropdown/Dropdown.js';
|
|
|
43
43
|
import { Captcha } from '../../components/Captcha/Captcha.js';
|
|
44
44
|
|
|
45
45
|
const CaptchaVerifyUser = () => {
|
|
46
|
-
const { consumeNonce,
|
|
46
|
+
const { consumeNonce, displaySiweStatement, environmentId, projectSettings, setIsSingleWalletAccount, selectedWalletConnector: walletConnector, } = useInternalDynamicContext();
|
|
47
47
|
const { setView } = useViewContext();
|
|
48
48
|
const { setCaptchaToken } = useCaptchaContext();
|
|
49
49
|
const verifyWallet = useVerifyWallet({
|
|
50
50
|
consumeNonce,
|
|
51
|
-
|
|
51
|
+
displaySiweStatement,
|
|
52
52
|
environmentId,
|
|
53
53
|
projectSettings,
|
|
54
54
|
setIsSingleWalletAccount,
|
|
@@ -61,7 +61,7 @@ const WalletUsedView = () => {
|
|
|
61
61
|
const { setErrorMessage } = ErrorContext.useErrorContext();
|
|
62
62
|
const { loading, setLoading } = LoadingContext.useLoadingContext();
|
|
63
63
|
const { setView, goToInitialView } = ViewContext.useViewContext();
|
|
64
|
-
const { environmentId,
|
|
64
|
+
const { environmentId, displaySiweStatement, authToken, setCallback, setShowAuthFlow, setUser, appName, siweStatement, setPrimaryWalletId, primaryWallet, setMultiWalletWidgetState, connectWallet, selectedWalletConnector: walletConnector, isSingleWalletAccount, consumeNonce, handleLogOut, } = useInternalDynamicContext.useInternalDynamicContext();
|
|
65
65
|
React.useEffect(() => {
|
|
66
66
|
const _fetchPublicAddress = () => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
67
67
|
const address = yield (walletConnector === null || walletConnector === void 0 ? void 0 : walletConnector.fetchPublicAddress());
|
|
@@ -110,7 +110,7 @@ const WalletUsedView = () => {
|
|
|
110
110
|
}
|
|
111
111
|
const walletProvider = getWalletProvider.getWalletProvider(walletConnector);
|
|
112
112
|
const verifyArgs = yield getVerifyArgs.getVerifyArgs({
|
|
113
|
-
|
|
113
|
+
displaySiweStatement,
|
|
114
114
|
environmentId,
|
|
115
115
|
nonce,
|
|
116
116
|
publicWalletAddress,
|
|
@@ -57,7 +57,7 @@ const WalletUsedView = () => {
|
|
|
57
57
|
const { setErrorMessage } = useErrorContext();
|
|
58
58
|
const { loading, setLoading } = useLoadingContext();
|
|
59
59
|
const { setView, goToInitialView } = useViewContext();
|
|
60
|
-
const { environmentId,
|
|
60
|
+
const { environmentId, displaySiweStatement, authToken, setCallback, setShowAuthFlow, setUser, appName, siweStatement, setPrimaryWalletId, primaryWallet, setMultiWalletWidgetState, connectWallet, selectedWalletConnector: walletConnector, isSingleWalletAccount, consumeNonce, handleLogOut, } = useInternalDynamicContext();
|
|
61
61
|
useEffect(() => {
|
|
62
62
|
const _fetchPublicAddress = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
63
63
|
const address = yield (walletConnector === null || walletConnector === void 0 ? void 0 : walletConnector.fetchPublicAddress());
|
|
@@ -106,7 +106,7 @@ const WalletUsedView = () => {
|
|
|
106
106
|
}
|
|
107
107
|
const walletProvider = getWalletProvider(walletConnector);
|
|
108
108
|
const verifyArgs = yield getVerifyArgs({
|
|
109
|
-
|
|
109
|
+
displaySiweStatement,
|
|
110
110
|
environmentId,
|
|
111
111
|
nonce,
|
|
112
112
|
publicWalletAddress,
|
|
@@ -50,7 +50,7 @@ var DynamicBridgeUserProfile = require('./components/DynamicBridgeUserProfile/Dy
|
|
|
50
50
|
var DynamicBridgeWidgetContext = require('./context/DynamicBridgeWidgetContext/DynamicBridgeWidgetContext.cjs');
|
|
51
51
|
|
|
52
52
|
const DynamicBridgeWidget = ({ className, variant = 'modal', }) => {
|
|
53
|
-
const { showAuthFlow, setShowBridgeWidget, walletsByChain, setShowAuthFlow,
|
|
53
|
+
const { showAuthFlow, setShowBridgeWidget, walletsByChain, setShowAuthFlow, connectedWallets, } = useInternalDynamicContext.useInternalDynamicContext();
|
|
54
54
|
const { widgetRef, inlineControlsRef } = DynamicBridgeWidgetContext.useDynamicBridgeWidgetContext();
|
|
55
55
|
const closeOnOutsideClick = React.useCallback((e) => {
|
|
56
56
|
var _a;
|
|
@@ -62,11 +62,11 @@ const DynamicBridgeWidget = ({ className, variant = 'modal', }) => {
|
|
|
62
62
|
}
|
|
63
63
|
}, [inlineControlsRef, variant, showAuthFlow, setShowBridgeWidget]);
|
|
64
64
|
index.useOnClickOutside(widgetRef, closeOnOutsideClick);
|
|
65
|
-
return (jsxRuntime.jsx(IsBrowser.IsBrowser, { children: jsxRuntime.jsxs(ShadowDOM.ShadowDOM, Object.assign({ id: 'dynamic-bridge-widget', className: 'dynamic-widget__container' }, { children: [jsxRuntime.jsx(InlineWidget.InlineWidget, Object.assign({ ref: inlineControlsRef, className: className, dataTestId: 'BridgeWidgetNav' }, { children: walletsByChain === null || walletsByChain === void 0 ? void 0 : walletsByChain.map(({ chain }
|
|
65
|
+
return (jsxRuntime.jsx(IsBrowser.IsBrowser, { children: jsxRuntime.jsxs(ShadowDOM.ShadowDOM, Object.assign({ id: 'dynamic-bridge-widget', className: 'dynamic-widget__container' }, { children: [jsxRuntime.jsx(InlineWidget.InlineWidget, Object.assign({ ref: inlineControlsRef, className: className, dataTestId: 'BridgeWidgetNav' }, { children: walletsByChain === null || walletsByChain === void 0 ? void 0 : walletsByChain.map(({ chain }) => {
|
|
66
66
|
const ChainIcon = getChainIcon.getChainIcon(chain);
|
|
67
|
-
const
|
|
68
|
-
if (
|
|
69
|
-
return (jsxRuntime.jsx(InlineWidgetButton.InlineWidgetButton, Object.assign({ icon: jsxRuntime.jsx(ChainIcon, {}), onClick: () => setShowBridgeWidget(true) }, { children: shortenWalletAddress.shortenWalletAddress(wallet.address, 3, 3) }),
|
|
67
|
+
const connectedChainWallets = connectedWallets.filter(({ chain: connectedChain }) => connectedChain === chain);
|
|
68
|
+
if (connectedChainWallets.length > 0) {
|
|
69
|
+
return connectedChainWallets.map((wallet) => (jsxRuntime.jsx(InlineWidgetButton.InlineWidgetButton, Object.assign({ icon: jsxRuntime.jsx(ChainIcon, {}), onClick: () => setShowBridgeWidget(true) }, { children: shortenWalletAddress.shortenWalletAddress(wallet.address, 3, 3) }), wallet.id)));
|
|
70
70
|
}
|
|
71
71
|
return (jsxRuntime.jsx(InlineWidgetButton.InlineWidgetButton, Object.assign({ icon: jsxRuntime.jsx(ChainIcon, {}), onClick: () => setShowAuthFlow(true) }, { children: "Connect wallet" }), chain));
|
|
72
72
|
}) })), jsxRuntime.jsx(DynamicBridgeUserProfile.DynamicBridgeUserProfile, { variant: variant })] })) }));
|
|
@@ -46,7 +46,7 @@ import { DynamicBridgeUserProfile } from './components/DynamicBridgeUserProfile/
|
|
|
46
46
|
import { useDynamicBridgeWidgetContext } from './context/DynamicBridgeWidgetContext/DynamicBridgeWidgetContext.js';
|
|
47
47
|
|
|
48
48
|
const DynamicBridgeWidget = ({ className, variant = 'modal', }) => {
|
|
49
|
-
const { showAuthFlow, setShowBridgeWidget, walletsByChain, setShowAuthFlow,
|
|
49
|
+
const { showAuthFlow, setShowBridgeWidget, walletsByChain, setShowAuthFlow, connectedWallets, } = useInternalDynamicContext();
|
|
50
50
|
const { widgetRef, inlineControlsRef } = useDynamicBridgeWidgetContext();
|
|
51
51
|
const closeOnOutsideClick = useCallback((e) => {
|
|
52
52
|
var _a;
|
|
@@ -58,11 +58,11 @@ const DynamicBridgeWidget = ({ className, variant = 'modal', }) => {
|
|
|
58
58
|
}
|
|
59
59
|
}, [inlineControlsRef, variant, showAuthFlow, setShowBridgeWidget]);
|
|
60
60
|
useOnClickOutside(widgetRef, closeOnOutsideClick);
|
|
61
|
-
return (jsx(IsBrowser, { children: jsxs(ShadowDOM, Object.assign({ id: 'dynamic-bridge-widget', className: 'dynamic-widget__container' }, { children: [jsx(InlineWidget, Object.assign({ ref: inlineControlsRef, className: className, dataTestId: 'BridgeWidgetNav' }, { children: walletsByChain === null || walletsByChain === void 0 ? void 0 : walletsByChain.map(({ chain }
|
|
61
|
+
return (jsx(IsBrowser, { children: jsxs(ShadowDOM, Object.assign({ id: 'dynamic-bridge-widget', className: 'dynamic-widget__container' }, { children: [jsx(InlineWidget, Object.assign({ ref: inlineControlsRef, className: className, dataTestId: 'BridgeWidgetNav' }, { children: walletsByChain === null || walletsByChain === void 0 ? void 0 : walletsByChain.map(({ chain }) => {
|
|
62
62
|
const ChainIcon = getChainIcon(chain);
|
|
63
|
-
const
|
|
64
|
-
if (
|
|
65
|
-
return (jsx(InlineWidgetButton, Object.assign({ icon: jsx(ChainIcon, {}), onClick: () => setShowBridgeWidget(true) }, { children: shortenWalletAddress(wallet.address, 3, 3) }),
|
|
63
|
+
const connectedChainWallets = connectedWallets.filter(({ chain: connectedChain }) => connectedChain === chain);
|
|
64
|
+
if (connectedChainWallets.length > 0) {
|
|
65
|
+
return connectedChainWallets.map((wallet) => (jsx(InlineWidgetButton, Object.assign({ icon: jsx(ChainIcon, {}), onClick: () => setShowBridgeWidget(true) }, { children: shortenWalletAddress(wallet.address, 3, 3) }), wallet.id)));
|
|
66
66
|
}
|
|
67
67
|
return (jsx(InlineWidgetButton, Object.assign({ icon: jsx(ChainIcon, {}), onClick: () => setShowAuthFlow(true) }, { children: "Connect wallet" }), chain));
|
|
68
68
|
}) })), jsx(DynamicBridgeUserProfile, { variant: variant })] })) }));
|
|
@@ -4,7 +4,6 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
var jsxRuntime = require('react/jsx-runtime');
|
|
6
6
|
var walletConnectorCore = require('@dynamic-labs/wallet-connector-core');
|
|
7
|
-
var DynamicWidgetFooter = require('../../../DynamicWidget/components/DynamicWidgetFooter/DynamicWidgetFooter.cjs');
|
|
8
7
|
require('react');
|
|
9
8
|
require('@dynamic-labs/sdk-api');
|
|
10
9
|
require('../../../../shared/logger.cjs');
|
|
@@ -44,20 +43,24 @@ require('formik');
|
|
|
44
43
|
require('yup');
|
|
45
44
|
require('../../../../components/InlineWidget/InlineWidget.cjs');
|
|
46
45
|
require('../../../../components/MenuList/Dropdown/Dropdown.cjs');
|
|
46
|
+
var Balance = require('../../../DynamicWidget/components/Balance/Balance.cjs');
|
|
47
|
+
var DynamicWidgetFooter = require('../../../DynamicWidget/components/DynamicWidgetFooter/DynamicWidgetFooter.cjs');
|
|
47
48
|
var DynamicBridgeWalletCard = require('../../components/DynamicBridgeWalletCard/DynamicBridgeWalletCard.cjs');
|
|
48
49
|
var DynamicBridgeWalletCardBody = require('../../components/DynamicBridgeWalletCardBody/DynamicBridgeWalletCardBody.cjs');
|
|
49
|
-
var Balance = require('../../../DynamicWidget/components/Balance/Balance.cjs');
|
|
50
50
|
var DynamicBridgeWidgetEmptyCard = require('../../components/DynamicBridgeWidgetEmptyCard/DynamicBridgeWidgetEmptyCard.cjs');
|
|
51
|
-
var SecondaryWallets = require('./components/SecondaryWallets/SecondaryWallets.cjs');
|
|
52
51
|
|
|
53
52
|
const WalletsView = () => {
|
|
54
|
-
const { unlinkConnectedWallet, walletsByChain,
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
53
|
+
const { unlinkConnectedWallet, walletsByChain, connectedWallets } = useInternalDynamicContext.useInternalDynamicContext();
|
|
54
|
+
return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx("div", Object.assign({ className: 'dynamic-bridge-widget-wallets-view' }, { children: walletsByChain === null || walletsByChain === void 0 ? void 0 : walletsByChain.map(({ chain }) => {
|
|
55
|
+
const chainWallets = connectedWallets.filter(({ chain: walletChain }) => chain === walletChain);
|
|
56
|
+
// "Connect wallet" for empty chains
|
|
57
|
+
if (!chainWallets.length)
|
|
58
|
+
return jsxRuntime.jsx(DynamicBridgeWidgetEmptyCard.DynamicBridgeWidgetEmptyCard, { chain: chain });
|
|
59
|
+
const WalletIcon = getChainIcon.getChainIcon(chain);
|
|
60
|
+
const walletInfo = walletConnectorCore.getChainInfo(chain);
|
|
61
|
+
// Wallets info for chains with connected wallets
|
|
62
|
+
return chainWallets.map(({ connector, address, id }) => (jsxRuntime.jsx(DynamicBridgeWalletCard.DynamicBridgeWalletCard, Object.assign({ networkIcon: jsxRuntime.jsx(WalletIcon, {}), networkName: walletInfo === null || walletInfo === void 0 ? void 0 : walletInfo.displayName }, { children: jsxRuntime.jsx(DynamicBridgeWalletCardBody.DynamicBridgeWalletCardBody, { walletName: connector.name, walletAddress: address, walletBalance: jsxRuntime.jsx(Balance.Balance, { address: address, connector: connector, network: chain }), onUnlinkClick: () => unlinkConnectedWallet(id) }) }), id)));
|
|
63
|
+
}) })), jsxRuntime.jsx(DynamicWidgetFooter.DynamicWidgetFooter, { children: jsxRuntime.jsx(LogoutButton.LogoutButton, { buttonClassName: 'dynamic-bridge-widget-wallets-view__logout-button', isTextButton: true }) })] }));
|
|
61
64
|
};
|
|
62
65
|
|
|
63
66
|
exports.WalletsView = WalletsView;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
|
|
2
2
|
import { getChainInfo } from '@dynamic-labs/wallet-connector-core';
|
|
3
|
-
import { DynamicWidgetFooter } from '../../../DynamicWidget/components/DynamicWidgetFooter/DynamicWidgetFooter.js';
|
|
4
3
|
import 'react';
|
|
5
4
|
import '@dynamic-labs/sdk-api';
|
|
6
5
|
import '../../../../shared/logger.js';
|
|
@@ -40,20 +39,24 @@ import 'formik';
|
|
|
40
39
|
import 'yup';
|
|
41
40
|
import '../../../../components/InlineWidget/InlineWidget.js';
|
|
42
41
|
import '../../../../components/MenuList/Dropdown/Dropdown.js';
|
|
42
|
+
import { Balance } from '../../../DynamicWidget/components/Balance/Balance.js';
|
|
43
|
+
import { DynamicWidgetFooter } from '../../../DynamicWidget/components/DynamicWidgetFooter/DynamicWidgetFooter.js';
|
|
43
44
|
import { DynamicBridgeWalletCard } from '../../components/DynamicBridgeWalletCard/DynamicBridgeWalletCard.js';
|
|
44
45
|
import { DynamicBridgeWalletCardBody } from '../../components/DynamicBridgeWalletCardBody/DynamicBridgeWalletCardBody.js';
|
|
45
|
-
import { Balance } from '../../../DynamicWidget/components/Balance/Balance.js';
|
|
46
46
|
import { DynamicBridgeWidgetEmptyCard } from '../../components/DynamicBridgeWidgetEmptyCard/DynamicBridgeWidgetEmptyCard.js';
|
|
47
|
-
import { MemoSecondaryWallets } from './components/SecondaryWallets/SecondaryWallets.js';
|
|
48
47
|
|
|
49
48
|
const WalletsView = () => {
|
|
50
|
-
const { unlinkConnectedWallet, walletsByChain,
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
49
|
+
const { unlinkConnectedWallet, walletsByChain, connectedWallets } = useInternalDynamicContext();
|
|
50
|
+
return (jsxs(Fragment, { children: [jsx("div", Object.assign({ className: 'dynamic-bridge-widget-wallets-view' }, { children: walletsByChain === null || walletsByChain === void 0 ? void 0 : walletsByChain.map(({ chain }) => {
|
|
51
|
+
const chainWallets = connectedWallets.filter(({ chain: walletChain }) => chain === walletChain);
|
|
52
|
+
// "Connect wallet" for empty chains
|
|
53
|
+
if (!chainWallets.length)
|
|
54
|
+
return jsx(DynamicBridgeWidgetEmptyCard, { chain: chain });
|
|
55
|
+
const WalletIcon = getChainIcon(chain);
|
|
56
|
+
const walletInfo = getChainInfo(chain);
|
|
57
|
+
// Wallets info for chains with connected wallets
|
|
58
|
+
return chainWallets.map(({ connector, address, id }) => (jsx(DynamicBridgeWalletCard, Object.assign({ networkIcon: jsx(WalletIcon, {}), networkName: walletInfo === null || walletInfo === void 0 ? void 0 : walletInfo.displayName }, { children: jsx(DynamicBridgeWalletCardBody, { walletName: connector.name, walletAddress: address, walletBalance: jsx(Balance, { address: address, connector: connector, network: chain }), onUnlinkClick: () => unlinkConnectedWallet(id) }) }), id)));
|
|
59
|
+
}) })), jsx(DynamicWidgetFooter, { children: jsx(LogoutButton, { buttonClassName: 'dynamic-bridge-widget-wallets-view__logout-button', isTextButton: true }) })] }));
|
|
57
60
|
};
|
|
58
61
|
|
|
59
62
|
export { WalletsView, WalletsView as default };
|