Skip to content

Commit

Permalink
refactoring and unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
borngraced committed Oct 8, 2024
1 parent 481f1c3 commit 0c00710
Show file tree
Hide file tree
Showing 19 changed files with 262 additions and 146 deletions.
5 changes: 3 additions & 2 deletions Cargo.lock

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

26 changes: 15 additions & 11 deletions mm2src/coins/tendermint/tendermint_coin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,10 @@ pub enum TendermintWalletConnectionType {
Other,
}

impl Default for TendermintWalletConnectionType {
fn default() -> Self { Self::Other }
}

pub struct TendermintCoinImpl {
ticker: String,
/// As seconds
Expand Down Expand Up @@ -652,7 +656,7 @@ impl TendermintCoin {
nodes: Vec<RpcNode>,
tx_history: bool,
activation_policy: TendermintActivationPolicy,
wallet_connection_type: TendermintWalletConnectionType,
wallet_connection_type: Option<TendermintWalletConnectionType>,
) -> MmResult<Self, TendermintInitError> {
if nodes.is_empty() {
return MmError::err(TendermintInitError {
Expand Down Expand Up @@ -717,7 +721,7 @@ impl TendermintCoin {
client: TendermintRpcClient(AsyncMutex::new(client_impl)),
chain_registry_name: protocol_info.chain_registry_name,
ctx: ctx.weak(),
wallet_connection_type,
wallet_connection_type: wallet_connection_type.unwrap_or_default(),
})))
}

Expand Down Expand Up @@ -3506,7 +3510,7 @@ pub mod tendermint_coin_tests {
nodes,
false,
activation_policy,
false,
None,
))
.unwrap();

Expand Down Expand Up @@ -3632,7 +3636,7 @@ pub mod tendermint_coin_tests {
nodes,
false,
activation_policy,
false,
None,
))
.unwrap();

Expand Down Expand Up @@ -3695,7 +3699,7 @@ pub mod tendermint_coin_tests {
nodes,
false,
activation_policy,
false,
None,
))
.unwrap();

Expand Down Expand Up @@ -3769,7 +3773,7 @@ pub mod tendermint_coin_tests {
nodes,
false,
activation_policy,
false,
None,
))
.unwrap();

Expand Down Expand Up @@ -3956,7 +3960,7 @@ pub mod tendermint_coin_tests {
nodes,
false,
activation_policy,
false,
None,
))
.unwrap();

Expand Down Expand Up @@ -4039,7 +4043,7 @@ pub mod tendermint_coin_tests {
nodes,
false,
activation_policy,
false,
None,
))
.unwrap();

Expand Down Expand Up @@ -4115,7 +4119,7 @@ pub mod tendermint_coin_tests {
nodes,
false,
activation_policy,
false,
None,
))
.unwrap();

Expand Down Expand Up @@ -4187,7 +4191,7 @@ pub mod tendermint_coin_tests {
nodes,
false,
activation_policy,
false,
None,
))
.unwrap();

Expand Down Expand Up @@ -4242,7 +4246,7 @@ pub mod tendermint_coin_tests {
nodes,
false,
activation_policy,
false,
None,
))
.unwrap();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ impl PlatformCoinWithTokensActivationOps for TendermintCoin {
activation_request.nodes,
activation_request.tx_history,
activation_policy,
wallet_connectin_type,
Some(wallet_connectin_type),
)
.await
}
Expand Down
1 change: 1 addition & 0 deletions mm2src/kdf_walletconnect/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ version = "0.1.0"
edition = "2021"

[dependencies]
anyhow = "1.0.89"
async-trait = "0.1.52"
base64 = "0.21.2"
chrono = { version = "0.4.23", "features" = ["serde"] }
Expand Down
14 changes: 7 additions & 7 deletions mm2src/kdf_walletconnect/src/inbound_message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ use serde_json::Value;

use crate::{error::WalletConnectCtxError,
pairing::{reply_pairing_delete_response, reply_pairing_extend_response, reply_pairing_ping_response},
session::{delete::reply_session_delete_request,
event::SessionEvents,
extend::reply_session_extend_request,
ping::reply_session_ping_request,
propose::{process_session_propose_response, reply_session_proposal_request},
settle::reply_session_settle_request,
update::reply_session_update_request},
session::rpc::{delete::reply_session_delete_request,
event::SessionEvents,
extend::reply_session_extend_request,
ping::reply_session_ping_request,
propose::{process_session_propose_response, reply_session_proposal_request},
settle::reply_session_settle_request,
update::reply_session_update_request},
WalletConnectCtx};

#[derive(Debug, Serialize, Deserialize)]
Expand Down
2 changes: 1 addition & 1 deletion mm2src/kdf_walletconnect/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ use relay_rpc::{auth::{ed25519_dalek::SigningKey, AuthToken},
ResponseParamsSuccess},
ErrorResponse, Payload, Request, Response, SuccessfulResponse}};
use serde_json::Value;
use session::{propose::send_proposal_request, SessionManagement, SymKeyPair};
use session::{key::SymKeyPair, rpc::propose::send_proposal_request, SessionManagement};
use std::{sync::Arc, time::Duration};
use storage::SessionStorageDb;
use wc_common::{decode_and_decrypt_type0, encrypt_and_encode, EnvelopeType};
Expand Down
Loading

0 comments on commit 0c00710

Please sign in to comment.