forked from Qortal/qortal-ui
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.
24 lines
1.0 KiB
24 lines
1.0 KiB
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 |
|
}
|
|
|