Skip to content

Commit

Permalink
enable dex mainnet
Browse files Browse the repository at this point in the history
Signed-off-by: Philemon Ukane <ukanephilemon@gmail.com>
  • Loading branch information
ukane-philemon committed Oct 15, 2024
1 parent c078574 commit 8fbda6e
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 28 deletions.
4 changes: 2 additions & 2 deletions libwallet/assets_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -907,8 +907,8 @@ func (mgr *AssetsManager) DEXCInitialized() bool {
// initialized first so the DEX client can bind previously added wallets when it
// starts.
func (mgr *AssetsManager) InitializeDEX(ctx context.Context) {
// Ignore attempts to InitializeDEX on mainnet and on mobile.
if mgr.NetType() == utils.Mainnet || appos.Current().IsMobile() {
// Ignore attempts to InitializeDEX on mobile.
if appos.Current().IsMobile() {
return
}

Expand Down
29 changes: 5 additions & 24 deletions ui/page/dcrdex/dcrdex_page.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import (
"github.com/crypto-power/cryptopower/ui/cryptomaterial"
"github.com/crypto-power/cryptopower/ui/load"
"github.com/crypto-power/cryptopower/ui/page/components"
"github.com/crypto-power/cryptopower/ui/page/settings"
"github.com/crypto-power/cryptopower/ui/values"
)

Expand All @@ -27,7 +26,6 @@ type DEXPage struct {

*load.Load

switchToTestnetBtn cryptomaterial.Button
openTradeMainPage *cryptomaterial.Clickable
splashPageInfoButton cryptomaterial.IconButton
splashPageContainer *widget.List
Expand All @@ -47,9 +45,8 @@ func NewDEXPage(l *load.Load) *DEXPage {
Alignment: layout.Middle,
Axis: layout.Vertical,
}},
showSplashPage: true,
switchToTestnetBtn: l.Theme.Button(values.String(values.StrSwitchToTestnet)),
materialLoader: material.Loader(l.Theme.Base),
showSplashPage: true,
materialLoader: material.Loader(l.Theme.Base),
}

if dp.AssetsManager.DEXCInitialized() && dp.AssetsManager.DexClient().InitializedWithPassword() {
Expand Down Expand Up @@ -117,8 +114,7 @@ func (pg *DEXPage) prepareInitialPage() {
// eventually drawn on screen.
// Part of the load.Page interface.
func (pg *DEXPage) Layout(gtx C) D {
isMainnet := pg.AssetsManager.NetType() == libutils.Mainnet
if !isMainnet && (!pg.AssetsManager.DEXCInitialized() || pg.CurrentPage() == nil) { // dexc must have been reset.
if !pg.AssetsManager.DEXCInitialized() || pg.CurrentPage() == nil { // dexc must have been reset.
pg.showSplashPage = true
if !pg.dexIsLoading {
pg.ParentNavigator().CloseAllPages()
Expand All @@ -132,19 +128,8 @@ func (pg *DEXPage) Layout(gtx C) D {
})
}

var msg string
var actionBtn *cryptomaterial.Button
if isMainnet {
if pg.CanChangeNetworkType() {
actionBtn = &pg.switchToTestnetBtn
}
msg = values.String(values.StrDexMainnetNotReady)
} else if hasMultipleWallets := pg.isMultipleAssetTypeWalletAvailable(); !hasMultipleWallets {
msg = values.String(values.StrMultipleAssetRequiredMsg)
}

if msg != "" {
return components.DisablePageWithOverlay(pg.Load, nil, gtx, msg, "", actionBtn)
if hasMultipleWallets := pg.isMultipleAssetTypeWalletAvailable(); !hasMultipleWallets {
return components.DisablePageWithOverlay(pg.Load, nil, gtx, values.String(values.StrMultipleAssetRequiredMsg), "", nil)
}

return pg.CurrentPage().Layout(gtx)
Expand All @@ -170,10 +155,6 @@ func (pg *DEXPage) isMultipleAssetTypeWalletAvailable() bool {
// page's UI components shortly before they are displayed.
// Part of the load.Page interface.
func (pg *DEXPage) HandleUserInteractions(gtx C) {
if pg.switchToTestnetBtn.Button.Clicked(gtx) {
settings.ChangeNetworkType(pg.Load, pg.ParentWindow(), string(libutils.Testnet))
}

if pg.CurrentPage() != nil {
pg.CurrentPage().HandleUserInteractions(gtx)
}
Expand Down
1 change: 0 additions & 1 deletion ui/values/localizable/en.go
Original file line number Diff line number Diff line change
Expand Up @@ -926,7 +926,6 @@ const EN = `
"destinationWallet" = "Destination Wallet"
"switchToMainnet" = "Switch to Mainnet"
"switchToTestnet" = "Switch to Testnet"
"dexMainnetNotReady" = "DCRDEX is currently in beta testing and has been disabled on mainnet to prevent potential loss of funds. Please switch to testnet to try it out."
"updateDEXWalletPasswordReason" = "Your %s wallet (%s) is connected to your DEX account. Please provide your DEX password to update DEX with the new wallet password."
"loginDEXForActiveOrdersOrExpiredBonds" = "You have one or more active orders and/or expired bonds waiting to be refunded, login to DEX now!"
"walletsNeedToSync" = "Wallet(s) need to sync"
Expand Down
1 change: 0 additions & 1 deletion ui/values/strings.go
Original file line number Diff line number Diff line change
Expand Up @@ -1035,7 +1035,6 @@ const (
StrDestinationWallet = "destinationWallet"
StrSwitchToMainnet = "switchToMainnet"
StrSwitchToTestnet = "switchToTestnet"
StrDexMainnetNotReady = "dexMainnetNotReady"
StrUpdateDEXWalletPasswordReason = "updateDEXWalletPasswordReason"
StrLoginDEXForActiveOrdersOrExpiredBonds = "loginDEXForActiveOrdersOrExpiredBonds"
StrWalletsNeedToSync = "walletsNeedToSync"
Expand Down

0 comments on commit 8fbda6e

Please sign in to comment.