@dynamic-labs/wallet-book 0.19.0-alpha.8 → 0.19.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.
Files changed (96) hide show
  1. package/CHANGELOG.md +321 -0
  2. package/README.md +34 -0
  3. package/package.json +3 -3
  4. package/src/build/index.d.ts +50 -41
  5. package/src/build/sources/firstParty/index.d.ts +2 -2
  6. package/src/build/sources/index.d.ts +4 -4
  7. package/src/build/sources/walletConnect/index.d.ts +100 -91
  8. package/src/build/sources/walletConnect/preprocessors.d.ts +13 -13
  9. package/src/build/sources/walletConnectOverrides/index.d.ts +249 -249
  10. package/src/build/sources/walletGroups/index.d.ts +2 -2
  11. package/src/components/WalletBookContext.cjs +3 -3
  12. package/src/components/WalletBookContext.d.ts +9 -9
  13. package/src/components/WalletBookContext.js +3 -3
  14. package/src/components/WalletIcon.cjs +19 -19
  15. package/src/components/WalletIcon.d.ts +8 -8
  16. package/src/components/WalletIcon.js +19 -19
  17. package/src/components/index.d.ts +2 -2
  18. package/src/helpers/findWalletBookWallet.cjs +9 -9
  19. package/src/helpers/findWalletBookWallet.d.ts +44 -35
  20. package/src/helpers/findWalletBookWallet.js +9 -9
  21. package/src/helpers/findWalletGroup.cjs +8 -8
  22. package/src/helpers/findWalletGroup.d.ts +11 -11
  23. package/src/helpers/findWalletGroup.js +8 -8
  24. package/src/helpers/getWalletBookCdnUrl.cjs +8 -8
  25. package/src/helpers/getWalletBookCdnUrl.d.ts +1 -1
  26. package/src/helpers/getWalletBookCdnUrl.js +8 -8
  27. package/src/helpers/getWalletBookWallet.cjs +6 -6
  28. package/src/helpers/getWalletBookWallet.d.ts +2 -2
  29. package/src/helpers/getWalletBookWallet.js +6 -6
  30. package/src/helpers/getWalletGroup.cjs +5 -5
  31. package/src/helpers/getWalletGroup.d.ts +3 -3
  32. package/src/helpers/getWalletGroup.js +5 -5
  33. package/src/helpers/getWalletIconUrl.cjs +23 -23
  34. package/src/helpers/getWalletIconUrl.d.ts +3 -3
  35. package/src/helpers/getWalletIconUrl.js +23 -23
  36. package/src/helpers/getWalletLinks.cjs +26 -26
  37. package/src/helpers/getWalletLinks.d.ts +10 -10
  38. package/src/helpers/getWalletLinks.js +26 -26
  39. package/src/helpers/getWalletPrimaryColor.cjs +3 -3
  40. package/src/helpers/getWalletPrimaryColor.d.ts +2 -2
  41. package/src/helpers/getWalletPrimaryColor.js +3 -3
  42. package/src/helpers/index.d.ts +11 -11
  43. package/src/helpers/logger.d.ts +2 -2
  44. package/src/helpers/normalizeWalletName.d.ts +1 -1
  45. package/src/helpers/renderTemplate.cjs +13 -13
  46. package/src/helpers/renderTemplate.d.ts +12 -12
  47. package/src/helpers/renderTemplate.js +13 -13
  48. package/src/hooks/index.d.ts +2 -2
  49. package/src/hooks/useWalletBookCdn.cjs +27 -27
  50. package/src/hooks/useWalletBookCdn.d.ts +55 -46
  51. package/src/hooks/useWalletBookCdn.js +27 -27
  52. package/src/hooks/useWalletBookContext.cjs +6 -6
  53. package/src/hooks/useWalletBookContext.d.ts +1 -1
  54. package/src/hooks/useWalletBookContext.js +6 -6
  55. package/src/index.d.ts +18 -18
  56. package/src/schemas/index.d.ts +3 -3
  57. package/src/schemas/utils/filterEmptyObject.cjs +5 -5
  58. package/src/schemas/utils/filterEmptyObject.d.ts +6 -6
  59. package/src/schemas/utils/filterEmptyObject.js +5 -5
  60. package/src/schemas/utils/nonEmptyString.cjs +3 -3
  61. package/src/schemas/utils/nonEmptyString.d.ts +5 -5
  62. package/src/schemas/utils/nonEmptyString.js +3 -3
  63. package/src/schemas/utils/nonEmptyStringArray.cjs +3 -3
  64. package/src/schemas/utils/nonEmptyStringArray.d.ts +5 -5
  65. package/src/schemas/utils/nonEmptyStringArray.js +3 -3
  66. package/src/schemas/utils/processWalletConnectNativeUrl.d.ts +1 -1
  67. package/src/schemas/utils/sortKeys.d.ts +5 -5
  68. package/src/schemas/utils/transformAndroidId.cjs +16 -16
  69. package/src/schemas/utils/transformAndroidId.d.ts +1 -1
  70. package/src/schemas/utils/transformAndroidId.js +16 -16
  71. package/src/schemas/utils/transformChromeExtensionId.cjs +13 -13
  72. package/src/schemas/utils/transformChromeExtensionId.d.ts +1 -1
  73. package/src/schemas/utils/transformChromeExtensionId.js +13 -13
  74. package/src/schemas/utils/transformEdgeExtensionId.cjs +13 -13
  75. package/src/schemas/utils/transformEdgeExtensionId.d.ts +1 -1
  76. package/src/schemas/utils/transformEdgeExtensionId.js +13 -13
  77. package/src/schemas/utils/transformFirefoxExtensionId.cjs +13 -13
  78. package/src/schemas/utils/transformFirefoxExtensionId.d.ts +1 -1
  79. package/src/schemas/utils/transformFirefoxExtensionId.js +13 -13
  80. package/src/schemas/utils/transformIosId.cjs +20 -20
  81. package/src/schemas/utils/transformIosId.d.ts +1 -1
  82. package/src/schemas/utils/transformIosId.js +20 -20
  83. package/src/schemas/walletBookSchema.cjs +5 -5
  84. package/src/schemas/walletBookSchema.d.ts +862 -714
  85. package/src/schemas/walletBookSchema.js +5 -5
  86. package/src/schemas/walletConnectSourceSchema.cjs +64 -64
  87. package/src/schemas/walletConnectSourceSchema.d.ts +504 -504
  88. package/src/schemas/walletConnectSourceSchema.js +64 -64
  89. package/src/schemas/walletGroup.cjs +22 -22
  90. package/src/schemas/walletGroup.d.ts +50 -50
  91. package/src/schemas/walletGroup.js +22 -22
  92. package/src/schemas/walletSchema.cjs +88 -66
  93. package/src/schemas/walletSchema.d.ts +351 -256
  94. package/src/schemas/walletSchema.js +88 -66
  95. package/wallet-book-fallbacks.cjs +82 -1
  96. package/wallet-book-fallbacks.js +82 -1
