@dynamic-labs/sdk-react-core 0.18.100-viem.27 → 0.18.100-viem.29
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +18 -0
- package/package.cjs +1 -1
- package/package.js +1 -1
- package/package.json +8 -8
- package/src/lib/components/SignMessagePreview/SignMessagePreview.cjs +1 -1
- package/src/lib/components/SignMessagePreview/SignMessagePreview.js +1 -1
- package/src/lib/utils/functions/getProviderByType/getProviderByType.cjs +7 -0
- package/src/lib/utils/functions/getProviderByType/getProviderByType.d.ts +2 -0
- package/src/lib/utils/functions/getProviderByType/getProviderByType.js +3 -0
- package/src/lib/utils/functions/getProviderByType/index.d.ts +1 -0
- package/src/lib/utils/functions/index.d.ts +1 -0
- package/src/lib/utils/hooks/useSocialAccounts/useSocialAccounts.cjs +42 -13
- package/src/lib/utils/hooks/useSocialAccounts/useSocialAccounts.js +42 -13
- package/src/lib/utils/hooks/useUserUpdateRequest/useUserUpdateRequest.cjs +5 -1
- package/src/lib/utils/hooks/useUserUpdateRequest/useUserUpdateRequest.js +5 -1
- package/src/lib/views/SendBalanceView/SendBalanceView.cjs +19 -3
- package/src/lib/views/SendBalanceView/SendBalanceView.js +19 -3
- package/src/lib/views/SendBalanceView/components/TransactionStage/TransactionStage.cjs +3 -9
- package/src/lib/views/SendBalanceView/components/TransactionStage/TransactionStage.d.ts +2 -0
- package/src/lib/views/SendBalanceView/components/TransactionStage/TransactionStage.js +4 -10
package/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,22 @@
|
|
|
1
1
|
|
|
2
|
+
### [0.18.100-viem.29](https://github.com/dynamic-labs/DynamicAuth/compare/v0.18.100-viem.28...v0.18.100-viem.29) (2023-11-22)
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
### Bug Fixes
|
|
6
|
+
|
|
7
|
+
* allow metadata to be updated in updateUser hook ([#3947](https://github.com/dynamic-labs/DynamicAuth/issues/3947)) ([d6a3591](https://github.com/dynamic-labs/DynamicAuth/commit/d6a35918327b095d1a715942bc84cd9763e6864d))
|
|
8
|
+
* null safe check to window object ([#3919](https://github.com/dynamic-labs/DynamicAuth/issues/3919)) ([e466964](https://github.com/dynamic-labs/DynamicAuth/commit/e4669644c451139d443e534df238602d18fcda07))
|
|
9
|
+
* only process oauth message coming from the expected origin ([#3812](https://github.com/dynamic-labs/DynamicAuth/issues/3812)) ([ff98948](https://github.com/dynamic-labs/DynamicAuth/commit/ff98948b5415967ad3769887bb95d9c6d353a0c6))
|
|
10
|
+
|
|
11
|
+
### [0.18.100-viem.28](https://github.com/dynamic-labs/DynamicAuth/compare/v0.18.100-viem.27...v0.18.100-viem.28) (2023-10-30)
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
### Bug Fixes
|
|
15
|
+
|
|
16
|
+
* better handling of Coinbase wallet disconnect + upgrade to 3.7.2 ([#3691](https://github.com/dynamic-labs/DynamicAuth/issues/3691)) ([2385af8](https://github.com/dynamic-labs/DynamicAuth/commit/2385af8e960c3c3a23d2ce3379c50668a88b0478))
|
|
17
|
+
* Fix send balance in multiple chains ([#3767](https://github.com/dynamic-labs/DynamicAuth/issues/3767)) ([724d650](https://github.com/dynamic-labs/DynamicAuth/commit/724d650965a4e8cc864a1eeb787646399fce3814))
|
|
18
|
+
* safely render message to sign ([#3655](https://github.com/dynamic-labs/DynamicAuth/issues/3655)) ([#3661](https://github.com/dynamic-labs/DynamicAuth/issues/3661)) ([8ddc30a](https://github.com/dynamic-labs/DynamicAuth/commit/8ddc30a9b43e5ef47fedcaa58e9b20a9528b8cc6))
|
|
19
|
+
|
|
2
20
|
### [0.18.100-viem.27](https://github.com/dynamic-labs/DynamicAuth/compare/v0.18.100-viem.26...v0.18.100-viem.27) (2023-10-19)
|
|
3
21
|
|
|
4
22
|
|
package/package.cjs
CHANGED
package/package.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dynamic-labs/sdk-react-core",
|
|
3
|
-
"version": "0.18.100-viem.
|
|
3
|
+
"version": "0.18.100-viem.29",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/dynamic-labs/DynamicAuth.git",
|
|
@@ -15,13 +15,13 @@
|
|
|
15
15
|
"yup": "0.32.11",
|
|
16
16
|
"formik": "2.2.9",
|
|
17
17
|
"qrcode": "1.5.1",
|
|
18
|
-
"@dynamic-labs/logger": "0.18.100-viem.
|
|
19
|
-
"@dynamic-labs/multi-wallet": "0.18.100-viem.
|
|
20
|
-
"@dynamic-labs/rpc-providers": "0.18.100-viem.
|
|
21
|
-
"@dynamic-labs/types": "0.18.100-viem.
|
|
22
|
-
"@dynamic-labs/utils": "0.18.100-viem.
|
|
23
|
-
"@dynamic-labs/wallet-book": "0.18.100-viem.
|
|
24
|
-
"@dynamic-labs/wallet-connector-core": "0.18.100-viem.
|
|
18
|
+
"@dynamic-labs/logger": "0.18.100-viem.29",
|
|
19
|
+
"@dynamic-labs/multi-wallet": "0.18.100-viem.29",
|
|
20
|
+
"@dynamic-labs/rpc-providers": "0.18.100-viem.29",
|
|
21
|
+
"@dynamic-labs/types": "0.18.100-viem.29",
|
|
22
|
+
"@dynamic-labs/utils": "0.18.100-viem.29",
|
|
23
|
+
"@dynamic-labs/wallet-book": "0.18.100-viem.29",
|
|
24
|
+
"@dynamic-labs/wallet-connector-core": "0.18.100-viem.29",
|
|
25
25
|
"eventemitter3": "5.0.1"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
@@ -21,7 +21,7 @@ const SignMessagePreview = ({ message, }) => {
|
|
|
21
21
|
if (signTypedData) {
|
|
22
22
|
return (jsxRuntime.jsx(SignTypedDataPreview.SignTypedDataPreview, { currentType: signTypedData.primaryType, types: signTypedData.types, showTypeName: true, data: signTypedData.message }));
|
|
23
23
|
}
|
|
24
|
-
return (jsxRuntime.jsx(Typography.Typography, { color: 'primary', variant: 'body_normal', children: jsxRuntime.jsx("span", { style: { whiteSpace: 'pre-line' },
|
|
24
|
+
return (jsxRuntime.jsx(Typography.Typography, { color: 'primary', variant: 'body_normal', children: jsxRuntime.jsx("span", { style: { whiteSpace: 'pre-line' }, children: message }) }));
|
|
25
25
|
};
|
|
26
26
|
|
|
27
27
|
exports.SignMessagePreview = SignMessagePreview;
|
|
@@ -17,7 +17,7 @@ const SignMessagePreview = ({ message, }) => {
|
|
|
17
17
|
if (signTypedData) {
|
|
18
18
|
return (jsx(SignTypedDataPreview, { currentType: signTypedData.primaryType, types: signTypedData.types, showTypeName: true, data: signTypedData.message }));
|
|
19
19
|
}
|
|
20
|
-
return (jsx(Typography, { color: 'primary', variant: 'body_normal', children: jsx("span", { style: { whiteSpace: 'pre-line' },
|
|
20
|
+
return (jsx(Typography, { color: 'primary', variant: 'body_normal', children: jsx("span", { style: { whiteSpace: 'pre-line' }, children: message }) }));
|
|
21
21
|
};
|
|
22
22
|
|
|
23
23
|
export { SignMessagePreview };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { getProviderByType } from './getProviderByType';
|
|
@@ -29,6 +29,7 @@ var stringifyURIQuery = require('../../functions/stringifyURIQuery/stringifyURIQ
|
|
|
29
29
|
var digestSHA256 = require('../../functions/digestSHA256/digestSHA256.cjs');
|
|
30
30
|
var encodeBase64URL = require('../../functions/encodeBase64URL/encodeBase64URL.cjs');
|
|
31
31
|
var getRedirectURIOrigin = require('../../functions/getRedirectURIOrigin/getRedirectURIOrigin.cjs');
|
|
32
|
+
var getProviderByType = require('../../functions/getProviderByType/getProviderByType.cjs');
|
|
32
33
|
|
|
33
34
|
const socialProviders = [
|
|
34
35
|
'discord',
|
|
@@ -136,28 +137,52 @@ const useSocialAccounts = ({ sessionTimeout } = {
|
|
|
136
137
|
providersWaitingOauthMessages.current = Object.assign(Object.assign({}, providersWaitingOauthMessages.current), { [provider]: false });
|
|
137
138
|
};
|
|
138
139
|
const handleAuthWindowMessage = (event) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
139
|
-
var _c;
|
|
140
|
+
var _c, _d;
|
|
140
141
|
const message = event.data;
|
|
141
142
|
const isAuthorizationMessage = (message === null || message === void 0 ? void 0 : message.type) === 'authorization_response';
|
|
142
143
|
if (isAuthorizationMessage) {
|
|
143
144
|
logger.logger.debug('Message received', { data: message });
|
|
144
145
|
}
|
|
145
|
-
const
|
|
146
|
+
const apiProvider = getProviderByType.getProviderByType((_c = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.providers) !== null && _c !== void 0 ? _c : [], provider);
|
|
147
|
+
if (!(apiProvider === null || apiProvider === void 0 ? void 0 : apiProvider.redirectUrl)) {
|
|
148
|
+
return;
|
|
149
|
+
}
|
|
150
|
+
let expectedOrigin = '';
|
|
151
|
+
try {
|
|
152
|
+
const redirectUri = new URL(apiProvider.redirectUrl);
|
|
153
|
+
expectedOrigin = redirectUri.origin;
|
|
154
|
+
}
|
|
155
|
+
catch (e) {
|
|
156
|
+
logger.logger.error('Failed to parse social provider redirect url', {
|
|
157
|
+
error: e,
|
|
158
|
+
});
|
|
159
|
+
return;
|
|
160
|
+
}
|
|
161
|
+
const isExpectedOrigin = event.origin === expectedOrigin;
|
|
162
|
+
const isValidMessage = isAuthorizationMessage &&
|
|
163
|
+
(message === null || message === void 0 ? void 0 : message.provider) === provider &&
|
|
164
|
+
isExpectedOrigin;
|
|
146
165
|
// don't process imvalid messages for provider
|
|
147
166
|
if (!isValidMessage) {
|
|
148
167
|
return;
|
|
149
168
|
}
|
|
150
169
|
setIsProcessing(true);
|
|
151
|
-
if (!((
|
|
170
|
+
if (!((_d = providersWaitingOauthMessages.current) === null || _d === void 0 ? void 0 : _d[provider])) {
|
|
152
171
|
handleError(`Linking ${provider} account session timeout.`);
|
|
153
172
|
return;
|
|
154
173
|
}
|
|
155
174
|
clearListeners();
|
|
156
|
-
const { code, error } = message;
|
|
175
|
+
const { code, error, state: authState } = message;
|
|
157
176
|
if (error && error !== 'undefined') {
|
|
158
177
|
handleError(`Failed to link ${provider} social account: ${error}`);
|
|
159
178
|
return;
|
|
160
179
|
}
|
|
180
|
+
// check that the state we receive from message is the same state we calculated earlier
|
|
181
|
+
// this could be an attack
|
|
182
|
+
if (state !== authState) {
|
|
183
|
+
handleError(`Failed to link ${provider} social account: invalid auth state`);
|
|
184
|
+
return;
|
|
185
|
+
}
|
|
161
186
|
if (!code) {
|
|
162
187
|
handleError(`Failed to link ${provider} social account: no authorization code`);
|
|
163
188
|
return;
|
|
@@ -184,19 +209,23 @@ const useSocialAccounts = ({ sessionTimeout } = {
|
|
|
184
209
|
// different origins (our api redirect page and the app where the sdk is running)
|
|
185
210
|
const oauthIFrameUrl = `${getRedirectURIOrigin.getRedirectURIOrigin(loginUrl)}/sdkoauth`;
|
|
186
211
|
addOAuthIFrame(oauthIFrameUrl);
|
|
187
|
-
|
|
212
|
+
if (!((_b = providersWaitingOauthMessages.current) === null || _b === void 0 ? void 0 : _b[provider])) {
|
|
213
|
+
window.addEventListener('message', handleAuthWindowMessage);
|
|
214
|
+
providersWaitingOauthMessages.current = Object.assign(Object.assign({}, providersWaitingOauthMessages.current), { [provider]: true });
|
|
215
|
+
}
|
|
216
|
+
// add state param for all providers
|
|
217
|
+
const stateParam = stringifyURIQuery.stringifyURIQuery({
|
|
218
|
+
state,
|
|
219
|
+
});
|
|
220
|
+
let oauthLoginUrl = `${loginUrl}&${stateParam}`;
|
|
221
|
+
// only add pkce params for providers that support/require it
|
|
188
222
|
if (providersRequiringPkce.includes(provider)) {
|
|
189
223
|
const digest = yield digestSHA256.digestSHA256(verifier);
|
|
190
224
|
const pkceParams = stringifyURIQuery.stringifyURIQuery({
|
|
191
225
|
code_challenge: encodeBase64URL.encodeBase64URL(digest),
|
|
192
226
|
code_challenge_method: 'S256',
|
|
193
|
-
state: state,
|
|
194
227
|
});
|
|
195
|
-
oauthLoginUrl = `${
|
|
196
|
-
}
|
|
197
|
-
if (!((_b = providersWaitingOauthMessages.current) === null || _b === void 0 ? void 0 : _b[provider])) {
|
|
198
|
-
window.addEventListener('message', handleAuthWindowMessage);
|
|
199
|
-
providersWaitingOauthMessages.current = Object.assign(Object.assign({}, providersWaitingOauthMessages.current), { [provider]: true });
|
|
228
|
+
oauthLoginUrl = `${oauthLoginUrl}&${pkceParams}`;
|
|
200
229
|
}
|
|
201
230
|
const authWindow = window.open(oauthLoginUrl, '_blank', 'width=500,height=600');
|
|
202
231
|
if (!providersWithoutWindowOpenerRefence.includes(provider)) {
|
|
@@ -225,7 +254,7 @@ const useSocialAccounts = ({ sessionTimeout } = {
|
|
|
225
254
|
}
|
|
226
255
|
});
|
|
227
256
|
const unlinkSocialAccount = (provider) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
228
|
-
var
|
|
257
|
+
var _e;
|
|
229
258
|
setError(undefined);
|
|
230
259
|
setIsProcessing(true);
|
|
231
260
|
if (!checkValidProvider(provider)) {
|
|
@@ -241,7 +270,7 @@ const useSocialAccounts = ({ sessionTimeout } = {
|
|
|
241
270
|
const jwt = yield api.unlinkOAuth({
|
|
242
271
|
environmentId,
|
|
243
272
|
primaryWalletId,
|
|
244
|
-
verifiedCrentialId: (
|
|
273
|
+
verifiedCrentialId: (_e = verifiedCredential.id) !== null && _e !== void 0 ? _e : '',
|
|
245
274
|
}, String(userJwt));
|
|
246
275
|
if (!jwt) {
|
|
247
276
|
handleError(`Failed to unlink social account: ${provider} | ${verifiedCredential.id}`);
|
|
@@ -25,6 +25,7 @@ import { stringifyURIQuery } from '../../functions/stringifyURIQuery/stringifyUR
|
|
|
25
25
|
import { digestSHA256 } from '../../functions/digestSHA256/digestSHA256.js';
|
|
26
26
|
import { encodeBase64URL } from '../../functions/encodeBase64URL/encodeBase64URL.js';
|
|
27
27
|
import { getRedirectURIOrigin } from '../../functions/getRedirectURIOrigin/getRedirectURIOrigin.js';
|
|
28
|
+
import { getProviderByType } from '../../functions/getProviderByType/getProviderByType.js';
|
|
28
29
|
|
|
29
30
|
const socialProviders = [
|
|
30
31
|
'discord',
|
|
@@ -132,28 +133,52 @@ const useSocialAccounts = ({ sessionTimeout } = {
|
|
|
132
133
|
providersWaitingOauthMessages.current = Object.assign(Object.assign({}, providersWaitingOauthMessages.current), { [provider]: false });
|
|
133
134
|
};
|
|
134
135
|
const handleAuthWindowMessage = (event) => __awaiter(void 0, void 0, void 0, function* () {
|
|
135
|
-
var _c;
|
|
136
|
+
var _c, _d;
|
|
136
137
|
const message = event.data;
|
|
137
138
|
const isAuthorizationMessage = (message === null || message === void 0 ? void 0 : message.type) === 'authorization_response';
|
|
138
139
|
if (isAuthorizationMessage) {
|
|
139
140
|
logger.debug('Message received', { data: message });
|
|
140
141
|
}
|
|
141
|
-
const
|
|
142
|
+
const apiProvider = getProviderByType((_c = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.providers) !== null && _c !== void 0 ? _c : [], provider);
|
|
143
|
+
if (!(apiProvider === null || apiProvider === void 0 ? void 0 : apiProvider.redirectUrl)) {
|
|
144
|
+
return;
|
|
145
|
+
}
|
|
146
|
+
let expectedOrigin = '';
|
|
147
|
+
try {
|
|
148
|
+
const redirectUri = new URL(apiProvider.redirectUrl);
|
|
149
|
+
expectedOrigin = redirectUri.origin;
|
|
150
|
+
}
|
|
151
|
+
catch (e) {
|
|
152
|
+
logger.error('Failed to parse social provider redirect url', {
|
|
153
|
+
error: e,
|
|
154
|
+
});
|
|
155
|
+
return;
|
|
156
|
+
}
|
|
157
|
+
const isExpectedOrigin = event.origin === expectedOrigin;
|
|
158
|
+
const isValidMessage = isAuthorizationMessage &&
|
|
159
|
+
(message === null || message === void 0 ? void 0 : message.provider) === provider &&
|
|
160
|
+
isExpectedOrigin;
|
|
142
161
|
// don't process imvalid messages for provider
|
|
143
162
|
if (!isValidMessage) {
|
|
144
163
|
return;
|
|
145
164
|
}
|
|
146
165
|
setIsProcessing(true);
|
|
147
|
-
if (!((
|
|
166
|
+
if (!((_d = providersWaitingOauthMessages.current) === null || _d === void 0 ? void 0 : _d[provider])) {
|
|
148
167
|
handleError(`Linking ${provider} account session timeout.`);
|
|
149
168
|
return;
|
|
150
169
|
}
|
|
151
170
|
clearListeners();
|
|
152
|
-
const { code, error } = message;
|
|
171
|
+
const { code, error, state: authState } = message;
|
|
153
172
|
if (error && error !== 'undefined') {
|
|
154
173
|
handleError(`Failed to link ${provider} social account: ${error}`);
|
|
155
174
|
return;
|
|
156
175
|
}
|
|
176
|
+
// check that the state we receive from message is the same state we calculated earlier
|
|
177
|
+
// this could be an attack
|
|
178
|
+
if (state !== authState) {
|
|
179
|
+
handleError(`Failed to link ${provider} social account: invalid auth state`);
|
|
180
|
+
return;
|
|
181
|
+
}
|
|
157
182
|
if (!code) {
|
|
158
183
|
handleError(`Failed to link ${provider} social account: no authorization code`);
|
|
159
184
|
return;
|
|
@@ -180,19 +205,23 @@ const useSocialAccounts = ({ sessionTimeout } = {
|
|
|
180
205
|
// different origins (our api redirect page and the app where the sdk is running)
|
|
181
206
|
const oauthIFrameUrl = `${getRedirectURIOrigin(loginUrl)}/sdkoauth`;
|
|
182
207
|
addOAuthIFrame(oauthIFrameUrl);
|
|
183
|
-
|
|
208
|
+
if (!((_b = providersWaitingOauthMessages.current) === null || _b === void 0 ? void 0 : _b[provider])) {
|
|
209
|
+
window.addEventListener('message', handleAuthWindowMessage);
|
|
210
|
+
providersWaitingOauthMessages.current = Object.assign(Object.assign({}, providersWaitingOauthMessages.current), { [provider]: true });
|
|
211
|
+
}
|
|
212
|
+
// add state param for all providers
|
|
213
|
+
const stateParam = stringifyURIQuery({
|
|
214
|
+
state,
|
|
215
|
+
});
|
|
216
|
+
let oauthLoginUrl = `${loginUrl}&${stateParam}`;
|
|
217
|
+
// only add pkce params for providers that support/require it
|
|
184
218
|
if (providersRequiringPkce.includes(provider)) {
|
|
185
219
|
const digest = yield digestSHA256(verifier);
|
|
186
220
|
const pkceParams = stringifyURIQuery({
|
|
187
221
|
code_challenge: encodeBase64URL(digest),
|
|
188
222
|
code_challenge_method: 'S256',
|
|
189
|
-
state: state,
|
|
190
223
|
});
|
|
191
|
-
oauthLoginUrl = `${
|
|
192
|
-
}
|
|
193
|
-
if (!((_b = providersWaitingOauthMessages.current) === null || _b === void 0 ? void 0 : _b[provider])) {
|
|
194
|
-
window.addEventListener('message', handleAuthWindowMessage);
|
|
195
|
-
providersWaitingOauthMessages.current = Object.assign(Object.assign({}, providersWaitingOauthMessages.current), { [provider]: true });
|
|
224
|
+
oauthLoginUrl = `${oauthLoginUrl}&${pkceParams}`;
|
|
196
225
|
}
|
|
197
226
|
const authWindow = window.open(oauthLoginUrl, '_blank', 'width=500,height=600');
|
|
198
227
|
if (!providersWithoutWindowOpenerRefence.includes(provider)) {
|
|
@@ -221,7 +250,7 @@ const useSocialAccounts = ({ sessionTimeout } = {
|
|
|
221
250
|
}
|
|
222
251
|
});
|
|
223
252
|
const unlinkSocialAccount = (provider) => __awaiter(void 0, void 0, void 0, function* () {
|
|
224
|
-
var
|
|
253
|
+
var _e;
|
|
225
254
|
setError(undefined);
|
|
226
255
|
setIsProcessing(true);
|
|
227
256
|
if (!checkValidProvider(provider)) {
|
|
@@ -237,7 +266,7 @@ const useSocialAccounts = ({ sessionTimeout } = {
|
|
|
237
266
|
const jwt = yield unlinkOAuth({
|
|
238
267
|
environmentId,
|
|
239
268
|
primaryWalletId,
|
|
240
|
-
verifiedCrentialId: (
|
|
269
|
+
verifiedCrentialId: (_e = verifiedCredential.id) !== null && _e !== void 0 ? _e : '',
|
|
241
270
|
}, String(userJwt));
|
|
242
271
|
if (!jwt) {
|
|
243
272
|
handleError(`Failed to unlink social account: ${provider} | ${verifiedCredential.id}`);
|
|
@@ -40,6 +40,7 @@ const userFieldsSchema = yup.object().shape({
|
|
|
40
40
|
kdaWallet: yup.string(),
|
|
41
41
|
lastName: yup.string(),
|
|
42
42
|
ltcWallet: yup.string(),
|
|
43
|
+
metadata: yup.object(),
|
|
43
44
|
newsletterNotification: yup.boolean(),
|
|
44
45
|
phoneNumber: yup.string(),
|
|
45
46
|
tShirtSize: yup.string(),
|
|
@@ -55,10 +56,13 @@ const useUserUpdateRequestInternal = ({ validationSchemaStripUnknown, }) => {
|
|
|
55
56
|
const { updateUserProfileByJWT } = useUpdateUserProfileByJWTCallback.useUpdateUserProfileByJWTCallback();
|
|
56
57
|
const updateUser = React.useCallback((userFields, userEnvironmentId) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
57
58
|
var _a, _b, _c;
|
|
59
|
+
// `stripUnknown: true` will automatically strip out any values in the metadata object
|
|
60
|
+
// so we need to pull out the metadata object here and then re-add it after stripping unknown fields
|
|
61
|
+
const { metadata } = userFields;
|
|
58
62
|
const validatedUserFields = yield userFieldsSchema.validate(userFields, {
|
|
59
63
|
stripUnknown: validationSchemaStripUnknown,
|
|
60
64
|
});
|
|
61
|
-
const updateUserProfileResponse = yield api.updateUserProfileFields(jwtToken, userEnvironmentId || environmentId, validatedUserFields);
|
|
65
|
+
const updateUserProfileResponse = yield api.updateUserProfileFields(jwtToken, userEnvironmentId || environmentId, Object.assign(Object.assign({}, validatedUserFields), { metadata }));
|
|
62
66
|
// check if decoded JWT still somehow has missing fields, we can't proceed if it does
|
|
63
67
|
const decodedJwt = decodeJwt.decodeJwt(updateUserProfileResponse.jwt);
|
|
64
68
|
const missingFields = (_a = decodedJwt === null || decodedJwt === void 0 ? void 0 : decodedJwt.missingFields) !== null && _a !== void 0 ? _a : [];
|
|
@@ -36,6 +36,7 @@ const userFieldsSchema = object().shape({
|
|
|
36
36
|
kdaWallet: string(),
|
|
37
37
|
lastName: string(),
|
|
38
38
|
ltcWallet: string(),
|
|
39
|
+
metadata: object(),
|
|
39
40
|
newsletterNotification: boolean(),
|
|
40
41
|
phoneNumber: string(),
|
|
41
42
|
tShirtSize: string(),
|
|
@@ -51,10 +52,13 @@ const useUserUpdateRequestInternal = ({ validationSchemaStripUnknown, }) => {
|
|
|
51
52
|
const { updateUserProfileByJWT } = useUpdateUserProfileByJWTCallback();
|
|
52
53
|
const updateUser = useCallback((userFields, userEnvironmentId) => __awaiter(void 0, void 0, void 0, function* () {
|
|
53
54
|
var _a, _b, _c;
|
|
55
|
+
// `stripUnknown: true` will automatically strip out any values in the metadata object
|
|
56
|
+
// so we need to pull out the metadata object here and then re-add it after stripping unknown fields
|
|
57
|
+
const { metadata } = userFields;
|
|
54
58
|
const validatedUserFields = yield userFieldsSchema.validate(userFields, {
|
|
55
59
|
stripUnknown: validationSchemaStripUnknown,
|
|
56
60
|
});
|
|
57
|
-
const updateUserProfileResponse = yield updateUserProfileFields(jwtToken, userEnvironmentId || environmentId, validatedUserFields);
|
|
61
|
+
const updateUserProfileResponse = yield updateUserProfileFields(jwtToken, userEnvironmentId || environmentId, Object.assign(Object.assign({}, validatedUserFields), { metadata }));
|
|
58
62
|
// check if decoded JWT still somehow has missing fields, we can't proceed if it does
|
|
59
63
|
const decodedJwt = decodeJwt(updateUserProfileResponse.jwt);
|
|
60
64
|
const missingFields = (_a = decodedJwt === null || decodedJwt === void 0 ? void 0 : decodedJwt.missingFields) !== null && _a !== void 0 ? _a : [];
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
+
var _tslib = require('../../../../_virtual/_tslib.cjs');
|
|
5
6
|
var jsxRuntime = require('react/jsx-runtime');
|
|
6
7
|
var React = require('react');
|
|
7
8
|
var viem = require('viem');
|
|
@@ -51,7 +52,7 @@ require('../../utils/hooks/useUserUpdateRequest/useUserUpdateRequest.cjs');
|
|
|
51
52
|
|
|
52
53
|
const SendBalanceView = ({ initialRecipientAddress = '', initialValue, onClickBack, onClickClose, onError, onSuccess, onDone, displayPoweredByDynamicFooter = false, }) => {
|
|
53
54
|
const [stage, setStage] = React.useState('form');
|
|
54
|
-
const { primaryWallet, network } = useInternalDynamicContext.useInternalDynamicContext();
|
|
55
|
+
const { primaryWallet, network, walletUiUtils } = useInternalDynamicContext.useInternalDynamicContext();
|
|
55
56
|
const [value, setValue] = React.useState(initialValue !== null && initialValue !== void 0 ? initialValue : null);
|
|
56
57
|
const [recipientAddress, setRecipientAddress] = React.useState(initialRecipientAddress);
|
|
57
58
|
const transactionRef = React.useRef(null);
|
|
@@ -86,10 +87,25 @@ const SendBalanceView = ({ initialRecipientAddress = '', initialValue, onClickBa
|
|
|
86
87
|
const transaction = {
|
|
87
88
|
from: primaryWallet.address,
|
|
88
89
|
to: recipientAddress,
|
|
89
|
-
type: 'eip2930',
|
|
90
90
|
value,
|
|
91
91
|
};
|
|
92
|
-
return (jsxRuntime.jsx(TransactionStage.TransactionStage, { walletConnector: walletConnector, provider: provider, transaction: transaction, title: 'Confirm transaction', onClickBack: () => setStage('form'), onError: onError, displayPoweredByDynamicFooter: displayPoweredByDynamicFooter,
|
|
92
|
+
return (jsxRuntime.jsx(TransactionStage.TransactionStage, { walletConnector: walletConnector, provider: provider, transaction: transaction, title: 'Confirm transaction', onClickBack: () => setStage('form'), onError: onError, displayPoweredByDynamicFooter: displayPoweredByDynamicFooter, mutation: ({ to, value, gasPrice, nonce }) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
93
|
+
walletUiUtils.disabledConfirmationOnce();
|
|
94
|
+
const signer = yield walletConnector.getSigner();
|
|
95
|
+
const sentTransaction = yield signer.sendTransaction({
|
|
96
|
+
account: signer.account || primaryWallet.address,
|
|
97
|
+
/**
|
|
98
|
+
* chain is set to null because viem already have the correct chain from the wallet connector
|
|
99
|
+
* docs: https://viem.sh/docs/actions/wallet/sendTransaction.html#chain-optional
|
|
100
|
+
*/
|
|
101
|
+
chain: null,
|
|
102
|
+
gasPrice,
|
|
103
|
+
nonce,
|
|
104
|
+
to,
|
|
105
|
+
value,
|
|
106
|
+
});
|
|
107
|
+
return sentTransaction;
|
|
108
|
+
}), onSuccess: (transaction) => {
|
|
93
109
|
transactionRef.current = transaction;
|
|
94
110
|
setStage('success');
|
|
95
111
|
onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess(transactionRef.current);
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { __awaiter } from '../../../../_virtual/_tslib.js';
|
|
1
2
|
import { jsx } from 'react/jsx-runtime';
|
|
2
3
|
import { useState, useRef } from 'react';
|
|
3
4
|
import { parseEther } from 'viem';
|
|
@@ -47,7 +48,7 @@ import '../../utils/hooks/useUserUpdateRequest/useUserUpdateRequest.js';
|
|
|
47
48
|
|
|
48
49
|
const SendBalanceView = ({ initialRecipientAddress = '', initialValue, onClickBack, onClickClose, onError, onSuccess, onDone, displayPoweredByDynamicFooter = false, }) => {
|
|
49
50
|
const [stage, setStage] = useState('form');
|
|
50
|
-
const { primaryWallet, network } = useInternalDynamicContext();
|
|
51
|
+
const { primaryWallet, network, walletUiUtils } = useInternalDynamicContext();
|
|
51
52
|
const [value, setValue] = useState(initialValue !== null && initialValue !== void 0 ? initialValue : null);
|
|
52
53
|
const [recipientAddress, setRecipientAddress] = useState(initialRecipientAddress);
|
|
53
54
|
const transactionRef = useRef(null);
|
|
@@ -82,10 +83,25 @@ const SendBalanceView = ({ initialRecipientAddress = '', initialValue, onClickBa
|
|
|
82
83
|
const transaction = {
|
|
83
84
|
from: primaryWallet.address,
|
|
84
85
|
to: recipientAddress,
|
|
85
|
-
type: 'eip2930',
|
|
86
86
|
value,
|
|
87
87
|
};
|
|
88
|
-
return (jsx(TransactionStage, { walletConnector: walletConnector, provider: provider, transaction: transaction, title: 'Confirm transaction', onClickBack: () => setStage('form'), onError: onError, displayPoweredByDynamicFooter: displayPoweredByDynamicFooter,
|
|
88
|
+
return (jsx(TransactionStage, { walletConnector: walletConnector, provider: provider, transaction: transaction, title: 'Confirm transaction', onClickBack: () => setStage('form'), onError: onError, displayPoweredByDynamicFooter: displayPoweredByDynamicFooter, mutation: ({ to, value, gasPrice, nonce }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
89
|
+
walletUiUtils.disabledConfirmationOnce();
|
|
90
|
+
const signer = yield walletConnector.getSigner();
|
|
91
|
+
const sentTransaction = yield signer.sendTransaction({
|
|
92
|
+
account: signer.account || primaryWallet.address,
|
|
93
|
+
/**
|
|
94
|
+
* chain is set to null because viem already have the correct chain from the wallet connector
|
|
95
|
+
* docs: https://viem.sh/docs/actions/wallet/sendTransaction.html#chain-optional
|
|
96
|
+
*/
|
|
97
|
+
chain: null,
|
|
98
|
+
gasPrice,
|
|
99
|
+
nonce,
|
|
100
|
+
to,
|
|
101
|
+
value,
|
|
102
|
+
});
|
|
103
|
+
return sentTransaction;
|
|
104
|
+
}), onSuccess: (transaction) => {
|
|
89
105
|
transactionRef.current = transaction;
|
|
90
106
|
setStage('success');
|
|
91
107
|
onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess(transactionRef.current);
|
|
@@ -22,7 +22,7 @@ var isMagicConnector = require('../../../../utils/functions/isMagicConnector/isM
|
|
|
22
22
|
var sendTransactionWithAutoNonce = require('../../../../utils/functions/sendTransactionWithAutoNonce/sendTransactionWithAutoNonce.cjs');
|
|
23
23
|
require('@dynamic-labs/rpc-providers');
|
|
24
24
|
require('../../../../utils/hooks/useWallets/utils/verifyMagicIsSetup/verifyMagicIsSetup.cjs');
|
|
25
|
-
|
|
25
|
+
require('../../../../context/DynamicContext/DynamicContext.cjs');
|
|
26
26
|
require('../../../../context/ErrorContext/ErrorContext.cjs');
|
|
27
27
|
require('../../../../context/AccessDeniedContext/AccessDeniedContext.cjs');
|
|
28
28
|
require('../../../../context/AccountExistsContext/AccountExistsContext.cjs');
|
|
@@ -48,20 +48,14 @@ require('../../../../utils/hooks/useUserUpdateRequest/useUserUpdateRequest.cjs')
|
|
|
48
48
|
var useTransactionWithGasPrice = require('../../../../utils/hooks/useTransactionWithGasPrice/useTransactionWithGasPrice.cjs');
|
|
49
49
|
|
|
50
50
|
const TransactionStage = (_a) => {
|
|
51
|
-
var { transaction, provider, walletConnector } = _a, rest = _tslib.__rest(_a, ["transaction", "provider", "walletConnector"]);
|
|
52
|
-
const { walletUiUtils } = useInternalDynamicContext.useInternalDynamicContext();
|
|
51
|
+
var { transaction, provider, walletConnector, mutation } = _a, rest = _tslib.__rest(_a, ["transaction", "provider", "walletConnector", "mutation"]);
|
|
53
52
|
const transactionWithGasPrice = useTransactionWithGasPrice.useTransactionWithGasPrice({
|
|
54
53
|
enabled: isMagicConnector.isMagicConnector(walletConnector),
|
|
55
54
|
increasePercentage: 5,
|
|
56
55
|
provider,
|
|
57
56
|
transaction,
|
|
58
57
|
});
|
|
59
|
-
return (jsxRuntime.jsx(TransactionConfirmationView.TransactionConfirmationView, Object.assign({ provider: provider, transaction: transactionWithGasPrice, mutation: () => sendTransactionWithAutoNonce.sendTransactionWithAutoNonce(walletConnector, transactionWithGasPrice,
|
|
60
|
-
walletUiUtils.disabledConfirmationOnce();
|
|
61
|
-
const signer = yield walletConnector.getSigner();
|
|
62
|
-
const sentTransaction = yield signer.sendTransaction(Object.assign(Object.assign({}, transaction), { account: transaction.from, chain: null }));
|
|
63
|
-
return sentTransaction;
|
|
64
|
-
})) }, rest)));
|
|
58
|
+
return (jsxRuntime.jsx(TransactionConfirmationView.TransactionConfirmationView, Object.assign({ provider: provider, transaction: transactionWithGasPrice, mutation: () => sendTransactionWithAutoNonce.sendTransactionWithAutoNonce(walletConnector, transactionWithGasPrice, mutation) }, rest)));
|
|
65
59
|
};
|
|
66
60
|
|
|
67
61
|
exports.TransactionStage = TransactionStage;
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { FC } from 'react';
|
|
2
|
+
import { Hex, TransactionRequest } from 'viem';
|
|
2
3
|
import { WalletConnector } from '@dynamic-labs/wallet-connector-core';
|
|
3
4
|
import { TransactionConfirmationViewProps } from '../../../TransactionConfirmationView';
|
|
4
5
|
type TransactionStageProps = Omit<TransactionConfirmationViewProps, 'mutation'> & {
|
|
5
6
|
walletConnector: WalletConnector;
|
|
7
|
+
mutation: (transaction: TransactionRequest) => Promise<Hex>;
|
|
6
8
|
};
|
|
7
9
|
export declare const TransactionStage: FC<TransactionStageProps>;
|
|
8
10
|
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { __rest
|
|
1
|
+
import { __rest } from '../../../../../../_virtual/_tslib.js';
|
|
2
2
|
import { jsx } from 'react/jsx-runtime';
|
|
3
3
|
import 'react';
|
|
4
4
|
import '@dynamic-labs/utils';
|
|
@@ -18,7 +18,7 @@ import { isMagicConnector } from '../../../../utils/functions/isMagicConnector/i
|
|
|
18
18
|
import { sendTransactionWithAutoNonce } from '../../../../utils/functions/sendTransactionWithAutoNonce/sendTransactionWithAutoNonce.js';
|
|
19
19
|
import '@dynamic-labs/rpc-providers';
|
|
20
20
|
import '../../../../utils/hooks/useWallets/utils/verifyMagicIsSetup/verifyMagicIsSetup.js';
|
|
21
|
-
import
|
|
21
|
+
import '../../../../context/DynamicContext/DynamicContext.js';
|
|
22
22
|
import '../../../../context/ErrorContext/ErrorContext.js';
|
|
23
23
|
import '../../../../context/AccessDeniedContext/AccessDeniedContext.js';
|
|
24
24
|
import '../../../../context/AccountExistsContext/AccountExistsContext.js';
|
|
@@ -44,20 +44,14 @@ import '../../../../utils/hooks/useUserUpdateRequest/useUserUpdateRequest.js';
|
|
|
44
44
|
import { useTransactionWithGasPrice } from '../../../../utils/hooks/useTransactionWithGasPrice/useTransactionWithGasPrice.js';
|
|
45
45
|
|
|
46
46
|
const TransactionStage = (_a) => {
|
|
47
|
-
var { transaction, provider, walletConnector } = _a, rest = __rest(_a, ["transaction", "provider", "walletConnector"]);
|
|
48
|
-
const { walletUiUtils } = useInternalDynamicContext();
|
|
47
|
+
var { transaction, provider, walletConnector, mutation } = _a, rest = __rest(_a, ["transaction", "provider", "walletConnector", "mutation"]);
|
|
49
48
|
const transactionWithGasPrice = useTransactionWithGasPrice({
|
|
50
49
|
enabled: isMagicConnector(walletConnector),
|
|
51
50
|
increasePercentage: 5,
|
|
52
51
|
provider,
|
|
53
52
|
transaction,
|
|
54
53
|
});
|
|
55
|
-
return (jsx(TransactionConfirmationView, Object.assign({ provider: provider, transaction: transactionWithGasPrice, mutation: () => sendTransactionWithAutoNonce(walletConnector, transactionWithGasPrice,
|
|
56
|
-
walletUiUtils.disabledConfirmationOnce();
|
|
57
|
-
const signer = yield walletConnector.getSigner();
|
|
58
|
-
const sentTransaction = yield signer.sendTransaction(Object.assign(Object.assign({}, transaction), { account: transaction.from, chain: null }));
|
|
59
|
-
return sentTransaction;
|
|
60
|
-
})) }, rest)));
|
|
54
|
+
return (jsx(TransactionConfirmationView, Object.assign({ provider: provider, transaction: transactionWithGasPrice, mutation: () => sendTransactionWithAutoNonce(walletConnector, transactionWithGasPrice, mutation) }, rest)));
|
|
61
55
|
};
|
|
62
56
|
|
|
63
57
|
export { TransactionStage };
|