Skip to content

Commit

Permalink
Add option to valset upd relayer to change wallet
Browse files Browse the repository at this point in the history
  • Loading branch information
sug0 committed Feb 15, 2023
1 parent 892e80b commit a20ac2a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
10 changes: 10 additions & 0 deletions apps/src/lib/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1913,6 +1913,7 @@ pub mod args {
const ETH_GAS: ArgOpt<u64> = arg_opt("eth-gas");
const ETH_GAS_PRICE: ArgOpt<u64> = arg_opt("eth-gas-price");
const ETH_ADDRESS: Arg<EthAddress> = arg("ethereum-address");
const ETH_ADDRESS_OPT: ArgOpt<EthAddress> = arg_opt("ethereum-address");
const ETH_RPC_ENDPOINT: ArgDefault<String> = arg_default(
"eth-rpc-endpoint",
DefaultFn(|| "http://localhost:8545".into()),
Expand Down Expand Up @@ -2243,6 +2244,9 @@ pub mod args {
/// The price of Ethereum gas, during the
/// relay call.
pub gas_price: Option<u64>,
/// The address of the Ethereum wallet to pay the gas fees.
/// If unset, the default wallet is used.
pub eth_addr: Option<EthAddress>,
}

impl Args for ValidatorSetUpdateRelay {
Expand All @@ -2252,6 +2256,7 @@ pub mod args {
let gas = ETH_GAS.parse(matches);
let gas_price = ETH_GAS_PRICE.parse(matches);
let eth_rpc_endpoint = ETH_RPC_ENDPOINT.parse(matches);
let eth_addr = ETH_ADDRESS_OPT.parse(matches);
let confirmations = ETH_CONFIRMATIONS.parse(matches);
Self {
query,
Expand All @@ -2260,11 +2265,16 @@ pub mod args {
gas_price,
confirmations,
eth_rpc_endpoint,
eth_addr,
}
}

fn def(app: App) -> App {
app.add_args::<Query>()
.arg(ETH_ADDRESS_OPT.def().about(
"The address of the Ethereum wallet to pay the gas fees. \
If unset, the default wallet is used.",
))
.arg(
EPOCH
.def()
Expand Down
3 changes: 3 additions & 0 deletions apps/src/lib/client/eth_bridge/validator_set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,9 @@ pub async fn relay_validator_set_update(args: args::ValidatorSetUpdateRelay) {
if let Some(gas_price) = args.gas_price {
relay_op.tx.set_gas_price(gas_price);
}
if let Some(eth_addr) = args.eth_addr {
relay_op.tx.set_from(eth_addr.into());
}

let pending_tx = relay_op.send().await.unwrap();
let transf_result = pending_tx
Expand Down

0 comments on commit a20ac2a

Please sign in to comment.