@@ -62,7 +62,7 @@ function getAllPropertyNamesOfPrototypeChain(type: unknown): string[] {
62
62
) ;
63
63
}
64
64
65
- function isFlexibleProvablePure (
65
+ export function isFlexibleProvablePure (
66
66
type : unknown
67
67
) : type is FlexibleProvablePure < unknown > {
68
68
// The required properties are defined on the prototype for Structs and CircuitValues
@@ -73,35 +73,43 @@ function isFlexibleProvablePure(
73
73
return mandatory . every ( ( prop ) => props . includes ( prop ) ) ;
74
74
}
75
75
76
- export class MethodParameterEncoder {
77
- public static fromMethod ( target : RuntimeModule < unknown > , methodName : string ) {
78
- // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
79
- const paramtypes : ArgTypeArray = Reflect . getMetadata (
80
- "design:paramtypes" ,
81
- target ,
82
- methodName
76
+ export function checkArgsProvable (
77
+ target : RuntimeModule < unknown > ,
78
+ methodName : string
79
+ ) {
80
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
81
+ const paramtypes : ArgTypeArray = Reflect . getMetadata (
82
+ "design:paramtypes" ,
83
+ target ,
84
+ methodName
85
+ ) ;
86
+
87
+ if ( paramtypes === undefined ) {
88
+ throw new Error (
89
+ `Method with name ${ methodName } doesn't exist on this module`
83
90
) ;
91
+ }
84
92
85
- if ( paramtypes === undefined ) {
86
- throw new Error (
87
- `Method with name ${ methodName } doesn't exist on this module`
88
- ) ;
89
- }
93
+ const indizes = paramtypes
94
+ . map ( ( type , index ) => {
95
+ if ( isFlexibleProvablePure ( type ) ) {
96
+ return undefined ;
97
+ }
98
+ return `${ index } ` ;
99
+ } )
100
+ . filter ( filterNonUndefined ) ;
101
+ if ( indizes . length > 0 ) {
102
+ const indexString = indizes . reduce ( ( a , b ) => `${ a } , ${ b } ` ) ;
103
+ throw new Error (
104
+ `Not all arguments of method '${ target . name } .${ methodName } ' are provable types or proofs (indizes: [${ indexString } ])`
105
+ ) ;
106
+ }
107
+ return paramtypes ;
108
+ }
90
109
91
- const indizes = paramtypes
92
- . map ( ( type , index ) => {
93
- if ( isProofBaseType ( type ) || isFlexibleProvablePure ( type ) ) {
94
- return undefined ;
95
- }
96
- return `${ index } ` ;
97
- } )
98
- . filter ( filterNonUndefined ) ;
99
- if ( indizes . length > 0 ) {
100
- const indexString = indizes . reduce ( ( a , b ) => `${ a } , ${ b } ` ) ;
101
- throw new Error (
102
- `Not all arguments of method '${ target . name } .${ methodName } ' are provable types or proofs (indizes: [${ indexString } ])`
103
- ) ;
104
- }
110
+ export class MethodParameterEncoder {
111
+ public static fromMethod ( target : RuntimeModule < unknown > , methodName : string ) {
112
+ const paramtypes = checkArgsProvable ( target , methodName ) ;
105
113
106
114
return new MethodParameterEncoder ( paramtypes ) ;
107
115
}
0 commit comments