@dynamic-labs/wallet-book 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/CHANGELOG.md +3746 -0
- package/LICENSE +21 -0
- package/README.md +142 -0
- package/_virtual/_tslib.cjs +49 -0
- package/_virtual/_tslib.js +44 -0
- package/package.json +38 -0
- package/src/build/index.d.ts +76 -0
- package/src/build/sources/firstParty/index.d.ts +2 -0
- package/src/build/sources/index.d.ts +4 -0
- package/src/build/sources/walletConnect/index.d.ts +128 -0
- package/src/build/sources/walletConnect/preprocessors.d.ts +14 -0
- package/src/build/sources/walletConnectOverrides/index.d.ts +197 -0
- package/src/build/sources/walletGroups/index.d.ts +2 -0
- package/src/components/BrandIcon.cjs +27 -0
- package/src/components/BrandIcon.d.ts +8 -0
- package/src/components/BrandIcon.js +23 -0
- package/src/components/WalletBookContext.cjs +14 -0
- package/src/components/WalletBookContext.d.ts +9 -0
- package/src/components/WalletBookContext.js +9 -0
- package/src/components/WalletIcon.cjs +34 -0
- package/src/components/WalletIcon.d.ts +8 -0
- package/src/components/WalletIcon.js +30 -0
- package/src/components/index.d.ts +3 -0
- package/src/helpers/findWalletBookWallet.cjs +18 -0
- package/src/helpers/findWalletBookWallet.d.ts +70 -0
- package/src/helpers/findWalletBookWallet.js +14 -0
- package/src/helpers/findWalletGroup.cjs +19 -0
- package/src/helpers/findWalletGroup.d.ts +18 -0
- package/src/helpers/findWalletGroup.js +15 -0
- package/src/helpers/findWalletGroupOverride.cjs +14 -0
- package/src/helpers/findWalletGroupOverride.d.ts +3 -0
- package/src/helpers/findWalletGroupOverride.js +10 -0
- package/src/helpers/getBrandIconUrl.cjs +15 -0
- package/src/helpers/getBrandIconUrl.d.ts +2 -0
- package/src/helpers/getBrandIconUrl.js +11 -0
- package/src/helpers/getWalletBookCdnUrl.cjs +14 -0
- package/src/helpers/getWalletBookCdnUrl.d.ts +1 -0
- package/src/helpers/getWalletBookCdnUrl.js +10 -0
- package/src/helpers/getWalletBookWallet.cjs +17 -0
- package/src/helpers/getWalletBookWallet.d.ts +2 -0
- package/src/helpers/getWalletBookWallet.js +13 -0
- package/src/helpers/getWalletGroup.cjs +13 -0
- package/src/helpers/getWalletGroup.d.ts +3 -0
- package/src/helpers/getWalletGroup.js +9 -0
- package/src/helpers/getWalletIconUrl.cjs +34 -0
- package/src/helpers/getWalletIconUrl.d.ts +3 -0
- package/src/helpers/getWalletIconUrl.js +29 -0
- package/src/helpers/getWalletLinks.cjs +34 -0
- package/src/helpers/getWalletLinks.d.ts +10 -0
- package/src/helpers/getWalletLinks.js +30 -0
- package/src/helpers/getWalletPrimaryColor.cjs +14 -0
- package/src/helpers/getWalletPrimaryColor.d.ts +2 -0
- package/src/helpers/getWalletPrimaryColor.js +10 -0
- package/src/helpers/index.d.ts +14 -0
- package/src/helpers/isWalletEventSupported.cjs +8 -0
- package/src/helpers/isWalletEventSupported.d.ts +2 -0
- package/src/helpers/isWalletEventSupported.js +4 -0
- package/src/helpers/isWalletMethodSupported.cjs +8 -0
- package/src/helpers/isWalletMethodSupported.d.ts +2 -0
- package/src/helpers/isWalletMethodSupported.js +4 -0
- package/src/helpers/logger.cjs +10 -0
- package/src/helpers/logger.d.ts +2 -0
- package/src/helpers/logger.js +6 -0
- package/src/helpers/renderTemplate.cjs +23 -0
- package/src/helpers/renderTemplate.d.ts +12 -0
- package/src/helpers/renderTemplate.js +19 -0
- package/src/hooks/index.d.ts +2 -0
- package/src/hooks/useWalletBookCdn.cjs +51 -0
- package/src/hooks/useWalletBookCdn.d.ts +88 -0
- package/src/hooks/useWalletBookCdn.js +47 -0
- package/src/hooks/useWalletBookContext.cjs +24 -0
- package/src/hooks/useWalletBookContext.d.ts +1 -0
- package/src/hooks/useWalletBookContext.js +20 -0
- package/src/index.cjs +44 -0
- package/src/index.d.ts +18 -0
- package/src/index.js +20 -0
- package/src/schemas/index.d.ts +3 -0
- package/src/schemas/utils/filterEmptyObject.cjs +13 -0
- package/src/schemas/utils/filterEmptyObject.d.ts +6 -0
- package/src/schemas/utils/filterEmptyObject.js +9 -0
- package/src/schemas/utils/nonEmptyString.cjs +13 -0
- package/src/schemas/utils/nonEmptyString.d.ts +5 -0
- package/src/schemas/utils/nonEmptyString.js +9 -0
- package/src/schemas/utils/nonEmptyStringArray.cjs +13 -0
- package/src/schemas/utils/nonEmptyStringArray.d.ts +5 -0
- package/src/schemas/utils/nonEmptyStringArray.js +9 -0
- package/src/schemas/utils/processWalletConnectNativeUrl.d.ts +1 -0
- package/src/schemas/utils/sortKeys.d.ts +5 -0
- package/src/schemas/utils/transformAndroidId.cjs +24 -0
- package/src/schemas/utils/transformAndroidId.d.ts +1 -0
- package/src/schemas/utils/transformAndroidId.js +20 -0
- package/src/schemas/utils/transformChromeExtensionId.cjs +21 -0
- package/src/schemas/utils/transformChromeExtensionId.d.ts +1 -0
- package/src/schemas/utils/transformChromeExtensionId.js +17 -0
- package/src/schemas/utils/transformEdgeExtensionId.cjs +21 -0
- package/src/schemas/utils/transformEdgeExtensionId.d.ts +1 -0
- package/src/schemas/utils/transformEdgeExtensionId.js +17 -0
- package/src/schemas/utils/transformFirefoxExtensionId.cjs +21 -0
- package/src/schemas/utils/transformFirefoxExtensionId.d.ts +1 -0
- package/src/schemas/utils/transformFirefoxExtensionId.js +17 -0
- package/src/schemas/utils/transformIosId.cjs +28 -0
- package/src/schemas/utils/transformIosId.d.ts +1 -0
- package/src/schemas/utils/transformIosId.js +24 -0
- package/src/schemas/walletBookSchema.cjs +17 -0
- package/src/schemas/walletBookSchema.d.ts +1369 -0
- package/src/schemas/walletBookSchema.js +13 -0
- package/src/schemas/walletConnectSourceSchema.cjs +78 -0
- package/src/schemas/walletConnectSourceSchema.d.ts +516 -0
- package/src/schemas/walletConnectSourceSchema.js +74 -0
- package/src/schemas/walletGroup.cjs +27 -0
- package/src/schemas/walletGroup.d.ts +113 -0
- package/src/schemas/walletGroup.js +23 -0
- package/src/schemas/walletSchema.cjs +141 -0
- package/src/schemas/walletSchema.d.ts +614 -0
- package/src/schemas/walletSchema.js +136 -0
- package/wallet-book-fallbacks.cjs +1082 -0
- package/wallet-book-fallbacks.js +1076 -0
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
export declare const WALLET_CONNECT_ENTRIES_TO_REMOVE: string[];
|
|
2
|
+
export declare const applyOverrides: (sourceData: any, overrides?: any) => void;
|
|
3
|
+
export declare const walletConnectOverrides: {
|
|
4
|
+
coin98: {
|
|
5
|
+
group: {
|
|
6
|
+
action: string;
|
|
7
|
+
value: string;
|
|
8
|
+
};
|
|
9
|
+
};
|
|
10
|
+
cryptocom: {
|
|
11
|
+
eip6963Config: {
|
|
12
|
+
action: string;
|
|
13
|
+
value: {
|
|
14
|
+
rdns: string;
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
mobile: {
|
|
18
|
+
action: string;
|
|
19
|
+
value: null;
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
exodus: {
|
|
23
|
+
group: {
|
|
24
|
+
action: string;
|
|
25
|
+
value: string;
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
exodusevm: {
|
|
29
|
+
chains: {
|
|
30
|
+
action: string;
|
|
31
|
+
value: string[];
|
|
32
|
+
};
|
|
33
|
+
mobile: {
|
|
34
|
+
action: string;
|
|
35
|
+
value: {
|
|
36
|
+
androidId: string;
|
|
37
|
+
iosId: string;
|
|
38
|
+
native: string;
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
walletConnect: {
|
|
42
|
+
action: string;
|
|
43
|
+
value: {
|
|
44
|
+
sdks: string[];
|
|
45
|
+
};
|
|
46
|
+
};
|
|
47
|
+
};
|
|
48
|
+
ledger: {
|
|
49
|
+
mobile: {
|
|
50
|
+
action: string;
|
|
51
|
+
value: {
|
|
52
|
+
androidId: string;
|
|
53
|
+
iosId: string;
|
|
54
|
+
native: string;
|
|
55
|
+
universal: string;
|
|
56
|
+
};
|
|
57
|
+
};
|
|
58
|
+
switchNetworkOnlyFromWallet: {
|
|
59
|
+
action: string;
|
|
60
|
+
value: boolean;
|
|
61
|
+
};
|
|
62
|
+
};
|
|
63
|
+
magiceden: {
|
|
64
|
+
walletConnect: {
|
|
65
|
+
sdks: {
|
|
66
|
+
action: string;
|
|
67
|
+
value: null;
|
|
68
|
+
};
|
|
69
|
+
};
|
|
70
|
+
};
|
|
71
|
+
mathwallet: {
|
|
72
|
+
group: {
|
|
73
|
+
action: string;
|
|
74
|
+
value: string;
|
|
75
|
+
};
|
|
76
|
+
};
|
|
77
|
+
metamask: {
|
|
78
|
+
walletConnect: {
|
|
79
|
+
sdks: {
|
|
80
|
+
action: string;
|
|
81
|
+
value: string[];
|
|
82
|
+
};
|
|
83
|
+
};
|
|
84
|
+
};
|
|
85
|
+
okxwallet: {
|
|
86
|
+
desktop: {
|
|
87
|
+
action: string;
|
|
88
|
+
value: {
|
|
89
|
+
chromeId: string;
|
|
90
|
+
};
|
|
91
|
+
};
|
|
92
|
+
walletConnect: {
|
|
93
|
+
sdks: {
|
|
94
|
+
action: string;
|
|
95
|
+
value: string[];
|
|
96
|
+
};
|
|
97
|
+
};
|
|
98
|
+
};
|
|
99
|
+
rabby: {
|
|
100
|
+
brand: {
|
|
101
|
+
spriteId: {
|
|
102
|
+
action: string;
|
|
103
|
+
value: string;
|
|
104
|
+
};
|
|
105
|
+
};
|
|
106
|
+
};
|
|
107
|
+
rainbow: {
|
|
108
|
+
brand: {
|
|
109
|
+
spriteId: {
|
|
110
|
+
action: string;
|
|
111
|
+
value: string;
|
|
112
|
+
};
|
|
113
|
+
};
|
|
114
|
+
};
|
|
115
|
+
safe: {
|
|
116
|
+
mobile: {
|
|
117
|
+
native: {
|
|
118
|
+
action: string;
|
|
119
|
+
value: null;
|
|
120
|
+
};
|
|
121
|
+
universal: {
|
|
122
|
+
action: string;
|
|
123
|
+
value: null;
|
|
124
|
+
};
|
|
125
|
+
};
|
|
126
|
+
};
|
|
127
|
+
safepal: {
|
|
128
|
+
eip6963Config: {
|
|
129
|
+
action: string;
|
|
130
|
+
value: {
|
|
131
|
+
rdns: string;
|
|
132
|
+
};
|
|
133
|
+
};
|
|
134
|
+
switchNetworkOnlyFromWallet: {
|
|
135
|
+
action: string;
|
|
136
|
+
value: boolean;
|
|
137
|
+
};
|
|
138
|
+
};
|
|
139
|
+
sequence: {
|
|
140
|
+
eip6963Config: {
|
|
141
|
+
action: string;
|
|
142
|
+
value: {
|
|
143
|
+
rdns: string;
|
|
144
|
+
};
|
|
145
|
+
};
|
|
146
|
+
};
|
|
147
|
+
trust: {
|
|
148
|
+
chains: {
|
|
149
|
+
action: string;
|
|
150
|
+
value: string[];
|
|
151
|
+
};
|
|
152
|
+
};
|
|
153
|
+
uniswap: {
|
|
154
|
+
eip6963Config: {
|
|
155
|
+
action: string;
|
|
156
|
+
value: {
|
|
157
|
+
rdns: string;
|
|
158
|
+
};
|
|
159
|
+
};
|
|
160
|
+
injectedConfig: {
|
|
161
|
+
action: string;
|
|
162
|
+
value: {
|
|
163
|
+
chain: string;
|
|
164
|
+
extensionLocators: never[];
|
|
165
|
+
windowLocations: never[];
|
|
166
|
+
}[];
|
|
167
|
+
};
|
|
168
|
+
name: {
|
|
169
|
+
action: string;
|
|
170
|
+
value: string;
|
|
171
|
+
};
|
|
172
|
+
};
|
|
173
|
+
wallet: {
|
|
174
|
+
action: string;
|
|
175
|
+
value: string;
|
|
176
|
+
};
|
|
177
|
+
zengo: {
|
|
178
|
+
brand: {
|
|
179
|
+
primaryColor: {
|
|
180
|
+
action: string;
|
|
181
|
+
value: string;
|
|
182
|
+
};
|
|
183
|
+
spriteId: {
|
|
184
|
+
action: string;
|
|
185
|
+
value: string;
|
|
186
|
+
};
|
|
187
|
+
};
|
|
188
|
+
};
|
|
189
|
+
zerion: {
|
|
190
|
+
brand: {
|
|
191
|
+
primaryColor: {
|
|
192
|
+
action: string;
|
|
193
|
+
value: string;
|
|
194
|
+
};
|
|
195
|
+
};
|
|
196
|
+
};
|
|
197
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
|
|
6
|
+
var _tslib = require('../../_virtual/_tslib.cjs');
|
|
7
|
+
var react = require('react');
|
|
8
|
+
var getWalletIconUrl = require('../helpers/getWalletIconUrl.cjs');
|
|
9
|
+
require('../helpers/renderTemplate.cjs');
|
|
10
|
+
require('../helpers/logger.cjs');
|
|
11
|
+
var getBrandIconUrl = require('../helpers/getBrandIconUrl.cjs');
|
|
12
|
+
|
|
13
|
+
const BrandIcon = (_a) => {
|
|
14
|
+
var { brand, walletKey } = _a, props = _tslib.__rest(_a, ["brand", "walletKey"]);
|
|
15
|
+
const [imgError, setImgError] = react.useState(false);
|
|
16
|
+
const walletIconUrl = getBrandIconUrl.getBrandIconUrl(brand);
|
|
17
|
+
const defaultWalletIconUrl = getWalletIconUrl.getDefaultWalletIconUrl();
|
|
18
|
+
if (!walletIconUrl) {
|
|
19
|
+
return react.createElement(react.Fragment, {});
|
|
20
|
+
}
|
|
21
|
+
const onError = () => {
|
|
22
|
+
setImgError(true);
|
|
23
|
+
};
|
|
24
|
+
return react.createElement('img', Object.assign(Object.assign({ 'data-testid': `wallet-icon-${walletKey}` }, props), { alt: brand.alt, onError: onError, src: imgError ? defaultWalletIconUrl : walletIconUrl }));
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
exports.BrandIcon = BrandIcon;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { FC, ImgHTMLAttributes } from 'react';
|
|
2
|
+
import { WalletBrand } from '../schemas';
|
|
3
|
+
type BrandIconProps = {
|
|
4
|
+
walletKey: string;
|
|
5
|
+
brand: WalletBrand;
|
|
6
|
+
} & ImgHTMLAttributes<HTMLImageElement>;
|
|
7
|
+
export declare const BrandIcon: FC<BrandIconProps>;
|
|
8
|
+
export {};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
import { __rest } from '../../_virtual/_tslib.js';
|
|
3
|
+
import { useState, createElement, Fragment } from 'react';
|
|
4
|
+
import { getDefaultWalletIconUrl } from '../helpers/getWalletIconUrl.js';
|
|
5
|
+
import '../helpers/renderTemplate.js';
|
|
6
|
+
import '../helpers/logger.js';
|
|
7
|
+
import { getBrandIconUrl } from '../helpers/getBrandIconUrl.js';
|
|
8
|
+
|
|
9
|
+
const BrandIcon = (_a) => {
|
|
10
|
+
var { brand, walletKey } = _a, props = __rest(_a, ["brand", "walletKey"]);
|
|
11
|
+
const [imgError, setImgError] = useState(false);
|
|
12
|
+
const walletIconUrl = getBrandIconUrl(brand);
|
|
13
|
+
const defaultWalletIconUrl = getDefaultWalletIconUrl();
|
|
14
|
+
if (!walletIconUrl) {
|
|
15
|
+
return createElement(Fragment, {});
|
|
16
|
+
}
|
|
17
|
+
const onError = () => {
|
|
18
|
+
setImgError(true);
|
|
19
|
+
};
|
|
20
|
+
return createElement('img', Object.assign(Object.assign({ 'data-testid': `wallet-icon-${walletKey}` }, props), { alt: brand.alt, onError: onError, src: imgError ? defaultWalletIconUrl : walletIconUrl }));
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export { BrandIcon };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
|
|
6
|
+
var react = require('react');
|
|
7
|
+
|
|
8
|
+
const WalletBookContext = react.createContext({});
|
|
9
|
+
const WalletBookContextProvider = ({ walletBook, children, }) => react.createElement(WalletBookContext.Provider, {
|
|
10
|
+
value: { walletBook },
|
|
11
|
+
}, children);
|
|
12
|
+
|
|
13
|
+
exports.WalletBookContext = WalletBookContext;
|
|
14
|
+
exports.WalletBookContextProvider = WalletBookContextProvider;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { WalletBookSchema } from '../schemas';
|
|
2
|
+
export type IWalletBookContext = {
|
|
3
|
+
walletBook: WalletBookSchema;
|
|
4
|
+
};
|
|
5
|
+
export declare const WalletBookContext: import("react").Context<IWalletBookContext>;
|
|
6
|
+
export declare const WalletBookContextProvider: ({ walletBook, children, }: {
|
|
7
|
+
walletBook: WalletBookSchema;
|
|
8
|
+
children: React.ReactNode;
|
|
9
|
+
}) => import("react").FunctionComponentElement<import("react").ProviderProps<IWalletBookContext>>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
import { createContext, createElement } from 'react';
|
|
3
|
+
|
|
4
|
+
const WalletBookContext = createContext({});
|
|
5
|
+
const WalletBookContextProvider = ({ walletBook, children, }) => createElement(WalletBookContext.Provider, {
|
|
6
|
+
value: { walletBook },
|
|
7
|
+
}, children);
|
|
8
|
+
|
|
9
|
+
export { WalletBookContext, WalletBookContextProvider };
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
|
|
6
|
+
var _tslib = require('../../_virtual/_tslib.cjs');
|
|
7
|
+
var react = require('react');
|
|
8
|
+
var getWalletIconUrl = require('../helpers/getWalletIconUrl.cjs');
|
|
9
|
+
var findWalletBookWallet = require('../helpers/findWalletBookWallet.cjs');
|
|
10
|
+
require('../helpers/renderTemplate.cjs');
|
|
11
|
+
require('../helpers/logger.cjs');
|
|
12
|
+
require('@dynamic-labs/utils');
|
|
13
|
+
require('../schemas/walletConnectSourceSchema.cjs');
|
|
14
|
+
require('../schemas/walletBookSchema.cjs');
|
|
15
|
+
require('../schemas/walletSchema.cjs');
|
|
16
|
+
var useWalletBookContext = require('../hooks/useWalletBookContext.cjs');
|
|
17
|
+
|
|
18
|
+
const WalletIcon = (_a) => {
|
|
19
|
+
var { walletKey, children } = _a, props = _tslib.__rest(_a, ["walletKey", "children"]);
|
|
20
|
+
const { walletBook } = useWalletBookContext.useWalletBookContext();
|
|
21
|
+
const walletData = findWalletBookWallet.findWalletBookWallet(walletBook, walletKey);
|
|
22
|
+
const [imgError, setImgError] = react.useState(false);
|
|
23
|
+
const walletIconUrl = getWalletIconUrl.getWalletIconUrl(walletBook, walletKey);
|
|
24
|
+
const defaultWalletIconUrl = getWalletIconUrl.getDefaultWalletIconUrl();
|
|
25
|
+
if (!walletData || !walletData.brand || !walletIconUrl) {
|
|
26
|
+
return react.createElement(react.Fragment, {}, children);
|
|
27
|
+
}
|
|
28
|
+
const onError = () => {
|
|
29
|
+
setImgError(true);
|
|
30
|
+
};
|
|
31
|
+
return react.createElement('img', Object.assign(Object.assign({ 'data-testid': `wallet-icon-${walletKey}` }, props), { alt: walletData.brand.alt, onError: onError, src: imgError ? defaultWalletIconUrl : walletIconUrl }), children);
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
exports.WalletIcon = WalletIcon;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import React, { FC, ReactNode } from 'react';
|
|
2
|
+
type WalletIconProps = React.DetailedHTMLProps<React.ImgHTMLAttributes<HTMLImageElement>, HTMLImageElement> & {
|
|
3
|
+
walletKey: string | undefined;
|
|
4
|
+
} & {
|
|
5
|
+
children?: ReactNode | any;
|
|
6
|
+
};
|
|
7
|
+
export declare const WalletIcon: FC<WalletIconProps>;
|
|
8
|
+
export {};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
import { __rest } from '../../_virtual/_tslib.js';
|
|
3
|
+
import { useState, createElement, Fragment } from 'react';
|
|
4
|
+
import { getWalletIconUrl, getDefaultWalletIconUrl } from '../helpers/getWalletIconUrl.js';
|
|
5
|
+
import { findWalletBookWallet } from '../helpers/findWalletBookWallet.js';
|
|
6
|
+
import '../helpers/renderTemplate.js';
|
|
7
|
+
import '../helpers/logger.js';
|
|
8
|
+
import '@dynamic-labs/utils';
|
|
9
|
+
import '../schemas/walletConnectSourceSchema.js';
|
|
10
|
+
import '../schemas/walletBookSchema.js';
|
|
11
|
+
import '../schemas/walletSchema.js';
|
|
12
|
+
import { useWalletBookContext } from '../hooks/useWalletBookContext.js';
|
|
13
|
+
|
|
14
|
+
const WalletIcon = (_a) => {
|
|
15
|
+
var { walletKey, children } = _a, props = __rest(_a, ["walletKey", "children"]);
|
|
16
|
+
const { walletBook } = useWalletBookContext();
|
|
17
|
+
const walletData = findWalletBookWallet(walletBook, walletKey);
|
|
18
|
+
const [imgError, setImgError] = useState(false);
|
|
19
|
+
const walletIconUrl = getWalletIconUrl(walletBook, walletKey);
|
|
20
|
+
const defaultWalletIconUrl = getDefaultWalletIconUrl();
|
|
21
|
+
if (!walletData || !walletData.brand || !walletIconUrl) {
|
|
22
|
+
return createElement(Fragment, {}, children);
|
|
23
|
+
}
|
|
24
|
+
const onError = () => {
|
|
25
|
+
setImgError(true);
|
|
26
|
+
};
|
|
27
|
+
return createElement('img', Object.assign(Object.assign({ 'data-testid': `wallet-icon-${walletKey}` }, props), { alt: walletData.brand.alt, onError: onError, src: imgError ? defaultWalletIconUrl : walletIconUrl }), children);
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
export { WalletIcon };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
|
|
6
|
+
var getWalletBookWallet = require('./getWalletBookWallet.cjs');
|
|
7
|
+
|
|
8
|
+
const findWalletBookWallet = (walletBook, walletKey) => {
|
|
9
|
+
try {
|
|
10
|
+
const walletData = getWalletBookWallet.getWalletBookWallet(walletBook, walletKey);
|
|
11
|
+
return walletData;
|
|
12
|
+
}
|
|
13
|
+
catch (err) {
|
|
14
|
+
return undefined;
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
exports.findWalletBookWallet = findWalletBookWallet;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { WalletBookSchema } from '../schemas';
|
|
2
|
+
export declare const findWalletBookWallet: (walletBook: WalletBookSchema, walletKey: string | undefined) => {
|
|
3
|
+
name: string;
|
|
4
|
+
brand?: {
|
|
5
|
+
alt?: string | undefined;
|
|
6
|
+
primaryColor?: string | undefined;
|
|
7
|
+
spriteId?: string | undefined;
|
|
8
|
+
} | undefined;
|
|
9
|
+
chainGroup?: string | undefined;
|
|
10
|
+
chains?: string[] | undefined;
|
|
11
|
+
desktop?: {
|
|
12
|
+
chromeId?: string | undefined;
|
|
13
|
+
edgeId?: string | undefined;
|
|
14
|
+
firefoxId?: string | undefined;
|
|
15
|
+
native?: string | undefined;
|
|
16
|
+
operaId?: string | undefined;
|
|
17
|
+
safariId?: string | undefined;
|
|
18
|
+
universal?: string | undefined;
|
|
19
|
+
} | undefined;
|
|
20
|
+
eip6963Config?: {
|
|
21
|
+
rdns: string;
|
|
22
|
+
} | undefined;
|
|
23
|
+
filterFromWalletConnect?: boolean | undefined;
|
|
24
|
+
group?: string | undefined;
|
|
25
|
+
hardwareWallets?: string[] | undefined;
|
|
26
|
+
injectedConfig?: {
|
|
27
|
+
chain: string;
|
|
28
|
+
extensionLocators: {
|
|
29
|
+
value: boolean;
|
|
30
|
+
flag: string;
|
|
31
|
+
}[];
|
|
32
|
+
providerInterface?: string | undefined;
|
|
33
|
+
walletStandard?: {
|
|
34
|
+
name: string;
|
|
35
|
+
features: string[];
|
|
36
|
+
} | undefined;
|
|
37
|
+
walletStandardLocators?: {
|
|
38
|
+
name: string;
|
|
39
|
+
locator: string;
|
|
40
|
+
}[] | undefined;
|
|
41
|
+
windowLocations?: string[] | undefined;
|
|
42
|
+
}[] | undefined;
|
|
43
|
+
mobile?: {
|
|
44
|
+
android?: string | null | undefined;
|
|
45
|
+
androidId?: string | undefined;
|
|
46
|
+
inAppBrowser?: string | null | undefined;
|
|
47
|
+
ios?: string | null | undefined;
|
|
48
|
+
iosId?: string | undefined;
|
|
49
|
+
native?: string | undefined;
|
|
50
|
+
universal?: string | undefined;
|
|
51
|
+
} | undefined;
|
|
52
|
+
mobileExperience?: "in-app-browser" | "redirect" | undefined;
|
|
53
|
+
shortName?: string | undefined;
|
|
54
|
+
showOnlyIfInstalled?: boolean | undefined;
|
|
55
|
+
switchNetworkOnlyFromWallet?: boolean | undefined;
|
|
56
|
+
walletConnect?: {
|
|
57
|
+
sdks?: string[] | undefined;
|
|
58
|
+
} | undefined;
|
|
59
|
+
walletGroup?: string | undefined;
|
|
60
|
+
walletLimitations?: {
|
|
61
|
+
browserExtension?: {
|
|
62
|
+
unsupportedEvents?: string[] | undefined;
|
|
63
|
+
unsupportedMethods?: string[] | undefined;
|
|
64
|
+
} | undefined;
|
|
65
|
+
mobile?: {
|
|
66
|
+
unsupportedEvents?: string[] | undefined;
|
|
67
|
+
unsupportedMethods?: string[] | undefined;
|
|
68
|
+
} | undefined;
|
|
69
|
+
} | undefined;
|
|
70
|
+
} | undefined;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
import { getWalletBookWallet } from './getWalletBookWallet.js';
|
|
3
|
+
|
|
4
|
+
const findWalletBookWallet = (walletBook, walletKey) => {
|
|
5
|
+
try {
|
|
6
|
+
const walletData = getWalletBookWallet(walletBook, walletKey);
|
|
7
|
+
return walletData;
|
|
8
|
+
}
|
|
9
|
+
catch (err) {
|
|
10
|
+
return undefined;
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export { findWalletBookWallet };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
|
|
6
|
+
var getWalletGroup = require('./getWalletGroup.cjs');
|
|
7
|
+
var logger = require('./logger.cjs');
|
|
8
|
+
|
|
9
|
+
const findWalletGroup = (walletBook, walletGroup) => {
|
|
10
|
+
try {
|
|
11
|
+
return getWalletGroup.getWalletGroup(walletBook, walletGroup);
|
|
12
|
+
}
|
|
13
|
+
catch (err) {
|
|
14
|
+
logger.logger.error(err);
|
|
15
|
+
return undefined;
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
exports.findWalletGroup = findWalletGroup;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { WalletBookSchema } from '../schemas';
|
|
2
|
+
export declare const findWalletGroup: (walletBook: WalletBookSchema, walletGroup: string) => {
|
|
3
|
+
key: string;
|
|
4
|
+
name: string;
|
|
5
|
+
brand?: {
|
|
6
|
+
alt?: string | undefined;
|
|
7
|
+
primaryColor?: string | undefined;
|
|
8
|
+
spriteId?: string | undefined;
|
|
9
|
+
} | undefined;
|
|
10
|
+
walletOverrides?: Record<string, {
|
|
11
|
+
brand?: {
|
|
12
|
+
alt?: string | undefined;
|
|
13
|
+
primaryColor?: string | undefined;
|
|
14
|
+
spriteId?: string | undefined;
|
|
15
|
+
} | undefined;
|
|
16
|
+
name?: string | undefined;
|
|
17
|
+
}> | undefined;
|
|
18
|
+
} | undefined;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
import { getWalletGroup } from './getWalletGroup.js';
|
|
3
|
+
import { logger } from './logger.js';
|
|
4
|
+
|
|
5
|
+
const findWalletGroup = (walletBook, walletGroup) => {
|
|
6
|
+
try {
|
|
7
|
+
return getWalletGroup(walletBook, walletGroup);
|
|
8
|
+
}
|
|
9
|
+
catch (err) {
|
|
10
|
+
logger.error(err);
|
|
11
|
+
return undefined;
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export { findWalletGroup };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
|
|
6
|
+
var findWalletGroup = require('./findWalletGroup.cjs');
|
|
7
|
+
|
|
8
|
+
const findWalletGroupOverride = (walletBook, groupKey, walletKey) => {
|
|
9
|
+
var _a;
|
|
10
|
+
const group = findWalletGroup.findWalletGroup(walletBook, groupKey);
|
|
11
|
+
return (_a = group === null || group === void 0 ? void 0 : group.walletOverrides) === null || _a === void 0 ? void 0 : _a[walletKey];
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
exports.findWalletGroupOverride = findWalletGroupOverride;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
import { findWalletGroup } from './findWalletGroup.js';
|
|
3
|
+
|
|
4
|
+
const findWalletGroupOverride = (walletBook, groupKey, walletKey) => {
|
|
5
|
+
var _a;
|
|
6
|
+
const group = findWalletGroup(walletBook, groupKey);
|
|
7
|
+
return (_a = group === null || group === void 0 ? void 0 : group.walletOverrides) === null || _a === void 0 ? void 0 : _a[walletKey];
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export { findWalletGroupOverride };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
|
|
6
|
+
var renderTemplate = require('./renderTemplate.cjs');
|
|
7
|
+
|
|
8
|
+
const getBrandIconUrl = (brand) => {
|
|
9
|
+
if (brand.spriteId) {
|
|
10
|
+
return renderTemplate.renderTemplate('iconicUrl', brand.spriteId);
|
|
11
|
+
}
|
|
12
|
+
return '';
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
exports.getBrandIconUrl = getBrandIconUrl;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
|
|
6
|
+
/* eslint-disable arrow-body-style */
|
|
7
|
+
// This method needs to be wrapped correctly to avoid bundler issues
|
|
8
|
+
// that may update process.env variable via custom configs in customers apps
|
|
9
|
+
const getWalletBookCdnUrl = () => {
|
|
10
|
+
var _a, _b, _c;
|
|
11
|
+
return ((_c = (_b = (_a = process.env['WALLET_BOOK_CDN_URL']) !== null && _a !== void 0 ? _a : process.env['NEXT_PUBLIC_WALLET_BOOK_CDN_URL']) !== null && _b !== void 0 ? _b : process.env['REACT_APP_WALLET_BOOK_CDN_URL']) !== null && _c !== void 0 ? _c : 'https://dynamic-static-assets.com/wallet-book/v1/stable/wallet-book.json');
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
exports.getWalletBookCdnUrl = getWalletBookCdnUrl;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const getWalletBookCdnUrl: () => string;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
/* eslint-disable arrow-body-style */
|
|
3
|
+
// This method needs to be wrapped correctly to avoid bundler issues
|
|
4
|
+
// that may update process.env variable via custom configs in customers apps
|
|
5
|
+
const getWalletBookCdnUrl = () => {
|
|
6
|
+
var _a, _b, _c;
|
|
7
|
+
return ((_c = (_b = (_a = process.env['WALLET_BOOK_CDN_URL']) !== null && _a !== void 0 ? _a : process.env['NEXT_PUBLIC_WALLET_BOOK_CDN_URL']) !== null && _b !== void 0 ? _b : process.env['REACT_APP_WALLET_BOOK_CDN_URL']) !== null && _c !== void 0 ? _c : 'https://dynamic-static-assets.com/wallet-book/v1/stable/wallet-book.json');
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export { getWalletBookCdnUrl };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
|
|
6
|
+
const getWalletBookWallet = (walletBook, walletKey, walletFallback) => {
|
|
7
|
+
var _a, _b, _c;
|
|
8
|
+
if (!walletKey)
|
|
9
|
+
throw new Error('Wallet key is required. Please pass in a wallet key to getWalletBookWallet');
|
|
10
|
+
const walletData = (_b = (_a = walletBook === null || walletBook === void 0 ? void 0 : walletBook.wallets) === null || _a === void 0 ? void 0 : _a[walletKey]) !== null && _b !== void 0 ? _b : walletFallback;
|
|
11
|
+
if (!walletData) {
|
|
12
|
+
throw new Error(`Wallet ${walletKey} not found in wallet book (${Object.keys((_c = walletBook === null || walletBook === void 0 ? void 0 : walletBook.wallets) !== null && _c !== void 0 ? _c : {}).length} wallets found)`);
|
|
13
|
+
}
|
|
14
|
+
return walletData;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
exports.getWalletBookWallet = getWalletBookWallet;
|