Skip to content

Commit

Permalink
rebase changes and minor bug fixes
Browse files Browse the repository at this point in the history
Signed-off-by: Philemon Ukane <[email protected]>
  • Loading branch information
ukane-philemon committed Jan 26, 2024
1 parent 5e56a2f commit c9eefec
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 19 deletions.
6 changes: 3 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -229,9 +229,9 @@ replace github.com/lib/pq => github.com/lib/pq v1.10.4
// github.com/btcsuite/btcwallet.
replace github.com/btcsuite/btcwallet v0.16.10-0.20230706223227-037580c66b74 => github.com/btcsuite/btcwallet v0.16.9

// github.com/ukane-philemon/dcrdex v0.0.0-20240123003034-3f8508fea639 is the
// latest dcrdex master plus 2 commits that adds methods required by
// github.com/ukane-philemon/dcrdex v0.0.0-20240126135833-b75c189e80a9 is the
// latest dcrdex master plus commits that adds methods required by
// cryptopower. This should be updated when these PRs get merged.
// 1. core: add ActiveOrders method to Core: https://github.com/decred/dcrdex/pull/2680
// 1. core: Add ExpiredBonds method to Core: https://github.com/decred/dcrdex/pull/2679
replace decred.org/dcrdex v0.6.3 => github.com/ukane-philemon/dcrdex v0.0.0-20240123003034-3f8508fea639
replace decred.org/dcrdex v0.6.3 => github.com/ukane-philemon/dcrdex v0.0.0-20240126135833-b75c189e80a9
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1578,8 +1578,8 @@ github.com/ugorji/go v1.1.4/go.mod h1:uQMGLiO92mf5W77hV/PUCpI3pbzQx3CRekS0kk+RGr
github.com/ugorji/go v1.1.7/go.mod h1:kZn38zHttfInRq0xu/PH0az30d+z6vm202qpg1oXVMw=
github.com/ugorji/go/codec v0.0.0-20181204163529-d75b2dcb6bc8/go.mod h1:VFNgLljTbGfSG7qAOspJ7OScBnGdDN/yBr0sguwnwf0=
github.com/ugorji/go/codec v1.1.7/go.mod h1:Ax+UKWsSmolVDwsd+7N3ZtXu+yMGCf907BLYF3GoBXY=
github.com/ukane-philemon/dcrdex v0.0.0-20240123003034-3f8508fea639 h1:CWRRlD0T9X1DCkEXTMc2i+2I56qeydEkvYnoUethenw=
github.com/ukane-philemon/dcrdex v0.0.0-20240123003034-3f8508fea639/go.mod h1:2U+b4uDx4ZbAkk/pLaa2rv57G23XTyEe0Sw7Um+AdNE=
github.com/ukane-philemon/dcrdex v0.0.0-20240126135833-b75c189e80a9 h1:9k0cyp9qflL5PfHCTu8KMtjpBtpUEFu6vwAjZ8cd8mQ=
github.com/ukane-philemon/dcrdex v0.0.0-20240126135833-b75c189e80a9/go.mod h1:2U+b4uDx4ZbAkk/pLaa2rv57G23XTyEe0Sw7Um+AdNE=
github.com/ulikunitz/xz v0.5.6/go.mod h1:2bypXElzHzzJZwzH67Y6wb67pO62Rzfn7BSiF4ABRW8=
github.com/ulikunitz/xz v0.5.7/go.mod h1:nbz6k7qbPmH4IRqmfOplQw/tblSgqTqBwxkY0oWt/14=
github.com/ultraware/funlen v0.0.3/go.mod h1:Dp4UiAus7Wdb9KUZsYWZEWiRzGuM2kXM1lPbfaF6xhA=
Expand Down
2 changes: 1 addition & 1 deletion libwallet/assets_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -954,7 +954,7 @@ func (mgr *AssetsManager) InitializeDEX(ctx context.Context) {
mgr.dexcMtx.Unlock()

go func() {
<-mgr.dexc.WaitForShutdown()
<-dexClient.WaitForShutdown()
mgr.dexcMtx.Lock()
mgr.dexc = nil
mgr.dexcMtx.Unlock()
Expand Down
1 change: 1 addition & 0 deletions libwallet/dex_interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ type DEXClient interface {
ExportSeed(pw []byte) ([]byte, error)
SyncBook(dex string, base, quote uint32) (*orderbook.OrderBook, core.BookFeed, error)
Orders(filter *core.OrderFilter) ([]*core.Order, error)
ActiveOrders() (map[string][]*core.Order, map[string][]*core.InFlightOrder, error)
TradeAsync(pw []byte, form *core.TradeForm) (*core.InFlightOrder, error)
WalletState(assetID uint32) *core.WalletState
WalletSettings(assetID uint32) (map[string]string, error)
Expand Down
3 changes: 2 additions & 1 deletion ui/page/dcrdex/market.go
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,7 @@ func (pg *DEXMarketPage) OnNavigatedTo() {
}

if dexc.IsLoggedIn() {
go pg.refreshOrders()
return // All good, return early.
}

Expand Down Expand Up @@ -1254,7 +1255,7 @@ func (pg *DEXMarketPage) openOrdersAndHistory(gtx C) D {
return layout.Flex{Axis: horizontal, Spacing: layout.SpaceBetween, Alignment: layout.Middle}.Layout(gtx,
pg.orderColumn(false, fmt.Sprintf("%s %s", values.String(ord.Type.String()), values.String(orderReader.SideString())), columnWidth, index),
pg.orderColumn(false, ord.MarketID, columnWidth, index),
pg.orderColumn(false, components.TimeAgo(int64(ord.SubmitTime)), columnWidth, index),
pg.orderColumn(false, components.TimeAgo(int64(ord.SubmitTime/1000)), columnWidth, index),
pg.orderColumn(false, orderReader.RateString(), columnWidth, index),
pg.orderColumn(false, fmt.Sprintf("%s %s", orderReader.BaseQtyString(), strings.ToTitle(orderReader.BaseSymbol)), columnWidth, index),
pg.orderColumn(false, fmt.Sprintf("%s%%", orderReader.FilledPercent()), columnWidth, index),
Expand Down
26 changes: 15 additions & 11 deletions ui/page/root/home_page.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"sync/atomic"
"time"

dexdb "decred.org/dcrdex/client/db"
"gioui.org/io/key"
"gioui.org/layout"
"gioui.org/widget"
Expand Down Expand Up @@ -150,6 +151,7 @@ func (hp *HomePage) OnNavigatedTo() {
hp.ctx, hp.ctxCancel = context.WithCancel(context.TODO())

hp.initPageItems()
hp.initDEX()

go hp.CalculateAssetsUSDBalance()
if !hp.AssetsManager.DEXCInitialized() {
Expand All @@ -173,7 +175,7 @@ func (hp *HomePage) OnNavigatedTo() {

// initDEX initializes a new dex client if dex is not ready.
func (hp *HomePage) initDEX() {
if hp.AssetsManager.DexcInitialized() {
if hp.AssetsManager.DEXCInitialized() {
return // do nothing
}

Expand All @@ -194,16 +196,20 @@ func (hp *HomePage) initDEX() {
log.Errorf("dexClient.ActiveOrders error: %w", err)
}

expiredBonds := dexClient.ExpiredBonds()
if len(activeOrders) == 0 && len(expiredBonds) == 0 {
return // nothing to do.
var expiredBonds []*dexdb.Bond
xcs := dexClient.Exchanges()
for _, xc := range xcs {
if len(xc.Auth.ExpiredBonds) == 0 {
continue // nothing to do.
}

expiredBonds = append(expiredBonds, xc.Auth.ExpiredBonds...)
}

dexPassEditor := hp.Theme.EditorPassword(new(widget.Editor), values.String(values.StrDexPassword))
dexPassEditor.Editor.SingleLine, dexPassEditor.IsRequired = true, true

loginModal := modal.NewCustomModal(hp.Load).
Title(values.String(values.StrLoginWithDEXPassword)).
UseCustomWidget(func(gtx C) D {
return layout.Flex{Axis: layout.Vertical}.Layout(gtx,
layout.Rigid(func(gtx C) D {
Expand All @@ -228,15 +234,13 @@ func (hp *HomePage) initDEX() {
walletsToSyncMap := make(map[uint32]*struct{})
for _, orders := range activeOrders {
for _, ord := range orders {
walletsToSyncMap[ord.Base()] = &struct{}{}
walletsToSyncMap[ord.Quote()] = &struct{}{}
walletsToSyncMap[ord.BaseID] = &struct{}{}
walletsToSyncMap[ord.QuoteID] = &struct{}{}
}
}

for _, bonds := range expiredBonds {
for _, bond := range bonds {
walletsToSyncMap[bond.AssetID] = &struct{}{}
}
for _, bond := range expiredBonds {
walletsToSyncMap[bond.AssetID] = &struct{}{}
}

var walletsToSync []sharedW.Asset
Expand Down
2 changes: 1 addition & 1 deletion ui/values/localizable/en.go
Original file line number Diff line number Diff line change
Expand Up @@ -913,7 +913,7 @@ const EN = `
"availableBalance" = "Available Balance: %s"
"missingDEXWalletMsg" = "No %s trade wallet found. Please add %s wallet to the DEX client to trade."
"swapAndRedeemFee" = "swap - %s, redeem - %s"
"loginWithDEXPassword" = "Please login with your DEX password."
"loginWithDEXPassword" = "Login with your DEX password."
"login" = "Login"
"destinationWallet" = "Destination Wallet"
"switchToMainnet" = "Switch to Mainnet"
Expand Down

0 comments on commit c9eefec

Please sign in to comment.