Skip to content
Merged
Show file tree
Hide file tree
Changes from 10 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
1 change: 0 additions & 1 deletion Cargo.lock

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

1 change: 0 additions & 1 deletion mm2src/coins/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ nom = "6.1.2"
mm2_core = { path = "../mm2_core" }
mm2_err_handle = { path = "../mm2_err_handle" }
mm2_event_stream = { path = "../mm2_event_stream" }
mm2_git = { path = "../mm2_git" }
mm2_io = { path = "../mm2_io" }
mm2_metrics = { path = "../mm2_metrics" }
mm2_net = { path = "../mm2_net" }
Expand Down
18 changes: 9 additions & 9 deletions mm2src/coins/lp_coins.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ use mm2_rpc::data::legacy::{EnabledCoin, GetEnabledResponse, Mm2RpcResult};
use mocktopus::macros::*;
use parking_lot::Mutex as PaMutex;
use rpc::v1::types::{Bytes as BytesJson, H256 as H256Json};
use rpc_command::tendermint::ibc::ChannelId;
use serde::{Deserialize, Deserializer, Serialize, Serializer};
use serde_json::{self as json, Value as Json};
use std::array::TryFromSliceError;
Expand Down Expand Up @@ -2220,7 +2221,7 @@ pub struct WithdrawRequest {
fee: Option<WithdrawFee>,
memo: Option<String>,
/// Tendermint specific field used for manually providing the IBC channel IDs.
ibc_source_channel: Option<String>,
ibc_source_channel: Option<ChannelId>,

@onur-ozkan onur-ozkan Apr 9, 2025

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Breakage 2: This now expects a numeric value (previously it accepted any String value without validation by hoping it was using in the channel-$id format) to align with the logic used in the coins file.

/// Currently, this flag is used by ETH/ERC20 coins activated with MetaMask **only**.
#[cfg(target_arch = "wasm32")]
#[serde(default)]
Expand Down Expand Up @@ -3177,15 +3178,15 @@ pub enum WithdrawError {
},
#[display(fmt = "Signing error {}", _0)]
SigningError(String),
#[display(fmt = "Eth transaction type not supported")]
#[display(fmt = "Transaction type not supported")]
TxTypeNotSupported,
#[display(fmt = "'chain_registry_name' was not found in coins configuration for '{}'", _0)]
RegistryNameIsMissing(String),
#[display(
fmt = "IBC channel could not found for '{}' address. Consider providing it manually with 'ibc_source_channel' in the request.",
_0
fmt = "IBC channel could not found from coins file for '{}' address. Provide it manually by including `ibc_source_channel` in the request. See https://ibc.iobscan.io/channels for reference.",
Comment thread
shamardy marked this conversation as resolved.
Outdated
target_address
)]
IBCChannelCouldNotFound(String),
IBCChannelCouldNotFound {
target_address: String,
},
}

impl HttpStatusCode for WithdrawError {
Expand Down Expand Up @@ -3214,8 +3215,7 @@ impl HttpStatusCode for WithdrawError {
| WithdrawError::NoChainIdSet { .. }
| WithdrawError::TxTypeNotSupported
| WithdrawError::SigningError(_)
| WithdrawError::RegistryNameIsMissing(_)
| WithdrawError::IBCChannelCouldNotFound(_)
| WithdrawError::IBCChannelCouldNotFound { .. }
| WithdrawError::MyAddressNotNftOwner { .. } => StatusCode::BAD_REQUEST,
WithdrawError::HwError(_) => StatusCode::GONE,
#[cfg(target_arch = "wasm32")]
Expand Down
3 changes: 2 additions & 1 deletion mm2src/coins/rpc_command/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@ pub mod init_account_balance;
pub mod init_create_account;
pub mod init_scan_for_new_addresses;
pub mod init_withdraw;
#[cfg(not(target_arch = "wasm32"))] pub mod lightning;
pub mod tendermint;

#[cfg(not(target_arch = "wasm32"))] pub mod lightning;
12 changes: 12 additions & 0 deletions mm2src/coins/rpc_command/tendermint/ibc.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
use std::fmt;

#[derive(Clone, Copy, Debug, Deserialize, Eq, PartialEq, Serialize, Hash)]
pub struct ChannelId(u16);

impl fmt::Display for ChannelId {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "channel-{}", self.0) }
}

impl ChannelId {
pub fn new(id: u16) -> Self { Self(id) }
}
35 changes: 0 additions & 35 deletions mm2src/coins/rpc_command/tendermint/ibc_chains.rs

This file was deleted.

105 changes: 0 additions & 105 deletions mm2src/coins/rpc_command/tendermint/ibc_transfer_channels.rs

This file was deleted.

13 changes: 1 addition & 12 deletions mm2src/coins/rpc_command/tendermint/mod.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,2 @@
mod ibc_chains;
mod ibc_transfer_channels;
pub mod ibc;
pub mod staking;

pub use ibc_chains::*;
pub use ibc_transfer_channels::*;

// Global constants for interacting with https://github.com/KomodoPlatform/chain-registry repository
// using `mm2_git` crate.
pub(crate) const CHAIN_REGISTRY_REPO_OWNER: &str = "KomodoPlatform";
pub(crate) const CHAIN_REGISTRY_REPO_NAME: &str = "chain-registry";
pub(crate) const CHAIN_REGISTRY_BRANCH: &str = "nucl";
pub(crate) const CHAIN_REGISTRY_IBC_DIR_NAME: &str = "_IBC";
3 changes: 2 additions & 1 deletion mm2src/coins/rpc_command/tendermint/staking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ impl From<TendermintCoinRpcError> for StakingInfoError {
match e {
TendermintCoinRpcError::InvalidResponse(e)
| TendermintCoinRpcError::PerformError(e)
| TendermintCoinRpcError::RpcClientError(e) => StakingInfoError::Transport(e),
| TendermintCoinRpcError::RpcClientError(e)
| TendermintCoinRpcError::NotFound(e) => StakingInfoError::Transport(e),
Comment thread
onur-ozkan marked this conversation as resolved.
TendermintCoinRpcError::Prost(e) | TendermintCoinRpcError::InternalError(e) => StakingInfoError::Internal(e),
TendermintCoinRpcError::UnexpectedAccountType { .. } => StakingInfoError::Internal(
"RPC client got an unexpected error 'TendermintCoinRpcError::UnexpectedAccountType', this isn't normal."
Expand Down
Loading