diff --git a/bridge-cli/Cargo.toml b/bridge-cli/Cargo.toml index 2977a0cf..f6f9b4db 100644 --- a/bridge-cli/Cargo.toml +++ b/bridge-cli/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "bridge-cli" -version = "0.3.37" +version = "0.3.38" edition = "2021" repository = "https://github.com/Near-One/bridge-sdk-rs" rust-version = "1.88.0" diff --git a/bridge-cli/src/omni_connector_command.rs b/bridge-cli/src/omni_connector_command.rs index 33427991..a58de20a 100644 --- a/bridge-cli/src/omni_connector_command.rs +++ b/bridge-cli/src/omni_connector_command.rs @@ -7,7 +7,7 @@ use alloy::primitives::{Address as EvmH160, TxHash}; use alloy::signers::local::PrivateKeySigner; use evm_bridge_client::EvmBridgeClientBuilder; use light_client::LightClientBuilder; -use near_bridge_client::{NearBridgeClientBuilder, TransactionOptions, UTXOChainAccounts}; +use near_bridge_client::{btc::format_max_gas_fee, NearBridgeClientBuilder, TransactionOptions, UTXOChainAccounts}; use near_primitives::{hash::CryptoHash, types::AccountId}; use omni_connector::{ BindTokenArgs, BtcDepositArgs, DeployTokenArgs, FinTransferArgs, InitTransferArgs, @@ -236,7 +236,7 @@ pub enum OmniConnectorSubCommand { fee: Option, #[clap(short, long, help = "Native fee to charge for the transfer")] native_fee: Option, - #[clap(short, long, help = "Additional message")] + #[clap(short, long, help = "Additional message (JSON format, e.g. '{\"MaxGasFee\": \"400\"}' for BTC transfers)")] message: Option, #[command(flatten)] config_cli: CliConfig, @@ -355,7 +355,7 @@ pub enum OmniConnectorSubCommand { fee: Option, #[clap(short, long, help = "Native fee to charge for the transfer")] native_fee: Option, - #[clap(short, long, help = "Additional message")] + #[clap(short, long, help = "Additional message (JSON format, e.g. '{\"MaxGasFee\": \"400\"}' for BTC transfers)")] message: Option, #[command(flatten)] config_cli: CliConfig, @@ -770,7 +770,7 @@ pub async fn match_subcommand(cmd: OmniConnectorSubCommand, network: Network) { && matches!(recipient.get_chain(), ChainKind::Btc | ChainKind::Zcash) { if let Some(gas_fee) = gas_fee { - message = format!("{{\"MaxGasFee\": \"{gas_fee}\"}}"); + message = format_max_gas_fee(u64::try_from(gas_fee).unwrap()); } } diff --git a/bridge-sdk/bridge-clients/near-bridge-client/Cargo.toml b/bridge-sdk/bridge-clients/near-bridge-client/Cargo.toml index d9c3afef..c06fe450 100644 --- a/bridge-sdk/bridge-clients/near-bridge-client/Cargo.toml +++ b/bridge-sdk/bridge-clients/near-bridge-client/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "near-bridge-client" -version = "0.2.14" +version = "0.2.15" edition = "2021" [dependencies] diff --git a/bridge-sdk/bridge-clients/near-bridge-client/src/btc.rs b/bridge-sdk/bridge-clients/near-bridge-client/src/btc.rs index 6df9ab5c..0d9da19b 100644 --- a/bridge-sdk/bridge-clients/near-bridge-client/src/btc.rs +++ b/bridge-sdk/bridge-clients/near-bridge-client/src/btc.rs @@ -224,6 +224,13 @@ impl TxBytes { } } +/// Format a MaxGasFee message for UTXO chain transfers. +/// This produces JSON like: `{"MaxGasFee":"400"}` +pub fn format_max_gas_fee(gas_fee: u64) -> String { + serde_json::to_string(&UTXOChainMsg::MaxGasFee(U64::from(gas_fee))) + .expect("Failed to serialize UTXOChainMsg") +} + impl NearBridgeClient { /// Signs a NEAR transfer to BTC by calling `sign_btc_transaction` on the BTC connector contract. #[tracing::instrument(skip_all, name = "NEAR SIGN BTC TRANSACTION")]