diff --git a/Cargo.lock b/Cargo.lock index 9acd166d20..4736c261e7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3552,6 +3552,7 @@ name = "kdf_walletconnect" version = "0.1.0" dependencies = [ "async-trait", + "base64 0.21.7", "chrono", "common", "derive_more", diff --git a/mm2src/coins_activation/src/tendermint_with_assets_activation.rs b/mm2src/coins_activation/src/tendermint_with_assets_activation.rs index 554b7bc877..c15e6cad0d 100644 --- a/mm2src/coins_activation/src/tendermint_with_assets_activation.rs +++ b/mm2src/coins_activation/src/tendermint_with_assets_activation.rs @@ -251,7 +251,7 @@ async fn get_walletconnect_pubkey( })?; let pubkey = match account.algo { - CosmosAccountAlgo::Secp256k1 => { + CosmosAccountAlgo::Secp256k1 | CosmosAccountAlgo::TendermintSecp256k1 => { TendermintPublicKey::from_raw_secp256k1(&account.pubkey).ok_or("Invalid secp256k1 pubkey".to_owned()) }, } diff --git a/mm2src/kdf_walletconnect/Cargo.toml b/mm2src/kdf_walletconnect/Cargo.toml index d83ce583ed..b8f5bd9a29 100644 --- a/mm2src/kdf_walletconnect/Cargo.toml +++ b/mm2src/kdf_walletconnect/Cargo.toml @@ -5,6 +5,7 @@ edition = "2021" [dependencies] async-trait = "0.1.52" +base64 = "0.21.2" chrono = { version = "0.4.23", "features" = ["serde"] } common = { path = "../common" } derive_more = "0.99" diff --git a/mm2src/kdf_walletconnect/src/chain/cosmos.rs b/mm2src/kdf_walletconnect/src/chain/cosmos.rs index 27c742e06f..9bd944c941 100644 --- a/mm2src/kdf_walletconnect/src/chain/cosmos.rs +++ b/mm2src/kdf_walletconnect/src/chain/cosmos.rs @@ -1,4 +1,5 @@ use crate::{error::WalletConnectCtxError, WalletConnectCtx}; +use base64::{engine::general_purpose, Engine}; use chrono::Utc; use common::log::info; use futures::StreamExt; @@ -11,9 +12,11 @@ use serde_json::Value; use super::WcRequestMethods; #[derive(Serialize, Deserialize, Debug, Clone)] -#[serde(rename_all = "lowercase")] pub enum CosmosAccountAlgo { + #[serde(rename = "lowercase")] Secp256k1, + #[serde(rename = "tendermint/PubKeySecp256k1")] + TendermintSecp256k1, } #[derive(Debug, Clone, Serialize, Deserialize)] @@ -54,7 +57,13 @@ where .map(|n| n as u8) }) .collect(), - _ => Err(serde::de::Error::custom("Pubkey must be an object or array")), + Value::String(data) => { + let data = general_purpose::STANDARD + .decode(data) + .map_err(|err| serde::de::Error::custom(err.to_string()))?; + Ok(data) + }, + _ => Err(serde::de::Error::custom("Pubkey must be an string, object or array")), } } diff --git a/mm2src/kdf_walletconnect/src/lib.rs b/mm2src/kdf_walletconnect/src/lib.rs index d7f1291fa9..0ddb8900ea 100644 --- a/mm2src/kdf_walletconnect/src/lib.rs +++ b/mm2src/kdf_walletconnect/src/lib.rs @@ -6,7 +6,6 @@ mod metadata; #[allow(unused)] mod pairing; mod session; -use async_trait::async_trait; use chain::{build_required_namespaces, cosmos::{cosmos_get_accounts_impl, CosmosAccount}, SUPPORTED_CHAINS};