@@ -3,8 +3,11 @@ import { isAddress } from "viem";
33import { normalize } from "viem/ens" ;
44
55const isHexAddress = ( str : string ) : boolean => / ^ 0 x [ a - f A - F 0 - 9 ] { 40 } $ / . test ( str ) ;
6-
76const isHexId = ( str : string ) : boolean => / ^ 0 x [ a - f A - F 0 - 9 ] { 1 , 64 } $ / . test ( str ) ;
7+ const isMultiaddr = ( str : string ) : boolean =>
8+ / ^ \/ (?: i p 4 | i p 6 | d n s 4 | d n s 6 | d n s a d d r | t c p | u d p | u t p | t l s | w s | w s s | i p f s | p 2 p - c i r c u i t | p 2 p - w e b r t c - s t a r | p 2 p - w e b r t c - d i r e c t | p 2 p - w e b s o c k e t - s t a r | o n i o n ) ( \/ [ ^ \s \/ ] + ) * $ / . test (
9+ str
10+ ) ;
811
912export const ethAddressSchema = z . string ( ) . refine ( ( value ) => isAddress ( value ) , {
1013 message : "Provided address is invalid." ,
@@ -33,7 +36,7 @@ export const AnswerSchema = z.object({
3336 id : z
3437 . string ( )
3538 . regex ( / ^ 0 x [ 0 - 9 a - f A - F ] + $ / )
36- . optional ( ) , // should be a bigint
39+ . optional ( ) ,
3740 title : z . string ( ) ,
3841 description : z . string ( ) ,
3942 reserved : z . boolean ( ) . optional ( ) ,
@@ -53,12 +56,14 @@ const DisputeDetailsSchema = z.object({
5356 description : z . string ( ) ,
5457 question : z . string ( ) ,
5558 answers : z . array ( AnswerSchema ) ,
56- policyURI : z . string ( ) ,
59+ policyURI : z . string ( ) . refine ( ( value ) => isMultiaddr ( value ) , {
60+ message : "Provided policy URI is not a valid multiaddr." ,
61+ } ) ,
5762 attachment : AttachmentSchema . optional ( ) ,
5863 frontendUrl : z . string ( ) . optional ( ) ,
5964 metadata : MetadataSchema . optional ( ) ,
6065 arbitratorChainID : z . string ( ) ,
61- arbitratorAddress : z . string ( ) , // should be changed for ethAddressSchema eventually, but some
66+ arbitratorAddress : ethAddressSchema ,
6267 category : z . string ( ) . optional ( ) ,
6368 lang : z . string ( ) . optional ( ) ,
6469 specification : z . string ( ) . optional ( ) ,
0 commit comments