Skip to content

Commit

Permalink
site: bond asset choice wording tweaks and settings page fixes
Browse files Browse the repository at this point in the history
This tweaks the wording on the bond asset selection form and adds the
"whatsabond" information text.

This also fixes a bug where the settings page was using the old registration fee
instead of the "bonds fee buffer".  It also fixes the condition for skipping the
wallet balance wait form created from the settings page.

---------

Co-authored-by: buck54321 <buck54321@gmail.com>
  • Loading branch information
chappjc and buck54321 committed Jun 19, 2023
1 parent 9908805 commit 29faa9b
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 22 deletions.
2 changes: 1 addition & 1 deletion client/webserver/locales/en-us.go
Expand Up @@ -186,7 +186,7 @@ var EnUS = map[string]string{
"Export Trades": "Export Trades",
"change the wallet type": "change the wallet type",
"confirmations": "confirmations",
"how_reg": "How will you post bond?",
"how_reg": "How will you create your bond?",
"All markets at": "All markets at",
"pick a different asset": "pick a different asset",
"Create": "Create",
Expand Down
4 changes: 3 additions & 1 deletion client/webserver/site/src/css/forms.scss
@@ -1,5 +1,7 @@
#regAssetForm {
position: relative;
#whatsabond {
max-width: 425px;
}

div.reg-asset-allmkts {
min-width: 210px;
Expand Down
4 changes: 2 additions & 2 deletions client/webserver/site/src/html/bodybuilder.tmpl
Expand Up @@ -9,7 +9,7 @@
<link rel="icon" href="/img/favicon.png?v=AK4XS4">
<meta name="description" content="Decred DEX Client Web Portal">
<title>{{.Title}}</title>
<link href="/css/style.css?v=rgcDpVd" rel="stylesheet">
<link href="/css/style.css?v=McgiIQS" rel="stylesheet">
</head>
<body {{if .UserInfo.DarkMode}} class="dark"{{end}}>
<div class="popup-notes" id="popupNotes">
Expand Down Expand Up @@ -104,7 +104,7 @@
{{end}}

{{define "bottom"}}
<script src="/js/entry.js?v=HcbEs4c"></script>
<script src="/js/entry.js?v=McgiIQS"></script>
</body>
</html>
{{end}}
4 changes: 4 additions & 0 deletions client/webserver/site/src/html/forms.tmpl
Expand Up @@ -218,6 +218,10 @@

{{define "regAssetForm"}}
<div class="text-center sans-light fs24 mb-3" data-tmpl="how">[[[how_reg]]]</div>
<div id="whatsabond" class="mt-1 fs14">
<span class="ico-info"></span>
<span class="ms-1">[[[whatsabond]]]</span>
</div>
<div data-tmpl="assets">
<div data-tmpl="assetTmpl" class="reg-asset pointer d-flex align-items-stretch">
<div class="reg-asset-logo-wrapper d-flex align-items-center justify-content-center">
Expand Down
6 changes: 3 additions & 3 deletions client/webserver/site/src/js/register.ts
Expand Up @@ -94,7 +94,7 @@ export default class RegistrationPage extends BasePage {
if (wallet) {
const bondAsset = this.currentDEX.bondAssets[asset.symbol]
const bondsFeeBuffer = await this.getBondsFeeBuffer(assetID, page.regAssetForm)
if (wallet.synced && wallet.balance.available > 2 * bondAsset.amount + bondsFeeBuffer) {
if (wallet.synced && wallet.balance.available >= 2 * bondAsset.amount + bondsFeeBuffer) {
this.animateConfirmForm(page.regAssetForm)
return
}
Expand Down Expand Up @@ -165,7 +165,7 @@ export default class RegistrationPage extends BasePage {
Doc.show(this.page.confirmRegForm)
}

// Retrieve an estimate for the tx fee needed to pay the registration fee.
// Retrieve an estimate for the tx fee needed to create new bond reserves.
async getBondsFeeBuffer (assetID: number, form: HTMLElement) {
const loaded = app().loading(form)
const res = await postJSON('/api/bondsfeebuffer', { assetID })
Expand Down Expand Up @@ -248,7 +248,7 @@ export default class RegistrationPage extends BasePage {
const bondAmt = this.currentDEX.bondAssets[asset.symbol].amount

const bondsFeeBuffer = await this.getBondsFeeBuffer(assetID, page.newWalletForm)
if (wallet.synced && wallet.balance.available > 2 * bondAmt + bondsFeeBuffer) {
if (wallet.synced && wallet.balance.available >= 2 * bondAmt + bondsFeeBuffer) {
await this.animateConfirmForm(page.newWalletForm)
return
}
Expand Down
25 changes: 10 additions & 15 deletions client/webserver/site/src/js/settings.ts
Expand Up @@ -80,12 +80,12 @@ export default class SettingsPage extends BasePage {
const wallet = asset.wallet
if (wallet) {
const bondAsset = this.currentDEX.bondAssets[asset.symbol]
if (wallet.synced && wallet.balance.available > bondAsset.amount) {
const bondsFeeBuffer = await this.getBondsFeeBuffer(assetID, page.regAssetForm)
if (wallet.synced && wallet.balance.available >= 2 * bondAsset.amount + bondsFeeBuffer) {
this.animateConfirmForm(page.regAssetForm)
return
}
const txFee = await this.getRegistrationTxFeeEstimate(assetID, page.regAssetForm)
this.walletWaitForm.setWallet(wallet, txFee)
this.walletWaitForm.setWallet(wallet, bondsFeeBuffer)
this.currentForm = page.walletWait
forms.slideSwap(page.regAssetForm, page.walletWait)
return
Expand Down Expand Up @@ -159,20 +159,15 @@ export default class SettingsPage extends BasePage {
})
}

// Retrieve an estimate for the tx fee needed to pay the registration fee.
async getRegistrationTxFeeEstimate (assetID: number, form: HTMLElement) {
const cert = await this.getCertFile()
// Retrieve an estimate for the tx fee needed to create new bond reserves.
async getBondsFeeBuffer (assetID: number, form: HTMLElement) {
const loaded = app().loading(form)
const res = await postJSON('/api/regtxfee', {
addr: this.currentDEX.host,
cert: cert,
asset: assetID
})
const res = await postJSON('/api/bondsfeebuffer', { assetID })
loaded()
if (!app().checkResponse(res)) {
return 0
}
return res.txfee
return res.feeBuffer
}

async newWalletCreated (assetID: number) {
Expand All @@ -183,13 +178,13 @@ export default class SettingsPage extends BasePage {
const wallet = asset.wallet
const bondAmt = this.currentDEX.bondAssets[asset.symbol].amount

if (wallet.synced && wallet.balance.available > bondAmt) {
const bondsFeeBuffer = await this.getBondsFeeBuffer(assetID, page.newWalletForm)
if (wallet.synced && wallet.balance.available >= 2 * bondAmt + bondsFeeBuffer) {
await this.animateConfirmForm(page.newWalletForm)
return
}

const txFee = await this.getRegistrationTxFeeEstimate(assetID, page.newWalletForm)
this.walletWaitForm.setWallet(wallet, txFee)
this.walletWaitForm.setWallet(wallet, bondsFeeBuffer)
this.currentForm = page.walletWait
await forms.slideSwap(page.newWalletForm, page.walletWait)
}
Expand Down

0 comments on commit 29faa9b

Please sign in to comment.