@dynamic-labs/multi-wallet 4.0.0-alpha.19 → 4.0.0-alpha.20
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
package/package.cjs
CHANGED
package/package.js
CHANGED
package/package.json
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dynamic-labs/multi-wallet",
|
|
3
|
-
"version": "4.0.0-alpha.
|
|
3
|
+
"version": "4.0.0-alpha.20",
|
|
4
4
|
"dependencies": {
|
|
5
5
|
"@dynamic-labs/sdk-api-core": "0.0.559",
|
|
6
6
|
"tslib": "2.4.1",
|
|
7
|
-
"@dynamic-labs/assert-package-version": "4.0.0-alpha.
|
|
8
|
-
"@dynamic-labs/rpc-providers": "4.0.0-alpha.
|
|
9
|
-
"@dynamic-labs/types": "4.0.0-alpha.
|
|
10
|
-
"@dynamic-labs/utils": "4.0.0-alpha.
|
|
11
|
-
"@dynamic-labs/wallet-book": "4.0.0-alpha.
|
|
12
|
-
"@dynamic-labs/wallet-connector-core": "4.0.0-alpha.
|
|
7
|
+
"@dynamic-labs/assert-package-version": "4.0.0-alpha.20",
|
|
8
|
+
"@dynamic-labs/rpc-providers": "4.0.0-alpha.20",
|
|
9
|
+
"@dynamic-labs/types": "4.0.0-alpha.20",
|
|
10
|
+
"@dynamic-labs/utils": "4.0.0-alpha.20",
|
|
11
|
+
"@dynamic-labs/wallet-book": "4.0.0-alpha.20",
|
|
12
|
+
"@dynamic-labs/wallet-connector-core": "4.0.0-alpha.20"
|
|
13
13
|
},
|
|
14
14
|
"devDependencies": {
|
|
15
15
|
"@walletconnect/types": "2.10.6"
|
|
@@ -19,9 +19,9 @@ const getSupportedWallets = (args) => {
|
|
|
19
19
|
solana: [],
|
|
20
20
|
starknet: [],
|
|
21
21
|
}, settings, skipMemo = false, walletConnectProjectId = '', walletConnectorsProp, walletUiUtils = undefined, walletBook, walletConnectPreferredChains, } = args;
|
|
22
|
-
let
|
|
23
|
-
if (!skipMemo &&
|
|
24
|
-
return
|
|
22
|
+
let walletConnectors = [];
|
|
23
|
+
if (!skipMemo && walletConnectors.length > 0) {
|
|
24
|
+
return walletConnectors;
|
|
25
25
|
}
|
|
26
26
|
const eclipseNetworkConfigs = (networkConfigurations === null || networkConfigurations === void 0 ? void 0 : networkConfigurations.eclipse) || [];
|
|
27
27
|
const evmNetworkConfigs = (networkConfigurations === null || networkConfigurations === void 0 ? void 0 : networkConfigurations.evm) || [];
|
|
@@ -51,31 +51,53 @@ const getSupportedWallets = (args) => {
|
|
|
51
51
|
walletConnectorEventsEmitter: walletConnectorCore.walletConnectorEvents,
|
|
52
52
|
walletUiUtils: walletUiUtils || _const.defaultWalletUiUtils,
|
|
53
53
|
};
|
|
54
|
-
const
|
|
55
|
-
.map((
|
|
54
|
+
const allWalletConnectors = walletConnectorsProp
|
|
55
|
+
.map((getWalletConnectorConstructors) => getWalletConnectorConstructors(opts))
|
|
56
56
|
.flat()
|
|
57
|
-
|
|
58
|
-
.filter((walletConnector) => {
|
|
59
|
-
var _a, _b;
|
|
60
|
-
return !((_a = walletConnector.metadata) === null || _a === void 0 ? void 0 : _a.id) ||
|
|
61
|
-
!disabledConnectors.includes((_b = walletConnector.metadata) === null || _b === void 0 ? void 0 : _b.id);
|
|
62
|
-
})
|
|
63
|
-
.map((wallet) => {
|
|
57
|
+
.map((walletConnectorConstructor) => {
|
|
64
58
|
try {
|
|
65
59
|
// This may contain third party code so we must be ready for anything
|
|
66
|
-
return new
|
|
60
|
+
return new walletConnectorConstructor(opts);
|
|
67
61
|
}
|
|
68
62
|
catch (error) {
|
|
69
|
-
walletConnectorCore.logger.error(`Failed to construct wallet ${
|
|
63
|
+
walletConnectorCore.logger.error(`Failed to construct wallet ${walletConnectorConstructor.name}`, error);
|
|
70
64
|
return undefined;
|
|
71
65
|
}
|
|
72
66
|
})
|
|
73
|
-
|
|
74
|
-
.
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
67
|
+
// filter out undefined and disabled connectors
|
|
68
|
+
.filter((walletConnector) => {
|
|
69
|
+
var _a;
|
|
70
|
+
return walletConnector &&
|
|
71
|
+
(!((_a = walletConnector.metadata) === null || _a === void 0 ? void 0 : _a.id) ||
|
|
72
|
+
!disabledConnectors.includes(walletConnector.metadata.id));
|
|
73
|
+
})
|
|
74
|
+
// initialize the wallet connector if it's not a WalletConnect connector
|
|
75
|
+
// or just the generic 'walletconnect' connector, not other WC connectors
|
|
76
|
+
.map((walletConnector) => {
|
|
77
|
+
if (!(walletConnector === null || walletConnector === void 0 ? void 0 : walletConnector.isWalletConnect) ||
|
|
78
|
+
walletConnector.key === 'walletconnect') {
|
|
79
|
+
walletConnector === null || walletConnector === void 0 ? void 0 : walletConnector.init();
|
|
80
|
+
}
|
|
81
|
+
return walletConnector;
|
|
82
|
+
})
|
|
83
|
+
// applies custom filter defined in the wallet connector
|
|
84
|
+
.filter((walletConnector) => walletConnector === null || walletConnector === void 0 ? void 0 : walletConnector.filter())
|
|
85
|
+
.map((walletConnector) => walletConnector.getMobileOrInstalledWallet());
|
|
86
|
+
// Filter out duplicated wallets (WC vs. non-WC)
|
|
87
|
+
const nonDuplicatedWalletConnectors = allWalletConnectors.filter((walletConnector) => {
|
|
88
|
+
if (!walletConnector.isWalletConnect)
|
|
89
|
+
return true;
|
|
90
|
+
// if current wallet is WalletConnect, check if there is another wallet with the same key that is
|
|
91
|
+
// not WalletConnect
|
|
92
|
+
// if there is, return false(filter out WC wallet)
|
|
93
|
+
// if there is no other wallet with the same key that is not WalletConnect, return true (keep WC wallet)
|
|
94
|
+
return !allWalletConnectors.some((wc) => wc.key === walletConnector.key &&
|
|
95
|
+
!wc.isWalletConnect &&
|
|
96
|
+
wc.isInstalledOnBrowser());
|
|
97
|
+
});
|
|
98
|
+
const filteredWalletConnectors = filterWalletsForPlatform.filterWalletsForPlatform(walletBook, nonDuplicatedWalletConnectors);
|
|
99
|
+
walletConnectors = applyLinksOverrides.applyLinksOverrides(walletBook, filteredWalletConnectors);
|
|
100
|
+
return walletConnectors;
|
|
79
101
|
};
|
|
80
102
|
|
|
81
103
|
exports.getSupportedWallets = getSupportedWallets;
|
|
@@ -15,9 +15,9 @@ const getSupportedWallets = (args) => {
|
|
|
15
15
|
solana: [],
|
|
16
16
|
starknet: [],
|
|
17
17
|
}, settings, skipMemo = false, walletConnectProjectId = '', walletConnectorsProp, walletUiUtils = undefined, walletBook, walletConnectPreferredChains, } = args;
|
|
18
|
-
let
|
|
19
|
-
if (!skipMemo &&
|
|
20
|
-
return
|
|
18
|
+
let walletConnectors = [];
|
|
19
|
+
if (!skipMemo && walletConnectors.length > 0) {
|
|
20
|
+
return walletConnectors;
|
|
21
21
|
}
|
|
22
22
|
const eclipseNetworkConfigs = (networkConfigurations === null || networkConfigurations === void 0 ? void 0 : networkConfigurations.eclipse) || [];
|
|
23
23
|
const evmNetworkConfigs = (networkConfigurations === null || networkConfigurations === void 0 ? void 0 : networkConfigurations.evm) || [];
|
|
@@ -47,31 +47,53 @@ const getSupportedWallets = (args) => {
|
|
|
47
47
|
walletConnectorEventsEmitter: walletConnectorEvents,
|
|
48
48
|
walletUiUtils: walletUiUtils || defaultWalletUiUtils,
|
|
49
49
|
};
|
|
50
|
-
const
|
|
51
|
-
.map((
|
|
50
|
+
const allWalletConnectors = walletConnectorsProp
|
|
51
|
+
.map((getWalletConnectorConstructors) => getWalletConnectorConstructors(opts))
|
|
52
52
|
.flat()
|
|
53
|
-
|
|
54
|
-
.filter((walletConnector) => {
|
|
55
|
-
var _a, _b;
|
|
56
|
-
return !((_a = walletConnector.metadata) === null || _a === void 0 ? void 0 : _a.id) ||
|
|
57
|
-
!disabledConnectors.includes((_b = walletConnector.metadata) === null || _b === void 0 ? void 0 : _b.id);
|
|
58
|
-
})
|
|
59
|
-
.map((wallet) => {
|
|
53
|
+
.map((walletConnectorConstructor) => {
|
|
60
54
|
try {
|
|
61
55
|
// This may contain third party code so we must be ready for anything
|
|
62
|
-
return new
|
|
56
|
+
return new walletConnectorConstructor(opts);
|
|
63
57
|
}
|
|
64
58
|
catch (error) {
|
|
65
|
-
logger.error(`Failed to construct wallet ${
|
|
59
|
+
logger.error(`Failed to construct wallet ${walletConnectorConstructor.name}`, error);
|
|
66
60
|
return undefined;
|
|
67
61
|
}
|
|
68
62
|
})
|
|
69
|
-
|
|
70
|
-
.
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
63
|
+
// filter out undefined and disabled connectors
|
|
64
|
+
.filter((walletConnector) => {
|
|
65
|
+
var _a;
|
|
66
|
+
return walletConnector &&
|
|
67
|
+
(!((_a = walletConnector.metadata) === null || _a === void 0 ? void 0 : _a.id) ||
|
|
68
|
+
!disabledConnectors.includes(walletConnector.metadata.id));
|
|
69
|
+
})
|
|
70
|
+
// initialize the wallet connector if it's not a WalletConnect connector
|
|
71
|
+
// or just the generic 'walletconnect' connector, not other WC connectors
|
|
72
|
+
.map((walletConnector) => {
|
|
73
|
+
if (!(walletConnector === null || walletConnector === void 0 ? void 0 : walletConnector.isWalletConnect) ||
|
|
74
|
+
walletConnector.key === 'walletconnect') {
|
|
75
|
+
walletConnector === null || walletConnector === void 0 ? void 0 : walletConnector.init();
|
|
76
|
+
}
|
|
77
|
+
return walletConnector;
|
|
78
|
+
})
|
|
79
|
+
// applies custom filter defined in the wallet connector
|
|
80
|
+
.filter((walletConnector) => walletConnector === null || walletConnector === void 0 ? void 0 : walletConnector.filter())
|
|
81
|
+
.map((walletConnector) => walletConnector.getMobileOrInstalledWallet());
|
|
82
|
+
// Filter out duplicated wallets (WC vs. non-WC)
|
|
83
|
+
const nonDuplicatedWalletConnectors = allWalletConnectors.filter((walletConnector) => {
|
|
84
|
+
if (!walletConnector.isWalletConnect)
|
|
85
|
+
return true;
|
|
86
|
+
// if current wallet is WalletConnect, check if there is another wallet with the same key that is
|
|
87
|
+
// not WalletConnect
|
|
88
|
+
// if there is, return false(filter out WC wallet)
|
|
89
|
+
// if there is no other wallet with the same key that is not WalletConnect, return true (keep WC wallet)
|
|
90
|
+
return !allWalletConnectors.some((wc) => wc.key === walletConnector.key &&
|
|
91
|
+
!wc.isWalletConnect &&
|
|
92
|
+
wc.isInstalledOnBrowser());
|
|
93
|
+
});
|
|
94
|
+
const filteredWalletConnectors = filterWalletsForPlatform(walletBook, nonDuplicatedWalletConnectors);
|
|
95
|
+
walletConnectors = applyLinksOverrides(walletBook, filteredWalletConnectors);
|
|
96
|
+
return walletConnectors;
|
|
75
97
|
};
|
|
76
98
|
|
|
77
99
|
export { getSupportedWallets };
|