@dynamic-labs/sdk-react-core 0.16.14 → 0.16.15
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
CHANGED
|
@@ -1,4 +1,11 @@
|
|
|
1
1
|
|
|
2
|
+
### [0.16.15](https://github.com/dynamic-labs/DynamicAuth/compare/v0.16.14...v0.16.15) (2023-05-10)
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
### Bug Fixes
|
|
6
|
+
|
|
7
|
+
* use primary wallet id from LS on handleUnlinkWallet ([#2066](https://github.com/dynamic-labs/DynamicAuth/issues/2066)) ([68e36a5](https://github.com/dynamic-labs/DynamicAuth/commit/68e36a5656f9fa7704d5bf18b25f6a55c0d9dcf3))
|
|
8
|
+
|
|
2
9
|
### [0.16.14](https://github.com/dynamic-labs/DynamicAuth/compare/v0.16.13...v0.16.14) (2023-05-08)
|
|
3
10
|
|
|
4
11
|
|
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.16.
|
|
3
|
+
"version": "0.16.15",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/dynamic-labs/DynamicAuth.git",
|
|
@@ -17,9 +17,9 @@
|
|
|
17
17
|
"formik": "^2.2.9",
|
|
18
18
|
"qrcode": "1.5.1",
|
|
19
19
|
"ethers": "^5.7.2",
|
|
20
|
-
"@dynamic-labs/logger": "0.16.
|
|
21
|
-
"@dynamic-labs/multi-wallet": "0.16.
|
|
22
|
-
"@dynamic-labs/wallet-connector-core": "0.16.
|
|
20
|
+
"@dynamic-labs/logger": "0.16.15",
|
|
21
|
+
"@dynamic-labs/multi-wallet": "0.16.15",
|
|
22
|
+
"@dynamic-labs/wallet-connector-core": "0.16.15"
|
|
23
23
|
},
|
|
24
24
|
"devDependencies": {
|
|
25
25
|
"semver": "^7.3.8"
|
|
@@ -4,17 +4,37 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
var _tslib = require('../../../../../_virtual/_tslib.cjs');
|
|
6
6
|
var React = require('react');
|
|
7
|
+
require('@dynamic-labs/sdk-api');
|
|
8
|
+
require('../../../shared/logger.cjs');
|
|
9
|
+
var getFromLS = require('../../../shared/utils/functions/storage/getFromLS.cjs');
|
|
10
|
+
require('@dynamic-labs/iconic');
|
|
11
|
+
require('@dynamic-labs/multi-wallet');
|
|
12
|
+
require('react/jsx-runtime');
|
|
13
|
+
require('../../../context/ViewContext/ViewContext.cjs');
|
|
14
|
+
var localStorage = require('../../constants/localStorage.cjs');
|
|
15
|
+
require('../../constants/colors.cjs');
|
|
16
|
+
require('../../../shared/consts/index.cjs');
|
|
7
17
|
var handleUnlinkHelper = require('../../functions/handleUnlinkHelper/handleUnlinkHelper.cjs');
|
|
8
18
|
var isSameWalletName = require('../../functions/isSameWalletName/isSameWalletName.cjs');
|
|
9
19
|
|
|
10
20
|
const useHandleUnlinkWallet = ({ verifiedCredentials, environmentId, primaryWalletId, secondaryWallets, setUser, }) => {
|
|
11
21
|
const callback = React.useCallback((walletId) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
12
|
-
var _a, _b;
|
|
13
|
-
|
|
22
|
+
var _a, _b, _c;
|
|
23
|
+
// when we call handleUnlinkWallet on the same execution stack as setPrimaryWallet, the value of
|
|
24
|
+
// primaryWalletId coming from the DynamicContext will be the old one in this callback function
|
|
25
|
+
// so we need to get the latest value from LS
|
|
26
|
+
// e.g. primary wallet id is 1234, and we have a function like this:
|
|
27
|
+
// async function setPrimaryWalletAndUnlink() {
|
|
28
|
+
// await setPrimaryWallet('5678');
|
|
29
|
+
// handleUnlinkWallet('1234');
|
|
30
|
+
// }
|
|
31
|
+
// without fetching from LS, primaryWalletId would still be 1234 when handleUnlinkWallet runs in the example above
|
|
32
|
+
const currentPrimaryWalletId = (_a = getFromLS.getFromLS(localStorage.PRIMARY_WALLET_ID)) !== null && _a !== void 0 ? _a : primaryWalletId;
|
|
33
|
+
if (walletId === currentPrimaryWalletId)
|
|
14
34
|
return;
|
|
15
35
|
const newUser = yield handleUnlinkHelper.handleUnlinkHelper({
|
|
16
36
|
environmentId,
|
|
17
|
-
primaryWalletId,
|
|
37
|
+
primaryWalletId: currentPrimaryWalletId,
|
|
18
38
|
walletId,
|
|
19
39
|
});
|
|
20
40
|
if (newUser) {
|
|
@@ -25,7 +45,7 @@ const useHandleUnlinkWallet = ({ verifiedCredentials, environmentId, primaryWall
|
|
|
25
45
|
isSameWalletName.isSameWalletName(account.walletName, (wallet === null || wallet === void 0 ? void 0 : wallet.connector.name) || '')).length;
|
|
26
46
|
// If there's only 1, it's the one being removed and we can kill the session
|
|
27
47
|
if (numberOfLinkedWallets === 1) {
|
|
28
|
-
yield ((
|
|
48
|
+
yield ((_c = wallet === null || wallet === void 0 ? void 0 : (_b = wallet.connector).endSession) === null || _c === void 0 ? void 0 : _c.call(_b));
|
|
29
49
|
}
|
|
30
50
|
}), [
|
|
31
51
|
primaryWalletId,
|
|
@@ -1,16 +1,36 @@
|
|
|
1
1
|
import { __awaiter } from '../../../../../_virtual/_tslib.js';
|
|
2
2
|
import { useCallback } from 'react';
|
|
3
|
+
import '@dynamic-labs/sdk-api';
|
|
4
|
+
import '../../../shared/logger.js';
|
|
5
|
+
import { getFromLS } from '../../../shared/utils/functions/storage/getFromLS.js';
|
|
6
|
+
import '@dynamic-labs/iconic';
|
|
7
|
+
import '@dynamic-labs/multi-wallet';
|
|
8
|
+
import 'react/jsx-runtime';
|
|
9
|
+
import '../../../context/ViewContext/ViewContext.js';
|
|
10
|
+
import { PRIMARY_WALLET_ID } from '../../constants/localStorage.js';
|
|
11
|
+
import '../../constants/colors.js';
|
|
12
|
+
import '../../../shared/consts/index.js';
|
|
3
13
|
import { handleUnlinkHelper } from '../../functions/handleUnlinkHelper/handleUnlinkHelper.js';
|
|
4
14
|
import { isSameWalletName } from '../../functions/isSameWalletName/isSameWalletName.js';
|
|
5
15
|
|
|
6
16
|
const useHandleUnlinkWallet = ({ verifiedCredentials, environmentId, primaryWalletId, secondaryWallets, setUser, }) => {
|
|
7
17
|
const callback = useCallback((walletId) => __awaiter(void 0, void 0, void 0, function* () {
|
|
8
|
-
var _a, _b;
|
|
9
|
-
|
|
18
|
+
var _a, _b, _c;
|
|
19
|
+
// when we call handleUnlinkWallet on the same execution stack as setPrimaryWallet, the value of
|
|
20
|
+
// primaryWalletId coming from the DynamicContext will be the old one in this callback function
|
|
21
|
+
// so we need to get the latest value from LS
|
|
22
|
+
// e.g. primary wallet id is 1234, and we have a function like this:
|
|
23
|
+
// async function setPrimaryWalletAndUnlink() {
|
|
24
|
+
// await setPrimaryWallet('5678');
|
|
25
|
+
// handleUnlinkWallet('1234');
|
|
26
|
+
// }
|
|
27
|
+
// without fetching from LS, primaryWalletId would still be 1234 when handleUnlinkWallet runs in the example above
|
|
28
|
+
const currentPrimaryWalletId = (_a = getFromLS(PRIMARY_WALLET_ID)) !== null && _a !== void 0 ? _a : primaryWalletId;
|
|
29
|
+
if (walletId === currentPrimaryWalletId)
|
|
10
30
|
return;
|
|
11
31
|
const newUser = yield handleUnlinkHelper({
|
|
12
32
|
environmentId,
|
|
13
|
-
primaryWalletId,
|
|
33
|
+
primaryWalletId: currentPrimaryWalletId,
|
|
14
34
|
walletId,
|
|
15
35
|
});
|
|
16
36
|
if (newUser) {
|
|
@@ -21,7 +41,7 @@ const useHandleUnlinkWallet = ({ verifiedCredentials, environmentId, primaryWall
|
|
|
21
41
|
isSameWalletName(account.walletName, (wallet === null || wallet === void 0 ? void 0 : wallet.connector.name) || '')).length;
|
|
22
42
|
// If there's only 1, it's the one being removed and we can kill the session
|
|
23
43
|
if (numberOfLinkedWallets === 1) {
|
|
24
|
-
yield ((
|
|
44
|
+
yield ((_c = wallet === null || wallet === void 0 ? void 0 : (_b = wallet.connector).endSession) === null || _c === void 0 ? void 0 : _c.call(_b));
|
|
25
45
|
}
|
|
26
46
|
}), [
|
|
27
47
|
primaryWalletId,
|