mirror of
https://github.com/haveno-dex/haveno-ts.git
synced 2025-02-22 23:49:58 -05:00
getMyOffers() does not require asset code
This commit is contained in:
parent
ffb77bdb15
commit
30dd997810
@ -967,9 +967,18 @@ test("Can get offers (CI)", async () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test("Can get my offers (CI)", async () => {
|
test("Can get my offers (CI)", async () => {
|
||||||
|
|
||||||
|
// get all offers
|
||||||
|
const offers: OfferInfo[] = await user1.getMyOffers();
|
||||||
|
for (const offer of offers) testOffer(offer);
|
||||||
|
|
||||||
|
// get offers by asset code
|
||||||
for (const assetCode of TestConfig.assetCodes) {
|
for (const assetCode of TestConfig.assetCodes) {
|
||||||
const offers: OfferInfo[] = await user1.getMyOffers(assetCode);
|
const offers: OfferInfo[] = await user1.getMyOffers(assetCode);
|
||||||
for (const offer of offers) testOffer(offer);
|
for (const offer of offers) {
|
||||||
|
testOffer(offer);
|
||||||
|
expect(assetCode).toEqual(isCrypto(assetCode) ? offer.getBaseCurrencyCode() : offer.getCounterCurrencyCode()); // crypto asset codes are base
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -958,14 +958,16 @@ export default class HavenoClient {
|
|||||||
/**
|
/**
|
||||||
* Get the user's posted offers to buy or sell XMR.
|
* Get the user's posted offers to buy or sell XMR.
|
||||||
*
|
*
|
||||||
* @param {string} assetCode - traded asset code
|
* @param {string|undefined} assetCode - traded asset code
|
||||||
* @param {string|undefined} direction - "buy" or "sell" XMR (default all)
|
* @param {string|undefined} direction - "buy" or "sell" XMR (default all)
|
||||||
* @return {OfferInfo[]} the user's created offers
|
* @return {OfferInfo[]} the user's created offers
|
||||||
*/
|
*/
|
||||||
async getMyOffers(assetCode: string, direction?: string): Promise<OfferInfo[]> {
|
async getMyOffers(assetCode?: string, direction?: string): Promise<OfferInfo[]> {
|
||||||
try {
|
try {
|
||||||
if (!direction) return (await this.getMyOffers(assetCode, "buy")).concat(await this.getMyOffers(assetCode, "sell")); // TODO: implement in backend
|
const req = new GetOffersRequest();
|
||||||
return (await this._offersClient.getMyOffers(new GetOffersRequest().setDirection(direction).setCurrencyCode(assetCode), {password: this._password})).getOffersList();
|
if (assetCode) req.setCurrencyCode(assetCode);
|
||||||
|
if (direction) req.setDirection(direction);
|
||||||
|
return (await this._offersClient.getMyOffers(req, {password: this._password})).getOffersList();
|
||||||
} catch (e: any) {
|
} catch (e: any) {
|
||||||
throw new HavenoError(e.message, e.code);
|
throw new HavenoError(e.message, e.code);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user