Skip to content

Commit

Permalink
feat: integrate Base chain
Browse files Browse the repository at this point in the history
  • Loading branch information
dlipicar committed Jan 14, 2025
1 parent 866a1a6 commit 564dce3
Show file tree
Hide file tree
Showing 13 changed files with 75 additions and 73 deletions.
43 changes: 1 addition & 42 deletions src/app_service/service/network/types.nim
Original file line number Diff line number Diff line change
@@ -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
2 changes: 2 additions & 0 deletions storybook/src/Models/NetworksModel.qml
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 2 additions & 0 deletions test/e2e/constants/wallet.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
3 changes: 3 additions & 0 deletions ui/StatusQ/src/assets.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -9115,6 +9115,8 @@
<file>assets/img/icons/mask/dummyLineGraph.svg</file>
<file>assets/img/icons/network/Network=Arbitrum.svg</file>
<file>assets/img/icons/network/Network=Arbitrum-test.svg</file>
<file>assets/img/icons/network/Network=Base.svg</file>
<file>assets/img/icons/network/Network=Base-test.svg</file>
<file>assets/img/icons/network/Network=Custom.svg</file>
<file>assets/img/icons/network/Network=Ethereum.svg</file>
<file>assets/img/icons/network/Network=Ethereum-test.svg</file>
Expand All @@ -9140,6 +9142,7 @@
<file>assets/img/icons/protocol/Protocol=Hop.svg</file>
<file>assets/img/icons/protocol/Protocol=Uniswap.svg</file>
<file>assets/img/icons/tiny/network/Network=Arbitrum.svg</file>
<file>assets/img/icons/tiny/network/Network=Base.svg</file>
<file>assets/img/icons/tiny/network/Network=Custom.svg</file>
<file>assets/img/icons/tiny/network/Network=Ethereum.svg</file>
<file>assets/img/icons/tiny/network/Network=Hermez.svg</file>
Expand Down
11 changes: 11 additions & 0 deletions ui/StatusQ/src/assets/img/icons/network/Network=Base-test.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions ui/StatusQ/src/assets/img/icons/network/Network=Base.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions ui/StatusQ/src/assets/img/icons/tiny/network/Network=Base.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions ui/app/AppLayouts/Wallet/WalletUtils.qml
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
31 changes: 9 additions & 22 deletions ui/app/AppLayouts/Wallet/stores/RootStore.qml
Original file line number Diff line number Diff line change
Expand Up @@ -399,29 +399,8 @@ QtObject {
return d.mainModuleInst.addressWasShown(address)
}

function getExplorerDomain(networkShortName) {
let link = Constants.networkExplorerLinks.etherscan
if (networkShortName === Constants.networkShortChainNames.mainnet) {
if (root.areTestNetworksEnabled) {
link = Constants.networkExplorerLinks.sepoliaEtherscan
}
}
if (networkShortName === Constants.networkShortChainNames.arbitrum) {
link = Constants.networkExplorerLinks.arbiscan
if (root.areTestNetworksEnabled) {
link = Constants.networkExplorerLinks.sepoliaArbiscan
}
} else if (networkShortName === Constants.networkShortChainNames.optimism) {
link = Constants.networkExplorerLinks.optimism
if (root.areTestNetworksEnabled) {
link = Constants.networkExplorerLinks.sepoliaOptimism
}
}
return link
}

function getExplorerUrl(networkShortName, contractAddress, tokenId) {
let link = getExplorerDomain(networkShortName)
let link = Utils.getExplorerDomain(networkShortName)
if (networkShortName === Constants.networkShortChainNames.mainnet) {
return "%1/nft/%2/%3".arg(link).arg(contractAddress).arg(tokenId)
}
Expand All @@ -437,6 +416,9 @@ QtObject {
if (networkShortName === Constants.networkShortChainNames.optimism) {
return qsTr("Optimism Explorer")
}
if (networkShortName === Constants.networkShortChainNames.base) {
return qsTr("Base Explorer")
}
return qsTr("Etherscan Explorer")
}

Expand All @@ -457,6 +439,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
}
Expand Down
3 changes: 2 additions & 1 deletion ui/imports/shared/views/HistoryView.qml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 7 additions & 0 deletions ui/imports/utils/Constants.qml
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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"
Expand All @@ -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"
Expand Down
32 changes: 25 additions & 7 deletions ui/imports/utils/Utils.qml
Original file line number Diff line number Diff line change
Expand Up @@ -610,15 +610,13 @@ QtObject {
Theme.palette.warningColor1
}

function getEtherscanUrl(networkShortName, testnetMode, addressOrTx, isAddressNotTx) {
const type = isAddressNotTx
? Constants.networkExplorerLinks.addressPath
: Constants.networkExplorerLinks.txPath
function getExplorerDomain(networkShortName, testnetMode) {
let link = Constants.networkExplorerLinks.etherscan
if (testnetMode) {
link = Constants.networkExplorerLinks.sepoliaEtherscan
if (networkShortName === Constants.networkShortChainNames.mainnet) {
if (testnetMode) {
link = Constants.networkExplorerLinks.sepoliaEtherscan
}
}

if (networkShortName === Constants.networkShortChainNames.arbitrum) {
link = Constants.networkExplorerLinks.arbiscan
if (testnetMode) {
Expand All @@ -629,7 +627,20 @@ QtObject {
if (testnetMode) {
link = Constants.networkExplorerLinks.sepoliaOptimism
}
} else if (networkShortName === Constants.networkShortChainNames.base) {
link = Constants.networkExplorerLinks.base
if (testnetMode) {
link = Constants.networkExplorerLinks.sepoliaBase
}
}
return link
}

function getEtherscanUrl(networkShortName, testnetMode, addressOrTx, isAddressNotTx) {
const type = isAddressNotTx
? Constants.networkExplorerLinks.addressPath
: Constants.networkExplorerLinks.txPath
let link = getExplorerDomain(networkShortName, testnetMode)

return "%1/%2/%3".arg(link).arg(type).arg(addressOrTx)
}
Expand All @@ -652,6 +663,9 @@ QtObject {
if (networkShortName === Constants.networkShortChainNames.optimism) {
return qsTr("Optimistic")
}
if (networkShortName === Constants.networkShortChainNames.base) {
return qsTr("BaseScan")
}
return qsTr("Etherscan")
}

Expand All @@ -667,6 +681,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 ""
}
Expand All @@ -677,6 +694,7 @@ QtObject {
case Constants.chains.mainnetChainId:
case Constants.chains.arbitrumChainId:
case Constants.chains.optimismChainId:
case Constants.chains.baseChainId:
return false
}
return true
Expand Down
2 changes: 1 addition & 1 deletion vendor/status-go
Submodule status-go updated 143 files

0 comments on commit 564dce3

Please sign in to comment.