From 02d96ae3106dc8af9b4bf08592ddefe89d34b2c4 Mon Sep 17 00:00:00 2001 From: Denis <136321897+defisaur@users.noreply.github.com> Date: Fri, 18 Aug 2023 13:40:29 +0400 Subject: [PATCH] add neon (#125) --- coin/coins.go | 27 ++++++++++++++++++++++++++- coin/coins.yml | 7 +++++++ coin/models.go | 2 ++ coin/models_test.go | 11 +++++++++++ types/chain.go | 2 ++ types/token.go | 8 +++++++- 6 files changed, 55 insertions(+), 2 deletions(-) diff --git a/coin/coins.go b/coin/coins.go index c9ecda0..8c59223 100644 --- a/coin/coins.go +++ b/coin/coins.go @@ -1,6 +1,6 @@ // Code generated by go generate; DO NOT EDIT. // This file was generated by robots at -// 2023-08-16 11:44:44.153204 +0900 JST m=+0.002881626 +// 2023-08-18 12:35:42.76733 +0400 +04 m=+0.003872418 // using data from coins.yml package coin @@ -150,6 +150,7 @@ const ( AXELAR = 50000118 JUNO = 30000118 SEI = 19000118 + NEON = 245022934 ) var Coins = map[uint]Coin{ @@ -1203,6 +1204,16 @@ var Coins = map[uint]Coin{ MinConfirmations: 0, Blockchain: "Cosmos", }, + NEON: { + ID: 245022934, + Handle: "neon", + Symbol: "NEON", + Name: "Neon", + Decimals: 18, + BlockTime: 0, + MinConfirmations: 0, + Blockchain: "Ethereum", + }, } var Chains = map[string]Coin{ @@ -2256,6 +2267,16 @@ var Chains = map[string]Coin{ MinConfirmations: 0, Blockchain: "Cosmos", }, + Neon().Handle: { + ID: 245022934, + Handle: "neon", + Symbol: "NEON", + Name: "Neon", + Decimals: 18, + BlockTime: 0, + MinConfirmations: 0, + Blockchain: "Ethereum", + }, } func Ethereum() Coin { @@ -2677,3 +2698,7 @@ func Juno() Coin { func Sei() Coin { return Coins[SEI] } + +func Neon() Coin { + return Coins[NEON] +} diff --git a/coin/coins.yml b/coin/coins.yml index c5d135d..8a87fd7 100644 --- a/coin/coins.yml +++ b/coin/coins.yml @@ -791,3 +791,10 @@ name: Sei decimals: 6 blockchain: Cosmos + +- id: 245022934 + symbol: NEON + handle: neon + name: Neon + decimals: 18 + blockchain: Ethereum diff --git a/coin/models.go b/coin/models.go index cf49920..f55e46d 100644 --- a/coin/models.go +++ b/coin/models.go @@ -155,6 +155,8 @@ func GetCoinExploreURL(c Coin, tokenID, tokenType string) (string, error) { return fmt.Sprintf("https://basescan.org/token/%s", tokenID), nil case CARDANO: return fmt.Sprintf("https://cexplorer.io/asset/%s", tokenID), nil + case NEON: + return fmt.Sprintf("https://neonscan.org/token/%s", tokenID), nil } return "", errors.New("no explorer for coin: " + c.Handle) diff --git a/coin/models_test.go b/coin/models_test.go index ccf61da..5d50a6e 100644 --- a/coin/models_test.go +++ b/coin/models_test.go @@ -354,6 +354,16 @@ func TestGetCoinExploreURL(t *testing.T) { want: "https://basescan.org/token/0x48bcf9455ba97cc439a2efbcfdf8f1afe692139b", wantErr: false, }, + { + name: "Test NEON token", + args: args{ + addr: "0x5f38248f339bf4e84a2caf4e4c0552862dc9f82a", + tokenType: "NEON", + chain: Neon(), + }, + want: "https://neonscan.org/token/0x5f38248f339bf4e84a2caf4e4c0552862dc9f82a", + wantErr: false, + }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { @@ -405,6 +415,7 @@ var evmCoinsTestSet = map[uint]struct{}{ CFXEVM: {}, ACALAEVM: {}, BASE: {}, + NEON: {}, } // TestEvmCoinsList This test will automatically fail when new EVM chain is added to coins.yml diff --git a/types/chain.go b/types/chain.go index 35c08da..f10b920 100644 --- a/types/chain.go +++ b/types/chain.go @@ -139,6 +139,8 @@ func GetChainFromAssetType(assetType string) (coin.Coin, error) { return coin.Sei(), nil case CARDANO: return coin.Cardano(), nil + case NEON: + return coin.Neon(), nil } return coin.Coin{}, errors.New("unknown asset type: " + assetType) diff --git a/types/token.go b/types/token.go index 66d0dda..4e2fbb9 100644 --- a/types/token.go +++ b/types/token.go @@ -103,6 +103,7 @@ const ( JUNO TokenType = "JUNO" SEI TokenType = "SEI" CARDANO TokenType = "CARDANO" + NEON TokenType = "NEON" ) const ( @@ -194,6 +195,7 @@ func GetTokenTypes() []TokenType { JUNO, SEI, CARDANO, + NEON, } } @@ -283,6 +285,8 @@ func GetTokenType(c uint, tokenID string) (string, bool) { return string(SEI), true case coin.CARDANO: return string(CARDANO), true + case coin.NEON: + return string(NEON), true default: return "", false } @@ -335,7 +339,7 @@ func GetTokenVersion(tokenType string) (TokenVersion, error) { return TokenVersionV13, nil case BRC20, ERC721, ERC1155, EOS, NEP5, VET, ONTOLOGY, THETA, TOMO, POA, OASIS, ALGORAND, KAVAERC20, METER, EVMOS_ERC20, KIP20, MOONBEAM, KLAYTN, METIS, MOONRIVER, BOBA, STRIDE, NEUTRON, FA2, CONFLUX, - ACA, CARDANO: + ACA, CARDANO, NEON: return TokenVersionUndefined, nil default: // This should not happen, as it is guarded by TestGetTokenVersionImplementEverySupportedTokenTypes @@ -433,6 +437,8 @@ func GetEthereumTokenTypeByIndex(coinIndex uint) (TokenType, error) { tokenType = ACA case coin.BASE: tokenType = BASE + case coin.NEON: + tokenType = NEON } if tokenType == "" {