Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

multi: Bug fixes #688

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 8 additions & 9 deletions ui/page/dcrdex/dex_onboarding_page.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import (
"github.com/crypto-power/cryptopower/ui/load"
"github.com/crypto-power/cryptopower/ui/modal"
"github.com/crypto-power/cryptopower/ui/page/components"
"github.com/crypto-power/cryptopower/ui/renderers"
"github.com/crypto-power/cryptopower/ui/utils"
"github.com/crypto-power/cryptopower/ui/values"
)
Expand Down Expand Up @@ -597,16 +596,16 @@ func (pg *DEXOnboarding) stepPostBond(gtx C) D {
return centerLayout(gtx, dp20, values.MarginPadding12, pg.Theme.H6(values.String(values.StrPostBond)).Layout)
}),
layout.Rigid(func(gtx C) D {
return centerLayout(gtx, 0, 0, pg.Theme.Body1(values.String(values.StrSelectBondWalletMsg)).Layout)
return centerLayout(gtx, 0, dp20, pg.Theme.Body1(values.String(values.StrSelectBondWalletMsg)).Layout)
}),
layout.Rigid(func(gtx C) D {
return layout.Inset{Bottom: values.MarginPadding16}.Layout(gtx, func(gtx C) D {
return pg.bondSourceWalletSelector.Layout(gtx, values.StrSupportedWallets)
return pg.bondSourceWalletSelector.Layout(gtx, values.String(values.StrSupportedWallets))
})
}),
layout.Rigid(func(gtx C) D {
return layout.Inset{Bottom: values.MarginPadding16}.Layout(gtx, func(gtx C) D {
return pg.bondSourceAccountSelector.Layout(gtx, values.StrAccount)
return pg.bondSourceAccountSelector.Layout(gtx, values.String(values.StrAccount))
})
}),
layout.Rigid(func(gtx C) D {
Expand All @@ -616,7 +615,7 @@ func (pg *DEXOnboarding) stepPostBond(gtx C) D {
return layout.S.Layout(gtx, pg.Theme.Body1(values.String(values.StrSelectBondStrengthMsg)).Layout)
}),
layout.Rigid(func(gtx C) D {
return centerLayout(gtx, dp20, dp16, renderers.RenderHTML(values.String(values.StrPostBondDesc), pg.Theme).Layout)
return layout.Inset{Top: dp20, Bottom: dp16}.Layout(gtx, pg.Theme.Body2(values.String(values.StrPostBondDesc)).Layout)
}),
layout.Rigid(func(gtx C) D {
return layout.Flex{Axis: layout.Vertical}.Layout(gtx,
Expand Down Expand Up @@ -767,7 +766,7 @@ func (pg *DEXOnboarding) stepWaitForBondConfirmation(gtx C) D {
return centerLayout(gtx, dp20, dp12, pg.Theme.H6(values.String(values.StrPostBond)).Layout)
}),
layout.Rigid(func(gtx C) D {
return centerLayout(gtx, 0, 0, renderers.RenderHTML(values.String(values.StrPostBondDesc), pg.Theme).Layout)
return centerLayout(gtx, 0, 0, pg.Theme.Body2(values.String(values.StrPostBondDesc)).Layout)
}),
layout.Rigid(func(gtx C) D {
return cryptomaterial.LinearLayout{
Expand Down Expand Up @@ -1051,8 +1050,6 @@ func (pg *DEXOnboarding) handleEditorEvents(gtx C) {
pg.isLoading = false
}()
}

pg.ParentWindow().Reload()
}
}

Expand Down Expand Up @@ -1198,7 +1195,7 @@ func (pg *DEXOnboarding) connectServerAndPrepareForBonding() {
Setup()
pg.bondSourceAccountSelector = components.NewAccountDropdown(pg.Load).
AccountValidator(func(a *sharedW.Account) bool {
return !a.IsWatchOnly && pg.validateBondWalletOrAccount(pg.bondSourceWalletSelector.SelectedWallet().GetAssetType(), dexc.WalletAccountNumberConfigKey, fmt.Sprint(a.AccountNumber))
return !a.IsWatchOnly && pg.validateBondWalletOrAccount(pg.bondSourceWalletSelector.SelectedWallet().GetAssetType(), dexc.WalletAccountNumberConfigKey, fmt.Sprint(a.AccountNumber)) && !utils.IsImportedAccount(pg.bondSourceWalletSelector.SelectedWallet().GetAssetType(), a)
}).
SetChangedCallback(func(_ *sharedW.Account) {
pg.bondAccountHasEnough()
Expand Down Expand Up @@ -1269,6 +1266,8 @@ func (pg *DEXOnboarding) postBond() {
}

pg.isLoading = true
pg.ParentWindow().Reload()

walletID, err := dexClient.WalletIDForAsset(bondAsset.ID)
if err != nil {
pg.notifyError(err.Error())
Expand Down
14 changes: 11 additions & 3 deletions ui/page/dcrdex/market.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import (
"github.com/crypto-power/cryptopower/ui/load"
"github.com/crypto-power/cryptopower/ui/modal"
"github.com/crypto-power/cryptopower/ui/page/components"
"github.com/crypto-power/cryptopower/ui/utils"
pageutils "github.com/crypto-power/cryptopower/ui/utils"
"github.com/crypto-power/cryptopower/ui/values"
)
Expand Down Expand Up @@ -1618,7 +1619,14 @@ func (pg *DEXMarketPage) HandleUserInteractions(gtx C) {
}

_, err = dexc.Trade([]byte(password), orderForm)
return err == nil
if err != nil {
return false
}

// Clear the trade form to allow for another trade entry
pg.refreshOrderForm()

return true
})

dexPasswordModal.SetPasswordTitleVisibility(false)
Expand Down Expand Up @@ -1706,7 +1714,7 @@ func (pg *DEXMarketPage) showSelectDEXWalletModal(missingWallet libutils.AssetTy

pg.accountSelector = components.NewAccountDropdown(pg.Load).
AccountValidator(func(a *sharedW.Account) bool {
return !a.IsWatchOnly
return !a.IsWatchOnly && !utils.IsImportedAccount(pg.walletSelector.SelectedWallet().GetAssetType(), a)
}).
Setup(pg.walletSelector.SelectedWallet())

Expand Down Expand Up @@ -1760,7 +1768,7 @@ func (pg *DEXMarketPage) showSelectDEXWalletModal(missingWallet libutils.AssetTy
}),
layout.Rigid(func(gtx C) D {
return layout.Inset{Bottom: dp2}.Layout(gtx, func(gtx C) D {
return pg.accountSelector.Layout(gtx, values.StrSelectAcc)
return pg.accountSelector.Layout(gtx, values.String(values.StrSelectAcc))
})
}),
)
Expand Down
3 changes: 2 additions & 1 deletion ui/page/privacy/manual_mixer_setup_page.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"github.com/crypto-power/cryptopower/ui/load"
"github.com/crypto-power/cryptopower/ui/modal"
"github.com/crypto-power/cryptopower/ui/page/components"
"github.com/crypto-power/cryptopower/ui/utils"
"github.com/crypto-power/cryptopower/ui/values"
)

Expand Down Expand Up @@ -90,7 +91,7 @@ func NewManualMixerSetupPage(l *load.Load, dcrWallet *dcr.Asset) *ManualMixerSet
}

// Imported, watch only and default wallet accounts are invalid to use as an unmixed account
accountIsValid := account.Number != load.MaxInt32 && !wal.IsWatchingOnlyWallet() && account.Number != dcr.DefaultAccountNum
accountIsValid := account.Number != load.MaxInt32 && !wal.IsWatchingOnlyWallet() && account.Number != dcr.DefaultAccountNum && !utils.IsImportedAccount(dcrWallet.GetAssetType(), account)

// Account is invalid if already selected by mixed account selector.
if !accountIsValid || account.Number == mixedAccNo {
Expand Down
16 changes: 5 additions & 11 deletions ui/page/settings/statistics_page.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,12 @@ import (
"gioui.org/widget"

"github.com/crypto-power/cryptopower/app"
"github.com/crypto-power/cryptopower/libwallet/assets/btc"
"github.com/crypto-power/cryptopower/libwallet/assets/dcr"
sharedW "github.com/crypto-power/cryptopower/libwallet/assets/wallet"
libutils "github.com/crypto-power/cryptopower/libwallet/utils"
"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/utils"
pageutils "github.com/crypto-power/cryptopower/ui/utils"
"github.com/crypto-power/cryptopower/ui/values"
)
Expand Down Expand Up @@ -75,18 +74,13 @@ func (pg *StatPage) OnNavigatedTo() {
log.Errorf("Error getting wallet accounts: %s", err.Error())
} else {
// Filter imported account.
accounts := make([]*sharedW.Account, 0)
filteredAccounts := make([]*sharedW.Account, 0)
for _, v := range acc.Accounts {
if pg.wallet.GetAssetType() == libutils.BTCWalletAsset && v.AccountNumber != btc.ImportedAccountNumber {
accounts = append(accounts, v)
if !utils.IsImportedAccount(pg.wallet.GetAssetType(), v) {
filteredAccounts = append(filteredAccounts, v)
}

if pg.wallet.GetAssetType() == libutils.DCRWalletAsset && v.Number != dcr.ImportedAccountNumber {
accounts = append(accounts, v)
}

}
acc.Accounts = accounts
acc.Accounts = filteredAccounts
pg.accounts = acc
}

Expand Down
11 changes: 5 additions & 6 deletions ui/page/wallet/wallet_settings_page.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,13 +147,12 @@ func (pg *SettingsPage) loadWalletAccount() {
}

for _, acct := range accounts.Accounts {
if acct.Number == dcr.ImportedAccountNumber {
continue
if !utils.IsImportedAccount(pg.wallet.GetAssetType(), acct) {
walletAccounts = append(walletAccounts, &accountData{
Account: acct,
clickable: pg.Theme.NewClickable(false),
})
}
walletAccounts = append(walletAccounts, &accountData{
Account: acct,
clickable: pg.Theme.NewClickable(false),
})
}

pg.accounts = walletAccounts
Expand Down
17 changes: 17 additions & 0 deletions ui/utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@ import (
"strings"

"decred.org/dcrdex/dex/encode"
"github.com/crypto-power/cryptopower/libwallet/assets/btc"
"github.com/crypto-power/cryptopower/libwallet/assets/dcr"
sharedW "github.com/crypto-power/cryptopower/libwallet/assets/wallet"
"github.com/crypto-power/cryptopower/libwallet/utils"
libutils "github.com/crypto-power/cryptopower/libwallet/utils"
"github.com/crypto-power/cryptopower/ui/cryptomaterial"
"github.com/crypto-power/cryptopower/ui/values"

Expand Down Expand Up @@ -164,3 +168,16 @@ func USDMarketFromAsset(asset utils.AssetType) (values.Market, error) {
return values.UnknownMarket, fmt.Errorf("unsupported asset type: %s", asset)
}
}

func IsImportedAccount(assetType libutils.AssetType, acc *sharedW.Account) bool {
switch assetType {
case libutils.BTCWalletAsset:
return acc.AccountNumber == btc.ImportedAccountNumber

case libutils.DCRWalletAsset:
return acc.Number == dcr.ImportedAccountNumber

default:
return false
}
}
2 changes: 1 addition & 1 deletion ui/values/localizable/en.go
Original file line number Diff line number Diff line change
Expand Up @@ -812,7 +812,7 @@ const EN = `
"refreshState" = "Refreshing..."
"24hChange" = "24h Change"
"back" = "Back"
"postBondDesc" = "<p> Posting bonds help you increase your trading account Tier. In order to trade, you need to have a <b> minimum of 1 Tier</b>. </p>"
"postBondDesc" = "Posting bonds help you increase your trading account Tier. In order to trade, you need to have a minimum of 1 Tier."
"selectBondWalletMsg" = "Select the wallet and account you would like to post bond from."
"supportedWallets" = "Supported Wallets"
"selectBondStrengthMsg" = "Select the bond strength of your choice."
Expand Down
Loading