Skip to content

Commit

Permalink
Update chain-factory endpoint to use new struct
Browse files Browse the repository at this point in the history
Signed-off-by: Andrei Baltariu <[email protected]>
  • Loading branch information
andreiblt1304 committed Dec 19, 2024
1 parent 1518ac2 commit 31d75ab
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 24 deletions.
15 changes: 3 additions & 12 deletions chain-factory/src/factory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use proxies::{
fee_market_proxy::{FeeMarketProxy, FeeStruct},
header_verifier_proxy::HeaderverifierProxy,
};
use transaction::StakeArgs;
use transaction::SovereignConfig;
multiversx_sc::derive_imports!();

#[multiversx_sc::module]
Expand All @@ -16,24 +16,15 @@ pub trait FactoryModule: only_admin::OnlyAdminModule {
#[endpoint(deploySovereignChainConfigContract)]
fn deploy_sovereign_chain_config_contract(
&self,
min_validators: u64,
max_validators: u64,
min_stake: BigUint,
additional_stake_required: MultiValueEncoded<StakeArgs<Self::Api>>,
config: SovereignConfig<Self::Api>,
) -> ManagedAddress {
let caller = self.blockchain().get_caller();
let source_address = self.chain_config_template().get();
let metadata = self.blockchain().get_code_metadata(&source_address);

self.tx()
.typed(ChainConfigContractProxy)
.init(
min_validators,
max_validators,
min_stake,
&caller,
additional_stake_required,
)
.init(config, &caller)
.gas(60_000_000)
.from_source(source_address)
.code_metadata(metadata)
Expand Down
15 changes: 3 additions & 12 deletions common/proxies/src/chain_factory_proxy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,24 +98,15 @@ where
Gas: TxGas<Env>,
{
pub fn deploy_sovereign_chain_config_contract<
Arg0: ProxyArg<u64>,
Arg1: ProxyArg<u64>,
Arg2: ProxyArg<BigUint<Env::Api>>,
Arg3: ProxyArg<MultiValueEncoded<Env::Api, transaction::StakeArgs<Env::Api>>>,
Arg0: ProxyArg<transaction::SovereignConfig<Env::Api>>,
>(
self,
min_validators: Arg0,
max_validators: Arg1,
min_stake: Arg2,
additional_stake_required: Arg3,
config: Arg0,
) -> TxTypedCall<Env, From, To, NotPayable, Gas, ManagedAddress<Env::Api>> {
self.wrapped_tx
.payment(NotPayable)
.raw_call("deploySovereignChainConfigContract")
.argument(&min_validators)
.argument(&max_validators)
.argument(&min_stake)
.argument(&additional_stake_required)
.argument(&config)
.original_result()
}

Expand Down

0 comments on commit 31d75ab

Please sign in to comment.