Skip to content

Commit

Permalink
Fix build Linux errors
Browse files Browse the repository at this point in the history
- Remove dialog module to select cert file, use Editor to input cert string instead
  • Loading branch information
song50119 committed Sep 21, 2021
1 parent c3bc587 commit 90a8435
Show file tree
Hide file tree
Showing 9 changed files with 55 additions and 53 deletions.
2 changes: 1 addition & 1 deletion dexc/dexc.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ func (d *Dexc) ConnectDexes(host string, password []byte) {

func (d *Dexc) connectDex(host string, password []byte) (*dexConnection, error) {
ctx := d.ctx
acct, err := d.Core.AccountExport([]byte(password), host)
acct, err := d.Core.AccountExport(password, host)
if err != nil {
return nil, err
}
Expand Down
1 change: 0 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ require (
github.com/onsi/ginkgo v1.14.0
github.com/onsi/gomega v1.10.1
github.com/planetdecred/dcrlibwallet v1.6.1-rc1.0.20210915175038-31878a61e002
github.com/sqweek/dialog v0.0.0-20210702151303-c326b49d3f01
github.com/yeqown/go-qrcode v1.5.1
golang.org/x/exp v0.0.0-20200331195152-e8c3332aa8e5
golang.org/x/image v0.0.0-20210220032944-ac19c3e999fb
Expand Down
4 changes: 0 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,6 @@ github.com/Sereal/Sereal v0.0.0-20181211220259-509a78ddbda3 h1:Xu7z47ZiE/J+sKXHZ
github.com/Sereal/Sereal v0.0.0-20181211220259-509a78ddbda3/go.mod h1:D0JMgToj/WdxCgd30Kc1UcA9E+WdZoJqeVOuYW7iTBM=
github.com/Shopify/sarama v1.19.0/go.mod h1:FVkBWblsNy7DGZRfXLU0O9RCGt5g3g3yEuWXgklEdEo=
github.com/Shopify/toxiproxy v2.1.4+incompatible/go.mod h1:OXgGpZ6Cli1/URJOF1DMxUHB2q5Ap20/P/eIdh4G0pI=
github.com/TheTitanrain/w32 v0.0.0-20180517000239-4f5cfb03fabf h1:FPsprx82rdrX2jiKyS17BH6IrTmUBYqZa/CXT4uvb+I=
github.com/TheTitanrain/w32 v0.0.0-20180517000239-4f5cfb03fabf/go.mod h1:peYoMncQljjNS6tZwI9WVyQB3qZS6u79/N3mBOcnd3I=
github.com/VividCortex/gohistogram v1.0.0/go.mod h1:Pf5mBqqDxYaXu3hDrrU+w6nw50o/4+TcAqDqk/vUH7g=
github.com/aead/siphash v0.0.0-20170329201724-e404fcfc8885/go.mod h1:Nywa3cDsYNNK3gaciGTWPwHt0wlpNV15vwmswBAUSII=
github.com/aead/siphash v1.0.1/go.mod h1:Nywa3cDsYNNK3gaciGTWPwHt0wlpNV15vwmswBAUSII=
Expand Down Expand Up @@ -811,8 +809,6 @@ github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnIn
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
github.com/spf13/viper v1.3.2/go.mod h1:ZiWeW+zYFKm7srdB9IoDzzZXaJaI5eL9QjNiN/DMA2s=
github.com/spf13/viper v1.7.0/go.mod h1:8WkrPz2fc9jxqZNCJI/76HCieCp4Q8HaLFoCha5qpdg=
github.com/sqweek/dialog v0.0.0-20210702151303-c326b49d3f01 h1:Ga2cbyk0hGMDSycM4gho27fQQAJvmhfTwkCac5FXQgU=
github.com/sqweek/dialog v0.0.0-20210702151303-c326b49d3f01/go.mod h1:/qNPSY91qTz/8TgHEMioAUc6q7+3SOybeKczHMXFcXw=
github.com/streadway/amqp v0.0.0-20190404075320-75d898a42a94/go.mod h1:AZpEONHx3DKn8O/DFsRAY58/XVQiIPMTMB1SddzLXVw=
github.com/streadway/amqp v0.0.0-20190827072141-edfb9018d271/go.mod h1:AZpEONHx3DKn8O/DFsRAY58/XVQiIPMTMB1SddzLXVw=
github.com/streadway/handy v0.0.0-20190108123426-d5acb3125c2a/go.mod h1:qNTQ5P5JnDBl6z3cMAg/SywNDC5ABu5ApDIw6lUbRmI=
Expand Down
11 changes: 6 additions & 5 deletions ui/load/load.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ type Icons struct {
TicketRevokedIcon,
TicketUnminedIcon *decredmaterial.Image

dexLogo, BTC, DCR, LTC, BCH *decredmaterial.Image
DexLogo, BTC, DCR, LTC, BCH *decredmaterial.Image
}

type Load struct {
Expand Down Expand Up @@ -225,10 +225,11 @@ func loadIcons() Icons {
DecredSymbolIcon: decredmaterial.NewImage(decredIcons["decred_symbol"]),
DecredSymbol2: decredmaterial.NewImage(decredIcons["ic_decred02"]),

BTC: decredmaterial.NewImage(decredIcons["dex_btc"]),
DCR: decredmaterial.NewImage(decredIcons["dex_dcr"]),
BCH: decredmaterial.NewImage(decredIcons["dex_bch"]),
LTC: decredmaterial.NewImage(decredIcons["dex_ltc"]),
DexLogo: decredmaterial.NewImage(decredIcons["dex_logo"]),
BTC: decredmaterial.NewImage(decredIcons["dex_btc"]),
DCR: decredmaterial.NewImage(decredIcons["dex_dcr"]),
BCH: decredmaterial.NewImage(decredIcons["dex_bch"]),
LTC: decredmaterial.NewImage(decredIcons["dex_ltc"]),
}
return ic
}
41 changes: 11 additions & 30 deletions ui/page/dexclient/add_dex_modal.go
Original file line number Diff line number Diff line change
@@ -1,27 +1,24 @@
package dexclient

import (
"io/ioutil"

"decred.org/dcrdex/client/core"
"gioui.org/layout"
"gioui.org/widget"
"github.com/planetdecred/godcr/ui/decredmaterial"
"github.com/planetdecred/godcr/ui/load"
"github.com/planetdecred/godcr/ui/values"
"github.com/sqweek/dialog"
)

const addDexModalID = "add_dex_modal"

type addDexModal struct {
*load.Load
modal *decredmaterial.Modal
addDexServer, addCertFile decredmaterial.Button
dexServerAddress decredmaterial.Editor
isSending bool
cert []byte
created func([]byte, *core.Exchange)
modal *decredmaterial.Modal
addDexServer decredmaterial.Button
dexServerAddress decredmaterial.Editor
isSending bool
cert decredmaterial.Editor
created func([]byte, *core.Exchange)
}

func newAddDexModal(l *load.Load) *addDexModal {
Expand All @@ -30,7 +27,7 @@ func newAddDexModal(l *load.Load) *addDexModal {
modal: l.Theme.ModalFloatTitle(),
dexServerAddress: l.Theme.Editor(new(widget.Editor), "DEX Address"),
addDexServer: l.Theme.Button(new(widget.Clickable), "Submit"),
addCertFile: l.Theme.Button(new(widget.Clickable), "Add a file"),
cert: l.Theme.Editor(new(widget.Editor), "Cert content"),
}

md.addDexServer.TextSize = values.TextSize12
Expand Down Expand Up @@ -68,35 +65,19 @@ func (md *addDexModal) Handle() {

md.isSending = true
go func() {
ce, err := md.DL.GetDEXConfig(md.dexServerAddress.Editor.Text(), md.cert)
c := []byte(md.cert.Editor.Text())
ce, err := md.DL.GetDEXConfig(md.dexServerAddress.Editor.Text(), c)
md.isSending = false
if err != nil {
md.Toast.NotifyError(err.Error())
return
}

md.created(md.cert, ce)
md.created(c, ce)
md.Dismiss()
}()
}

if md.addCertFile.Button.Clicked() {
go func() {
filename, err := dialog.File().Filter("Select TLS Certificate", "cert").Load()

if err != nil {
md.Toast.NotifyError(err.Error())
return
}

content, err := ioutil.ReadFile(filename)
if err != nil {
md.Toast.NotifyError(err.Error())
return
}
md.cert = content
}()
}
}

func (md *addDexModal) Layout(gtx layout.Context) D {
Expand All @@ -113,7 +94,7 @@ func (md *addDexModal) Layout(gtx layout.Context) D {
}),
layout.Rigid(func(gtx C) D {
return layout.Inset{Top: values.MarginPadding15}.Layout(gtx, func(gtx C) D {
return md.addCertFile.Layout(gtx)
return md.cert.Layout(gtx)
})
}),
)
Expand Down
10 changes: 5 additions & 5 deletions ui/page/dexclient/listeners.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,23 +28,21 @@ func (pg *Page) listenerMessages() {
select {
case msg, ok := <-msgs:
if !ok {
fmt.Errorf("listen(wc): Connection terminated for %wsc.", "test")
fmt.Println("[ERROR] Listen(wc): Connection terminated for.", "test")
return
}
switch msg.Type {
case msgjson.Request:
fmt.Sprintf(">>>>>>>>>>>>>>>>>>>>> Message source Request: %s ", msg)
case msgjson.Notification:
pg.noteHandlers(msg)
case msgjson.Response:
// client/comms.wsConn handles responses to requests we sent.
fmt.Sprintf("A response was received in the message queue: %s", msg)
continue
default:
fmt.Sprintf("Invalid message type %d from MessageSource", msg.Type)
continue
}

case <-pg.ctx.Done():
return
}
}
}
Expand All @@ -56,6 +54,8 @@ func (pg *Page) readNotifications() {
select {
case n := <-ch:
fmt.Println("Recv notification", n)
case <-pg.ctx.Done():
return
}
}
}
Expand Down
31 changes: 27 additions & 4 deletions ui/page/dexclient/markets.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package dexclient

