@dynamic-labs/multi-wallet 4.0.0-alpha.5 → 4.0.0-alpha.51
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 +468 -0
- package/package.cjs +8 -0
- package/package.js +4 -0
- package/package.json +9 -16
- package/src/const.cjs +33 -0
- package/src/const.d.ts +3 -0
- package/src/const.js +29 -0
- package/src/index.cjs +14 -7
- package/src/index.d.ts +1 -2
- package/src/index.js +10 -2
- package/src/utils/{getApiProviders.d.ts → getApiProviders/getApiProviders.d.ts} +6 -0
- package/src/utils/getApiProviders/index.d.ts +1 -0
- package/src/utils/getEnabledProviders/getEnabledProviders.cjs +18 -0
- package/src/utils/getEnabledProviders/getEnabledProviders.d.ts +2 -0
- package/src/utils/getEnabledProviders/getEnabledProviders.js +14 -0
- package/src/utils/getEnabledProviders/index.d.ts +1 -0
- package/src/utils/getEnabledWallets/getEnabledWallets.cjs +16 -0
- package/src/utils/getEnabledWallets/getEnabledWallets.d.ts +6 -0
- package/src/utils/getEnabledWallets/getEnabledWallets.js +12 -0
- package/src/utils/getEnabledWallets/index.d.ts +1 -0
- package/src/utils/getSupportedChainsForWalletConnector/getSupportedChainsForWalletConnector.cjs +41 -0
- package/src/utils/getSupportedChainsForWalletConnector/getSupportedChainsForWalletConnector.d.ts +3 -0
- package/src/utils/getSupportedChainsForWalletConnector/getSupportedChainsForWalletConnector.js +37 -0
- package/src/utils/getSupportedChainsForWalletConnector/index.d.ts +1 -0
- package/src/utils/getSupportedWallets/applyLinksOverrides/applyLinksOverrides.cjs +17 -0
- package/src/utils/getSupportedWallets/applyLinksOverrides/applyLinksOverrides.d.ts +3 -0
- package/src/utils/getSupportedWallets/applyLinksOverrides/applyLinksOverrides.js +13 -0
- package/src/utils/getSupportedWallets/applyLinksOverrides/index.d.ts +1 -0
- package/src/utils/getSupportedWallets/filterWalletsForPlatform/filterWalletsForPlatform.cjs +30 -0
- package/src/utils/getSupportedWallets/filterWalletsForPlatform/filterWalletsForPlatform.d.ts +3 -0
- package/src/utils/getSupportedWallets/filterWalletsForPlatform/filterWalletsForPlatform.js +26 -0
- package/src/utils/getSupportedWallets/filterWalletsForPlatform/index.d.ts +1 -0
- package/src/utils/getSupportedWallets/getSupportedWallets.cjs +71 -0
- package/src/utils/getSupportedWallets/getSupportedWallets.d.ts +2 -0
- package/src/utils/getSupportedWallets/getSupportedWallets.js +67 -0
- package/src/utils/getSupportedWallets/handleMobileWalletFilter/handleMobileWalletFilter.cjs +35 -0
- package/src/utils/getSupportedWallets/handleMobileWalletFilter/handleMobileWalletFilter.d.ts +2 -0
- package/src/utils/getSupportedWallets/handleMobileWalletFilter/handleMobileWalletFilter.js +31 -0
- package/src/utils/getSupportedWallets/handleMobileWalletFilter/index.d.ts +1 -0
- package/src/utils/getSupportedWallets/index.d.ts +1 -0
- package/src/utils/getWalletConnectorConstructorOptions/getWalletConnectorConstructorOptions.cjs +42 -0
- package/src/utils/getWalletConnectorConstructorOptions/getWalletConnectorConstructorOptions.d.ts +162 -0
- package/src/utils/getWalletConnectorConstructorOptions/getWalletConnectorConstructorOptions.js +38 -0
- package/src/utils/getWalletConnectorConstructorOptions/index.d.ts +1 -0
- package/src/utils/index.d.ts +6 -0
- package/src/utils/message/index.d.ts +1 -0
- package/src/multi-wallet.cjs +0 -178
- package/src/multi-wallet.d.ts +0 -11
- package/src/multi-wallet.js +0 -171
- /package/src/utils/{getApiProviders.cjs → getApiProviders/getApiProviders.cjs} +0 -0
- /package/src/utils/{getApiProviders.js → getApiProviders/getApiProviders.js} +0 -0
- /package/src/utils/{message.cjs → message/message.cjs} +0 -0
- /package/src/utils/{message.d.ts → message/message.d.ts} +0 -0
- /package/src/utils/{message.js → message/message.js} +0 -0
package/src/utils/getWalletConnectorConstructorOptions/getWalletConnectorConstructorOptions.d.ts
ADDED
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
import { IChainRpcProviders } from '@dynamic-labs/rpc-providers';
|
|
2
|
+
import { ProjectSettings } from '@dynamic-labs/sdk-api-core';
|
|
3
|
+
import { CoinbaseWalletPreference, MobileExperience, NetworkConfigurationMap, WalletUiUtils } from '@dynamic-labs/types';
|
|
4
|
+
import { WalletBookSchema } from '@dynamic-labs/wallet-book';
|
|
5
|
+
import { DeepLinkVariant, InternalWalletConnector } from '@dynamic-labs/wallet-connector-core';
|
|
6
|
+
type WalletConnectorConstructorOptionsParams = {
|
|
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
|
+
walletBook: WalletBookSchema;
|
|
17
|
+
walletConnectProjectId?: string;
|
|
18
|
+
walletUiUtils?: WalletUiUtils<InternalWalletConnector>;
|
|
19
|
+
walletConnectPreferredChains?: `eip155:${number}`[];
|
|
20
|
+
};
|
|
21
|
+
export declare const getWalletConnectorConstructorOptions: ({ appLogoUrl, appName, coinbaseWalletPreference, chainRpcProviders, deepLinkPreference, flowNetwork, mobileExperience, networkConfigurations, settings, walletConnectProjectId, walletUiUtils, walletBook, walletConnectPreferredChains, }: WalletConnectorConstructorOptionsParams) => {
|
|
22
|
+
apiProviders: {
|
|
23
|
+
emailOnly?: import("@dynamic-labs/sdk-api-core").Provider | undefined;
|
|
24
|
+
magicLink?: import("@dynamic-labs/sdk-api-core").Provider | undefined;
|
|
25
|
+
apple?: import("@dynamic-labs/sdk-api-core").Provider | undefined;
|
|
26
|
+
bitbucket?: import("@dynamic-labs/sdk-api-core").Provider | undefined;
|
|
27
|
+
coinbasesocial?: import("@dynamic-labs/sdk-api-core").Provider | undefined;
|
|
28
|
+
discord?: import("@dynamic-labs/sdk-api-core").Provider | undefined;
|
|
29
|
+
epicgames?: import("@dynamic-labs/sdk-api-core").Provider | undefined;
|
|
30
|
+
facebook?: import("@dynamic-labs/sdk-api-core").Provider | undefined;
|
|
31
|
+
farcaster?: import("@dynamic-labs/sdk-api-core").Provider | undefined;
|
|
32
|
+
github?: import("@dynamic-labs/sdk-api-core").Provider | undefined;
|
|
33
|
+
gitlab?: import("@dynamic-labs/sdk-api-core").Provider | undefined;
|
|
34
|
+
google?: import("@dynamic-labs/sdk-api-core").Provider | undefined;
|
|
35
|
+
instagram?: import("@dynamic-labs/sdk-api-core").Provider | undefined;
|
|
36
|
+
linkedin?: import("@dynamic-labs/sdk-api-core").Provider | undefined;
|
|
37
|
+
microsoft?: import("@dynamic-labs/sdk-api-core").Provider | undefined;
|
|
38
|
+
twitch?: import("@dynamic-labs/sdk-api-core").Provider | undefined;
|
|
39
|
+
twitter?: import("@dynamic-labs/sdk-api-core").Provider | undefined;
|
|
40
|
+
blocto?: import("@dynamic-labs/sdk-api-core").Provider | undefined;
|
|
41
|
+
banxa?: import("@dynamic-labs/sdk-api-core").Provider | undefined;
|
|
42
|
+
dynamic?: import("@dynamic-labs/sdk-api-core").Provider | undefined;
|
|
43
|
+
alchemy?: import("@dynamic-labs/sdk-api-core").Provider | undefined;
|
|
44
|
+
zerodev?: import("@dynamic-labs/sdk-api-core").Provider | undefined;
|
|
45
|
+
telegram?: import("@dynamic-labs/sdk-api-core").Provider | undefined;
|
|
46
|
+
turnkey?: import("@dynamic-labs/sdk-api-core").Provider | undefined;
|
|
47
|
+
coinbaseWaas?: import("@dynamic-labs/sdk-api-core").Provider | undefined;
|
|
48
|
+
sms?: import("@dynamic-labs/sdk-api-core").Provider | undefined;
|
|
49
|
+
spotify?: import("@dynamic-labs/sdk-api-core").Provider | undefined;
|
|
50
|
+
tiktok?: import("@dynamic-labs/sdk-api-core").Provider | undefined;
|
|
51
|
+
line?: import("@dynamic-labs/sdk-api-core").Provider | undefined;
|
|
52
|
+
steam?: import("@dynamic-labs/sdk-api-core").Provider | undefined;
|
|
53
|
+
shopify?: import("@dynamic-labs/sdk-api-core").Provider | undefined;
|
|
54
|
+
};
|
|
55
|
+
appLogoUrl: string | undefined;
|
|
56
|
+
appName: string | undefined;
|
|
57
|
+
chainRpcProviders: IChainRpcProviders;
|
|
58
|
+
coinbaseWalletPreference: CoinbaseWalletPreference | undefined;
|
|
59
|
+
cosmosNetworks: import("@dynamic-labs/types").GenericNetwork[];
|
|
60
|
+
deepLinkPreference: DeepLinkVariant | undefined;
|
|
61
|
+
eclipseNetworks: import("@dynamic-labs/types").GenericNetwork[];
|
|
62
|
+
evmNetworks: import("@dynamic-labs/types").GenericNetwork[];
|
|
63
|
+
flowNetwork: "mainnet" | "testnet" | undefined;
|
|
64
|
+
mobileExperience: MobileExperience | undefined;
|
|
65
|
+
projectId: string | undefined;
|
|
66
|
+
settings: ProjectSettings;
|
|
67
|
+
solNetworks: import("@dynamic-labs/types").GenericNetwork[];
|
|
68
|
+
starknetNetworks: import("@dynamic-labs/types").GenericNetwork[];
|
|
69
|
+
walletBook: {
|
|
70
|
+
groups: Record<string, {
|
|
71
|
+
name: string;
|
|
72
|
+
key: string;
|
|
73
|
+
brand?: {
|
|
74
|
+
alt?: string | undefined;
|
|
75
|
+
primaryColor?: string | undefined;
|
|
76
|
+
spriteId?: string | undefined;
|
|
77
|
+
} | undefined;
|
|
78
|
+
walletOverrides?: Record<string, {
|
|
79
|
+
brand?: {
|
|
80
|
+
alt?: string | undefined;
|
|
81
|
+
primaryColor?: string | undefined;
|
|
82
|
+
spriteId?: string | undefined;
|
|
83
|
+
} | undefined;
|
|
84
|
+
name?: string | undefined;
|
|
85
|
+
}> | undefined;
|
|
86
|
+
}>;
|
|
87
|
+
wallets: Record<string, {
|
|
88
|
+
name: string;
|
|
89
|
+
brand?: {
|
|
90
|
+
alt?: string | undefined;
|
|
91
|
+
primaryColor?: string | undefined;
|
|
92
|
+
spriteId?: string | undefined;
|
|
93
|
+
} | undefined;
|
|
94
|
+
chainGroup?: string | undefined;
|
|
95
|
+
chains?: string[] | undefined;
|
|
96
|
+
desktop?: {
|
|
97
|
+
chromeId?: string | undefined;
|
|
98
|
+
edgeId?: string | undefined;
|
|
99
|
+
firefoxId?: string | undefined;
|
|
100
|
+
native?: string | undefined;
|
|
101
|
+
operaId?: string | undefined;
|
|
102
|
+
safariId?: string | undefined;
|
|
103
|
+
universal?: string | undefined;
|
|
104
|
+
} | undefined;
|
|
105
|
+
eip6963Config?: {
|
|
106
|
+
rdns: string;
|
|
107
|
+
} | undefined;
|
|
108
|
+
filterFromWalletConnect?: boolean | undefined;
|
|
109
|
+
group?: string | undefined;
|
|
110
|
+
hardwareWallets?: string[] | undefined;
|
|
111
|
+
injectedConfig?: {
|
|
112
|
+
chain: string;
|
|
113
|
+
extensionLocators: {
|
|
114
|
+
value: boolean;
|
|
115
|
+
flag: string;
|
|
116
|
+
}[];
|
|
117
|
+
providerInterface?: string | undefined;
|
|
118
|
+
walletStandard?: {
|
|
119
|
+
features: string[];
|
|
120
|
+
name: string;
|
|
121
|
+
providerId?: string | undefined;
|
|
122
|
+
} | undefined;
|
|
123
|
+
walletStandardLocators?: {
|
|
124
|
+
name: string;
|
|
125
|
+
locator: string;
|
|
126
|
+
}[] | undefined;
|
|
127
|
+
windowLocations?: string[] | undefined;
|
|
128
|
+
}[] | undefined;
|
|
129
|
+
mobile?: {
|
|
130
|
+
android?: string | null | undefined;
|
|
131
|
+
androidId?: string | undefined;
|
|
132
|
+
inAppBrowser?: string | null | undefined;
|
|
133
|
+
ios?: string | null | undefined;
|
|
134
|
+
iosId?: string | undefined;
|
|
135
|
+
native?: string | undefined;
|
|
136
|
+
universal?: string | undefined;
|
|
137
|
+
} | undefined;
|
|
138
|
+
mobileExperience?: "in-app-browser" | "redirect" | undefined;
|
|
139
|
+
shortName?: string | undefined;
|
|
140
|
+
showOnlyIfInstalled?: boolean | undefined;
|
|
141
|
+
switchNetworkOnlyFromWallet?: boolean | undefined;
|
|
142
|
+
walletConnect?: {
|
|
143
|
+
sdks?: string[] | undefined;
|
|
144
|
+
} | undefined;
|
|
145
|
+
walletGroup?: string | undefined;
|
|
146
|
+
walletLimitations?: {
|
|
147
|
+
browserExtension?: {
|
|
148
|
+
unsupportedEvents?: string[] | undefined;
|
|
149
|
+
unsupportedMethods?: string[] | undefined;
|
|
150
|
+
} | undefined;
|
|
151
|
+
mobile?: {
|
|
152
|
+
unsupportedEvents?: string[] | undefined;
|
|
153
|
+
unsupportedMethods?: string[] | undefined;
|
|
154
|
+
} | undefined;
|
|
155
|
+
} | undefined;
|
|
156
|
+
}>;
|
|
157
|
+
};
|
|
158
|
+
walletConnectPreferredChains: `eip155:${number}`[] | undefined;
|
|
159
|
+
walletConnectorEventsEmitter: import("eventemitter3").EventEmitter<import("dist/packages/wallet-connector-core/src/events").WalletConnectorEvents, any>;
|
|
160
|
+
walletUiUtils: WalletUiUtils<import("@dynamic-labs/wallet-connector-core").WalletConnectorCore.WalletConnector>;
|
|
161
|
+
};
|
|
162
|
+
export {};
|
package/src/utils/getWalletConnectorConstructorOptions/getWalletConnectorConstructorOptions.js
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
import { walletConnectorEvents } from '@dynamic-labs/wallet-connector-core';
|
|
3
|
+
import { getEnabledProviders } from '../getEnabledProviders/getEnabledProviders.js';
|
|
4
|
+
import { getApiProviders } from '../getApiProviders/getApiProviders.js';
|
|
5
|
+
import { defaultWalletUiUtils } from '../../const.js';
|
|
6
|
+
|
|
7
|
+
const getWalletConnectorConstructorOptions = ({ appLogoUrl, appName, coinbaseWalletPreference, chainRpcProviders, deepLinkPreference, flowNetwork, mobileExperience, networkConfigurations, settings, walletConnectProjectId, walletUiUtils, walletBook, walletConnectPreferredChains, }) => {
|
|
8
|
+
const eclipseNetworkConfigs = (networkConfigurations === null || networkConfigurations === void 0 ? void 0 : networkConfigurations.eclipse) || [];
|
|
9
|
+
const evmNetworkConfigs = (networkConfigurations === null || networkConfigurations === void 0 ? void 0 : networkConfigurations.evm) || [];
|
|
10
|
+
const solanaNetworkConfigs = (networkConfigurations === null || networkConfigurations === void 0 ? void 0 : networkConfigurations.solana) || [];
|
|
11
|
+
const cosmosNetworkConfigs = (networkConfigurations === null || networkConfigurations === void 0 ? void 0 : networkConfigurations.cosmos) || [];
|
|
12
|
+
const starknetNetworkConfigs = (networkConfigurations === null || networkConfigurations === void 0 ? void 0 : networkConfigurations.starknet) || [];
|
|
13
|
+
const apiProviders = getApiProviders(getEnabledProviders(settings.providers));
|
|
14
|
+
const opts = {
|
|
15
|
+
apiProviders,
|
|
16
|
+
appLogoUrl,
|
|
17
|
+
appName,
|
|
18
|
+
chainRpcProviders,
|
|
19
|
+
coinbaseWalletPreference,
|
|
20
|
+
cosmosNetworks: cosmosNetworkConfigs,
|
|
21
|
+
deepLinkPreference,
|
|
22
|
+
eclipseNetworks: eclipseNetworkConfigs,
|
|
23
|
+
evmNetworks: evmNetworkConfigs,
|
|
24
|
+
flowNetwork,
|
|
25
|
+
mobileExperience,
|
|
26
|
+
projectId: walletConnectProjectId,
|
|
27
|
+
settings,
|
|
28
|
+
solNetworks: solanaNetworkConfigs,
|
|
29
|
+
starknetNetworks: starknetNetworkConfigs,
|
|
30
|
+
walletBook,
|
|
31
|
+
walletConnectPreferredChains,
|
|
32
|
+
walletConnectorEventsEmitter: walletConnectorEvents,
|
|
33
|
+
walletUiUtils: walletUiUtils || defaultWalletUiUtils,
|
|
34
|
+
};
|
|
35
|
+
return opts;
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
export { getWalletConnectorConstructorOptions };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { getWalletConnectorConstructorOptions } from './getWalletConnectorConstructorOptions';
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { generateMessageToSign } from './message';
|
|
2
|
+
export { getEnabledProviders } from './getEnabledProviders';
|
|
3
|
+
export { getEnabledWallets } from './getEnabledWallets';
|
|
4
|
+
export { getSupportedWallets } from './getSupportedWallets';
|
|
5
|
+
export { getSupportedChainsForWalletConnector } from './getSupportedChainsForWalletConnector';
|
|
6
|
+
export { getWalletConnectorConstructorOptions } from './getWalletConnectorConstructorOptions';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './message';
|
package/src/multi-wallet.cjs
DELETED
|
@@ -1,178 +0,0 @@
|
|
|
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;
|
package/src/multi-wallet.d.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { Chain, InternalWalletConnector } 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: InternalWalletConnector) => Chain[];
|
|
7
|
-
export declare const getEnabledWallets: (props: {
|
|
8
|
-
enabledChains: Chain[];
|
|
9
|
-
getSupportedWalletOpts: GetSupportedWalletsOpts;
|
|
10
|
-
}) => InternalWalletConnector[];
|
|
11
|
-
export declare const getEnabledProviders: (providers: Provider[] | undefined) => Provider[];
|
package/src/multi-wallet.js
DELETED
|
@@ -1,171 +0,0 @@
|
|
|
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 };
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|