@@ -2,6 +2,10 @@ import { z } from "zod";
22import { isAddress } from "viem" ;
33import { normalize } from "viem/ens" ;
44
5+ const isHexAddress = ( str : string ) : boolean => / ^ 0 x [ a - f A - F 0 - 9 ] { 40 } $ / . test ( str ) ;
6+
7+ const isHexId = ( str : string ) : boolean => / ^ 0 x [ a - f A - F 0 - 9 ] { 1 , 64 } $ / . test ( str ) ;
8+
59export const ethAddressSchema = z . string ( ) . refine ( ( value ) => isAddress ( value ) , {
610 message : "Provided address is invalid." ,
711} ) ;
@@ -26,40 +30,41 @@ export enum QuestionType {
2630export const QuestionTypeSchema = z . nativeEnum ( QuestionType ) ;
2731
2832export const AnswerSchema = z . object ( {
29- id : z . string ( ) . regex ( / ^ 0 x [ 0 - 9 a - f A - F ] + $ / ) , // should be a bigint
33+ id : z
34+ . string ( )
35+ . regex ( / ^ 0 x [ 0 - 9 a - f A - F ] + $ / )
36+ . optional ( ) , // should be a bigint
3037 title : z . string ( ) ,
3138 description : z . string ( ) ,
32- reserved : z . boolean ( ) ,
39+ reserved : z . boolean ( ) . optional ( ) ,
3340} ) ;
3441
3542export const AttachmentSchema = z . object ( {
3643 label : z . string ( ) ,
3744 uri : z . string ( ) ,
3845} ) ;
3946
40- export const AliasSchema = z . object ( {
41- id : z . string ( ) . optional ( ) ,
42- name : z . string ( ) ,
43- address : ethAddressOrEnsNameSchema ,
44- } ) ;
47+ export const AliasSchema = z . record ( ethAddressOrEnsNameSchema ) ;
48+
49+ const MetadataSchema = z . record ( z . any ( ) ) ;
4550
4651const DisputeDetailsSchema = z . object ( {
4752 title : z . string ( ) ,
4853 description : z . string ( ) ,
4954 question : z . string ( ) ,
50- type : QuestionTypeSchema ,
5155 answers : z . array ( AnswerSchema ) ,
5256 policyURI : z . string ( ) ,
53- attachment : AttachmentSchema ,
57+ attachment : AttachmentSchema . optional ( ) ,
5458 frontendUrl : z . string ( ) ,
59+ metadata : MetadataSchema . optional ( ) ,
5560 arbitrableChainID : z . string ( ) ,
56- arbitrableAddress : ethAddressSchema ,
61+ arbitrableAddress : z . string ( ) , // should be changed for ethAddressSchema eventually
5762 arbitratorChainID : z . string ( ) ,
58- arbitratorAddress : ethAddressSchema ,
63+ arbitratorAddress : z . string ( ) , // should be changed for ethAddressSchema eventually
5964 category : z . string ( ) ,
60- lang : z . string ( ) ,
61- specification : z . string ( ) ,
62- aliases : z . array ( AliasSchema ) . optional ( ) ,
65+ lang : z . string ( ) . optional ( ) ,
66+ specification : z . string ( ) . optional ( ) ,
67+ aliases : AliasSchema . optional ( ) ,
6368 version : z . string ( ) ,
6469} ) ;
6570
0 commit comments