@dynamic-labs/wallet-connector-core 4.0.0-alpha.4 → 4.0.0-alpha.41
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 +361 -0
- package/package.cjs +8 -0
- package/package.js +4 -0
- package/package.json +9 -16
- package/src/{lib/wallets/Wallet → Wallet}/Wallet.cjs +3 -5
- package/src/{lib/wallets/Wallet → Wallet}/Wallet.d.ts +1 -1
- package/src/{lib/wallets/Wallet → Wallet}/Wallet.js +3 -5
- package/src/{lib → WalletBookSingleton}/WalletBookSingleton.cjs +3 -0
- package/src/{lib → WalletBookSingleton}/WalletBookSingleton.d.ts +1 -0
- package/src/{lib → WalletBookSingleton}/WalletBookSingleton.js +3 -0
- package/src/WalletBookSingleton/index.d.ts +1 -0
- package/src/{lib/WalletConnector.cjs → WalletConnectorBase/WalletConnectorBase.cjs} +20 -37
- package/src/{lib/WalletConnector.d.ts → WalletConnectorBase/WalletConnectorBase.d.ts} +13 -44
- package/src/{lib/WalletConnector.js → WalletConnectorBase/WalletConnectorBase.js} +21 -36
- package/src/WalletConnectorBase/index.d.ts +2 -0
- package/src/WalletConnectorBase/types.cjs +33 -0
- package/src/WalletConnectorBase/types.d.ts +54 -0
- package/src/WalletConnectorBase/types.js +28 -0
- package/src/events/index.d.ts +1 -0
- package/src/events/walletConnectorEvents.cjs +14 -0
- package/src/events/walletConnectorEvents.d.ts +34 -0
- package/src/events/walletConnectorEvents.js +6 -0
- package/src/index.cjs +22 -7
- package/src/index.d.ts +7 -4
- package/src/index.js +13 -2
- package/src/{lib → interfaces}/IAccountAbstractionWalletConnector.d.ts +11 -2
- package/src/{lib → interfaces}/IBitcoinWalletConnector.d.ts +1 -1
- package/src/{lib → interfaces}/ICoinbaseMPCWalletConnector.d.ts +1 -1
- package/src/{lib → interfaces}/IEmailWalletConnector.d.ts +1 -1
- package/src/{lib → interfaces}/IHardwareWalletConnector.d.ts +1 -1
- package/src/{lib → interfaces}/IPasskeyWalletConnector.d.ts +1 -1
- package/src/{lib → interfaces}/IPhantomRedirectConnector.d.ts +1 -1
- package/src/{lib → interfaces}/ISMSWalletConnector.d.ts +1 -1
- package/src/{lib → interfaces}/ISendBalanceWalletConnector.d.ts +1 -1
- package/src/{lib → interfaces}/ISessionKeyCompatibleWalletConnector.d.ts +1 -1
- package/src/{lib → interfaces}/ITurnkeyWalletConnector.d.ts +1 -1
- package/src/interfaces/ITurnkeyWalletConnectorStamper.d.ts +35 -0
- package/src/{lib → interfaces}/IWalletConnectConnector.d.ts +1 -1
- package/src/{lib → interfaces}/index.d.ts +7 -10
- package/src/types.d.ts +88 -0
- package/src/utils/eventListenerHandlers.d.ts +1 -1
- package/src/utils/getChainInfo/getChainInfo.cjs +4 -4
- package/src/utils/getChainInfo/getChainInfo.d.ts +2 -2
- package/src/utils/getChainInfo/getChainInfo.js +4 -4
- package/src/utils/getWalletConnectorByKey.d.ts +1 -1
- package/src/utils/getWalletLinks/getWalletLinks.cjs +32 -0
- package/src/utils/getWalletLinks/getWalletLinks.d.ts +2 -0
- package/src/utils/getWalletLinks/getWalletLinks.js +28 -0
- package/src/utils/getWalletLinks/index.d.ts +1 -0
- package/src/utils/getWalletMetadataFromWalletBook/getDeepLinks/getDeepLinks.cjs +36 -0
- package/src/utils/getWalletMetadataFromWalletBook/getDeepLinks/getDeepLinks.d.ts +6 -0
- package/src/utils/getWalletMetadataFromWalletBook/getDeepLinks/getDeepLinks.js +32 -0
- package/src/utils/getWalletMetadataFromWalletBook/getDeepLinks/index.d.ts +1 -0
- package/src/utils/getWalletMetadataFromWalletBook/getDownloadLinks/getDownloadLinks.cjs +36 -0
- package/src/utils/getWalletMetadataFromWalletBook/getDownloadLinks/getDownloadLinks.d.ts +3 -0
- package/src/utils/getWalletMetadataFromWalletBook/getDownloadLinks/getDownloadLinks.js +32 -0
- package/src/utils/getWalletMetadataFromWalletBook/getDownloadLinks/index.d.ts +1 -0
- package/src/utils/getWalletMetadataFromWalletBook/getIconUrl/getIconUrl.cjs +15 -0
- package/src/utils/getWalletMetadataFromWalletBook/getIconUrl/getIconUrl.d.ts +1 -0
- package/src/utils/getWalletMetadataFromWalletBook/getIconUrl/getIconUrl.js +11 -0
- package/src/utils/getWalletMetadataFromWalletBook/getIconUrl/index.d.ts +1 -0
- package/src/utils/getWalletMetadataFromWalletBook/getValidHexColor/getValidHexColor.cjs +15 -0
- package/src/utils/getWalletMetadataFromWalletBook/getValidHexColor/getValidHexColor.d.ts +1 -0
- package/src/utils/getWalletMetadataFromWalletBook/getValidHexColor/getValidHexColor.js +11 -0
- package/src/utils/getWalletMetadataFromWalletBook/getValidHexColor/index.d.ts +1 -0
- package/src/utils/getWalletMetadataFromWalletBook/getWalletLimitations/getWalletLimitations.cjs +19 -0
- package/src/utils/getWalletMetadataFromWalletBook/getWalletLimitations/getWalletLimitations.d.ts +3 -0
- package/src/utils/getWalletMetadataFromWalletBook/getWalletLimitations/getWalletLimitations.js +15 -0
- package/src/utils/getWalletMetadataFromWalletBook/getWalletLimitations/index.d.ts +1 -0
- package/src/utils/getWalletMetadataFromWalletBook/getWalletMetadataFromWalletBook.cjs +46 -0
- package/src/utils/getWalletMetadataFromWalletBook/getWalletMetadataFromWalletBook.d.ts +10 -0
- package/src/utils/getWalletMetadataFromWalletBook/getWalletMetadataFromWalletBook.js +42 -0
- package/src/utils/getWalletMetadataFromWalletBook/index.d.ts +1 -0
- package/src/utils/index.d.ts +4 -0
- package/src/utils/isAccountAbstractionConnector/isAccountAbstractionConnector.d.ts +1 -1
- package/src/utils/isBitcoinConnector/isBitcoinConnector.d.ts +1 -1
- package/src/utils/isBloctoConnector/isBloctoConnector.d.ts +1 -1
- package/src/utils/isCoinbaseMpcWalletConnector/isCoinbaseMpcWalletConnector.d.ts +1 -1
- package/src/utils/isConnectorEventSupported/index.d.ts +1 -0
- package/src/utils/isConnectorEventSupported/isConnectorEventSupported.cjs +11 -0
- package/src/utils/isConnectorEventSupported/isConnectorEventSupported.d.ts +3 -0
- package/src/utils/isConnectorEventSupported/isConnectorEventSupported.js +7 -0
- package/src/utils/isConnectorMethodSupported/isConnectorMethodSupported.cjs +2 -5
- package/src/utils/isConnectorMethodSupported/isConnectorMethodSupported.d.ts +3 -3
- package/src/utils/isConnectorMethodSupported/isConnectorMethodSupported.js +2 -5
- package/src/utils/isEmailOTPWalletConnector/isEmailOTPWalletConnector.d.ts +1 -1
- package/src/utils/isEmailWalletConnector/isEmailWalletConnector.d.ts +1 -1
- package/src/utils/isEmbeddedConnector/isEmbeddedConnector.d.ts +1 -1
- package/src/utils/isHardwareWalletConnector/isHardwareWalletConnector.d.ts +1 -1
- package/src/utils/isMagicConnector/isMagicConnector.d.ts +1 -1
- package/src/utils/isPasskeyWalletConnector/isPasskeyWalletConnector.d.ts +1 -1
- package/src/utils/isPhantomRedirectConnector/isPhantomRedirectConnector.d.ts +1 -1
- package/src/utils/isSendBalanceWalletConnector/isSendBalanceWalletConnector.cjs +2 -1
- package/src/utils/isSendBalanceWalletConnector/isSendBalanceWalletConnector.d.ts +2 -2
- package/src/utils/isSendBalanceWalletConnector/isSendBalanceWalletConnector.js +2 -1
- package/src/utils/isSessionKeyCompatible/isSessionKeyCompatibleWallet/isSessionKeyCompatibleWallet.d.ts +1 -1
- package/src/utils/isSessionKeyCompatible/isSessionKeyCompatibleWalletConnector/isSessionKeyCompatibleWalletConnector.d.ts +2 -2
- package/src/utils/isSocialWalletConnector/isSocialWalletConnector.d.ts +1 -1
- package/src/utils/isTurnkeyWalletConnector/isTurnkeyWalletConnector.d.ts +1 -1
- package/src/utils/isWalletConnectConnector/isWalletConnectConnector.d.ts +1 -1
- package/src/utils/walletConnectDeepLinks/performPlatformSpecificConnectionMethod.cjs +3 -3
- package/src/utils/walletConnectDeepLinks/performPlatformSpecificConnectionMethod.d.ts +3 -3
- package/src/utils/walletConnectDeepLinks/performPlatformSpecificConnectionMethod.js +3 -3
- package/src/utils/walletConnectDeepLinks/walletConnectDeepLinks.cjs +11 -8
- package/src/utils/walletConnectDeepLinks/walletConnectDeepLinks.d.ts +3 -3
- package/src/utils/walletConnectDeepLinks/walletConnectDeepLinks.js +11 -8
- package/src/lib/ITurnkeyWalletConnectorStamper.d.ts +0 -18
- package/src/lib/WalletConnectorExtension.d.ts +0 -7
- package/src/lib/types.d.ts +0 -8
- package/src/lib/wallets/index.d.ts +0 -1
- /package/src/{lib/wallets/Wallet → Wallet}/index.d.ts +0 -0
- /package/src/{lib → interfaces}/IEmailOTPWalletConnector.d.ts +0 -0
|
@@ -1,17 +1,14 @@
|
|
|
1
|
-
export * from './IEmailOTPWalletConnector';
|
|
2
|
-
export * from './IEmailWalletConnector';
|
|
3
|
-
export * from './WalletConnector';
|
|
4
|
-
export * from './types';
|
|
5
|
-
export * from './IPasskeyWalletConnector';
|
|
6
|
-
export * from './ITurnkeyWalletConnector';
|
|
7
|
-
export * from './ITurnkeyWalletConnectorStamper';
|
|
8
1
|
export * from './IAccountAbstractionWalletConnector';
|
|
9
2
|
export * from './IBitcoinWalletConnector';
|
|
3
|
+
export * from './ICoinbaseMPCWalletConnector';
|
|
4
|
+
export * from './IEmailOTPWalletConnector';
|
|
5
|
+
export * from './IEmailWalletConnector';
|
|
10
6
|
export * from './IHardwareWalletConnector';
|
|
7
|
+
export * from './IPasskeyWalletConnector';
|
|
11
8
|
export * from './IPhantomRedirectConnector';
|
|
12
|
-
export * from './ICoinbaseMPCWalletConnector';
|
|
13
|
-
export * from './IWalletConnectConnector';
|
|
14
9
|
export * from './ISendBalanceWalletConnector';
|
|
15
10
|
export * from './ISessionKeyCompatibleWalletConnector';
|
|
16
11
|
export * from './ISMSWalletConnector';
|
|
17
|
-
export * from './
|
|
12
|
+
export * from './ITurnkeyWalletConnector';
|
|
13
|
+
export * from './ITurnkeyWalletConnectorStamper';
|
|
14
|
+
export * from './IWalletConnectConnector';
|
package/src/types.d.ts
CHANGED
|
@@ -3,3 +3,91 @@ export type ChainChangeEventHandler = (chainId: string | number) => Promise<void
|
|
|
3
3
|
export type DisconnectEventHandler = (error?: {
|
|
4
4
|
code: number;
|
|
5
5
|
}) => Promise<void>;
|
|
6
|
+
export type WalletEvent = 'accountChanged' | 'chainChanged';
|
|
7
|
+
export type WalletMethod = 'getConnectedAccounts';
|
|
8
|
+
export type WalletLimitations = {
|
|
9
|
+
desktop?: {
|
|
10
|
+
unsupportedEvents?: WalletEvent[];
|
|
11
|
+
unsupportedMethods?: WalletMethod[];
|
|
12
|
+
};
|
|
13
|
+
mobile?: {
|
|
14
|
+
unsupportedEvents?: WalletEvent[];
|
|
15
|
+
unsupportedMethods?: WalletMethod[];
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* @property android - The full url to download the wallet on Android
|
|
20
|
+
* @property brave - The full url to download the wallet on Brave
|
|
21
|
+
* @property chrome - The full url to download the wallet on Chrome
|
|
22
|
+
* @property edge - The full url to download the wallet on Edge
|
|
23
|
+
* @property firefox - The full url to download the wallet on Firefox
|
|
24
|
+
* @property ios - The full url to download the wallet on iOS
|
|
25
|
+
*/
|
|
26
|
+
export type WalletLinks = {
|
|
27
|
+
android: string;
|
|
28
|
+
brave: string;
|
|
29
|
+
chrome: string;
|
|
30
|
+
edge: string;
|
|
31
|
+
firefox: string;
|
|
32
|
+
ios: string;
|
|
33
|
+
};
|
|
34
|
+
export type WalletDownloadLinks = {
|
|
35
|
+
chromeId?: string;
|
|
36
|
+
edgeId?: string;
|
|
37
|
+
firefoxId?: string;
|
|
38
|
+
operaId?: string;
|
|
39
|
+
safariId?: string;
|
|
40
|
+
/**
|
|
41
|
+
* @property androidId - The id to download the wallet on Google Play
|
|
42
|
+
*/
|
|
43
|
+
androidId?: string;
|
|
44
|
+
/**
|
|
45
|
+
* @property iosId - The id to download the wallet on App Store
|
|
46
|
+
*/
|
|
47
|
+
iosId?: string;
|
|
48
|
+
/**
|
|
49
|
+
* @property android - The url to download the wallet on Android
|
|
50
|
+
*/
|
|
51
|
+
androidUrl?: string;
|
|
52
|
+
/**
|
|
53
|
+
* @property ios - The url to download the wallet on iOS
|
|
54
|
+
*/
|
|
55
|
+
iosUrl?: string;
|
|
56
|
+
};
|
|
57
|
+
export type WalletDeepLinks = {
|
|
58
|
+
mobile?: {
|
|
59
|
+
native?: string;
|
|
60
|
+
universal?: string;
|
|
61
|
+
};
|
|
62
|
+
desktop?: {
|
|
63
|
+
native?: string;
|
|
64
|
+
universal?: string;
|
|
65
|
+
};
|
|
66
|
+
};
|
|
67
|
+
export type HardwareWallet = 'ledger';
|
|
68
|
+
/**
|
|
69
|
+
* @property id - A key that can be used to identify the wallet/connector, based on the wallet name
|
|
70
|
+
* @property name - The wallet name
|
|
71
|
+
* @property icon - The url or data for the wallet icon
|
|
72
|
+
* @property brandColor - The hex valye for the wallet brand color
|
|
73
|
+
* @property groupKey - Key used to group wallets together, for example, by chain
|
|
74
|
+
* @property inAppBrowserUrl - The url to open the wallet in the in-app browser
|
|
75
|
+
* @property deepLinks - The mobile deep links of the wallet
|
|
76
|
+
* @property downloadLinks - The ids to download the wallet in the different browsers and mobile stores
|
|
77
|
+
* @property walletLimitations - The limitations of the wallet in regards to methods and events
|
|
78
|
+
* @property rdns - The wallet rdns if it supports EIP-6963
|
|
79
|
+
*/
|
|
80
|
+
export type WalletMetadata = {
|
|
81
|
+
id: string;
|
|
82
|
+
name: string;
|
|
83
|
+
icon: string;
|
|
84
|
+
brandColor?: `#${string}`;
|
|
85
|
+
groupKey?: string;
|
|
86
|
+
inAppBrowserUrl?: string;
|
|
87
|
+
deepLinks?: WalletDeepLinks;
|
|
88
|
+
downloadLinks?: WalletDownloadLinks;
|
|
89
|
+
walletLimitations?: WalletLimitations;
|
|
90
|
+
supportedHardwareWallets?: HardwareWallet[];
|
|
91
|
+
rdns?: string;
|
|
92
|
+
};
|
|
93
|
+
export declare namespace WalletConnectorCore { }
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { WalletConnector } from '
|
|
1
|
+
import { WalletConnector } from '..';
|
|
2
2
|
import { AccountChangeEventHandler, ChainChangeEventHandler, DisconnectEventHandler } from '../types';
|
|
3
3
|
export declare const eventListenerHandlers: (walletConnector: WalletConnector) => {
|
|
4
4
|
handleAccountChange: AccountChangeEventHandler;
|
|
@@ -47,10 +47,10 @@ const chainsInfo = [
|
|
|
47
47
|
symbol: 'COSMOS',
|
|
48
48
|
},
|
|
49
49
|
{
|
|
50
|
-
blockchainName: '
|
|
51
|
-
displayName: '
|
|
52
|
-
name: '
|
|
53
|
-
symbol: '
|
|
50
|
+
blockchainName: 'Eclipse',
|
|
51
|
+
displayName: 'Eclipse',
|
|
52
|
+
name: 'eclipse',
|
|
53
|
+
symbol: 'ECLIPSE',
|
|
54
54
|
},
|
|
55
55
|
];
|
|
56
56
|
const chainOverrides = {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ChainInfo } from '
|
|
2
|
-
export type ChainName = 'algorand' | 'bitcoin' | 'evm' | 'flow' | 'solana' | 'starknet' | 'cosmos';
|
|
1
|
+
import { ChainInfo } from '../..';
|
|
2
|
+
export type ChainName = 'algorand' | 'eclipse' | 'bitcoin' | 'evm' | 'flow' | 'solana' | 'starknet' | 'cosmos';
|
|
3
3
|
export type ChainDisplayOverrides = Partial<Record<ChainName, {
|
|
4
4
|
displayName?: string;
|
|
5
5
|
}>>;
|
|
@@ -43,10 +43,10 @@ const chainsInfo = [
|
|
|
43
43
|
symbol: 'COSMOS',
|
|
44
44
|
},
|
|
45
45
|
{
|
|
46
|
-
blockchainName: '
|
|
47
|
-
displayName: '
|
|
48
|
-
name: '
|
|
49
|
-
symbol: '
|
|
46
|
+
blockchainName: 'Eclipse',
|
|
47
|
+
displayName: 'Eclipse',
|
|
48
|
+
name: 'eclipse',
|
|
49
|
+
symbol: 'ECLIPSE',
|
|
50
50
|
},
|
|
51
51
|
];
|
|
52
52
|
const chainOverrides = {
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { InternalWalletConnector } from '
|
|
1
|
+
import { InternalWalletConnector } from '..';
|
|
2
2
|
export declare const getWalletConnectorByKey: (wallets: InternalWalletConnector[], key: string) => InternalWalletConnector | null;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
|
|
6
|
+
var walletBook = require('@dynamic-labs/wallet-book');
|
|
7
|
+
|
|
8
|
+
const getWalletLinks = (downloadLinks) => {
|
|
9
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
10
|
+
const links = {
|
|
11
|
+
android: '',
|
|
12
|
+
brave: '',
|
|
13
|
+
chrome: '',
|
|
14
|
+
edge: '',
|
|
15
|
+
firefox: '',
|
|
16
|
+
ios: '',
|
|
17
|
+
};
|
|
18
|
+
if (!downloadLinks) {
|
|
19
|
+
return links;
|
|
20
|
+
}
|
|
21
|
+
links.brave = (_a = walletBook.renderTemplate('chromeUrl', downloadLinks.chromeId)) !== null && _a !== void 0 ? _a : '';
|
|
22
|
+
links.chrome = (_b = walletBook.renderTemplate('chromeUrl', downloadLinks.chromeId)) !== null && _b !== void 0 ? _b : '';
|
|
23
|
+
links.edge = (_c = walletBook.renderTemplate('edgeUrl', downloadLinks.edgeId)) !== null && _c !== void 0 ? _c : '';
|
|
24
|
+
links.firefox = (_d = walletBook.renderTemplate('firefoxUrl', downloadLinks.firefoxId)) !== null && _d !== void 0 ? _d : '';
|
|
25
|
+
links.ios =
|
|
26
|
+
(_f = (_e = walletBook.renderTemplate('iosUrl', downloadLinks.iosId)) !== null && _e !== void 0 ? _e : downloadLinks.iosUrl) !== null && _f !== void 0 ? _f : '';
|
|
27
|
+
links.android =
|
|
28
|
+
(_h = (_g = walletBook.renderTemplate('androidUrl', downloadLinks.androidId)) !== null && _g !== void 0 ? _g : downloadLinks.androidUrl) !== null && _h !== void 0 ? _h : '';
|
|
29
|
+
return links;
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
exports.getWalletLinks = getWalletLinks;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
import { renderTemplate } from '@dynamic-labs/wallet-book';
|
|
3
|
+
|
|
4
|
+
const getWalletLinks = (downloadLinks) => {
|
|
5
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
6
|
+
const links = {
|
|
7
|
+
android: '',
|
|
8
|
+
brave: '',
|
|
9
|
+
chrome: '',
|
|
10
|
+
edge: '',
|
|
11
|
+
firefox: '',
|
|
12
|
+
ios: '',
|
|
13
|
+
};
|
|
14
|
+
if (!downloadLinks) {
|
|
15
|
+
return links;
|
|
16
|
+
}
|
|
17
|
+
links.brave = (_a = renderTemplate('chromeUrl', downloadLinks.chromeId)) !== null && _a !== void 0 ? _a : '';
|
|
18
|
+
links.chrome = (_b = renderTemplate('chromeUrl', downloadLinks.chromeId)) !== null && _b !== void 0 ? _b : '';
|
|
19
|
+
links.edge = (_c = renderTemplate('edgeUrl', downloadLinks.edgeId)) !== null && _c !== void 0 ? _c : '';
|
|
20
|
+
links.firefox = (_d = renderTemplate('firefoxUrl', downloadLinks.firefoxId)) !== null && _d !== void 0 ? _d : '';
|
|
21
|
+
links.ios =
|
|
22
|
+
(_f = (_e = renderTemplate('iosUrl', downloadLinks.iosId)) !== null && _e !== void 0 ? _e : downloadLinks.iosUrl) !== null && _f !== void 0 ? _f : '';
|
|
23
|
+
links.android =
|
|
24
|
+
(_h = (_g = renderTemplate('androidUrl', downloadLinks.androidId)) !== null && _g !== void 0 ? _g : downloadLinks.androidUrl) !== null && _h !== void 0 ? _h : '';
|
|
25
|
+
return links;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
export { getWalletLinks };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { getWalletLinks } from './getWalletLinks';
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
|
|
6
|
+
const getMobileDeepLinks = (mobile) => {
|
|
7
|
+
if (!mobile) {
|
|
8
|
+
return;
|
|
9
|
+
}
|
|
10
|
+
return {
|
|
11
|
+
native: mobile.native,
|
|
12
|
+
universal: mobile.universal,
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
const getDesktopDeepLinks = (desktop) => {
|
|
16
|
+
if (!desktop) {
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
return {
|
|
20
|
+
native: desktop.native,
|
|
21
|
+
universal: desktop.universal,
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
const getDeepLinks = ({ mobile, desktop, }) => {
|
|
25
|
+
const mobileDeepLinks = getMobileDeepLinks(mobile);
|
|
26
|
+
const desktopDeepLinks = getDesktopDeepLinks(desktop);
|
|
27
|
+
if (!mobileDeepLinks && !desktopDeepLinks) {
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
return {
|
|
31
|
+
desktop: desktopDeepLinks,
|
|
32
|
+
mobile: mobileDeepLinks,
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
exports.getDeepLinks = getDeepLinks;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { WalletSchema } from '@dynamic-labs/wallet-book';
|
|
2
|
+
import { WalletDeepLinks } from '../../../types';
|
|
3
|
+
export declare const getDeepLinks: ({ mobile, desktop, }: {
|
|
4
|
+
mobile?: WalletSchema['mobile'];
|
|
5
|
+
desktop?: WalletSchema['desktop'];
|
|
6
|
+
}) => WalletDeepLinks | undefined;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
const getMobileDeepLinks = (mobile) => {
|
|
3
|
+
if (!mobile) {
|
|
4
|
+
return;
|
|
5
|
+
}
|
|
6
|
+
return {
|
|
7
|
+
native: mobile.native,
|
|
8
|
+
universal: mobile.universal,
|
|
9
|
+
};
|
|
10
|
+
};
|
|
11
|
+
const getDesktopDeepLinks = (desktop) => {
|
|
12
|
+
if (!desktop) {
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
return {
|
|
16
|
+
native: desktop.native,
|
|
17
|
+
universal: desktop.universal,
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
const getDeepLinks = ({ mobile, desktop, }) => {
|
|
21
|
+
const mobileDeepLinks = getMobileDeepLinks(mobile);
|
|
22
|
+
const desktopDeepLinks = getDesktopDeepLinks(desktop);
|
|
23
|
+
if (!mobileDeepLinks && !desktopDeepLinks) {
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
return {
|
|
27
|
+
desktop: desktopDeepLinks,
|
|
28
|
+
mobile: mobileDeepLinks,
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export { getDeepLinks };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './getDeepLinks';
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
|
|
6
|
+
const getMobileDownloadLinks = (mobile) => {
|
|
7
|
+
if (!mobile) {
|
|
8
|
+
return;
|
|
9
|
+
}
|
|
10
|
+
return {
|
|
11
|
+
androidId: mobile.androidId,
|
|
12
|
+
iosId: mobile.iosId,
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
const getDesktopDownloadLinks = (desktop) => {
|
|
16
|
+
if (!desktop) {
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
return {
|
|
20
|
+
chromeId: desktop.chromeId,
|
|
21
|
+
edgeId: desktop.edgeId,
|
|
22
|
+
firefoxId: desktop.firefoxId,
|
|
23
|
+
operaId: desktop.operaId,
|
|
24
|
+
safariId: desktop.safariId,
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
const getDownloadLinks = (wallet) => {
|
|
28
|
+
const mobileLinks = getMobileDownloadLinks(wallet.mobile);
|
|
29
|
+
const desktopLinks = getDesktopDownloadLinks(wallet.desktop);
|
|
30
|
+
if (!mobileLinks && !desktopLinks) {
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
return Object.assign(Object.assign({}, mobileLinks), desktopLinks);
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
exports.getDownloadLinks = getDownloadLinks;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
const getMobileDownloadLinks = (mobile) => {
|
|
3
|
+
if (!mobile) {
|
|
4
|
+
return;
|
|
5
|
+
}
|
|
6
|
+
return {
|
|
7
|
+
androidId: mobile.androidId,
|
|
8
|
+
iosId: mobile.iosId,
|
|
9
|
+
};
|
|
10
|
+
};
|
|
11
|
+
const getDesktopDownloadLinks = (desktop) => {
|
|
12
|
+
if (!desktop) {
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
return {
|
|
16
|
+
chromeId: desktop.chromeId,
|
|
17
|
+
edgeId: desktop.edgeId,
|
|
18
|
+
firefoxId: desktop.firefoxId,
|
|
19
|
+
operaId: desktop.operaId,
|
|
20
|
+
safariId: desktop.safariId,
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
const getDownloadLinks = (wallet) => {
|
|
24
|
+
const mobileLinks = getMobileDownloadLinks(wallet.mobile);
|
|
25
|
+
const desktopLinks = getDesktopDownloadLinks(wallet.desktop);
|
|
26
|
+
if (!mobileLinks && !desktopLinks) {
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
return Object.assign(Object.assign({}, mobileLinks), desktopLinks);
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export { getDownloadLinks };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './getDownloadLinks';
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
|
|
6
|
+
var walletBook = require('@dynamic-labs/wallet-book');
|
|
7
|
+
|
|
8
|
+
const getIconUrl = (spriteId) => {
|
|
9
|
+
if (!spriteId) {
|
|
10
|
+
return walletBook.renderTemplate('iconicUrl', 'defaultwallet');
|
|
11
|
+
}
|
|
12
|
+
return walletBook.renderTemplate('iconicUrl', spriteId);
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
exports.getIconUrl = getIconUrl;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const getIconUrl: (spriteId?: string) => string | undefined;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
import { renderTemplate } from '@dynamic-labs/wallet-book';
|
|
3
|
+
|
|
4
|
+
const getIconUrl = (spriteId) => {
|
|
5
|
+
if (!spriteId) {
|
|
6
|
+
return renderTemplate('iconicUrl', 'defaultwallet');
|
|
7
|
+
}
|
|
8
|
+
return renderTemplate('iconicUrl', spriteId);
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export { getIconUrl };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './getIconUrl';
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
|
|
6
|
+
const getValidHexColor = (color) => {
|
|
7
|
+
if (!color) {
|
|
8
|
+
return;
|
|
9
|
+
}
|
|
10
|
+
// Check if string starts with # and is followed by either 3 or 6 valid hex characters
|
|
11
|
+
const hexColorRegex = /^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/;
|
|
12
|
+
return hexColorRegex.test(color) ? color : undefined;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
exports.getValidHexColor = getValidHexColor;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const getValidHexColor: (color?: string) => `#${string}` | undefined;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
const getValidHexColor = (color) => {
|
|
3
|
+
if (!color) {
|
|
4
|
+
return;
|
|
5
|
+
}
|
|
6
|
+
// Check if string starts with # and is followed by either 3 or 6 valid hex characters
|
|
7
|
+
const hexColorRegex = /^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/;
|
|
8
|
+
return hexColorRegex.test(color) ? color : undefined;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export { getValidHexColor };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './getValidHexColor';
|
package/src/utils/getWalletMetadataFromWalletBook/getWalletLimitations/getWalletLimitations.cjs
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
|
|
6
|
+
const getWalletLimitations = (walletLimitations) => {
|
|
7
|
+
if (!(walletLimitations === null || walletLimitations === void 0 ? void 0 : walletLimitations.browserExtension)) {
|
|
8
|
+
return;
|
|
9
|
+
}
|
|
10
|
+
const { unsupportedEvents, unsupportedMethods } = walletLimitations.browserExtension;
|
|
11
|
+
return {
|
|
12
|
+
desktop: {
|
|
13
|
+
unsupportedEvents: unsupportedEvents,
|
|
14
|
+
unsupportedMethods: unsupportedMethods,
|
|
15
|
+
},
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
exports.getWalletLimitations = getWalletLimitations;
|
package/src/utils/getWalletMetadataFromWalletBook/getWalletLimitations/getWalletLimitations.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
const getWalletLimitations = (walletLimitations) => {
|
|
3
|
+
if (!(walletLimitations === null || walletLimitations === void 0 ? void 0 : walletLimitations.browserExtension)) {
|
|
4
|
+
return;
|
|
5
|
+
}
|
|
6
|
+
const { unsupportedEvents, unsupportedMethods } = walletLimitations.browserExtension;
|
|
7
|
+
return {
|
|
8
|
+
desktop: {
|
|
9
|
+
unsupportedEvents: unsupportedEvents,
|
|
10
|
+
unsupportedMethods: unsupportedMethods,
|
|
11
|
+
},
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export { getWalletLimitations };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './getWalletLimitations';
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
|
|
6
|
+
var walletBook = require('@dynamic-labs/wallet-book');
|
|
7
|
+
var logger = require('../logger.cjs');
|
|
8
|
+
require('@dynamic-labs/utils');
|
|
9
|
+
require('../../../_virtual/_tslib.cjs');
|
|
10
|
+
var getIconUrl = require('./getIconUrl/getIconUrl.cjs');
|
|
11
|
+
var getValidHexColor = require('./getValidHexColor/getValidHexColor.cjs');
|
|
12
|
+
var getDeepLinks = require('./getDeepLinks/getDeepLinks.cjs');
|
|
13
|
+
var getDownloadLinks = require('./getDownloadLinks/getDownloadLinks.cjs');
|
|
14
|
+
var getWalletLimitations = require('./getWalletLimitations/getWalletLimitations.cjs');
|
|
15
|
+
|
|
16
|
+
const getWalletMetadataFromWalletBook = ({ walletKey, walletBookWallet, walletBook: walletBook$1, walletFallback, }) => {
|
|
17
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
18
|
+
if (!walletBook$1 && !walletFallback) {
|
|
19
|
+
logger.logger.warn('Wallet book is required');
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
const wallet = walletBookWallet !== null && walletBookWallet !== void 0 ? walletBookWallet : walletBook.getWalletBookWallet(walletBook$1, walletKey, walletFallback);
|
|
23
|
+
// if no walletBookWallet is provided and no wallet is found in the wallet book, throw an error
|
|
24
|
+
if (!wallet) {
|
|
25
|
+
logger.logger.warn('Wallet not found in wallet book');
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
return {
|
|
29
|
+
brandColor: getValidHexColor.getValidHexColor((_a = wallet === null || wallet === void 0 ? void 0 : wallet.brand) === null || _a === void 0 ? void 0 : _a.primaryColor),
|
|
30
|
+
deepLinks: getDeepLinks.getDeepLinks({
|
|
31
|
+
desktop: wallet === null || wallet === void 0 ? void 0 : wallet.desktop,
|
|
32
|
+
mobile: wallet === null || wallet === void 0 ? void 0 : wallet.mobile,
|
|
33
|
+
}),
|
|
34
|
+
downloadLinks: getDownloadLinks.getDownloadLinks(wallet),
|
|
35
|
+
groupKey: (_b = wallet === null || wallet === void 0 ? void 0 : wallet.chainGroup) !== null && _b !== void 0 ? _b : wallet === null || wallet === void 0 ? void 0 : wallet.walletGroup,
|
|
36
|
+
icon: (_d = getIconUrl.getIconUrl((_c = wallet === null || wallet === void 0 ? void 0 : wallet.brand) === null || _c === void 0 ? void 0 : _c.spriteId)) !== null && _d !== void 0 ? _d : '',
|
|
37
|
+
id: walletKey,
|
|
38
|
+
inAppBrowserUrl: (_f = (_e = wallet.mobile) === null || _e === void 0 ? void 0 : _e.inAppBrowser) !== null && _f !== void 0 ? _f : undefined,
|
|
39
|
+
name: wallet.name,
|
|
40
|
+
rdns: (_g = wallet.eip6963Config) === null || _g === void 0 ? void 0 : _g.rdns,
|
|
41
|
+
supportedHardwareWallets: wallet.hardwareWallets,
|
|
42
|
+
walletLimitations: getWalletLimitations.getWalletLimitations(wallet.walletLimitations),
|
|
43
|
+
};
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
exports.getWalletMetadataFromWalletBook = getWalletMetadataFromWalletBook;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { WalletBookSchema, WalletSchema } from '@dynamic-labs/wallet-book';
|
|
2
|
+
import { WalletMetadata } from '../../types';
|
|
3
|
+
type GetWalletMetadataFromWalletBookOpts = {
|
|
4
|
+
walletKey: string;
|
|
5
|
+
walletBookWallet?: WalletSchema;
|
|
6
|
+
walletBook?: WalletBookSchema;
|
|
7
|
+
walletFallback?: WalletSchema;
|
|
8
|
+
};
|
|
9
|
+
export declare const getWalletMetadataFromWalletBook: ({ walletKey, walletBookWallet, walletBook, walletFallback, }: GetWalletMetadataFromWalletBookOpts) => WalletMetadata | undefined;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
import { getWalletBookWallet } from '@dynamic-labs/wallet-book';
|
|
3
|
+
import { logger } from '../logger.js';
|
|
4
|
+
import '@dynamic-labs/utils';
|
|
5
|
+
import '../../../_virtual/_tslib.js';
|
|
6
|
+
import { getIconUrl } from './getIconUrl/getIconUrl.js';
|
|
7
|
+
import { getValidHexColor } from './getValidHexColor/getValidHexColor.js';
|
|
8
|
+
import { getDeepLinks } from './getDeepLinks/getDeepLinks.js';
|
|
9
|
+
import { getDownloadLinks } from './getDownloadLinks/getDownloadLinks.js';
|
|
10
|
+
import { getWalletLimitations } from './getWalletLimitations/getWalletLimitations.js';
|
|
11
|
+
|
|
12
|
+
const getWalletMetadataFromWalletBook = ({ walletKey, walletBookWallet, walletBook, walletFallback, }) => {
|
|
13
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
14
|
+
if (!walletBook && !walletFallback) {
|
|
15
|
+
logger.warn('Wallet book is required');
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
const wallet = walletBookWallet !== null && walletBookWallet !== void 0 ? walletBookWallet : getWalletBookWallet(walletBook, walletKey, walletFallback);
|
|
19
|
+
// if no walletBookWallet is provided and no wallet is found in the wallet book, throw an error
|
|
20
|
+
if (!wallet) {
|
|
21
|
+
logger.warn('Wallet not found in wallet book');
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
return {
|
|
25
|
+
brandColor: getValidHexColor((_a = wallet === null || wallet === void 0 ? void 0 : wallet.brand) === null || _a === void 0 ? void 0 : _a.primaryColor),
|
|
26
|
+
deepLinks: getDeepLinks({
|
|
27
|
+
desktop: wallet === null || wallet === void 0 ? void 0 : wallet.desktop,
|
|
28
|
+
mobile: wallet === null || wallet === void 0 ? void 0 : wallet.mobile,
|
|
29
|
+
}),
|
|
30
|
+
downloadLinks: getDownloadLinks(wallet),
|
|
31
|
+
groupKey: (_b = wallet === null || wallet === void 0 ? void 0 : wallet.chainGroup) !== null && _b !== void 0 ? _b : wallet === null || wallet === void 0 ? void 0 : wallet.walletGroup,
|
|
32
|
+
icon: (_d = getIconUrl((_c = wallet === null || wallet === void 0 ? void 0 : wallet.brand) === null || _c === void 0 ? void 0 : _c.spriteId)) !== null && _d !== void 0 ? _d : '',
|
|
33
|
+
id: walletKey,
|
|
34
|
+
inAppBrowserUrl: (_f = (_e = wallet.mobile) === null || _e === void 0 ? void 0 : _e.inAppBrowser) !== null && _f !== void 0 ? _f : undefined,
|
|
35
|
+
name: wallet.name,
|
|
36
|
+
rdns: (_g = wallet.eip6963Config) === null || _g === void 0 ? void 0 : _g.rdns,
|
|
37
|
+
supportedHardwareWallets: wallet.hardwareWallets,
|
|
38
|
+
walletLimitations: getWalletLimitations(wallet.walletLimitations),
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
export { getWalletMetadataFromWalletBook };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './getWalletMetadataFromWalletBook';
|
package/src/utils/index.d.ts
CHANGED
|
@@ -26,3 +26,7 @@ export * from './isWalletConnectConnector';
|
|
|
26
26
|
export * from './isSendBalanceWalletConnector';
|
|
27
27
|
export * from './isSessionKeyCompatible';
|
|
28
28
|
export * from './getMobileExperience';
|
|
29
|
+
export * from './getWalletMetadataFromWalletBook';
|
|
30
|
+
export * from './isConnectorMethodSupported';
|
|
31
|
+
export * from './isConnectorEventSupported';
|
|
32
|
+
export * from './getWalletLinks';
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { IAccountAbstractionWalletConnector } from '
|
|
1
|
+
import { IAccountAbstractionWalletConnector } from '../..';
|
|
2
2
|
export declare const isAccountAbstractionConnector: (walletConnector: IAccountAbstractionWalletConnector | unknown) => walletConnector is IAccountAbstractionWalletConnector;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { IBitcoinWalletConnector, WalletConnector } from '
|
|
1
|
+
import { IBitcoinWalletConnector, WalletConnector } from '../..';
|
|
2
2
|
export declare const isBitcoinConnector: (connector: WalletConnector | IBitcoinWalletConnector) => connector is IBitcoinWalletConnector;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { WalletConnector } from '
|
|
1
|
+
import { WalletConnector } from '../..';
|
|
2
2
|
export declare const isBloctoConnector: (connector: WalletConnector) => boolean;
|