@dynamic-labs/wallet-book 4.25.5 → 4.25.6

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.
@@ -1,5 +1,5 @@
1
1
  'use client'
2
- import { z, string } from 'zod';
2
+ import * as z from 'zod/mini';
3
3
  import { filterEmptyObject } from './utils/filterEmptyObject.js';
4
4
  import { nonEmptyString } from './utils/nonEmptyString.js';
5
5
  import { nonEmptyStringArray } from './utils/nonEmptyStringArray.js';
@@ -9,36 +9,30 @@ import { transformEdgeExtensionId } from './utils/transformEdgeExtensionId.js';
9
9
  import { transformFirefoxExtensionId } from './utils/transformFirefoxExtensionId.js';
10
10
  import { transformIosId } from './utils/transformIosId.js';
11
11
 
12
+ // eslint-disable-next-line import/no-extraneous-dependencies, import/no-namespace
12
13
  const injectedConfigSchema = z.object({
13
14
  chain: z.string(),
14
15
  extensionLocators: z.array(z.object({
15
16
  flag: z.string(),
16
- value: z.boolean().optional().default(true),
17
+ value: z._default(z.optional(z.boolean()), true),
17
18
  })),
18
19
  /**
19
20
  * Allows declaring which interface, if any, this wallet's implementation follows
20
21
  * ex. Leather with https://btckit.org/
21
22
  */
22
- providerInterface: z.string().optional(),
23
+ providerInterface: z.optional(z.string()),
23
24
  /**
24
25
  * Allows declaring that this wallet is discoverable through the the Wallet Standard
25
26
  * See https://github.com/wallet-standard/wallet-standard
26
27
  * Also allows ignoring wallets that don't support the provided features
27
28
  */
28
- walletStandard: z
29
- .object({
29
+ walletStandard: z.optional(z.object({
30
30
  features: z.array(z.string()),
31
31
  name: z.string(),
32
- providerId: z.string().optional(),
33
- })
34
- .optional(),
35
- walletStandardLocators: z
36
- .array(z.object({ locator: z.string(), name: z.string() }))
37
- .optional(),
38
- windowLocations: z
39
- .array(z.string())
40
- .optional()
41
- .refine((val) => {
32
+ providerId: z.optional(z.string()),
33
+ })),
34
+ walletStandardLocators: z.optional(z.array(z.object({ locator: z.string(), name: z.string() }))),
35
+ windowLocations: z.optional(z.array(z.string())).check(z.refine((val) => {
42
36
  if (!val)
43
37
  return true;
44
38
  if (!val.some((v) => ['ethereum', 'ethereum.providers'].includes(v)))
@@ -47,87 +41,70 @@ const injectedConfigSchema = z.object({
47
41
  }, {
48
42
  message: 'windowLocations cannot include ethereum or ethereum.providers as they are included by default',
49
43
  path: ['config'],
50
- }),
44
+ })),
51
45
  });
52
46
  const brandSchema = z.object({
53
47
  alt: nonEmptyString,
54
48
  primaryColor: nonEmptyString,
55
49
  spriteId: nonEmptyString,
56
50
  });
57
- const walletSchema = z
58
- .preprocess((val) => val, z.object({
59
- brand: brandSchema.optional(),
60
- chainGroup: z.string().optional(),
61
- chains: z.array(z.string()).optional(),
62
- desktop: z
63
- .object({
64
- chromeId: nonEmptyString.transform(transformChromeExtensionId),
65
- edgeId: nonEmptyString.transform(transformEdgeExtensionId),
66
- firefoxId: nonEmptyString.transform(transformFirefoxExtensionId),
51
+ const walletSchema = z.pipe(z.pipe(z.transform((val) => val), z.object({
52
+ brand: z.optional(brandSchema),
53
+ chainGroup: z.optional(z.string()),
54
+ chains: z.optional(z.array(z.string())),
55
+ desktop: z.optional(z.pipe(z.object({
56
+ chromeId: z.optional(z.pipe(nonEmptyString, z.transform(transformChromeExtensionId))),
57
+ edgeId: z.optional(z.pipe(nonEmptyString, z.transform(transformEdgeExtensionId))),
58
+ firefoxId: z.optional(z.pipe(nonEmptyString, z.transform(transformFirefoxExtensionId))),
67
59
  native: nonEmptyString,
68
60
  operaId: nonEmptyString,
69
61
  safariId: nonEmptyString,
70
62
  universal: nonEmptyString,
71
- })
72
- .optional()
73
- .transform(filterEmptyObject),
74
- eip6963Config: z.object({ rdns: z.string() }).optional(),
75
- filterFromWalletConnect: z.boolean().optional(),
76
- group: z.string().optional(),
63
+ }), z.transform(filterEmptyObject))),
64
+ eip6963Config: z.optional(z.object({ rdns: z.string() })),
65
+ filterFromWalletConnect: z.optional(z.boolean()),
66
+ group: z.optional(z.string()),
77
67
  /**
78
68
  * Indicates which hardware wallets are enabled for this wallet
79
69
  */
80
- hardwareWallets: z.array(z.string()).optional(),
81
- injectedConfig: z.array(injectedConfigSchema).optional(),
82
- mobile: z
83
- .object({
84
- android: string().nullish(),
85
- androidId: nonEmptyString.transform(transformAndroidId),
70
+ hardwareWallets: z.optional(z.array(z.string())),
71
+ injectedConfig: z.optional(z.array(injectedConfigSchema)),
72
+ mobile: z.optional(z.pipe(z.optional(z.object({
73
+ android: z.nullish(z.string()),
74
+ androidId: z.optional(z.pipe(nonEmptyString, z.transform(transformAndroidId))),
86
75
  /**
87
76
  * @deprecated Use inAppBrowserV2 instead for EVM wallet deep linking
88
77
  */
89
- inAppBrowser: string().nullish(),
90
- inAppBrowserV2: string().nullish(),
91
- ios: string().nullish(),
92
- iosId: nonEmptyString.transform(transformIosId),
78
+ inAppBrowser: z.nullish(z.string()),
79
+ inAppBrowserV2: z.nullish(z.string()),
80
+ ios: z.nullish(z.string()),
81
+ iosId: z.optional(z.pipe(nonEmptyString, z.transform(transformIosId))),
93
82
  native: nonEmptyString,
94
83
  universal: nonEmptyString,
95
- })
96
- .optional()
97
- .transform(filterEmptyObject),
98
- mobileExperience: z.enum(['in-app-browser', 'redirect']).optional(),
84
+ })), z.transform(filterEmptyObject))),
85
+ mobileExperience: z.optional(z.enum(['in-app-browser', 'redirect'])),
99
86
  name: z.string(),
100
87
  shortName: nonEmptyString,
101
- showOnlyIfInstalled: z.boolean().optional(),
102
- switchNetworkOnlyFromWallet: z.boolean().optional(),
103
- walletConnect: z
104
- .object({
88
+ showOnlyIfInstalled: z.optional(z.boolean()),
89
+ switchNetworkOnlyFromWallet: z.optional(z.boolean()),
90
+ walletConnect: z.optional(z.pipe(z.optional(z.object({
105
91
  sdks: nonEmptyStringArray,
106
- })
107
- .optional()
108
- .transform(filterEmptyObject),
109
- walletGroup: z.string().optional(),
92
+ })), z.transform(filterEmptyObject))),
93
+ walletGroup: z.optional(z.string()),
110
94
  /**
111
95
  * Indicates which connector methods/events are not supported, keyed by wallet type
112
96
  */
113
- walletLimitations: z
114
- .object({
115
- browserExtension: z
116
- .object({
117
- unsupportedEvents: z.array(z.string()).optional(),
118
- unsupportedMethods: z.array(z.string()).optional(),
119
- })
120
- .optional(),
121
- mobile: z
122
- .object({
123
- unsupportedEvents: z.array(z.string()).optional(),
124
- unsupportedMethods: z.array(z.string()).optional(),
125
- })
126
- .optional(),
127
- })
128
- .optional(),
129
- }))
130
- .transform((val) => {
97
+ walletLimitations: z.optional(z.object({
98
+ browserExtension: z.optional(z.object({
99
+ unsupportedEvents: z.optional(z.array(z.string())),
100
+ unsupportedMethods: z.optional(z.array(z.string())),
101
+ })),
102
+ mobile: z.optional(z.object({
103
+ unsupportedEvents: z.optional(z.array(z.string())),
104
+ unsupportedMethods: z.optional(z.array(z.string())),
105
+ })),
106
+ })),
107
+ })), z.transform((val) => {
131
108
  var _a, _b, _c, _d, _e, _f;
132
109
  if (val.group) {
133
110
  val.chainGroup = val.group;
@@ -139,6 +116,6 @@ const walletSchema = z
139
116
  (_f = val.mobile) === null || _f === void 0 ? true : delete _f.android;
140
117
  }
141
118
  return val;
142
- });
119
+ }));
143
120
 
144
121
  export { brandSchema, walletSchema };
@@ -590,7 +590,7 @@ var wallets = {
590
590
  edgeId: "ajcicjlkibolbeaaagejfhnofogocgcj",
591
591
  firefoxId: "argent-x"
592
592
  },
593
- name: "Argent X",
593
+ name: "Ready Wallet (formerly Argent)",
594
594
  shortName: "Ready Wallet (formerly Argent)"
595
595
  },
596
596
  perawallet: {
@@ -586,7 +586,7 @@ var wallets = {
586
586
  edgeId: "ajcicjlkibolbeaaagejfhnofogocgcj",
587
587
  firefoxId: "argent-x"
588
588
  },
589
- name: "Argent X",
589
+ name: "Ready Wallet (formerly Argent)",
590
590
  shortName: "Ready Wallet (formerly Argent)"
591
591
  },
592
592
  perawallet: {