@dynamic-labs/sdk-react-core 3.1.2 → 3.1.4
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 +19 -0
- package/package.cjs +2 -2
- package/package.js +2 -2
- package/package.json +11 -12
- package/src/lib/components/SendBalanceForm/SendBalanceForm.cjs +5 -1
- package/src/lib/components/SendBalanceForm/SendBalanceForm.js +5 -1
- package/src/lib/context/ConnectWithOtpContext/utils/createEmailHandler.cjs +11 -1
- package/src/lib/context/ConnectWithOtpContext/utils/createEmailHandler.js +12 -2
- package/src/lib/data/api/oauth/oauth.cjs +14 -0
- package/src/lib/data/api/oauth/oauth.d.ts +1 -0
- package/src/lib/data/api/oauth/oauth.js +14 -1
- package/src/lib/modals/SendBalanceModal/SendBalanceModal.cjs +5 -5
- package/src/lib/modals/SendBalanceModal/SendBalanceModal.js +5 -5
- package/src/lib/utils/functions/getWalletConnectorForWallet/getWalletConnectorForWallet.cjs +24 -0
- package/src/lib/utils/functions/getWalletConnectorForWallet/getWalletConnectorForWallet.js +20 -0
- package/src/lib/utils/hooks/useConnectWallet/useConnectWallet.cjs +5 -3
- package/src/lib/utils/hooks/useConnectWallet/useConnectWallet.js +5 -3
- package/src/lib/utils/hooks/useConnectedWalletsNetworkValidation/useConnectedWalletsNetworkValidation.cjs +9 -0
- package/src/lib/utils/hooks/useConnectedWalletsNetworkValidation/useConnectedWalletsNetworkValidation.js +10 -1
- package/src/lib/utils/hooks/useSocialAuth/useSocialAuth.cjs +3 -2
- package/src/lib/utils/hooks/useSocialAuth/useSocialAuth.d.ts +2 -1
- package/src/lib/utils/hooks/useSocialAuth/useSocialAuth.js +3 -2
- package/src/lib/utils/hooks/useTelegramLogin/useTelegramLogin.cjs +39 -25
- package/src/lib/utils/hooks/useTelegramLogin/useTelegramLogin.d.ts +8 -1
- package/src/lib/utils/hooks/useTelegramLogin/useTelegramLogin.js +39 -25
- package/src/lib/utils/hooks/useWalletConnectors/utils/createLinkedWalletsFromWalletOptions/createLinkedWalletsFromWalletOptions.cjs +9 -2
- package/src/lib/utils/hooks/useWalletConnectors/utils/createLinkedWalletsFromWalletOptions/createLinkedWalletsFromWalletOptions.js +10 -3
- package/src/lib/utils/hooks/useWalletEventListeners/useWalletEventListeners.cjs +0 -14
- package/src/lib/utils/hooks/useWalletEventListeners/useWalletEventListeners.js +0 -14
- package/src/lib/utils/hooks/useWalletOptions/useWalletOptions.cjs +1 -0
- package/src/lib/utils/hooks/useWalletOptions/useWalletOptions.d.ts +1 -0
- package/src/lib/utils/hooks/useWalletOptions/useWalletOptions.js +1 -0
- package/src/lib/views/NoAccess/NoAccess.cjs +4 -1
- package/src/lib/views/NoAccess/NoAccess.js +4 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,23 @@
|
|
|
1
1
|
|
|
2
|
+
### [3.1.4](https://github.com/dynamic-labs/DynamicAuth/compare/v3.1.3...v3.1.4) (2024-09-30)
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
### Bug Fixes
|
|
6
|
+
|
|
7
|
+
* add popper context to send balance ([#7017](https://github.com/dynamic-labs/DynamicAuth/issues/7017)) ([bedcc5e](https://github.com/dynamic-labs/DynamicAuth/commit/bedcc5ec005267b7fa40a2020bc9fef6e2e09714))
|
|
8
|
+
* add retry to useConnectWithOtp ([#7013](https://github.com/dynamic-labs/DynamicAuth/issues/7013)) ([4d3455a](https://github.com/dynamic-labs/DynamicAuth/commit/4d3455a5ead6585ec309ff32294f392154900d73))
|
|
9
|
+
* don't re-fetch wallet address on network change ([#7023](https://github.com/dynamic-labs/DynamicAuth/issues/7023)) ([d23b716](https://github.com/dynamic-labs/DynamicAuth/commit/d23b71608af8b6b75b015efdfcb8bea34602dc6a))
|
|
10
|
+
* fix sign message with solana wallet standard provider ([#7015](https://github.com/dynamic-labs/DynamicAuth/issues/7015)) ([b575622](https://github.com/dynamic-labs/DynamicAuth/commit/b575622d7ec8b3dc61049acb592b7c7fa458ec61))
|
|
11
|
+
* persist isHardwareWalletEnabled on wallet connector ([#7025](https://github.com/dynamic-labs/DynamicAuth/issues/7025)) ([7ed7832](https://github.com/dynamic-labs/DynamicAuth/commit/7ed7832235ecafe8172a16528d428f7c03485064))
|
|
12
|
+
* update wallet reference when user switches wallet in connect-only ([#7031](https://github.com/dynamic-labs/DynamicAuth/issues/7031)) ([031515f](https://github.com/dynamic-labs/DynamicAuth/commit/031515fc6c785facbbc95d2f65d58551559334e6))
|
|
13
|
+
|
|
14
|
+
### [3.1.3](https://github.com/dynamic-labs/DynamicAuth/compare/v3.1.2...v3.1.3) (2024-09-25)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
### Features
|
|
18
|
+
|
|
19
|
+
* add isInstalledOnBrowser prop to wallet options in useWalletOptions ([#6977](https://github.com/dynamic-labs/DynamicAuth/issues/6977)) ([9436e48](https://github.com/dynamic-labs/DynamicAuth/commit/9436e48994663b62d1ef5afa0c37df436f68caae))
|
|
20
|
+
|
|
2
21
|
### [3.1.2](https://github.com/dynamic-labs/DynamicAuth/compare/v3.1.1...v3.1.2) (2024-09-23)
|
|
3
22
|
|
|
4
23
|
|
package/package.cjs
CHANGED
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
|
|
4
4
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
5
|
|
|
6
|
-
var version = "3.1.
|
|
6
|
+
var version = "3.1.4";
|
|
7
7
|
var dependencies = {
|
|
8
|
-
"@dynamic-labs/sdk-api-core": "0.0.
|
|
8
|
+
"@dynamic-labs/sdk-api-core": "0.0.535",
|
|
9
9
|
"@hcaptcha/react-hcaptcha": "1.4.4",
|
|
10
10
|
"country-list": "2.3.0",
|
|
11
11
|
formik: "2.2.9",
|
package/package.js
CHANGED
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dynamic-labs/sdk-react-core",
|
|
3
|
-
"version": "3.1.
|
|
3
|
+
"version": "3.1.4",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/dynamic-labs/dynamic-auth.git",
|
|
7
7
|
"directory": "packages/sdk-react-core"
|
|
8
8
|
},
|
|
9
9
|
"dependencies": {
|
|
10
|
-
"@dynamic-labs/sdk-api-core": "0.0.
|
|
10
|
+
"@dynamic-labs/sdk-api-core": "0.0.535",
|
|
11
11
|
"@hcaptcha/react-hcaptcha": "1.4.4",
|
|
12
12
|
"country-list": "2.3.0",
|
|
13
13
|
"formik": "2.2.9",
|
|
@@ -17,16 +17,15 @@
|
|
|
17
17
|
"react-i18next": "13.5.0",
|
|
18
18
|
"yup": "0.32.11",
|
|
19
19
|
"react-international-phone": "4.2.5",
|
|
20
|
-
"@dynamic-labs/iconic": "3.1.
|
|
21
|
-
"@dynamic-labs/logger": "3.1.
|
|
22
|
-
"@dynamic-labs/
|
|
23
|
-
"@dynamic-labs/
|
|
24
|
-
"@dynamic-labs/
|
|
25
|
-
"@dynamic-labs/
|
|
26
|
-
"@dynamic-labs/
|
|
27
|
-
"@dynamic-labs/
|
|
28
|
-
"@dynamic-labs/wallet-
|
|
29
|
-
"@dynamic-labs/wallet-connector-core": "3.1.2",
|
|
20
|
+
"@dynamic-labs/iconic": "3.1.4",
|
|
21
|
+
"@dynamic-labs/logger": "3.1.4",
|
|
22
|
+
"@dynamic-labs/multi-wallet": "3.1.4",
|
|
23
|
+
"@dynamic-labs/rpc-providers": "3.1.4",
|
|
24
|
+
"@dynamic-labs/store": "3.1.4",
|
|
25
|
+
"@dynamic-labs/types": "3.1.4",
|
|
26
|
+
"@dynamic-labs/utils": "3.1.4",
|
|
27
|
+
"@dynamic-labs/wallet-book": "3.1.4",
|
|
28
|
+
"@dynamic-labs/wallet-connector-core": "3.1.4",
|
|
30
29
|
"eventemitter3": "5.0.1"
|
|
31
30
|
},
|
|
32
31
|
"devDependencies": {
|
|
@@ -153,7 +153,7 @@ const SendBalanceForm = ({ initialValues, onSubmit, decimals = 18, validateAddre
|
|
|
153
153
|
}),
|
|
154
154
|
});
|
|
155
155
|
}, [decimals, validateAddress, validateAmount]);
|
|
156
|
-
return (jsxRuntime.jsx(formik.Formik, { initialValues: initialValues || sendBalanceFormInitialValues, validationSchema: sendBalanceFormValidationSchema, onSubmit: (values) => onSubmit(values), validateOnChange: false, validateOnBlur: false, children: ({ errors, touched, values, handleChange, setFieldValue, setErrors, }) => {
|
|
156
|
+
return (jsxRuntime.jsx(formik.Formik, { initialValues: initialValues || sendBalanceFormInitialValues, validationSchema: sendBalanceFormValidationSchema, onSubmit: (values) => onSubmit(values), validateOnChange: false, validateOnBlur: false, children: ({ errors, touched, values, handleChange, setFieldValue, setErrors, handleBlur, setFieldTouched, validateField, }) => {
|
|
157
157
|
var _a;
|
|
158
158
|
return (jsxRuntime.jsxs(formik.Form, { className: 'send-balance-form', children: [jsxRuntime.jsxs("div", { className: 'send-balance-page-layout__balance-container', children: [jsxRuntime.jsx(FormFieldLabel.FormFieldLabel, { children: "Select any token" }), jsxRuntime.jsx(TokensBalanceDropdown.TokensBalanceDropdown, { tokenBalances: tokenBalances !== null && tokenBalances !== void 0 ? tokenBalances : (currentToken && [currentToken]), currentToken: currentToken, setCurrentToken: setCurrentToken, isLoading: isLoading, setFieldValue: setFieldValue, setErrors: setErrors })] }), jsxRuntime.jsxs("div", { className: 'send-balance-form__amount-container', children: [jsxRuntime.jsx(formik.Field, { variant: 'regular', className: `send-balance-form__amount-container__field ${showFiat ? 'fiat' : ''}`, name: 'amount', id: 'amount', onChange: (e) => {
|
|
159
159
|
const newValue = e.target.value;
|
|
@@ -168,6 +168,10 @@ const SendBalanceForm = ({ initialValues, onSubmit, decimals = 18, validateAddre
|
|
|
168
168
|
return;
|
|
169
169
|
}
|
|
170
170
|
sendBalances.setSendBalanceVariable('amount', (currentToken === null || currentToken === void 0 ? void 0 : currentToken.price) ? Number(newValue) : undefined);
|
|
171
|
+
}, onBlur: (e) => {
|
|
172
|
+
handleBlur(e);
|
|
173
|
+
setFieldTouched('amount', true);
|
|
174
|
+
validateField('amount');
|
|
171
175
|
}, placeholder: t('dyn_send_transaction.data.amount.placeholder'), as: Input.Input, error: errors['amount'], copykey: 'dyn_send_transaction.data.amount.label', message: touched['amount'] &&
|
|
172
176
|
getDisplayErrorMessage(errors, t, 'amount', decimals), style: {
|
|
173
177
|
paddingLeft: `${leftSymbolPadding}px`,
|
|
@@ -149,7 +149,7 @@ const SendBalanceForm = ({ initialValues, onSubmit, decimals = 18, validateAddre
|
|
|
149
149
|
}),
|
|
150
150
|
});
|
|
151
151
|
}, [decimals, validateAddress, validateAmount]);
|
|
152
|
-
return (jsx(Formik, { initialValues: initialValues || sendBalanceFormInitialValues, validationSchema: sendBalanceFormValidationSchema, onSubmit: (values) => onSubmit(values), validateOnChange: false, validateOnBlur: false, children: ({ errors, touched, values, handleChange, setFieldValue, setErrors, }) => {
|
|
152
|
+
return (jsx(Formik, { initialValues: initialValues || sendBalanceFormInitialValues, validationSchema: sendBalanceFormValidationSchema, onSubmit: (values) => onSubmit(values), validateOnChange: false, validateOnBlur: false, children: ({ errors, touched, values, handleChange, setFieldValue, setErrors, handleBlur, setFieldTouched, validateField, }) => {
|
|
153
153
|
var _a;
|
|
154
154
|
return (jsxs(Form, { className: 'send-balance-form', children: [jsxs("div", { className: 'send-balance-page-layout__balance-container', children: [jsx(FormFieldLabel, { children: "Select any token" }), jsx(TokensBalanceDropdown, { tokenBalances: tokenBalances !== null && tokenBalances !== void 0 ? tokenBalances : (currentToken && [currentToken]), currentToken: currentToken, setCurrentToken: setCurrentToken, isLoading: isLoading, setFieldValue: setFieldValue, setErrors: setErrors })] }), jsxs("div", { className: 'send-balance-form__amount-container', children: [jsx(Field, { variant: 'regular', className: `send-balance-form__amount-container__field ${showFiat ? 'fiat' : ''}`, name: 'amount', id: 'amount', onChange: (e) => {
|
|
155
155
|
const newValue = e.target.value;
|
|
@@ -164,6 +164,10 @@ const SendBalanceForm = ({ initialValues, onSubmit, decimals = 18, validateAddre
|
|
|
164
164
|
return;
|
|
165
165
|
}
|
|
166
166
|
setSendBalanceVariable('amount', (currentToken === null || currentToken === void 0 ? void 0 : currentToken.price) ? Number(newValue) : undefined);
|
|
167
|
+
}, onBlur: (e) => {
|
|
168
|
+
handleBlur(e);
|
|
169
|
+
setFieldTouched('amount', true);
|
|
170
|
+
validateField('amount');
|
|
167
171
|
}, placeholder: t('dyn_send_transaction.data.amount.placeholder'), as: Input, error: errors['amount'], copykey: 'dyn_send_transaction.data.amount.label', message: touched['amount'] &&
|
|
168
172
|
getDisplayErrorMessage(errors, t, 'amount', decimals), style: {
|
|
169
173
|
paddingLeft: `${leftSymbolPadding}px`,
|
|
@@ -27,11 +27,21 @@ require('../../../store/state/projectSettings/projectSettings.cjs');
|
|
|
27
27
|
require('../../../locale/locale.cjs');
|
|
28
28
|
|
|
29
29
|
const createEmailHandler = (environmentId, { shouldRegisterSessionKeysOnSignin, generateSessionKey, }) => (email$1) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
30
|
-
const
|
|
30
|
+
const createEmailVerificationResponse = yield email.createEmailVerification({
|
|
31
31
|
email: email$1,
|
|
32
32
|
environmentId,
|
|
33
33
|
});
|
|
34
|
+
let { verificationUUID } = createEmailVerificationResponse;
|
|
34
35
|
return {
|
|
36
|
+
retry: () => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
37
|
+
const retryEmailVerificationResponse = yield email.retryEmailVerification({
|
|
38
|
+
email: email$1,
|
|
39
|
+
environmentId,
|
|
40
|
+
verificationUUID,
|
|
41
|
+
});
|
|
42
|
+
// eslint-disable-next-line prefer-destructuring
|
|
43
|
+
verificationUUID = retryEmailVerificationResponse.verificationUUID;
|
|
44
|
+
}),
|
|
35
45
|
type: 'email',
|
|
36
46
|
verify: (oneTimePassword) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
37
47
|
let sessionPublicKey = undefined;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use client'
|
|
2
2
|
import { __awaiter } from '../../../../../_virtual/_tslib.js';
|
|
3
|
-
import { createEmailVerification, signInWithEmailVerification } from '../../../data/api/email/email.js';
|
|
3
|
+
import { createEmailVerification, retryEmailVerification, signInWithEmailVerification } from '../../../data/api/email/email.js';
|
|
4
4
|
import '@dynamic-labs/sdk-api-core';
|
|
5
5
|
import '@dynamic-labs/utils';
|
|
6
6
|
import '../../../shared/logger.js';
|
|
@@ -23,11 +23,21 @@ import '../../../store/state/projectSettings/projectSettings.js';
|
|
|
23
23
|
import '../../../locale/locale.js';
|
|
24
24
|
|
|
25
25
|
const createEmailHandler = (environmentId, { shouldRegisterSessionKeysOnSignin, generateSessionKey, }) => (email) => __awaiter(void 0, void 0, void 0, function* () {
|
|
26
|
-
const
|
|
26
|
+
const createEmailVerificationResponse = yield createEmailVerification({
|
|
27
27
|
email,
|
|
28
28
|
environmentId,
|
|
29
29
|
});
|
|
30
|
+
let { verificationUUID } = createEmailVerificationResponse;
|
|
30
31
|
return {
|
|
32
|
+
retry: () => __awaiter(void 0, void 0, void 0, function* () {
|
|
33
|
+
const retryEmailVerificationResponse = yield retryEmailVerification({
|
|
34
|
+
email,
|
|
35
|
+
environmentId,
|
|
36
|
+
verificationUUID,
|
|
37
|
+
});
|
|
38
|
+
// eslint-disable-next-line prefer-destructuring
|
|
39
|
+
verificationUUID = retryEmailVerificationResponse.verificationUUID;
|
|
40
|
+
}),
|
|
31
41
|
type: 'email',
|
|
32
42
|
verify: (oneTimePassword) => __awaiter(void 0, void 0, void 0, function* () {
|
|
33
43
|
let sessionPublicKey = undefined;
|
|
@@ -143,6 +143,19 @@ const telegramSignIn = (environmentId, oauthResultRequest) => _tslib.__awaiter(v
|
|
|
143
143
|
return handleSignInError(e);
|
|
144
144
|
}
|
|
145
145
|
});
|
|
146
|
+
const isUserLinkedWithTelegram = (environmentId, oauthResultRequest) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
147
|
+
const telegramCheckAuthRequest = {
|
|
148
|
+
environmentId,
|
|
149
|
+
oauthResultRequest,
|
|
150
|
+
};
|
|
151
|
+
try {
|
|
152
|
+
yield api.sdkApi().telegramCheckAuth(telegramCheckAuthRequest);
|
|
153
|
+
return true;
|
|
154
|
+
}
|
|
155
|
+
catch (e) {
|
|
156
|
+
return false;
|
|
157
|
+
}
|
|
158
|
+
});
|
|
146
159
|
const telegramVerify = (environmentId, oauthResultRequest) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
147
160
|
const telegramVerifyRequest = {
|
|
148
161
|
environmentId,
|
|
@@ -195,6 +208,7 @@ exports.farcasterSignIn = farcasterSignIn;
|
|
|
195
208
|
exports.farcasterVerify = farcasterVerify;
|
|
196
209
|
exports.getOAuthResult = getOAuthResult;
|
|
197
210
|
exports.initAuth = initAuth;
|
|
211
|
+
exports.isUserLinkedWithTelegram = isUserLinkedWithTelegram;
|
|
198
212
|
exports.signInOAuth = signInOAuth;
|
|
199
213
|
exports.telegramSignIn = telegramSignIn;
|
|
200
214
|
exports.telegramVerify = telegramVerify;
|
|
@@ -13,4 +13,5 @@ export declare const getOAuthResult: (environmentId: string, providerType: Provi
|
|
|
13
13
|
export declare const farcasterSignIn: (environmentId: string, farcasterSignInRequest: FarcasterSignInRequest) => Promise<UserProfile | undefined>;
|
|
14
14
|
export declare const farcasterVerify: (farcasterVerifyRequest: FarcasterVerifyRequest) => Promise<UserProfile | undefined>;
|
|
15
15
|
export declare const telegramSignIn: (environmentId: string, oauthResultRequest: OauthResultRequest) => Promise<UserProfile | undefined>;
|
|
16
|
+
export declare const isUserLinkedWithTelegram: (environmentId: string, oauthResultRequest: OauthResultRequest) => Promise<boolean | undefined>;
|
|
16
17
|
export declare const telegramVerify: (environmentId: string, oauthResultRequest: OauthResultRequest) => Promise<UserProfile | undefined>;
|
|
@@ -139,6 +139,19 @@ const telegramSignIn = (environmentId, oauthResultRequest) => __awaiter(void 0,
|
|
|
139
139
|
return handleSignInError(e);
|
|
140
140
|
}
|
|
141
141
|
});
|
|
142
|
+
const isUserLinkedWithTelegram = (environmentId, oauthResultRequest) => __awaiter(void 0, void 0, void 0, function* () {
|
|
143
|
+
const telegramCheckAuthRequest = {
|
|
144
|
+
environmentId,
|
|
145
|
+
oauthResultRequest,
|
|
146
|
+
};
|
|
147
|
+
try {
|
|
148
|
+
yield sdkApi().telegramCheckAuth(telegramCheckAuthRequest);
|
|
149
|
+
return true;
|
|
150
|
+
}
|
|
151
|
+
catch (e) {
|
|
152
|
+
return false;
|
|
153
|
+
}
|
|
154
|
+
});
|
|
142
155
|
const telegramVerify = (environmentId, oauthResultRequest) => __awaiter(void 0, void 0, void 0, function* () {
|
|
143
156
|
const telegramVerifyRequest = {
|
|
144
157
|
environmentId,
|
|
@@ -187,4 +200,4 @@ const handleSignInError = (e) => __awaiter(void 0, void 0, void 0, function* ()
|
|
|
187
200
|
return undefined;
|
|
188
201
|
});
|
|
189
202
|
|
|
190
|
-
export { farcasterSignIn, farcasterVerify, getOAuthResult, initAuth, signInOAuth, telegramSignIn, telegramVerify, unlinkOAuth, verifyOAuth };
|
|
203
|
+
export { farcasterSignIn, farcasterVerify, getOAuthResult, initAuth, isUserLinkedWithTelegram, signInOAuth, telegramSignIn, telegramVerify, unlinkOAuth, verifyOAuth };
|
|
@@ -79,7 +79,7 @@ require('../../components/IsBrowser/IsBrowser.cjs');
|
|
|
79
79
|
require('../../context/WidgetRegistry/WidgetRegistryContextProvider.cjs');
|
|
80
80
|
require('../../context/FundingContext/FundingContext.cjs');
|
|
81
81
|
require('../../components/Popper/Popper/Popper.cjs');
|
|
82
|
-
require('../../components/Popper/PopperContext/PopperContext.cjs');
|
|
82
|
+
var PopperContext = require('../../components/Popper/PopperContext/PopperContext.cjs');
|
|
83
83
|
require('../../widgets/DynamicBridgeWidget/views/WalletsView/components/SecondaryWallets/SecondaryWallets.cjs');
|
|
84
84
|
require('@hcaptcha/react-hcaptcha');
|
|
85
85
|
require('../../context/IpConfigurationContext/IpConfigurationContext.cjs');
|
|
@@ -112,10 +112,10 @@ const SendBalanceModal = ({ initialRecipientAddress, initialValue, onReject, onS
|
|
|
112
112
|
};
|
|
113
113
|
return (jsxRuntime.jsx(Portal.Portal, { handleClose: closeModal, isShown: show, zIndex: index.authModalZIndex, withBackdrop: true, elementId: 'dynamic-send-balance', transitionEvents: {
|
|
114
114
|
onUnmount: handleOnModalUnmount,
|
|
115
|
-
}, children: jsxRuntime.jsx(Modal.Modal, { children: jsxRuntime.jsx(ModalCard.ModalCard, { children: jsxRuntime.jsx(VerticalDrawerTransition.VerticalDrawerTransition, { isShown: true, children: jsxRuntime.jsx(SendBalanceView.SendBalanceView, { initialRecipientAddress: initialRecipientAddress, initialValue: initialValue, onError: (error) => (errorRef.current = error), onClickClose: closeModal, onDone: closeModal, displayPoweredByDynamicFooter: true, onSuccess: (receipt) => {
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
115
|
+
}, children: jsxRuntime.jsx(Modal.Modal, { children: jsxRuntime.jsx(ModalCard.ModalCard, { children: jsxRuntime.jsx(VerticalDrawerTransition.VerticalDrawerTransition, { isShown: true, children: jsxRuntime.jsx(PopperContext.PopperProvider, { children: jsxRuntime.jsx(SendBalanceView.SendBalanceView, { initialRecipientAddress: initialRecipientAddress, initialValue: initialValue, onError: (error) => (errorRef.current = error), onClickClose: closeModal, onDone: closeModal, displayPoweredByDynamicFooter: true, onSuccess: (receipt) => {
|
|
116
|
+
errorRef.current = null;
|
|
117
|
+
receiptRef.current = receipt;
|
|
118
|
+
} }) }) }) }) }) }));
|
|
119
119
|
};
|
|
120
120
|
|
|
121
121
|
exports.SendBalanceModal = SendBalanceModal;
|
|
@@ -75,7 +75,7 @@ import '../../components/IsBrowser/IsBrowser.js';
|
|
|
75
75
|
import '../../context/WidgetRegistry/WidgetRegistryContextProvider.js';
|
|
76
76
|
import '../../context/FundingContext/FundingContext.js';
|
|
77
77
|
import '../../components/Popper/Popper/Popper.js';
|
|
78
|
-
import '../../components/Popper/PopperContext/PopperContext.js';
|
|
78
|
+
import { PopperProvider } from '../../components/Popper/PopperContext/PopperContext.js';
|
|
79
79
|
import '../../widgets/DynamicBridgeWidget/views/WalletsView/components/SecondaryWallets/SecondaryWallets.js';
|
|
80
80
|
import '@hcaptcha/react-hcaptcha';
|
|
81
81
|
import '../../context/IpConfigurationContext/IpConfigurationContext.js';
|
|
@@ -108,10 +108,10 @@ const SendBalanceModal = ({ initialRecipientAddress, initialValue, onReject, onS
|
|
|
108
108
|
};
|
|
109
109
|
return (jsx(Portal, { handleClose: closeModal, isShown: show, zIndex: authModalZIndex, withBackdrop: true, elementId: 'dynamic-send-balance', transitionEvents: {
|
|
110
110
|
onUnmount: handleOnModalUnmount,
|
|
111
|
-
}, children: jsx(Modal, { children: jsx(ModalCard, { children: jsx(VerticalDrawerTransition, { isShown: true, children: jsx(SendBalanceView, { initialRecipientAddress: initialRecipientAddress, initialValue: initialValue, onError: (error) => (errorRef.current = error), onClickClose: closeModal, onDone: closeModal, displayPoweredByDynamicFooter: true, onSuccess: (receipt) => {
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
111
|
+
}, children: jsx(Modal, { children: jsx(ModalCard, { children: jsx(VerticalDrawerTransition, { isShown: true, children: jsx(PopperProvider, { children: jsx(SendBalanceView, { initialRecipientAddress: initialRecipientAddress, initialValue: initialValue, onError: (error) => (errorRef.current = error), onClickClose: closeModal, onDone: closeModal, displayPoweredByDynamicFooter: true, onSuccess: (receipt) => {
|
|
112
|
+
errorRef.current = null;
|
|
113
|
+
receiptRef.current = receipt;
|
|
114
|
+
} }) }) }) }) }) }));
|
|
115
115
|
};
|
|
116
116
|
|
|
117
117
|
export { SendBalanceModal };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
|
|
6
|
+
var walletConnectorOptions = require('../../../store/state/walletConnectorOptions.cjs');
|
|
7
|
+
|
|
8
|
+
const getWalletConnectorForWallet = (wallet) => {
|
|
9
|
+
var _a, _b;
|
|
10
|
+
if (!wallet) {
|
|
11
|
+
return undefined;
|
|
12
|
+
}
|
|
13
|
+
const walletConnectorOptions$1 = walletConnectorOptions.getWalletConnectorOptions();
|
|
14
|
+
const { key: walletKey, chain } = wallet;
|
|
15
|
+
const walletConnector = (_a = walletConnectorOptions$1.find((wallet) => walletKey === wallet.key &&
|
|
16
|
+
wallet.walletConnector.connectedChain === chain)) === null || _a === void 0 ? void 0 : _a.walletConnector;
|
|
17
|
+
if (walletConnector) {
|
|
18
|
+
return walletConnector;
|
|
19
|
+
}
|
|
20
|
+
const fallbackConnector = (_b = walletConnectorOptions$1.find((wallet) => wallet.key === 'fallbackconnector')) === null || _b === void 0 ? void 0 : _b.walletConnector;
|
|
21
|
+
return fallbackConnector;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
exports.getWalletConnectorForWallet = getWalletConnectorForWallet;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
import { getWalletConnectorOptions } from '../../../store/state/walletConnectorOptions.js';
|
|
3
|
+
|
|
4
|
+
const getWalletConnectorForWallet = (wallet) => {
|
|
5
|
+
var _a, _b;
|
|
6
|
+
if (!wallet) {
|
|
7
|
+
return undefined;
|
|
8
|
+
}
|
|
9
|
+
const walletConnectorOptions = getWalletConnectorOptions();
|
|
10
|
+
const { key: walletKey, chain } = wallet;
|
|
11
|
+
const walletConnector = (_a = walletConnectorOptions.find((wallet) => walletKey === wallet.key &&
|
|
12
|
+
wallet.walletConnector.connectedChain === chain)) === null || _a === void 0 ? void 0 : _a.walletConnector;
|
|
13
|
+
if (walletConnector) {
|
|
14
|
+
return walletConnector;
|
|
15
|
+
}
|
|
16
|
+
const fallbackConnector = (_b = walletConnectorOptions.find((wallet) => wallet.key === 'fallbackconnector')) === null || _b === void 0 ? void 0 : _b.walletConnector;
|
|
17
|
+
return fallbackConnector;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export { getWalletConnectorForWallet };
|
|
@@ -30,6 +30,7 @@ var session = require('../../../data/api/session/session.cjs');
|
|
|
30
30
|
require('../../../locale/locale.cjs');
|
|
31
31
|
var getWalletProvider = require('../../functions/getWalletProvider/getWalletProvider.cjs');
|
|
32
32
|
var isConnectOnly = require('../authenticationHooks/helpers/isConnectOnly.cjs');
|
|
33
|
+
var getWalletConnectorForWallet = require('../../functions/getWalletConnectorForWallet/getWalletConnectorForWallet.cjs');
|
|
33
34
|
var updateUserWalletsFromConnectedWallets = require('./updateUserWalletsFromConnectedWallets/updateUserWalletsFromConnectedWallets.cjs');
|
|
34
35
|
|
|
35
36
|
const useConnectWallet = ({ authMode, clearPrimaryWalletId, enableVisitTrackingOnConnectOnly, environmentId, primaryWalletId, setPrimaryWalletId, walletConnectorOptions, handleConnectedWallet, setShowAuthFlow, isBridgeFlow, user, }) => {
|
|
@@ -136,10 +137,11 @@ const useConnectWallet = ({ authMode, clearPrimaryWalletId, enableVisitTrackingO
|
|
|
136
137
|
var _a;
|
|
137
138
|
const clonedConnectedWalletsList = [...connectedWallets];
|
|
138
139
|
const connectedWalletIndex = clonedConnectedWalletsList.findIndex((connectedWallet) => connectedWallet.id === walletId);
|
|
139
|
-
if (connectedWalletIndex
|
|
140
|
-
|
|
141
|
-
(_a = walletObject.address) !== null && _a !== void 0 ? _a : clonedConnectedWalletsList[connectedWalletIndex].address;
|
|
140
|
+
if (connectedWalletIndex < 0) {
|
|
141
|
+
return;
|
|
142
142
|
}
|
|
143
|
+
clonedConnectedWalletsList[connectedWalletIndex] =
|
|
144
|
+
clonedConnectedWalletsList[connectedWalletIndex].connector.createWallet(Object.assign(Object.assign({}, clonedConnectedWalletsList[connectedWalletIndex]), { address: (_a = walletObject.address) !== null && _a !== void 0 ? _a : clonedConnectedWalletsList[connectedWalletIndex].address, connector: getWalletConnectorForWallet.getWalletConnectorForWallet(clonedConnectedWalletsList[connectedWalletIndex]) }));
|
|
143
145
|
setConnectedWallets(clonedConnectedWalletsList);
|
|
144
146
|
}, [connectedWallets, setConnectedWallets]);
|
|
145
147
|
// Keeps connected wallet data inside localStorage
|
|
@@ -26,6 +26,7 @@ import { createVisit } from '../../../data/api/session/session.js';
|
|
|
26
26
|
import '../../../locale/locale.js';
|
|
27
27
|
import { getWalletProvider } from '../../functions/getWalletProvider/getWalletProvider.js';
|
|
28
28
|
import { isConnectOnly } from '../authenticationHooks/helpers/isConnectOnly.js';
|
|
29
|
+
import { getWalletConnectorForWallet } from '../../functions/getWalletConnectorForWallet/getWalletConnectorForWallet.js';
|
|
29
30
|
import { updateUserWalletsFromConnectedWallets } from './updateUserWalletsFromConnectedWallets/updateUserWalletsFromConnectedWallets.js';
|
|
30
31
|
|
|
31
32
|
const useConnectWallet = ({ authMode, clearPrimaryWalletId, enableVisitTrackingOnConnectOnly, environmentId, primaryWalletId, setPrimaryWalletId, walletConnectorOptions, handleConnectedWallet, setShowAuthFlow, isBridgeFlow, user, }) => {
|
|
@@ -132,10 +133,11 @@ const useConnectWallet = ({ authMode, clearPrimaryWalletId, enableVisitTrackingO
|
|
|
132
133
|
var _a;
|
|
133
134
|
const clonedConnectedWalletsList = [...connectedWallets];
|
|
134
135
|
const connectedWalletIndex = clonedConnectedWalletsList.findIndex((connectedWallet) => connectedWallet.id === walletId);
|
|
135
|
-
if (connectedWalletIndex
|
|
136
|
-
|
|
137
|
-
(_a = walletObject.address) !== null && _a !== void 0 ? _a : clonedConnectedWalletsList[connectedWalletIndex].address;
|
|
136
|
+
if (connectedWalletIndex < 0) {
|
|
137
|
+
return;
|
|
138
138
|
}
|
|
139
|
+
clonedConnectedWalletsList[connectedWalletIndex] =
|
|
140
|
+
clonedConnectedWalletsList[connectedWalletIndex].connector.createWallet(Object.assign(Object.assign({}, clonedConnectedWalletsList[connectedWalletIndex]), { address: (_a = walletObject.address) !== null && _a !== void 0 ? _a : clonedConnectedWalletsList[connectedWalletIndex].address, connector: getWalletConnectorForWallet(clonedConnectedWalletsList[connectedWalletIndex]) }));
|
|
139
141
|
setConnectedWallets(clonedConnectedWalletsList);
|
|
140
142
|
}, [connectedWallets, setConnectedWallets]);
|
|
141
143
|
// Keeps connected wallet data inside localStorage
|
|
@@ -19,6 +19,7 @@ require('../../constants/values.cjs');
|
|
|
19
19
|
require('../../../store/state/loadingAndLifecycle.cjs');
|
|
20
20
|
require('../../../shared/consts/index.cjs');
|
|
21
21
|
require('../../../events/dynamicEvents.cjs');
|
|
22
|
+
var useWalletConnectorEvent = require('../events/useWalletConnectorEvent/useWalletConnectorEvent.cjs');
|
|
22
23
|
require('../../../context/CaptchaContext/CaptchaContext.cjs');
|
|
23
24
|
require('../../../context/ErrorContext/ErrorContext.cjs');
|
|
24
25
|
require('@dynamic-labs/multi-wallet');
|
|
@@ -140,6 +141,14 @@ const useConnectedWalletsNetworkValidation = () => {
|
|
|
140
141
|
setShowAuthFlow,
|
|
141
142
|
setView,
|
|
142
143
|
]);
|
|
144
|
+
const uniqueConnectors = React.useMemo(() => {
|
|
145
|
+
const connectors = connectedWallets.map(({ connector }) => connector);
|
|
146
|
+
const allWalletConnectors = new Set([...connectors].filter((connector) => Boolean(connector)));
|
|
147
|
+
return Array.from(allWalletConnectors);
|
|
148
|
+
}, [connectedWallets]);
|
|
149
|
+
useWalletConnectorEvent.useWalletConnectorEvent(uniqueConnectors, 'chainChange', ({ chain }) => {
|
|
150
|
+
validateNetwork();
|
|
151
|
+
});
|
|
143
152
|
React.useEffect(() => {
|
|
144
153
|
/**
|
|
145
154
|
* This check was added to prevent the "wrong network" modal from appearing
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use client'
|
|
2
2
|
import { __awaiter } from '../../../../../_virtual/_tslib.js';
|
|
3
|
-
import { useCallback, useEffect } from 'react';
|
|
3
|
+
import { useCallback, useMemo, useEffect } from 'react';
|
|
4
4
|
import '../../../context/DynamicContext/DynamicContext.js';
|
|
5
5
|
import '@dynamic-labs/sdk-api-core';
|
|
6
6
|
import '../../../shared/logger.js';
|
|
@@ -15,6 +15,7 @@ import '../../constants/values.js';
|
|
|
15
15
|
import '../../../store/state/loadingAndLifecycle.js';
|
|
16
16
|
import '../../../shared/consts/index.js';
|
|
17
17
|
import '../../../events/dynamicEvents.js';
|
|
18
|
+
import { useWalletConnectorEvent } from '../events/useWalletConnectorEvent/useWalletConnectorEvent.js';
|
|
18
19
|
import '../../../context/CaptchaContext/CaptchaContext.js';
|
|
19
20
|
import '../../../context/ErrorContext/ErrorContext.js';
|
|
20
21
|
import '@dynamic-labs/multi-wallet';
|
|
@@ -136,6 +137,14 @@ const useConnectedWalletsNetworkValidation = () => {
|
|
|
136
137
|
setShowAuthFlow,
|
|
137
138
|
setView,
|
|
138
139
|
]);
|
|
140
|
+
const uniqueConnectors = useMemo(() => {
|
|
141
|
+
const connectors = connectedWallets.map(({ connector }) => connector);
|
|
142
|
+
const allWalletConnectors = new Set([...connectors].filter((connector) => Boolean(connector)));
|
|
143
|
+
return Array.from(allWalletConnectors);
|
|
144
|
+
}, [connectedWallets]);
|
|
145
|
+
useWalletConnectorEvent(uniqueConnectors, 'chainChange', ({ chain }) => {
|
|
146
|
+
validateNetwork();
|
|
147
|
+
});
|
|
139
148
|
useEffect(() => {
|
|
140
149
|
/**
|
|
141
150
|
* This check was added to prevent the "wrong network" modal from appearing
|
|
@@ -187,7 +187,7 @@ const useSocialAuth = ({ sessionTimeout, onSettled, onError, onFarcasterUrl, })
|
|
|
187
187
|
verifyFunction: () => apiCall(),
|
|
188
188
|
});
|
|
189
189
|
}), [handleError, initAuth, onSettled]);
|
|
190
|
-
const completeConnection = React.useCallback((_a) => _tslib.__awaiter(void 0, [_a], void 0, function* ({ authMode, provider, state, authCode, captchaToken, verifier, telegramAuthToken, }) {
|
|
190
|
+
const completeConnection = React.useCallback((_a) => _tslib.__awaiter(void 0, [_a], void 0, function* ({ authMode, provider, state, authCode, captchaToken, verifier, telegramAuthToken, forceCreateUser = false, }) {
|
|
191
191
|
try {
|
|
192
192
|
let sessionPublicKey = undefined;
|
|
193
193
|
if (shouldRegisterSessionKeysOnSignin()) {
|
|
@@ -197,10 +197,11 @@ const useSocialAuth = ({ sessionTimeout, onSettled, onError, onFarcasterUrl, })
|
|
|
197
197
|
if (authMode === 'signin') {
|
|
198
198
|
if (provider === sdkApiCore.ProviderEnum.Telegram && telegramAuthToken) {
|
|
199
199
|
const apiCall = () => oauth.telegramSignIn(environmentId, {
|
|
200
|
+
forceCreateUser,
|
|
200
201
|
sessionPublicKey,
|
|
201
202
|
telegramAuthToken,
|
|
202
203
|
});
|
|
203
|
-
yield signInAccount(provider, apiCall);
|
|
204
|
+
return yield signInAccount(provider, apiCall);
|
|
204
205
|
}
|
|
205
206
|
else if (provider === sdkApiCore.ProviderEnum.Telegram) {
|
|
206
207
|
const apiCall = () => oauth.telegramSignIn(environmentId, {
|
|
@@ -18,7 +18,7 @@ export type ConnectSocialAccountProps = {
|
|
|
18
18
|
};
|
|
19
19
|
export declare const useSocialAuth: ({ sessionTimeout, onSettled, onError, onFarcasterUrl, }: UseSocialAuthProps) => {
|
|
20
20
|
readonly checkValidProvider: (provider: ProviderEnum, authMode: SocialAuthMode) => boolean;
|
|
21
|
-
readonly completeConnection: ({ authMode, provider, state, authCode, captchaToken, verifier, telegramAuthToken, }: {
|
|
21
|
+
readonly completeConnection: ({ authMode, provider, state, authCode, captchaToken, verifier, telegramAuthToken, forceCreateUser, }: {
|
|
22
22
|
authMode: SocialAuthMode;
|
|
23
23
|
provider: ProviderEnum;
|
|
24
24
|
state: string;
|
|
@@ -26,6 +26,7 @@ export declare const useSocialAuth: ({ sessionTimeout, onSettled, onError, onFar
|
|
|
26
26
|
authCode?: string | undefined;
|
|
27
27
|
verifier?: string | undefined;
|
|
28
28
|
telegramAuthToken?: string | undefined;
|
|
29
|
+
forceCreateUser?: boolean | undefined;
|
|
29
30
|
}) => Promise<void>;
|
|
30
31
|
readonly connectSocialAccount: ({ authMode, provider, validator, captchaToken, redirectUrl, telegramAuthToken, }: ConnectSocialAccountProps) => Promise<void>;
|
|
31
32
|
readonly error: SocialOAuthError | undefined;
|
|
@@ -183,7 +183,7 @@ const useSocialAuth = ({ sessionTimeout, onSettled, onError, onFarcasterUrl, })
|
|
|
183
183
|
verifyFunction: () => apiCall(),
|
|
184
184
|
});
|
|
185
185
|
}), [handleError, initAuth$1, onSettled]);
|
|
186
|
-
const completeConnection = useCallback((_a) => __awaiter(void 0, [_a], void 0, function* ({ authMode, provider, state, authCode, captchaToken, verifier, telegramAuthToken, }) {
|
|
186
|
+
const completeConnection = useCallback((_a) => __awaiter(void 0, [_a], void 0, function* ({ authMode, provider, state, authCode, captchaToken, verifier, telegramAuthToken, forceCreateUser = false, }) {
|
|
187
187
|
try {
|
|
188
188
|
let sessionPublicKey = undefined;
|
|
189
189
|
if (shouldRegisterSessionKeysOnSignin()) {
|
|
@@ -193,10 +193,11 @@ const useSocialAuth = ({ sessionTimeout, onSettled, onError, onFarcasterUrl, })
|
|
|
193
193
|
if (authMode === 'signin') {
|
|
194
194
|
if (provider === ProviderEnum.Telegram && telegramAuthToken) {
|
|
195
195
|
const apiCall = () => telegramSignIn(environmentId, {
|
|
196
|
+
forceCreateUser,
|
|
196
197
|
sessionPublicKey,
|
|
197
198
|
telegramAuthToken,
|
|
198
199
|
});
|
|
199
|
-
yield signInAccount(provider, apiCall);
|
|
200
|
+
return yield signInAccount(provider, apiCall);
|
|
200
201
|
}
|
|
201
202
|
else if (provider === ProviderEnum.Telegram) {
|
|
202
203
|
const apiCall = () => telegramSignIn(environmentId, {
|
|
@@ -4,7 +4,6 @@
|
|
|
4
4
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
5
|
|
|
6
6
|
var _tslib = require('../../../../../_virtual/_tslib.cjs');
|
|
7
|
-
var React = require('react');
|
|
8
7
|
var sdkApiCore = require('@dynamic-labs/sdk-api-core');
|
|
9
8
|
require('../../constants/values.cjs');
|
|
10
9
|
require('@dynamic-labs/utils');
|
|
@@ -16,12 +15,14 @@ require('@dynamic-labs/iconic');
|
|
|
16
15
|
require('@dynamic-labs/wallet-connector-core');
|
|
17
16
|
require('react/jsx-runtime');
|
|
18
17
|
require('../../../context/ViewContext/ViewContext.cjs');
|
|
18
|
+
require('react');
|
|
19
19
|
require('@dynamic-labs/wallet-book');
|
|
20
20
|
require('../../../store/state/loadingAndLifecycle.cjs');
|
|
21
21
|
require('../../../shared/consts/index.cjs');
|
|
22
22
|
var isProviderEnabled = require('../../functions/isProviderEnabled/isProviderEnabled.cjs');
|
|
23
23
|
require('../../../config/ApiEndpoint.cjs');
|
|
24
24
|
require('../../../store/state/user/user.cjs');
|
|
25
|
+
var oauth = require('../../../data/api/oauth/oauth.cjs');
|
|
25
26
|
require('../../../locale/locale.cjs');
|
|
26
27
|
require('../../../store/state/projectSettings/projectSettings.cjs');
|
|
27
28
|
require('../../../context/DynamicContext/DynamicContext.cjs');
|
|
@@ -94,35 +95,48 @@ require('../../../store/state/tokenBalances.cjs');
|
|
|
94
95
|
var useInternalDynamicContext = require('../../../context/DynamicContext/useDynamicContext/useInternalDynamicContext.cjs');
|
|
95
96
|
|
|
96
97
|
const useTelegramLogin = () => {
|
|
97
|
-
const { sdkHasLoaded, user, projectSettings } = useInternalDynamicContext.useInternalDynamicContext();
|
|
98
|
+
const { sdkHasLoaded, user, projectSettings, environmentId } = useInternalDynamicContext.useInternalDynamicContext();
|
|
98
99
|
const providers = (projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.providers) || [];
|
|
99
100
|
const { completeConnection } = useSocialAuth.useSocialAuth({
|
|
100
101
|
sessionTimeout: 20000,
|
|
101
102
|
});
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
103
|
+
const getTelegramAuthToken = () => {
|
|
104
|
+
// in non-browser environments like Node.js
|
|
105
|
+
// or during server-side rendering (e.g., with frameworks like Next.js).
|
|
106
|
+
if (typeof window === 'undefined') {
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
const search = new URLSearchParams(window.location.search);
|
|
110
|
+
return search.get('telegramAuthToken') || undefined;
|
|
111
|
+
};
|
|
112
|
+
const canProceedWithTelegram = (telegramAuthToken) => isProviderEnabled.isProviderEnabled(providers, sdkApiCore.ProviderEnum.Telegram) &&
|
|
113
|
+
sdkHasLoaded &&
|
|
114
|
+
!user &&
|
|
115
|
+
telegramAuthToken;
|
|
116
|
+
const isAuthWithTelegram = () => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
117
|
+
const telegramAuthToken = getTelegramAuthToken();
|
|
118
|
+
if (!canProceedWithTelegram(telegramAuthToken)) {
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
return oauth.isUserLinkedWithTelegram(environmentId, { telegramAuthToken });
|
|
122
|
+
});
|
|
123
|
+
const telegramSignIn = (...args_1) => _tslib.__awaiter(void 0, [...args_1], void 0, function* ({ forceCreateUser = false, } = {}) {
|
|
124
|
+
const telegramAuthToken = getTelegramAuthToken();
|
|
125
|
+
if (!canProceedWithTelegram(telegramAuthToken)) {
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
128
|
+
yield completeConnection({
|
|
129
|
+
authMode: 'signin',
|
|
130
|
+
forceCreateUser,
|
|
131
|
+
provider: sdkApiCore.ProviderEnum.Telegram,
|
|
132
|
+
state: '',
|
|
133
|
+
telegramAuthToken,
|
|
123
134
|
});
|
|
124
|
-
|
|
125
|
-
|
|
135
|
+
});
|
|
136
|
+
return {
|
|
137
|
+
isAuthWithTelegram,
|
|
138
|
+
telegramSignIn,
|
|
139
|
+
};
|
|
126
140
|
};
|
|
127
141
|
|
|
128
142
|
exports.useTelegramLogin = useTelegramLogin;
|
|
@@ -1 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
interface TelegramConfig {
|
|
2
|
+
forceCreateUser?: boolean;
|
|
3
|
+
}
|
|
4
|
+
export declare const useTelegramLogin: () => {
|
|
5
|
+
isAuthWithTelegram: () => Promise<boolean | undefined>;
|
|
6
|
+
telegramSignIn: ({ forceCreateUser, }?: TelegramConfig) => Promise<void>;
|
|
7
|
+
};
|
|
8
|
+
export {};
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
'use client'
|
|
2
2
|
import { __awaiter } from '../../../../../_virtual/_tslib.js';
|
|
3
|
-
import { useEffect } from 'react';
|
|
4
3
|
import { ProviderEnum } from '@dynamic-labs/sdk-api-core';
|
|
5
4
|
import '../../constants/values.js';
|
|
6
5
|
import '@dynamic-labs/utils';
|
|
@@ -12,12 +11,14 @@ import '@dynamic-labs/iconic';
|
|
|
12
11
|
import '@dynamic-labs/wallet-connector-core';
|
|
13
12
|
import 'react/jsx-runtime';
|
|
14
13
|
import '../../../context/ViewContext/ViewContext.js';
|
|
14
|
+
import 'react';
|
|
15
15
|
import '@dynamic-labs/wallet-book';
|
|
16
16
|
import '../../../store/state/loadingAndLifecycle.js';
|
|
17
17
|
import '../../../shared/consts/index.js';
|
|
18
18
|
import { isProviderEnabled } from '../../functions/isProviderEnabled/isProviderEnabled.js';
|
|
19
19
|
import '../../../config/ApiEndpoint.js';
|
|
20
20
|
import '../../../store/state/user/user.js';
|
|
21
|
+
import { isUserLinkedWithTelegram } from '../../../data/api/oauth/oauth.js';
|
|
21
22
|
import '../../../locale/locale.js';
|
|
22
23
|
import '../../../store/state/projectSettings/projectSettings.js';
|
|
23
24
|
import '../../../context/DynamicContext/DynamicContext.js';
|
|
@@ -90,35 +91,48 @@ import '../../../store/state/tokenBalances.js';
|
|
|
90
91
|
import { useInternalDynamicContext } from '../../../context/DynamicContext/useDynamicContext/useInternalDynamicContext.js';
|
|
91
92
|
|
|
92
93
|
const useTelegramLogin = () => {
|
|
93
|
-
const { sdkHasLoaded, user, projectSettings } = useInternalDynamicContext();
|
|
94
|
+
const { sdkHasLoaded, user, projectSettings, environmentId } = useInternalDynamicContext();
|
|
94
95
|
const providers = (projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.providers) || [];
|
|
95
96
|
const { completeConnection } = useSocialAuth({
|
|
96
97
|
sessionTimeout: 20000,
|
|
97
98
|
});
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
99
|
+
const getTelegramAuthToken = () => {
|
|
100
|
+
// in non-browser environments like Node.js
|
|
101
|
+
// or during server-side rendering (e.g., with frameworks like Next.js).
|
|
102
|
+
if (typeof window === 'undefined') {
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
const search = new URLSearchParams(window.location.search);
|
|
106
|
+
return search.get('telegramAuthToken') || undefined;
|
|
107
|
+
};
|
|
108
|
+
const canProceedWithTelegram = (telegramAuthToken) => isProviderEnabled(providers, ProviderEnum.Telegram) &&
|
|
109
|
+
sdkHasLoaded &&
|
|
110
|
+
!user &&
|
|
111
|
+
telegramAuthToken;
|
|
112
|
+
const isAuthWithTelegram = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
113
|
+
const telegramAuthToken = getTelegramAuthToken();
|
|
114
|
+
if (!canProceedWithTelegram(telegramAuthToken)) {
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
return isUserLinkedWithTelegram(environmentId, { telegramAuthToken });
|
|
118
|
+
});
|
|
119
|
+
const telegramSignIn = (...args_1) => __awaiter(void 0, [...args_1], void 0, function* ({ forceCreateUser = false, } = {}) {
|
|
120
|
+
const telegramAuthToken = getTelegramAuthToken();
|
|
121
|
+
if (!canProceedWithTelegram(telegramAuthToken)) {
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
124
|
+
yield completeConnection({
|
|
125
|
+
authMode: 'signin',
|
|
126
|
+
forceCreateUser,
|
|
127
|
+
provider: ProviderEnum.Telegram,
|
|
128
|
+
state: '',
|
|
129
|
+
telegramAuthToken,
|
|
119
130
|
});
|
|
120
|
-
|
|
121
|
-
|
|
131
|
+
});
|
|
132
|
+
return {
|
|
133
|
+
isAuthWithTelegram,
|
|
134
|
+
telegramSignIn,
|
|
135
|
+
};
|
|
122
136
|
};
|
|
123
137
|
|
|
124
138
|
export { useTelegramLogin };
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
5
|
|
|
6
6
|
var sdkApiCore = require('@dynamic-labs/sdk-api-core');
|
|
7
|
+
var walletConnectorCore = require('@dynamic-labs/wallet-connector-core');
|
|
7
8
|
var findWalletOptionFor = require('../../../../functions/findWalletOptionFor/findWalletOptionFor.cjs');
|
|
8
9
|
var shouldManuallyReconnectOnRefresh = require('../../../../functions/shouldManuallyReconnectOnRefresh/shouldManuallyReconnectOnRefresh.cjs');
|
|
9
10
|
var convertLegacyPhantomLedgerConnector = require('../convertLegacyPhantomLedgerConnector/convertLegacyPhantomLedgerConnector.cjs');
|
|
@@ -17,7 +18,7 @@ const createLinkedWalletsFromWalletOptions = ({ user, walletConnectorOptions, pr
|
|
|
17
18
|
return user.verifiedCredentials
|
|
18
19
|
.map(convertLegacyPhantomLedger)
|
|
19
20
|
.map((account) => {
|
|
20
|
-
var _a;
|
|
21
|
+
var _a, _b;
|
|
21
22
|
const wallet = findWalletOptionFor.findWalletOptionFor(account, walletConnectorOptions);
|
|
22
23
|
// this probably shouldn't happen. this would mean that the user has an account linked
|
|
23
24
|
// with wallet W, but the customer has toggled off wallet W or the chain that
|
|
@@ -29,6 +30,12 @@ const createLinkedWalletsFromWalletOptions = ({ user, walletConnectorOptions, pr
|
|
|
29
30
|
shouldManuallyReconnectOnRefresh.shouldManuallyReconnectOnRefresh(wallet.walletConnector)) {
|
|
30
31
|
wallet.walletConnector.connect();
|
|
31
32
|
}
|
|
33
|
+
// only checking for ledger hardware wallets since we only specify ledger as a hardware wallet
|
|
34
|
+
if (((_a = account.walletProperties) === null || _a === void 0 ? void 0 : _a.hardwareWallet) ===
|
|
35
|
+
sdkApiCore.HardwareWalletEnum.Ledger &&
|
|
36
|
+
walletConnectorCore.isHardwareWalletConnector(wallet.walletConnector)) {
|
|
37
|
+
wallet.walletConnector.isHardwareWalletEnabled = true;
|
|
38
|
+
}
|
|
32
39
|
// this account is the owner of a smart wallet, and should not be surfaced
|
|
33
40
|
if (smartWallet.isOwnerOfASmartWallet(account, user.verifiedCredentials)) {
|
|
34
41
|
return null;
|
|
@@ -48,7 +55,7 @@ const createLinkedWalletsFromWalletOptions = ({ user, walletConnectorOptions, pr
|
|
|
48
55
|
connector: wallet.walletConnector,
|
|
49
56
|
id: account.id,
|
|
50
57
|
isAuthenticated: true,
|
|
51
|
-
key: (
|
|
58
|
+
key: (_b = account.walletName) !== null && _b !== void 0 ? _b : wallet.walletConnector.key,
|
|
52
59
|
});
|
|
53
60
|
}
|
|
54
61
|
return null;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
'use client'
|
|
2
|
-
import { WalletProviderEnum } from '@dynamic-labs/sdk-api-core';
|
|
2
|
+
import { HardwareWalletEnum, WalletProviderEnum } from '@dynamic-labs/sdk-api-core';
|
|
3
|
+
import { isHardwareWalletConnector } from '@dynamic-labs/wallet-connector-core';
|
|
3
4
|
import { findWalletOptionFor } from '../../../../functions/findWalletOptionFor/findWalletOptionFor.js';
|
|
4
5
|
import { shouldManuallyReconnectOnRefresh } from '../../../../functions/shouldManuallyReconnectOnRefresh/shouldManuallyReconnectOnRefresh.js';
|
|
5
6
|
import { convertLegacyPhantomLedgerConnector } from '../convertLegacyPhantomLedgerConnector/convertLegacyPhantomLedgerConnector.js';
|
|
@@ -13,7 +14,7 @@ const createLinkedWalletsFromWalletOptions = ({ user, walletConnectorOptions, pr
|
|
|
13
14
|
return user.verifiedCredentials
|
|
14
15
|
.map(convertLegacyPhantomLedger)
|
|
15
16
|
.map((account) => {
|
|
16
|
-
var _a;
|
|
17
|
+
var _a, _b;
|
|
17
18
|
const wallet = findWalletOptionFor(account, walletConnectorOptions);
|
|
18
19
|
// this probably shouldn't happen. this would mean that the user has an account linked
|
|
19
20
|
// with wallet W, but the customer has toggled off wallet W or the chain that
|
|
@@ -25,6 +26,12 @@ const createLinkedWalletsFromWalletOptions = ({ user, walletConnectorOptions, pr
|
|
|
25
26
|
shouldManuallyReconnectOnRefresh(wallet.walletConnector)) {
|
|
26
27
|
wallet.walletConnector.connect();
|
|
27
28
|
}
|
|
29
|
+
// only checking for ledger hardware wallets since we only specify ledger as a hardware wallet
|
|
30
|
+
if (((_a = account.walletProperties) === null || _a === void 0 ? void 0 : _a.hardwareWallet) ===
|
|
31
|
+
HardwareWalletEnum.Ledger &&
|
|
32
|
+
isHardwareWalletConnector(wallet.walletConnector)) {
|
|
33
|
+
wallet.walletConnector.isHardwareWalletEnabled = true;
|
|
34
|
+
}
|
|
28
35
|
// this account is the owner of a smart wallet, and should not be surfaced
|
|
29
36
|
if (isOwnerOfASmartWallet(account, user.verifiedCredentials)) {
|
|
30
37
|
return null;
|
|
@@ -44,7 +51,7 @@ const createLinkedWalletsFromWalletOptions = ({ user, walletConnectorOptions, pr
|
|
|
44
51
|
connector: wallet.walletConnector,
|
|
45
52
|
id: account.id,
|
|
46
53
|
isAuthenticated: true,
|
|
47
|
-
key: (
|
|
54
|
+
key: (_b = account.walletName) !== null && _b !== void 0 ? _b : wallet.walletConnector.key,
|
|
48
55
|
});
|
|
49
56
|
}
|
|
50
57
|
return null;
|
|
@@ -22,13 +22,6 @@ var useWalletConnectorEvent = require('../events/useWalletConnectorEvent/useWall
|
|
|
22
22
|
var dynamicEvents = require('../../../events/dynamicEvents.cjs');
|
|
23
23
|
|
|
24
24
|
const useWalletEventListeners = ({ disconnectWallet, handleLogOut, multiWallet, multiWalletWidgetState, primaryWallet, secondaryWallets, selectedWalletConnector, selectedWalletWithAction, setSelectedWalletConnectorKey, setSelectedWalletWithAction, setMultiWalletWidgetState, user, setPrimaryWalletId, authMode, refreshConnectedWallet, detectNewWalletsForLinking, }) => {
|
|
25
|
-
useWalletConnectorEvent.useWalletConnectorEvent(primaryWallet === null || primaryWallet === void 0 ? void 0 : primaryWallet.connector, 'chainChange', ({ chain }) => {
|
|
26
|
-
logger.logger.debug('primary wallet chain change', { chain });
|
|
27
|
-
if (!primaryWallet) {
|
|
28
|
-
return;
|
|
29
|
-
}
|
|
30
|
-
refreshConnectedWallet(primaryWallet.id, primaryWallet.connector);
|
|
31
|
-
});
|
|
32
25
|
const handleAccountChangeWhenAwaitingAccountSwitch = React.useCallback((isPrimaryWallet, newAddress) => {
|
|
33
26
|
logger.logger.debug('handleAccountChangeWhenAwaitingAccountSwitch', {
|
|
34
27
|
isPrimaryWallet,
|
|
@@ -149,13 +142,6 @@ const useWalletEventListeners = ({ disconnectWallet, handleLogOut, multiWallet,
|
|
|
149
142
|
handleAccountChangeWhenAwaitingAccountSwitch(false, (selectedWalletWithAction === null || selectedWalletWithAction === void 0 ? void 0 : selectedWalletWithAction.wallet.address) || '');
|
|
150
143
|
}
|
|
151
144
|
}));
|
|
152
|
-
useWalletConnectorEvent.useWalletConnectorEvent(uniqueNonPrimaryWallets, 'chainChange', (_, changedConnector) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
153
|
-
logger.logger.debug('secondary wallet chain change');
|
|
154
|
-
// Get all wallets with this connector
|
|
155
|
-
const affectedWallets = secondaryWallets.filter(({ connector }) => connector.key === changedConnector.key);
|
|
156
|
-
for (const wallet of affectedWallets)
|
|
157
|
-
refreshConnectedWallet(wallet.id, wallet.connector);
|
|
158
|
-
}));
|
|
159
145
|
useWalletConnectorEvent.useWalletConnectorEvent(primaryWallet === null || primaryWallet === void 0 ? void 0 : primaryWallet.connector, 'disconnect', () => {
|
|
160
146
|
logger.logger.debug('primary wallet disconnect');
|
|
161
147
|
if (authMode === 'connect-only') {
|
|
@@ -18,13 +18,6 @@ import { useWalletConnectorEvent } from '../events/useWalletConnectorEvent/useWa
|
|
|
18
18
|
import { dynamicEvents } from '../../../events/dynamicEvents.js';
|
|
19
19
|
|
|
20
20
|
const useWalletEventListeners = ({ disconnectWallet, handleLogOut, multiWallet, multiWalletWidgetState, primaryWallet, secondaryWallets, selectedWalletConnector, selectedWalletWithAction, setSelectedWalletConnectorKey, setSelectedWalletWithAction, setMultiWalletWidgetState, user, setPrimaryWalletId, authMode, refreshConnectedWallet, detectNewWalletsForLinking, }) => {
|
|
21
|
-
useWalletConnectorEvent(primaryWallet === null || primaryWallet === void 0 ? void 0 : primaryWallet.connector, 'chainChange', ({ chain }) => {
|
|
22
|
-
logger.debug('primary wallet chain change', { chain });
|
|
23
|
-
if (!primaryWallet) {
|
|
24
|
-
return;
|
|
25
|
-
}
|
|
26
|
-
refreshConnectedWallet(primaryWallet.id, primaryWallet.connector);
|
|
27
|
-
});
|
|
28
21
|
const handleAccountChangeWhenAwaitingAccountSwitch = useCallback((isPrimaryWallet, newAddress) => {
|
|
29
22
|
logger.debug('handleAccountChangeWhenAwaitingAccountSwitch', {
|
|
30
23
|
isPrimaryWallet,
|
|
@@ -145,13 +138,6 @@ const useWalletEventListeners = ({ disconnectWallet, handleLogOut, multiWallet,
|
|
|
145
138
|
handleAccountChangeWhenAwaitingAccountSwitch(false, (selectedWalletWithAction === null || selectedWalletWithAction === void 0 ? void 0 : selectedWalletWithAction.wallet.address) || '');
|
|
146
139
|
}
|
|
147
140
|
}));
|
|
148
|
-
useWalletConnectorEvent(uniqueNonPrimaryWallets, 'chainChange', (_, changedConnector) => __awaiter(void 0, void 0, void 0, function* () {
|
|
149
|
-
logger.debug('secondary wallet chain change');
|
|
150
|
-
// Get all wallets with this connector
|
|
151
|
-
const affectedWallets = secondaryWallets.filter(({ connector }) => connector.key === changedConnector.key);
|
|
152
|
-
for (const wallet of affectedWallets)
|
|
153
|
-
refreshConnectedWallet(wallet.id, wallet.connector);
|
|
154
|
-
}));
|
|
155
141
|
useWalletConnectorEvent(primaryWallet === null || primaryWallet === void 0 ? void 0 : primaryWallet.connector, 'disconnect', () => {
|
|
156
142
|
logger.debug('primary wallet disconnect');
|
|
157
143
|
if (authMode === 'connect-only') {
|
|
@@ -104,7 +104,10 @@ require('qrcode');
|
|
|
104
104
|
const NoAccess = () => {
|
|
105
105
|
const { deniedAddress, setDeniedAddress, setDeniedOauthProvider, deniedOauthProvider, deniedOauthUsername, } = AccessDeniedContext.useAccessDeniedContext();
|
|
106
106
|
const { t } = reactI18next.useTranslation();
|
|
107
|
-
|
|
107
|
+
// deniedOauthProvider can be undefined
|
|
108
|
+
const accessIcon = deniedOauthProvider
|
|
109
|
+
? iconic.findSocialIcon(deniedOauthProvider)
|
|
110
|
+
: undefined;
|
|
108
111
|
const { selectedWalletConnector: walletConnector, socialMediaIconUrl, notInTheListImageUrl, accessDeniedButton, } = useInternalDynamicContext.useInternalDynamicContext();
|
|
109
112
|
const { displayedDestination: email } = VerificationContext.useVerification();
|
|
110
113
|
const { goToInitialView } = ViewContext.useViewContext();
|
|
@@ -100,7 +100,10 @@ import 'qrcode';
|
|
|
100
100
|
const NoAccess = () => {
|
|
101
101
|
const { deniedAddress, setDeniedAddress, setDeniedOauthProvider, deniedOauthProvider, deniedOauthUsername, } = useAccessDeniedContext();
|
|
102
102
|
const { t } = useTranslation();
|
|
103
|
-
|
|
103
|
+
// deniedOauthProvider can be undefined
|
|
104
|
+
const accessIcon = deniedOauthProvider
|
|
105
|
+
? findSocialIcon(deniedOauthProvider)
|
|
106
|
+
: undefined;
|
|
104
107
|
const { selectedWalletConnector: walletConnector, socialMediaIconUrl, notInTheListImageUrl, accessDeniedButton, } = useInternalDynamicContext();
|
|
105
108
|
const { displayedDestination: email } = useVerification();
|
|
106
109
|
const { goToInitialView } = useViewContext();
|