From ad67803ac938b71a961d55cbb1e3ba1dd71b493b Mon Sep 17 00:00:00 2001 From: Andrei Baltariu Date: Wed, 11 Dec 2024 14:18:15 +0200 Subject: [PATCH 1/8] Added `deploy_phase_four` endpoint Signed-off-by: Andrei Baltariu --- sovereign-forge/src/common/sc_deploy.rs | 16 +++++++++++++++- sovereign-forge/src/common/utils.rs | 7 +++++++ sovereign-forge/src/phases.rs | 21 +++++++++++++++++++++ 3 files changed, 43 insertions(+), 1 deletion(-) diff --git a/sovereign-forge/src/common/sc_deploy.rs b/sovereign-forge/src/common/sc_deploy.rs index 95259150..765013de 100644 --- a/sovereign-forge/src/common/sc_deploy.rs +++ b/sovereign-forge/src/common/sc_deploy.rs @@ -1,6 +1,6 @@ use crate::err_msg; use multiversx_sc::types::{MultiValueEncoded, ReturnsResult}; -use proxies::chain_factory_proxy::ChainFactoryContractProxy; +use proxies::{chain_factory_proxy::ChainFactoryContractProxy, fee_market_proxy::FeeStruct}; use transaction::StakeMultiArg; #[multiversx_sc::module] @@ -49,4 +49,18 @@ pub trait ScDeployModule: super::utils::UtilsModule + super::storage::StorageMod .returns(ReturnsResult) .sync_call() } + + #[inline] + fn deploy_fee_market( + &self, + esdt_safe_address: &ManagedAddress, + fee: Option>, + ) -> ManagedAddress { + self.tx() + .to(self.get_chain_factory_address()) + .typed(ChainFactoryContractProxy) + .deploy_fee_market(esdt_safe_address, fee) + .returns(ReturnsResult) + .sync_call() + } } diff --git a/sovereign-forge/src/common/utils.rs b/sovereign-forge/src/common/utils.rs index 9f210533..8c5bd2c1 100644 --- a/sovereign-forge/src/common/utils.rs +++ b/sovereign-forge/src/common/utils.rs @@ -39,6 +39,13 @@ pub enum ScArray { #[multiversx_sc::module] pub trait UtilsModule: super::storage::StorageModule { + fn require_phase_three_completed(&self, caller: &ManagedAddress) { + require!( + self.is_contract_deployed(caller, ScArray::ESDTSafe), + "The Header-Verifier SC is not deployed, you skipped the second phase" + ); + } + fn require_phase_two_completed(&self, caller: &ManagedAddress) { require!( self.is_contract_deployed(caller, ScArray::HeaderVerifier), diff --git a/sovereign-forge/src/phases.rs b/sovereign-forge/src/phases.rs index 4fc4e3a7..777a69a4 100644 --- a/sovereign-forge/src/phases.rs +++ b/sovereign-forge/src/phases.rs @@ -1,5 +1,6 @@ use crate::err_msg; use core::ops::Deref; +use proxies::fee_market_proxy::FeeStruct; use transaction::StakeMultiArg; use multiversx_sc::{require, types::MultiValueEncoded}; @@ -127,4 +128,24 @@ pub trait PhasesModule: self.sovereign_deployed_contracts(&self.sovereigns_mapper(&caller).get()) .insert(esdt_safe_contract_info); } + + #[endpoint(deployPhaseFour)] + fn deploy_phase_four(&self, fee: Option>) { + let caller = self.blockchain().get_caller(); + + self.require_phase_three_completed(&caller); + require!( + !self.is_contract_deployed(&caller, ScArray::FeeMarket), + "The Fee-Market SC is already deployed" + ); + + let esdt_safe_address = self.get_contract_address(&caller, ScArray::ESDTSafe); + + let fee_market_address = self.deploy_fee_market(&esdt_safe_address, fee); + + let fee_market_contract_info = ContractInfo::new(ScArray::FeeMarket, fee_market_address); + + self.sovereign_deployed_contracts(&self.sovereigns_mapper(&caller).get()) + .insert(fee_market_contract_info); + } } From 2f07c42d968fc76767e3299f100128155326140b Mon Sep 17 00:00:00 2001 From: Andrei Baltariu Date: Wed, 11 Dec 2024 14:27:21 +0200 Subject: [PATCH 2/8] Added fee-market as dependency Signed-off-by: Andrei Baltariu --- Cargo.lock | 1 + sovereign-forge/Cargo.toml | 3 +++ 2 files changed, 4 insertions(+) diff --git a/Cargo.lock b/Cargo.lock index 49e0494a..094c8454 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2141,6 +2141,7 @@ dependencies = [ "chain-config", "chain-factory", "esdt-safe", + "fee-market", "header-verifier", "multiversx-sc", "multiversx-sc-modules", diff --git a/sovereign-forge/Cargo.toml b/sovereign-forge/Cargo.toml index 0869d99e..6ed26821 100644 --- a/sovereign-forge/Cargo.toml +++ b/sovereign-forge/Cargo.toml @@ -23,6 +23,9 @@ path = "../chain-config" [dependencies.header-verifier] path = "../header-verifier" +[dependencies.fee-market] +path = "../fee-market" + [dependencies.esdt-safe] path = "../esdt-safe" From 9872203a3730c007b2496b5f3e52f1ef428a4190 Mon Sep 17 00:00:00 2001 From: Andrei Baltariu Date: Wed, 11 Dec 2024 14:32:06 +0200 Subject: [PATCH 3/8] Added proxy rename + regen Signed-off-by: Andrei Baltariu --- common/proxies/src/sovereign_forge_proxy.rs | 13 +++++++++++++ sovereign-forge/sc-config.toml | 4 ++++ .../wasm-sovereign-forge-full/Cargo.lock | 1 + .../wasm-sovereign-forge-full/src/lib.rs | 5 +++-- .../wasm-soveriegn-forge-view/Cargo.lock | 1 + sovereign-forge/wasm/Cargo.lock | 1 + sovereign-forge/wasm/src/lib.rs | 5 +++-- 7 files changed, 26 insertions(+), 4 deletions(-) diff --git a/common/proxies/src/sovereign_forge_proxy.rs b/common/proxies/src/sovereign_forge_proxy.rs index d45bf090..48de77cb 100644 --- a/common/proxies/src/sovereign_forge_proxy.rs +++ b/common/proxies/src/sovereign_forge_proxy.rs @@ -173,6 +173,19 @@ where .original_result() } + pub fn deploy_phase_four< + Arg0: ProxyArg>>, + >( + self, + fee: Arg0, + ) -> TxTypedCall { + self.wrapped_tx + .payment(NotPayable) + .raw_call("deployPhaseFour") + .argument(&fee) + .original_result() + } + pub fn chain_factories< Arg0: ProxyArg, >( diff --git a/sovereign-forge/sc-config.toml b/sovereign-forge/sc-config.toml index 163cb6f7..56baf08c 100644 --- a/sovereign-forge/sc-config.toml +++ b/sovereign-forge/sc-config.toml @@ -17,3 +17,7 @@ add-labels = ["sovereign-forge-external-view"] [[proxy]] path = "../common/proxies/src/sovereign_forge_proxy.rs" + +[[proxy.path-rename]] +from = "proxies::fee_market_proxy::FeeStruct" +to = "super::fee_market_proxy::FeeStruct" diff --git a/sovereign-forge/wasm-sovereign-forge-full/Cargo.lock b/sovereign-forge/wasm-sovereign-forge-full/Cargo.lock index 988f1192..f46cced9 100644 --- a/sovereign-forge/wasm-sovereign-forge-full/Cargo.lock +++ b/sovereign-forge/wasm-sovereign-forge-full/Cargo.lock @@ -258,6 +258,7 @@ dependencies = [ "chain-config", "chain-factory", "esdt-safe", + "fee-market", "header-verifier", "multiversx-sc", "multiversx-sc-modules", diff --git a/sovereign-forge/wasm-sovereign-forge-full/src/lib.rs b/sovereign-forge/wasm-sovereign-forge-full/src/lib.rs index 07331b22..5eb34350 100644 --- a/sovereign-forge/wasm-sovereign-forge-full/src/lib.rs +++ b/sovereign-forge/wasm-sovereign-forge-full/src/lib.rs @@ -6,9 +6,9 @@ // Init: 1 // Upgrade: 1 -// Endpoints: 10 +// Endpoints: 11 // Async Callback (empty): 1 -// Total number of exported functions: 13 +// Total number of exported functions: 14 #![no_std] @@ -26,6 +26,7 @@ multiversx_sc_wasm_adapter::endpoints! { deployPhaseOne => deploy_phase_one deployPhaseTwo => deploy_phase_two deployPhaseThree => deploy_phase_three + deployPhaseFour => deploy_phase_four getChainFactoryAddress => chain_factories getTokenHandlerAddress => token_handlers getDeployCost => deploy_cost diff --git a/sovereign-forge/wasm-soveriegn-forge-view/Cargo.lock b/sovereign-forge/wasm-soveriegn-forge-view/Cargo.lock index 20f07787..5dcedc03 100644 --- a/sovereign-forge/wasm-soveriegn-forge-view/Cargo.lock +++ b/sovereign-forge/wasm-soveriegn-forge-view/Cargo.lock @@ -258,6 +258,7 @@ dependencies = [ "chain-config", "chain-factory", "esdt-safe", + "fee-market", "header-verifier", "multiversx-sc", "multiversx-sc-modules", diff --git a/sovereign-forge/wasm/Cargo.lock b/sovereign-forge/wasm/Cargo.lock index 3278000e..bbb98c75 100644 --- a/sovereign-forge/wasm/Cargo.lock +++ b/sovereign-forge/wasm/Cargo.lock @@ -258,6 +258,7 @@ dependencies = [ "chain-config", "chain-factory", "esdt-safe", + "fee-market", "header-verifier", "multiversx-sc", "multiversx-sc-modules", diff --git a/sovereign-forge/wasm/src/lib.rs b/sovereign-forge/wasm/src/lib.rs index 07331b22..5eb34350 100644 --- a/sovereign-forge/wasm/src/lib.rs +++ b/sovereign-forge/wasm/src/lib.rs @@ -6,9 +6,9 @@ // Init: 1 // Upgrade: 1 -// Endpoints: 10 +// Endpoints: 11 // Async Callback (empty): 1 -// Total number of exported functions: 13 +// Total number of exported functions: 14 #![no_std] @@ -26,6 +26,7 @@ multiversx_sc_wasm_adapter::endpoints! { deployPhaseOne => deploy_phase_one deployPhaseTwo => deploy_phase_two deployPhaseThree => deploy_phase_three + deployPhaseFour => deploy_phase_four getChainFactoryAddress => chain_factories getTokenHandlerAddress => token_handlers getDeployCost => deploy_cost From 6f3e18174830750f84ab4597492c35ab309b94cb Mon Sep 17 00:00:00 2001 From: Andrei Baltariu Date: Wed, 11 Dec 2024 14:48:09 +0200 Subject: [PATCH 4/8] Modified error message Signed-off-by: Andrei Baltariu --- sovereign-forge/src/common/utils.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sovereign-forge/src/common/utils.rs b/sovereign-forge/src/common/utils.rs index 8c5bd2c1..bffccaf9 100644 --- a/sovereign-forge/src/common/utils.rs +++ b/sovereign-forge/src/common/utils.rs @@ -42,7 +42,7 @@ pub trait UtilsModule: super::storage::StorageModule { fn require_phase_three_completed(&self, caller: &ManagedAddress) { require!( self.is_contract_deployed(caller, ScArray::ESDTSafe), - "The Header-Verifier SC is not deployed, you skipped the second phase" + "The ESDT-Safe SC is not deployed, you skipped the third phase" ); } From 47fde5d1b85682cf0a23786370c9f9eacb1833f5 Mon Sep 17 00:00:00 2001 From: Andrei Baltariu Date: Wed, 11 Dec 2024 14:48:14 +0200 Subject: [PATCH 5/8] Added unit tests Signed-off-by: Andrei Baltariu --- .../tests/sovereign_forge_unit_tests.rs | 174 +++++++++++++++++- 1 file changed, 171 insertions(+), 3 deletions(-) diff --git a/sovereign-forge/tests/sovereign_forge_unit_tests.rs b/sovereign-forge/tests/sovereign_forge_unit_tests.rs index ebcf2967..c6af19e5 100644 --- a/sovereign-forge/tests/sovereign_forge_unit_tests.rs +++ b/sovereign-forge/tests/sovereign_forge_unit_tests.rs @@ -4,8 +4,11 @@ use multiversx_sc_scenario::{ ScenarioWorld, }; use proxies::{ - chain_config_proxy::ChainConfigContractProxy, chain_factory_proxy::ChainFactoryContractProxy, - esdt_safe_proxy::EsdtSafeProxy, header_verifier_proxy::HeaderverifierProxy, + chain_config_proxy::ChainConfigContractProxy, + chain_factory_proxy::ChainFactoryContractProxy, + esdt_safe_proxy::EsdtSafeProxy, + fee_market_proxy::{FeeMarketProxy, FeeStruct}, + header_verifier_proxy::HeaderverifierProxy, sovereign_forge_proxy::SovereignForgeProxy, }; use setup_phase::SetupPhaseModule; @@ -33,6 +36,9 @@ const HEADER_VERIFIER_CODE_PATH: MxscPath = const ESDT_SAFE_ADDRESS: TestSCAddress = TestSCAddress::new("esdt-safe"); const ESDT_SAFE_CODE_PATH: MxscPath = MxscPath::new("../esdt-safe/output/esdt-safe.mxsc.json"); +const FEE_MARKET_ADDRESS: TestSCAddress = TestSCAddress::new("fee-market"); +const FEE_MARKET_CODE_PATH: MxscPath = MxscPath::new("../fee-market/output/fee-market.mxsc.json"); + const TOKEN_HANDLER_ADDRESS: TestSCAddress = TestSCAddress::new("token-handler"); const BALANCE: u128 = 100_000_000_000_000_000; @@ -46,6 +52,7 @@ fn world() -> ScenarioWorld { blockchain.register_contract(CONFIG_CODE_PATH, chain_config::ContractBuilder); blockchain.register_contract(HEADER_VERIFIER_CODE_PATH, header_verifier::ContractBuilder); blockchain.register_contract(ESDT_SAFE_CODE_PATH, esdt_safe::ContractBuilder); + blockchain.register_contract(FEE_MARKET_CODE_PATH, fee_market::ContractBuilder); blockchain } @@ -76,7 +83,7 @@ impl SovereignForgeTestState { CONFIG_ADDRESS, HEADER_VERIFIER_ADDRESS, ESDT_SAFE_ADDRESS, - FACTORY_ADDRESS, + FEE_MARKET_ADDRESS, ) .code(FACTORY_CODE_PATH) .new_address(FACTORY_ADDRESS) @@ -149,6 +156,20 @@ impl SovereignForgeTestState { self } + fn deploy_fee_market_template(&mut self) -> &mut Self { + let fee: Option> = None; + + self.world + .tx() + .from(OWNER_ADDRESS) + .typed(FeeMarketProxy) + .init(ESDT_SAFE_ADDRESS, fee) + .code(FEE_MARKET_CODE_PATH) + .new_address(FEE_MARKET_ADDRESS) + .run(); + + self + } fn register_token_handler( &mut self, shard_id: u32, @@ -282,6 +303,26 @@ impl SovereignForgeTestState { transaction.run(); } } + + fn deploy_phase_four( + &mut self, + fee: Option>, + expect_error: Option, + ) { + let transaction = self + .world + .tx() + .from(OWNER_ADDRESS) + .to(FORGE_ADDRESS) + .typed(SovereignForgeProxy) + .deploy_phase_four(fee); + + if let Some(error) = expect_error { + transaction.returns(error).run(); + } else { + transaction.run(); + } + } } #[test] @@ -564,6 +605,17 @@ fn deploy_phase_three() { state.deploy_phase_two(None, &bls_keys); state.deploy_phase_three(false, None); + + state + .world + .query() + .to(FORGE_ADDRESS) + .whitebox(sovereign_forge::contract_obj, |sc| { + let is_esdt_safe_deployed = + sc.is_contract_deployed(&OWNER_ADDRESS.to_managed_address(), ScArray::ESDTSafe); + + assert!(is_esdt_safe_deployed); + }) } #[test] @@ -647,3 +699,119 @@ fn deploy_phase_three_already_deployed() { Some(ExpectError(4, "The ESDT-Safe SC is already deployed")), ); } + +#[test] +fn deploy_phase_four() { + let mut state = SovereignForgeTestState::new(); + state.deploy_sovereign_forge(); + state.deploy_chain_factory(); + state.deploy_chain_config_template(); + state.deploy_fee_market_template(); + state.finish_setup(); + + let deploy_cost = BigUint::from(100_000u32); + + state.deploy_phase_one( + &deploy_cost, + 1, + 2, + BigUint::from(2u32), + MultiValueEncoded::new(), + None, + ); + + state.deploy_header_verifier_template(); + state.deploy_esdt_safe_template(); + + let mut bls_keys = MultiValueEncoded::new(); + bls_keys.push(ManagedBuffer::from("bls1")); + bls_keys.push(ManagedBuffer::from("bls2")); + + state.deploy_phase_two(None, &bls_keys); + state.deploy_phase_three(false, None); + state.deploy_phase_four(None, None); + + state + .world + .query() + .to(FORGE_ADDRESS) + .whitebox(sovereign_forge::contract_obj, |sc| { + let is_fee_market_deployed = + sc.is_contract_deployed(&OWNER_ADDRESS.to_managed_address(), ScArray::FeeMarket); + + assert!(is_fee_market_deployed); + }) +} + +#[test] +fn deploy_phase_four_without_previous_phase() { + let mut state = SovereignForgeTestState::new(); + state.deploy_sovereign_forge(); + state.deploy_chain_factory(); + state.deploy_chain_config_template(); + state.deploy_fee_market_template(); + state.finish_setup(); + + let deploy_cost = BigUint::from(100_000u32); + + state.deploy_phase_one( + &deploy_cost, + 1, + 2, + BigUint::from(2u32), + MultiValueEncoded::new(), + None, + ); + + state.deploy_header_verifier_template(); + state.deploy_esdt_safe_template(); + + let mut bls_keys = MultiValueEncoded::new(); + bls_keys.push(ManagedBuffer::from("bls1")); + bls_keys.push(ManagedBuffer::from("bls2")); + + state.deploy_phase_two(None, &bls_keys); + state.deploy_phase_four( + None, + Some(ExpectError( + 4, + "The ESDT-Safe SC is not deployed, you skipped the third phase", + )), + ); +} + +#[test] +fn deploy_phase_four_fee_market_already_deployed() { + let mut state = SovereignForgeTestState::new(); + state.deploy_sovereign_forge(); + state.deploy_chain_factory(); + state.deploy_chain_config_template(); + state.deploy_fee_market_template(); + state.finish_setup(); + + let deploy_cost = BigUint::from(100_000u32); + + state.deploy_phase_one( + &deploy_cost, + 1, + 2, + BigUint::from(2u32), + MultiValueEncoded::new(), + None, + ); + + state.deploy_header_verifier_template(); + state.deploy_esdt_safe_template(); + + let mut bls_keys = MultiValueEncoded::new(); + bls_keys.push(ManagedBuffer::from("bls1")); + bls_keys.push(ManagedBuffer::from("bls2")); + + state.deploy_phase_two(None, &bls_keys); + state.deploy_phase_three(false, None); + state.deploy_phase_four(None, None); + state.deploy_phase_four( + None, + Some(ExpectError(4, "The Fee-Market SC is already deployed")), + ); +} From 4f366ed2d95b7d5ade7eba2ff1d5fb3754a61f09 Mon Sep 17 00:00:00 2001 From: Andrei Baltariu Date: Wed, 11 Dec 2024 14:57:18 +0200 Subject: [PATCH 6/8] Added logic to also set `fee_market_address` in ESDTSafe contract Signed-off-by: Andrei Baltariu --- chain-factory/src/factory.rs | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/chain-factory/src/factory.rs b/chain-factory/src/factory.rs index fe1fd1ee..3021d809 100644 --- a/chain-factory/src/factory.rs +++ b/chain-factory/src/factory.rs @@ -126,14 +126,23 @@ pub trait FactoryModule: only_admin::OnlyAdminModule { let source_address = self.fee_market_template().get(); let metadata = self.blockchain().get_code_metadata(&source_address); - self.tx() + let fee_market_address = self + .tx() .typed(FeeMarketProxy) - .init(esdt_safe_address, fee) + .init(&esdt_safe_address, fee) .gas(60_000_000) .from_source(source_address) .code_metadata(metadata) .returns(ReturnsNewManagedAddress) - .sync_call() + .sync_call(); + + self.tx() + .to(&esdt_safe_address) + .typed(EsdtSafeProxy) + .set_fee_market_address(&fee_market_address) + .sync_call(); + + fee_market_address } #[only_admin] From 120737f77d3fbefb92ca8903e3e1394e098e4e88 Mon Sep 17 00:00:00 2001 From: Andrei Baltariu Date: Wed, 11 Dec 2024 15:45:16 +0200 Subject: [PATCH 7/8] Added setup + chain-simulator test update Signed-off-by: Andrei Baltariu --- sovereign-forge/interactor/src/interact.rs | 73 +++++++++++++++++-- .../interactor/tests/interact_cs_tests.rs | 2 + 2 files changed, 67 insertions(+), 8 deletions(-) diff --git a/sovereign-forge/interactor/src/interact.rs b/sovereign-forge/interactor/src/interact.rs index 09eced50..81e727ec 100644 --- a/sovereign-forge/interactor/src/interact.rs +++ b/sovereign-forge/interactor/src/interact.rs @@ -5,8 +5,11 @@ mod config; use config::Config; use multiversx_sc_snippets::{imports::*, sdk::bech32}; use proxies::{ - chain_config_proxy::ChainConfigContractProxy, chain_factory_proxy::ChainFactoryContractProxy, - esdt_safe_proxy::EsdtSafeProxy, header_verifier_proxy::HeaderverifierProxy, + chain_config_proxy::ChainConfigContractProxy, + chain_factory_proxy::ChainFactoryContractProxy, + esdt_safe_proxy::EsdtSafeProxy, + fee_market_proxy::{FeeMarketProxy, FeeStruct}, + header_verifier_proxy::HeaderverifierProxy, sovereign_forge_proxy::SovereignForgeProxy, }; use serde::{Deserialize, Serialize}; @@ -20,6 +23,7 @@ const CHAIN_CONFIG_CODE_PATH: &str = "../../chain-config/output/chain-config.mxs const CHAIN_FACTORY_CODE_PATH: &str = "../../chain-factory/output/chain-factory.mxsc.json"; const HEADER_VERIFIER_CODE_PATH: &str = "../../header-verifier/output/header-verifier.mxsc.json"; const ESDT_SAFE_CODE_PATH: &str = "../../esdt-safe/output/esdt-safe.mxsc.json"; +const FEE_MARKET_CODE_PATH: &str = "../../fee-market/output/fee-market.mxsc.json"; pub async fn sovereign_forge_cli() { env_logger::init(); @@ -50,6 +54,7 @@ pub struct State { factory_address: Option, header_verifier_address: Option, esdt_safe_address: Option, + fee_market_address: Option, } impl State { @@ -65,30 +70,36 @@ impl State { } } - /// Sets the contract address + /// Sets the Sovereign-Forge contract address pub fn set_address(&mut self, address: Bech32Address) { self.contract_address = Some(address); } - /// Sets the contract address + /// Sets the Chain-Config contract address pub fn set_config_template(&mut self, address: Bech32Address) { self.config_address = Some(address); } - /// Sets the contract address + /// Sets the Chain-Factory contract address pub fn set_factory_template(&mut self, address: Bech32Address) { self.factory_address = Some(address); } - /// Sets the contract address + /// Sets the Header-Verifier contract address pub fn set_header_verifier_address(&mut self, address: Bech32Address) { self.header_verifier_address = Some(address); } + /// Sets the Esdt-Safe contract address pub fn set_esdt_safe_address(&mut self, address: Bech32Address) { self.esdt_safe_address = Some(address); } + /// Sets the Fee-Market contract address + pub fn set_fee_market_address(&mut self, address: Bech32Address) { + self.fee_market_address = Some(address); + } + /// Returns the contract address pub fn current_address(&self) -> &Bech32Address { self.contract_address @@ -172,6 +183,8 @@ impl ContractInteract { self.convert_address_to_managed(self.state.config_address.clone()); let esdt_safe_managed_address = self.convert_address_to_managed(self.state.esdt_safe_address.clone()); + let fee_market_mananged_address = + self.convert_address_to_managed(self.state.fee_market_address.clone()); let new_address = self .interactor @@ -184,7 +197,7 @@ impl ContractInteract { config_managed_address, header_verifier_managed_address, esdt_safe_managed_address, - forge_managed_address, // USE ACTUAL FEE-MARKET TEMPLATE + fee_market_mananged_address, ) .code(MxscPath::new(CHAIN_FACTORY_CODE_PATH)) .returns(ReturnsNewAddress) @@ -278,8 +291,35 @@ impl ContractInteract { new_address_bech32.clone(), )); - println!("new Header-Verifier address: {new_address_bech32}"); + println!("new ESDT-Safe address: {new_address_bech32}"); } + + pub async fn deploy_fee_market_template(&mut self) { + let esdt_safe_managed_address = + self.convert_address_to_managed(self.state.esdt_safe_address.clone()); + let fee: Option> = None; + + let new_address = self + .interactor + .tx() + .from(&self.wallet_address) + .gas(80_000_000u64) + .typed(FeeMarketProxy) + .init(esdt_safe_managed_address, fee) + .returns(ReturnsNewAddress) + .code(MxscPath::new(FEE_MARKET_CODE_PATH)) + .run() + .await; + + let new_address_bech32 = bech32::encode(&new_address); + self.state + .set_fee_market_address(Bech32Address::from_bech32_string( + new_address_bech32.clone(), + )); + + println!("new Fee-Market address: {new_address_bech32}"); + } + pub async fn upgrade(&mut self) { let response = self .interactor @@ -425,6 +465,23 @@ impl ContractInteract { println!("Result: {response:?}"); } + pub async fn deploy_phase_four(&mut self) { + let fee: Option> = None; + + let response = self + .interactor + .tx() + .from(&self.wallet_address) + .to(self.state.current_address()) + .gas(80_000_000u64) + .typed(SovereignForgeProxy) + .deploy_phase_four(fee) + .returns(ReturnsResultUnmanaged) + .run() + .await; + + println!("Result: {response:?}"); + } pub async fn chain_factories(&mut self) { let shard_id = 0u32; diff --git a/sovereign-forge/interactor/tests/interact_cs_tests.rs b/sovereign-forge/interactor/tests/interact_cs_tests.rs index f035b97d..b478f4ae 100644 --- a/sovereign-forge/interactor/tests/interact_cs_tests.rs +++ b/sovereign-forge/interactor/tests/interact_cs_tests.rs @@ -10,6 +10,7 @@ async fn deploy_test_sovereign_forge_cs() { interactor.deploy_header_verifier_template().await; interactor.deploy_chain_config_template().await; interactor.deploy_esdt_safe_template().await; + interactor.deploy_fee_market_template().await; interactor.deploy_chain_factory().await; interactor.register_token_handler(1).await; @@ -24,4 +25,5 @@ async fn deploy_test_sovereign_forge_cs() { interactor.deploy_phase_one().await; interactor.deploy_phase_two().await; interactor.deploy_phase_three().await; + interactor.deploy_phase_four().await; } From 8412739e2d2f8adbb80c625ad3557a8f452aa124 Mon Sep 17 00:00:00 2001 From: Andrei Baltariu Date: Wed, 11 Dec 2024 16:04:06 +0200 Subject: [PATCH 8/8] Removed `state.toml` Signed-off-by: Andrei Baltariu --- sovereign-forge/interactor/state.toml | 5 ----- 1 file changed, 5 deletions(-) delete mode 100644 sovereign-forge/interactor/state.toml diff --git a/sovereign-forge/interactor/state.toml b/sovereign-forge/interactor/state.toml deleted file mode 100644 index de9f43bb..00000000 --- a/sovereign-forge/interactor/state.toml +++ /dev/null @@ -1,5 +0,0 @@ -contract_address = "erd1qqqqqqqqqqqqqpgqt54uz2y2frvy7fqet479a6efarnyw3yud8ssj6kyuz" -config_address = "erd1qqqqqqqqqqqqqpgqd3sm30pzrsqs2y7ct6368tlt94d6xvl6d8ssqhckfm" -factory_address = "erd1qqqqqqqqqqqqqpgq9xqda668zt76c8tvfqe9t39g7pz0j9t2d8sss3w65z" -header_verifier_address = "erd1qqqqqqqqqqqqqpgqlmtayq49qt94dj7gghagd7ap3d3htj76d8sszr0t7z" -esdt_safe_address = "erd1qqqqqqqqqqqqqpgqvxvmyp2fgr6qekksx8n6t8netkpweh28d8ssw9gwh8"