Qortal UI - Main Code Repository A User Interface for the Qortal Blockchain Project. Truly decentralized web hosting, application hosting, communications, data storage, and full infrastructure for the future global decentralized digital world.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

25 lines
984 B

import { request } from '../../../fetch-request.js'
import { deleteTradeOffer, signTradeBotTxn } from '../../../tradeRequest.js'
import { processTransaction } from '../../../createTransaction.js'
export const cancelAllOffers = async (requestObject) => {
const keyPair = requestObject.keyPair
const publicKey = requestObject.base58PublicKey
const address = requestObject.address
const getMyOpenOffers = async () => {
const res = await request('/crosschain/tradeoffers')
const myOpenTradeOrders = await res.filter(order => order.mode === "OFFERING" && order.qortalCreator === address)
return myOpenTradeOrders
}
const myOpenOffers = await getMyOpenOffers()
let response = true
myOpenOffers.forEach(async (openOffer) => {
let unsignedTxn = await deleteTradeOffer({ creatorPublicKey: publicKey, atAddress: openOffer.qortalAtAddress })
let signedTxnBytes = await signTradeBotTxn(unsignedTxn, keyPair)
await processTransaction(signedTxnBytes)
})
return response
}