@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.
Files changed (117) hide show
  1. package/CHANGELOG.md +3746 -0
  2. package/LICENSE +21 -0
  3. package/README.md +142 -0
  4. package/_virtual/_tslib.cjs +49 -0
  5. package/_virtual/_tslib.js +44 -0
  6. package/package.json +38 -0
  7. package/src/build/index.d.ts +76 -0
  8. package/src/build/sources/firstParty/index.d.ts +2 -0
  9. package/src/build/sources/index.d.ts +4 -0
  10. package/src/build/sources/walletConnect/index.d.ts +128 -0
  11. package/src/build/sources/walletConnect/preprocessors.d.ts +14 -0
  12. package/src/build/sources/walletConnectOverrides/index.d.ts +197 -0
  13. package/src/build/sources/walletGroups/index.d.ts +2 -0
  14. package/src/components/BrandIcon.cjs +27 -0
  15. package/src/components/BrandIcon.d.ts +8 -0
  16. package/src/components/BrandIcon.js +23 -0
  17. package/src/components/WalletBookContext.cjs +14 -0
  18. package/src/components/WalletBookContext.d.ts +9 -0
  19. package/src/components/WalletBookContext.js +9 -0
  20. package/src/components/WalletIcon.cjs +34 -0
  21. package/src/components/WalletIcon.d.ts +8 -0
  22. package/src/components/WalletIcon.js +30 -0
  23. package/src/components/index.d.ts +3 -0
  24. package/src/helpers/findWalletBookWallet.cjs +18 -0
  25. package/src/helpers/findWalletBookWallet.d.ts +70 -0
  26. package/src/helpers/findWalletBookWallet.js +14 -0
  27. package/src/helpers/findWalletGroup.cjs +19 -0
  28. package/src/helpers/findWalletGroup.d.ts +18 -0
  29. package/src/helpers/findWalletGroup.js +15 -0
  30. package/src/helpers/findWalletGroupOverride.cjs +14 -0
  31. package/src/helpers/findWalletGroupOverride.d.ts +3 -0
  32. package/src/helpers/findWalletGroupOverride.js +10 -0
  33. package/src/helpers/getBrandIconUrl.cjs +15 -0
  34. package/src/helpers/getBrandIconUrl.d.ts +2 -0
  35. package/src/helpers/getBrandIconUrl.js +11 -0
  36. package/src/helpers/getWalletBookCdnUrl.cjs +14 -0
  37. package/src/helpers/getWalletBookCdnUrl.d.ts +1 -0
  38. package/src/helpers/getWalletBookCdnUrl.js +10 -0
  39. package/src/helpers/getWalletBookWallet.cjs +17 -0
  40. package/src/helpers/getWalletBookWallet.d.ts +2 -0
  41. package/src/helpers/getWalletBookWallet.js +13 -0
  42. package/src/helpers/getWalletGroup.cjs +13 -0
  43. package/src/helpers/getWalletGroup.d.ts +3 -0
  44. package/src/helpers/getWalletGroup.js +9 -0
  45. package/src/helpers/getWalletIconUrl.cjs +34 -0
  46. package/src/helpers/getWalletIconUrl.d.ts +3 -0
  47. package/src/helpers/getWalletIconUrl.js +29 -0
  48. package/src/helpers/getWalletLinks.cjs +34 -0
  49. package/src/helpers/getWalletLinks.d.ts +10 -0
  50. package/src/helpers/getWalletLinks.js +30 -0
  51. package/src/helpers/getWalletPrimaryColor.cjs +14 -0
  52. package/src/helpers/getWalletPrimaryColor.d.ts +2 -0
  53. package/src/helpers/getWalletPrimaryColor.js +10 -0
  54. package/src/helpers/index.d.ts +14 -0
  55. package/src/helpers/isWalletEventSupported.cjs +8 -0
  56. package/src/helpers/isWalletEventSupported.d.ts +2 -0
  57. package/src/helpers/isWalletEventSupported.js +4 -0
  58. package/src/helpers/isWalletMethodSupported.cjs +8 -0
  59. package/src/helpers/isWalletMethodSupported.d.ts +2 -0
  60. package/src/helpers/isWalletMethodSupported.js +4 -0
  61. package/src/helpers/logger.cjs +10 -0
  62. package/src/helpers/logger.d.ts +2 -0
  63. package/src/helpers/logger.js +6 -0
  64. package/src/helpers/renderTemplate.cjs +23 -0
  65. package/src/helpers/renderTemplate.d.ts +12 -0
  66. package/src/helpers/renderTemplate.js +19 -0
  67. package/src/hooks/index.d.ts +2 -0
  68. package/src/hooks/useWalletBookCdn.cjs +51 -0
  69. package/src/hooks/useWalletBookCdn.d.ts +88 -0
  70. package/src/hooks/useWalletBookCdn.js +47 -0
  71. package/src/hooks/useWalletBookContext.cjs +24 -0
  72. package/src/hooks/useWalletBookContext.d.ts +1 -0
  73. package/src/hooks/useWalletBookContext.js +20 -0
  74. package/src/index.cjs +44 -0
  75. package/src/index.d.ts +18 -0
  76. package/src/index.js +20 -0
  77. package/src/schemas/index.d.ts +3 -0
  78. package/src/schemas/utils/filterEmptyObject.cjs +13 -0
  79. package/src/schemas/utils/filterEmptyObject.d.ts +6 -0
  80. package/src/schemas/utils/filterEmptyObject.js +9 -0
  81. package/src/schemas/utils/nonEmptyString.cjs +13 -0
  82. package/src/schemas/utils/nonEmptyString.d.ts +5 -0
  83. package/src/schemas/utils/nonEmptyString.js +9 -0
  84. package/src/schemas/utils/nonEmptyStringArray.cjs +13 -0
  85. package/src/schemas/utils/nonEmptyStringArray.d.ts +5 -0
  86. package/src/schemas/utils/nonEmptyStringArray.js +9 -0
  87. package/src/schemas/utils/processWalletConnectNativeUrl.d.ts +1 -0
  88. package/src/schemas/utils/sortKeys.d.ts +5 -0
  89. package/src/schemas/utils/transformAndroidId.cjs +24 -0
  90. package/src/schemas/utils/transformAndroidId.d.ts +1 -0
  91. package/src/schemas/utils/transformAndroidId.js +20 -0
  92. package/src/schemas/utils/transformChromeExtensionId.cjs +21 -0
  93. package/src/schemas/utils/transformChromeExtensionId.d.ts +1 -0
  94. package/src/schemas/utils/transformChromeExtensionId.js +17 -0
  95. package/src/schemas/utils/transformEdgeExtensionId.cjs +21 -0
  96. package/src/schemas/utils/transformEdgeExtensionId.d.ts +1 -0
  97. package/src/schemas/utils/transformEdgeExtensionId.js +17 -0
  98. package/src/schemas/utils/transformFirefoxExtensionId.cjs +21 -0
  99. package/src/schemas/utils/transformFirefoxExtensionId.d.ts +1 -0
  100. package/src/schemas/utils/transformFirefoxExtensionId.js +17 -0
  101. package/src/schemas/utils/transformIosId.cjs +28 -0
  102. package/src/schemas/utils/transformIosId.d.ts +1 -0
  103. package/src/schemas/utils/transformIosId.js +24 -0
  104. package/src/schemas/walletBookSchema.cjs +17 -0
  105. package/src/schemas/walletBookSchema.d.ts +1369 -0
  106. package/src/schemas/walletBookSchema.js +13 -0
  107. package/src/schemas/walletConnectSourceSchema.cjs +78 -0
  108. package/src/schemas/walletConnectSourceSchema.d.ts +516 -0
  109. package/src/schemas/walletConnectSourceSchema.js +74 -0
  110. package/src/schemas/walletGroup.cjs +27 -0
  111. package/src/schemas/walletGroup.d.ts +113 -0
  112. package/src/schemas/walletGroup.js +23 -0
  113. package/src/schemas/walletSchema.cjs +141 -0
  114. package/src/schemas/walletSchema.d.ts +614 -0
  115. package/src/schemas/walletSchema.js +136 -0
  116. package/wallet-book-fallbacks.cjs +1082 -0
  117. package/wallet-book-fallbacks.js +1076 -0
