@@ -778,6 +778,14 @@ impl<Runtime: ContractRuntime> CallInterceptorContract<Runtime> {
778778 Ok ( ApplicationId :: from ( & application_description) )
779779 }
780780
781+ /// Publishes the `input`.
782+ fn publish_create_inputs ( context : & mut Ctx < ' _ , Runtime > , inputs : & mut CreateInputs ) -> Result < ModuleId , ExecutionError > {
783+ let contract = linera_base:: data_types:: Bytecode :: new ( inputs. init_code . to_vec ( ) ) ;
784+ let service = linera_base:: data_types:: Bytecode :: new ( vec ! [ ] ) ;
785+ let mut runtime = context. db ( ) . 0 . runtime . lock ( ) . unwrap ( ) ;
786+ runtime. publish_module ( contract, service, VmRuntime :: Evm )
787+ }
788+
781789 /// The function `fn create` of the inspector trait is called
782790 /// when a contract is going to be instantiated. Since the
783791 /// function can have some error case which are not supported
@@ -891,19 +899,10 @@ impl<Runtime: ContractRuntime> CallInterceptorContract<Runtime> {
891899 inputs. value ,
892900 ) ?;
893901 }
894- let contract = linera_base:: data_types:: Bytecode :: new ( inputs. init_code . to_vec ( ) ) ;
895- let service = linera_base:: data_types:: Bytecode :: new ( vec ! [ ] ) ;
902+ let module_id = Self :: publish_create_inputs ( context, inputs) ?;
896903 let mut runtime = context. db ( ) . 0 . runtime . lock ( ) . unwrap ( ) ;
897- let module_id = runtime. publish_module ( contract, service, VmRuntime :: Evm ) ?;
898904 let chain_id = runtime. chain_id ( ) ?;
899905 let application_id = runtime. application_id ( ) ?;
900- let parameters = JSON_EMPTY_VECTOR . to_vec ( ) ; // No constructor
901- let evm_call = EvmInstantiation {
902- value : inputs. value ,
903- argument : Vec :: new ( ) ,
904- } ;
905- let argument = serde_json:: to_vec ( & evm_call) ?;
906- let required_application_ids = Vec :: new ( ) ;
907906 let expected_application_id = Self :: get_expected_application_id ( & mut runtime, module_id) ?;
908907 if inputs. value != U256 :: ZERO {
909908 let amount = Amount :: try_from ( inputs. value ) . map_err ( EvmExecutionError :: from) ?;
@@ -914,6 +913,13 @@ impl<Runtime: ContractRuntime> CallInterceptorContract<Runtime> {
914913 let source = application_id. into ( ) ;
915914 runtime. transfer ( source, destination, amount) ?;
916915 }
916+ let parameters = JSON_EMPTY_VECTOR . to_vec ( ) ; // No constructor
917+ let evm_call = EvmInstantiation {
918+ value : inputs. value ,
919+ argument : Vec :: new ( ) ,
920+ } ;
921+ let argument = serde_json:: to_vec ( & evm_call) ?;
922+ let required_application_ids = Vec :: new ( ) ;
917923 let created_application_id = runtime. create_application (
918924 module_id,
919925 parameters,
0 commit comments