@@ -8,7 +8,6 @@ use std::{
88
99use fastcrypto:: { error:: FastCryptoError , traits:: ToFromBytes } ;
1010use iota_protocol_config:: ProtocolConfig ;
11- use move_core_types:: language_storage:: TypeTag ;
1211use once_cell:: sync:: OnceCell ;
1312use schemars:: JsonSchema ;
1413use serde:: { Deserialize , Serialize } ;
@@ -23,6 +22,7 @@ use crate::{
2322 signature:: { AuthenticatorTrait , VerifyParams } ,
2423 signature_verification:: VerifiedDigestCache ,
2524 transaction:: { CallArg , InputObjectKind , ObjectArg , SharedInputObject } ,
25+ type_input:: TypeInput ,
2626} ;
2727
2828/// MoveAuthenticator is a GenericSignature variant that enables a new
@@ -35,7 +35,7 @@ pub struct MoveAuthenticator {
3535 call_args : Vec < CallArg > ,
3636 /// Type arguments for the Move authenticate function
3737 #[ schemars( with = "String" ) ]
38- type_arguments : Vec < TypeTag > , // TypeInput???
38+ type_arguments : Vec < TypeInput > ,
3939 /// The object that is authenticated. Represents the account being the
4040 /// sender of the transaction.
4141 object_to_authenticate : CallArg ,
@@ -56,7 +56,7 @@ impl Hash for MoveAuthenticator {
5656impl MoveAuthenticator {
5757 pub fn new_for_testing (
5858 call_args : Vec < CallArg > ,
59- type_arguments : Vec < TypeTag > ,
59+ type_arguments : Vec < TypeInput > ,
6060 object_to_authenticate : CallArg ,
6161 ) -> Self {
6262 Self {
@@ -80,7 +80,7 @@ impl MoveAuthenticator {
8080 & self . call_args
8181 }
8282
83- pub fn type_arguments ( & self ) -> & Vec < TypeTag > {
83+ pub fn type_arguments ( & self ) -> & Vec < TypeInput > {
8484 & self . type_arguments
8585 }
8686
@@ -142,30 +142,51 @@ impl MoveAuthenticator {
142142 . collect ( )
143143 }
144144
145- /// Validity check for the MoveAuthenticator.
145+ /// Validity check for MoveAuthenticator.
146146 pub fn validity_check ( & self , config : & ProtocolConfig ) -> UserInputResult {
147147 // Check that the object to authenticate is valid.
148148 self . object_to_authenticate_components ( ) ?;
149149
150150 // Inputs validity check.
151-
151+ //
152152 // `validity_check` is not called for `object_to_authenticate` because it is
153153 // already validated with a dedicated function.
154154
155+ // `ProtocolConfig::max_arguments` is used to check the call arguments because
156+ // MoveAuthenticator is considered as a simple programmable Move call.
157+ fp_ensure ! (
158+ self . call_args( ) . len( ) < ( config. max_arguments( ) as usize ) ,
159+ UserInputError :: SizeLimitExceeded {
160+ limit: "maximum arguments in MoveAuthenticator" . to_string( ) ,
161+ value: config. max_arguments( ) . to_string( )
162+ }
163+ ) ;
164+
165+ // TODO: should we handle duplicate inputs somehow?
166+
155167 self . call_args ( )
156168 . iter ( )
157169 . try_for_each ( |obj| obj. validity_check ( config) ) ?;
158170
159- if self . receiving_objects ( ) . len ( ) > 0 {
160- return Err ( UserInputError :: Unsupported (
171+ fp_ensure ! (
172+ self . receiving_objects( ) . is_empty( ) ,
173+ UserInputError :: Unsupported (
161174 "MoveAuthenticator cannot have receiving objects as input" . to_string( ) ,
162175 )
163- . into ( ) ) ;
164- }
176+ ) ;
165177
166- // TODO: check max arguments amount.
167- // TODO: should we handle duplicate inputs somehow?
168- // TODO: TypeTag -> TypeInput and validate.
178+ // Type arguments validity check.
179+ //
180+ // Each type argument is checked for validity in the same way as it is done for
181+ // `ProgrammableMoveCall`.
182+ let mut type_arguments_count = 0 ;
183+ self . type_arguments ( ) . iter ( ) . try_for_each ( |type_arg| {
184+ crate :: transaction:: type_input_validity_check (
185+ type_arg,
186+ config,
187+ & mut type_arguments_count,
188+ )
189+ } ) ?;
169190
170191 Ok ( ( ) )
171192 }
0 commit comments