#189 Predeployed Contracts functionality (#218)

* Added a possibility to predeploy contracts to the genesis block
* Added some default contracts to predeploy.
This commit is contained in:
Nikita Khateev
2024-06-12 09:35:05 +04:00
committed by GitHub
parent b080293cdb
commit 26c49797cb
16 changed files with 1390 additions and 26 deletions
+23 -6
View File
@@ -14,15 +14,19 @@ use sp_runtime::traits::AccountIdConversion;
use crate::{
chain_spec,
cli::{Cli, RelayChainCli, Subcommand},
cli::{Cli, ExtendedBuildSpecCmd, RelayChainCli, Subcommand},
contracts::ContractsPath,
service::new_partial,
};
fn load_spec(id: &str) -> std::result::Result<Box<dyn ChainSpec>, String> {
fn load_spec(
id: &str,
contracts_path: ContractsPath,
) -> std::result::Result<Box<dyn ChainSpec>, String> {
Ok(match id {
"dev" => Box::new(chain_spec::development_config()),
"template-rococo" => Box::new(chain_spec::local_testnet_config()),
"" | "local" => Box::new(chain_spec::local_testnet_config()),
"dev" => Box::new(chain_spec::development_config(contracts_path)),
"template-rococo" => Box::new(chain_spec::local_testnet_config(contracts_path)),
"" | "local" => Box::new(chain_spec::local_testnet_config(contracts_path)),
path => Box::new(chain_spec::ChainSpec::from_json_file(std::path::PathBuf::from(path))?),
})
}
@@ -58,7 +62,10 @@ impl SubstrateCli for Cli {
}
fn load_spec(&self, id: &str) -> std::result::Result<Box<dyn sc_service::ChainSpec>, String> {
load_spec(id)
load_spec(
id,
self.subcommand.as_ref().map(Subcommand::contract_directory).unwrap_or_default(),
)
}
}
@@ -389,3 +396,13 @@ impl CliConfiguration<Self> for RelayChainCli {
self.base.base.node_name()
}
}
impl CliConfiguration for ExtendedBuildSpecCmd {
fn shared_params(&self) -> &SharedParams {
self.cmd.shared_params()
}
fn node_key_params(&self) -> Option<&sc_cli::NodeKeyParams> {
self.cmd.node_key_params()
}
}