From 8c24366ab6e71342ed464f6d2fc6dbddd83b9109 Mon Sep 17 00:00:00 2001 From: Dario Gabriel Lipicar Date: Mon, 13 Jan 2025 14:34:31 -0300 Subject: [PATCH] feat: integrate Base chain --- src/app_service/service/network/types.nim | 43 +------------------ storybook/src/Models/NetworksModel.qml | 2 + test/e2e/constants/wallet.py | 2 + ui/StatusQ/src/assets.qrc | 3 ++ .../img/icons/network/Network=Base-test.svg | 11 +++++ .../assets/img/icons/network/Network=Base.svg | 4 ++ .../img/icons/tiny/network/Network=Base.svg | 4 ++ ui/app/AppLayouts/Wallet/WalletUtils.qml | 4 ++ ui/app/AppLayouts/Wallet/stores/RootStore.qml | 13 ++++++ ui/imports/shared/views/HistoryView.qml | 4 +- ui/imports/utils/Constants.qml | 7 +++ ui/imports/utils/Utils.qml | 12 ++++++ vendor/status-go | 2 +- 13 files changed, 67 insertions(+), 44 deletions(-) create mode 100644 ui/StatusQ/src/assets/img/icons/network/Network=Base-test.svg create mode 100644 ui/StatusQ/src/assets/img/icons/network/Network=Base.svg create mode 100644 ui/StatusQ/src/assets/img/icons/tiny/network/Network=Base.svg diff --git a/src/app_service/service/network/types.nim b/src/app_service/service/network/types.nim index 1556af5b42a..83758742e09 100644 --- a/src/app_service/service/network/types.nim +++ b/src/app_service/service/network/types.nim @@ -1,50 +1,9 @@ const Mainnet = 1 -const Ropsten = 3 -const Rinkeby = 4 const Sepolia = 11155111 -const Optimism = 10 -const Poa = 99 -const XDai = 100 const NETWORK_LAYER_1 = 1 const NETWORK_LAYER_2 = 2 -export Mainnet, Ropsten, Rinkeby, Optimism, Poa, XDai, Sepolia +export Mainnet, Sepolia export NETWORK_LAYER_1, NETWORK_LAYER_2 -type - NetworkType* {.pure.} = enum - Mainnet = "mainnet_rpc", - Testnet = "testnet_rpc", - Rinkeby = "rinkeby_rpc", - Sepolia = "sepolia_rpc", - XDai = "xdai_rpc", - Poa = "poa_rpc", - Other = "other" - -proc toNetworkType*(networkName: string): NetworkType = - case networkName: - of "mainnet_rpc": - result = NetworkType.Mainnet - of "testnet_rpc": - result = NetworkType.Testnet - of "rinkeby_rpc": - result = NetworkType.Rinkeby - of "sepolia_rpc": - result = NetworkType.Sepolia - of "xdai_rpc": - result = NetworkType.XDai - of "poa_rpc": - result = NetworkType.Poa - else: - result = NetworkType.Other - -proc toChainId*(self: NetworkType): int = - case self: - of NetworkType.Mainnet: result = Mainnet - of NetworkType.Testnet: result = Ropsten - of NetworkType.Rinkeby: result = Rinkeby - of NetworkType.Sepolia: result = Sepolia - of NetworkType.XDai: result = XDai - of NetworkType.Poa: result = 99 - of NetworkType.Other: result = -1 diff --git a/storybook/src/Models/NetworksModel.qml b/storybook/src/Models/NetworksModel.qml index e3cb64a5ff9..39ae35da9ad 100644 --- a/storybook/src/Models/NetworksModel.qml +++ b/storybook/src/Models/NetworksModel.qml @@ -18,6 +18,8 @@ QtObject { readonly property int sepOptChainId: 11155420 readonly property int arbChainId: 42161 readonly property int sepArbChainId: 421614 + readonly property int baseChainId: 8453 + readonly property int sepBaseChainId: 84532 function getShortChainName(chainId) { diff --git a/test/e2e/constants/wallet.py b/test/e2e/constants/wallet.py index e6e38cbbe21..fed3ab344b7 100644 --- a/test/e2e/constants/wallet.py +++ b/test/e2e/constants/wallet.py @@ -54,6 +54,8 @@ class WalletNetworkNaming(Enum): OPTIMISM_SEPOLIA_NETWORK_ID = 11155420 ARBITRUM_MAINNET_NETWORK_ID = 42161 ARBITRUM_SEPOLIA_NETWORK_ID = 421614 + BASE_MAINNET_NETWORK_ID = 8453 + BASE_SEPOLIA_NETWORK_ID = 84532 class WalletNetworkDefaultValues(Enum): diff --git a/ui/StatusQ/src/assets.qrc b/ui/StatusQ/src/assets.qrc index df7e418ae11..669bc78b74d 100644 --- a/ui/StatusQ/src/assets.qrc +++ b/ui/StatusQ/src/assets.qrc @@ -9115,6 +9115,8 @@ assets/img/icons/mask/dummyLineGraph.svg assets/img/icons/network/Network=Arbitrum.svg assets/img/icons/network/Network=Arbitrum-test.svg + assets/img/icons/network/Network=Base.svg + assets/img/icons/network/Network=Base-test.svg assets/img/icons/network/Network=Custom.svg assets/img/icons/network/Network=Ethereum.svg assets/img/icons/network/Network=Ethereum-test.svg @@ -9140,6 +9142,7 @@ assets/img/icons/protocol/Protocol=Hop.svg assets/img/icons/protocol/Protocol=Uniswap.svg assets/img/icons/tiny/network/Network=Arbitrum.svg + assets/img/icons/tiny/network/Network=Base.svg assets/img/icons/tiny/network/Network=Custom.svg assets/img/icons/tiny/network/Network=Ethereum.svg assets/img/icons/tiny/network/Network=Hermez.svg diff --git a/ui/StatusQ/src/assets/img/icons/network/Network=Base-test.svg b/ui/StatusQ/src/assets/img/icons/network/Network=Base-test.svg new file mode 100644 index 00000000000..1af08075e6f --- /dev/null +++ b/ui/StatusQ/src/assets/img/icons/network/Network=Base-test.svg @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/ui/StatusQ/src/assets/img/icons/network/Network=Base.svg b/ui/StatusQ/src/assets/img/icons/network/Network=Base.svg new file mode 100644 index 00000000000..9fc6d5b4af5 --- /dev/null +++ b/ui/StatusQ/src/assets/img/icons/network/Network=Base.svg @@ -0,0 +1,4 @@ + + + + diff --git a/ui/StatusQ/src/assets/img/icons/tiny/network/Network=Base.svg b/ui/StatusQ/src/assets/img/icons/tiny/network/Network=Base.svg new file mode 100644 index 00000000000..9fc6d5b4af5 --- /dev/null +++ b/ui/StatusQ/src/assets/img/icons/tiny/network/Network=Base.svg @@ -0,0 +1,4 @@ + + + + diff --git a/ui/app/AppLayouts/Wallet/WalletUtils.qml b/ui/app/AppLayouts/Wallet/WalletUtils.qml index 7a658a79d0a..789239603bd 100644 --- a/ui/app/AppLayouts/Wallet/WalletUtils.qml +++ b/ui/app/AppLayouts/Wallet/WalletUtils.qml @@ -291,6 +291,10 @@ QtObject { case Constants.chains.arbitrumSepoliaChainId: chain = Constants.openseaExplorerLinks.arbitrum break + case Constants.chains.baseChainId: + case Constants.chains.baseSepoliaChainId: + chain = Constants.openseaExplorerLinks.base + break } return qsTr("not enough balance for %1 on %2 chain").arg(jsonObj.token).arg(chain) diff --git a/ui/app/AppLayouts/Wallet/stores/RootStore.qml b/ui/app/AppLayouts/Wallet/stores/RootStore.qml index 60a512d42c1..70c9baa440d 100644 --- a/ui/app/AppLayouts/Wallet/stores/RootStore.qml +++ b/ui/app/AppLayouts/Wallet/stores/RootStore.qml @@ -416,6 +416,11 @@ QtObject { if (root.areTestNetworksEnabled) { link = Constants.networkExplorerLinks.sepoliaOptimism } + } else if (networkShortName === Constants.networkShortChainNames.base) { + link = Constants.networkExplorerLinks.base + if (root.areTestNetworksEnabled) { + link = Constants.networkExplorerLinks.sepoliaBase + } } return link } @@ -437,6 +442,9 @@ QtObject { if (networkShortName === Constants.networkShortChainNames.optimism) { return qsTr("Optimism Explorer") } + if (networkShortName === Constants.networkShortChainNames.base) { + return qsTr("Base Explorer") + } return qsTr("Etherscan Explorer") } @@ -457,6 +465,11 @@ QtObject { if (root.areTestNetworksEnabled) { networkName = Constants.openseaExplorerLinks.sepoliaOptimism } + } else if (networkShortName === Constants.networkShortChainNames.base) { + networkName = Constants.openseaExplorerLinks.base + if (root.areTestNetworksEnabled) { + networkName = Constants.openseaExplorerLinks.sepoliaBase + } } return networkName } diff --git a/ui/imports/shared/views/HistoryView.qml b/ui/imports/shared/views/HistoryView.qml index b52c23577ea..0ceb702c1ea 100644 --- a/ui/imports/shared/views/HistoryView.qml +++ b/ui/imports/shared/views/HistoryView.qml @@ -97,9 +97,10 @@ ColumnLayout { bgBorderColor: Theme.palette.primaryColor2 tagPrimaryLabel.textFormat: Text.RichText tagPrimaryLabel.font.pixelSize: Theme.additionalTextSize - tagPrimaryLabel.text: qsTr("Activity is in beta. If transactions are missing, check %1, %2, or %3.") + tagPrimaryLabel.text: qsTr("Activity is in beta. If transactions are missing, check %1, %2, %3 or %4.") .arg(Utils.getStyledLink("Etherscan", "https://etherscan.io/", tagPrimaryLabel.hoveredLink)) .arg(Utils.getStyledLink("OP Explorer", "https://optimistic.etherscan.io/", tagPrimaryLabel.hoveredLink)) + .arg(Utils.getStyledLink("BaseScan", "https://basescan.org/", tagPrimaryLabel.hoveredLink)) .arg(Utils.getStyledLink("Arbiscan", "https://arbiscan.io/", tagPrimaryLabel.hoveredLink)) tagPrimaryLabel.onLinkActivated: (link) => { const explorerUrl = root.walletRootStore.showAllAccounts ? link @@ -309,6 +310,7 @@ ColumnLayout { } onViewTxOnExplorerRequested: { + console.log("Viewing tx on explorer ", networkShortName, isNetworkTestnet, firstTxChainId, firstTxHash) let link = Utils.getUrlForTxOnNetwork(networkShortName, isNetworkTestnet, firstTxHash) Global.openLink(link) } diff --git a/ui/imports/utils/Constants.qml b/ui/imports/utils/Constants.qml index 7a6cd3e1384..ff078025720 100644 --- a/ui/imports/utils/Constants.qml +++ b/ui/imports/utils/Constants.qml @@ -21,6 +21,8 @@ QtObject { readonly property int optimismSepoliaChainId: 11155420 readonly property int arbitrumChainId: 42161 readonly property int arbitrumSepoliaChainId: 421614 + readonly property int baseChainId: 8453 + readonly property int baseSepoliaChainId: 84532 } readonly property QtObject startupFlow: QtObject { @@ -887,16 +889,19 @@ QtObject { readonly property string mainnet: "eth" readonly property string arbitrum: "arb1" readonly property string optimism: "oeth" + readonly property string base: "base" } readonly property QtObject networkExplorerLinks: QtObject { readonly property string etherscan: "https://etherscan.io" readonly property string arbiscan: "https://arbiscan.io" readonly property string optimism: "https://optimistic.etherscan.io" + readonly property string base: "https://basescan.org" readonly property string sepoliaEtherscan: "https://sepolia.etherscan.io/" readonly property string sepoliaArbiscan: "https://sepolia.arbiscan.io/" readonly property string sepoliaOptimism: "https://sepolia-optimism.etherscan.io/" + readonly property string sepoliaBase: "https://sepolia.basescan.org/" readonly property string addressPath: "address" readonly property string txPath: "tx" @@ -909,10 +914,12 @@ QtObject { readonly property string ethereum: "ethereum" readonly property string arbitrum: "arbitrum" readonly property string optimism: "optimism" + readonly property string base: "base" readonly property string sepoliaEthereum: "sepolia" readonly property string sepoliaArbitrum: "arbitrum-sepolia" readonly property string sepoliaOptimism: "optimism-sepolia" + readonly property string sepoliaBase: "base-sepolia" } readonly property string api_request: "api-request" diff --git a/ui/imports/utils/Utils.qml b/ui/imports/utils/Utils.qml index e6daa6d68df..3f031623395 100644 --- a/ui/imports/utils/Utils.qml +++ b/ui/imports/utils/Utils.qml @@ -629,6 +629,11 @@ QtObject { if (testnetMode) { link = Constants.networkExplorerLinks.sepoliaOptimism } + } else if (networkShortName === Constants.networkShortChainNames.base) { + link = Constants.networkExplorerLinks.base + if (testnetMode) { + link = Constants.networkExplorerLinks.sepoliaBase + } } return "%1/%2/%3".arg(link).arg(type).arg(addressOrTx) @@ -652,6 +657,9 @@ QtObject { if (networkShortName === Constants.networkShortChainNames.optimism) { return qsTr("Optimistic") } + if (networkShortName === Constants.networkShortChainNames.base) { + return qsTr("BaseScan") + } return qsTr("Etherscan") } @@ -667,6 +675,9 @@ QtObject { case Constants.chains.optimismChainId: case Constants.chains.optimismSepoliaChainId: return Constants.networkShortChainNames.optimism + case Constants.chains.baseChainId: + case Constants.chains.baseSepoliaChainId: + return Constants.networkShortChainNames.base } return "" } @@ -677,6 +688,7 @@ QtObject { case Constants.chains.mainnetChainId: case Constants.chains.arbitrumChainId: case Constants.chains.optimismChainId: + case Constants.chains.baseChainId: return false } return true diff --git a/vendor/status-go b/vendor/status-go index 90ce72a2d58..1e4b20ecc3c 160000 --- a/vendor/status-go +++ b/vendor/status-go @@ -1 +1 @@ -Subproject commit 90ce72a2d58cb1aa5823025f7f7585f9b9beccfb +Subproject commit 1e4b20ecc3c7202de998280da4d6891553d136c7