Skip to content

Commit

Permalink
app: Fix registration flow forms
Browse files Browse the repository at this point in the history
The registration flow didn't take into account the case where an exchange
had not yet been added to user.Exchanges. It assumed the exchange would
already be view only.
  • Loading branch information
martonp committed May 9, 2024
1 parent 6bfab3d commit 57de9e2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
9 changes: 4 additions & 5 deletions client/webserver/site/src/js/forms.ts
Original file line number Diff line number Diff line change
Expand Up @@ -887,7 +887,7 @@ export class ConfirmRegistrationForm {
let form: any
let url: string

if (xc.viewOnly || !app().exchanges[xc.host]) {
if (!app().exchanges[xc.host] || app().exchanges[xc.host].viewOnly) {
form = {
addr: dexAddr,
cert: certFile,
Expand Down Expand Up @@ -1264,7 +1264,7 @@ export class WalletWaitForm {
page: Record<string, PageElement>
assetID: number
parentID?: number
host: string
xc: Exchange
bondAsset: BondAsset
progressCache: ProgressPoint[]
progressed: boolean
Expand Down Expand Up @@ -1295,7 +1295,7 @@ export class WalletWaitForm {

/* setExchange sets the exchange for which the fee is being paid. */
setExchange (xc: Exchange) {
this.host = xc.host
this.xc = xc
}

/* setWallet must be called before showing the WalletWaitForm. */
Expand All @@ -1308,10 +1308,9 @@ export class WalletWaitForm {
this.parentAssetSynced = false
const page = this.page
const asset = app().assets[assetID]
const xc = app().exchanges[this.host]
const { symbol, unitInfo: ui, wallet: { balance: bal, address, synced, syncProgress }, token } = asset
this.parentID = token?.parentID
const bondAsset = this.bondAsset = xc.bondAssets[symbol]
const bondAsset = this.bondAsset = this.xc.bondAssets[symbol]

const symbolize = (el: PageElement, asset: SupportedAsset) => {
Doc.empty(el)
Expand Down
9 changes: 4 additions & 5 deletions client/webserver/site/src/js/register.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export default class RegistrationPage extends BasePage {
body: HTMLElement
data: RegistrationPageData
pwCache: PasswordCache
host: string
xc: Exchange
page: Record<string, PageElement>
loginForm: LoginForm
appPassResetForm: AppPassResetForm
Expand Down Expand Up @@ -110,7 +110,7 @@ export default class RegistrationPage extends BasePage {
const asset = app().assets[assetID]
const wallet = asset.wallet
if (wallet) {
const bondAsset = this.regAssetForm.xc.bondAssets[asset.symbol]
const bondAsset = this.xc.bondAssets[asset.symbol]
const bondsFeeBuffer = await this.getBondsFeeBuffer(assetID, page.regAssetForm)
this.confirmRegisterForm.setAsset(assetID, tier, bondsFeeBuffer)
if (wallet.synced && wallet.balance.available >= 2 * bondAsset.amount + bondsFeeBuffer) {
Expand Down Expand Up @@ -171,7 +171,7 @@ export default class RegistrationPage extends BasePage {
}

async requestFeepayment (oldForm: HTMLElement, xc: Exchange, certFile: string) {
this.host = xc.host
this.xc = xc
this.confirmRegisterForm.setExchange(xc, certFile)
this.walletWaitForm.setExchange(xc)
this.regAssetForm.setExchange(xc, certFile)
Expand Down Expand Up @@ -225,9 +225,8 @@ export default class RegistrationPage extends BasePage {
if (!user) return
const page = this.page
const asset = user.assets[assetID]
const xc = app().exchanges[this.host]
const wallet = asset.wallet
const bondAmt = xc.bondAssets[asset.symbol].amount
const bondAmt = this.xc.bondAssets[asset.symbol].amount

const bondsFeeBuffer = await this.getBondsFeeBuffer(assetID, page.newWalletForm)
this.walletWaitForm.setWallet(assetID, bondsFeeBuffer, tier)
Expand Down

0 comments on commit 57de9e2

Please sign in to comment.