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
use client_pangolin::component::PangolinClientComponent;
use client_pangolin::types::EthereumAccount;
use support_common::config::{Config, Names};
use support_common::error::BridgerError;
use support_terminal::output;
use crate::bridge::PangolinRopstenConfig;
use crate::command::types::EcdsaOpts;
pub async fn handle_ecdsa(opts: EcdsaOpts) -> color_eyre::Result<()> {
let message = opts.message;
let bridge_config: PangolinRopstenConfig = Config::restore(Names::BridgePangolinRopsten)?;
let config_darwinia = bridge_config.darwinia;
let config_web3 = bridge_config.web3;
let client = PangolinClientComponent::component(config_darwinia.clone()).await?;
let ethereum_account = EthereumAccount::new(
config_web3.endpoint,
config_darwinia.ecdsa_authority_private_key,
);
let message = array_bytes::hex2bytes(&message[2..])
.map_err(|_| BridgerError::Custom("message[2..]".into()))?;
let mut buffer = [0u8; 32];
buffer.copy_from_slice(&message);
let tx = client
.ethereum()
.ecdsa_sign_and_submit_signed_authorities(ethereum_account, buffer)
.await?;
output::output_text(format!("{:?}", tx));
output::output_text("Success");
Ok(())
}