From ad1c11e74908132c0776f3ab2c7e60900720ae28 Mon Sep 17 00:00:00 2001 From: timdegen <104884878+timdegen@users.noreply.github.com> Date: Fri, 4 Aug 2023 02:56:35 +0100 Subject: [PATCH] Make node, price, tokenlist, chain_type, asset_type public --- primitives/src/asset_type.rs | 7 +++++++ primitives/src/chain_type.rs | 21 +++++++++++-------- primitives/src/config.rs | 40 ++++++++++++++++++++++-------------- primitives/src/lib.rs | 7 ++++++- primitives/src/node.rs | 39 +++++++++++++++++++++-------------- primitives/src/price.rs | 2 +- primitives/src/tokenlist.rs | 34 ++++++++++++++++++------------ 7 files changed, 97 insertions(+), 53 deletions(-) diff --git a/primitives/src/asset_type.rs b/primitives/src/asset_type.rs index 43cb3c65..e7973bd9 100644 --- a/primitives/src/asset_type.rs +++ b/primitives/src/asset_type.rs @@ -1,4 +1,9 @@ +use typeshare::typeshare; +use serde::{Serialize, Deserialize}; + +#[derive(Debug, Clone, Serialize, Deserialize)] #[typeshare(swift = "Equatable, Codable, CaseIterable")] +#[serde(rename_all = "UPPERCASE")] pub enum AssetType { NATIVE, ERC20, @@ -9,7 +14,9 @@ pub enum AssetType { TRC20, } +#[derive(Debug, Clone, Serialize, Deserialize)] #[typeshare(swift = "Equatable, Codable, CaseIterable")] +#[serde(rename_all = "UPPERCASE")] pub enum AssetSubtype { NATIVE, TOKEN, diff --git a/primitives/src/chain_type.rs b/primitives/src/chain_type.rs index e239dbc4..bc5b3354 100644 --- a/primitives/src/chain_type.rs +++ b/primitives/src/chain_type.rs @@ -1,10 +1,15 @@ -#[typeshare] +use typeshare::typeshare; +use serde::{Serialize, Deserialize}; + +#[derive(Debug, Serialize, Deserialize)] +#[typeshare(swift = "Equatable, Codable, CaseIterable")] +#[serde(rename_all = "lowercase")] pub enum BlockchainType { - ethereum, - bitcoin, - binance, - solana, - cosmos, - ton, - tron, + Ethereum, + Bitcoin, + Binance, + Solana, + Cosmos, + Ton, + Tron, } \ No newline at end of file diff --git a/primitives/src/config.rs b/primitives/src/config.rs index 94bfa991..99068d17 100644 --- a/primitives/src/config.rs +++ b/primitives/src/config.rs @@ -1,35 +1,45 @@ +use typeshare::typeshare; +use serde::{Serialize, Deserialize}; + +use crate::tokenlist::TokenListChainVersion; + +#[derive(Debug, Clone, Serialize, Deserialize)] #[typeshare(swift="Codable")] #[serde(rename_all = "camelCase")] -struct ConfigResponse { - app: ConfigApp, - versions: ConfigVersions, +pub struct ConfigResponse { + pub app: ConfigApp, + pub versions: ConfigVersions, } +#[derive(Debug, Clone, Serialize, Deserialize)] #[typeshare(swift="Codable")] -struct ConfigApp { - ios: ConfigIOSApp, - android: ConfigAndroidApp, +pub struct ConfigApp { + pub ios: ConfigIOSApp, + pub android: ConfigAndroidApp, } +#[derive(Debug, Clone, Serialize, Deserialize)] #[typeshare(swift="Codable")] -struct ConfigIOSApp { - version: ConfigAppVersion +pub struct ConfigIOSApp { + pub version: ConfigAppVersion } +#[derive(Debug, Clone, Serialize, Deserialize)] #[typeshare(swift="Codable")] -struct ConfigAndroidApp { - version: ConfigAppVersion +pub struct ConfigAndroidApp { + pub version: ConfigAppVersion } +#[derive(Debug, Clone, Serialize, Deserialize)] #[typeshare(swift="Codable")] -struct ConfigAppVersion { - production: String, - beta: String, - alpha: String, +pub struct ConfigAppVersion { + pub production: String, + pub beta: String, + pub alpha: String, } #[typeshare(swift="Codable")] -#[derive(Debug, Deserialize, Serialize)] +#[derive(Debug, Clone, Serialize, Deserialize)] #[serde(rename_all = "camelCase")] pub struct ConfigVersions { pub nodes: i32, diff --git a/primitives/src/lib.rs b/primitives/src/lib.rs index 3e0a783e..07bfe49a 100644 --- a/primitives/src/lib.rs +++ b/primitives/src/lib.rs @@ -3,4 +3,9 @@ pub mod chain; pub mod name; pub mod price; -pub mod asset_price; \ No newline at end of file +pub mod asset_price; +pub mod tokenlist; +pub mod asset_type; +pub mod chain_type; +pub mod node; +pub mod config; \ No newline at end of file diff --git a/primitives/src/node.rs b/primitives/src/node.rs index defaad93..8a62ac89 100644 --- a/primitives/src/node.rs +++ b/primitives/src/node.rs @@ -1,31 +1,40 @@ +use typeshare::typeshare; +use serde::{Serialize, Deserialize}; + +#[derive(Debug, Clone, Serialize, Deserialize)] #[typeshare(swift="Codable")] -struct Node { - url: String, - status: NodeStatus, - priority: i32, +pub struct Node { + pub url: String, + pub status: NodeStatus, + pub priority: i32, } +#[derive(Debug, Clone, Serialize, Deserialize)] #[typeshare(swift="Codable")] -struct ChainNode { - chain: String, - node: Node +pub struct ChainNode { + pub chain: String, + pub node: Node } +#[derive(Debug, Clone, Serialize, Deserialize)] #[typeshare(swift="Codable")] -struct ChainNodes { - chain: String, - nodes: Vec +pub struct ChainNodes { + pub chain: String, + pub nodes: Vec } +#[derive(Debug, Clone, Serialize, Deserialize)] #[typeshare(swift="Codable")] #[serde(rename_all = "camelCase")] -struct NodesResponse { - version: i32, - nodes: Vec +pub struct NodesResponse { + pub version: i32, + pub nodes: Vec } +#[derive(Debug, Clone, Serialize, Deserialize)] #[typeshare(swift = "Equatable, Codable, CaseIterable")] +#[serde(rename_all = "lowercase")] pub enum NodeStatus { - active, - inactive, + Active, + Inactive, } \ No newline at end of file diff --git a/primitives/src/price.rs b/primitives/src/price.rs index de98d387..dbb5e4d8 100644 --- a/primitives/src/price.rs +++ b/primitives/src/price.rs @@ -1,5 +1,5 @@ -use serde::{Serialize, Deserialize}; use typeshare::typeshare; +use serde::{Serialize, Deserialize}; #[derive(Copy, Clone, Debug, Serialize, Deserialize)] #[typeshare(swift = "Equatable, Codable, Hashable")] diff --git a/primitives/src/tokenlist.rs b/primitives/src/tokenlist.rs index ea51ac1f..b9bbda45 100644 --- a/primitives/src/tokenlist.rs +++ b/primitives/src/tokenlist.rs @@ -1,23 +1,31 @@ +use typeshare::typeshare; +use crate::chain::Chain; +use crate::asset_type::AssetType; +use serde::{Serialize, Deserialize}; + +#[derive(Debug, Clone, Serialize, Deserialize)] #[typeshare] -struct TokenList { - version: i32, - assets: Vec, +pub struct TokenList { + pub version: i32, + pub assets: Vec, } +#[derive(Debug, Clone, Serialize, Deserialize)] #[typeshare] -struct TokenListAsset { - chain: Chain, +pub struct TokenListAsset { + pub chain: Chain, #[serde(rename = "tokenId")] - token_id: String, - name: String, - symbol: String, + pub token_id: String, + pub name: String, + pub symbol: String, #[serde(rename = "type")] - asset_type: AssetType, - decimals: i32, + pub asset_type: AssetType, + pub decimals: i32, } +#[derive(Debug, Clone, Serialize, Deserialize)] #[typeshare] -struct TokenListChainVersion { - chain: String, - version: i32, +pub struct TokenListChainVersion { + pub chain: String, + pub version: i32, } \ No newline at end of file