Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add more SPL tokens #1

Closed
wants to merge 7 commits into from
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
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ APP_LOAD_PARAMS += $(COMMON_LOAD_PARAMS)

APPNAME = "Solana"
APPVERSION_M = 1
APPVERSION_N = 4
APPVERSION_P = 2
APPVERSION_N = 5
APPVERSION_P = 0
APPVERSION = "$(APPVERSION_M).$(APPVERSION_N).$(APPVERSION_P)"

ifeq ($(TARGET_NAME),TARGET_NANOS)
Expand Down
581 changes: 568 additions & 13 deletions libsol/token_info.c

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions libsol/token_info.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,11 @@

#include "sol/parser.h"

typedef struct TokenInfo {
Pubkey mint_address;
char symbol[10];
} TokenInfo;

extern TokenInfo const TOKEN_REGISTRY[];

const char* get_token_symbol(const Pubkey* mint_address);
39 changes: 39 additions & 0 deletions libsol/token_info_test.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#include "common_byte_strings.h"
#include "util.h"
#include "token_info.h"
#include <assert.h>
#include <stdio.h>

void test_get_token_symbol_unknown() {
Pubkey pubkey = {{BYTES32_BS58_1}};
const char* symbol = get_token_symbol(&pubkey);

assert_string_equal(symbol, "???");
}

void test_get_token_symbol_USDC() {
Pubkey pubkey = {{0xc6, 0xfa, 0x7a, 0xf3, 0xbe, 0xdb, 0xad, 0x3a, 0x3d, 0x65, 0xf3,
0x6a, 0xab, 0xc9, 0x74, 0x31, 0xb1, 0xbb, 0xe4, 0xc2, 0xd2, 0xf6,
0xe0, 0xe4, 0x7c, 0xa6, 0x02, 0x03, 0x45, 0x2f, 0x5d, 0x61}};
const char* symbol = get_token_symbol(&pubkey);

assert_string_equal(symbol, "USDC");
}

void test_get_token_symbol_SOL() {
Pubkey pubkey = {{0x06, 0x9b, 0x88, 0x57, 0xfe, 0xab, 0x81, 0x84, 0xfb, 0x68, 0x7f,
0x63, 0x46, 0x18, 0xc0, 0x35, 0xda, 0xc4, 0x39, 0xdc, 0x1a, 0xeb,
0x3b, 0x55, 0x98, 0xa0, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x01}};
const char* symbol = get_token_symbol(&pubkey);

assert_string_equal(symbol, "SOL");
}

int main() {
test_get_token_symbol_unknown();
test_get_token_symbol_SOL();
test_get_token_symbol_USDC();

printf("passed\n");
return 0;
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading