mirror of
https://github.com/haveno-dex/haveno-ts.git
synced 2025-02-22 15:39:51 -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 () => {
|
||||
|
||||
// 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) {
|
||||
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.
|
||||
*
|
||||
* @param {string} assetCode - traded asset code
|
||||
* @param {string|undefined} assetCode - traded asset code
|
||||
* @param {string|undefined} direction - "buy" or "sell" XMR (default all)
|
||||
* @return {OfferInfo[]} the user's created offers
|
||||
*/
|
||||
async getMyOffers(assetCode: string, direction?: string): Promise<OfferInfo[]> {
|
||||
async getMyOffers(assetCode?: string, direction?: string): Promise<OfferInfo[]> {
|
||||
try {
|
||||
if (!direction) return (await this.getMyOffers(assetCode, "buy")).concat(await this.getMyOffers(assetCode, "sell")); // TODO: implement in backend
|
||||
return (await this._offersClient.getMyOffers(new GetOffersRequest().setDirection(direction).setCurrencyCode(assetCode), {password: this._password})).getOffersList();
|
||||
const req = new GetOffersRequest();
|
||||
if (assetCode) req.setCurrencyCode(assetCode);
|
||||
if (direction) req.setDirection(direction);
|
||||
return (await this._offersClient.getMyOffers(req, {password: this._password})).getOffersList();
|
||||
} catch (e: any) {
|
||||
throw new HavenoError(e.message, e.code);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user