@@ -2,6 +2,10 @@ import { z } from "zod";
2
2
import { isAddress } from "viem" ;
3
3
import { normalize } from "viem/ens" ;
4
4
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
+
5
9
export const ethAddressSchema = z . string ( ) . refine ( ( value ) => isAddress ( value ) , {
6
10
message : "Provided address is invalid." ,
7
11
} ) ;
@@ -26,40 +30,41 @@ export enum QuestionType {
26
30
export const QuestionTypeSchema = z . nativeEnum ( QuestionType ) ;
27
31
28
32
export 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
30
37
title : z . string ( ) ,
31
38
description : z . string ( ) ,
32
- reserved : z . boolean ( ) ,
39
+ reserved : z . boolean ( ) . optional ( ) ,
33
40
} ) ;
34
41
35
42
export const AttachmentSchema = z . object ( {
36
43
label : z . string ( ) ,
37
44
uri : z . string ( ) ,
38
45
} ) ;
39
46
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 ( ) ) ;
45
50
46
51
const DisputeDetailsSchema = z . object ( {
47
52
title : z . string ( ) ,
48
53
description : z . string ( ) ,
49
54
question : z . string ( ) ,
50
- type : QuestionTypeSchema ,
51
55
answers : z . array ( AnswerSchema ) ,
52
56
policyURI : z . string ( ) ,
53
- attachment : AttachmentSchema ,
57
+ attachment : AttachmentSchema . optional ( ) ,
54
58
frontendUrl : z . string ( ) ,
59
+ metadata : MetadataSchema . optional ( ) ,
55
60
arbitrableChainID : z . string ( ) ,
56
- arbitrableAddress : ethAddressSchema ,
61
+ arbitrableAddress : z . string ( ) , // should be changed for ethAddressSchema eventually
57
62
arbitratorChainID : z . string ( ) ,
58
- arbitratorAddress : ethAddressSchema ,
63
+ arbitratorAddress : z . string ( ) , // should be changed for ethAddressSchema eventually
59
64
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 ( ) ,
63
68
version : z . string ( ) ,
64
69
} ) ;
65
70
0 commit comments