mirror of
https://github.com/Qortal/qortal-ui.git
synced 2025-02-12 02:05:51 +00:00
load ltc balance first
This commit is contained in:
parent
8096ec0a6f
commit
a9c2314197
@ -825,44 +825,11 @@ class TradePortal extends LitElement {
|
|||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
|
|
||||||
setForeignCoin(coin) {
|
|
||||||
let _this = this
|
|
||||||
this.selectedCoin = coin
|
|
||||||
this.isLoadingHistoricTrades = true
|
|
||||||
this.isLoadingOpenTrades = true
|
|
||||||
this.createConnection()
|
|
||||||
this._openOrdersGrid.querySelector('#priceColumn').headerRenderer = function (root) {
|
|
||||||
root.innerHTML = '<vaadin-grid-sorter path="price" direction="asc">Price (' + _this.listedCoins.get(_this.selectedCoin).coinCode + ')</vaadin-grid-sorter>'
|
|
||||||
}
|
|
||||||
this.clearSellForm()
|
|
||||||
this.clearBuyForm()
|
|
||||||
this.updateWalletBalance()
|
|
||||||
}
|
|
||||||
|
|
||||||
displayTabContent(tab) {
|
|
||||||
const tabBuyContent = this.shadowRoot.getElementById('tab-buy-content')
|
|
||||||
const tabSellContent = this.shadowRoot.getElementById('tab-sell-content')
|
|
||||||
tabBuyContent.style.display = (tab === 'buy') ? 'block' : 'none'
|
|
||||||
tabSellContent.style.display = (tab === 'sell') ? 'block' : 'none'
|
|
||||||
}
|
|
||||||
|
|
||||||
reRenderHistoricTrades() {
|
|
||||||
this.requestUpdate()
|
|
||||||
this.isLoadingHistoricTrades = false
|
|
||||||
}
|
|
||||||
|
|
||||||
reRenderOpenFilteredOrders() {
|
|
||||||
this.requestUpdate()
|
|
||||||
this.isLoadingOpenTrades = false
|
|
||||||
}
|
|
||||||
|
|
||||||
reRenderMyOpenOrders() {
|
|
||||||
this.requestUpdate()
|
|
||||||
this.isLoadingMyOpenOrders = false
|
|
||||||
}
|
|
||||||
|
|
||||||
firstUpdated() {
|
firstUpdated() {
|
||||||
let _this = this
|
let _this = this
|
||||||
|
|
||||||
|
this.updateWalletBalance()
|
||||||
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
this.displayTabContent('buy')
|
this.displayTabContent('buy')
|
||||||
}, 0)
|
}, 0)
|
||||||
@ -882,7 +849,6 @@ class TradePortal extends LitElement {
|
|||||||
this._myHistoricTradesGrid = this.shadowRoot.getElementById('myHistoricTradesGrid')
|
this._myHistoricTradesGrid = this.shadowRoot.getElementById('myHistoricTradesGrid')
|
||||||
this._stuckOrdersGrid = this.shadowRoot.getElementById('stuckOrdersGrid')
|
this._stuckOrdersGrid = this.shadowRoot.getElementById('stuckOrdersGrid')
|
||||||
|
|
||||||
// call getOpenOrdersGrid
|
|
||||||
this.getOpenOrdersGrid()
|
this.getOpenOrdersGrid()
|
||||||
|
|
||||||
window.addEventListener(
|
window.addEventListener(
|
||||||
@ -940,6 +906,73 @@ class TradePortal extends LitElement {
|
|||||||
setTimeout(() => this.shadowRoot.querySelector('[slot="vaadin-grid-cell-content-3"]').setAttribute('title', 'Last Seen'), 3000)
|
setTimeout(() => this.shadowRoot.querySelector('[slot="vaadin-grid-cell-content-3"]').setAttribute('title', 'Last Seen'), 3000)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
updateWalletBalance() {
|
||||||
|
let _url = ``
|
||||||
|
let _body = null
|
||||||
|
|
||||||
|
switch (this.selectedCoin) {
|
||||||
|
case 'LITECOIN':
|
||||||
|
_url = `/crosschain/ltc/walletbalance?apiKey=${this.getApiKey()}`
|
||||||
|
_body = window.parent.reduxStore.getState().app.selectedAddress.ltcWallet.derivedMasterPublicKey
|
||||||
|
break
|
||||||
|
case 'DOGECOIN':
|
||||||
|
_url = `/crosschain/doge/walletbalance?apiKey=${this.getApiKey()}`
|
||||||
|
_body = window.parent.reduxStore.getState().app.selectedAddress.dogeWallet.derivedMasterPublicKey
|
||||||
|
break
|
||||||
|
default:
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
|
parentEpml.request('apiCall', {
|
||||||
|
url: _url,
|
||||||
|
method: 'POST',
|
||||||
|
body: _body,
|
||||||
|
})
|
||||||
|
.then((res) => {
|
||||||
|
if (isNaN(Number(res))) {
|
||||||
|
parentEpml.request('showSnackBar', 'Failed to Fetch Balance. Try again!')
|
||||||
|
} else {
|
||||||
|
this.listedCoins.get(this.selectedCoin).balance = (Number(res) / 1e8).toFixed(8)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
setForeignCoin(coin) {
|
||||||
|
let _this = this
|
||||||
|
this.selectedCoin = coin
|
||||||
|
this.isLoadingHistoricTrades = true
|
||||||
|
this.isLoadingOpenTrades = true
|
||||||
|
this.createConnection()
|
||||||
|
this._openOrdersGrid.querySelector('#priceColumn').headerRenderer = function (root) {
|
||||||
|
root.innerHTML = '<vaadin-grid-sorter path="price" direction="asc">Price (' + _this.listedCoins.get(_this.selectedCoin).coinCode + ')</vaadin-grid-sorter>'
|
||||||
|
}
|
||||||
|
this.clearSellForm()
|
||||||
|
this.clearBuyForm()
|
||||||
|
this.updateWalletBalance()
|
||||||
|
}
|
||||||
|
|
||||||
|
displayTabContent(tab) {
|
||||||
|
const tabBuyContent = this.shadowRoot.getElementById('tab-buy-content')
|
||||||
|
const tabSellContent = this.shadowRoot.getElementById('tab-sell-content')
|
||||||
|
tabBuyContent.style.display = (tab === 'buy') ? 'block' : 'none'
|
||||||
|
tabSellContent.style.display = (tab === 'sell') ? 'block' : 'none'
|
||||||
|
}
|
||||||
|
|
||||||
|
reRenderHistoricTrades() {
|
||||||
|
this.requestUpdate()
|
||||||
|
this.isLoadingHistoricTrades = false
|
||||||
|
}
|
||||||
|
|
||||||
|
reRenderOpenFilteredOrders() {
|
||||||
|
this.requestUpdate()
|
||||||
|
this.isLoadingOpenTrades = false
|
||||||
|
}
|
||||||
|
|
||||||
|
reRenderMyOpenOrders() {
|
||||||
|
this.requestUpdate()
|
||||||
|
this.isLoadingMyOpenOrders = false
|
||||||
|
}
|
||||||
|
|
||||||
fillBuyForm(sellerRequest) {
|
fillBuyForm(sellerRequest) {
|
||||||
this.shadowRoot.getElementById('buyAmountInput').value = parseFloat(sellerRequest.qortAmount)
|
this.shadowRoot.getElementById('buyAmountInput').value = parseFloat(sellerRequest.qortAmount)
|
||||||
this.shadowRoot.getElementById('buyPriceInput').value = this.round(parseFloat(sellerRequest.foreignAmount) / parseFloat(sellerRequest.qortAmount))
|
this.shadowRoot.getElementById('buyPriceInput').value = this.round(parseFloat(sellerRequest.foreignAmount) / parseFloat(sellerRequest.qortAmount))
|
||||||
@ -1652,37 +1685,6 @@ class TradePortal extends LitElement {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
updateWalletBalance() {
|
|
||||||
let _url = ``
|
|
||||||
let _body = null
|
|
||||||
|
|
||||||
switch (this.selectedCoin) {
|
|
||||||
case 'LITECOIN':
|
|
||||||
_url = `/crosschain/ltc/walletbalance?apiKey=${this.getApiKey()}`
|
|
||||||
_body = window.parent.reduxStore.getState().app.selectedAddress.ltcWallet.derivedMasterPublicKey
|
|
||||||
break
|
|
||||||
case 'DOGECOIN':
|
|
||||||
_url = `/crosschain/doge/walletbalance?apiKey=${this.getApiKey()}`
|
|
||||||
_body = window.parent.reduxStore.getState().app.selectedAddress.dogeWallet.derivedMasterPublicKey
|
|
||||||
break
|
|
||||||
default:
|
|
||||||
break
|
|
||||||
}
|
|
||||||
|
|
||||||
parentEpml.request('apiCall', {
|
|
||||||
url: _url,
|
|
||||||
method: 'POST',
|
|
||||||
body: _body,
|
|
||||||
})
|
|
||||||
.then((res) => {
|
|
||||||
if (isNaN(Number(res))) {
|
|
||||||
parentEpml.request('showSnackBar', 'Failed to Fetch Balance. Try again!')
|
|
||||||
} else {
|
|
||||||
this.listedCoins.get(this.selectedCoin).balance = (Number(res) / 1e8).toFixed(8)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
renderCancelButton(stateItem) {
|
renderCancelButton(stateItem) {
|
||||||
if (stateItem.tradeState === 'BOB_WAITING_FOR_MESSAGE') {
|
if (stateItem.tradeState === 'BOB_WAITING_FOR_MESSAGE') {
|
||||||
return html`<mwc-button id="${stateItem.atAddress}" ?disabled=${this.cancelBtnDisable} class="cancel" @click=${(e) => this.cancelAction(stateItem)}>CANCEL</mwc-button>`
|
return html`<mwc-button id="${stateItem.atAddress}" ?disabled=${this.cancelBtnDisable} class="cancel" @click=${(e) => this.cancelAction(stateItem)}>CANCEL</mwc-button>`
|
||||||
|
Loading…
x
Reference in New Issue
Block a user