mirror of
https://github.com/Qortal/qortal-ui.git
synced 2025-02-14 11:15:50 +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 },
|
arrrWalletBalance: { type: Number },
|
||||||
failedTradesList: { type: Array },
|
failedTradesList: { type: Array },
|
||||||
tradesOpenBtcQortal: { type: Array },
|
tradesOpenBtcQortal: { type: Array },
|
||||||
|
myTradesOpenLtcQortal: { type: Array },
|
||||||
tradesFailedBtcQortal: { type: Array },
|
tradesFailedBtcQortal: { type: Array },
|
||||||
tradesOpenBtcQortalCleaned: { type: Array },
|
tradesOpenBtcQortalCleaned: { type: Array },
|
||||||
tradesOpenLtcQortal: { type: Array },
|
tradesOpenLtcQortal: { type: Array },
|
||||||
@ -465,6 +466,7 @@ class AppView extends connect(store)(LitElement) {
|
|||||||
this.arrrWalletBalance = 0
|
this.arrrWalletBalance = 0
|
||||||
this.failedTradesList = []
|
this.failedTradesList = []
|
||||||
this.tradesOpenBtcQortal = []
|
this.tradesOpenBtcQortal = []
|
||||||
|
this.myTradesOpenLtcQortal = []
|
||||||
this.tradesFailedBtcQortal = []
|
this.tradesFailedBtcQortal = []
|
||||||
this.tradesOpenBtcQortalCleaned = []
|
this.tradesOpenBtcQortalCleaned = []
|
||||||
this.tradesOpenLtcQortal = []
|
this.tradesOpenLtcQortal = []
|
||||||
@ -741,6 +743,7 @@ class AppView extends connect(store)(LitElement) {
|
|||||||
await this.botArrrTradebook()
|
await this.botArrrTradebook()
|
||||||
|
|
||||||
window.addEventListener('storage', async () => {
|
window.addEventListener('storage', async () => {
|
||||||
|
this.failedTradesList = JSON.parse(localStorage.getItem("failedTrades") || "[]")
|
||||||
this.tradeBotBtcBook = JSON.parse(localStorage.getItem(this.botBtcWallet) || "[]")
|
this.tradeBotBtcBook = JSON.parse(localStorage.getItem(this.botBtcWallet) || "[]")
|
||||||
this.tradeBotLtcBook = JSON.parse(localStorage.getItem(this.botLtcWallet) || "[]")
|
this.tradeBotLtcBook = JSON.parse(localStorage.getItem(this.botLtcWallet) || "[]")
|
||||||
this.tradeBotDogeBook = JSON.parse(localStorage.getItem(this.botDogeWallet) || "[]")
|
this.tradeBotDogeBook = JSON.parse(localStorage.getItem(this.botDogeWallet) || "[]")
|
||||||
@ -872,13 +875,18 @@ class AppView extends connect(store)(LitElement) {
|
|||||||
|
|
||||||
await filterUnconfirmedTransactionsBTC()
|
await filterUnconfirmedTransactionsBTC()
|
||||||
|
|
||||||
this.failedTradesList.map(item => {
|
this.tradesOpenBtcQortalCleaned = this.tradesOpenBtcQortal
|
||||||
const recipientToRemove = item.recipient
|
|
||||||
this.tradesOpenBtcQortalCleaned = this.tradesOpenBtcQortal.filter(obj => {
|
|
||||||
return obj.qortalCreatorTradeAddress !== recipientToRemove
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
|
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)
|
await appDelay(1000)
|
||||||
filterMyBotPriceTradesBTC()
|
filterMyBotPriceTradesBTC()
|
||||||
setTimeout(getOpenTradesBTC, 150000)
|
setTimeout(getOpenTradesBTC, 150000)
|
||||||
@ -925,8 +933,6 @@ class AppView extends connect(store)(LitElement) {
|
|||||||
|
|
||||||
if (this.tradeBotBtcAt.some(item => item.atAddress === this.checkBtcAlice)) {
|
if (this.tradeBotBtcAt.some(item => item.atAddress === this.checkBtcAlice)) {
|
||||||
return
|
return
|
||||||
} else {
|
|
||||||
this.tradeBotAvailableBtcQortal = this.tradeBotAvailableBtcQortal
|
|
||||||
}
|
}
|
||||||
|
|
||||||
await appDelay(1000)
|
await appDelay(1000)
|
||||||
@ -972,8 +978,6 @@ class AppView extends connect(store)(LitElement) {
|
|||||||
|
|
||||||
if (Number(botamount) === 0) {
|
if (Number(botamount) === 0) {
|
||||||
this.removeBotBTCTradebook()
|
this.removeBotBTCTradebook()
|
||||||
} else {
|
|
||||||
this.tradeBotBtcBook = this.tradeBotBtcBook
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -985,8 +989,6 @@ class AppView extends connect(store)(LitElement) {
|
|||||||
|
|
||||||
if (Number(myBotBtcFunds) < Number(checkBotBtcFunds)) {
|
if (Number(myBotBtcFunds) < Number(checkBotBtcFunds)) {
|
||||||
this.removeBotBTCTradebook()
|
this.removeBotBTCTradebook()
|
||||||
} else {
|
|
||||||
this.tradeBotBtcBook = this.tradeBotBtcBook
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1000,27 +1002,38 @@ class AppView extends connect(store)(LitElement) {
|
|||||||
timerLTC = setTimeout(getOpenTradesLTC, 150000)
|
timerLTC = setTimeout(getOpenTradesLTC, 150000)
|
||||||
} else {
|
} else {
|
||||||
await this.updateLtcWalletBalance()
|
await this.updateLtcWalletBalance()
|
||||||
const tradesOpenLtcQortalUrl = `${nodeAppUrl}/crosschain/tradeoffers?foreignBlockchain=LITECOIN&limit=0`
|
|
||||||
|
|
||||||
const tradesOpenLtcQortal = await fetch(tradesOpenLtcQortalUrl).then(response => {
|
const getTradesOpenLtcQortal = async () => {
|
||||||
return response.json()
|
const tradesOpenLtcQortalUrl = `${nodeAppUrl}/crosschain/tradeoffers?foreignBlockchain=LITECOIN&limit=0`
|
||||||
})
|
|
||||||
|
|
||||||
this.tradesOpenLtcQortal = tradesOpenLtcQortal.map(item => {
|
await fetch(tradesOpenLtcQortalUrl).then(response => {
|
||||||
const expiryTime = item.creatorPresenceExpiry
|
return response.json()
|
||||||
if (Number(expiryTime) > Date.now()) {
|
}).then(data => {
|
||||||
const calcedPrice = parseFloat(item.expectedForeignAmount) / parseFloat(item.qortAmount)
|
this.myTradesOpenLtcQortal = data
|
||||||
const roundedPrice = (Math.round(parseFloat(calcedPrice) * 1e8) / 1e8).toFixed(8)
|
})
|
||||||
return {
|
}
|
||||||
qortAmount: item.qortAmount,
|
|
||||||
price: roundedPrice,
|
await getTradesOpenLtcQortal()
|
||||||
foreignAmount: item.expectedForeignAmount,
|
|
||||||
qortalCreator: item.qortalCreator,
|
const filterTradesOpenLtcQortal = async () => {
|
||||||
qortalAtAddress: item.qortalAtAddress,
|
this.tradesOpenLtcQortal = this.myTradesOpenLtcQortal.map(item => {
|
||||||
qortalCreatorTradeAddress: item.qortalCreatorTradeAddress
|
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 unconfirmedTransactionsLTC = async () => {
|
||||||
const unconfirmedTransactionsUrlLTC = `${nodeAppUrl}/transactions/unconfirmed?txType=MESSAGE&limit=0&reverse=true`
|
const unconfirmedTransactionsUrlLTC = `${nodeAppUrl}/transactions/unconfirmed?txType=MESSAGE&limit=0&reverse=true`
|
||||||
@ -1059,13 +1072,18 @@ class AppView extends connect(store)(LitElement) {
|
|||||||
|
|
||||||
await filterUnconfirmedTransactionsLTC()
|
await filterUnconfirmedTransactionsLTC()
|
||||||
|
|
||||||
this.failedTradesList.map(item => {
|
this.tradesOpenLtcQortalCleaned = this.tradesOpenLtcQortal
|
||||||
const recipientToRemove = item.recipient
|
|
||||||
this.tradesOpenLtcQortalCleaned = this.tradesOpenLtcQortal.filter(obj => {
|
|
||||||
return obj.qortalCreatorTradeAddress !== recipientToRemove
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
|
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)
|
await appDelay(1000)
|
||||||
filterMyBotPriceTradesLTC()
|
filterMyBotPriceTradesLTC()
|
||||||
setTimeout(getOpenTradesLTC, 150000)
|
setTimeout(getOpenTradesLTC, 150000)
|
||||||
@ -1112,8 +1130,6 @@ class AppView extends connect(store)(LitElement) {
|
|||||||
|
|
||||||
if (this.tradeBotLtcAt.some(item => item.atAddress === this.checkLtcAlice)) {
|
if (this.tradeBotLtcAt.some(item => item.atAddress === this.checkLtcAlice)) {
|
||||||
return
|
return
|
||||||
} else {
|
|
||||||
this.tradeBotAvailableLtcQortal = this.tradeBotAvailableLtcQortal
|
|
||||||
}
|
}
|
||||||
|
|
||||||
await appDelay(1000)
|
await appDelay(1000)
|
||||||
@ -1159,8 +1175,6 @@ class AppView extends connect(store)(LitElement) {
|
|||||||
|
|
||||||
if (Number(botamount) === 0) {
|
if (Number(botamount) === 0) {
|
||||||
this.removeBotLTCTradebook()
|
this.removeBotLTCTradebook()
|
||||||
} else {
|
|
||||||
this.tradeBotLtcBook = this.tradeBotLtcBook
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1172,8 +1186,6 @@ class AppView extends connect(store)(LitElement) {
|
|||||||
|
|
||||||
if (Number(myBotLtcFunds) < Number(checkBotLtcFunds)) {
|
if (Number(myBotLtcFunds) < Number(checkBotLtcFunds)) {
|
||||||
this.removeBotLTCTradebook()
|
this.removeBotLTCTradebook()
|
||||||
} else {
|
|
||||||
this.tradeBotLtcBook = this.tradeBotLtcBook
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1246,13 +1258,18 @@ class AppView extends connect(store)(LitElement) {
|
|||||||
|
|
||||||
await filterUnconfirmedTransactionsDOGE()
|
await filterUnconfirmedTransactionsDOGE()
|
||||||
|
|
||||||
this.failedTradesList.map(item => {
|
this.tradesOpenDogeQortalCleaned = this.tradesOpenDogeQortal
|
||||||
const recipientToRemove = item.recipient
|
|
||||||
this.tradesOpenDogeQortalCleaned = this.tradesOpenDogeQortal.filter(obj => {
|
|
||||||
return obj.qortalCreatorTradeAddress !== recipientToRemove
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
|
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)
|
await appDelay(1000)
|
||||||
filterMyBotPriceTradesDOGE()
|
filterMyBotPriceTradesDOGE()
|
||||||
setTimeout(getOpenTradesDOGE, 150000)
|
setTimeout(getOpenTradesDOGE, 150000)
|
||||||
@ -1299,8 +1316,6 @@ class AppView extends connect(store)(LitElement) {
|
|||||||
|
|
||||||
if (this.tradeBotDogeAt.some(item => item.atAddress === this.checkDogeAlice)) {
|
if (this.tradeBotDogeAt.some(item => item.atAddress === this.checkDogeAlice)) {
|
||||||
return
|
return
|
||||||
} else {
|
|
||||||
this.tradeBotAvailableDogeQortal = this.tradeBotAvailableDogeQortal
|
|
||||||
}
|
}
|
||||||
|
|
||||||
await appDelay(1000)
|
await appDelay(1000)
|
||||||
@ -1346,8 +1361,6 @@ class AppView extends connect(store)(LitElement) {
|
|||||||
|
|
||||||
if (Number(botamount) === 0) {
|
if (Number(botamount) === 0) {
|
||||||
this.removeBotDOGETradebook()
|
this.removeBotDOGETradebook()
|
||||||
} else {
|
|
||||||
this.tradeBotDogeBook = this.tradeBotDogeBook
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1359,8 +1372,6 @@ class AppView extends connect(store)(LitElement) {
|
|||||||
|
|
||||||
if (Number(myBotDogeFunds) < Number(checkBotDogeFunds)) {
|
if (Number(myBotDogeFunds) < Number(checkBotDogeFunds)) {
|
||||||
this.removeBotDOGETradebook()
|
this.removeBotDOGETradebook()
|
||||||
} else {
|
|
||||||
this.tradeBotDogeBook = this.tradeBotDogeBook
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1433,13 +1444,18 @@ class AppView extends connect(store)(LitElement) {
|
|||||||
|
|
||||||
await filterUnconfirmedTransactionsDGB()
|
await filterUnconfirmedTransactionsDGB()
|
||||||
|
|
||||||
this.failedTradesList.map(item => {
|
this.tradesOpenDgbQortalCleaned = this.tradesOpenDgbQortal
|
||||||
const recipientToRemove = item.recipient
|
|
||||||
this.tradesOpenDgbQortalCleaned = this.tradesOpenDgbQortal.filter(obj => {
|
|
||||||
return obj.qortalCreatorTradeAddress !== recipientToRemove
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
|
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)
|
await appDelay(1000)
|
||||||
filterMyBotPriceTradesDGB()
|
filterMyBotPriceTradesDGB()
|
||||||
setTimeout(getOpenTradesDGB, 150000)
|
setTimeout(getOpenTradesDGB, 150000)
|
||||||
@ -1486,8 +1502,6 @@ class AppView extends connect(store)(LitElement) {
|
|||||||
|
|
||||||
if (this.tradeBotDgbAt.some(item => item.atAddress === this.checkDgbAlice)) {
|
if (this.tradeBotDgbAt.some(item => item.atAddress === this.checkDgbAlice)) {
|
||||||
return
|
return
|
||||||
} else {
|
|
||||||
this.tradeBotAvailableDgbQortal = this.tradeBotAvailableDgbQortal
|
|
||||||
}
|
}
|
||||||
|
|
||||||
await appDelay(1000)
|
await appDelay(1000)
|
||||||
@ -1533,8 +1547,6 @@ class AppView extends connect(store)(LitElement) {
|
|||||||
|
|
||||||
if (Number(botamount) === 0) {
|
if (Number(botamount) === 0) {
|
||||||
this.removeBotDGBTradebook()
|
this.removeBotDGBTradebook()
|
||||||
} else {
|
|
||||||
this.tradeBotDgbBook = this.tradeBotDgbBook
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1546,8 +1558,6 @@ class AppView extends connect(store)(LitElement) {
|
|||||||
|
|
||||||
if (Number(myBotDgbFunds) < Number(checkBotDgbFunds)) {
|
if (Number(myBotDgbFunds) < Number(checkBotDgbFunds)) {
|
||||||
this.removeBotDGBTradebook()
|
this.removeBotDGBTradebook()
|
||||||
} else {
|
|
||||||
this.tradeBotDgbBook = this.tradeBotDgbBook
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1620,13 +1630,18 @@ class AppView extends connect(store)(LitElement) {
|
|||||||
|
|
||||||
await filterUnconfirmedTransactionsRVN()
|
await filterUnconfirmedTransactionsRVN()
|
||||||
|
|
||||||
this.failedTradesList.map(item => {
|
this.tradesOpenRvnQortalCleaned = this.tradesOpenRvnQortal
|
||||||
const recipientToRemove = item.recipient
|
|
||||||
this.tradesOpenRvnQortalCleaned = this.tradesOpenRvnQortal.filter(obj => {
|
|
||||||
return obj.qortalCreatorTradeAddress !== recipientToRemove
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
|
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)
|
await appDelay(1000)
|
||||||
filterMyBotPriceTradesRVN()
|
filterMyBotPriceTradesRVN()
|
||||||
setTimeout(getOpenTradesRVN, 150000)
|
setTimeout(getOpenTradesRVN, 150000)
|
||||||
@ -1673,8 +1688,6 @@ class AppView extends connect(store)(LitElement) {
|
|||||||
|
|
||||||
if (this.tradeBotRvnAt.some(item => item.atAddress === this.checkRvnAlice)) {
|
if (this.tradeBotRvnAt.some(item => item.atAddress === this.checkRvnAlice)) {
|
||||||
return
|
return
|
||||||
} else {
|
|
||||||
this.tradeBotAvailableRvnQortal = this.tradeBotAvailableRvnQortal
|
|
||||||
}
|
}
|
||||||
|
|
||||||
await appDelay(1000)
|
await appDelay(1000)
|
||||||
@ -1720,8 +1733,6 @@ class AppView extends connect(store)(LitElement) {
|
|||||||
|
|
||||||
if (Number(botamount) === 0) {
|
if (Number(botamount) === 0) {
|
||||||
this.removeBotRVNTradebook()
|
this.removeBotRVNTradebook()
|
||||||
} else {
|
|
||||||
this.tradeBotRvnBook = this.tradeBotRvnBook
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1733,8 +1744,6 @@ class AppView extends connect(store)(LitElement) {
|
|||||||
|
|
||||||
if (Number(myBotRvnFunds) < Number(checkBotRvnFunds)) {
|
if (Number(myBotRvnFunds) < Number(checkBotRvnFunds)) {
|
||||||
this.removeBotRVNTradebook()
|
this.removeBotRVNTradebook()
|
||||||
} else {
|
|
||||||
this.tradeBotRvnBook = this.tradeBotRvnBook
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1807,13 +1816,18 @@ class AppView extends connect(store)(LitElement) {
|
|||||||
|
|
||||||
await filterUnconfirmedTransactionsARRR()
|
await filterUnconfirmedTransactionsARRR()
|
||||||
|
|
||||||
this.failedTradesList.map(item => {
|
this.tradesOpenArrrQortalCleaned = this.tradesOpenArrrQortal
|
||||||
const recipientToRemove = item.recipient
|
|
||||||
this.tradesOpenArrrQortalCleaned = this.tradesOpenArrrQortal.filter(obj => {
|
|
||||||
return obj.qortalCreatorTradeAddress !== recipientToRemove
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
|
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)
|
await appDelay(1000)
|
||||||
filterMyBotPriceTradesARRR()
|
filterMyBotPriceTradesARRR()
|
||||||
setTimeout(getOpenTradesARRR, 150000)
|
setTimeout(getOpenTradesARRR, 150000)
|
||||||
@ -1860,8 +1874,6 @@ class AppView extends connect(store)(LitElement) {
|
|||||||
|
|
||||||
if (this.tradeBotArrrAt.some(item => item.atAddress === this.checkArrrAlice)) {
|
if (this.tradeBotArrrAt.some(item => item.atAddress === this.checkArrrAlice)) {
|
||||||
return
|
return
|
||||||
} else {
|
|
||||||
this.tradeBotAvailableArrrQortal = this.tradeBotAvailableArrrQortal
|
|
||||||
}
|
}
|
||||||
|
|
||||||
await appDelay(1000)
|
await appDelay(1000)
|
||||||
@ -1907,8 +1919,6 @@ class AppView extends connect(store)(LitElement) {
|
|||||||
|
|
||||||
if (Number(botamount) === 0) {
|
if (Number(botamount) === 0) {
|
||||||
this.removeBotARRRTradebook()
|
this.removeBotARRRTradebook()
|
||||||
} else {
|
|
||||||
this.tradeBotArrrBook = this.tradeBotArrrBook
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1920,8 +1930,6 @@ class AppView extends connect(store)(LitElement) {
|
|||||||
|
|
||||||
if (Number(myBotArrrFunds) < Number(checkBotArrrFunds)) {
|
if (Number(myBotArrrFunds) < Number(checkBotArrrFunds)) {
|
||||||
this.removeBotARRRTradebook()
|
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 },
|
selectedAddress: { type: Object },
|
||||||
config: { type: Object },
|
config: { type: Object },
|
||||||
listedCoins: { type: Map },
|
listedCoins: { type: Map },
|
||||||
|
blockedTradesList: { type: Array },
|
||||||
|
preparedPresence: { type: Array },
|
||||||
|
tradesPresenceCleaned: { type: Array },
|
||||||
sellBtnDisable: { type: Boolean },
|
sellBtnDisable: { type: Boolean },
|
||||||
isSellLoading: { type: Boolean },
|
isSellLoading: { type: Boolean },
|
||||||
isBuyLoading: { type: Boolean },
|
isBuyLoading: { type: Boolean },
|
||||||
@ -847,6 +850,9 @@ class TradeBotPortal extends LitElement {
|
|||||||
this.selectedCoin = "LITECOIN"
|
this.selectedCoin = "LITECOIN"
|
||||||
this.selectedAddress = {}
|
this.selectedAddress = {}
|
||||||
this.config = {}
|
this.config = {}
|
||||||
|
this.blockedTradesList = []
|
||||||
|
this.preparedPresence = []
|
||||||
|
this.tradesPresenceCleaned = []
|
||||||
this.sellBtnDisable = false
|
this.sellBtnDisable = false
|
||||||
this.isSellLoading = false
|
this.isSellLoading = false
|
||||||
this.buyBtnDisable = true
|
this.buyBtnDisable = true
|
||||||
@ -2098,12 +2104,13 @@ class TradeBotPortal extends LitElement {
|
|||||||
`
|
`
|
||||||
}
|
}
|
||||||
|
|
||||||
firstUpdated() {
|
async firstUpdated() {
|
||||||
let _this = this
|
let _this = this
|
||||||
|
|
||||||
this.changeTheme()
|
this.changeTheme()
|
||||||
this.changeLanguage()
|
this.changeLanguage()
|
||||||
this.tradeFee()
|
this.tradeFee()
|
||||||
|
await this.getNewBlockedTrades()
|
||||||
|
|
||||||
this.autoHelperMessage = this.renderAutoHelperPass()
|
this.autoHelperMessage = this.renderAutoHelperPass()
|
||||||
|
|
||||||
@ -2145,7 +2152,7 @@ class TradeBotPortal extends LitElement {
|
|||||||
|
|
||||||
this.updateWalletBalance()
|
this.updateWalletBalance()
|
||||||
this.fetchWalletAddress(this.selectedCoin)
|
this.fetchWalletAddress(this.selectedCoin)
|
||||||
|
this.blockedTradesList = JSON.parse(localStorage.getItem('failedTrades') || '[]')
|
||||||
this._openOrdersGrid = this.shadowRoot.getElementById('openOrdersGrid')
|
this._openOrdersGrid = this.shadowRoot.getElementById('openOrdersGrid')
|
||||||
|
|
||||||
this._openOrdersGrid.querySelector('#priceColumn').headerRenderer = function (root) {
|
this._openOrdersGrid.querySelector('#priceColumn').headerRenderer = function (root) {
|
||||||
@ -2203,6 +2210,7 @@ class TradeBotPortal extends LitElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
window.addEventListener('storage', () => {
|
window.addEventListener('storage', () => {
|
||||||
|
this.blockedTradesList = JSON.parse(localStorage.getItem('failedTrades') || '[]')
|
||||||
this.tradeBotBtcBook = JSON.parse(localStorage.getItem(this.btcWallet) || "[]")
|
this.tradeBotBtcBook = JSON.parse(localStorage.getItem(this.btcWallet) || "[]")
|
||||||
this.tradeBotLtcBook = JSON.parse(localStorage.getItem(this.ltcWallet) || "[]")
|
this.tradeBotLtcBook = JSON.parse(localStorage.getItem(this.ltcWallet) || "[]")
|
||||||
this.tradeBotDogeBook = JSON.parse(localStorage.getItem(this.dogeWallet) || "[]")
|
this.tradeBotDogeBook = JSON.parse(localStorage.getItem(this.dogeWallet) || "[]")
|
||||||
@ -2284,6 +2292,9 @@ class TradeBotPortal extends LitElement {
|
|||||||
setInterval(() => {
|
setInterval(() => {
|
||||||
this.clearConsole()
|
this.clearConsole()
|
||||||
}, 60000)
|
}, 60000)
|
||||||
|
setInterval(() => {
|
||||||
|
this.getNewBlockedTrades()
|
||||||
|
}, 300000)
|
||||||
}
|
}
|
||||||
|
|
||||||
clearConsole() {
|
clearConsole() {
|
||||||
@ -3817,8 +3828,8 @@ class TradeBotPortal extends LitElement {
|
|||||||
return null
|
return null
|
||||||
case 'PRESENCE':
|
case 'PRESENCE':
|
||||||
this.listedCoins.get(message.data.relatedCoin).openOrders = message.data.offers
|
this.listedCoins.get(message.data.relatedCoin).openOrders = message.data.offers
|
||||||
this.listedCoins.get(message.data.relatedCoin).openFilteredOrders = message.data.filteredOffers
|
this.preparedPresence = message.data.filteredOffers
|
||||||
this.reRenderOpenFilteredOrders()
|
this.filterPresenceTrades()
|
||||||
return null
|
return null
|
||||||
default:
|
default:
|
||||||
break
|
break
|
||||||
@ -3839,6 +3850,67 @@ class TradeBotPortal extends LitElement {
|
|||||||
|
|
||||||
workers.get(this.selectedCoin).tradesConnectedWorker.postMessage({ type: "set_coin", content: this.selectedCoin })
|
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 },
|
config: { type: Object },
|
||||||
listedCoins: { type: Map },
|
listedCoins: { type: Map },
|
||||||
nodeInfo: { type: Array },
|
nodeInfo: { type: Array },
|
||||||
|
blockedTradesList: { type: Array },
|
||||||
|
preparedPresence: { type: Array },
|
||||||
|
tradesPresenceCleaned: { type: Array },
|
||||||
sellBtnDisable: { type: Boolean },
|
sellBtnDisable: { type: Boolean },
|
||||||
isSellLoading: { type: Boolean },
|
isSellLoading: { type: Boolean },
|
||||||
isBuyLoading: { type: Boolean },
|
isBuyLoading: { type: Boolean },
|
||||||
@ -853,6 +856,9 @@ class TradePortal extends LitElement {
|
|||||||
this.selectedCoin = "LITECOIN"
|
this.selectedCoin = "LITECOIN"
|
||||||
this.selectedAddress = {}
|
this.selectedAddress = {}
|
||||||
this.nodeInfo = []
|
this.nodeInfo = []
|
||||||
|
this.blockedTradesList = []
|
||||||
|
this.preparedPresence = []
|
||||||
|
this.tradesPresenceCleaned = []
|
||||||
this.config = {}
|
this.config = {}
|
||||||
this.sellBtnDisable = false
|
this.sellBtnDisable = false
|
||||||
this.isSellLoading = false
|
this.isSellLoading = false
|
||||||
@ -1462,12 +1468,13 @@ class TradePortal extends LitElement {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
firstUpdated() {
|
async firstUpdated() {
|
||||||
let _this = this
|
let _this = this
|
||||||
|
|
||||||
this.changeTheme()
|
this.changeTheme()
|
||||||
this.changeLanguage()
|
this.changeLanguage()
|
||||||
this.tradeFee()
|
this.tradeFee()
|
||||||
|
await this.getNewBlockedTrades()
|
||||||
|
|
||||||
this.tradeHelperMessage = this.renderTradeHelperPass()
|
this.tradeHelperMessage = this.renderTradeHelperPass()
|
||||||
|
|
||||||
@ -1509,6 +1516,7 @@ class TradePortal extends LitElement {
|
|||||||
|
|
||||||
this.updateWalletBalance()
|
this.updateWalletBalance()
|
||||||
this.fetchWalletAddress(this.selectedCoin)
|
this.fetchWalletAddress(this.selectedCoin)
|
||||||
|
this.blockedTradesList = JSON.parse(localStorage.getItem('failedTrades') || '[]')
|
||||||
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
this.displayTabContent('buy')
|
this.displayTabContent('buy')
|
||||||
@ -1592,6 +1600,7 @@ class TradePortal extends LitElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
window.addEventListener('storage', () => {
|
window.addEventListener('storage', () => {
|
||||||
|
this.blockedTradesList = JSON.parse(localStorage.getItem('failedTrades') || '[]')
|
||||||
const checkLanguage = localStorage.getItem('qortalLanguage')
|
const checkLanguage = localStorage.getItem('qortalLanguage')
|
||||||
const checkTheme = localStorage.getItem('qortalTheme')
|
const checkTheme = localStorage.getItem('qortalTheme')
|
||||||
|
|
||||||
@ -1694,10 +1703,15 @@ class TradePortal extends LitElement {
|
|||||||
parentEpml.imReady()
|
parentEpml.imReady()
|
||||||
|
|
||||||
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)
|
||||||
|
|
||||||
this.clearConsole()
|
this.clearConsole()
|
||||||
setInterval(() => {
|
setInterval(() => {
|
||||||
this.clearConsole()
|
this.clearConsole()
|
||||||
}, 60000)
|
}, 60000)
|
||||||
|
|
||||||
|
setInterval(() => {
|
||||||
|
this.getNewBlockedTrades()
|
||||||
|
}, 150000)
|
||||||
}
|
}
|
||||||
|
|
||||||
clearConsole() {
|
clearConsole() {
|
||||||
@ -3208,8 +3222,8 @@ class TradePortal extends LitElement {
|
|||||||
return null
|
return null
|
||||||
case 'PRESENCE':
|
case 'PRESENCE':
|
||||||
this.listedCoins.get(message.data.relatedCoin).openOrders = message.data.offers
|
this.listedCoins.get(message.data.relatedCoin).openOrders = message.data.offers
|
||||||
this.listedCoins.get(message.data.relatedCoin).openFilteredOrders = message.data.filteredOffers
|
this.preparedPresence = message.data.filteredOffers
|
||||||
this.reRenderOpenFilteredOrders()
|
this.filterPresenceTrades()
|
||||||
return null
|
return null
|
||||||
default:
|
default:
|
||||||
break
|
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() {
|
handleStuckTrades() {
|
||||||
let tradeBotStates = []
|
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