feat(@wallet): Enable sepolia network
This commit is contained in:
parent
3321708629
commit
18c37fbdac
|
@ -50,6 +50,12 @@ proc areTestNetworksEnabled*(self: Controller): bool =
|
|||
proc toggleTestNetworksEnabled*(self: Controller) =
|
||||
self.walletAccountService.toggleTestNetworksEnabled()
|
||||
|
||||
proc isSepoliaEnabled*(self: Controller): bool =
|
||||
return self.walletAccountService.isSepoliaEnabled()
|
||||
|
||||
proc toggleIsSepoliaEnabled*(self: Controller) =
|
||||
self.walletAccountService.toggleIsSepoliaEnabled()
|
||||
|
||||
proc fetchChainIdForUrl*(self: Controller, url: string, isMainUrl: bool) =
|
||||
self.walletAccountService.fetchChainIdForUrl(url, isMainUrl)
|
||||
|
||||
|
|
|
@ -25,6 +25,9 @@ method refreshNetworks*(self: AccessInterface) {.base.} =
|
|||
method toggleTestNetworksEnabled*(self: AccessInterface) {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
method toggleIsSepoliaEnabled*(self: AccessInterface) {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
method getModuleAsVariant*(self: AccessInterface): QVariant {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
|
|
|
@ -100,6 +100,10 @@ method toggleTestNetworksEnabled*(self: Module) =
|
|||
self.controller.toggleTestNetworksEnabled()
|
||||
self.refreshNetworks()
|
||||
|
||||
method toggleIsSepoliaEnabled*(self: Module) =
|
||||
self.controller.toggleIsSepoliaEnabled()
|
||||
self.refreshNetworks()
|
||||
|
||||
method updateNetworkEndPointValues*(self: Module, chainId: int, newMainRpcInput, newFailoverRpcUrl: string) =
|
||||
self.controller.updateNetworkEndPointValues(chainId, newMainRpcInput, newFailoverRpcUrl)
|
||||
|
||||
|
|
|
@ -13,6 +13,7 @@ QtObject:
|
|||
combinedNetworks: CombinedModel
|
||||
networks: Model
|
||||
areTestNetworksEnabled: bool
|
||||
isSepoliaEnabled: bool
|
||||
|
||||
proc setup(self: View) =
|
||||
self.QObject.setup
|
||||
|
@ -46,6 +47,24 @@ QtObject:
|
|||
self.areTestNetworksEnabled = not self.areTestNetworksEnabled
|
||||
self.areTestNetworksEnabledChanged()
|
||||
|
||||
proc isSepoliaEnabledChanged*(self: View) {.signal.}
|
||||
|
||||
proc getIsSepoliaEnalbled(self: View): bool {.slot.} =
|
||||
return self.isSepoliaEnabled
|
||||
|
||||
QtProperty[bool] isSepoliaEnabled:
|
||||
read = getIsSepoliaEnalbled
|
||||
notify = isSepoliaEnabledChanged
|
||||
|
||||
proc setIsSepoliaEnabled*(self: View, isSepoliaEnabled: bool) =
|
||||
self.isSepoliaEnabled = isSepoliaEnabled
|
||||
self.isSepoliaEnabledChanged()
|
||||
|
||||
proc toggleIsSepoliaEnabled*(self: View) {.slot.} =
|
||||
self.delegate.toggleIsSepoliaEnabled()
|
||||
self.isSepoliaEnabled = not self.isSepoliaEnabled
|
||||
self.isSepoliaEnabledChanged()
|
||||
|
||||
proc networksChanged*(self: View) {.signal.}
|
||||
proc getNetworks(self: View): QVariant {.slot.} =
|
||||
return newQVariant(self.networks)
|
||||
|
|
|
@ -171,6 +171,23 @@ var NETWORKS* = %* [
|
|||
"layer": 2,
|
||||
"enabled": false,
|
||||
"relatedChainId": 42161,
|
||||
},
|
||||
{
|
||||
"chainId": 11155111,
|
||||
"chainName": "Mainnet",
|
||||
"rpcUrl": "https://sepolia-archival.gateway.pokt.network/v1/lb/" & POKT_TOKEN_RESOLVED,
|
||||
"fallbackUrl": "https://sepolia.infura.io/v3/" & INFURA_TOKEN_RESOLVED,
|
||||
"blockExplorerUrl": "https://sepolia.etherscan.io/",
|
||||
"iconUrl": "network/Network=Ethereum",
|
||||
"chainColor": "#51D0F0",
|
||||
"shortName": "sep",
|
||||
"nativeCurrencyName": "Ether",
|
||||
"nativeCurrencySymbol": "ETH",
|
||||
"nativeCurrencyDecimals": 18,
|
||||
"isTest": true,
|
||||
"layer": 1,
|
||||
"enabled": true,
|
||||
"relatedChainId": 1,
|
||||
}
|
||||
]
|
||||
|
||||
|
|
|
@ -51,6 +51,9 @@ proc fetchNetworks*(self: Service, useCached: bool = true): seq[CombinedNetworkD
|
|||
self.networks = result
|
||||
self.networksInited = true
|
||||
|
||||
proc resetNetworks*(self: Service) =
|
||||
discard self.fetchNetworks(useCached = false)
|
||||
|
||||
proc getCombinedNetworks*(self: Service): seq[CombinedNetworkDto] =
|
||||
return self.fetchNetworks()
|
||||
|
||||
|
@ -128,7 +131,11 @@ proc setNetworksState*(self: Service, chainIds: seq[int], enabled: bool) =
|
|||
|
||||
proc getChainIdForEns*(self: Service): int =
|
||||
if self.settingsService.areTestNetworksEnabled():
|
||||
if self.settingsService.isSepoliaEnabled():
|
||||
return Sepolia
|
||||
|
||||
return Goerli
|
||||
|
||||
return Mainnet
|
||||
|
||||
proc getNetworkForEns*(self: Service): NetworkDto =
|
||||
|
@ -137,6 +144,9 @@ proc getNetworkForEns*(self: Service): NetworkDto =
|
|||
|
||||
proc getNetworkForStickers*(self: Service): NetworkDto =
|
||||
if self.settingsService.areTestNetworksEnabled():
|
||||
if self.settingsService.isSepoliaEnabled():
|
||||
return self.getNetwork(Sepolia)
|
||||
|
||||
return self.getNetwork(Goerli)
|
||||
|
||||
return self.getNetwork(Mainnet)
|
||||
|
@ -152,6 +162,9 @@ proc getNetworkForActivityCheck*(self: Service): NetworkDto =
|
|||
|
||||
proc getNetworkForCollectibles*(self: Service): NetworkDto =
|
||||
if self.settingsService.areTestNetworksEnabled():
|
||||
if self.settingsService.isSepoliaEnabled():
|
||||
return self.getNetwork(Sepolia)
|
||||
|
||||
return self.getNetwork(Goerli)
|
||||
|
||||
return self.getNetwork(Mainnet)
|
||||
|
|
|
@ -2,11 +2,12 @@ const Mainnet = 1
|
|||
const Ropsten = 3
|
||||
const Rinkeby = 4
|
||||
const Goerli = 5
|
||||
const Sepolia = 11155111
|
||||
const Optimism = 10
|
||||
const Poa = 99
|
||||
const XDai = 100
|
||||
|
||||
export Mainnet, Ropsten, Rinkeby, Goerli, Optimism, Poa, XDai
|
||||
export Mainnet, Ropsten, Rinkeby, Goerli, Optimism, Poa, XDai, Sepolia
|
||||
|
||||
type
|
||||
NetworkType* {.pure.} = enum
|
||||
|
@ -14,6 +15,7 @@ type
|
|||
Testnet = "testnet_rpc",
|
||||
Rinkeby = "rinkeby_rpc",
|
||||
Goerli = "goerli_rpc",
|
||||
Sepolia = "sepolia_rpc",
|
||||
XDai = "xdai_rpc",
|
||||
Poa = "poa_rpc",
|
||||
Other = "other"
|
||||
|
@ -28,6 +30,8 @@ proc toNetworkType*(networkName: string): NetworkType =
|
|||
result = NetworkType.Rinkeby
|
||||
of "goerli_rpc":
|
||||
result = NetworkType.Goerli
|
||||
of "sepolia_rpc":
|
||||
result = NetworkType.Sepolia
|
||||
of "xdai_rpc":
|
||||
result = NetworkType.XDai
|
||||
of "poa_rpc":
|
||||
|
@ -41,6 +45,7 @@ proc toChainId*(self: NetworkType): int =
|
|||
of NetworkType.Testnet: result = Ropsten
|
||||
of NetworkType.Rinkeby: result = Rinkeby
|
||||
of NetworkType.Goerli: result = Goerli
|
||||
of NetworkType.Sepolia: result = Sepolia
|
||||
of NetworkType.XDai: result = XDai
|
||||
of NetworkType.Poa: result = 99
|
||||
of NetworkType.Other: result = -1
|
|
@ -44,6 +44,7 @@ const KEY_GIF_API_KEY* = "gifs/api-key"
|
|||
const KEY_DISPLAY_NAME* = "display-name"
|
||||
const KEY_BIO* = "bio"
|
||||
const KEY_TEST_NETWORKS_ENABLED* = "test-networks-enabled?"
|
||||
const KEY_IS_SEPOLIA_ENABLED* = "is-sepolia-enabled?"
|
||||
const INCLUDE_WATCH_ONLY_ACCOUNT* = "include-watch-only-account?"
|
||||
const PROFILE_MIGRATION_NEEDED* = "profile-migration-needed"
|
||||
|
||||
|
@ -139,6 +140,7 @@ type
|
|||
notificationsMessagePreview*: int
|
||||
includeWatchOnlyAccount*: bool
|
||||
profileMigrationNeeded*: bool
|
||||
isSepoliaEnabled*: bool
|
||||
|
||||
proc toPinnedMailserver*(jsonObj: JsonNode): PinnedMailserver =
|
||||
# we maintain pinned mailserver per fleet
|
||||
|
@ -192,6 +194,7 @@ proc toSettingsDto*(jsonObj: JsonNode): SettingsDto =
|
|||
discard jsonObj.getProp(KEY_GIF_RECENTS, result.gifRecents)
|
||||
discard jsonObj.getProp(KEY_GIF_FAVORITES, result.gifFavorites)
|
||||
discard jsonObj.getProp(KEY_TEST_NETWORKS_ENABLED, result.testNetworksEnabled)
|
||||
discard jsonObj.getProp(KEY_IS_SEPOLIA_ENABLED, result.isSepoliaEnabled)
|
||||
discard jsonObj.getProp(INCLUDE_WATCH_ONLY_ACCOUNT, result.includeWatchOnlyAccount)
|
||||
discard jsonObj.getProp(PROFILE_MIGRATION_NEEDED, result.profileMigrationNeeded)
|
||||
|
||||
|
|
|
@ -484,6 +484,16 @@ QtObject:
|
|||
return true
|
||||
return false
|
||||
|
||||
proc isSepoliaEnabled*(self: Service): bool =
|
||||
return self.settings.isSepoliaEnabled
|
||||
|
||||
proc toggleIsSepoliaEnabled*(self: Service): bool =
|
||||
let newValue = not self.settings.isSepoliaEnabled
|
||||
if(self.saveSetting(KEY_IS_SEPOLIA_ENABLED, newValue)):
|
||||
self.settings.isSepoliaEnabled = newValue
|
||||
return true
|
||||
return false
|
||||
|
||||
proc notifSettingAllowNotificationsChanged*(self: Service) {.signal.}
|
||||
proc getNotifSettingAllowNotifications*(self: Service): bool {.slot.} =
|
||||
if self.initialized:
|
||||
|
|
|
@ -530,6 +530,15 @@ proc toggleTestNetworksEnabled*(self: Service) =
|
|||
self.checkRecentHistory(addresses)
|
||||
self.events.emit(SIGNAL_WALLET_ACCOUNT_NETWORK_ENABLED_UPDATED, Args())
|
||||
|
||||
proc toggleIsSepoliaEnabled*(self: Service) =
|
||||
discard self.settingsService.toggleIsSepoliaEnabled()
|
||||
self.networkService.resetNetworks()
|
||||
let addresses = self.getWalletAddresses()
|
||||
self.buildAllTokens(addresses, store = true)
|
||||
self.tokenService.loadData()
|
||||
self.checkRecentHistory(addresses)
|
||||
self.events.emit(SIGNAL_WALLET_ACCOUNT_NETWORK_ENABLED_UPDATED, Args())
|
||||
|
||||
proc updateWalletAccount*(self: Service, address: string, accountName: string, colorId: string, emoji: string): bool =
|
||||
try:
|
||||
var account = self.getAccountByAddress(address)
|
||||
|
@ -749,6 +758,9 @@ proc getCurrencyFormat*(self: Service, symbol: string): CurrencyFormatDto =
|
|||
proc areTestNetworksEnabled*(self: Service): bool =
|
||||
return self.settingsService.areTestNetworksEnabled()
|
||||
|
||||
proc isSepoliaEnabled*(self: Service): bool =
|
||||
return self.settingsService.isSepoliaEnabled()
|
||||
|
||||
proc hasPairedDevices*(self: Service): bool =
|
||||
return hasPairedDevices()
|
||||
|
||||
|
|
|
@ -11,6 +11,7 @@ StatusMenu {
|
|||
|
||||
property string selectedAddress
|
||||
property bool areTestNetworksEnabled: false
|
||||
property bool isSepoliaEnabled: false
|
||||
property string preferredSharingNetworks
|
||||
property var preferredSharingNetworksArray
|
||||
|
||||
|
@ -27,7 +28,15 @@ StatusMenu {
|
|||
text: qsTr("View address on Etherscan")
|
||||
icon.name: "link"
|
||||
onTriggered: {
|
||||
const link = areTestNetworksEnabled ? Constants.networkExplorerLinks.goerliEtherscan : Constants.networkExplorerLinks.etherscan
|
||||
let link = Constants.networkExplorerLinks.etherscan
|
||||
if (areTestNetworksEnabled) {
|
||||
if (root.isSepoliaEnabled) {
|
||||
link = Constants.networkExplorerLinks.sepoliaEtherscan
|
||||
} else {
|
||||
link = Constants.networkExplorerLinks.goerliEtherscan
|
||||
}
|
||||
}
|
||||
|
||||
Global.openLink("%1/%2/%3".arg(link).arg(Constants.networkExplorerLinks.addressPath).arg(root.selectedAddress))
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,6 +5,8 @@ QtObject {
|
|||
id: root
|
||||
|
||||
property var advancedModule
|
||||
property var walletModule
|
||||
property var networksModule: root.walletModule.networksModule
|
||||
|
||||
// Advanced Module Properties
|
||||
property string fleet: advancedModule? advancedModule.fleet : ""
|
||||
|
@ -43,6 +45,8 @@ QtObject {
|
|||
readonly property real scrollVelocity: localAppSettings.scrollVelocity
|
||||
readonly property real scrollDeceleration: localAppSettings.scrollDeceleration
|
||||
|
||||
readonly property bool isSepoliaEnabled: networksModule.isSepoliaEnabled
|
||||
|
||||
function logDir() {
|
||||
if(!root.advancedModule)
|
||||
return ""
|
||||
|
@ -178,4 +182,9 @@ QtObject {
|
|||
|
||||
localAppSettings.scrollDeceleration = value
|
||||
}
|
||||
|
||||
function toggleIsSepoliaEnabled(){
|
||||
networksModule.toggleIsSepoliaEnabled()
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -19,6 +19,7 @@ QtObject {
|
|||
}
|
||||
|
||||
property AdvancedStore advancedStore: AdvancedStore {
|
||||
walletModule: profileSectionModuleInst.walletModule
|
||||
advancedModule: profileSectionModuleInst.advancedModule
|
||||
}
|
||||
|
||||
|
|
|
@ -14,6 +14,8 @@ QtObject {
|
|||
property var dappList: Global.appIsReady? dappPermissionsModule.dapps : null
|
||||
|
||||
readonly property bool areTestNetworksEnabled: networksModule.areTestNetworksEnabled
|
||||
readonly property bool isSepoliaEnabled: networksModule.isSepoliaEnabled
|
||||
|
||||
readonly property var networks: networksModule.networks
|
||||
readonly property var combinedNetworks: networksModule.combinedNetworks
|
||||
property var selectedAccount
|
||||
|
@ -21,7 +23,6 @@ QtObject {
|
|||
function toggleTestNetworksEnabled(){
|
||||
networksModule.toggleTestNetworksEnabled()
|
||||
}
|
||||
|
||||
// TODO(alaibe): there should be no access to wallet section, create collectible in profile
|
||||
property var overview: walletSectionOverview
|
||||
property var assets: walletSectionAssets.assets
|
||||
|
|
|
@ -434,6 +434,17 @@ SettingsContentBase {
|
|||
}
|
||||
}
|
||||
|
||||
StatusSettingsLineButton {
|
||||
anchors.leftMargin: 0
|
||||
anchors.rightMargin: 0
|
||||
text: qsTr("Enable Sepolia as Test Network")
|
||||
isSwitch: true
|
||||
switchChecked: root.advancedStore.isSepoliaEnabled
|
||||
onClicked: {
|
||||
root.advancedStore.toggleIsSepoliaEnabled()
|
||||
}
|
||||
}
|
||||
|
||||
StatusSettingsLineButton {
|
||||
anchors.leftMargin: 0
|
||||
anchors.rightMargin: 0
|
||||
|
|
|
@ -298,6 +298,7 @@ ColumnLayout {
|
|||
id: addressMenu
|
||||
selectedAddress: !!root.account ? root.account.address: ""
|
||||
areTestNetworksEnabled: root.walletStore.areTestNetworksEnabled
|
||||
isSepoliaEnabled: root.walletStore.isSepoliaEnabled
|
||||
preferredSharingNetworks: d.preferredSharingNetworkShortNames
|
||||
preferredSharingNetworksArray: d.preferredSharingNetworksArray
|
||||
onCopyToClipboard: root.walletStore.copyToClipboard(address)
|
||||
|
|
|
@ -25,6 +25,7 @@ StatusListItem {
|
|||
property string chainShortNames
|
||||
property bool favourite: false
|
||||
property bool areTestNetworksEnabled: false
|
||||
property bool isSepoliaEnabled: false
|
||||
property var saveAddress: function (name, address, favourite, chainShortNames, ens) {}
|
||||
property var deleteSavedAddress: function (address, ens) {}
|
||||
|
||||
|
@ -172,7 +173,11 @@ StatusListItem {
|
|||
onTriggered: {
|
||||
var baseUrl = Constants.networkExplorerLinks.etherscan
|
||||
if (root.areTestNetworksEnabled) {
|
||||
baseUrl = Constants.networkExplorerLinks.goerliEtherscan
|
||||
if (root.isSepoliaEnabled) {
|
||||
baseUrl = Constants.networkExplorerLinks.sepoliaEtherscan
|
||||
} else {
|
||||
baseUrl = Constants.networkExplorerLinks.goerliEtherscan
|
||||
}
|
||||
}
|
||||
Global.openLink("%1/%2/%3".arg(baseUrl).arg(Constants.networkExplorerLinks.addressPath).arg(d.visibleAddress ? d.visibleAddress : root.ens))
|
||||
}
|
||||
|
|
|
@ -19,6 +19,7 @@ ColumnLayout {
|
|||
property string tokenAddress
|
||||
property bool strikethrough: false
|
||||
property bool areTestNetworksEnabled: false
|
||||
property bool isSepoliaEnabled: false
|
||||
|
||||
spacing: Style.current.padding
|
||||
|
||||
|
@ -103,7 +104,14 @@ ColumnLayout {
|
|||
radius: 8
|
||||
visible: nftPreviewSensor.hovered && !!root.tokenId && !!root.tokenAddress
|
||||
onClicked: {
|
||||
const link = areTestNetworksEnabled ? Constants.networkExplorerLinks.goerliEtherscan : Constants.networkExplorerLinks.etherscan
|
||||
let link = Constants.networkExplorerLinks.etherscan
|
||||
if (areTestNetworksEnabled) {
|
||||
if (root.isSepoliaEnabled) {
|
||||
link = Constants.networkExplorerLinks.sepoliaEtherscan
|
||||
} else {
|
||||
link = Constants.networkExplorerLinks.goerliEtherscan
|
||||
}
|
||||
}
|
||||
Global.openLink("%1/nft/%2/%3".arg(link).arg(root.tokenAddress).arg(root.tokenId))
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,6 +20,7 @@ StatusMenu {
|
|||
|
||||
property var contactsStore
|
||||
property bool areTestNetworksEnabled: false
|
||||
property bool isSepoliaEnabled: false
|
||||
|
||||
signal openSendModal(address: string)
|
||||
|
||||
|
@ -191,7 +192,14 @@ StatusMenu {
|
|||
icon.name: "link"
|
||||
onTriggered: {
|
||||
const type = d.addressType === TransactionAddressMenu.Tx ? Constants.networkExplorerLinks.txPath : Constants.networkExplorerLinks.addressPath
|
||||
const link = areTestNetworksEnabled ? Constants.networkExplorerLinks.goerliEtherscan : Constants.networkExplorerLinks.etherscan
|
||||
let link = Constants.networkExplorerLinks.etherscan
|
||||
if (areTestNetworksEnabled) {
|
||||
if (root.isSepoliaEnabled) {
|
||||
link = Constants.networkExplorerLinks.sepoliaEtherscan
|
||||
} else {
|
||||
link = Constants.networkExplorerLinks.goerliEtherscan
|
||||
}
|
||||
}
|
||||
Global.openLink("%1/%2/%3".arg(link).arg(type).arg(d.selectedAddress))
|
||||
}
|
||||
}
|
||||
|
|
|
@ -123,6 +123,7 @@ Item {
|
|||
store: RootStore
|
||||
contactsStore: root.contactsStore
|
||||
areTestNetworksEnabled: RootStore.areTestNetworksEnabled
|
||||
isSepoliaEnabled: RootStore.isSepoliaEnabled
|
||||
onOpenSendModal: root.sendModal.open(recipient);
|
||||
saveAddress: function(name, address, favourite, chainShortNames, ens) {
|
||||
_internal.saveAddress(name, address, favourite, chainShortNames, ens)
|
||||
|
|
|
@ -191,6 +191,7 @@ Item {
|
|||
tokenId: root.isTransactionValid ? transaction.tokenID : ""
|
||||
tokenAddress: root.isTransactionValid ? transaction.tokenAddress : ""
|
||||
areTestNetworksEnabled: WalletStores.RootStore.areTestNetworksEnabled
|
||||
isSepoliaEnabled: WalletStores.RootStore.isSepoliaEnabled
|
||||
}
|
||||
|
||||
Column {
|
||||
|
@ -772,6 +773,7 @@ Item {
|
|||
id: addressMenu
|
||||
|
||||
areTestNetworksEnabled: WalletStores.RootStore.areTestNetworksEnabled
|
||||
isSepoliaEnabled: WalletStores.RootStore.isSepoliaEnabled
|
||||
contactsStore: root.contactsStore
|
||||
onOpenSendModal: (address) => root.sendModal.open(address)
|
||||
}
|
||||
|
|
|
@ -891,6 +891,7 @@ QtObject {
|
|||
readonly property string goerliEtherscan: "https://goerli.etherscan.io"
|
||||
readonly property string goerliArbiscan: "https://goerli.arbiscan.io"
|
||||
readonly property string goerliOptimistic: "https://goerli-optimism.etherscan.io"
|
||||
readonly property string sepoliaEtherscan: "https://sepolia.etherscan.io/"
|
||||
|
||||
readonly property string addressPath: "address"
|
||||
readonly property string txPath: "tx"
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit da3df63eb19a0a267caf67e6fcdf2d5a8291b888
|
||||
Subproject commit 39676c8c011fafe8cc5ccc716d039d24c1866f78
|
Loading…
Reference in New Issue