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_darwinia::component::DarwiniaClientComponent;
use client_darwinia::types::runtime_types::{darwinia_bridge_ethereum, darwinia_runtime};
use shadow_liketh::component::ShadowComponent;
use shadow_liketh::types::BridgeName;
use support_common::config::{Config, Names};
use support_terminal::output;
use crate::bridge::DarwiniaEthereumConfig;
use crate::command::types::ConfirmOpts;
pub async fn handle_confirm(opts: ConfirmOpts) -> color_eyre::Result<()> {
let block = opts.block;
let bridge_config: DarwiniaEthereumConfig = Config::restore(Names::BridgeDarwiniaEthereum)?;
let config_darwinia = bridge_config.darwinia;
let shadow = ShadowComponent::component(
bridge_config.shadow,
bridge_config.ethereum,
bridge_config.web3,
BridgeName::DarwiniaEthereum,
)?;
let client = DarwiniaClientComponent::component(config_darwinia).await?;
let parcel = shadow.parcel(block as u64).await?;
let tx = client
.runtime()
.tx()
.sudo()
.sudo(darwinia_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(())
}