Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support BRC20 type #110

Merged
merged 3 commits into from
Jul 10, 2023
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
2 changes: 2 additions & 0 deletions types/chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import (
// nolint:cyclop
func GetChainFromAssetType(assetType string) (coin.Coin, error) {
switch TokenType(assetType) {
case BRC20:
return coin.Bitcoin(), nil
case ERC20:
return coin.Ethereum(), nil
case BEP2, BEP8:
Expand Down
6 changes: 5 additions & 1 deletion types/token.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ type (
const (
Coin TokenType = "coin"
Gas TokenType = "gas"
BRC20 TokenType = "BRC20"
ERC20 TokenType = "ERC20"
ERC721 TokenType = "ERC721"
ERC1155 TokenType = "ERC1155"
Expand Down Expand Up @@ -112,6 +113,7 @@ const (

func GetTokenTypes() []TokenType {
return []TokenType{
BRC20,
ERC20,
ERC721,
ERC1155,
Expand Down Expand Up @@ -185,6 +187,8 @@ func GetTokenType(c uint, tokenID string) (string, bool) {
}

switch c {
case coin.BITCOIN:
return string(BRC20), true
case coin.TRON:
_, err := strconv.Atoi(tokenID)
if err != nil {
Expand Down Expand Up @@ -291,7 +295,7 @@ func GetTokenVersion(tokenType string) (TokenVersion, error) {
return TokenVersionV11, nil
case TON, POLYGONZKEVM, ZKSYNC, SUI:
return TokenVersionV12, nil
case ERC721, ERC1155, EOS, NEP5, VET, ONTOLOGY, THETA, TOMO, POA, OASIS, ALGORAND,
case BRC20, ERC721, ERC1155, EOS, NEP5, VET, ONTOLOGY, THETA, TOMO, POA, OASIS, ALGORAND,
KAVAERC20, METER, EVMOS_ERC20, KIP20, MOONBEAM, KLAYTN, METIS, MOONRIVER, BOBA, STRIDE, NEUTRON, FA2:
return TokenVersionUndefined, nil
default:
Expand Down
3 changes: 2 additions & 1 deletion types/token_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,8 @@ func TestGetTokenType(t *testing.T) {
{
name: "Bitcoin",
args: args{coin.BITCOIN, ""},
wantBool: false,
want: string(BRC20),
wantBool: true,
},
{
name: "TERRA CW20",
Expand Down