1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
use client_pangolin::component::PangolinClientComponent;
use client_pangolin::types::runtime_types::{darwinia_bridge_ethereum, pangolin_runtime};
use shadow_liketh::component::ShadowComponent;
use shadow_liketh::types::BridgeName;
use support_common::config::{Config, Names};
use support_terminal::output;
use crate::bridge::PangolinRopstenConfig;
use crate::command::types::ConfirmOpts;
pub async fn handle_confirm(opts: ConfirmOpts) -> color_eyre::Result<()> {
let block = opts.block;
let bridge_config: PangolinRopstenConfig = Config::restore(Names::BridgePangolinRopsten)?;
let config_darwinia = bridge_config.darwinia;
let shadow = ShadowComponent::component(
bridge_config.shadow,
bridge_config.ethereum,
bridge_config.web3,
BridgeName::PangolinRopsten,
)?;
let client = PangolinClientComponent::component(config_darwinia).await?;
let parcel = shadow.parcel(block as u64).await?;
let tx = client
.runtime()
.tx()
.sudo()
.sudo(pangolin_runtime::Call::EthereumRelay(
darwinia_bridge_ethereum::Call::set_confirmed_parcel {
ethereum_relay_header_parcel: parcel.try_into()?,
},
))
.sign_and_submit(client.account().signer())
.await?;
let msg = format!("Set confirmed block {} succeed! {:?}", block, tx);
output::output_text(msg);
Ok(())
}