Skip to content

Commit

Permalink
allow dry run for eth claim (#19937)
Browse files Browse the repository at this point in the history
## Description 

as title

## Test plan 

How did you test the new or updated feature?

---

## Release notes

Check each box that your changes affect. If none of the boxes relate to
your changes, release notes aren't required.

For each box you select, include information after the relevant heading
that describes the impact of your changes that a user might notice and
any actions they must take to implement updates.

- [ ] Protocol: 
- [ ] Nodes (Validators and Full nodes): 
- [ ] Indexer: 
- [ ] JSON-RPC: 
- [ ] GraphQL: 
- [ ] CLI: 
- [ ] Rust SDK:
- [ ] REST API:
  • Loading branch information
longbowlu authored Oct 21, 2024
1 parent 314960e commit 4a13cb1
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions crates/sui-bridge-cli/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -540,6 +540,8 @@ pub enum BridgeClientCommands {
ClaimOnEth {
#[clap(long)]
seq_num: u64,
#[clap(long, default_value_t = true, action = clap::ArgAction::Set)]
dry_run: bool,
},
}

Expand Down Expand Up @@ -575,8 +577,8 @@ impl BridgeClientCommands {
);
Ok(())
}
BridgeClientCommands::ClaimOnEth { seq_num } => {
claim_on_eth(seq_num, config, sui_bridge_client)
BridgeClientCommands::ClaimOnEth { seq_num, dry_run } => {
claim_on_eth(seq_num, config, sui_bridge_client, dry_run)
.await
.map_err(|e| anyhow!("{:?}", e))
}
Expand Down Expand Up @@ -680,6 +682,7 @@ async fn claim_on_eth(
seq_num: u64,
config: &LoadedBridgeCliConfig,
sui_bridge_client: SuiBridgeClient,
dry_run: bool,
) -> BridgeResult<()> {
let sui_chain_id = sui_bridge_client.get_bridge_summary().await?.chain_id;
let parsed_message = sui_bridge_client
Expand Down Expand Up @@ -709,8 +712,20 @@ async fn claim_on_eth(
);
let message = eth_sui_bridge::Message::from(parsed_message);
let tx = eth_sui_bridge.transfer_bridged_tokens_with_signatures(signatures, message);
let _eth_claim_tx_receipt = tx.send().await.unwrap().await.unwrap().unwrap();
info!("Sui to Eth bridge transfer claimed");
if dry_run {
let tx = tx.tx;
let resp = config.eth_signer.estimate_gas(&tx, None).await;
println!(
"Sui to Eth bridge transfer claim dry run result: {:?}",
resp
);
} else {
let eth_claim_tx_receipt = tx.send().await.unwrap().await.unwrap().unwrap();
println!(
"Sui to Eth bridge transfer claimed: {:?}",
eth_claim_tx_receipt
);
}
Ok(())
}

Expand Down

0 comments on commit 4a13cb1

Please sign in to comment.