primitives: add vec conversion functions
This commit is contained in:
Generated
+10
-9
@@ -3039,15 +3039,6 @@ dependencies = [
|
||||
"websocket-requests",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "nym-primitives"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"cosmrs",
|
||||
"cosmwasm-std",
|
||||
"thiserror",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "nym-socks5-client"
|
||||
version = "0.12.1"
|
||||
@@ -3692,6 +3683,15 @@ dependencies = [
|
||||
"uint",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "primitives"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"cosmrs",
|
||||
"cosmwasm-std",
|
||||
"thiserror",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "proc-macro-crate"
|
||||
version = "1.1.3"
|
||||
@@ -6008,6 +6008,7 @@ dependencies = [
|
||||
"log",
|
||||
"mixnet-contract-common",
|
||||
"network-defaults",
|
||||
"primitives",
|
||||
"prost",
|
||||
"reqwest",
|
||||
"serde",
|
||||
|
||||
@@ -21,6 +21,7 @@ url = { version = "2.2", features = ["serde"] }
|
||||
|
||||
coconut-interface = { path = "../../coconut-interface" }
|
||||
network-defaults = { path = "../../network-defaults" }
|
||||
primitives = { path = "../../primitives" }
|
||||
validator-api-requests = { path = "../../../validator-api/validator-api-requests" }
|
||||
|
||||
# required for nymd-client
|
||||
|
||||
@@ -369,14 +369,14 @@ pub trait SigningCosmWasmClient: CosmWasmClient {
|
||||
&self,
|
||||
sender_address: &AccountId,
|
||||
recipient_address: &AccountId,
|
||||
amount: Vec<Coin>,
|
||||
amount: Vec<primitives::Coin>,
|
||||
fee: Fee,
|
||||
memo: impl Into<String> + Send + 'static,
|
||||
) -> Result<broadcast::tx_commit::Response, NymdError> {
|
||||
let send_msg = MsgSend {
|
||||
from_address: sender_address.clone(),
|
||||
to_address: recipient_address.clone(),
|
||||
amount,
|
||||
amount: primitives::coin::try_into(amount)?,
|
||||
}
|
||||
.to_any()
|
||||
.map_err(|_| NymdError::SerializationError("MsgSend".to_owned()))?;
|
||||
|
||||
@@ -108,6 +108,9 @@ pub enum NymdError {
|
||||
|
||||
#[error("Abci query failed with code {0} - {1}")]
|
||||
AbciError(u32, abci::Log),
|
||||
|
||||
#[error("Failed to handle primitives")]
|
||||
PrimitivesError(#[from] primitives::PrimitivesError)
|
||||
}
|
||||
|
||||
impl NymdError {
|
||||
|
||||
@@ -606,7 +606,7 @@ impl<C> NymdClient<C> {
|
||||
pub async fn send(
|
||||
&self,
|
||||
recipient: &AccountId,
|
||||
amount: Vec<CosmosCoin>,
|
||||
amount: Vec<primitives::Coin>,
|
||||
memo: impl Into<String> + Send + 'static,
|
||||
) -> Result<broadcast::tx_commit::Response, NymdError>
|
||||
where
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
[package]
|
||||
name = "nym-primitives"
|
||||
name = "primitives"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
|
||||
@@ -50,6 +50,15 @@ impl TryFrom<Coin> for cosmrs::Coin {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
pub fn try_into(coins: Vec<Coin>) -> Result<Vec<cosmrs::Coin>, PrimitivesError> {
|
||||
coins.into_iter().map(TryInto::try_into).collect::<Result<Vec<_>, _>>()
|
||||
}
|
||||
|
||||
pub fn into(coins: Vec<Coin>) -> Vec<cosmwasm_std::Coin> {
|
||||
coins.into_iter().map(Into::into).collect()
|
||||
}
|
||||
|
||||
impl From<cosmwasm_std::Coin> for Coin {
|
||||
fn from(cosmwasm_coin: cosmwasm_std::Coin) -> Self {
|
||||
Self {
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
// Copyright 2022 - Nym Technologies SA <contact@nymtech.net>
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
mod coin;
|
||||
pub mod coin;
|
||||
mod error;
|
||||
|
||||
pub use error::PrimitivesError;
|
||||
pub use coin::Coin;
|
||||
Reference in New Issue
Block a user