mirror of
https://github.com/darkrenaissance/darkfi.git
synced 2026-04-28 03:00:18 -04:00
renamed TokenList to SolTokenList
This commit is contained in:
@@ -19,7 +19,7 @@ use drk::{
|
||||
serial::{deserialize, serialize},
|
||||
util::{
|
||||
assign_id, decimals, decode_base10, expand_path, generate_id, join_config_path,
|
||||
NetworkName, TokenList,
|
||||
DrkTokenList, NetworkName, SolTokenList,
|
||||
},
|
||||
wallet::WalletDb,
|
||||
Result,
|
||||
@@ -28,7 +28,7 @@ use drk::{
|
||||
struct Darkfid {
|
||||
config: DarkfidConfig,
|
||||
client: Arc<Mutex<Client>>,
|
||||
tokenlist: TokenList,
|
||||
tokenlist: SolTokenList,
|
||||
}
|
||||
|
||||
#[async_trait]
|
||||
@@ -77,7 +77,8 @@ impl Darkfid {
|
||||
|
||||
let client = Arc::new(Mutex::new(client));
|
||||
|
||||
let tokenlist = TokenList::new()?;
|
||||
let tokenlist = SolTokenList::new()?;
|
||||
let drk_tokenlist = DrkTokenList::new(tokenlist.clone())?;
|
||||
|
||||
Ok(Self {
|
||||
config,
|
||||
@@ -368,10 +369,6 @@ impl Darkfid {
|
||||
// --> {"method": "transfer", [dToken, address, amount]}
|
||||
// <-- {"result": "txID"}
|
||||
async fn transfer(&self, id: Value, params: Value) -> JsonResult {
|
||||
//let token_vec = self.wallet.get_token_ids();
|
||||
|
||||
//for (network_name, token_id) in self.tokenlist.drk_tokenlist.iter() {}
|
||||
|
||||
let args = params.as_array();
|
||||
|
||||
if args.is_none() {
|
||||
@@ -394,6 +391,10 @@ impl Darkfid {
|
||||
|
||||
let _token = token.as_str().unwrap();
|
||||
|
||||
//let token_vec = self.wallet.get_token_ids();
|
||||
|
||||
//for (network_name, token_id) in self.tokenlist.drk_tokenlist.iter() {}
|
||||
|
||||
if address.as_str().is_none() {
|
||||
return JsonResult::Err(jsonerr(InvalidAddressParam, None, id));
|
||||
}
|
||||
|
||||
@@ -6,4 +6,4 @@ pub mod token_list;
|
||||
pub use net_name::NetworkName;
|
||||
pub use parse::{assign_id, decimals, decode_base10, encode_base10, generate_id};
|
||||
pub use path::{expand_path, join_config_path};
|
||||
pub use token_list::{DrkTokenList, TokenList};
|
||||
pub use token_list::{DrkTokenList, SolTokenList};
|
||||
|
||||
@@ -5,7 +5,7 @@ use std::str::FromStr;
|
||||
|
||||
use crate::{
|
||||
serial::{deserialize, serialize},
|
||||
util::{NetworkName, TokenList},
|
||||
util::{NetworkName, SolTokenList},
|
||||
Error, Result,
|
||||
};
|
||||
|
||||
@@ -43,7 +43,7 @@ pub fn generate_id(tkn_str: &str, network: &NetworkName) -> Result<jubjub::Fr> {
|
||||
Ok(token_id)
|
||||
}
|
||||
|
||||
pub fn assign_id(network: &str, _token: &str, _tokenlist: TokenList) -> Result<String> {
|
||||
pub fn assign_id(network: &str, _token: &str, _tokenlist: SolTokenList) -> Result<String> {
|
||||
match NetworkName::from_str(network)? {
|
||||
#[cfg(feature = "sol")]
|
||||
NetworkName::Solana => match _token.to_lowercase().as_str() {
|
||||
@@ -68,7 +68,7 @@ pub fn assign_id(network: &str, _token: &str, _tokenlist: TokenList) -> Result<S
|
||||
}
|
||||
}
|
||||
|
||||
pub fn decimals(network: &str, _token: &str, _tokenlist: TokenList) -> Result<usize> {
|
||||
pub fn decimals(network: &str, _token: &str, _tokenlist: SolTokenList) -> Result<usize> {
|
||||
match NetworkName::from_str(network)? {
|
||||
#[cfg(feature = "sol")]
|
||||
NetworkName::Solana => match _token {
|
||||
@@ -92,7 +92,7 @@ pub fn decimals(network: &str, _token: &str, _tokenlist: TokenList) -> Result<us
|
||||
// Ok(apo)
|
||||
//}
|
||||
|
||||
pub fn symbol_to_id(token: &str, tokenlist: TokenList) -> Result<String> {
|
||||
pub fn symbol_to_id(token: &str, tokenlist: SolTokenList) -> Result<String> {
|
||||
let vec: Vec<char> = token.chars().collect();
|
||||
let mut counter = 0;
|
||||
for c in vec {
|
||||
|
||||
@@ -6,11 +6,11 @@ use serde_json::Value;
|
||||
use std::collections::HashMap;
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct TokenList {
|
||||
pub struct SolTokenList {
|
||||
sol_tokenlist: Value,
|
||||
}
|
||||
|
||||
impl TokenList {
|
||||
impl SolTokenList {
|
||||
pub fn new() -> Result<Self> {
|
||||
// TODO: FIXME
|
||||
let file_contents = std::fs::read_to_string("token/solanatokenlist.json")?;
|
||||
@@ -75,7 +75,7 @@ pub struct DrkTokenList {
|
||||
}
|
||||
|
||||
impl DrkTokenList {
|
||||
pub fn new(list: TokenList) -> Result<Self> {
|
||||
pub fn new(list: SolTokenList) -> Result<Self> {
|
||||
let mut drk_tokenlist = HashMap::new();
|
||||
let symbols = list.clone().get_symbols()?;
|
||||
for symbol in symbols {
|
||||
@@ -91,12 +91,12 @@ impl DrkTokenList {
|
||||
mod tests {
|
||||
|
||||
use super::*;
|
||||
use crate::util::TokenList;
|
||||
use crate::util::SolTokenList;
|
||||
use crate::Result;
|
||||
|
||||
#[test]
|
||||
pub fn test_get_symbols() -> Result<()> {
|
||||
let token = TokenList::new()?;
|
||||
let token = SolTokenList::new()?;
|
||||
let symbols = token.get_symbols()?;
|
||||
for symbol in symbols {
|
||||
println!("{}", symbol)
|
||||
|
||||
Reference in New Issue
Block a user