wormchain: tokenbridge: Check for base denom in GetWrappedCoinMeta

The base denom for wrapped tokens is prefixed with "b".  Check for this
in GetWrappedCoinMeta so that we don't end up treating base denom tokens
as native tokens.
This commit is contained in:
Chirantan Ekbote 2022-08-22 16:34:03 +09:00 committed by Chirantan Ekbote
parent a66b3ac28c
commit a0c25dead2
2 changed files with 10 additions and 1 deletions

View File

@ -101,7 +101,7 @@ func GetWrappedCoinMeta(identifier string) (tokenChain uint16, tokenAddress [32]
if len(parts) != 3 {
return 0, [32]byte{}, false
}
if parts[0] != "wh" {
if parts[0] != "wh" && parts[0] != "bwh" {
return 0, [32]byte{}, false
}
if len(parts[1]) != 5 {

View File

@ -1,6 +1,8 @@
package types
import (
"encoding/hex"
"fmt"
"testing"
"github.com/stretchr/testify/require"
@ -87,6 +89,13 @@ func TestGetWrappedCoinMeta(t *testing.T) {
tokenAddress: [32]byte{},
wrapped: false,
},
{
name: "base denom",
identifier: fmt.Sprintf("bwh/00008/%s", hex.EncodeToString(testToken[:])),
tokenChain: 8,
tokenAddress: testToken,
wrapped: true,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {