File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ ---
2+ ' @hyperlane-xyz/sdk ' : patch
3+ ---
4+
5+ Replaced z.coerce.bigint().positive() with pipe-based coercion in TokenMetadataSchema scale field to fix zod-to-json-schema compatibility in the registry build.
Original file line number Diff line number Diff line change @@ -33,6 +33,33 @@ export const contractVersionMatchesDependency = (version: string) => {
3333
3434export const VERSION_ERROR_MESSAGE = `Contract version must match the @hyperlane-xyz/core dependency version (${ CONTRACTS_PACKAGE_VERSION } )` ;
3535
36+ /**
37+ * Coerces bigint or string to bigint with positivity check.
38+ * Needed because bigints are serialised as strings in JSON/YAML
39+ * and must be converted back on parse. Uses .refine() instead of
40+ * .positive() to avoid bigint values in zod-to-json-schema output.
41+ */
42+ const PositiveBigIntFromString = z
43+ . union ( [
44+ z . bigint ( ) ,
45+ z
46+ . string ( )
47+ . refine (
48+ ( s ) => {
49+ try {
50+ BigInt ( s ) ;
51+ return true ;
52+ } catch {
53+ return false ;
54+ }
55+ } ,
56+ { message : 'Must be a bigint-compatible string' } ,
57+ )
58+ . transform ( ( s ) => BigInt ( s ) ) ,
59+ ] )
60+ . pipe ( z . bigint ( ) )
61+ . refine ( ( n ) => n > 0n , { message : 'Must be positive' } ) ;
62+
3663export const TokenMetadataSchema = z . object ( {
3764 name : z . string ( ) ,
3865 symbol : z . string ( ) ,
@@ -45,8 +72,8 @@ export const TokenMetadataSchema = z.object({
4572 denominator : z . number ( ) . int ( ) . gt ( 0 ) ,
4673 } ) ,
4774 z . object ( {
48- numerator : z . coerce . bigint ( ) . positive ( ) ,
49- denominator : z . coerce . bigint ( ) . positive ( ) ,
75+ numerator : PositiveBigIntFromString ,
76+ denominator : PositiveBigIntFromString ,
5077 } ) ,
5178 ] )
5279 . optional ( ) ,
You can’t perform that action at this time.
0 commit comments