mirror of
https://github.com/Qortal/qortal-ui.git
synced 2025-02-11 17:55:51 +00:00
Filter bad offers from lists
This commit is contained in:
parent
015298323a
commit
bf8e622ccb
@ -75,6 +75,7 @@ class AppView extends connect(store)(LitElement) {
|
||||
arrrWalletBalance: { type: Number },
|
||||
failedTradesList: { type: Array },
|
||||
tradesOpenBtcQortal: { type: Array },
|
||||
myTradesOpenLtcQortal: { type: Array },
|
||||
tradesFailedBtcQortal: { type: Array },
|
||||
tradesOpenBtcQortalCleaned: { type: Array },
|
||||
tradesOpenLtcQortal: { type: Array },
|
||||
@ -465,6 +466,7 @@ class AppView extends connect(store)(LitElement) {
|
||||
this.arrrWalletBalance = 0
|
||||
this.failedTradesList = []
|
||||
this.tradesOpenBtcQortal = []
|
||||
this.myTradesOpenLtcQortal = []
|
||||
this.tradesFailedBtcQortal = []
|
||||
this.tradesOpenBtcQortalCleaned = []
|
||||
this.tradesOpenLtcQortal = []
|
||||
@ -741,6 +743,7 @@ class AppView extends connect(store)(LitElement) {
|
||||
await this.botArrrTradebook()
|
||||
|
||||
window.addEventListener('storage', async () => {
|
||||
this.failedTradesList = JSON.parse(localStorage.getItem("failedTrades") || "[]")
|
||||
this.tradeBotBtcBook = JSON.parse(localStorage.getItem(this.botBtcWallet) || "[]")
|
||||
this.tradeBotLtcBook = JSON.parse(localStorage.getItem(this.botLtcWallet) || "[]")
|
||||
this.tradeBotDogeBook = JSON.parse(localStorage.getItem(this.botDogeWallet) || "[]")
|
||||
@ -872,13 +875,18 @@ class AppView extends connect(store)(LitElement) {
|
||||
|
||||
await filterUnconfirmedTransactionsBTC()
|
||||
|
||||
this.failedTradesList.map(item => {
|
||||
const recipientToRemove = item.recipient
|
||||
this.tradesOpenBtcQortalCleaned = this.tradesOpenBtcQortal.filter(obj => {
|
||||
return obj.qortalCreatorTradeAddress !== recipientToRemove
|
||||
})
|
||||
})
|
||||
this.tradesOpenBtcQortalCleaned = this.tradesOpenBtcQortal
|
||||
|
||||
const filterOpenOfferBTC = async () => {
|
||||
this.failedTradesList.forEach(item => {
|
||||
const recipientToRemove = item.recipient
|
||||
this.tradesOpenBtcQortalCleaned = this.tradesOpenBtcQortalCleaned.filter(obj => {
|
||||
return obj.qortalCreatorTradeAddress !== recipientToRemove
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
await filterOpenOfferBTC()
|
||||
await appDelay(1000)
|
||||
filterMyBotPriceTradesBTC()
|
||||
setTimeout(getOpenTradesBTC, 150000)
|
||||
@ -925,8 +933,6 @@ class AppView extends connect(store)(LitElement) {
|
||||
|
||||
if (this.tradeBotBtcAt.some(item => item.atAddress === this.checkBtcAlice)) {
|
||||
return
|
||||
} else {
|
||||
this.tradeBotAvailableBtcQortal = this.tradeBotAvailableBtcQortal
|
||||
}
|
||||
|
||||
await appDelay(1000)
|
||||
@ -972,8 +978,6 @@ class AppView extends connect(store)(LitElement) {
|
||||
|
||||
if (Number(botamount) === 0) {
|
||||
this.removeBotBTCTradebook()
|
||||
} else {
|
||||
this.tradeBotBtcBook = this.tradeBotBtcBook
|
||||
}
|
||||
}
|
||||
|
||||
@ -985,8 +989,6 @@ class AppView extends connect(store)(LitElement) {
|
||||
|
||||
if (Number(myBotBtcFunds) < Number(checkBotBtcFunds)) {
|
||||
this.removeBotBTCTradebook()
|
||||
} else {
|
||||
this.tradeBotBtcBook = this.tradeBotBtcBook
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1000,27 +1002,38 @@ class AppView extends connect(store)(LitElement) {
|
||||
timerLTC = setTimeout(getOpenTradesLTC, 150000)
|
||||
} else {
|
||||
await this.updateLtcWalletBalance()
|
||||
const tradesOpenLtcQortalUrl = `${nodeAppUrl}/crosschain/tradeoffers?foreignBlockchain=LITECOIN&limit=0`
|
||||
|
||||
const tradesOpenLtcQortal = await fetch(tradesOpenLtcQortalUrl).then(response => {
|
||||
return response.json()
|
||||
})
|
||||
const getTradesOpenLtcQortal = async () => {
|
||||
const tradesOpenLtcQortalUrl = `${nodeAppUrl}/crosschain/tradeoffers?foreignBlockchain=LITECOIN&limit=0`
|
||||
|
||||
this.tradesOpenLtcQortal = tradesOpenLtcQortal.map(item => {
|
||||
const expiryTime = item.creatorPresenceExpiry
|
||||
if (Number(expiryTime) > Date.now()) {
|
||||
const calcedPrice = parseFloat(item.expectedForeignAmount) / parseFloat(item.qortAmount)
|
||||
const roundedPrice = (Math.round(parseFloat(calcedPrice) * 1e8) / 1e8).toFixed(8)
|
||||
return {
|
||||
qortAmount: item.qortAmount,
|
||||
price: roundedPrice,
|
||||
foreignAmount: item.expectedForeignAmount,
|
||||
qortalCreator: item.qortalCreator,
|
||||
qortalAtAddress: item.qortalAtAddress,
|
||||
qortalCreatorTradeAddress: item.qortalCreatorTradeAddress
|
||||
await fetch(tradesOpenLtcQortalUrl).then(response => {
|
||||
return response.json()
|
||||
}).then(data => {
|
||||
this.myTradesOpenLtcQortal = data
|
||||
})
|
||||
}
|
||||
|
||||
await getTradesOpenLtcQortal()
|
||||
|
||||
const filterTradesOpenLtcQortal = async () => {
|
||||
this.tradesOpenLtcQortal = this.myTradesOpenLtcQortal.map(item => {
|
||||
const expiryTime = item.creatorPresenceExpiry
|
||||
if (Number(expiryTime) > Date.now()) {
|
||||
const calcedPrice = parseFloat(item.expectedForeignAmount) / parseFloat(item.qortAmount)
|
||||
const roundedPrice = (Math.round(parseFloat(calcedPrice) * 1e8) / 1e8).toFixed(8)
|
||||
return {
|
||||
qortAmount: item.qortAmount,
|
||||
price: roundedPrice,
|
||||
foreignAmount: item.expectedForeignAmount,
|
||||
qortalCreator: item.qortalCreator,
|
||||
qortalAtAddress: item.qortalAtAddress,
|
||||
qortalCreatorTradeAddress: item.qortalCreatorTradeAddress
|
||||
}
|
||||
}
|
||||
}
|
||||
}).filter(item => !!item)
|
||||
}).filter(item => !!item)
|
||||
}
|
||||
|
||||
await filterTradesOpenLtcQortal()
|
||||
|
||||
const unconfirmedTransactionsLTC = async () => {
|
||||
const unconfirmedTransactionsUrlLTC = `${nodeAppUrl}/transactions/unconfirmed?txType=MESSAGE&limit=0&reverse=true`
|
||||
@ -1059,13 +1072,18 @@ class AppView extends connect(store)(LitElement) {
|
||||
|
||||
await filterUnconfirmedTransactionsLTC()
|
||||
|
||||
this.failedTradesList.map(item => {
|
||||
const recipientToRemove = item.recipient
|
||||
this.tradesOpenLtcQortalCleaned = this.tradesOpenLtcQortal.filter(obj => {
|
||||
return obj.qortalCreatorTradeAddress !== recipientToRemove
|
||||
})
|
||||
})
|
||||
this.tradesOpenLtcQortalCleaned = this.tradesOpenLtcQortal
|
||||
|
||||
const filterOpenOfferLTC = async () => {
|
||||
this.failedTradesList.forEach(item => {
|
||||
const recipientToRemove = item.recipient
|
||||
this.tradesOpenLtcQortalCleaned = this.tradesOpenLtcQortalCleaned.filter(obj => {
|
||||
return obj.qortalCreatorTradeAddress !== recipientToRemove
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
await filterOpenOfferLTC()
|
||||
await appDelay(1000)
|
||||
filterMyBotPriceTradesLTC()
|
||||
setTimeout(getOpenTradesLTC, 150000)
|
||||
@ -1112,8 +1130,6 @@ class AppView extends connect(store)(LitElement) {
|
||||
|
||||
if (this.tradeBotLtcAt.some(item => item.atAddress === this.checkLtcAlice)) {
|
||||
return
|
||||
} else {
|
||||
this.tradeBotAvailableLtcQortal = this.tradeBotAvailableLtcQortal
|
||||
}
|
||||
|
||||
await appDelay(1000)
|
||||
@ -1159,8 +1175,6 @@ class AppView extends connect(store)(LitElement) {
|
||||
|
||||
if (Number(botamount) === 0) {
|
||||
this.removeBotLTCTradebook()
|
||||
} else {
|
||||
this.tradeBotLtcBook = this.tradeBotLtcBook
|
||||
}
|
||||
}
|
||||
|
||||
@ -1172,8 +1186,6 @@ class AppView extends connect(store)(LitElement) {
|
||||
|
||||
if (Number(myBotLtcFunds) < Number(checkBotLtcFunds)) {
|
||||
this.removeBotLTCTradebook()
|
||||
} else {
|
||||
this.tradeBotLtcBook = this.tradeBotLtcBook
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1246,13 +1258,18 @@ class AppView extends connect(store)(LitElement) {
|
||||
|
||||
await filterUnconfirmedTransactionsDOGE()
|
||||
|
||||
this.failedTradesList.map(item => {
|
||||
const recipientToRemove = item.recipient
|
||||
this.tradesOpenDogeQortalCleaned = this.tradesOpenDogeQortal.filter(obj => {
|
||||
return obj.qortalCreatorTradeAddress !== recipientToRemove
|
||||
})
|
||||
})
|
||||
this.tradesOpenDogeQortalCleaned = this.tradesOpenDogeQortal
|
||||
|
||||
const filterOpenOfferDOGE = async () => {
|
||||
this.failedTradesList.forEach(item => {
|
||||
const recipientToRemove = item.recipient
|
||||
this.tradesOpenDogeQortalCleaned = this.tradesOpenDogeQortalCleaned.filter(obj => {
|
||||
return obj.qortalCreatorTradeAddress !== recipientToRemove
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
await filterOpenOfferDOGE()
|
||||
await appDelay(1000)
|
||||
filterMyBotPriceTradesDOGE()
|
||||
setTimeout(getOpenTradesDOGE, 150000)
|
||||
@ -1299,8 +1316,6 @@ class AppView extends connect(store)(LitElement) {
|
||||
|
||||
if (this.tradeBotDogeAt.some(item => item.atAddress === this.checkDogeAlice)) {
|
||||
return
|
||||
} else {
|
||||
this.tradeBotAvailableDogeQortal = this.tradeBotAvailableDogeQortal
|
||||
}
|
||||
|
||||
await appDelay(1000)
|
||||
@ -1346,8 +1361,6 @@ class AppView extends connect(store)(LitElement) {
|
||||
|
||||
if (Number(botamount) === 0) {
|
||||
this.removeBotDOGETradebook()
|
||||
} else {
|
||||
this.tradeBotDogeBook = this.tradeBotDogeBook
|
||||
}
|
||||
}
|
||||
|
||||
@ -1359,8 +1372,6 @@ class AppView extends connect(store)(LitElement) {
|
||||
|
||||
if (Number(myBotDogeFunds) < Number(checkBotDogeFunds)) {
|
||||
this.removeBotDOGETradebook()
|
||||
} else {
|
||||
this.tradeBotDogeBook = this.tradeBotDogeBook
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1433,13 +1444,18 @@ class AppView extends connect(store)(LitElement) {
|
||||
|
||||
await filterUnconfirmedTransactionsDGB()
|
||||
|
||||
this.failedTradesList.map(item => {
|
||||
const recipientToRemove = item.recipient
|
||||
this.tradesOpenDgbQortalCleaned = this.tradesOpenDgbQortal.filter(obj => {
|
||||
return obj.qortalCreatorTradeAddress !== recipientToRemove
|
||||
})
|
||||
})
|
||||
this.tradesOpenDgbQortalCleaned = this.tradesOpenDgbQortal
|
||||
|
||||
const filterOpenOfferDGB = async () => {
|
||||
this.failedTradesList.forEach(item => {
|
||||
const recipientToRemove = item.recipient
|
||||
this.tradesOpenDgbQortalCleaned = this.tradesOpenDgbQortalCleaned.filter(obj => {
|
||||
return obj.qortalCreatorTradeAddress !== recipientToRemove
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
await filterOpenOfferDGB()
|
||||
await appDelay(1000)
|
||||
filterMyBotPriceTradesDGB()
|
||||
setTimeout(getOpenTradesDGB, 150000)
|
||||
@ -1486,8 +1502,6 @@ class AppView extends connect(store)(LitElement) {
|
||||
|
||||
if (this.tradeBotDgbAt.some(item => item.atAddress === this.checkDgbAlice)) {
|
||||
return
|
||||
} else {
|
||||
this.tradeBotAvailableDgbQortal = this.tradeBotAvailableDgbQortal
|
||||
}
|
||||
|
||||
await appDelay(1000)
|
||||
@ -1533,8 +1547,6 @@ class AppView extends connect(store)(LitElement) {
|
||||
|
||||
if (Number(botamount) === 0) {
|
||||
this.removeBotDGBTradebook()
|
||||
} else {
|
||||
this.tradeBotDgbBook = this.tradeBotDgbBook
|
||||
}
|
||||
}
|
||||
|
||||
@ -1546,8 +1558,6 @@ class AppView extends connect(store)(LitElement) {
|
||||
|
||||
if (Number(myBotDgbFunds) < Number(checkBotDgbFunds)) {
|
||||
this.removeBotDGBTradebook()
|
||||
} else {
|
||||
this.tradeBotDgbBook = this.tradeBotDgbBook
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1620,13 +1630,18 @@ class AppView extends connect(store)(LitElement) {
|
||||
|
||||
await filterUnconfirmedTransactionsRVN()
|
||||
|
||||
this.failedTradesList.map(item => {
|
||||
const recipientToRemove = item.recipient
|
||||
this.tradesOpenRvnQortalCleaned = this.tradesOpenRvnQortal.filter(obj => {
|
||||
return obj.qortalCreatorTradeAddress !== recipientToRemove
|
||||
})
|
||||
})
|
||||
this.tradesOpenRvnQortalCleaned = this.tradesOpenRvnQortal
|
||||
|
||||
const filterOpenOfferRVN = async () => {
|
||||
this.failedTradesList.forEach(item => {
|
||||
const recipientToRemove = item.recipient
|
||||
this.tradesOpenRvnQortalCleaned = this.tradesOpenRvnQortalCleaned.filter(obj => {
|
||||
return obj.qortalCreatorTradeAddress !== recipientToRemove
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
await filterOpenOfferRVN()
|
||||
await appDelay(1000)
|
||||
filterMyBotPriceTradesRVN()
|
||||
setTimeout(getOpenTradesRVN, 150000)
|
||||
@ -1673,8 +1688,6 @@ class AppView extends connect(store)(LitElement) {
|
||||
|
||||
if (this.tradeBotRvnAt.some(item => item.atAddress === this.checkRvnAlice)) {
|
||||
return
|
||||
} else {
|
||||
this.tradeBotAvailableRvnQortal = this.tradeBotAvailableRvnQortal
|
||||
}
|
||||
|
||||
await appDelay(1000)
|
||||
@ -1720,8 +1733,6 @@ class AppView extends connect(store)(LitElement) {
|
||||
|
||||
if (Number(botamount) === 0) {
|
||||
this.removeBotRVNTradebook()
|
||||
} else {
|
||||
this.tradeBotRvnBook = this.tradeBotRvnBook
|
||||
}
|
||||
}
|
||||
|
||||
@ -1733,8 +1744,6 @@ class AppView extends connect(store)(LitElement) {
|
||||
|
||||
if (Number(myBotRvnFunds) < Number(checkBotRvnFunds)) {
|
||||
this.removeBotRVNTradebook()
|
||||
} else {
|
||||
this.tradeBotRvnBook = this.tradeBotRvnBook
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1807,13 +1816,18 @@ class AppView extends connect(store)(LitElement) {
|
||||
|
||||
await filterUnconfirmedTransactionsARRR()
|
||||
|
||||
this.failedTradesList.map(item => {
|
||||
const recipientToRemove = item.recipient
|
||||
this.tradesOpenArrrQortalCleaned = this.tradesOpenArrrQortal.filter(obj => {
|
||||
return obj.qortalCreatorTradeAddress !== recipientToRemove
|
||||
})
|
||||
})
|
||||
this.tradesOpenArrrQortalCleaned = this.tradesOpenArrrQortal
|
||||
|
||||
const filterOpenOfferARRR = async () => {
|
||||
this.failedTradesList.forEach(item => {
|
||||
const recipientToRemove = item.recipient
|
||||
this.tradesOpenArrrQortalCleaned = this.tradesOpenArrrQortalCleaned.filter(obj => {
|
||||
return obj.qortalCreatorTradeAddress !== recipientToRemove
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
await filterOpenOfferARRR()
|
||||
await appDelay(1000)
|
||||
filterMyBotPriceTradesARRR()
|
||||
setTimeout(getOpenTradesARRR, 150000)
|
||||
@ -1860,8 +1874,6 @@ class AppView extends connect(store)(LitElement) {
|
||||
|
||||
if (this.tradeBotArrrAt.some(item => item.atAddress === this.checkArrrAlice)) {
|
||||
return
|
||||
} else {
|
||||
this.tradeBotAvailableArrrQortal = this.tradeBotAvailableArrrQortal
|
||||
}
|
||||
|
||||
await appDelay(1000)
|
||||
@ -1907,8 +1919,6 @@ class AppView extends connect(store)(LitElement) {
|
||||
|
||||
if (Number(botamount) === 0) {
|
||||
this.removeBotARRRTradebook()
|
||||
} else {
|
||||
this.tradeBotArrrBook = this.tradeBotArrrBook
|
||||
}
|
||||
}
|
||||
|
||||
@ -1920,8 +1930,6 @@ class AppView extends connect(store)(LitElement) {
|
||||
|
||||
if (Number(myBotArrrFunds) < Number(checkBotArrrFunds)) {
|
||||
this.removeBotARRRTradebook()
|
||||
} else {
|
||||
this.tradeBotArrrBook = this.tradeBotArrrBook
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -3333,5 +3341,4 @@ class AppView extends connect(store)(LitElement) {
|
||||
}
|
||||
}
|
||||
|
||||
window.customElements.define('app-view', AppView)
|
||||
|
||||
window.customElements.define('app-view', AppView)
|
@ -37,6 +37,9 @@ class TradeBotPortal extends LitElement {
|
||||
selectedAddress: { type: Object },
|
||||
config: { type: Object },
|
||||
listedCoins: { type: Map },
|
||||
blockedTradesList: { type: Array },
|
||||
preparedPresence: { type: Array },
|
||||
tradesPresenceCleaned: { type: Array },
|
||||
sellBtnDisable: { type: Boolean },
|
||||
isSellLoading: { type: Boolean },
|
||||
isBuyLoading: { type: Boolean },
|
||||
@ -847,6 +850,9 @@ class TradeBotPortal extends LitElement {
|
||||
this.selectedCoin = "LITECOIN"
|
||||
this.selectedAddress = {}
|
||||
this.config = {}
|
||||
this.blockedTradesList = []
|
||||
this.preparedPresence = []
|
||||
this.tradesPresenceCleaned = []
|
||||
this.sellBtnDisable = false
|
||||
this.isSellLoading = false
|
||||
this.buyBtnDisable = true
|
||||
@ -2098,12 +2104,13 @@ class TradeBotPortal extends LitElement {
|
||||
`
|
||||
}
|
||||
|
||||
firstUpdated() {
|
||||
async firstUpdated() {
|
||||
let _this = this
|
||||
|
||||
this.changeTheme()
|
||||
this.changeLanguage()
|
||||
this.tradeFee()
|
||||
await this.getNewBlockedTrades()
|
||||
|
||||
this.autoHelperMessage = this.renderAutoHelperPass()
|
||||
|
||||
@ -2145,7 +2152,7 @@ class TradeBotPortal extends LitElement {
|
||||
|
||||
this.updateWalletBalance()
|
||||
this.fetchWalletAddress(this.selectedCoin)
|
||||
|
||||
this.blockedTradesList = JSON.parse(localStorage.getItem('failedTrades') || '[]')
|
||||
this._openOrdersGrid = this.shadowRoot.getElementById('openOrdersGrid')
|
||||
|
||||
this._openOrdersGrid.querySelector('#priceColumn').headerRenderer = function (root) {
|
||||
@ -2203,6 +2210,7 @@ class TradeBotPortal extends LitElement {
|
||||
}
|
||||
|
||||
window.addEventListener('storage', () => {
|
||||
this.blockedTradesList = JSON.parse(localStorage.getItem('failedTrades') || '[]')
|
||||
this.tradeBotBtcBook = JSON.parse(localStorage.getItem(this.btcWallet) || "[]")
|
||||
this.tradeBotLtcBook = JSON.parse(localStorage.getItem(this.ltcWallet) || "[]")
|
||||
this.tradeBotDogeBook = JSON.parse(localStorage.getItem(this.dogeWallet) || "[]")
|
||||
@ -2284,6 +2292,9 @@ class TradeBotPortal extends LitElement {
|
||||
setInterval(() => {
|
||||
this.clearConsole()
|
||||
}, 60000)
|
||||
setInterval(() => {
|
||||
this.getNewBlockedTrades()
|
||||
}, 300000)
|
||||
}
|
||||
|
||||
clearConsole() {
|
||||
@ -3817,8 +3828,8 @@ class TradeBotPortal extends LitElement {
|
||||
return null
|
||||
case 'PRESENCE':
|
||||
this.listedCoins.get(message.data.relatedCoin).openOrders = message.data.offers
|
||||
this.listedCoins.get(message.data.relatedCoin).openFilteredOrders = message.data.filteredOffers
|
||||
this.reRenderOpenFilteredOrders()
|
||||
this.preparedPresence = message.data.filteredOffers
|
||||
this.filterPresenceTrades()
|
||||
return null
|
||||
default:
|
||||
break
|
||||
@ -3839,6 +3850,67 @@ class TradeBotPortal extends LitElement {
|
||||
|
||||
workers.get(this.selectedCoin).tradesConnectedWorker.postMessage({ type: "set_coin", content: this.selectedCoin })
|
||||
}
|
||||
|
||||
async getNewBlockedTrades() {
|
||||
const unconfirmedTransactionsList = async () => {
|
||||
const myNodeInf = window.parent.reduxStore.getState().app.nodeConfig.knownNodes[window.parent.reduxStore.getState().app.nodeConfig.node]
|
||||
const myNodeUrl = myNodeInf.protocol + '://' + myNodeInf.domain + ':' + myNodeInf.port
|
||||
const unconfirmedTransactionslUrl = `${myNodeUrl}/transactions/unconfirmed?txType=MESSAGE&limit=0&reverse=true`
|
||||
|
||||
var addBlockedTrades = JSON.parse(localStorage.getItem('failedTrades') || '[]')
|
||||
|
||||
await fetch(unconfirmedTransactionslUrl).then(response => {
|
||||
return response.json()
|
||||
}).then(data => {
|
||||
data.map(item => {
|
||||
const unconfirmedNessageTimeDiff = Date.now() - item.timestamp
|
||||
const timeOneHour = 60 * 60 * 1000
|
||||
if (Number(unconfirmedNessageTimeDiff) > Number(timeOneHour)) {
|
||||
const addBlocked = {
|
||||
timestamp: item.timestamp,
|
||||
recipient: item.recipient
|
||||
}
|
||||
addBlockedTrades.push(addBlocked)
|
||||
}
|
||||
})
|
||||
localStorage.setItem("failedTrades", JSON.stringify(addBlockedTrades))
|
||||
this.blockedTradesList = JSON.parse(localStorage.getItem('failedTrades') || '[]')
|
||||
})
|
||||
}
|
||||
|
||||
await unconfirmedTransactionsList()
|
||||
|
||||
const filterUnconfirmedTransactionsList = async () => {
|
||||
let cleanBlockedTrades = this.blockedTradesList.reduce((newArray, cut) => {
|
||||
if(!newArray.some(obj => obj.recipient === cut.recipient)) {
|
||||
newArray.push(cut)
|
||||
}
|
||||
return newArray
|
||||
},[])
|
||||
localStorage.setItem("failedTrades", JSON.stringify(cleanBlockedTrades))
|
||||
this.blockedTradesList = JSON.parse(localStorage.getItem("failedTrades") || "[]")
|
||||
}
|
||||
|
||||
await filterUnconfirmedTransactionsList()
|
||||
}
|
||||
|
||||
async filterPresenceTrades() {
|
||||
this.tradesPresenceCleaned = this.preparedPresence
|
||||
|
||||
const filterPresenceList = async () => {
|
||||
this.blockedTradesList.forEach(item => {
|
||||
const toDelete = item.recipient
|
||||
this.tradesPresenceCleaned = this.tradesPresenceCleaned.filter(el => {
|
||||
return el.qortalCreatorTradeAddress !== toDelete
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
await filterPresenceList()
|
||||
|
||||
this.listedCoins.get(this.selectedCoin).openFilteredOrders = this.tradesPresenceCleaned
|
||||
this.reRenderOpenFilteredOrders()
|
||||
}
|
||||
}
|
||||
|
||||
window.customElements.define('trade-bot-portal', TradeBotPortal)
|
||||
window.customElements.define('trade-bot-portal', TradeBotPortal)
|
@ -45,6 +45,9 @@ class TradePortal extends LitElement {
|
||||
config: { type: Object },
|
||||
listedCoins: { type: Map },
|
||||
nodeInfo: { type: Array },
|
||||
blockedTradesList: { type: Array },
|
||||
preparedPresence: { type: Array },
|
||||
tradesPresenceCleaned: { type: Array },
|
||||
sellBtnDisable: { type: Boolean },
|
||||
isSellLoading: { type: Boolean },
|
||||
isBuyLoading: { type: Boolean },
|
||||
@ -853,6 +856,9 @@ class TradePortal extends LitElement {
|
||||
this.selectedCoin = "LITECOIN"
|
||||
this.selectedAddress = {}
|
||||
this.nodeInfo = []
|
||||
this.blockedTradesList = []
|
||||
this.preparedPresence = []
|
||||
this.tradesPresenceCleaned = []
|
||||
this.config = {}
|
||||
this.sellBtnDisable = false
|
||||
this.isSellLoading = false
|
||||
@ -1462,12 +1468,13 @@ class TradePortal extends LitElement {
|
||||
}
|
||||
}
|
||||
|
||||
firstUpdated() {
|
||||
async firstUpdated() {
|
||||
let _this = this
|
||||
|
||||
this.changeTheme()
|
||||
this.changeLanguage()
|
||||
this.tradeFee()
|
||||
await this.getNewBlockedTrades()
|
||||
|
||||
this.tradeHelperMessage = this.renderTradeHelperPass()
|
||||
|
||||
@ -1509,6 +1516,7 @@ class TradePortal extends LitElement {
|
||||
|
||||
this.updateWalletBalance()
|
||||
this.fetchWalletAddress(this.selectedCoin)
|
||||
this.blockedTradesList = JSON.parse(localStorage.getItem('failedTrades') || '[]')
|
||||
|
||||
setTimeout(() => {
|
||||
this.displayTabContent('buy')
|
||||
@ -1592,6 +1600,7 @@ class TradePortal extends LitElement {
|
||||
}
|
||||
|
||||
window.addEventListener('storage', () => {
|
||||
this.blockedTradesList = JSON.parse(localStorage.getItem('failedTrades') || '[]')
|
||||
const checkLanguage = localStorage.getItem('qortalLanguage')
|
||||
const checkTheme = localStorage.getItem('qortalTheme')
|
||||
|
||||
@ -1694,10 +1703,15 @@ class TradePortal extends LitElement {
|
||||
parentEpml.imReady()
|
||||
|
||||
setTimeout(() => this.shadowRoot.querySelector('[slot="vaadin-grid-cell-content-3"]').setAttribute('title', 'Last Seen'), 3000)
|
||||
|
||||
this.clearConsole()
|
||||
setInterval(() => {
|
||||
this.clearConsole()
|
||||
}, 60000)
|
||||
|
||||
setInterval(() => {
|
||||
this.getNewBlockedTrades()
|
||||
}, 150000)
|
||||
}
|
||||
|
||||
clearConsole() {
|
||||
@ -3208,8 +3222,8 @@ class TradePortal extends LitElement {
|
||||
return null
|
||||
case 'PRESENCE':
|
||||
this.listedCoins.get(message.data.relatedCoin).openOrders = message.data.offers
|
||||
this.listedCoins.get(message.data.relatedCoin).openFilteredOrders = message.data.filteredOffers
|
||||
this.reRenderOpenFilteredOrders()
|
||||
this.preparedPresence = message.data.filteredOffers
|
||||
this.filterPresenceTrades()
|
||||
return null
|
||||
default:
|
||||
break
|
||||
@ -3232,6 +3246,67 @@ class TradePortal extends LitElement {
|
||||
|
||||
}
|
||||
|
||||
async getNewBlockedTrades() {
|
||||
const unconfirmedTransactionsList = async () => {
|
||||
const myNodeInf = window.parent.reduxStore.getState().app.nodeConfig.knownNodes[window.parent.reduxStore.getState().app.nodeConfig.node]
|
||||
const myNodeUrl = myNodeInf.protocol + '://' + myNodeInf.domain + ':' + myNodeInf.port
|
||||
const unconfirmedTransactionslUrl = `${myNodeUrl}/transactions/unconfirmed?txType=MESSAGE&limit=0&reverse=true`
|
||||
|
||||
var addBlockedTrades = JSON.parse(localStorage.getItem('failedTrades') || '[]')
|
||||
|
||||
await fetch(unconfirmedTransactionslUrl).then(response => {
|
||||
return response.json()
|
||||
}).then(data => {
|
||||
data.map(item => {
|
||||
const unconfirmedNessageTimeDiff = Date.now() - item.timestamp
|
||||
const timeOneHour = 60 * 60 * 1000
|
||||
if (Number(unconfirmedNessageTimeDiff) > Number(timeOneHour)) {
|
||||
const addBlocked = {
|
||||
timestamp: item.timestamp,
|
||||
recipient: item.recipient
|
||||
}
|
||||
addBlockedTrades.push(addBlocked)
|
||||
}
|
||||
})
|
||||
localStorage.setItem("failedTrades", JSON.stringify(addBlockedTrades))
|
||||
this.blockedTradesList = JSON.parse(localStorage.getItem('failedTrades') || '[]')
|
||||
})
|
||||
}
|
||||
|
||||
await unconfirmedTransactionsList()
|
||||
|
||||
const filterUnconfirmedTransactionsList = async () => {
|
||||
let cleanBlockedTrades = this.blockedTradesList.reduce((newArray, cut) => {
|
||||
if(!newArray.some(obj => obj.recipient === cut.recipient)) {
|
||||
newArray.push(cut)
|
||||
}
|
||||
return newArray
|
||||
},[])
|
||||
localStorage.setItem("failedTrades", JSON.stringify(cleanBlockedTrades))
|
||||
this.blockedTradesList = JSON.parse(localStorage.getItem("failedTrades") || "[]")
|
||||
}
|
||||
|
||||
await filterUnconfirmedTransactionsList()
|
||||
}
|
||||
|
||||
async filterPresenceTrades() {
|
||||
this.tradesPresenceCleaned = this.preparedPresence
|
||||
|
||||
const filterPresenceList = async () => {
|
||||
this.blockedTradesList.forEach(item => {
|
||||
const toDelete = item.recipient
|
||||
this.tradesPresenceCleaned = this.tradesPresenceCleaned.filter(el => {
|
||||
return el.qortalCreatorTradeAddress !== toDelete
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
await filterPresenceList()
|
||||
|
||||
this.listedCoins.get(this.selectedCoin).openFilteredOrders = this.tradesPresenceCleaned
|
||||
this.reRenderOpenFilteredOrders()
|
||||
}
|
||||
|
||||
handleStuckTrades() {
|
||||
let tradeBotStates = []
|
||||
|
||||
@ -3341,4 +3416,4 @@ class TradePortal extends LitElement {
|
||||
}
|
||||
}
|
||||
|
||||
window.customElements.define('trade-portal', TradePortal)
|
||||
window.customElements.define('trade-portal', TradePortal)
|
Loading…
x
Reference in New Issue
Block a user