@@ -0,0 +1,136 @@
1
+ 'use client'
2
+ import { z, string } from 'zod';
3
+ import { nonEmptyString } from './utils/nonEmptyString.js';
4
+ import { transformChromeExtensionId } from './utils/transformChromeExtensionId.js';
5
+ import { transformEdgeExtensionId } from './utils/transformEdgeExtensionId.js';
6
+ import { transformFirefoxExtensionId } from './utils/transformFirefoxExtensionId.js';
7
+ import { transformIosId } from './utils/transformIosId.js';
8
+ import { transformAndroidId } from './utils/transformAndroidId.js';
9
+ import { nonEmptyStringArray } from './utils/nonEmptyStringArray.js';
10
+ import { filterEmptyObject } from './utils/filterEmptyObject.js';
11
+
12
+ const injectedConfigSchema = z.object({
13
+ chain: z.string(),
14
+ extensionLocators: z.array(z.object({
15
+ flag: z.string(),
16
+ value: z.boolean().optional().default(true),
17
+ })),
18
+ /**
19
+ * Allows declaring which interface, if any, this wallet's implementation follows
20
+ * ex. Leather with https://btckit.org/
21
+ */
22
+ providerInterface: z.string().optional(),
23
+ /**
24
+ * Allows declaring that this wallet is discoverable through the the Wallet Standard
25
+ * See https://github.com/wallet-standard/wallet-standard
26
+ * Also allows ignoring wallets that don't support the provided features
27
+ */
28
+ walletStandard: z
29
+ .object({ features: z.array(z.string()), name: z.string() })
30
+ .optional(),
31
+ walletStandardLocators: z
32
+ .array(z.object({ locator: z.string(), name: z.string() }))
33
+ .optional(),
34
+ windowLocations: z
35
+ .array(z.string())
36
+ .optional()
37
+ .refine((val) => {
38
+ if (!val)
39
+ return true;
40
+ if (!val.some((v) => ['ethereum', 'ethereum.providers'].includes(v)))
41
+ return true;
42
+ return false;
43
+ }, {
44
+ message: 'windowLocations cannot include ethereum or ethereum.providers as they are included by default',
45
+ path: ['config'],
46
+ }),
47
+ });
48
+ const brandSchema = z.object({
49
+ alt: nonEmptyString,
50
+ primaryColor: nonEmptyString,
51
+ spriteId: nonEmptyString,
52
+ });
53
+ const walletSchema = z
54
+ .preprocess((val) => val, z.object({
55
+ brand: brandSchema.optional(),
56
+ chainGroup: z.string().optional(),
57
+ chains: z.array(z.string()).optional(),
58
+ desktop: z
59
+ .object({
60
+ chromeId: nonEmptyString.transform(transformChromeExtensionId),
61
+ edgeId: nonEmptyString.transform(transformEdgeExtensionId),
62
+ firefoxId: nonEmptyString.transform(transformFirefoxExtensionId),
63
+ native: nonEmptyString,
64
+ operaId: nonEmptyString,
65
+ safariId: nonEmptyString,
66
+ universal: nonEmptyString,
67
+ })
68
+ .optional()
69
+ .transform(filterEmptyObject),
70
+ eip6963Config: z.object({ rdns: z.string() }).optional(),
71
+ filterFromWalletConnect: z.boolean().optional(),
72
+ group: z.string().optional(),
73
+ /**
74
+ * Indicates which hardware wallets are enabled for this wallet
75
+ */
76
+ hardwareWallets: z.array(z.string()).optional(),
77
+ injectedConfig: z.array(injectedConfigSchema).optional(),
78
+ mobile: z
79
+ .object({
80
+ android: string().nullish(),
81
+ androidId: nonEmptyString.transform(transformAndroidId),
82
+ inAppBrowser: string().nullish(),
83
+ ios: string().nullish(),
84
+ iosId: nonEmptyString.transform(transformIosId),
85
+ native: nonEmptyString,
86
+ universal: nonEmptyString,
87
+ })
88
+ .optional()
89
+ .transform(filterEmptyObject),
90
+ mobileExperience: z.enum(['in-app-browser', 'redirect']).optional(),
91
+ name: z.string(),
92
+ shortName: nonEmptyString,
93
+ showOnlyIfInstalled: z.boolean().optional(),
94
+ switchNetworkOnlyFromWallet: z.boolean().optional(),
95
+ walletConnect: z
96
+ .object({
97
+ sdks: nonEmptyStringArray,
98
+ })
99
+ .optional()
100
+ .transform(filterEmptyObject),
101
+ walletGroup: z.string().optional(),
102
+ /**
103
+ * Indicates which connector methods/events are not supported, keyed by wallet type
104
+ */
105
+ walletLimitations: z
106
+ .object({
107
+ browserExtension: z
108
+ .object({
109
+ unsupportedEvents: z.array(z.string()).optional(),
110
+ unsupportedMethods: z.array(z.string()).optional(),
111
+ })
112
+ .optional(),
113
+ mobile: z
114
+ .object({
115
+ unsupportedEvents: z.array(z.string()).optional(),
116
+ unsupportedMethods: z.array(z.string()).optional(),
117
+ })
118
+ .optional(),
119
+ })
120
+ .optional(),
121
+ }))
122
+ .transform((val) => {
123
+ var _a, _b, _c, _d, _e, _f;
124
+ if (val.group) {
125
+ val.chainGroup = val.group;
126
+ }
127
+ if (((_a = val.mobile) === null || _a === void 0 ? void 0 : _a.iosId) || ((_b = val.mobile) === null || _b === void 0 ? void 0 : _b.ios) === null) {
128
+ (_c = val.mobile) === null || _c === void 0 ? true : delete _c.ios;
129
+ }
130
+ if (((_d = val.mobile) === null || _d === void 0 ? void 0 : _d.androidId) || ((_e = val.mobile) === null || _e === void 0 ? void 0 : _e.android) === null) {
131
+ (_f = val.mobile) === null || _f === void 0 ? true : delete _f.android;
132
+ }
133
+ return val;
134
+ });
135
+
136
+ export { brandSchema, walletSchema };