Skip to content

Commit

Permalink
add neon (#125)
Browse files Browse the repository at this point in the history
  • Loading branch information
defisaur authored Aug 18, 2023
1 parent c5cf61a commit 02d96ae
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 2 deletions.
27 changes: 26 additions & 1 deletion coin/coins.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions coin/coins.yml
Original file line number Diff line number Diff line change
Expand Up @@ -791,3 +791,10 @@
name: Sei
decimals: 6
blockchain: Cosmos

- id: 245022934
symbol: NEON
handle: neon
name: Neon
decimals: 18
blockchain: Ethereum
2 changes: 2 additions & 0 deletions coin/models.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
11 changes: 11 additions & 0 deletions coin/models_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions types/chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
8 changes: 7 additions & 1 deletion types/token.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ const (
JUNO TokenType = "JUNO"
SEI TokenType = "SEI"
CARDANO TokenType = "CARDANO"
NEON TokenType = "NEON"
)

const (
Expand Down Expand Up @@ -194,6 +195,7 @@ func GetTokenTypes() []TokenType {
JUNO,
SEI,
CARDANO,
NEON,
}
}

Expand Down Expand Up @@ -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
}
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -433,6 +437,8 @@ func GetEthereumTokenTypeByIndex(coinIndex uint) (TokenType, error) {
tokenType = ACA
case coin.BASE:
tokenType = BASE
case coin.NEON:
tokenType = NEON
}

if tokenType == "" {
Expand Down

0 comments on commit 02d96ae

Please sign in to comment.