Skip to content

Commit

Permalink
Add support to zkLink Nova
Browse files Browse the repository at this point in the history
  • Loading branch information
danielmbirochi committed Jun 14, 2024
1 parent 6b27b73 commit 383d1bb
Show file tree
Hide file tree
Showing 4 changed files with 26 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 @@ -175,6 +175,8 @@ func GetCoinExploreURL(c Coin, tokenID, tokenType string) (string, error) {
return fmt.Sprintf("https://blastscan.io/token/%s", tokenID), nil
case SCROLL:
return fmt.Sprintf("https://scrollscan.com/token/%s", tokenID), nil
case ZKLINKNOVA:
return fmt.Sprintf("https://explorer.zklink.io/address/%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 @@ -417,6 +417,16 @@ func TestGetCoinExploreURL(t *testing.T) {
want: "https://scrollscan.com/token/0xf55bec9cafdbe8730f096aa55dad6d22d44099df",
wantErr: false,
},
{
name: "Test zkLink Nova - Dai",
args: args{
addr: "0xF573fA04A73d5AC442F3DEa8741317fEaA3cDeab",
tokenType: "ZKLINKNOVA",
chain: Zklinknova(),
},
want: "https://explorer.zklink.io/address/0xF573fA04A73d5AC442F3DEa8741317fEaA3cDeab",
wantErr: false,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
Expand Down
2 changes: 2 additions & 0 deletions types/token.go
Original file line number Diff line number Diff line change
Expand Up @@ -546,6 +546,8 @@ func GetEthereumTokenTypeByIndex(coinIndex uint) (TokenType, error) {
tokenType = SCROLL
case coin.BOUNCEBIT:
tokenType = BOUNCEBIT
case coin.ZKLINKNOVA:
tokenType = ZKLINKNOVA
}

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

for _, tt := range tests {
Expand Down Expand Up @@ -620,6 +626,12 @@ func TestGetTokenVersion(t *testing.T) {
TokenVersionV19,
nil,
},
{
"ZKLINKNOVA token version",
args{t: string(ZKLINKNOVA)},
TokenVersionV20,
nil,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
Expand Down

0 comments on commit 383d1bb

Please sign in to comment.