From f98f57023fd18f78a805443001e5a08ada0fef80 Mon Sep 17 00:00:00 2001 From: tomasklim Date: Sat, 5 Oct 2024 09:18:56 +0200 Subject: [PATCH] feat(suite): add Optimism --- packages/address-validator/src/currencies.js | 5 ++++ packages/blockchain-link/src/ui/config.ts | 22 ++++++++++++++ .../src/components/CoinLogo/coins.ts | 1 + .../src/images/coins/op.svg | 21 ++++++++++++++ packages/suite/src/support/messages.ts | 6 +++- packages/theme/src/coinsColors.ts | 1 + .../assets/cryptoIcons/op.svg | 21 ++++++++++++++ suite-common/icons-deprecated/src/icons.ts | 1 + .../wallet-config/src/networksConfig.ts | 29 ++++++++++++++++++- suite-common/wallet-config/src/types.ts | 1 + .../src/blockchain/blockchainThunks.ts | 1 + .../src/__fixtures__/accountUtils.ts | 1 + suite-common/wallet-utils/src/accountUtils.ts | 2 ++ suite-native/config/src/supportedNetworks.ts | 2 +- 14 files changed, 111 insertions(+), 3 deletions(-) create mode 100644 packages/product-components/src/images/coins/op.svg create mode 100644 suite-common/icons-deprecated/assets/cryptoIcons/op.svg diff --git a/packages/address-validator/src/currencies.js b/packages/address-validator/src/currencies.js index 410371a0dff..3538176897b 100644 --- a/packages/address-validator/src/currencies.js +++ b/packages/address-validator/src/currencies.js @@ -1451,6 +1451,11 @@ var CURRENCIES = [ symbol: 'bnb', validator: ETHValidator, }, + { + name: 'Optimism', + symbol: 'eth', + validator: ETHValidator, + }, { name: 'EOS', symbol: 'eos', diff --git a/packages/blockchain-link/src/ui/config.ts b/packages/blockchain-link/src/ui/config.ts index df63223da52..e2cf01c7291 100644 --- a/packages/blockchain-link/src/ui/config.ts +++ b/packages/blockchain-link/src/ui/config.ts @@ -109,6 +109,28 @@ export default [ subscribe: '', }, }, + { + blockchain: { + name: 'Optimism', + worker: 'js/blockbook-worker.js', + server: ['https://blockbook-dev.corp.sldev.cz:9302'], + debug: true, + }, + data: { + address: '', + accountInfoOptions: { + page: 1, + pageSize: 25, + contractFilter: undefined, + }, + estimateFeeOptions: { + blocks: [1, 2, 10], + }, + txid: '', + tx: '', + subscribe: '', + }, + }, { blockchain: { name: 'Ethereum Classic', diff --git a/packages/product-components/src/components/CoinLogo/coins.ts b/packages/product-components/src/components/CoinLogo/coins.ts index 360043461a1..4dd3f3620f8 100644 --- a/packages/product-components/src/components/CoinLogo/coins.ts +++ b/packages/product-components/src/components/CoinLogo/coins.ts @@ -13,6 +13,7 @@ export const COINS: Record = { etc: require('../../images/coins/etc.svg'), eth: require('../../images/coins/eth.svg'), ltc: require('../../images/coins/ltc.svg'), + op: require('../../images/coins/op.svg'), pol: require('../../images/coins/pol.svg'), nmc: require('../../images/coins/nmc.svg'), regtest: require('../../images/coins/btc_test.svg'), diff --git a/packages/product-components/src/images/coins/op.svg b/packages/product-components/src/images/coins/op.svg new file mode 100644 index 00000000000..098392b7f62 --- /dev/null +++ b/packages/product-components/src/images/coins/op.svg @@ -0,0 +1,21 @@ + + + + + + + + diff --git a/packages/suite/src/support/messages.ts b/packages/suite/src/support/messages.ts index dbf6ee7c942..743fa9ee6e9 100644 --- a/packages/suite/src/support/messages.ts +++ b/packages/suite/src/support/messages.ts @@ -2780,6 +2780,10 @@ export default defineMessages({ defaultMessage: 'BNB Smart Chain', id: 'TR_NETWORK_BNB', }, + TR_NETWORK_OP: { + defaultMessage: 'Optimism', + id: 'TR_NETWORK_OP', + }, TR_NETWORK_LITECOIN: { defaultMessage: 'Litecoin', id: 'TR_NETWORK_LITECOIN', @@ -4950,7 +4954,7 @@ export default defineMessages({ TR_EXPERIMENTAL_OP_ETHEREUM_DESCRIPTION: { id: 'TR_EXPERIMENTAL_OP_ETHEREUM_DESCRIPTION', defaultMessage: - 'Enables the Optimism network but without internal transaction data history.', + 'Enables the Optimism network but with wrong symbol OP instead of ETH and minimum gas 1 gwei.', }, TR_EXPERIMENTAL_PASSWORD_MANAGER: { id: 'TR_EXPERIMENTAL_PASSWORD_MANAGER', diff --git a/packages/theme/src/coinsColors.ts b/packages/theme/src/coinsColors.ts index 7181f5f9eaf..0921d85adde 100644 --- a/packages/theme/src/coinsColors.ts +++ b/packages/theme/src/coinsColors.ts @@ -17,6 +17,7 @@ export const coinsColors: CoinsColors = { etc: '#60c67e', eth: '#454a75', ltc: '#a6a8a9', + op: '#ff0720', pol: '#7b3fe4', nmc: '#186c9d', regtest: '#e75f5f', diff --git a/suite-common/icons-deprecated/assets/cryptoIcons/op.svg b/suite-common/icons-deprecated/assets/cryptoIcons/op.svg new file mode 100644 index 00000000000..098392b7f62 --- /dev/null +++ b/suite-common/icons-deprecated/assets/cryptoIcons/op.svg @@ -0,0 +1,21 @@ + + + + + + + + diff --git a/suite-common/icons-deprecated/src/icons.ts b/suite-common/icons-deprecated/src/icons.ts index 781ad390920..746ad3e5f03 100644 --- a/suite-common/icons-deprecated/src/icons.ts +++ b/suite-common/icons-deprecated/src/icons.ts @@ -238,6 +238,7 @@ export const cryptoIcons = { dsol: require('../assets/cryptoIcons/dsol.svg'), etc: require('../assets/cryptoIcons/etc.svg'), eth: require('../assets/cryptoIcons/eth.svg'), + op: require('../assets/cryptoIcons/op.svg'), gnt: require('../assets/cryptoIcons/gnt.svg'), ltc: require('../assets/cryptoIcons/ltc.svg'), pol: require('../assets/cryptoIcons/pol.svg'), diff --git a/suite-common/wallet-config/src/networksConfig.ts b/suite-common/wallet-config/src/networksConfig.ts index 8e850b6dbf9..29b24dda88f 100644 --- a/suite-common/wallet-config/src/networksConfig.ts +++ b/suite-common/wallet-config/src/networksConfig.ts @@ -81,7 +81,6 @@ export const networks = { coingeckoId: 'ethereum', coingeckoNativeId: 'ethereum', }, - pol: { symbol: 'pol', name: 'Polygon PoS', @@ -136,6 +135,34 @@ export const networks = { coingeckoId: 'binance-smart-chain', coingeckoNativeId: 'binancecoin', }, + op: { + symbol: 'op', + name: 'Optimism', + networkType: 'ethereum', + chainId: 10, + bip43Path: "m/44'/60'/0'/0/i", + decimals: 18, + testnet: false, + explorer: { + tx: 'https://blockbook-dev.corp.sldev.cz:9302/tx/', + account: 'https://blockbook-dev.corp.sldev.cz:9302/address/', + nft: 'https://blockbook-dev.corp.sldev.cz:9302/nft/', + address: 'https://blockbook-dev.corp.sldev.cz:9302/address/', + queryString: '', + }, + features: ['rbf', 'sign-verify', 'tokens', 'coin-definitions', 'nft-definitions'], + customBackends: ['blockbook'], + accountTypes: { + ledger: { + // ledger (live), #1 acc is same as Trezor, so it is skipped + accountType: 'ledger', + bip43Path: "m/44'/60'/i'/0/0", + isDebugOnlyAccountType: true, + }, + }, + coingeckoId: 'optimistic-ethereum', + coingeckoNativeId: 'ethereum', + }, sol: { symbol: 'sol', name: 'Solana', diff --git a/suite-common/wallet-config/src/types.ts b/suite-common/wallet-config/src/types.ts index fc628c23353..c3e7739f7a4 100644 --- a/suite-common/wallet-config/src/types.ts +++ b/suite-common/wallet-config/src/types.ts @@ -19,6 +19,7 @@ export type NetworkSymbol = | 'sol' | 'pol' | 'bnb' + | 'op' | 'test' | 'regtest' | 'tsep' diff --git a/suite-common/wallet-core/src/blockchain/blockchainThunks.ts b/suite-common/wallet-core/src/blockchain/blockchainThunks.ts index 98dac58f1f2..185b24f84f0 100644 --- a/suite-common/wallet-core/src/blockchain/blockchainThunks.ts +++ b/suite-common/wallet-core/src/blockchain/blockchainThunks.ts @@ -41,6 +41,7 @@ const DEFAULT_ACCOUNT_SYNC_INTERVAL = 60 * 1000; const CUSTOM_ACCOUNT_SYNC_INTERVALS: Partial> = { pol: 20 * 1000, bnb: 20 * 1000, + op: 20 * 1000, }; const getAccountSyncInterval = (symbol: NetworkSymbol) => diff --git a/suite-common/wallet-utils/src/__fixtures__/accountUtils.ts b/suite-common/wallet-utils/src/__fixtures__/accountUtils.ts index ed6c120fb04..a480da495d3 100644 --- a/suite-common/wallet-utils/src/__fixtures__/accountUtils.ts +++ b/suite-common/wallet-utils/src/__fixtures__/accountUtils.ts @@ -61,6 +61,7 @@ export const accountTitleFixture = [ { symbol: 'zec', title: 'TR_NETWORK_ZCASH' }, { symbol: 'eth', title: 'TR_NETWORK_ETHEREUM' }, { symbol: 'bnb', title: 'TR_NETWORK_BNB' }, + { symbol: 'op', title: 'TR_NETWORK_OP' }, { symbol: 'etc', title: 'TR_NETWORK_ETHEREUM_CLASSIC' }, { symbol: 'xem', title: 'TR_NETWORK_NEM' }, { symbol: 'xlm', title: 'TR_NETWORK_STELLAR' }, diff --git a/suite-common/wallet-utils/src/accountUtils.ts b/suite-common/wallet-utils/src/accountUtils.ts index ed4857c5c8e..a10e7175c3b 100644 --- a/suite-common/wallet-utils/src/accountUtils.ts +++ b/suite-common/wallet-utils/src/accountUtils.ts @@ -156,6 +156,8 @@ export const getTitleForNetwork = (symbol: NetworkSymbol) => { return 'TR_NETWORK_ETHEREUM'; case 'bnb': return 'TR_NETWORK_BNB'; + case 'op': + return 'TR_NETWORK_OP'; case 'tsep': return 'TR_NETWORK_ETHEREUM_SEPOLIA'; case 'thol': diff --git a/suite-native/config/src/supportedNetworks.ts b/suite-native/config/src/supportedNetworks.ts index ebb02ac5c5f..dafd3470011 100644 --- a/suite-native/config/src/supportedNetworks.ts +++ b/suite-native/config/src/supportedNetworks.ts @@ -17,7 +17,7 @@ export const orderedAccountTypes: AccountType[] = [ 'ledger', ]; -const discoveryBlacklist: NetworkSymbol[] = ['sol', 'dsol', 'pol', 'bnb']; +const discoveryBlacklist: NetworkSymbol[] = ['sol', 'dsol', 'pol', 'bnb', 'op']; // All supported coins for device discovery export const networkSymbolsWhitelistMap = {