Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 46 additions & 4 deletions crates/mcp/src/surfpool/set_token_account.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ use solana_pubkey::Pubkey;
use solana_signer::Signer as _;
use spl_associated_token_account_interface::address::get_associated_token_address_with_program_id;
use surfpool_types::{
VERIFIED_TOKENS, VERIFIED_TOKENS_BY_SYMBOL,
types::{AccountUpdate, TokenAccountUpdate},
verified_tokens::VERIFIED_TOKENS_BY_SYMBOL,
};

const SOL_DECIMALS: u32 = 9;
Expand Down Expand Up @@ -187,10 +187,10 @@ pub async fn run(
})
} else if let Ok(mint_pubkey) = Pubkey::try_from(token_identifier.as_str()) {
let mint_str = mint_pubkey.to_string();
let token_info = VERIFIED_TOKENS_BY_SYMBOL
let token_info = VERIFIED_TOKENS
.iter()
.find(|(_, info)| info.address == mint_str)
.map(|(symbol, info)| (symbol.clone(), info.decimals as u32));
.find(|info| info.address == mint_str)
.map(|info| (info.symbol.clone(), info.decimals as u32));
if let Some((symbol, decimals)) = token_info {
Ok(TokenDetails {
is_sol: false,
Expand Down Expand Up @@ -363,3 +363,45 @@ pub async fn run(
),
}
}

#[cfg(test)]
mod tests {
use std::{
io::{Read, Write},
net::TcpListener,
};

use super::*;

#[tokio::test]
async fn portal_wbtc_mint_resolves_its_decimals() {
let listener = TcpListener::bind("127.0.0.1:0").expect("bind canned rpc");
let addr = listener.local_addr().expect("local addr");
std::thread::spawn(move || {
let (mut stream, _) = listener.accept().expect("accept");
assert_ne!(stream.read(&mut [0u8; 16 * 1024]).expect("read request"), 0);
let body = r#"{"jsonrpc":"2.0","result":null,"id":1}"#;
write!(
stream,
"HTTP/1.1 200 OK\r\nContent-Type: application/json\r\nContent-Length: {}\r\nConnection: close\r\n\r\n{body}",
body.len()
)
.expect("write response");
});

let response = run(
format!("http://{addr}"),
SeededAccount::new(None),
Some("3NZ9JMVBmGAqocybic2c7LQCJScmgsAZ6vQqTDzcqmJh".to_string()),
Some(1),
None,
None,
)
.await;

let Some([SetAccountSuccess::Token(updated)]) = response.success.as_deref() else {
panic!("{:?}", response.error);
};
assert_eq!(updated.token_amount, 100_000_000);
}
}
2 changes: 1 addition & 1 deletion crates/types/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ pub use features::*;
pub use jito_bundles::*;
pub use scenarios::*;
pub use types::*;
pub use verified_tokens::{TokenInfo, VERIFIED_TOKENS_BY_SYMBOL};
pub use verified_tokens::{TokenInfo, VERIFIED_TOKENS, VERIFIED_TOKENS_BY_SYMBOL};
3 changes: 1 addition & 2 deletions crates/types/src/verified_tokens.csv
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,7 @@
"7Y2TPeq3hqw21LRTCi4wBWoivDngCpNNJsN1hzhZpump","Sachicoin","SACHI","https://ipfs.io/ipfs/bafybeid7vmfzlijieyk2yjc5pq4e7dkbn2w7yadoojuf6qsqwably5w7nm",6,"GgniteFe3VjeJq1PraxoQsFKw4qHajBDpYViVTqggoq5",985127434.646622,985127434.646622,"TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA","","verified","2025-10-07T07:37:18Z",0.006875074890217659,"2025-12-08T21:49:24.619965854Z"
"8x5VqbHA8D7NkD52uNuS5nnt3PwA8pLD34ymskeSo2Wn","zerebro","ZEREBRO","https://ipfs.io/ipfs/QmZ1HDSibY2LdEmC1tPHK36ApGCQACJENqsbPsT2nc29AD",6,"9zPxrXcor3gzTsg73LGBji6VVpfNYeiAq9T9GDPmKTHV",999952225.37906,999952225.37906,"TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA","","community|launchpad|moonshot-verified|verified","2024-10-25T05:55:11Z",0.03042315351134891,"2025-12-08T21:48:07.619745813Z"
"LBTCgU4b3wsFKsPwBn1rRZDx5DoFutM6RPiEt1TPDsY","Lombard Staked BTC","LBTC","https://www.lombard.finance/lbtc/LBTC.png",8,"CuyPF5P5ZgAVKqiUTF29XiD76bUkG4jD71KuiJrLiwCt",955.63389127,955.63389127,"TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA","HzCyQqcAoxAHeqHAWH1RQbfw7GNUzinqSWideGj7ZtEE","community-assist|verified|major","2025-04-02T15:01:21Z",91142.22356340135,"2025-12-08T21:48:48.619784251Z"
"5XZw2LKTyrfvfiskJ78AMpackRjPcyCif1WhUsPDuVqQ","Wrapped BTC","WBTC","https://j73gp4w27ucraqtyzsqa5th4fwldfvqgq576cnceekfactgk4fla.arweave.net/T_Zn8tr9BRBCeMygDsz8LZYy1gaHf-E0RCKKAUzK4VY
",8,"3YDttErxTR3WNwhGkFm8QbpfHtbCEzG96E6U29jQWYuK",104.83190243,104.83190243,"TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA","3YDttErxTR3WNwhGkFm8QbpfHtbCEzG96E6U29jQWYuK","community-assist|verified|major","2025-04-28T07:00:50Z",90600.87361021532,"2025-12-08T21:45:47.620764281Z"
"5XZw2LKTyrfvfiskJ78AMpackRjPcyCif1WhUsPDuVqQ","Wrapped BTC","WBTC","https://j73gp4w27ucraqtyzsqa5th4fwldfvqgq576cnceekfactgk4fla.arweave.net/T_Zn8tr9BRBCeMygDsz8LZYy1gaHf-E0RCKKAUzK4VY",8,"3YDttErxTR3WNwhGkFm8QbpfHtbCEzG96E6U29jQWYuK",104.83190243,104.83190243,"TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA","3YDttErxTR3WNwhGkFm8QbpfHtbCEzG96E6U29jQWYuK","community-assist|verified|major","2025-04-28T07:00:50Z",90600.87361021532,"2025-12-08T21:45:47.620764281Z"
"F7pB3ZdfBnyFw2LRHydWEn9BmhEa5XihXLjhySFRpump","You’ll own nothing & be happy","NOTHING","https://ipfs.io/ipfs/QmUrePFqpeW7AXZhFhexoCMFRcmyP3z5rrBF9RXGu32rFw",6,"GHgSVNjsWXyTc3ZNEEaEowF5xMT4wptUKFcerKSgSVtB",999931431.949414,999931431.949414,"TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA","","verified","2025-11-11T20:07:12Z",0.0016335744185029628,"2025-12-08T21:49:18.620061143Z"
"3ThdFZQKM6kRyVGLG48kaPg5TRMhYMKY1iCRa9xop1WC","eUSX","eUSX","https://raw.githubusercontent.com/Solstice-Labs-Official/eusx-metadata/refs/heads/main/eusx.png",6,"5RabYeYt19sor9RvExkiRvv1T9rWje5hPW7xeYXB6quQ",129179166.045647,129179166.045647,"TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA","2aHdm37djj4c21ztMRBmmo4my6RtzN5Nn58Y39rpWbRM","community-assist|verified|stable","2025-06-24T14:47:50Z",1.016026466750484,"2025-12-08T21:49:07.619462473Z"
"KENJSUYLASHUMfHyy5o4Hp2FdNqZg1AsUPhfH2kYvEP","test griffain.com","GRIFFAIN","https://griffain.com/logo.png",6,"KEN7s6mHAFpqmvppk7L9VaJW3htu3jz6z3dDjiaWdYT",999860138.921969,999860138.921969,"TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA","","birdeye-trending|community|launchpad|moonshot-verified|verified","2024-11-02T23:37:45Z",0.020462329233444255,"2025-12-08T21:48:03.629819082Z"
Expand Down
20 changes: 19 additions & 1 deletion crates/types/src/verified_tokens.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ pub static VERIFIED_TOKENS_BY_SYMBOL: Lazy<HashMap<String, TokenInfo>> = Lazy::n

#[cfg(test)]
mod tests {
use super::parse_csv_line;
use super::{VERIFIED_TOKENS, parse_csv_line};

#[test]
fn parse_csv_line_handles_quoted_fields() {
Expand All @@ -107,4 +107,22 @@ mod tests {

assert_eq!(fields[1], r#""quoted""#);
}

#[test]
fn loads_every_row() {
let rows = include_str!("verified_tokens.csv").lines().skip(1).count();

assert_eq!(VERIFIED_TOKENS.len(), rows);
}

#[test]
fn loads_wbtc() {
let wbtc = VERIFIED_TOKENS
.iter()
.find(|token| token.address == "5XZw2LKTyrfvfiskJ78AMpackRjPcyCif1WhUsPDuVqQ")
.expect("WBTC row loads");

assert_eq!(wbtc.symbol, "WBTC");
assert_eq!(wbtc.decimals, 8);
}
}
8 changes: 8 additions & 0 deletions greptile.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"autoReview": [],
"strictness": 1,
"customContext": {
"rules": [],
"files": []
}
}
Loading