Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion bridge-cli/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "bridge-cli"
version = "0.3.35"
version = "0.3.36"
edition = "2021"
repository = "https://github.com/Near-One/bridge-sdk-rs"
rust-version = "1.88.0"
Expand Down
6 changes: 3 additions & 3 deletions bridge-cli/src/defaults.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/// Mainnet
pub const NEAR_RPC_MAINNET: &str = "https://archival-rpc.mainnet.fastnear.com/";
pub const NEAR_TOKEN_LOCKER_ID_MAINNET: &str = "omni.bridge.near";
pub const BRIDGE_INDEXER_API_MAINNET: &str = "https://mainnet.api.bridge.nearone.org/";
pub const BRIDGE_INDEXER_API_MAINNET: &str = "https://mainnet.api.bridge.nearone.org";
pub const ETH_LIGHT_CLIENT_ID_MAINNET: &str = "client-eth2.bridge.near";
pub const BTC_LIGHT_CLIENT_ID_MAINNET: &str = "btc-client.bridge.near";
pub const ZCASH_LIGHT_CLIENT_ID_MAINNET: &str = "zcash-client.bridge.near";
Expand Down Expand Up @@ -52,7 +52,7 @@ pub const ENABLE_ORCHARD_BUNDLE_MAINNET: bool = false;
/// Testnet
pub const NEAR_RPC_TESTNET: &str = "https://archival-rpc.testnet.fastnear.com/";
pub const NEAR_TOKEN_LOCKER_ID_TESTNET: &str = "omni.n-bridge.testnet";
pub const BRIDGE_INDEXER_API_TESTNET: &str = "https://testnet.api.bridge.nearone.org/";
pub const BRIDGE_INDEXER_API_TESTNET: &str = "https://testnet.api.bridge.nearone.org";
pub const ETH_LIGHT_CLIENT_ID_TESTNET: &str = "client-eth2.sepolia.testnet";
pub const BTC_LIGHT_CLIENT_ID_TESTNET: &str = "btc-client-v4.testnet";
pub const ZCASH_LIGHT_CLIENT_ID_TESTNET: &str = "zcash-client.n-bridge.testnet";
Expand Down Expand Up @@ -103,7 +103,7 @@ pub const ENABLE_ORCHARD_BUNDLE_TESTNET: bool = true;
/// Devnet
pub const NEAR_RPC_DEVNET: &str = "https://archival-rpc.testnet.near.org/";
pub const NEAR_TOKEN_LOCKER_ID_DEVNET: &str = "omni-locker.testnet";
pub const BRIDGE_INDEXER_API_DEVNET: &str = "https://testnet.api.bridge.nearone.org/";
pub const BRIDGE_INDEXER_API_DEVNET: &str = "https://testnet.api.bridge.nearone.org";
pub const ETH_LIGHT_CLIENT_ID_DEVNET: &str = "client-eth2.sepolia.testnet";
pub const BTC_LIGHT_CLIENT_ID_DEVNET: &str = "btc-client-v4.testnet";
pub const ZCASH_LIGHT_CLIENT_ID_DEVNET: &str = "zcash-client.n-bridge.testnet";
Expand Down
18 changes: 6 additions & 12 deletions bridge-cli/src/omni_connector_command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ pub enum OmniConnectorSubCommand {
#[clap(about = "Initialize a transfer on NEAR")]
NearInitTransfer {
#[clap(short, long, help = "Token to transfer")]
token: String,
token: AccountId,
#[clap(short, long, help = "Amount to transfer")]
amount: u128,
#[clap(short, long, help = "Recipient address on the destination chain")]
Expand Down Expand Up @@ -732,32 +732,26 @@ pub async fn match_subcommand(cmd: OmniConnectorSubCommand, network: Network) {
} => {
let combined_config = combined_config(config_cli.clone(), network);

let (fee, native_fee, gas_fee) = match (fee, native_fee) {
let (_, native_fee, gas_fee) = match (fee, native_fee) {
(Some(f), Some(nf)) => (f, nf, None),
(Some(f), None) => (f, 0, None),
(None, Some(nf)) => (0, nf, None),
_ => {
let api_url = combined_config
.bridge_indexer_api_url
.as_deref()
.expect(
"Getting fee: bridge_indexer_api_url not available",
);
.expect("Getting fee: bridge_indexer_api_url not available");

let sender = combined_config
.near_signer
.as_deref()
.expect(
"Getting fee: near_signer not available",
)
.expect("Getting fee: near_signer not available")
.parse()
.map(OmniAddress::Near)
.map(|addr| addr.to_string())
.expect("Getting fee: failed to parse near_signer");

let token_addr: OmniAddress = token
.parse()
.expect("Getting fee: failed to parse token");
let token_addr = OmniAddress::Near(token.clone());
fetch_indexer_fees(api_url, sender, token_addr.to_string(), amount, &recipient)
.await
.expect("Failed to get fee from indexer")
Expand All @@ -778,7 +772,7 @@ pub async fn match_subcommand(cmd: OmniConnectorSubCommand, network: Network) {
token,
amount,
recipient,
fee: Some(fee),
fee: None,
native_fee: Some(native_fee),
message,
transaction_options: TransactionOptions::default(),
Expand Down
2 changes: 1 addition & 1 deletion bridge-sdk/bridge-clients/near-bridge-client/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "near-bridge-client"
version = "0.2.13"
version = "0.2.14"
edition = "2021"

[dependencies]
Expand Down
3 changes: 1 addition & 2 deletions bridge-sdk/bridge-clients/near-bridge-client/src/btc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -675,8 +675,7 @@ impl NearBridgeClient {
let btc_connector = self.utxo_chain_connector(chain)?;
let chain_signatures_root_public_key = config.chain_signatures_root_public_key.ok_or(
BridgeSdkError::ContractConfigurationError(format!(
"Chain signatures root public key is not set for chain {:?}",
chain
"Chain signatures root public key is not set for chain {chain:?}",
)),
)?;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -603,7 +603,7 @@ impl NearBridgeClient {
#[allow(clippy::too_many_arguments)]
pub async fn init_transfer(
&self,
token_id: String,
token_id: AccountId,
amount: u128,
receiver: OmniAddress,
fee: u128,
Expand Down Expand Up @@ -656,9 +656,7 @@ impl NearBridgeClient {
ChangeRequest {
signer: self.signer()?,
nonce,
receiver_id: token_id.parse().map_err(|err| {
BridgeSdkError::ConfigError(format!("Failed to parse token_id: {err}"))
})?,
receiver_id: token_id,
method_name: "ft_transfer_call".to_string(),
args: serde_json::json!({
"receiver_id": omni_bridge_id,
Expand Down
2 changes: 1 addition & 1 deletion bridge-sdk/connectors/omni-connector/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "omni-connector"
version = "0.3.3"
version = "0.3.4"
edition = "2021"
rust-version = "1.88.0"

Expand Down
34 changes: 18 additions & 16 deletions bridge-sdk/connectors/omni-connector/src/omni_connector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ pub enum BindTokenArgs {

pub enum InitTransferArgs {
NearInitTransfer {
token: String,
token: AccountId,
amount: u128,
recipient: OmniAddress,
fee: Option<u128>,
Expand Down Expand Up @@ -390,7 +390,7 @@ impl OmniConnector {
#[allow(clippy::too_many_arguments)]
pub async fn near_init_transfer(
&self,
token_id: String,
token_id: AccountId,
amount: u128,
receiver: OmniAddress,
fee: u128,
Expand Down Expand Up @@ -1790,25 +1790,27 @@ impl OmniConnector {
message,
transaction_options,
} => {
let fee = fee.ok_or_else(|| {
BridgeSdkError::ConfigError(
"OmniConnector Near init_transfer missing fees: provide fee and native_fee before calling."
.to_string(),
)
})?;
let native_fee = native_fee.ok_or_else(|| {
BridgeSdkError::ConfigError(
"OmniConnector Near init_transfer missing fees: provide fee and native_fee before calling."
.to_string(),
)
})?;
match (fee, native_fee) {
(Some(_), Some(_)) => {
return Err(BridgeSdkError::ConfigError(
"init_transfer can't have both fee and native_fee".to_string(),
))
}
(None, None) => {
return Err(BridgeSdkError::ConfigError(
"init_transfer missing fee: provide fee or native_fee before calling."
.to_string(),
))
}
_ => {}
}

self.near_init_transfer(
near_token_id,
amount,
recipient,
fee,
native_fee,
fee.unwrap_or(0),
native_fee.unwrap_or(0),
message,
transaction_options,
)
Expand Down
Loading