Skip to content

Commit

Permalink
add new coin Stride (#102)
Browse files Browse the repository at this point in the history
* add new coin Stride

* Makefile: bump golangci-lint version to v1.52.2

* add types and enum values for Stride

* remove enum value for Stride chain ID for now

---------

Co-authored-by: Peter <[email protected]>
  • Loading branch information
pengux and Peter authored May 5, 2023
1 parent e71ea74 commit dd83a10
Show file tree
Hide file tree
Showing 9 changed files with 70 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,4 @@ jobs:
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
version: v1.50.1
version: v1.52.2
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ lint: go-lint-install go-lint
go-lint-install:
ifeq (,$(wildcard test -f bin/golangci-lint))
@echo " > Installing golint"
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- v1.50.1
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- v1.52.2
endif

go-lint:
@echo " > Running golint"
bin/golangci-lint run --timeout=2m
bin/golangci-lint run --timeout=2m
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 @@ -692,3 +692,10 @@
name: Sui
decimals: 9
blockchain: Sui

- id: 40000118
symbol: STRD
handle: stride
name: Stride
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 @@ -132,6 +132,8 @@ func GetCoinExploreURL(c Coin, tokenID, tokenType string) (string, error) {
return fmt.Sprintf("https://explorer.zksync.io/address/%s", tokenID), nil
case SUI:
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
}

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 @@ -284,6 +284,16 @@ func TestGetCoinExploreURL(t *testing.T) {
want: "https://explorer.sui.io/address/test",
wantErr: false,
},
{
name: "Test Stride",
args: args{
addr: "test",
tokenType: "Stride",
chain: Stride(),
},
want: "https://www.mintscan.io/stride/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 @@ -111,6 +111,8 @@ func GetChainFromAssetType(assetType string) (coin.Coin, error) {
return coin.Zksync(), nil
case SUI:
return coin.Sui(), nil
case STRIDE:
return coin.Stride(), 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 @@ -89,6 +89,7 @@ const (
POLYGONZKEVM TokenType = "ZKEVM"
ZKSYNC TokenType = "ZKSYNC"
SUI TokenType = "SUI"
STRIDE TokenType = "STRIDE"
)

const (
Expand Down Expand Up @@ -167,6 +168,7 @@ func GetTokenTypes() []TokenType {
POLYGONZKEVM,
ZKSYNC,
SUI,
STRIDE,
}
}

Expand Down Expand Up @@ -234,6 +236,8 @@ func GetTokenType(c uint, tokenID string) (string, bool) {
return string(TON), true
case coin.SUI:
return string(SUI), true
case coin.STRIDE:
return string(STRIDE), true
default:
return "", false
}
Expand Down Expand Up @@ -283,7 +287,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:
KAVAERC20, METER, EVMOS_ERC20, KIP20, MOONBEAM, KLAYTN, METIS, MOONRIVER, BOBA, STRIDE:
return TokenVersionUndefined, nil
default:
// This should not happen, as it is guarded by TestGetTokenVersionImplementEverySupportedTokenTypes
Expand Down Expand Up @@ -371,6 +375,8 @@ func GetEthereumTokenTypeByIndex(coinIndex uint) (TokenType, error) {
tokenType = ZKSYNC
case coin.SUI:
tokenType = SUI
case coin.STRIDE:
tokenType = STRIDE
}

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 @@ -323,6 +323,12 @@ func TestGetTokenType(t *testing.T) {
want: string(SUI),
wantBool: true,
},
{
name: "Stride",
args: args{coin.STRIDE, ""},
want: string(STRIDE),
wantBool: true,
},
}

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

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

0 comments on commit dd83a10

Please sign in to comment.