Feed xdns with dummy metadata in ExecDelivery
@@ -330,6 +330,85 @@ impl ExecComposer {
submitter_id: AuthorityId,
gateway_pointer: &GatewayPointer,
) -> Result<Box<dyn GatewayInboundProtocol>, &'static str> {
+ // Very dummy - replace asap with https://github.com/t3rn/t3rn/pull/87
+ use crate::message_assembly::chain_generic_metadata::Metadata;
+ use frame_metadata::{
+ DecodeDifferent, ExtrinsicMetadata, FunctionMetadata, ModuleMetadata,
+ RuntimeMetadataV13,
+ };
+ pub fn get_dummy_modules_with_functions() -> Vec<(&'static str, Vec<&'static str>)> {
+ vec![
+ ("state", vec!["call"]),
+ ("state", vec!["getStorage"]),
+ ("state", vec!["setStorage"]),
+ ("ModuleName", vec!["FnName"]),
+ ("ModuleName", vec!["FnName1"]),
+ ("ModuleName", vec!["FnName2"]),
+ ("ModuleName", vec!["FnName3"]),
+ ("author", vec!["submitExtrinsic"]),
+ ("utility", vec!["batchAll"]),
+ ("system", vec!["remark"]),
+ ("gateway", vec!["call"]),
+ ("balances", vec!["transfer"]),
+ ("gateway", vec!["getStorage"]),
+ ("gateway", vec!["transfer"]),
+ ("gateway", vec!["emitEvent"]),
+ ("gateway", vec!["custom"]),
+ ("gatewayEscrowed", vec!["callStatic"]),
+ ("gatewayEscrowed", vec!["callEscrowed"]),
+ ]
+ }
+ // Very dummy - replace asap with https://github.com/t3rn/t3rn/pull/87
+ fn create_test_metadata(
+ modules_with_functions: Vec<(&'static str, Vec<&'static str>)>,
+ ) -> Metadata {
+ let mut module_index = 0;
+ let mut modules: Vec<ModuleMetadata> = vec![];
+
+ let fn_metadata_generator = |name: &'static str| -> FunctionMetadata {
+ FunctionMetadata {
+ name: DecodeDifferent::Encode(name),
+ arguments: DecodeDifferent::Decoded(vec![]),
+ documentation: DecodeDifferent::Decoded(vec![]),
+ }
+ };
+
+ let module_metadata_generator = |mod_name: &'static str,
+ mod_index: u8,
+ functions: Vec<FunctionMetadata>|
+ -> ModuleMetadata {
+ ModuleMetadata {
+ index: mod_index,
+ name: DecodeDifferent::Encode(mod_name),
+ storage: None,
+ calls: Some(DecodeDifferent::Decoded(functions)),
+ event: None,
+ constants: DecodeDifferent::Decoded(vec![]),
+ errors: DecodeDifferent::Decoded(vec![]),
+ }
+ };
+
+ for module in modules_with_functions {
+ let (module_name, fn_names) = module;
+ let functions = fn_names.into_iter().map(fn_metadata_generator).collect();
+ modules.push(module_metadata_generator(
+ module_name,
+ module_index,
+ functions,
+ ));
+ module_index = module_index + 1;
+ }
+
+ let runtime_metadata = RuntimeMetadataV13 {
+ extrinsic: ExtrinsicMetadata {
+ version: 1,
+ signed_extensions: vec![DecodeDifferent::Encode("test")],
+ },
+ modules: DecodeDifferent::Decoded(modules),
+ };
+ Metadata::new(runtime_metadata)
+ }
+
let mut best_gateway = pallet_xdns::Pallet::<T>::best_available(gateway_pointer.id)?;
let genesis_hash = T::Hashing::hash(&mut best_gateway.gateway_genesis.genesis_hash);
@@ -337,7 +416,8 @@ impl ExecComposer {
Ok(Box::new(
SubstrateGatewayProtocol::<AuthorityId, T::Hash>::new(
- Default::default(),
+ // FixMe: Very dummy - replace asap with https://github.com/t3rn/t3rn/pull/87
+ create_test_metadata(get_dummy_modules_with_functions()),
runtime_version,
genesis_hash,
submitter_id,
