mirror of
https://github.com/darkrenaissance/darkfi.git
synced 2026-04-28 03:00:18 -04:00
sol: Compile token list inside the program.
The reasoning is we support arbitrary tokens, and this is simply a helper for token aliases. If updates are necessary, they should be pushed to git, and the binaries recompiled.
This commit is contained in:
@@ -6,7 +6,7 @@ use async_native_tls::TlsConnector;
|
||||
use async_std::sync::{Arc, Mutex};
|
||||
use async_trait::async_trait;
|
||||
use futures::{SinkExt, StreamExt};
|
||||
use log::{debug, error, warn};
|
||||
use log::{debug, error, info};
|
||||
use rand::rngs::OsRng;
|
||||
use serde::Serialize;
|
||||
use serde_json::{json, Value};
|
||||
@@ -55,9 +55,7 @@ impl SolClient {
|
||||
let main_keypair: Keypair = deserialize(&main_keypair)?;
|
||||
let notify_channel = async_channel::unbounded();
|
||||
|
||||
warn!(target: "SOL BRIDGE", "Main SOL wallet: {:?}", main_keypair.to_bytes());
|
||||
|
||||
debug!(target: "SOL BRIDGE", "Main SOL wallet pubkey: {:?}", &main_keypair.pubkey());
|
||||
info!(target: "SOL BRIDGE", "Main SOL wallet pubkey: {:?}", &main_keypair.pubkey());
|
||||
|
||||
let (rpc_server, wss_server) = match network {
|
||||
"mainnet" => (
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
use serde_json::Value;
|
||||
use std::collections::HashMap;
|
||||
|
||||
use crate::{
|
||||
util::{generate_id, NetworkName},
|
||||
Error, Result,
|
||||
};
|
||||
use serde_json::Value;
|
||||
use std::collections::HashMap;
|
||||
use std::iter::FromIterator;
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct SolTokenList {
|
||||
@@ -13,9 +13,8 @@ pub struct SolTokenList {
|
||||
|
||||
impl SolTokenList {
|
||||
pub fn new() -> Result<Self> {
|
||||
// TODO: FIXME
|
||||
let file_contents = std::fs::read_to_string("token/solanatokenlist.json")?;
|
||||
let sol_tokenlist: Value = serde_json::from_str(&file_contents)?;
|
||||
let file_contents = include_bytes!("../../token/solanatokenlist.json");
|
||||
let sol_tokenlist: Value = serde_json::from_slice(file_contents)?;
|
||||
|
||||
let tokens = sol_tokenlist["tokens"]
|
||||
.as_array()
|
||||
@@ -112,8 +111,8 @@ impl DrkTokenList {
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(unused_imports)]
|
||||
mod tests {
|
||||
|
||||
use super::*;
|
||||
use crate::util::{DrkTokenList, SolTokenList};
|
||||
use crate::Result;
|
||||
@@ -127,6 +126,7 @@ mod tests {
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[test]
|
||||
pub fn test_get_id_from_symbols() -> Result<()> {
|
||||
let token = SolTokenList::new()?;
|
||||
@@ -136,6 +136,7 @@ mod tests {
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[test]
|
||||
pub fn test_hashmap() -> Result<()> {
|
||||
let token = SolTokenList::new()?;
|
||||
|
||||
Reference in New Issue
Block a user