Skip to content

Commit

Permalink
Stellar tokens (#61)
Browse files Browse the repository at this point in the history
* Add stellar token

* fmt

* remove wrong test

* add link to explorer
  • Loading branch information
vcoolish authored Apr 25, 2022
1 parent e4dd595 commit da50809
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 0 deletions.
2 changes: 2 additions & 0 deletions coin/models.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
10 changes: 10 additions & 0 deletions coin/models_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 2 additions & 0 deletions types/chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
8 changes: 8 additions & 0 deletions types/chain_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
4 changes: 4 additions & 0 deletions types/token.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ const (
CW20 TokenType = "CW20"
OASIS TokenType = "OASIS"
CRC20 TokenType = "CRC20"
STELLAR TokenType = "STELLAR"
)

func GetTokenTypes() []TokenType {
Expand Down Expand Up @@ -110,6 +111,7 @@ func GetTokenTypes() []TokenType {
ESDT,
OASIS,
CRC20,
STELLAR,
}
}

Expand Down Expand Up @@ -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
}
Expand Down
6 changes: 6 additions & 0 deletions types/token_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit da50809

Please sign in to comment.