Skip to content

Commit 4a97a53

Browse files
committed
app: Update UI to support bond updaters
The transaction details popup now shows change and replaced bonds. Also in many placed the bond amount was multiplied by two to handle the bond reserves requirement which bond updaters do not have, so this needed to be updated.
1 parent 36ec4f7 commit 4a97a53

11 files changed

Lines changed: 163 additions & 41 deletions

File tree

client/core/bond.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1771,15 +1771,16 @@ func (c *Core) makeAndPostBond(dc *dexConnection, acctExists bool, wallet *xcWal
17711771
coinIDString(bond.AssetID, bondCoinCast), bondCoinStr)
17721772
}
17731773

1774+
// Set up the coin waiter, which watches confirmations so the user knows
1775+
// when to expect their account to be marked paid by the server.
1776+
c.monitorBondConfs(dc, bond, reqConfs)
1777+
17741778
c.updateAssetBalance(bond.AssetID)
17751779

17761780
// Start waiting for reqConfs.
17771781
subject, details := c.formatDetails(TopicBondConfirming, reqConfs, makeCoinIDToken(bondCoinStr, bond.AssetID), unbip(bond.AssetID), dc.acct.host)
17781782
c.notify(newBondPostNoteWithConfirmations(TopicBondConfirming, subject,
17791783
details, db.Success, bond.AssetID, bondCoinStr, 0, dc.acct.host, c.exchangeAuth(dc)))
1780-
// Set up the coin waiter, which watches confirmations so the user knows
1781-
// when to expect their account to be marked paid by the server.
1782-
c.monitorBondConfs(dc, bond, reqConfs)
17831784

17841785
return bond.CoinID, nil
17851786
}

client/webserver/locales/en-us.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -524,6 +524,11 @@ var EnUS = map[string]string{
524524
"fee": "Fee",
525525
"tx_id": "Transaction ID",
526526
"bond_id": "Bond ID",
527+
"change_bond_id": "Change Bond ID",
528+
"value": "Value",
529+
"replaced_bonds": "Replaced Bonds",
530+
"change_bond_tooltip": `The new bond required is smaller than the combined value of the replaced bonds, so a change bond that can be refunded sooner is created.`,
531+
"replaced_bonds_tooptip": "This asset allows existing bonds to fund new bonds without having to be refunded first.",
527532
"locktime": "Lock Time",
528533
"recipient": "Recipient",
529534
"block": "Block",

client/webserver/site/src/css/wallets.scss

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,11 @@
370370
transition: color 1s ease;
371371
}
372372

373-
#txDetailsBondSection, #txDetailsRecipientSection, #txDetailsNonceSection {
373+
#txDetailsBondSection,
374+
#txDetailsRecipientSection,
375+
#txDetailsNonceSection,
376+
#txDetailsChangeBondSection,
377+
#txDetailsReplacedBondsSection {
374378
margin-top: 10px;
375379
padding-top: 10px;
376380
border-top: 1px solid #777;