@@ -8,72 +8,94 @@ import { transformAndroidId } from './utils/transformAndroidId.js';
8
8
  import { nonEmptyStringArray } from './utils/nonEmptyStringArray.js';
9
9
  import { filterEmptyObject } from './utils/filterEmptyObject.js';
10
10
 
11
- const walletSchema = z
12
- .preprocess((val) => val, z.object({
13
- brand: z
14
- .object({
15
- alt: nonEmptyString,
16
- imageId: nonEmptyString,
17
- primaryColor: nonEmptyString,
18
- spriteId: nonEmptyString,
19
- })
20
- .optional()
21
- .refine((val) => {
22
- if (!val)
23
- return true;
24
- if (!(val.spriteId && val.imageId) &&
25
- (val.spriteId || val.imageId)) {
26
- return true;
27
- }
28
- return false;
29
- }, {
30
- message: 'Only one of spriteId or imageId can be defined',
31
- path: ['brand'],
32
- }),
33
- chains: z.array(z.string()).optional(),
34
- desktop: z
35
- .object({
36
- chromeId: nonEmptyString.transform(transformChromeExtensionId),
37
- edgeId: nonEmptyString.transform(transformEdgeExtensionId),
38
- firefoxId: nonEmptyString.transform(transformFirefoxExtensionId),
39
- native: nonEmptyString,
40
- operaId: nonEmptyString,
41
- safariId: nonEmptyString,
42
- universal: nonEmptyString,
43
- })
44
- .optional()
45
- .transform(filterEmptyObject),
46
- group: z.string().optional(),
47
- mobile: z
48
- .object({
49
- android: string().nullish(),
50
- androidId: nonEmptyString.transform(transformAndroidId),
51
- ios: string().nullish(),
52
- iosId: nonEmptyString.transform(transformIosId),
53
- native: nonEmptyString,
54
- universal: nonEmptyString,
55
- })
56
- .optional()
57
- .transform(filterEmptyObject),
58
- name: z.string(),
59
- shortName: nonEmptyString,
60
- showOnlyIfInstalled: z.boolean().optional(),
61
- switchNetworkOnlyFromWallet: z.boolean().optional(),
62
- walletConnect: z
63
- .object({
64
- sdks: nonEmptyStringArray,
65
- })
66
- .optional()
67
- .transform(filterEmptyObject),
68
- }))
69
- .transform((val) => {
70
- if (val.mobile?.iosId || val.mobile?.ios === null) {
71
- delete val.mobile?.ios;
72
- }
73
- if (val.mobile?.androidId || val.mobile?.android === null) {
74
- delete val.mobile?.android;
75
- }
76
- return val;
11
+ const injectedConfigSchema = z.object({
12
+ chain: z.string(),
13
+ extensionLocators: z.array(z.object({
14
+ flag: z.string(),
15
+ value: z.boolean().optional().default(true),
16
+ })),
17
+ windowLocations: z
18
+ .array(z.string())
19
+ .optional()
20
+ .refine((val) => {
21
+ if (!val)
22
+ return true;
23
+ if (!val.some((v) => ['ethereum', 'ethereum.providers'].includes(v)))
24
+ return true;
25
+ return false;
26
+ }, {
27
+ message: 'windowLocations cannot include ethereum or ethereum.providers as they are included by default',
28
+ path: ['config'],
29
+ }),
30
+ });
31
+ const walletSchema = z
32
+ .preprocess((val) => val, z.object({
33
+ brand: z
34
+ .object({
35
+ alt: nonEmptyString,
36
+ imageId: nonEmptyString,
37
+ primaryColor: nonEmptyString,
38
+ spriteId: nonEmptyString,
39
+ })
40
+ .optional()
41
+ .refine((val) => {
42
+ if (!val)
43
+ return true;
44
+ if (!(val.spriteId && val.imageId) &&
45
+ (val.spriteId || val.imageId)) {
46
+ return true;
47
+ }
48
+ return false;
49
+ }, {
50
+ message: 'Only one of spriteId or imageId can be defined',
51
+ path: ['brand'],
52
+ }),
53
+ chains: z.array(z.string()).optional(),
54
+ desktop: z
55
+ .object({
56
+ chromeId: nonEmptyString.transform(transformChromeExtensionId),
57
+ edgeId: nonEmptyString.transform(transformEdgeExtensionId),
58
+ firefoxId: nonEmptyString.transform(transformFirefoxExtensionId),
59
+ native: nonEmptyString,
60
+ operaId: nonEmptyString,
61
+ safariId: nonEmptyString,
62
+ universal: nonEmptyString,
63
+ })
64
+ .optional()
65
+ .transform(filterEmptyObject),
66
+ filterFromWalletConnect: z.boolean().optional(),
67
+ group: z.string().optional(),
68
+ injectedConfig: z.array(injectedConfigSchema).optional(),
69
+ mobile: z
70
+ .object({
71
+ android: string().nullish(),
72
+ androidId: nonEmptyString.transform(transformAndroidId),
73
+ ios: string().nullish(),
74
+ iosId: nonEmptyString.transform(transformIosId),
75
+ native: nonEmptyString,
76
+ universal: nonEmptyString,
77
+ })
78
+ .optional()
79
+ .transform(filterEmptyObject),
80
+ name: z.string(),
81
+ shortName: nonEmptyString,
82
+ showOnlyIfInstalled: z.boolean().optional(),
83
+ switchNetworkOnlyFromWallet: z.boolean().optional(),
84
+ walletConnect: z
85
+ .object({
86
+ sdks: nonEmptyStringArray,
87
+ })
88
+ .optional()
89
+ .transform(filterEmptyObject),
90
+ }))
91
+ .transform((val) => {
92
+ if (val.mobile?.iosId || val.mobile?.ios === null) {
93
+ delete val.mobile?.ios;
94
+ }
95
+ if (val.mobile?.androidId || val.mobile?.android === null) {
96
+ delete val.mobile?.android;
97
+ }
98
+ return val;
77
99
  });
78
100
 
79
101
  export { walletSchema };
@@ -63,6 +63,66 @@ var wallets = {
63
63
  edgeId: "ejbalbakoplchlghecdalmeeeajnimhm",
64
64
  firefoxId: "ether-metamask"
65
65
  },
66
+ filterFromWalletConnect: true,
67
+ injectedConfig: [
68
+ {
69
+ chain: "evm",
70
+ extensionLocators: [
71
+ {
72
+ flag: "isMetaMask",
73
+ value: true
74
+ },
75
+ {
76
+ flag: "isDawn",
77
+ value: false
78
+ },
79
+ {
80
+ flag: "isBraveWallet",
81
+ value: false
82
+ },
83
+ {
84
+ flag: "isTrustWallet",
85
+ value: false
86
+ },
87
+ {
88
+ flag: "isExodus",
89
+ value: false
90
+ },
91
+ {
92
+ flag: "isPhantom",
93
+ value: false
94
+ },
95
+ {
96
+ flag: "isZerion",
97
+ value: false
98
+ },
99
+ {
100
+ flag: "isSuperb",
101
+ value: false
102
+ },
103
+ {
104
+ flag: "isRabby",
105
+ value: false
106
+ },
107
+ {
108
+ flag: "isOKExWallet",
109
+ value: false
110
+ },
111
+ {
112
+ flag: "isOkxWallet",
113
+ value: false
114
+ },
115
+ {
116
+ flag: "isRainbow",
117
+ value: false
118
+ },
119
+ {
120
+ flag: "isAvalanche",
121
+ value: false
122
+ }
123
+ ]
124
+ }
125
+ ],
66
126
  mobile: {
67
127
  androidId: "io.metamask",
68
128
  iosId: "id1438144202",
@@ -133,6 +193,10 @@ var wallets = {
133
193
  chromeId: "dlcobpjiigpikoobohmabehhmhfoodbb",
134
194
  firefoxId: "argent-x"
135
195
  },
196
+ mobile: {
197
+ androidId: "im.argent.contractwalletclient",
198
+ iosId: "id1358741926"
199
+ },
136
200
  name: "Argent X"
137
201
  },
138
202
  myalgo: {
@@ -195,12 +259,13 @@ var wallets = {
195
259
  desktop: {
196
260
  chromeId: "egjidjbpglichdcondbcbdnbeeppgdph"
197
261
  },
262
+ filterFromWalletConnect: true,
198
263
  mobile: {
199
264
  androidId: "com.wallet.crypto.trustapp",
200
265
  iosId: "id1288339409",
201
266
  native: "trust://wc"
202
267
  },
203
- name: "Trust Wallet",
268
+ name: "Trust",
204
269
  shortName: "Trust",
205
270
  walletConnect: {
206
271
  sdks: [
@@ -222,6 +287,21 @@ var wallets = {
222
287
  "eip155:42161",
223
288
  "eip155:56"
224
289
  ],
290
+ filterFromWalletConnect: true,
291
+ injectedConfig: [
292
+ {
293
+ chain: "evm",
294
+ extensionLocators: [
295
+ {
296
+ flag: "isRainbow",
297
+ value: true
298
+ }
299
+ ],
300
+ windowLocations: [
301
+ "rainbow"
302
+ ]
303
+ }
304
+ ],
225
305
  mobile: {
226
306
  androidId: "me.rainbow",
227
307
  iosId: "id1457119021",
@@ -274,6 +354,7 @@ var wallets = {
274
354
  desktop: {
275
355
  chromeId: "hpclkefagolihohboafpheddmmgdffjm"
276
356
  },
357
+ filterFromWalletConnect: true,
277
358
  mobile: {
278
359
  androidId: "io.outblock.lilico",
279
360
  iosId: "id1644169603",
@@ -59,6 +59,66 @@ var wallets = {
59
59
  edgeId: "ejbalbakoplchlghecdalmeeeajnimhm",
60
60
  firefoxId: "ether-metamask"
61
61
  },
62
+ filterFromWalletConnect: true,
63
+ injectedConfig: [
64
+ {
65
+ chain: "evm",
66
+ extensionLocators: [
67
+ {
68
+ flag: "isMetaMask",
69
+ value: true
70
+ },
71
+ {
72
+ flag: "isDawn",
73
+ value: false
74
+ },
75
+ {
76
+ flag: "isBraveWallet",
77
+ value: false
78
+ },
79
+ {
80
+ flag: "isTrustWallet",
81
+ value: false
82
+ },
83
+ {
84
+ flag: "isExodus",
85
+ value: false
86
+ },
87
+ {
88
+ flag: "isPhantom",
89
+ value: false
90
+ },
91
+ {
92
+ flag: "isZerion",
93
+ value: false
94
+ },
95
+ {
96
+ flag: "isSuperb",
97
+ value: false
98
+ },
99
+ {
100
+ flag: "isRabby",
101
+ value: false
102
+ },
103
+ {
104
+ flag: "isOKExWallet",
105
+ value: false
106
+ },
107
+ {
108
+ flag: "isOkxWallet",
109
+ value: false
110
+ },
111
+ {
112
+ flag: "isRainbow",
113
+ value: false
114
+ },
115
+ {
116
+ flag: "isAvalanche",
117
+ value: false
118
+ }
119
+ ]
120
+ }
121
+ ],
62
122
  mobile: {
63
123
  androidId: "io.metamask",
64
124
  iosId: "id1438144202",
@@ -129,6 +189,10 @@ var wallets = {
129
189
  chromeId: "dlcobpjiigpikoobohmabehhmhfoodbb",
130
190
  firefoxId: "argent-x"
131
191
  },
192
+ mobile: {
193
+ androidId: "im.argent.contractwalletclient",
194
+ iosId: "id1358741926"
195
+ },
132
196
  name: "Argent X"
133
197
  },
134
198
  myalgo: {
@@ -191,12 +255,13 @@ var wallets = {
191
255
  desktop: {
192
256
  chromeId: "egjidjbpglichdcondbcbdnbeeppgdph"
193
257
  },
258
+ filterFromWalletConnect: true,
194
259
  mobile: {
195
260
  androidId: "com.wallet.crypto.trustapp",
196
261
  iosId: "id1288339409",
197
262
  native: "trust://wc"
198
263
  },
199
- name: "Trust Wallet",
264
+ name: "Trust",
200
265
  shortName: "Trust",
201
266
  walletConnect: {
202
267
  sdks: [
@@ -218,6 +283,21 @@ var wallets = {
218
283
  "eip155:42161",
219
284
  "eip155:56"
220
285
  ],
286
+ filterFromWalletConnect: true,
287
+ injectedConfig: [
288
+ {
289
+ chain: "evm",
290
+ extensionLocators: [
291
+ {
292
+ flag: "isRainbow",
293
+ value: true
294
+ }
295
+ ],
296
+ windowLocations: [
297
+ "rainbow"
298
+ ]
299
+ }
300
+ ],
221
301
  mobile: {
222
302
  androidId: "me.rainbow",
223
303
  iosId: "id1457119021",
@@ -270,6 +350,7 @@ var wallets = {
270
350
  desktop: {
271
351
  chromeId: "hpclkefagolihohboafpheddmmgdffjm"
272
352
  },
353
+ filterFromWalletConnect: true,
273
354
  mobile: {
274
355
  androidId: "io.outblock.lilico",
275
356
  iosId: "id1644169603",