diff --git a/coin/models.go b/coin/models.go index baa11e4..ab16a20 100644 --- a/coin/models.go +++ b/coin/models.go @@ -116,6 +116,8 @@ func GetCoinExploreURL(c Coin, tokenID, tokenType string) (string, error) { return fmt.Sprintf("https://explorer.oasis.updev.si/token/%s", tokenID), nil case CRONOS: return fmt.Sprintf("https://cronos.org/explorer/token/%s/token-transfers", tokenID), nil + case STELLAR: + return fmt.Sprintf("https://stellar.expert/explorer/public/asset/%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 dc021be..0bb10b1 100644 --- a/coin/models_test.go +++ b/coin/models_test.go @@ -101,6 +101,16 @@ func TestGetCoinExploreURL(t *testing.T) { want: "https://explorer.elrond.com/tokens/EGLDUSDC-594e5e", wantErr: false, }, + { + name: "Test STELLAR", + args: args{ + addr: "yXLM-GARDNV3Q7YGT4AKSDF25LT32YSCCW4EV22Y2TV3I2PU2MMXJTEDL5T55", + tokenType: "STELLAR", + chain: Stellar(), + }, + want: "https://stellar.expert/explorer/public/asset/yXLM-GARDNV3Q7YGT4AKSDF25LT32YSCCW4EV22Y2TV3I2PU2MMXJTEDL5T55", + wantErr: false, + }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { diff --git a/types/chain.go b/types/chain.go index d11593b..c9e3d95 100644 --- a/types/chain.go +++ b/types/chain.go @@ -75,6 +75,8 @@ func GetChainFromAssetType(assetType string) (coin.Coin, error) { return coin.Oasis(), nil case CRC20: return coin.Cronos(), nil + case STELLAR: + return coin.Stellar(), nil } return coin.Coin{}, errors.New("unknown asset type: " + assetType) diff --git a/types/chain_test.go b/types/chain_test.go index 2284121..918be8b 100644 --- a/types/chain_test.go +++ b/types/chain_test.go @@ -74,6 +74,14 @@ func TestGetChainFromAssetType(t *testing.T) { want: coin.Tomochain(), wantErr: false, }, + { + name: "Test STELLAR", + args: args{ + type_: "STELLAR", + }, + want: coin.Stellar(), + wantErr: false, + }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { diff --git a/types/token.go b/types/token.go index 15178dd..1eb4628 100644 --- a/types/token.go +++ b/types/token.go @@ -66,6 +66,7 @@ const ( CW20 TokenType = "CW20" OASIS TokenType = "OASIS" CRC20 TokenType = "CRC20" + STELLAR TokenType = "STELLAR" ) func GetTokenTypes() []TokenType { @@ -110,6 +111,7 @@ func GetTokenTypes() []TokenType { ESDT, OASIS, CRC20, + STELLAR, } } @@ -157,6 +159,8 @@ func GetTokenType(c uint, tokenID string) (string, bool) { return string(HRC20), true case coin.OASIS: return string(OASIS), true + case coin.STELLAR: + return string(STELLAR), true default: return "", false } diff --git a/types/token_test.go b/types/token_test.go index ca51086..0b42542 100644 --- a/types/token_test.go +++ b/types/token_test.go @@ -228,6 +228,12 @@ func TestGetTokenType(t *testing.T) { want: string(OASIS), wantBool: true, }, + { + name: "Stellar", + args: args{coin.STELLAR, ""}, + want: string(STELLAR), + wantBool: true, + }, } for _, tt := range tests {