Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 28 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 @@ -1135,3 +1135,10 @@
decimals: 18
blockchain: Cosmos

- id: 9745
symbol: XPL
handle: plasma
name: Plasma
decimals: 18
blockchain: Ethereum
chainId: 9745 # https://chainlist.org/chain/9745
2 changes: 2 additions & 0 deletions coin/models.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,8 @@ func GetCoinExploreURL(c Coin, tokenID, tokenType string) (string, error) {
return "https://www.mintscan.io/celestia", nil
case DYDX:
return "https://www.mintscan.io/dydx", nil
case PLASMA:
return fmt.Sprintf("https://plasmascan.to/token/%s", tokenID), nil
}

return "", errors.New("no explorer for coin: " + c.Handle)
Expand Down
11 changes: 11 additions & 0 deletions coin/models_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -467,6 +467,16 @@ func TestGetCoinExploreURL(t *testing.T) {
want: "https://sonicscan.org/token/0x29219dd400f2bf60e5a23d13be72b486d4038894",
wantErr: false,
},
{
name: "Test Plasma",
args: args{
addr: "0xB8CE59FC3717ada4C02eaDF9682A9e934F625ebb",
tokenType: "PLASMA",
chain: Plasma(),
},
want: "https://plasmascan.to/token/0xB8CE59FC3717ada4C02eaDF9682A9e934F625ebb",
wantErr: false,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
Expand Down Expand Up @@ -531,6 +541,7 @@ var evmCoinsTestSet = map[uint]struct{}{
BOUNCEBIT: {},
ZKLINKNOVA: {},
SONIC: {},
PLASMA: {},
}

// 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 @@ -185,6 +185,8 @@ func GetChainFromAssetType(assetType string) (coin.Coin, error) {
return coin.Tia(), nil
case DYDX:
return coin.Dydx(), nil
case PLASMA:
return coin.Plasma(), nil
}

return coin.Coin{}, errors.New("unknown asset type: " + assetType)
Expand Down
9 changes: 9 additions & 0 deletions types/token.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ const (
SONIC TokenType = "SONIC"
TIA TokenType = "TIA"
DYDX TokenType = "DYDX"
PLASMA TokenType = "PLASMA"
)

const (
Expand All @@ -154,6 +155,7 @@ const (
TokenVersionV20 TokenVersion = 20
TokenVersionV21 TokenVersion = 21
TokenVersionV22 TokenVersion = 22
TokenVersionV23 TokenVersion = 23
TokenVersionUndefined TokenVersion = -1
)

Expand Down Expand Up @@ -254,6 +256,7 @@ func GetTokenTypes() []TokenType {
SONIC,
TIA,
DYDX,
PLASMA,
}
}

Expand Down Expand Up @@ -385,6 +388,8 @@ func GetTokenType(c uint, tokenID string) (string, bool) {
return string(TIA), true
case coin.DYDX:
return string(DYDX), true
case coin.PLASMA:
return string(PLASMA), true
default:
return "", false
}
Expand Down Expand Up @@ -455,6 +460,8 @@ func GetTokenVersion(tokenType string) (TokenVersion, error) {
return TokenVersionV21, nil
case XRP, SONIC:
return TokenVersionV22, nil
case PLASMA:
return TokenVersionV23, nil
default:
// This should not happen, as it is guarded by TestGetTokenVersionImplementEverySupportedTokenTypes
return TokenVersionUndefined, fmt.Errorf("tokenType %s: %w", parsedTokenType, errTokenVersionNotImplemented)
Expand Down Expand Up @@ -577,6 +584,8 @@ func GetEthereumTokenTypeByIndex(coinIndex uint) (TokenType, error) {
tokenType = ZKLINKNOVA
case coin.SONIC:
tokenType = SONIC
case coin.PLASMA:
tokenType = PLASMA
}

if tokenType == "" {
Expand Down
17 changes: 17 additions & 0 deletions types/token_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,11 @@ func TestGetEthereumTokenTypeByIndex(t *testing.T) {
args: args{coinIndex: coin.BOUNCEBIT},
want: BOUNCEBIT,
},
{
name: "Plasma PLASMA",
args: args{coinIndex: coin.PLASMA},
want: PLASMA,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
Expand Down Expand Up @@ -412,6 +417,12 @@ func TestGetTokenType(t *testing.T) {
want: string(SONIC),
wantBool: true,
},
{
name: "Plasma",
args: args{coin.PLASMA, ""},
want: string(PLASMA),
wantBool: true,
},
}

for _, tt := range tests {
Expand Down Expand Up @@ -650,6 +661,12 @@ func TestGetTokenVersion(t *testing.T) {
TokenVersionV22,
nil,
},
{
"PLASMA token version",
args{t: string(PLASMA)},
TokenVersionV23,
nil,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
Expand Down