From cf2d1abdfa564ed2153d06d2bbaacd7ab9c03196 Mon Sep 17 00:00:00 2001 From: Martin Homola Date: Sun, 15 Dec 2024 16:16:37 +0100 Subject: [PATCH] feat(connect): update bnb to bsc --- packages/address-validator/src/currencies.js | 2 +- .../tests/wallet_address_validator.test.js | 20 +- .../src/components/menu.tsx | 2 +- packages/connect/src/data/config.ts | 2 +- .../src/components/CoinLogo/coins.ts | 2 +- .../SelectAssetModal.storiesData.ts | 4 +- .../suite/src/storage/migrations/index.ts | 5 + .../src/storage/migrations/networks/bnb.ts | 201 ++++++++++++++++++ .../CoinmarketFormInputCryptoSelect.tsx | 2 +- packages/theme/src/coinsColors.ts | 2 +- .../src/coinselect/inputs/branchAndBound.ts | 2 +- .../coinselect/{bnb.ts => bsc.ts} | 0 .../coinselect/coinselect-index.ts | 18 +- .../tests/coinselect/branchAndBound.test.ts | 4 +- suite-common/graph/src/balanceHistoryUtils.ts | 2 +- suite-common/graph/src/constants.ts | 2 +- suite-common/icons-deprecated/src/icons.ts | 2 +- suite-common/icons/src/cryptoIcons.ts | 2 +- suite-common/suite-constants/src/protocol.ts | 4 +- .../wallet-config/src/networksConfig.ts | 4 +- suite-common/wallet-config/src/types.ts | 2 +- .../src/blockchain/blockchainThunks.ts | 2 +- .../src/__fixtures__/accountUtils.ts | 2 +- .../__tests__/filterReceiveAccounts.test.ts | 2 +- suite-common/wallet-utils/src/accountUtils.ts | 2 +- suite-native/config/src/supportedNetworks.ts | 2 +- .../src/hooks/useAddCoinAccount.ts | 2 +- suite-native/tokens/src/utils.ts | 2 +- 28 files changed, 252 insertions(+), 46 deletions(-) create mode 100644 packages/suite/src/storage/migrations/networks/bnb.ts rename packages/utxo-lib/tests/__fixtures__/coinselect/{bnb.ts => bsc.ts} (100%) diff --git a/packages/address-validator/src/currencies.js b/packages/address-validator/src/currencies.js index 9d74114ce5ea..b11b86697d69 100644 --- a/packages/address-validator/src/currencies.js +++ b/packages/address-validator/src/currencies.js @@ -1448,7 +1448,7 @@ var CURRENCIES = [ }, { name: 'BNB Smart Chain', - symbol: 'bnb', + symbol: 'bsc', validator: ETHValidator, }, { diff --git a/packages/address-validator/tests/wallet_address_validator.test.js b/packages/address-validator/tests/wallet_address_validator.test.js index 341818c49d6c..8f17989681f4 100644 --- a/packages/address-validator/tests/wallet_address_validator.test.js +++ b/packages/address-validator/tests/wallet_address_validator.test.js @@ -786,8 +786,8 @@ describe('WAValidator.validate()', function () { isValidAddressType('aaaaaaaaaaaaaaa000000000000000', 'siacoin', 'prod', undefined); }); - it('should return true for correct BNB addresses', function () { - valid('0x0590396689ee1d287147e9383fb8dd24532f2006', 'bnb'); + it('should return true for correct BSC addresses', function () { + valid('0x0590396689ee1d287147e9383fb8dd24532f2006', 'bsc'); valid('0x07fc5c2bcaa0fa6bdaa4fff897490312c8f33c27', 'BNB smart chain'); }); @@ -1116,12 +1116,12 @@ describe('WAValidator.validate()', function () { }); it('should return true for correct BNB smart chain address', function () { - valid('0x7ae2f5b9e386cd1b50a4550696d957cb4900f03a', 'bnb'); + valid('0x7ae2f5b9e386cd1b50a4550696d957cb4900f03a', 'bsc'); valid('0x0000000000000000000000000000000000001000', 'BNB Smart Chain'); }); it('should return false for incorrect BNB smart chain address', function () { - invalid('bnb1xlvns0n2mxh77mzaspn2hgav4rr4m8eerfju38', 'bnb'); + invalid('bnb1xlvns0n2mxh77mzaspn2hgav4rr4m8eerfju38', 'bsc'); }); it('should return true for correct xtz(tezos) address', function () { @@ -1567,13 +1567,13 @@ describe('WAValidator.validate()', function () { invalid('g4VPBPrHZkfE8CsjuG2S4yBQNd455UWmk', 'stellar'); }); - it('should return false for incorrect bnb addresses', function () { + it('should return false for incorrect bsc addresses', function () { commonTests('bnb smart chain'); - commonTests('bnb'); - invalid('xrb_1f5e4w33ndqbkx4bw5jtp13kp5xghebfxcmw9hdt1f7goid1s4373w6tjdgu', 'bnb'); - invalid('nano_1f5e4w33ndqbkx4bw5jtp13kp5xghebfxcmw9hdt1f7goid1s4373w6tjdgu', 'bnb'); - invalid('xrb_1111111112111111111111111111111111111111111111111111hifc8npp', 'bnb'); - invalid('nano_111111111111111111111111111111111111111111111111111hifc8npp', 'bnb'); + commonTests('bsc'); + invalid('xrb_1f5e4w33ndqbkx4bw5jtp13kp5xghebfxcmw9hdt1f7goid1s4373w6tjdgu', 'bsc'); + invalid('nano_1f5e4w33ndqbkx4bw5jtp13kp5xghebfxcmw9hdt1f7goid1s4373w6tjdgu', 'bsc'); + invalid('xrb_1111111112111111111111111111111111111111111111111111hifc8npp', 'bsc'); + invalid('nano_111111111111111111111111111111111111111111111111111hifc8npp', 'bsc'); }); it('should return false for incorrect xtz(tezos) address', function () { diff --git a/packages/connect-explorer-theme/src/components/menu.tsx b/packages/connect-explorer-theme/src/components/menu.tsx index d6c688673653..95540f66cf7e 100644 --- a/packages/connect-explorer-theme/src/components/menu.tsx +++ b/packages/connect-explorer-theme/src/components/menu.tsx @@ -111,7 +111,7 @@ export function Menu({ const prevRoute = useRef(route); const coinSymbols = { - binance: 'bnb', + binance: 'bsc', bitcoin: 'btc', cardano: 'ada', eos: 'eos', diff --git a/packages/connect/src/data/config.ts b/packages/connect/src/data/config.ts index 93d17614379f..026f2f56c7ff 100644 --- a/packages/connect/src/data/config.ts +++ b/packages/connect/src/data/config.ts @@ -117,7 +117,7 @@ export const config = { ], }, { - coin: ['bnb'], + coin: ['bsc'], min: { T1B1: '1.9.0', T2T1: '2.3.0' }, comment: [ 'There were protobuf backwards incompatible changes with introduction of 1.9.0/2.3.0 firmwares', diff --git a/packages/product-components/src/components/CoinLogo/coins.ts b/packages/product-components/src/components/CoinLogo/coins.ts index aa0fc7458748..4bedb569d9fc 100644 --- a/packages/product-components/src/components/CoinLogo/coins.ts +++ b/packages/product-components/src/components/CoinLogo/coins.ts @@ -7,7 +7,7 @@ export const COINS: Record = { ada: require('../../images/coins/ada.svg'), base: require('../../images/coins/base.svg'), bch: require('../../images/coins/bch.svg'), - bnb: require('../../images/coins/bnb.svg'), + bsc: require('../../images/coins/bnb.svg'), btc: require('../../images/coins/btc.svg'), btg: require('../../images/coins/btg.svg'), dash: require('../../images/coins/dash.svg'), diff --git a/packages/product-components/src/components/SelectAssetModal/SelectAssetModal.storiesData.ts b/packages/product-components/src/components/SelectAssetModal/SelectAssetModal.storiesData.ts index 434614962fce..6f7c1cc1fe26 100644 --- a/packages/product-components/src/components/SelectAssetModal/SelectAssetModal.storiesData.ts +++ b/packages/product-components/src/components/SelectAssetModal/SelectAssetModal.storiesData.ts @@ -162,7 +162,7 @@ export const selectAssetModalOptions: ( coingeckoId: 'binancecoin', contractAddress: null, ticker: 'BNB', - symbol: 'bnb', + symbol: 'bsc', }, { type: 'group', @@ -474,7 +474,7 @@ export const selectAssetModalNetworks: NetworkFilterCategory[] = [ }, { name: 'BNB Smart Chain', - symbol: 'bnb', + symbol: 'bsc', coingeckoId: 'binance-smart-chain', coingeckoNativeId: 'binancecoin', }, diff --git a/packages/suite/src/storage/migrations/index.ts b/packages/suite/src/storage/migrations/index.ts index aed45f3bb64c..3c98018a0af5 100644 --- a/packages/suite/src/storage/migrations/index.ts +++ b/packages/suite/src/storage/migrations/index.ts @@ -20,6 +20,7 @@ import { PartialRecord } from '@trezor/type-utils'; import type { CustomBackend, BlockbookUrl } from 'src/types/wallet/backend'; import type { State } from 'src/reducers/wallet/settingsReducer'; +import { migrationOfBnbNetwork } from 'src/storage/migrations/networks/bnb'; import { updateAll } from './utils'; import type { DBWalletAccountTransaction, SuiteDBSchema } from '../definitions'; @@ -1149,4 +1150,8 @@ export const migrate: OnUpgradeFunc = async ( return tx; }); } + + if (oldVersion < 50) { + await migrationOfBnbNetwork(db, oldVersion, newVersion, transaction); + } }; diff --git a/packages/suite/src/storage/migrations/networks/bnb.ts b/packages/suite/src/storage/migrations/networks/bnb.ts new file mode 100644 index 000000000000..c3d39615dfbe --- /dev/null +++ b/packages/suite/src/storage/migrations/networks/bnb.ts @@ -0,0 +1,201 @@ +import type { OnUpgradeFunc } from '@trezor/suite-storage'; + +import { updateAll } from '../utils'; +import type { SuiteDBSchema } from '../../definitions'; + +export const migrationOfBnbNetwork: OnUpgradeFunc = async ( + _db, + _oldVersion, + _newVersion, + transaction, +) => { + // migrate bnb to bsc + + await updateAll(transaction, 'walletSettings', walletSettings => { + // @ts-expect-error + const indexOfBnb = walletSettings.enabledNetworks.indexOf('bnb'); + if (indexOfBnb !== -1) { + walletSettings.enabledNetworks[indexOfBnb] = 'bsc'; + } + + return walletSettings; + }); + + await updateAll(transaction, 'suiteSettings', suiteSettings => { + if ( + // @ts-expect-error + typeof suiteSettings.evmSettings?.confirmExplanationModalClosed?.bnb == 'boolean' + ) { + suiteSettings.evmSettings.confirmExplanationModalClosed.bsc = + // @ts-expect-error + suiteSettings.evmSettings.confirmExplanationModalClosed.bnb; + // @ts-expect-error + delete suiteSettings.evmSettings.confirmExplanationModalClosed.bnb; + } + + if ( + // @ts-expect-error + typeof suiteSettings.evmSettings?.explanationBannerClosed?.bnb == 'boolean' + ) { + suiteSettings.evmSettings.explanationBannerClosed.bsc = + // @ts-expect-error + suiteSettings.evmSettings.explanationBannerClosed.bnb; + // @ts-expect-error + delete suiteSettings.evmSettings.explanationBannerClosed.bnb; + } + + return suiteSettings; + }); + + const backendSettings = transaction.objectStore('backendSettings'); + // @ts-expect-error + const bnbBackendSettings = await backendSettings.get('bnb'); + if (bnbBackendSettings) { + backendSettings.add(bnbBackendSettings, 'bsc'); + // @ts-expect-error + backendSettings.delete('bnb'); + } + + const tokenManagement = transaction.objectStore('tokenManagement'); + const bnbTokenManagementShow = await tokenManagement.get('bnb-coin-show'); + if (bnbTokenManagementShow) { + tokenManagement.add(bnbTokenManagementShow, 'bsc-coin-show'); + tokenManagement.delete('bnb-coin-show'); + } + + const bnbTokenManagementHide = await tokenManagement.get('bnb-coin-hide'); + if (bnbTokenManagementHide) { + tokenManagement.add(bnbTokenManagementHide, 'bsc-coin-hide'); + tokenManagement.delete('bnb-coin-hide'); + } + + await updateAll(transaction, 'discovery', discovery => { + discovery.networks = discovery.networks.map(network => + // @ts-expect-error + network === 'bnb' ? 'bsc' : network, + ); + + discovery.failed = discovery.failed.map(network => { + // @ts-expect-error + if (network.symbol === 'bnb') { + network = { ...network, symbol: 'bsc' }; + } + + return network; + }); + + return discovery; + }); + + const accounts = transaction.objectStore('accounts'); + let accountsCursor = await accounts.openCursor(); + while (accountsCursor) { + const account = accountsCursor.value; + // @ts-expect-error + if (account.symbol === 'bnb') { + const newAccount = { + ...account, + symbol: 'bsc' as const, + key: account.key.replace('bnb', 'bsc'), + }; + await accountsCursor.delete(); + await accounts.add(newAccount); + } + + accountsCursor = await accountsCursor.continue(); + } + + await updateAll(transaction, 'walletSettings', walletSettings => { + if (walletSettings.lastUsedFeeLevel['bnb']) { + walletSettings.lastUsedFeeLevel = { + ...walletSettings.lastUsedFeeLevel, + bsc: { ...walletSettings.lastUsedFeeLevel['bnb'] }, + }; + + delete walletSettings.lastUsedFeeLevel['bnb']; + } + + return walletSettings; + }); + + await updateAll(transaction, 'txs', tx => { + // @ts-expect-error + if (tx.tx.symbol === 'bnb') { + tx.tx = { ...tx.tx, symbol: 'bsc' }; + } + + return tx; + }); + + const graphs = transaction.objectStore('graph'); + let graphCursor = await graphs.openCursor(); + while (graphCursor) { + const graph = graphCursor.value; + //@ts-expect-error + if (graph.account.symbol === 'bnb') { + const newGraph = { + ...graph, + account: { ...graph.account, symbol: 'bsc' as const }, + }; + await graphCursor.delete(); + await graphs.add(newGraph); + } + + graphCursor = await graphCursor.continue(); + } + + await updateAll(transaction, 'historicRates', rates => { + const rate = Object.keys(rates).reduce((newRates, key) => { + const newKey = key.replace('bnb', 'bsc'); + // @ts-expect-error + newRates[newKey] = rates[key]; + + return newRates; + }, {}); + + return rate; + }); + + const historicRates = transaction.objectStore('historicRates'); + const historicRatesKeys = await historicRates.getAllKeys(); + const historicRatesKeysWithBnb = historicRatesKeys.filter(key => key.includes('bnb')); + + historicRatesKeysWithBnb.forEach(async key => { + const rate = await historicRates.get(key); + if (rate) { + historicRates.add(rate, key.replace('bnb', 'bsc')); + } + historicRates.delete(key); + }); + + const sendFormDrafts = transaction.objectStore('sendFormDrafts'); + const sendFormDraftsKeys = await sendFormDrafts.getAllKeys(); + const sendFormDraftsKeysWithBnb = sendFormDraftsKeys.filter(key => key.includes('bnb')); + + sendFormDraftsKeysWithBnb.forEach(async key => { + const draft = await sendFormDrafts.get(key); + if (draft) { + sendFormDrafts.add(draft, key.replace('bnb', 'bsc')); + } + sendFormDrafts.delete(key); + }); + + const formDrafts = transaction.objectStore('formDrafts'); + const formDraftsKeys = await formDrafts.getAllKeys(); + const formDraftsKeysWithBnb = formDraftsKeys.filter(key => key.includes('bnb')); + + formDraftsKeysWithBnb.forEach(async key => { + const draft = await formDrafts.get(key); + if (draft) { + formDrafts.add(draft, key.replace('bnb', 'bsc')); + } + formDrafts.delete(key); + }); + + await updateAll(transaction, 'coinmarketTrades', trade => { + // @ts-expect-error + if (trade.account.symbol === 'bnb') { + trade.account.symbol = 'bsc'; + } + }); +}; diff --git a/packages/suite/src/views/wallet/coinmarket/common/CoinmarketForm/CoinmarketFormInput/CoinmarketFormInputCryptoSelect.tsx b/packages/suite/src/views/wallet/coinmarket/common/CoinmarketForm/CoinmarketFormInput/CoinmarketFormInputCryptoSelect.tsx index fc332a908b3c..0a2168c45ee2 100644 --- a/packages/suite/src/views/wallet/coinmarket/common/CoinmarketForm/CoinmarketFormInput/CoinmarketFormInputCryptoSelect.tsx +++ b/packages/suite/src/views/wallet/coinmarket/common/CoinmarketForm/CoinmarketFormInput/CoinmarketFormInputCryptoSelect.tsx @@ -155,7 +155,7 @@ export const CoinmarketFormInputCryptoSelect = < }; const getNetworks = () => { - const networksToSelect: NetworkSymbol[] = ['eth', 'sol', 'pol', 'bnb']; + const networksToSelect: NetworkSymbol[] = ['eth', 'sol', 'pol', 'bsc']; const networkKeys = networkSymbolCollection.filter(item => networksToSelect.includes(item)); const networksSelected: NetworkFilterCategory[] = networkKeys.map(networkKey => { const network = getNetwork(networkKey); diff --git a/packages/theme/src/coinsColors.ts b/packages/theme/src/coinsColors.ts index be985fd9acd2..21045054a8eb 100644 --- a/packages/theme/src/coinsColors.ts +++ b/packages/theme/src/coinsColors.ts @@ -8,7 +8,7 @@ export const coinsColors: CoinsColors = { ada: '#3468d1', base: '#0052ff', bch: '#0ac18e', - bnb: '#f0b90b', + bsc: '#f0b90b', btc: '#f29937', btg: '#3b5185', dash: '#1796e4', diff --git a/packages/utxo-lib/src/coinselect/inputs/branchAndBound.ts b/packages/utxo-lib/src/coinselect/inputs/branchAndBound.ts index 979f2e87c1a9..8b3ae368b85a 100644 --- a/packages/utxo-lib/src/coinselect/inputs/branchAndBound.ts +++ b/packages/utxo-lib/src/coinselect/inputs/branchAndBound.ts @@ -134,7 +134,7 @@ export const branchAndBound: CoinSelectAlgorithm = ( feeRate, options, ): CoinSelectResult => { - if (options.baseFee) return { fee: 0 }; // TEMP: disable bnb algorithm for DOGE + if (options.baseFee) return { fee: 0 }; // TEMP: disable bsc algorithm for DOGE if (utxos.find(u => u.required)) return { fee: 0 }; // TODO: enable bnb algorithm if required utxos are defined // cost of change: cost of additional output in current tx (fee) + minimum possible value of that output (dust) diff --git a/packages/utxo-lib/tests/__fixtures__/coinselect/bnb.ts b/packages/utxo-lib/tests/__fixtures__/coinselect/bsc.ts similarity index 100% rename from packages/utxo-lib/tests/__fixtures__/coinselect/bnb.ts rename to packages/utxo-lib/tests/__fixtures__/coinselect/bsc.ts diff --git a/packages/utxo-lib/tests/__fixtures__/coinselect/coinselect-index.ts b/packages/utxo-lib/tests/__fixtures__/coinselect/coinselect-index.ts index a73a0c63904f..f22f9882f1ad 100644 --- a/packages/utxo-lib/tests/__fixtures__/coinselect/coinselect-index.ts +++ b/packages/utxo-lib/tests/__fixtures__/coinselect/coinselect-index.ts @@ -236,7 +236,7 @@ export const coinselectIndexFixture = [ factor: 0.5, }, { - description: '1 output, bnb change rejected, value > 2^32', + description: '1 output, bsc change rejected, value > 2^32', feeRate: 5, inputs: [ { @@ -270,7 +270,7 @@ export const coinselectIndexFixture = [ dustThreshold: 546, }, { - description: '1 output, only possibility with change, bnb rejects', + description: '1 output, only possibility with change, bsc rejects', feeRate: 5, inputs: [ { @@ -351,7 +351,7 @@ export const coinselectIndexFixture = [ }, { description: - '1 output, sub-optimal inputs (if re-ordered), direct possible, but slightly higher fee, bnb rejects', + '1 output, sub-optimal inputs (if re-ordered), direct possible, but slightly higher fee, bsc rejects', feeRate: 10, inputs: [ { @@ -604,7 +604,7 @@ export const coinselectIndexFixture = [ dustThreshold: 546, }, { - description: '1 output, no fee, no bnb match', + description: '1 output, no fee, no bsc match', feeRate: 0, inputs: [ { @@ -827,7 +827,7 @@ export const coinselectIndexFixture = [ dustThreshold: 546, }, { - description: 'many outputs, bnb no match', + description: 'many outputs, bsc no match', feeRate: 10, inputs: [ { @@ -1061,7 +1061,7 @@ export const coinselectIndexFixture = [ dustThreshold: 546, }, { - description: 'no outputs, bnb no match', + description: 'no outputs, bsc no match', feeRate: 10, inputs: [ { @@ -1098,7 +1098,7 @@ export const coinselectIndexFixture = [ dustThreshold: 546, }, { - description: 'not enough funds, bnb empty result', + description: 'not enough funds, bsc empty result', feeRate: 10, inputs: [ { @@ -1115,7 +1115,7 @@ export const coinselectIndexFixture = [ dustThreshold: 546, }, { - description: 'not enough funds (w/ fee), bnb empty result', + description: 'not enough funds (w/ fee), bsc empty result', feeRate: 10, inputs: [ { @@ -1216,7 +1216,7 @@ export const coinselectIndexFixture = [ dustThreshold: 546, }, { - description: 'exhausting BnB', + description: 'exhausting bsc', feeRate: 10, inputs: [ { diff --git a/packages/utxo-lib/tests/coinselect/branchAndBound.test.ts b/packages/utxo-lib/tests/coinselect/branchAndBound.test.ts index 030e5783858a..39ae6b3be9b1 100644 --- a/packages/utxo-lib/tests/coinselect/branchAndBound.test.ts +++ b/packages/utxo-lib/tests/coinselect/branchAndBound.test.ts @@ -1,9 +1,9 @@ import { branchAndBound } from '../../src/coinselect/inputs/branchAndBound'; -import fixtures from '../__fixtures__/coinselect/bnb'; +import fixtures from '../__fixtures__/coinselect/bsc'; import * as utils from './test.utils'; import { CoinSelectOptions } from '../../src/types'; -describe('coinselect: branchAndBound (bnb)', () => { +describe('coinselect: branchAndBound (bsc)', () => { fixtures.forEach(f => { it(f.description, () => { const inputs = utils.expand(f.inputs, true); diff --git a/suite-common/graph/src/balanceHistoryUtils.ts b/suite-common/graph/src/balanceHistoryUtils.ts index 0c091ab150ba..de1905b4dc35 100644 --- a/suite-common/graph/src/balanceHistoryUtils.ts +++ b/suite-common/graph/src/balanceHistoryUtils.ts @@ -324,7 +324,7 @@ export const getAccountHistoryMovementFromTransactions = ({ return getAccountHistoryMovementItemRipple({ transactions, from, to }); case 'eth': case 'pol': - case 'bnb': + case 'bsc': return getAccountHistoryMovementItemETH({ transactions, from, to }); default: diff --git a/suite-common/graph/src/constants.ts b/suite-common/graph/src/constants.ts index 428fcd5348fe..957c0a513ecc 100644 --- a/suite-common/graph/src/constants.ts +++ b/suite-common/graph/src/constants.ts @@ -7,7 +7,7 @@ export const NUMBER_OF_POINTS = 40; export const LOCAL_BALANCE_HISTORY_COINS = [ 'eth', 'pol', - 'bnb', + 'bsc', 'xrp', ] satisfies Array; export type LocalBalanceHistoryCoin = (typeof LOCAL_BALANCE_HISTORY_COINS)[number]; diff --git a/suite-common/icons-deprecated/src/icons.ts b/suite-common/icons-deprecated/src/icons.ts index 653192c29497..4d8a4df95894 100644 --- a/suite-common/icons-deprecated/src/icons.ts +++ b/suite-common/icons-deprecated/src/icons.ts @@ -231,7 +231,7 @@ export const cryptoIcons = { ada: require('../assets/cryptoIcons/ada.svg'), base: require('../assets/cryptoIcons/base.svg'), bch: require('../assets/cryptoIcons/bch.svg'), - bnb: require('../assets/cryptoIcons/bnb.svg'), + bsc: require('../assets/cryptoIcons/bnb.svg'), btc: require('../assets/cryptoIcons/btc.svg'), btg: require('../assets/cryptoIcons/btg.svg'), dash: require('../assets/cryptoIcons/dash.svg'), diff --git a/suite-common/icons/src/cryptoIcons.ts b/suite-common/icons/src/cryptoIcons.ts index 55d226d0e143..6e35b0313530 100644 --- a/suite-common/icons/src/cryptoIcons.ts +++ b/suite-common/icons/src/cryptoIcons.ts @@ -5,7 +5,7 @@ export const cryptoIcons = { ada: require('../cryptoAssets/cryptoIcons/ada.svg'), base: require('../cryptoAssets/cryptoIcons/base.svg'), bch: require('../cryptoAssets/cryptoIcons/bch.svg'), - bnb: require('../cryptoAssets/cryptoIcons/bnb.svg'), + bsc: require('../cryptoAssets/cryptoIcons/bnb.svg'), btc: require('../cryptoAssets/cryptoIcons/btc.svg'), btg: require('../cryptoAssets/cryptoIcons/btg.svg'), dash: require('../cryptoAssets/cryptoIcons/dash.svg'), diff --git a/suite-common/suite-constants/src/protocol.ts b/suite-common/suite-constants/src/protocol.ts index c7b0a444cfab..209a2f944ca8 100644 --- a/suite-common/suite-constants/src/protocol.ts +++ b/suite-common/suite-constants/src/protocol.ts @@ -38,7 +38,7 @@ export type Protocol = | 'ada' | 'sol' | 'pol' - | 'bnb' + | 'bsc' | 'base' | 'op' | 'test' @@ -66,7 +66,7 @@ export const NETWORK_TO_PROTOCOLS: Record = { ada: ['cardano', 'ada'], sol: ['solana', 'sol'], pol: ['polygon', 'matic', 'pol'], - bnb: ['binance', 'bnb', 'bsc'], + bsc: ['binance', 'bsc'], base: ['base'], op: ['optimism', 'op'], test: ['test'], diff --git a/suite-common/wallet-config/src/networksConfig.ts b/suite-common/wallet-config/src/networksConfig.ts index ab8624db0431..f1db02f66db9 100644 --- a/suite-common/wallet-config/src/networksConfig.ts +++ b/suite-common/wallet-config/src/networksConfig.ts @@ -108,8 +108,8 @@ export const networks = { coingeckoId: 'polygon-pos', coingeckoNativeId: 'polygon-ecosystem-token', }, - bnb: { - symbol: 'bnb', + bsc: { + symbol: 'bsc', name: 'BNB Smart Chain', networkType: 'ethereum', chainId: 56, diff --git a/suite-common/wallet-config/src/types.ts b/suite-common/wallet-config/src/types.ts index 6cf1b820b5cd..b7c9f90c0234 100644 --- a/suite-common/wallet-config/src/types.ts +++ b/suite-common/wallet-config/src/types.ts @@ -18,7 +18,7 @@ export type NetworkSymbol = | 'ada' | 'sol' | 'pol' - | 'bnb' + | 'bsc' | 'base' | 'op' | 'test' diff --git a/suite-common/wallet-core/src/blockchain/blockchainThunks.ts b/suite-common/wallet-core/src/blockchain/blockchainThunks.ts index 747b0ddb69f7..dcf00a4e60a2 100644 --- a/suite-common/wallet-core/src/blockchain/blockchainThunks.ts +++ b/suite-common/wallet-core/src/blockchain/blockchainThunks.ts @@ -42,7 +42,7 @@ export const DEFAULT_ACCOUNT_SYNC_INTERVAL = 60 * 1000; // 1 minute // using fast and cheap blockchains, it looks suspicious when tx is not almost instantly confirmed const CUSTOM_ACCOUNT_SYNC_INTERVALS: Partial> = { pol: 20 * 1000, - bnb: 20 * 1000, + bsc: 20 * 1000, op: 20 * 1000, sol: DEFAULT_ACCOUNT_SYNC_INTERVAL * 5, ada: DEFAULT_ACCOUNT_SYNC_INTERVAL * 5, diff --git a/suite-common/wallet-utils/src/__fixtures__/accountUtils.ts b/suite-common/wallet-utils/src/__fixtures__/accountUtils.ts index 186fce0cc205..06cd7f041bf6 100644 --- a/suite-common/wallet-utils/src/__fixtures__/accountUtils.ts +++ b/suite-common/wallet-utils/src/__fixtures__/accountUtils.ts @@ -69,7 +69,7 @@ export const accountTitleFixture: Array<{ { symbol: 'vtc', title: 'TR_NETWORK_VERTCOIN' }, { symbol: 'zec', title: 'TR_NETWORK_ZCASH' }, { symbol: 'eth', title: 'TR_NETWORK_ETHEREUM' }, - { symbol: 'bnb', title: 'TR_NETWORK_BNB' }, + { symbol: 'bsc', title: 'TR_NETWORK_BNB' }, { symbol: 'base', title: 'TR_NETWORK_BASE' }, { symbol: 'op', title: 'TR_NETWORK_OP' }, { symbol: 'etc', title: 'TR_NETWORK_ETHEREUM_CLASSIC' }, diff --git a/suite-common/wallet-utils/src/__tests__/filterReceiveAccounts.test.ts b/suite-common/wallet-utils/src/__tests__/filterReceiveAccounts.test.ts index 7cbda314b0fb..597aec15c444 100644 --- a/suite-common/wallet-utils/src/__tests__/filterReceiveAccounts.test.ts +++ b/suite-common/wallet-utils/src/__tests__/filterReceiveAccounts.test.ts @@ -82,7 +82,7 @@ describe('filter receive accounts', () => { }); it('returns no results when given a non-existing network in acccounts list', () => { - expect(runFilterReceiveAccouns({ symbol: 'bnb' })).toEqual([]); + expect(runFilterReceiveAccouns({ symbol: 'bsc' })).toEqual([]); }); it('returns all accounts when debug mode is on', () => { diff --git a/suite-common/wallet-utils/src/accountUtils.ts b/suite-common/wallet-utils/src/accountUtils.ts index 30d9854d8221..e241c1948b63 100644 --- a/suite-common/wallet-utils/src/accountUtils.ts +++ b/suite-common/wallet-utils/src/accountUtils.ts @@ -157,7 +157,7 @@ export const getTitleForNetwork = (symbol: NetworkSymbolExtended) => { return 'TR_NETWORK_ZCASH'; case 'eth': return 'TR_NETWORK_ETHEREUM'; - case 'bnb': + case 'bsc': return 'TR_NETWORK_BNB'; case 'base': return 'TR_NETWORK_BASE'; diff --git a/suite-native/config/src/supportedNetworks.ts b/suite-native/config/src/supportedNetworks.ts index 0d8c3325a3d4..f40c6c89a87c 100644 --- a/suite-native/config/src/supportedNetworks.ts +++ b/suite-native/config/src/supportedNetworks.ts @@ -26,7 +26,7 @@ export const networkSymbolsWhitelistMap: Record<'mainnet' | 'testnet', readonly 'btc', 'eth', 'pol', - 'bnb', + 'bsc', 'ltc', 'etc', 'ada', diff --git a/suite-native/module-add-accounts/src/hooks/useAddCoinAccount.ts b/suite-native/module-add-accounts/src/hooks/useAddCoinAccount.ts index 01c6c0ad4c32..954eed0c9be7 100644 --- a/suite-native/module-add-accounts/src/hooks/useAddCoinAccount.ts +++ b/suite-native/module-add-accounts/src/hooks/useAddCoinAccount.ts @@ -113,7 +113,7 @@ export const useAddCoinAccount = () => { availableTypes.set(symbol, [ NORMAL_ACCOUNT_TYPE, // For Cardano and EVMs allow only normal account type - ...(['ada', 'eth', 'pol', 'bnb', 'sol', 'op', 'base'].includes(symbol) + ...(['ada', 'eth', 'pol', 'bsc', 'sol', 'op', 'base'].includes(symbol) ? [] : types), ]); diff --git a/suite-native/tokens/src/utils.ts b/suite-native/tokens/src/utils.ts index 485b7fcbca9f..bc7f9092a4cd 100644 --- a/suite-native/tokens/src/utils.ts +++ b/suite-native/tokens/src/utils.ts @@ -12,7 +12,7 @@ export const getTokenName = (tokenName?: string) => { export const NETWORK_SYMBOLS_WITH_TOKENS = [ 'eth', 'pol', - 'bnb', + 'bsc', 'sol', ] satisfies Array; export type NetworkSymbolWithTokens = (typeof NETWORK_SYMBOLS_WITH_TOKENS)[number];