From dd4f54303af305912b63d53332acc32b855f97cc Mon Sep 17 00:00:00 2001 From: Karim Yassine Date: Mon, 3 Jun 2024 18:24:41 +0000 Subject: [PATCH] Add BounceBit support (#172) * Add BounceBit support * Add missing key --- coin/coins.go | 264 ++++++++++++++++++++++++-------------------- coin/coins.yml | 8 ++ coin/models_test.go | 1 + types/chain.go | 2 + types/token.go | 9 ++ types/token_test.go | 17 +++ 6 files changed, 183 insertions(+), 118 deletions(-) diff --git a/coin/coins.go b/coin/coins.go index be9501d..b9dd2a5 100644 --- a/coin/coins.go +++ b/coin/coins.go @@ -1,6 +1,6 @@ // Code generated by go generate; DO NOT EDIT. // This file was generated by robots at -// 2024-05-22 12:47:58.070135 +0900 JST m=+0.002676334 +// 2024-05-31 22:36:18.175544 -0300 -03 m=+0.002313543 // using data from coins.yml package coin @@ -23,7 +23,7 @@ type Coin struct { BlockTime int MinConfirmations int64 Blockchain string // Name of the Blockchain which core is used for this network - IsTokenSupported bool // Indicate whether the backend supports token parsing for this network + IsTokenSupported bool // Indicate whether the backend supports token parsing for this network } type AssetID string @@ -46,123 +46,124 @@ func (c Coin) TokenAssetID(t string) AssetID { } const ( - ETHEREUM = 60 - CLASSIC = 61 - ICON = 74 - COSMOS = 118 - RIPPLE = 144 - STELLAR = 148 - POA = 178 - TRON = 195 - FIO = 235 - NIMIQ = 242 - IOTEX = 304 - IOTEXEVM = 10004689 - ZILLIQA = 313 - AION = 425 - AETERNITY = 457 - KAVA = 459 - THETA = 500 - BINANCE = 714 - VECHAIN = 818 - CALLISTO = 820 - TOMOCHAIN = 889 - THUNDERTOKEN = 1001 - ONTOLOGY = 1024 - TEZOS = 1729 - KIN = 2017 - NEBULAS = 2718 - GOCHAIN = 6060 - WANCHAIN = 5718350 - WAVES = 5741564 - BITCOIN = 0 - LITECOIN = 2 - DOGE = 3 - DASH = 5 - VIACOIN = 14 - GROESTLCOIN = 17 - ZCASH = 133 - FIRO = 136 - BITCOINCASH = 145 - RAVENCOIN = 175 - QTUM = 2301 - ZELCASH = 19167 - DECRED = 42 - ALGORAND = 283 - NANO = 165 - DIGIBYTE = 20 - HARMONY = 1023 - KUSAMA = 434 - POLKADOT = 354 - SOLANA = 501 - NEAR = 397 - ELROND = 508 - SMARTCHAIN = 20000714 - FILECOIN = 461 - OASIS = 474 - MONACOIN = 22 - BITCOINGOLD = 156 - EOS = 194 - TERRA = 330 - BAND = 494 - NEO = 888 - CARDANO = 1815 - NULS = 8964 - POLYGON = 966 - THORCHAIN = 931 - OPTIMISM = 10000070 - XDAI = 10000100 - AVALANCHEC = 10009000 - HECO = 10000553 - FANTOM = 10000250 - ARBITRUM = 10042221 - CELO = 52752 - RONIN = 10002020 - OSMOSIS = 10000118 - CRONOS = 10000025 - KCC = 10000321 - AURORA = 1323161554 - KAVAEVM = 10002222 - METER = 18000 - EVMOS = 10009001 - NATIVEEVMOS = 20009001 - OKC = 996 - CRYPTOORG = 394 - APTOS = 637 - MOONBEAM = 10001284 - KLAYTN = 10008217 - METIS = 10001088 - MOONRIVER = 10001285 - BOBA = 10000288 - TON = 607 - POLYGONZKEVM = 10001101 - ZKSYNC = 10000324 - SUI = 784 - STRIDE = 40000118 - NEUTRON = 90000118 - STARGAZE = 20000118 - NATIVEINJECTIVE = 10000060 - CFXEVM = 1030 - ACALA = 787 - ACALAEVM = 10000787 - BASE = 8453 - AKASH = 17000118 - AGORIC = 564 - AXELAR = 50000118 - JUNO = 30000118 - SEI = 19000118 - NEON = 245022934 - OPBNB = 204 - LINEA = 59144 - GBNB = 5600 - MANTLE = 5000 - MANTA = 169 - ZETACHAIN = 10007000 - ZETAEVM = 20007000 - MERLIN = 4200 - BLAST = 81457 - SCROLL = 534352 + ETHEREUM = 60 + CLASSIC = 61 + ICON = 74 + COSMOS = 118 + RIPPLE = 144 + STELLAR = 148 + POA = 178 + TRON = 195 + FIO = 235 + NIMIQ = 242 + IOTEX = 304 + IOTEXEVM = 10004689 + ZILLIQA = 313 + AION = 425 + AETERNITY = 457 + KAVA = 459 + THETA = 500 + BINANCE = 714 + VECHAIN = 818 + CALLISTO = 820 + TOMOCHAIN = 889 + THUNDERTOKEN = 1001 + ONTOLOGY = 1024 + TEZOS = 1729 + KIN = 2017 + NEBULAS = 2718 + GOCHAIN = 6060 + WANCHAIN = 5718350 + WAVES = 5741564 + BITCOIN = 0 + LITECOIN = 2 + DOGE = 3 + DASH = 5 + VIACOIN = 14 + GROESTLCOIN = 17 + ZCASH = 133 + FIRO = 136 + BITCOINCASH = 145 + RAVENCOIN = 175 + QTUM = 2301 + ZELCASH = 19167 + DECRED = 42 + ALGORAND = 283 + NANO = 165 + DIGIBYTE = 20 + HARMONY = 1023 + KUSAMA = 434 + POLKADOT = 354 + SOLANA = 501 + NEAR = 397 + ELROND = 508 + SMARTCHAIN = 20000714 + FILECOIN = 461 + OASIS = 474 + MONACOIN = 22 + BITCOINGOLD = 156 + EOS = 194 + TERRA = 330 + BAND = 494 + NEO = 888 + CARDANO = 1815 + NULS = 8964 + POLYGON = 966 + THORCHAIN = 931 + OPTIMISM = 10000070 + XDAI = 10000100 + AVALANCHEC = 10009000 + HECO = 10000553 + FANTOM = 10000250 + ARBITRUM = 10042221 + CELO = 52752 + RONIN = 10002020 + OSMOSIS = 10000118 + CRONOS = 10000025 + KCC = 10000321 + AURORA = 1323161554 + KAVAEVM = 10002222 + METER = 18000 + EVMOS = 10009001 + NATIVEEVMOS = 20009001 + OKC = 996 + CRYPTOORG = 394 + APTOS = 637 + MOONBEAM = 10001284 + KLAYTN = 10008217 + METIS = 10001088 + MOONRIVER = 10001285 + BOBA = 10000288 + TON = 607 + POLYGONZKEVM = 10001101 + ZKSYNC = 10000324 + SUI = 784 + STRIDE = 40000118 + NEUTRON = 90000118 + STARGAZE = 20000118 + NATIVEINJECTIVE = 10000060 + CFXEVM = 1030 + ACALA = 787 + ACALAEVM = 10000787 + BASE = 8453 + AKASH = 17000118 + AGORIC = 564 + AXELAR = 50000118 + JUNO = 30000118 + SEI = 19000118 + NEON = 245022934 + OPBNB = 204 + LINEA = 59144 + GBNB = 5600 + MANTLE = 5000 + MANTA = 169 + ZETACHAIN = 10007000 + ZETAEVM = 20007000 + MERLIN = 4200 + BLAST = 81457 + SCROLL = 534352 INTERNET_COMPUTER = 223 + BOUNCEBIT = 6001 ) var Coins = map[uint]Coin{ @@ -1453,6 +1454,17 @@ var Coins = map[uint]Coin{ Blockchain: "Internet Computer", IsTokenSupported: false, }, + BOUNCEBIT: { + ID: 6001, + Handle: "bouncebit", + Symbol: "BB", + Name: "BounceBit", + Decimals: 18, + BlockTime: 0, + MinConfirmations: 0, + Blockchain: "Ethereum", + IsTokenSupported: false, + }, } var Chains = map[string]Coin{ @@ -2743,6 +2755,17 @@ var Chains = map[string]Coin{ Blockchain: "Internet Computer", IsTokenSupported: false, }, + Bouncebit().Handle: { + ID: 6001, + Handle: "bouncebit", + Symbol: "BB", + Name: "BounceBit", + Decimals: 18, + BlockTime: 0, + MinConfirmations: 0, + Blockchain: "Ethereum", + IsTokenSupported: false, + }, } func Ethereum() Coin { @@ -3212,3 +3235,8 @@ func Scroll() Coin { func Internet_computer() Coin { return Coins[INTERNET_COMPUTER] } + +func Bouncebit() Coin { + return Coins[BOUNCEBIT] +} + diff --git a/coin/coins.yml b/coin/coins.yml index 10b20e9..b4fc4c8 100644 --- a/coin/coins.yml +++ b/coin/coins.yml @@ -1045,3 +1045,11 @@ decimals: 8 blockchain: Internet Computer isTokenSupported: false + +- id: 6001 + symbol: BB + handle: bouncebit + name: BounceBit + decimals: 18 + blockchain: Ethereum + isTokenSupported: false diff --git a/coin/models_test.go b/coin/models_test.go index 0659dfe..e99541a 100644 --- a/coin/models_test.go +++ b/coin/models_test.go @@ -478,6 +478,7 @@ var evmCoinsTestSet = map[uint]struct{}{ MERLIN: {}, BLAST: {}, SCROLL: {}, + BOUNCEBIT: {}, } // TestEvmCoinsList This test will automatically fail when new EVM chain is added to coins.yml diff --git a/types/chain.go b/types/chain.go index c868811..f4b7188 100644 --- a/types/chain.go +++ b/types/chain.go @@ -173,6 +173,8 @@ func GetChainFromAssetType(assetType string) (coin.Coin, error) { return coin.Scroll(), nil case ICP: return coin.Internet_computer(), nil + case BOUNCEBIT: + return coin.Bouncebit(), nil } return coin.Coin{}, errors.New("unknown asset type: " + assetType) diff --git a/types/token.go b/types/token.go index b187308..7b3b6b1 100644 --- a/types/token.go +++ b/types/token.go @@ -121,6 +121,7 @@ const ( BLAST TokenType = "BLAST" SCROLL TokenType = "SCROLL" ICP TokenType = "ICP" + BOUNCEBIT TokenType = "BOUNCEBIT" ) const ( @@ -142,6 +143,7 @@ const ( TokenVersionV16 TokenVersion = 16 TokenVersionV17 TokenVersion = 17 TokenVersionV18 TokenVersion = 18 + TokenVersionV19 TokenVersion = 19 TokenVersionUndefined TokenVersion = -1 ) @@ -235,6 +237,7 @@ func GetTokenTypes() []TokenType { BLAST, SCROLL, ICP, + BOUNCEBIT, } } @@ -352,6 +355,8 @@ func GetTokenType(c uint, tokenID string) (string, bool) { return string(SCROLL), true case coin.INTERNET_COMPUTER: return string(ICP), true + case coin.BOUNCEBIT: + return string(BOUNCEBIT), true default: return "", false } @@ -411,6 +416,8 @@ func GetTokenVersion(tokenType string) (TokenVersion, error) { return TokenVersionV17, nil case BLAST, SCROLL: return TokenVersionV18, nil + case BOUNCEBIT: + return TokenVersionV19, nil case ERC721, ERC1155, EOS, NEP5, VET, ONTOLOGY, THETA, TOMO, POA, OASIS, ALGORAND, METER, EVMOS_ERC20, KIP20, STRIDE, NEUTRON, FA2, CARDANO, NATIVEEVMOS, CRYPTOORG, COSMOS, OSMOSIS, STARGAZE: return TokenVersionUndefined, nil @@ -530,6 +537,8 @@ func GetEthereumTokenTypeByIndex(coinIndex uint) (TokenType, error) { tokenType = BLAST case coin.SCROLL: tokenType = SCROLL + case coin.BOUNCEBIT: + tokenType = BOUNCEBIT } if tokenType == "" { diff --git a/types/token_test.go b/types/token_test.go index 2c3867c..8e7cacf 100644 --- a/types/token_test.go +++ b/types/token_test.go @@ -155,6 +155,11 @@ func TestGetEthereumTokenTypeByIndex(t *testing.T) { args: args{coinIndex: coin.CFXEVM}, want: CONFLUX, }, + { + name: "BounceBit BOUNCEBIT", + args: args{coinIndex: coin.BOUNCEBIT}, + want: BOUNCEBIT, + }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { @@ -377,6 +382,12 @@ func TestGetTokenType(t *testing.T) { want: string(SCROLL), wantBool: true, }, + { + name: "BounceBit", + args: args{coin.BOUNCEBIT, ""}, + want: string(BOUNCEBIT), + wantBool: true, + }, } for _, tt := range tests { @@ -603,6 +614,12 @@ func TestGetTokenVersion(t *testing.T) { TokenVersionV18, nil, }, + { + "BOUNCEBIT token version", + args{t: string(BOUNCEBIT)}, + TokenVersionV19, + nil, + }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) {