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 new chain Neutron #103

Merged
merged 1 commit into from
May 16, 2023
Merged
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
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 @@ -699,3 +699,10 @@
name: Stride
decimals: 6
blockchain: Cosmos

- id: 90000118
symbol: NTRN
handle: neutron
name: Neutron
decimals: 6
blockchain: Cosmos
2 changes: 2 additions & 0 deletions coin/models.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,8 @@ func GetCoinExploreURL(c Coin, tokenID, tokenType string) (string, error) {
return fmt.Sprintf("https://explorer.sui.io/address/%s", tokenID), nil
case STRIDE:
return fmt.Sprintf("https://www.mintscan.io/stride/account/%s", tokenID), nil
case NEUTRON:
return fmt.Sprintf("https://www.mintscan.io/neutron/account/%s", tokenID), nil
}

return "", errors.New("no explorer for coin: " + c.Handle)
Expand Down
10 changes: 10 additions & 0 deletions coin/models_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,16 @@ func TestGetCoinExploreURL(t *testing.T) {
want: "https://www.mintscan.io/stride/account/test",
wantErr: false,
},
{
name: "Test Neutron",
args: args{
addr: "test",
tokenType: "Neutron",
chain: Neutron(),
},
want: "https://www.mintscan.io/neutron/account/test",
wantErr: false,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
Expand Down
2 changes: 2 additions & 0 deletions types/chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,8 @@ func GetChainFromAssetType(assetType string) (coin.Coin, error) {
return coin.Sui(), nil
case STRIDE:
return coin.Stride(), nil
case NEUTRON:
return coin.Neutron(), 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 @@ -90,6 +90,7 @@ const (
ZKSYNC TokenType = "ZKSYNC"
SUI TokenType = "SUI"
STRIDE TokenType = "STRIDE"
NEUTRON TokenType = "NEUTRON"
)

const (
Expand Down Expand Up @@ -169,6 +170,7 @@ func GetTokenTypes() []TokenType {
ZKSYNC,
SUI,
STRIDE,
NEUTRON,
}
}

Expand Down Expand Up @@ -238,6 +240,8 @@ func GetTokenType(c uint, tokenID string) (string, bool) {
return string(SUI), true
case coin.STRIDE:
return string(STRIDE), true
case coin.NEUTRON:
return string(NEUTRON), true
default:
return "", false
}
Expand Down Expand Up @@ -287,7 +291,7 @@ func GetTokenVersion(tokenType string) (TokenVersion, error) {
case TON, POLYGONZKEVM, ZKSYNC, SUI:
return TokenVersionV12, nil
case ERC721, ERC1155, EOS, NEP5, VET, ONTOLOGY, THETA, TOMO, POA, OASIS, ALGORAND,
KAVAERC20, METER, EVMOS_ERC20, KIP20, MOONBEAM, KLAYTN, METIS, MOONRIVER, BOBA, STRIDE:
KAVAERC20, METER, EVMOS_ERC20, KIP20, MOONBEAM, KLAYTN, METIS, MOONRIVER, BOBA, STRIDE, NEUTRON:
return TokenVersionUndefined, nil
default:
// This should not happen, as it is guarded by TestGetTokenVersionImplementEverySupportedTokenTypes
Expand Down Expand Up @@ -377,6 +381,8 @@ func GetEthereumTokenTypeByIndex(coinIndex uint) (TokenType, error) {
tokenType = SUI
case coin.STRIDE:
tokenType = STRIDE
case coin.NEUTRON:
tokenType = NEUTRON
}

if tokenType == "" {
Expand Down
13 changes: 13 additions & 0 deletions types/token_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,12 @@ func TestGetTokenType(t *testing.T) {
want: string(STRIDE),
wantBool: true,
},
{
name: "Neutron",
args: args{coin.NEUTRON, ""},
want: string(NEUTRON),
wantBool: true,
},
}

for _, tt := range tests {
Expand Down Expand Up @@ -497,6 +503,13 @@ func TestGetTokenVersion(t *testing.T) {
TokenVersionUndefined,
nil,
},

{
"Neutron token version",
args{t: string(NEUTRON)},
TokenVersionUndefined,
nil,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
Expand Down