@dynamic-labs/multi-wallet 0.0.0-exp20240808.0

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2022 Dynamic Labs, Inc.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,7 @@
1
+ # multi-wallet
2
+
3
+ This library was generated with [Nx](https://nx.dev).
4
+
5
+ ## Running unit tests
6
+
7
+ Run `nx test multi-wallet` to execute the unit tests via [Jest](https://jestjs.io).
package/package.json ADDED
@@ -0,0 +1,41 @@
1
+ {
2
+ "name": "@dynamic-labs/multi-wallet",
3
+ "version": "0.0.0-exp20240808.0",
4
+ "repository": {
5
+ "type": "git",
6
+ "url": "git+https://github.com/dynamic-labs/dynamic-auth.git",
7
+ "directory": "packages/multi-wallet"
8
+ },
9
+ "dependencies": {
10
+ "@dynamic-labs/sdk-api-core": "0.0.509",
11
+ "tslib": "2.4.1",
12
+ "@dynamic-labs/rpc-providers": "0.0.0-exp20240808.0",
13
+ "@dynamic-labs/types": "0.0.0-exp20240808.0",
14
+ "@dynamic-labs/utils": "0.0.0-exp20240808.0",
15
+ "@dynamic-labs/wallet-book": "0.0.0-exp20240808.0",
16
+ "@dynamic-labs/wallet-connector-core": "0.0.0-exp20240808.0"
17
+ },
18
+ "devDependencies": {
19
+ "@walletconnect/types": "2.10.6"
20
+ },
21
+ "description": "Multi-wallet is a toolkit for working with many different wallets to create and verify signatures",
22
+ "bugs": {
23
+ "url": "https://github.com/dynamic-labs/DynamicAuth/issues"
24
+ },
25
+ "homepage": "https://github.com/dynamic-labs/DynamicAuth/main/packages/multi-wallet#readme",
26
+ "author": "Dynamic Labs, Inc.",
27
+ "license": "MIT",
28
+ "main": "./src/index.cjs",
29
+ "module": "./src/index.js",
30
+ "types": "./src/index.d.ts",
31
+ "type": "module",
32
+ "exports": {
33
+ ".": {
34
+ "types": "./src/index.d.ts",
35
+ "import": "./src/index.js",
36
+ "require": "./src/index.cjs"
37
+ },
38
+ "./package.json": "./package.json"
39
+ },
40
+ "peerDependencies": {}
41
+ }
package/src/index.cjs ADDED
@@ -0,0 +1,15 @@
1
+ 'use client'
2
+ 'use strict';
3
+
4
+ Object.defineProperty(exports, '__esModule', { value: true });
5
+
6
+ var multiWallet = require('./multi-wallet.cjs');
7
+ var message = require('./utils/message.cjs');
8
+
9
+
10
+
11
+ exports.getEnabledProviders = multiWallet.getEnabledProviders;
12
+ exports.getEnabledWallets = multiWallet.getEnabledWallets;
13
+ exports.getSupportedChainsForWalletConnector = multiWallet.getSupportedChainsForWalletConnector;
14
+ exports.getSupportedWallets = multiWallet.getSupportedWallets;
15
+ exports.generateMessageToSign = message.generateMessageToSign;
package/src/index.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ export * from './multi-wallet';
2
+ export * from './types';
3
+ export { generateMessageToSign } from './utils/message';
package/src/index.js ADDED
@@ -0,0 +1,3 @@
1
+ 'use client'
2
+ export { getEnabledProviders, getEnabledWallets, getSupportedChainsForWalletConnector, getSupportedWallets } from './multi-wallet.js';
3
+ export { generateMessageToSign } from './utils/message.js';
@@ -0,0 +1,178 @@
1
+ 'use client'
2
+ 'use strict';
3
+
4
+ Object.defineProperty(exports, '__esModule', { value: true });
5
+
6
+ var walletConnectorCore = require('@dynamic-labs/wallet-connector-core');
7
+ var walletBook = require('@dynamic-labs/wallet-book');
8
+ var utils = require('@dynamic-labs/utils');
9
+ var sdkApiCore = require('@dynamic-labs/sdk-api-core');
10
+ var getApiProviders = require('./utils/getApiProviders.cjs');
11
+
12
+ let wallets = [];
13
+ const defaultWalletUiUtils = {
14
+ createPassword: () => {
15
+ throw Error('createPassword not implemented');
16
+ },
17
+ disabledConfirmationOnce: () => {
18
+ throw Error('disabledConfirmationOnce, not implemented');
19
+ },
20
+ enterPassword: () => {
21
+ throw Error('enterPassword not implemented');
22
+ },
23
+ sendTransaction: () => {
24
+ throw Error('requestSendTransactionConfirmation not implemented');
25
+ },
26
+ signMessage: () => {
27
+ throw Error('signMessage not implemented');
28
+ },
29
+ syncWallet: () => {
30
+ throw Error('syncWallet not implemented');
31
+ },
32
+ };
33
+ const getSupportedWallets = (args) => {
34
+ const { appLogoUrl = '', appName = '', coinbaseWalletPreference, chainRpcProviders, deepLinkPreference, flowNetwork, mobileExperience = 'in-app-browser', networkConfigurations = { cosmos: [], evm: [], solana: [], starknet: [] }, settings, skipMemo = false, walletConnectProjectId = '', walletConnectorsProp, walletUiUtils = undefined, walletBook, walletConnectPreferredChains, } = args;
35
+ if (!skipMemo && wallets.length > 0) {
36
+ return wallets;
37
+ }
38
+ const evmNetworkConfigs = (networkConfigurations === null || networkConfigurations === void 0 ? void 0 : networkConfigurations.evm) || [];
39
+ const solanaNetworkConfigs = (networkConfigurations === null || networkConfigurations === void 0 ? void 0 : networkConfigurations.solana) || [];
40
+ const cosmosNetworkConfigs = (networkConfigurations === null || networkConfigurations === void 0 ? void 0 : networkConfigurations.cosmos) || [];
41
+ const starknetNetworkConfigs = (networkConfigurations === null || networkConfigurations === void 0 ? void 0 : networkConfigurations.starknet) || [];
42
+ const apiProviders = getApiProviders.getApiProviders(getEnabledProviders(settings.providers));
43
+ const opts = {
44
+ apiProviders,
45
+ appLogoUrl,
46
+ appName,
47
+ chainRpcProviders,
48
+ coinbaseWalletPreference,
49
+ cosmosNetworks: cosmosNetworkConfigs,
50
+ deepLinkPreference,
51
+ evmNetworks: evmNetworkConfigs,
52
+ flowNetwork,
53
+ mobileExperience,
54
+ projectId: walletConnectProjectId,
55
+ settings,
56
+ solNetworks: solanaNetworkConfigs,
57
+ starknetNetworks: starknetNetworkConfigs,
58
+ walletBook,
59
+ walletConnectPreferredChains,
60
+ walletUiUtils: walletUiUtils || defaultWalletUiUtils,
61
+ };
62
+ const allWallets = walletConnectorsProp
63
+ .map((walletConnector) => walletConnector(opts))
64
+ .flat()
65
+ .map((wallet) => {
66
+ try {
67
+ // This may contain third party code so we must be ready for anything
68
+ return new wallet(opts);
69
+ }
70
+ catch (error) {
71
+ walletConnectorCore.logger.error(`Failed to construct wallet ${wallet.name}`, error);
72
+ return undefined;
73
+ }
74
+ })
75
+ .filter((wallet) => wallet === null || wallet === void 0 ? void 0 : wallet.filter())
76
+ .map((wallet) => wallet.getMobileOrInstalledWallet());
77
+ // Memoize the wallets
78
+ const filteredWallets = filterWalletsForPlatform(walletBook, allWallets);
79
+ wallets = applyLinksOverrides(walletBook, filteredWallets);
80
+ return wallets;
81
+ };
82
+ const applyLinksOverrides = (walletBook$1, wallets) => wallets.map((wallet) => {
83
+ const metadata = walletBook.getWalletBookWallet(walletBook$1, wallet.key, wallet.walletFallback);
84
+ if (metadata.switchNetworkOnlyFromWallet !== undefined) {
85
+ wallet.switchNetworkOnlyFromWallet = metadata.switchNetworkOnlyFromWallet;
86
+ }
87
+ return wallet;
88
+ });
89
+ const filterWalletsForPlatform = (walletBook$1, wallets) => wallets.filter((wallet) => {
90
+ const metadata = walletBook.getWalletBookWallet(walletBook$1, wallet.key, wallet.walletFallback);
91
+ if (wallet.isInstalledOnBrowser()) {
92
+ return true;
93
+ }
94
+ else if (walletConnectorCore.isEmbeddedConnector(wallet)) {
95
+ return true;
96
+ }
97
+ else if (metadata.showOnlyIfInstalled) {
98
+ return false;
99
+ }
100
+ else if (!utils.isMobile()) {
101
+ return true;
102
+ }
103
+ else {
104
+ return handleMobileWalletFilter(walletBook$1, wallet.key, metadata);
105
+ }
106
+ });
107
+ const handleMobileWalletFilter = (walletBook$1, walletKey, metadata) => {
108
+ if (!metadata.mobile)
109
+ return false;
110
+ /**
111
+ * WalletConnect provides a "universal" and "native" deep link. They recommend using
112
+ * the universal deep link over the native one due to UX differences, and our current
113
+ * implementation uses only universal. This means we need to filter for wallets that
114
+ * have a universal deep link available.
115
+ */
116
+ const hasWalletConnectLink = Boolean(metadata.mobile.universal) || Boolean(metadata.mobile.native);
117
+ const isWalletConnectWallet = metadata.walletConnect !== undefined;
118
+ if (utils.isIPad() || utils.isIPhone()) {
119
+ const hasIOSLink = Boolean(walletBook.getWalletLinks(walletBook$1, walletKey).ios);
120
+ return !isWalletConnectWallet
121
+ ? hasIOSLink
122
+ : hasIOSLink && hasWalletConnectLink;
123
+ }
124
+ else {
125
+ const hasAndroidLink = Boolean(walletBook.getWalletLinks(walletBook$1, walletKey).android);
126
+ return !isWalletConnectWallet
127
+ ? hasAndroidLink
128
+ : hasAndroidLink && hasWalletConnectLink;
129
+ }
130
+ };
131
+ const chainStringToChains = {
132
+ 'eip155:1': ['ETH', 'EVM'],
133
+ 'flow:mainnet': ['FLOW'],
134
+ };
135
+ const getSupportedChainsForWalletConnector = (walletBook$1, walletConnector) => {
136
+ var _a;
137
+ const metadata = walletBook.getWalletBookWallet(walletBook$1, walletConnector.key, walletConnector.walletFallback);
138
+ /**
139
+ * chains could contain multiple eth networks eg
140
+ * "eip155:1",
141
+ * "eip155:10",
142
+ * "eip155:56",
143
+ * "eip155:100",
144
+ *
145
+ * so we will use a set to ensure uniqueness
146
+ */
147
+ const chainSet = new Set();
148
+ const chainStringList = (_a = metadata.chains) !== null && _a !== void 0 ? _a : [];
149
+ chainStringList.forEach((chainString) => {
150
+ const chains = chainStringToChains[chainString];
151
+ chains === null || chains === void 0 ? void 0 : chains.forEach((chain) => {
152
+ chainSet.add(chain);
153
+ });
154
+ });
155
+ walletConnector.supportedChains.forEach((chain) => {
156
+ chainSet.add(chain);
157
+ });
158
+ return [...chainSet];
159
+ };
160
+ const getEnabledWallets = (props) => {
161
+ const supportedWallets = getSupportedWallets(props.getSupportedWalletOpts);
162
+ const allEnabledWallets = supportedWallets.filter((wallet) => props.enabledChains.some((chain) => getSupportedChainsForWalletConnector(props.getSupportedWalletOpts.walletBook, wallet).includes(chain)) || wallet.key === 'magiclink');
163
+ return allEnabledWallets;
164
+ };
165
+ // get list of providers enabled in the sense that we should have wallet connectors for them
166
+ // note: magic and turnkey are considered enabled when a provider exists (for magic, a providerProjectId exists)
167
+ const getEnabledProviders = (providers) => {
168
+ var _a;
169
+ return (_a = providers === null || providers === void 0 ? void 0 : providers.filter((provider) => Boolean(provider.enabledAt) ||
170
+ (provider.provider === sdkApiCore.ProviderEnum.MagicLink &&
171
+ Boolean(provider.providerProjectId)) ||
172
+ provider.provider === sdkApiCore.ProviderEnum.Turnkey)) !== null && _a !== void 0 ? _a : [];
173
+ };
174
+
175
+ exports.getEnabledProviders = getEnabledProviders;
176
+ exports.getEnabledWallets = getEnabledWallets;
177
+ exports.getSupportedChainsForWalletConnector = getSupportedChainsForWalletConnector;
178
+ exports.getSupportedWallets = getSupportedWallets;
@@ -0,0 +1,11 @@
1
+ import { Chain, WalletConnector } from '@dynamic-labs/wallet-connector-core';
2
+ import { WalletBookSchema } from '@dynamic-labs/wallet-book';
3
+ import { Provider } from '@dynamic-labs/sdk-api-core';
4
+ import { GetSupportedWallets, GetSupportedWalletsOpts } from './types';
5
+ export declare const getSupportedWallets: GetSupportedWallets;
6
+ export declare const getSupportedChainsForWalletConnector: (walletBook: WalletBookSchema, walletConnector: WalletConnector) => Chain[];
7
+ export declare const getEnabledWallets: (props: {
8
+ enabledChains: Chain[];
9
+ getSupportedWalletOpts: GetSupportedWalletsOpts;
10
+ }) => WalletConnector[];
11
+ export declare const getEnabledProviders: (providers: Provider[] | undefined) => Provider[];
@@ -0,0 +1,171 @@
1
+ 'use client'
2
+ import { logger, isEmbeddedConnector } from '@dynamic-labs/wallet-connector-core';
3
+ import { getWalletBookWallet, getWalletLinks } from '@dynamic-labs/wallet-book';
4
+ import { isMobile, isIPad, isIPhone } from '@dynamic-labs/utils';
5
+ import { ProviderEnum } from '@dynamic-labs/sdk-api-core';
6
+ import { getApiProviders } from './utils/getApiProviders.js';
7
+
8
+ let wallets = [];
9
+ const defaultWalletUiUtils = {
10
+ createPassword: () => {
11
+ throw Error('createPassword not implemented');
12
+ },
13
+ disabledConfirmationOnce: () => {
14
+ throw Error('disabledConfirmationOnce, not implemented');
15
+ },
16
+ enterPassword: () => {
17
+ throw Error('enterPassword not implemented');
18
+ },
19
+ sendTransaction: () => {
20
+ throw Error('requestSendTransactionConfirmation not implemented');
21
+ },
22
+ signMessage: () => {
23
+ throw Error('signMessage not implemented');
24
+ },
25
+ syncWallet: () => {
26
+ throw Error('syncWallet not implemented');
27
+ },
28
+ };
29
+ const getSupportedWallets = (args) => {
30
+ const { appLogoUrl = '', appName = '', coinbaseWalletPreference, chainRpcProviders, deepLinkPreference, flowNetwork, mobileExperience = 'in-app-browser', networkConfigurations = { cosmos: [], evm: [], solana: [], starknet: [] }, settings, skipMemo = false, walletConnectProjectId = '', walletConnectorsProp, walletUiUtils = undefined, walletBook, walletConnectPreferredChains, } = args;
31
+ if (!skipMemo && wallets.length > 0) {
32
+ return wallets;
33
+ }
34
+ const evmNetworkConfigs = (networkConfigurations === null || networkConfigurations === void 0 ? void 0 : networkConfigurations.evm) || [];
35
+ const solanaNetworkConfigs = (networkConfigurations === null || networkConfigurations === void 0 ? void 0 : networkConfigurations.solana) || [];
36
+ const cosmosNetworkConfigs = (networkConfigurations === null || networkConfigurations === void 0 ? void 0 : networkConfigurations.cosmos) || [];
37
+ const starknetNetworkConfigs = (networkConfigurations === null || networkConfigurations === void 0 ? void 0 : networkConfigurations.starknet) || [];
38
+ const apiProviders = getApiProviders(getEnabledProviders(settings.providers));
39
+ const opts = {
40
+ apiProviders,
41
+ appLogoUrl,
42
+ appName,
43
+ chainRpcProviders,
44
+ coinbaseWalletPreference,
45
+ cosmosNetworks: cosmosNetworkConfigs,
46
+ deepLinkPreference,
47
+ evmNetworks: evmNetworkConfigs,
48
+ flowNetwork,
49
+ mobileExperience,
50
+ projectId: walletConnectProjectId,
51
+ settings,
52
+ solNetworks: solanaNetworkConfigs,
53
+ starknetNetworks: starknetNetworkConfigs,
54
+ walletBook,
55
+ walletConnectPreferredChains,
56
+ walletUiUtils: walletUiUtils || defaultWalletUiUtils,
57
+ };
58
+ const allWallets = walletConnectorsProp
59
+ .map((walletConnector) => walletConnector(opts))
60
+ .flat()
61
+ .map((wallet) => {
62
+ try {
63
+ // This may contain third party code so we must be ready for anything
64
+ return new wallet(opts);
65
+ }
66
+ catch (error) {
67
+ logger.error(`Failed to construct wallet ${wallet.name}`, error);
68
+ return undefined;
69
+ }
70
+ })
71
+ .filter((wallet) => wallet === null || wallet === void 0 ? void 0 : wallet.filter())
72
+ .map((wallet) => wallet.getMobileOrInstalledWallet());
73
+ // Memoize the wallets
74
+ const filteredWallets = filterWalletsForPlatform(walletBook, allWallets);
75
+ wallets = applyLinksOverrides(walletBook, filteredWallets);
76
+ return wallets;
77
+ };
78
+ const applyLinksOverrides = (walletBook, wallets) => wallets.map((wallet) => {
79
+ const metadata = getWalletBookWallet(walletBook, wallet.key, wallet.walletFallback);
80
+ if (metadata.switchNetworkOnlyFromWallet !== undefined) {
81
+ wallet.switchNetworkOnlyFromWallet = metadata.switchNetworkOnlyFromWallet;
82
+ }
83
+ return wallet;
84
+ });
85
+ const filterWalletsForPlatform = (walletBook, wallets) => wallets.filter((wallet) => {
86
+ const metadata = getWalletBookWallet(walletBook, wallet.key, wallet.walletFallback);
87
+ if (wallet.isInstalledOnBrowser()) {
88
+ return true;
89
+ }
90
+ else if (isEmbeddedConnector(wallet)) {
91
+ return true;
92
+ }
93
+ else if (metadata.showOnlyIfInstalled) {
94
+ return false;
95
+ }
96
+ else if (!isMobile()) {
97
+ return true;
98
+ }
99
+ else {
100
+ return handleMobileWalletFilter(walletBook, wallet.key, metadata);
101
+ }
102
+ });
103
+ const handleMobileWalletFilter = (walletBook, walletKey, metadata) => {
104
+ if (!metadata.mobile)
105
+ return false;
106
+ /**
107
+ * WalletConnect provides a "universal" and "native" deep link. They recommend using
108
+ * the universal deep link over the native one due to UX differences, and our current
109
+ * implementation uses only universal. This means we need to filter for wallets that
110
+ * have a universal deep link available.
111
+ */
112
+ const hasWalletConnectLink = Boolean(metadata.mobile.universal) || Boolean(metadata.mobile.native);
113
+ const isWalletConnectWallet = metadata.walletConnect !== undefined;
114
+ if (isIPad() || isIPhone()) {
115
+ const hasIOSLink = Boolean(getWalletLinks(walletBook, walletKey).ios);
116
+ return !isWalletConnectWallet
117
+ ? hasIOSLink
118
+ : hasIOSLink && hasWalletConnectLink;
119
+ }
120
+ else {
121
+ const hasAndroidLink = Boolean(getWalletLinks(walletBook, walletKey).android);
122
+ return !isWalletConnectWallet
123
+ ? hasAndroidLink
124
+ : hasAndroidLink && hasWalletConnectLink;
125
+ }
126
+ };
127
+ const chainStringToChains = {
128
+ 'eip155:1': ['ETH', 'EVM'],
129
+ 'flow:mainnet': ['FLOW'],
130
+ };
131
+ const getSupportedChainsForWalletConnector = (walletBook, walletConnector) => {
132
+ var _a;
133
+ const metadata = getWalletBookWallet(walletBook, walletConnector.key, walletConnector.walletFallback);
134
+ /**
135
+ * chains could contain multiple eth networks eg
136
+ * "eip155:1",
137
+ * "eip155:10",
138
+ * "eip155:56",
139
+ * "eip155:100",
140
+ *
141
+ * so we will use a set to ensure uniqueness
142
+ */
143
+ const chainSet = new Set();
144
+ const chainStringList = (_a = metadata.chains) !== null && _a !== void 0 ? _a : [];
145
+ chainStringList.forEach((chainString) => {
146
+ const chains = chainStringToChains[chainString];
147
+ chains === null || chains === void 0 ? void 0 : chains.forEach((chain) => {
148
+ chainSet.add(chain);
149
+ });
150
+ });
151
+ walletConnector.supportedChains.forEach((chain) => {
152
+ chainSet.add(chain);
153
+ });
154
+ return [...chainSet];
155
+ };
156
+ const getEnabledWallets = (props) => {
157
+ const supportedWallets = getSupportedWallets(props.getSupportedWalletOpts);
158
+ const allEnabledWallets = supportedWallets.filter((wallet) => props.enabledChains.some((chain) => getSupportedChainsForWalletConnector(props.getSupportedWalletOpts.walletBook, wallet).includes(chain)) || wallet.key === 'magiclink');
159
+ return allEnabledWallets;
160
+ };
161
+ // get list of providers enabled in the sense that we should have wallet connectors for them
162
+ // note: magic and turnkey are considered enabled when a provider exists (for magic, a providerProjectId exists)
163
+ const getEnabledProviders = (providers) => {
164
+ var _a;
165
+ return (_a = providers === null || providers === void 0 ? void 0 : providers.filter((provider) => Boolean(provider.enabledAt) ||
166
+ (provider.provider === ProviderEnum.MagicLink &&
167
+ Boolean(provider.providerProjectId)) ||
168
+ provider.provider === ProviderEnum.Turnkey)) !== null && _a !== void 0 ? _a : [];
169
+ };
170
+
171
+ export { getEnabledProviders, getEnabledWallets, getSupportedChainsForWalletConnector, getSupportedWallets };
package/src/types.d.ts ADDED
@@ -0,0 +1,34 @@
1
+ import type { ProjectSettings } from '@dynamic-labs/sdk-api-core';
2
+ import { WalletConnector, Chain, WalletConnectorsMethod, DeepLinkVariant } from '@dynamic-labs/wallet-connector-core';
3
+ import { type NetworkConfigurationMap, type WalletUiUtils, type CoinbaseWalletPreference, type MobileExperience } from '@dynamic-labs/types';
4
+ import { IChainRpcProviders } from '@dynamic-labs/rpc-providers';
5
+ import { WalletBookSchema } from '@dynamic-labs/wallet-book';
6
+ export type GetSupportedWalletsOpts = {
7
+ appLogoUrl?: string;
8
+ appName?: string;
9
+ coinbaseWalletPreference?: CoinbaseWalletPreference;
10
+ chainRpcProviders: IChainRpcProviders;
11
+ deepLinkPreference?: DeepLinkVariant;
12
+ flowNetwork?: 'mainnet' | 'testnet';
13
+ mobileExperience?: MobileExperience;
14
+ networkConfigurations?: NetworkConfigurationMap;
15
+ settings: ProjectSettings;
16
+ skipMemo?: boolean;
17
+ walletBook: WalletBookSchema;
18
+ walletConnectProjectId?: string;
19
+ walletConnectorsProp: WalletConnectorsMethod[];
20
+ walletConnectPreferredChains?: `eip155:${number}`[];
21
+ walletUiUtils?: WalletUiUtils<WalletConnector>;
22
+ };
23
+ export type GetSupportedWallets = (opts: GetSupportedWalletsOpts) => WalletConnector[];
24
+ export type ChainInfo = {
25
+ blockchainName: string;
26
+ displayName: string;
27
+ name: string;
28
+ symbol: Chain;
29
+ };
30
+ export type ChainWihtIcon = {
31
+ icon?: string;
32
+ name: string | undefined;
33
+ symbol: Chain | undefined;
34
+ };
@@ -0,0 +1,16 @@
1
+ 'use client'
2
+ 'use strict';
3
+
4
+ Object.defineProperty(exports, '__esModule', { value: true });
5
+
6
+ var sdkApiCore = require('@dynamic-labs/sdk-api-core');
7
+
8
+ const getApiProviders = (providers) => Object.values(sdkApiCore.ProviderEnum).reduce((acc, provider) => {
9
+ const foundProvider = providers.find((providerSetting) => providerSetting.provider === provider);
10
+ if (foundProvider) {
11
+ acc[provider] = foundProvider;
12
+ }
13
+ return acc;
14
+ }, {});
15
+
16
+ exports.getApiProviders = getApiProviders;
@@ -0,0 +1,28 @@
1
+ import { Provider, ProviderEnum } from '@dynamic-labs/sdk-api-core';
2
+ export declare const getApiProviders: (providers: Provider[]) => {
3
+ emailOnly?: Provider | undefined;
4
+ magicLink?: Provider | undefined;
5
+ apple?: Provider | undefined;
6
+ bitbucket?: Provider | undefined;
7
+ coinbasesocial?: Provider | undefined;
8
+ discord?: Provider | undefined;
9
+ facebook?: Provider | undefined;
10
+ farcaster?: Provider | undefined;
11
+ github?: Provider | undefined;
12
+ gitlab?: Provider | undefined;
13
+ google?: Provider | undefined;
14
+ instagram?: Provider | undefined;
15
+ linkedin?: Provider | undefined;
16
+ microsoft?: Provider | undefined;
17
+ twitch?: Provider | undefined;
18
+ twitter?: Provider | undefined;
19
+ blocto?: Provider | undefined;
20
+ banxa?: Provider | undefined;
21
+ dynamic?: Provider | undefined;
22
+ alchemy?: Provider | undefined;
23
+ zerodev?: Provider | undefined;
24
+ telegram?: Provider | undefined;
25
+ turnkey?: Provider | undefined;
26
+ coinbaseWaas?: Provider | undefined;
27
+ sms?: Provider | undefined;
28
+ };
@@ -0,0 +1,12 @@
1
+ 'use client'
2
+ import { ProviderEnum } from '@dynamic-labs/sdk-api-core';
3
+
4
+ const getApiProviders = (providers) => Object.values(ProviderEnum).reduce((acc, provider) => {
5
+ const foundProvider = providers.find((providerSetting) => providerSetting.provider === provider);
6
+ if (foundProvider) {
7
+ acc[provider] = foundProvider;
8
+ }
9
+ return acc;
10
+ }, {});
11
+
12
+ export { getApiProviders };
@@ -0,0 +1,50 @@
1
+ 'use client'
2
+ 'use strict';
3
+
4
+ Object.defineProperty(exports, '__esModule', { value: true });
5
+
6
+ var walletConnectorCore = require('@dynamic-labs/wallet-connector-core');
7
+
8
+ const generateMessageToSign = ({ blockchain, domain, chainId, nonce, uri, publicKey, issuedAt = new Date().toISOString(), statement, requestId, resources, }) => {
9
+ var _a, _b;
10
+ if (blockchain === 'STARK') {
11
+ /**
12
+ * Starknet requires the strings to be 31 chars long
13
+ * Nonce - we need to keep full size for nonce verification on the backend (the backend shortens it to 31 chars)
14
+ * Domain - we need to shorten the domain to 31 chars
15
+ */
16
+ return JSON.stringify({
17
+ domain: domain.substring(0, 31),
18
+ nonce,
19
+ });
20
+ }
21
+ const blockchainName = (_b = (_a = walletConnectorCore.getChainInfo(blockchain)) === null || _a === void 0 ? void 0 : _a.blockchainName) !== null && _b !== void 0 ? _b : 'Ethereum';
22
+ // This format follows the sign-in with ethereum (SIWE) standard,
23
+ // but we are using it also for non-ethereum wallets for now (eg. Solana)
24
+ // for more context on format and fields, please see:
25
+ // https://docs.login.xyz/general-information/siwe-overview/eip-4361
26
+ const header = `${domain} wants you to sign in with your ${blockchainName} account:`;
27
+ const prefix = [header, publicKey].join('\n');
28
+ // If there is a statement, we want to add a gap between the prefix and the statement
29
+ // two times '\n', first to move statement to next line and second to add a gap between prefix and statement
30
+ const prefixWithStatementGap = statement ? '\n\n' : '\n';
31
+ const prefixWithStatement = `${[prefix, statement].join(prefixWithStatementGap)}\n`;
32
+ const suffixFields = [];
33
+ suffixFields.push(`URI: ${uri}`);
34
+ suffixFields.push('Version: 1');
35
+ if (chainId) {
36
+ suffixFields.push(`Chain ID: ${chainId}`);
37
+ }
38
+ suffixFields.push(`Nonce: ${nonce}`);
39
+ suffixFields.push(`Issued At: ${issuedAt}`);
40
+ if (requestId) {
41
+ suffixFields.push(`Request ID: ${requestId}`);
42
+ }
43
+ if (resources === null || resources === void 0 ? void 0 : resources.length) {
44
+ suffixFields.push(`Resources:${resources.map((resource) => '\n- ' + resource).join()}`);
45
+ }
46
+ const suffix = suffixFields.join('\n');
47
+ return [prefixWithStatement, suffix].join('\n');
48
+ };
49
+
50
+ exports.generateMessageToSign = generateMessageToSign;
@@ -0,0 +1,14 @@
1
+ import { Chain } from '@dynamic-labs/wallet-connector-core';
2
+ export interface MessageParameters {
3
+ blockchain: Chain;
4
+ chainId?: number | string;
5
+ domain: string;
6
+ issuedAt?: string;
7
+ nonce: string;
8
+ publicKey: string;
9
+ requestId?: string;
10
+ resources?: string[];
11
+ statement?: string;
12
+ uri: string;
13
+ }
14
+ export declare const generateMessageToSign: ({ blockchain, domain, chainId, nonce, uri, publicKey, issuedAt, statement, requestId, resources, }: MessageParameters) => string;
@@ -0,0 +1,46 @@
1
+ 'use client'
2
+ import { getChainInfo } from '@dynamic-labs/wallet-connector-core';
3
+
4
+ const generateMessageToSign = ({ blockchain, domain, chainId, nonce, uri, publicKey, issuedAt = new Date().toISOString(), statement, requestId, resources, }) => {
5
+ var _a, _b;
6
+ if (blockchain === 'STARK') {
7
+ /**
8
+ * Starknet requires the strings to be 31 chars long
9
+ * Nonce - we need to keep full size for nonce verification on the backend (the backend shortens it to 31 chars)
10
+ * Domain - we need to shorten the domain to 31 chars
11
+ */
12
+ return JSON.stringify({
13
+ domain: domain.substring(0, 31),
14
+ nonce,
15
+ });
16
+ }
17
+ const blockchainName = (_b = (_a = getChainInfo(blockchain)) === null || _a === void 0 ? void 0 : _a.blockchainName) !== null && _b !== void 0 ? _b : 'Ethereum';
18
+ // This format follows the sign-in with ethereum (SIWE) standard,
19
+ // but we are using it also for non-ethereum wallets for now (eg. Solana)
20
+ // for more context on format and fields, please see:
21
+ // https://docs.login.xyz/general-information/siwe-overview/eip-4361
22
+ const header = `${domain} wants you to sign in with your ${blockchainName} account:`;
23
+ const prefix = [header, publicKey].join('\n');
24
+ // If there is a statement, we want to add a gap between the prefix and the statement
25
+ // two times '\n', first to move statement to next line and second to add a gap between prefix and statement
26
+ const prefixWithStatementGap = statement ? '\n\n' : '\n';
27
+ const prefixWithStatement = `${[prefix, statement].join(prefixWithStatementGap)}\n`;
28
+ const suffixFields = [];
29
+ suffixFields.push(`URI: ${uri}`);
30
+ suffixFields.push('Version: 1');
31
+ if (chainId) {
32
+ suffixFields.push(`Chain ID: ${chainId}`);
33
+ }
34
+ suffixFields.push(`Nonce: ${nonce}`);
35
+ suffixFields.push(`Issued At: ${issuedAt}`);
36
+ if (requestId) {
37
+ suffixFields.push(`Request ID: ${requestId}`);
38
+ }
39
+ if (resources === null || resources === void 0 ? void 0 : resources.length) {
40
+ suffixFields.push(`Resources:${resources.map((resource) => '\n- ' + resource).join()}`);
41
+ }
42
+ const suffix = suffixFields.join('\n');
43
+ return [prefixWithStatement, suffix].join('\n');
44
+ };
45
+
46
+ export { generateMessageToSign };