client/webserver/site/src/html/wallets.tmpl

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1011,19 +1011,47 @@
10111011
<div><span id="txDetailsRecipient" class="ease-color"></span><span id="copyRecipientBtn" class="copy-btn ico-copy mx-2 fs18 ease-color"></span></div>
10121012
</span>
10131013
<div id="txDetailsBondSection" class="w-100">
1014+
<span id="txDetailsBondAccountIDSection" class="d-flex justify-content-between w-100">
1015+
<span>[[[Account ID]]]</span>
1016+
<div><span id="txDetailsBondAccountID" class="ease-color"></span><span id="copyBondAccountIDBtn" class="copy-btn ico-copy mx-2 fs18 ease-color"></span></div>
1017+
</span>
10141018
<span class="d-flex justify-content-between w-100">
10151019
<span>[[[bond_id]]]</span>
10161020
<div><span id="txDetailsBondID" class="ease-color"></span><span id="copyBondIDBtn" class="copy-btn ico-copy mx-2 fs18 ease-color"></span></div>
10171021
</span>
1022+
<span class="d-flex justify-content-between w-100">
1023+
<span>[[[value]]]</span>
1024+
<div><span id="txDetailsBondValue" class="ease-color"></span></div>
1025+
</span>
10181026
<span class="d-flex justify-content-between w-100">
10191027
<span>[[[locktime]]]</span>
10201028
<span id="txDetailsBondLocktime" class="ease-color"></span>
10211029
</span>
1022-
<span id="txDetailsBondAccountIDSection" class="d-flex justify-content-between w-100">
1023-
<span>[[[Account ID]]]</span>
1024-
<div><span id="txDetailsBondAccountID" class="ease-color"></span><span id="copyBondAccountIDBtn" class="copy-btn ico-copy mx-2 fs18 ease-color"></span></div>
1030+
</div>
1031+
<div id="txDetailsChangeBondSection" class="w-100">
1032+
<span class="d-flex justify-content-between w-100">
1033+
<span>[[[change_bond_id]]] <span class="ico-info fs12 me-1" data-tooltip="[[[change_bond_tooltip]]]"></span></span>
1034+
<div><span id="txDetailsChangeBondID" class="ease-color"></span><span id="copyChangeBondIDBtn" class="copy-btn ico-copy mx-2 fs18 ease-color"></span></div>
1035+
</span>
1036+
<span class="d-flex justify-content-between w-100">
1037+
<span>[[[value]]]</span>
1038+
<div><span id="txDetailsChangeBondValue" class="ease-color"></span></div>
1039+
</span>
1040+
<span class="d-flex justify-content-between w-100">
1041+
<span>[[[locktime]]]</span>
1042+
<span id="txDetailsChangeBondLocktime" class="ease-color"></span>
10251043
</span>
10261044
</div>
1045+
<div id="txDetailsReplacedBondsSection" class="w-100">
1046+
<span class="d-flex justify-content-between w-100">
1047+
<span>[[[replaced_bonds]]] <span class="ico-info fs12 me-1" data-tooltip="[[[replaced_bonds_tooptip]]]"></span></span><span><span>
1048+
</span>
1049+
<div id="replacedBonds">
1050+
<span id="replacedBondTmpl" class="d-flex justify-content-between w-100">
1051+
<span></span><span data-tmpl="info"></span>
1052+
</span>
1053+
</div>
1054+
</div>
10271055
<span id="txDetailsNonceSection" class="d-flex justify-content-between w-100">
10281056
<span>[[[nonce]]]</span><span id="txDetailsNonce"></span>
10291057
</span>

