11#![ allow( non_upper_case_globals) ]
2- use loam_sdk:: soroban_sdk:: { self , contracttype, env, vec, Address , BytesN , Map , String , Lazy , Symbol , symbol_short} ;
3-
4- use crate :: { error:: Error , registry:: Publishable , util:: { hash_string, MAX_BUMP } , version:: Version , Contract } ;
2+ use loam_sdk:: soroban_sdk:: {
3+ self , contracttype, env, symbol_short, vec, Address , BytesN , Lazy , Map , String , Symbol , Val ,
4+ } ;
5+
6+ use crate :: {
7+ error:: Error ,
8+ registry:: Publishable ,
9+ util:: { hash_string, MAX_BUMP } ,
10+ version:: Version ,
11+ Contract ,
12+ } ;
513
614use super :: { IsDeployable , IsDevDeployable } ;
715
8-
916loam_sdk:: import_contract!( core_riff) ;
1017
11- // Is the same as
18+ // Is the same as
1219
1320// mod core_riff {
1421// use loam_sdk::soroban_sdk;
1522// loam_sdk::soroban_sdk::contractimport!(file = "../../target/loam/core_riff.wasm",);
1623// }
1724
18-
1925#[ contracttype( export = false ) ]
2026pub struct ContractRegistry ( pub Map < String , Address > ) ;
2127
@@ -29,7 +35,6 @@ fn key() -> Symbol {
2935 symbol_short ! ( "contractR" )
3036}
3137
32-
3338impl Lazy for ContractRegistry {
3439 fn get_lazy ( ) -> Option < Self > {
3540 env ( ) . storage ( ) . persistent ( ) . get ( & key ( ) )
@@ -57,6 +62,7 @@ impl IsDeployable for ContractRegistry {
5762 deployed_name : String ,
5863 owner : Address ,
5964 salt : Option < BytesN < 32 > > ,
65+ init : Option < ( Symbol , soroban_sdk:: Vec < soroban_sdk:: Val > ) > ,
6066 ) -> Result < Address , Error > {
6167 if self . 0 . contains_key ( deployed_name. clone ( ) ) {
6268 return Err ( Error :: NoSuchContractDeployed ) ;
@@ -66,6 +72,9 @@ impl IsDeployable for ContractRegistry {
6672 let hash = Contract :: fetch_hash ( contract_name, version) ?;
6773 let salt = salt. unwrap_or_else ( || hash_string ( & deployed_name) ) ;
6874 let address = deploy_and_init ( & owner, salt, hash) ?;
75+ if let Some ( ( init_fn, args) ) = init {
76+ let _ = env ( ) . invoke_contract :: < Val > ( & address, & init_fn, args) ;
77+ }
6978 self . 0 . set ( deployed_name, address. clone ( ) ) ;
7079 Ok ( address)
7180 }
0 commit comments