import (
"context"

"decred.org/dcrdex/client/core"
"gioui.org/layout"
"gioui.org/widget"
Expand Down Expand Up @@ -31,6 +33,8 @@ type selectedMaket struct {

type Page struct {
*load.Load
ctx context.Context // page context
ctxCancel context.CancelFunc
user *core.User
miniTradeFormWdg *miniTradeFormWidget
initializeModal bool
Expand Down Expand Up @@ -69,12 +73,34 @@ func (pg *Page) ID() string {
}

func (pg *Page) OnResume() {
pg.ctx, pg.ctxCancel = context.WithCancel(context.TODO())
pg.refreshUser()

if pg.user.Initialized && pg.DL.IsLoggedIn {
go pg.listenerMessages()
go pg.readNotifications()
pg.updateOrderBook()
}
}

func (pg *Page) Layout(gtx C) D {
dims := components.UniformPadding(gtx, func(gtx C) D {
return layout.Flex{Axis: layout.Vertical}.Layout(gtx,
layout.Rigid(func(gtx C) D {
return layout.Flex{Axis: layout.Vertical, Alignment: layout.Middle}.Layout(gtx,
layout.Rigid(func(gtx C) D {
return pg.Theme.Label(values.TextSize14, "Waiting for confirmations...").Layout(gtx)
}),
layout.Rigid(func(gtx C) D {
t := "In order to trade at 127.0.0.1:7232, the registration fee payment needs 4 confirmations."
return pg.Theme.Label(values.TextSize14, t).Layout(gtx)
}),
layout.Rigid(func(gtx C) D {
t := "1/4"
return pg.Theme.Label(values.TextSize14, t).Layout(gtx)
}),
)
}),
layout.Rigid(func(gtx C) D {
return pg.pageSections(gtx, func(gtx C) D {
return layout.Inset{
Expand Down Expand Up @@ -134,6 +160,7 @@ func (pg *Page) Handle() {

func (pg *Page) OnClose() {
pg.initializeModal = false
pg.ctxCancel()
}

func (pg *Page) handleModals() {
Expand Down Expand Up @@ -207,8 +234,4 @@ func (pg *Page) handleModals() {
func (pg *Page) refreshUser() {
pg.user = pg.DL.Core.User()
pg.initializeModal = false

if pg.user.Initialized && pg.DL.IsLoggedIn {
pg.updateOrderBook()
}
}
4 changes: 3 additions & 1 deletion ui/page/dexclient/mini_trade_form.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,10 @@ func (miniTradeFormWdg *miniTradeFormWidget) handle() {

ord := miniTradeFormWdg.orderBook
if ord != nil {
var rate float64 = 0
var rate float64

bitSize := 64

if miniTradeFormWdg.isSell {
_, rate = minMaxRateOrderBook(ord.Buys)
} else {
Expand Down
4 changes: 2 additions & 2 deletions ui/page/main_page.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,8 @@ func (mp *MainPage) initNavItems() {
},
{
Clickable: new(widget.Clickable),
Image: mp.Icons.MoreIcon,
ImageInactive: mp.Icons.MoreIconInactive,
Image: mp.Icons.DexLogo,
ImageInactive: mp.Icons.DexLogo,
Title: values.String(values.StrDex),
PageID: dexclient.MarketPageID,
},
Expand Down

0 comments on commit 90a8435

Please sign in to comment.