Skip to content

Commit

Permalink
introduce zksync (#100)
Browse files Browse the repository at this point in the history
  • Loading branch information
nikoskarakostas authored Apr 3, 2023
1 parent f705515 commit d28d555
Show file tree
Hide file tree
Showing 9 changed files with 62 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
*.out

# Dependency directories (remove the comment below to include it)
# vendor/
vendor/

.idea/

Expand Down
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 @@ -679,6 +679,13 @@
decimals: 18
blockchain: Ethereum

- id: 10000324
symbol: ZKSYNC
handle: zksync
name: Zksync
decimals: 18
blockchain: Ethereum

- id: 784
symbol: SUI
handle: sui
Expand Down
2 changes: 2 additions & 0 deletions coin/models.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,8 @@ func GetCoinExploreURL(c Coin, tokenID, tokenType string) (string, error) {
return fmt.Sprintf("https://tonscan.org/address/%s", tokenID), nil
case ZKEVM:
return fmt.Sprintf("https://explorer.public.zkevm-test.net/address/%s", tokenID), nil
case ZKSYNC:
return fmt.Sprintf("https://explorer.zksync.io/address/%s", tokenID), nil
case SUI:
return fmt.Sprintf("https://explorer.sui.io/address/%s", tokenID), nil
}
Expand Down
14 changes: 11 additions & 3 deletions coin/models_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,6 @@ func TestGetCoinExploreURL(t *testing.T) {
want: "https://bobascan.com/token/test",
wantErr: false,
},

{
name: "Test Ton",
args: args{
Expand All @@ -255,7 +254,6 @@ func TestGetCoinExploreURL(t *testing.T) {
want: "https://tonscan.org/address/test",
wantErr: false,
},

{
name: "Test ZKEVM",
args: args{
Expand All @@ -266,7 +264,16 @@ func TestGetCoinExploreURL(t *testing.T) {
want: "https://explorer.public.zkevm-test.net/address/test",
wantErr: false,
},

{
name: "Test ZKSync",
args: args{
addr: "test",
tokenType: "ZKSYNC",
chain: Zksync(),
},
want: "https://explorer.zksync.io/address/test",
wantErr: false,
},
{
name: "Test Sui",
args: args{
Expand Down Expand Up @@ -324,6 +331,7 @@ var evmCoinsTestSet = map[uint]struct{}{
MOONRIVER: {},
BOBA: {},
ZKEVM: {},
ZKSYNC: {},
}

// 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 @@ -107,6 +107,8 @@ func GetChainFromAssetType(assetType string) (coin.Coin, error) {
return coin.Ton(), nil
case ZKEVM:
return coin.Zkevm(), nil
case ZKSYNC:
return coin.Zksync(), nil
case SUI:
return coin.Sui(), nil
}
Expand Down
3 changes: 2 additions & 1 deletion types/chainid.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,6 @@ const (
ChainIDMoonriver = 1285
ChainIDBoba = 288
ChainIDTon = 607
ChainIDZKEVM = 1422
ChainIDZKEVM = 1101
ChainIDZKSync = 324
)
6 changes: 5 additions & 1 deletion types/token.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ const (
BOBA TokenType = "BOBA"
TON TokenType = "TON"
ZKEVM TokenType = "ZKEVM"
ZKSYNC TokenType = "ZKSYNC"
SUI TokenType = "SUI"
)

Expand Down Expand Up @@ -164,6 +165,7 @@ func GetTokenTypes() []TokenType {
BOBA,
TON,
ZKEVM,
ZKSYNC,
SUI,
}
}
Expand Down Expand Up @@ -278,7 +280,7 @@ func GetTokenVersion(tokenType string) (TokenVersion, error) {
return TokenVersionV10, nil
case RONIN, AURORA:
return TokenVersionV11, nil
case TON, ZKEVM, SUI:
case TON, ZKEVM, 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:
Expand Down Expand Up @@ -365,6 +367,8 @@ func GetEthereumTokenTypeByIndex(coinIndex uint) (TokenType, error) {
tokenType = TON
case coin.ZKEVM:
tokenType = ZKEVM
case coin.ZKSYNC:
tokenType = ZKSYNC
case coin.SUI:
tokenType = SUI
}
Expand Down
6 changes: 6 additions & 0 deletions types/token_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,12 @@ func TestGetTokenType(t *testing.T) {
want: string(ZKEVM),
wantBool: true,
},
{
name: "zksync",
args: args{coin.ZKSYNC, ""},
want: string(ZKSYNC),
wantBool: true,
},
{
name: "Sui",
args: args{coin.SUI, ""},
Expand Down

0 comments on commit d28d555

Please sign in to comment.