client/webserver/site/src/js/dexsettings.ts

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import State from './state'
44
import { postJSON } from './http'
55
import * as forms from './forms'
66
import * as intl from './locales'
7-
import { ReputationMeter, strongTier } from './account'
7+
import { ReputationMeter, strongTier, bondReserveMultiplier } from './account'
88
import {
99
app,
1010
PageElement,
@@ -13,6 +13,7 @@ import {
1313
PasswordCache,
1414
WalletState
1515
} from './registry'
16+
import { traitBondUpdater } from './wallets'
1617

1718
interface Animator {
1819
animate: (() => Promise<void>)
@@ -229,11 +230,21 @@ export default class DexSettingsPage extends BasePage {
229230
return
230231
}
231232
}
232-
if (wallet.synced && wallet.balance.available >= 2 * bondAsset.amount + fees) {
233-
// If we are raising our tier, we'll show a confirmation form
233+
234+
const isBondUpdater = (wallet.traits & traitBondUpdater) !== 0
235+
236+
let multiplier = bondReserveMultiplier
237+
if (isBondUpdater) multiplier = 1
238+
const walletFunded = wallet.balance.available >= multiplier * bondAsset.amount + fees
239+
240+
const loweringTier = this.confirmRegisterForm.tier < xc.auth.targetTier
241+
const stillSameUpdater = isBondUpdater && (xc.auth.bondAssetID === assetID)
242+
243+
if (wallet.synced && (walletFunded || loweringTier || stillSameUpdater)) {
234244
this.progressTierFormWithSyncedFundedWallet(assetID)
235245
return
236246
}
247+
237248
this.walletWaitForm.setWallet(assetID, fees, this.confirmRegisterForm.tier)
238249
this.showForm(page.walletWait)
239250
}
@@ -477,7 +488,9 @@ export default class DexSettingsPage extends BasePage {
477488
const bondsFeeBuffer = await this.getBondsFeeBuffer(assetID, page.newWalletForm)
478489
this.confirmRegisterForm.setFees(assetID, bondsFeeBuffer)
479490

480-
if (wallet.synced && wallet.balance.available >= 2 * bondAmt + bondsFeeBuffer) {
491+
let multiplier = bondReserveMultiplier
492+
if ((wallet.traits & traitBondUpdater) !== 0) multiplier = 1
493+
if (wallet.synced && wallet.balance.available >= multiplier * bondAmt + bondsFeeBuffer) {
481494
this.progressTierFormWithSyncedFundedWallet(assetID)
482495
return
483496
}

client/webserver/site/src/js/forms.ts

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ import {
3232
CoreNote
3333
} from './registry'
3434
import { XYRangeHandler } from './opts'
35+
import { traitNewAddresser, traitBondUpdater } from './wallets'
3536

3637
interface ConfigOptionInput extends HTMLInputElement {
3738
configOpt: ConfigOption
@@ -838,7 +839,9 @@ export class ConfirmRegistrationForm {
838839
const page = this.page
839840
const xc = this.xc
840841
const bondAsset = xc.bondAssets[asset.symbol]
841-
const bondLock = bondAsset.amount * tier * bondReserveMultiplier
842+
let multiplier = bondReserveMultiplier
843+
if (asset.wallet && (asset.wallet.traits & traitBondUpdater) !== 0) multiplier = 1
844+
const bondLock = bondAsset.amount * tier * multiplier
842845
const bondLockConventional = bondLock / conversionFactor
843846
page.tradingTier.textContent = String(tier)
844847
page.logo.src = Doc.logoPath(asset.symbol)
@@ -1109,7 +1112,9 @@ export class FeeAssetSelectionForm {
11091112
return
11101113
}
11111114
setReadyMessage(tmpl.ready, asset)
1112-
const bondLock = bondAsset.amount * bondReserveMultiplier * tier
1115+
let multiplier = bondReserveMultiplier
1116+
if (asset.wallet && (asset.wallet.traits & traitBondUpdater) !== 0) multiplier = 1
1117+
const bondLock = bondAsset.amount * multiplier * tier
11131118
const fee = Doc.formatCoinValue(bondLock, unitInfo)
11141119
tmpl.feeAmt.textContent = String(fee)
11151120
if (r) tmpl.fiatBondAmount.textContent = Doc.formatFiatConversion(bondLock, r, asset.unitInfo)
@@ -1290,7 +1295,9 @@ export class WalletWaitForm {
12901295
Doc.hide(page.syncUncheck, page.syncCheck, page.balUncheck, page.balCheck, page.syncRemainBox, page.bondCostBreakdown)
12911296
Doc.show(page.balanceBox)
12921297

1293-
let bondLock = 2 * bondAsset.amount * tier
1298+
let multiplier = bondReserveMultiplier
1299+
if ((asset.wallet.traits & traitBondUpdater) !== 0) multiplier = 1
1300+
let bondLock = multiplier * bondAsset.amount * tier
12941301
if (bondFeeBuffer > 0) {
12951302
Doc.show(page.bondCostBreakdown)
12961303
page.bondLockNoFees.textContent = Doc.formatCoinValue(bondLock, ui)
@@ -1321,7 +1328,7 @@ export class WalletWaitForm {
13211328
}
13221329

13231330
Doc.show(synced ? page.syncCheck : syncProgress >= 1 ? page.syncSpinner : page.syncUncheck)
1324-
Doc.show(bal.available >= 2 * bondAsset.amount + bondFeeBuffer ? page.balCheck : page.balUncheck)
1331+
Doc.show(bal.available >= multiplier * bondAsset.amount + bondFeeBuffer ? page.balCheck : page.balUncheck)
13251332

13261333
page.progress.textContent = (syncProgress * 100).toFixed(1)
13271334

@@ -1364,7 +1371,9 @@ export class WalletWaitForm {
13641371
// NOTE: when/if we allow one-time bond post (no maintenance) from the UI we
13651372
// may allow to proceed as long as they have enough for tx fees. For now,
13661373
// the balance check box will remain unchecked and we will not proceed.
1367-
if (avail < 2 * this.bondAsset.amount + this.bondFeeBuffer) return
1374+
let multiplier = bondReserveMultiplier
1375+
if ((asset.wallet.traits & traitBondUpdater) !== 0) multiplier = 1
1376+
if (avail < multiplier * this.bondAsset.amount + this.bondFeeBuffer) return
13681377

13691378
Doc.show(page.balCheck)
13701379
Doc.hide(page.balUncheck, page.balanceBox, page.sendEnough)
@@ -1968,8 +1977,6 @@ export class LoginForm {
19681977
}
19691978
}
19701979

1971-
const traitNewAddresser = 1 << 1
1972-
19731980
/*
19741981
* DepositAddress displays a deposit address, a QR code, and a button to
19751982
* generate a new address (if supported).

client/webserver/site/src/js/locales.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,7 @@ export const ID_TX_TYPE_REVOKE_TOKEN_APPROVAL = 'TX_TYPE_REVOKE_TOKEN_APPROVAL'
174174
export const ID_TX_TYPE_TICKET_PURCHASE = 'TX_TYPE_TICKET_PURCHASE'
175175
export const ID_TX_TYPE_TICKET_VOTE = 'TX_TYPE_TICKET_VOTE'
176176
export const ID_TX_TYPE_TICKET_REVOCATION = 'TX_TYPE_TICKET_REVOCATION'
177+
export const ID_TX_TYPE_UPDATE_BOND = 'TX_TYPE_UPDATE_BOND'
177178
export const ID_MISSING_CEX_CREDS = 'MISSING_CEX_CREDS'
178179
export const ID_MULTIPLIER = 'MULTIPLIER'
179180
export const ID_NO_PLACEMENTS = 'NO_PLACEMENTS'
@@ -360,6 +361,7 @@ export const enUS: Locale = {
360361
[ID_TX_TYPE_TICKET_PURCHASE]: 'Ticket purchase',
361362
[ID_TX_TYPE_TICKET_VOTE]: 'Ticket vote',
362363
[ID_TX_TYPE_TICKET_REVOCATION]: 'Ticket revocation',
364+
[ID_TX_TYPE_UPDATE_BOND]: 'Update bond',
363365
[ID_MISSING_CEX_CREDS]: 'specify both key and secret',
364366
[ID_MULTIPLIER]: 'Multiplier',
365367
[ID_NO_PLACEMENTS]: 'must specify 1 or more placements',

client/webserver/site/src/js/register.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ import {
1919
PageElement
2020
} from './registry'
2121
import State from './state'
22+
import { bondReserveMultiplier } from './account'
23+
import { traitBondUpdater } from './wallets'
2224

2325
export default class RegistrationPage extends BasePage {
2426
body: HTMLElement
@@ -101,7 +103,9 @@ export default class RegistrationPage extends BasePage {
101103
const bondAsset = this.currentDEX.bondAssets[asset.symbol]
102104
const bondsFeeBuffer = await this.getBondsFeeBuffer(assetID, page.regAssetForm)
103105
this.confirmRegisterForm.setAsset(assetID, tier, bondsFeeBuffer)
104-
if (wallet.synced && wallet.balance.available >= 2 * bondAsset.amount + bondsFeeBuffer) {
106+
let multiplier = bondReserveMultiplier
107+
if ((wallet.traits & traitBondUpdater) !== 0) multiplier = 1
108+
if (wallet.synced && wallet.balance.available >= multiplier * bondAsset.amount + bondsFeeBuffer) {
105109
this.animateConfirmForm(page.regAssetForm)
106110
return
107111
}
@@ -216,7 +220,9 @@ export default class RegistrationPage extends BasePage {
216220
const bondAmt = this.currentDEX.bondAssets[asset.symbol].amount
217221

218222
const bondsFeeBuffer = await this.getBondsFeeBuffer(assetID, page.newWalletForm)
219-
if (wallet.synced && wallet.balance.available >= 2 * bondAmt + bondsFeeBuffer) {
223+
let multiplier = bondReserveMultiplier
224+
if ((wallet.traits & traitBondUpdater) !== 0) multiplier = 1
225+
if (wallet.synced && wallet.balance.available >= multiplier * bondAmt + bondsFeeBuffer) {
220226
await this.animateConfirmForm(page.newWalletForm)
221227
return
222228
}

client/webserver/site/src/js/registry.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -891,10 +891,17 @@ export interface VotingServiceProvider {
891891
netShare: number
892892
}
893893

894-
export interface BondTxInfo {
895-
bondID: string
894+
export interface BondInfo {
895+
id : string
896+
amount: number
896897
lockTime: number
898+
}
899+
900+
export interface BondTxInfo {
897901
accountID: string
902+
bond: BondInfo
903+
changeBond?: BondInfo
904+
replacedBond?: BondInfo[]
898905
}
899906

900907
export interface WalletTransaction {

client/webserver/site/src/js/settings.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ import {
1717
PageElement,
1818
PasswordCache
1919
} from './registry'
20+
import { bondReserveMultiplier } from './account'
21+
import { traitBondUpdater } from './wallets'
2022

2123
const animationLength = 300
2224

@@ -89,7 +91,9 @@ export default class SettingsPage extends BasePage {
8991
const bondAsset = this.currentDEX.bondAssets[asset.symbol]
9092
const bondsFeeBuffer = await this.getBondsFeeBuffer(assetID, page.regAssetForm)
9193
this.confirmRegisterForm.setAsset(assetID, tier, bondsFeeBuffer)
92-
if (wallet.synced && wallet.balance.available >= 2 * bondAsset.amount + bondsFeeBuffer) {
94+
let multiplier = bondReserveMultiplier
95+
if ((wallet.traits & traitBondUpdater) !== 0) multiplier = 1
96+
if (wallet.synced && wallet.balance.available >= multiplier * bondAsset.amount + bondsFeeBuffer) {
9397
this.animateConfirmForm(page.regAssetForm)
9498
return
9599
}
@@ -269,7 +273,9 @@ export default class SettingsPage extends BasePage {
269273

270274
const bondsFeeBuffer = await this.getBondsFeeBuffer(assetID, page.newWalletForm)
271275
this.confirmRegisterForm.setFees(assetID, bondsFeeBuffer)
272-
if (wallet.synced && wallet.balance.available >= 2 * bondAmt + bondsFeeBuffer) {
276+
let multiplier = bondReserveMultiplier
277+
if ((wallet.traits & traitBondUpdater) !== 0) multiplier = 1
278+
if (wallet.synced && wallet.balance.available >= multiplier * bondAmt + bondsFeeBuffer) {
273279
await this.animateConfirmForm(page.newWalletForm)
274280
return
275281
}

0 commit comments

Comments
 (0)