update monero-ts to v0.9.4

This commit is contained in:
woodser 2023-11-13 11:02:09 -05:00
parent 56d7219fbc
commit 6787ca44b8
13 changed files with 111 additions and 60 deletions

View File

@ -1,7 +1,7 @@
import type * as grpcWeb from "grpc-web";
import { GetVersionClient, AccountClient, MoneroConnectionsClient, DisputesClient, DisputeAgentsClient, NotificationsClient, WalletsClient, PriceClient, OffersClient, PaymentAccountsClient, TradesClient, ShutdownServerClient, MoneroNodeClient } from './protobuf/GrpcServiceClientPb';
import { MarketPriceInfo, MarketDepthInfo, XmrBalanceInfo, OfferInfo, TradeInfo, XmrTx, XmrDestination, NotificationMessage, UrlConnection } from "./protobuf/grpc_pb";
import { PaymentMethod, PaymentAccountForm, PaymentAccountFormField, PaymentAccount, PaymentAccountPayload, Attachment, DisputeResult, Dispute, ChatMessage, MoneroNodeSettings } from "./protobuf/pb_pb";
import { OfferDirection, PaymentMethod, PaymentAccountForm, PaymentAccountFormField, PaymentAccount, PaymentAccountPayload, Attachment, DisputeResult, Dispute, ChatMessage, MoneroNodeSettings } from "./protobuf/pb_pb";
/**
* Haveno daemon client.
*/
@ -392,18 +392,18 @@ export default class HavenoClient {
* Get available offers to buy or sell XMR.
*
* @param {string} assetCode - traded asset code
* @param {string|undefined} direction - "buy" or "sell" (default all)
* @param {OfferDirection|undefined} direction - "buy" or "sell" (default all)
* @return {OfferInfo[]} the available offers
*/
getOffers(assetCode: string, direction?: string): Promise<OfferInfo[]>;
getOffers(assetCode: string, direction?: OfferDirection): Promise<OfferInfo[]>;
/**
* Get the user's posted offers to buy or sell XMR.
*
* @param {string|undefined} assetCode - traded asset code
* @param {string|undefined} direction - "buy" or "sell" XMR (default all)
* @param {OfferDirection|undefined} direction - get offers to buy or sell XMR (default all)
* @return {OfferInfo[]} the user's created offers
*/
getMyOffers(assetCode?: string, direction?: string): Promise<OfferInfo[]>;
getMyOffers(assetCode?: string, direction?: OfferDirection): Promise<OfferInfo[]>;
/**
* Get my offer by id.
*
@ -414,7 +414,7 @@ export default class HavenoClient {
/**
* Post an offer.
*
* @param {string} direction - "buy" or "sell" XMR
* @param {OfferDirection} direction - "buy" or "sell" XMR
* @param {bigint} amount - amount of XMR to trade
* @param {string} assetCode - asset code to trade for XMR
* @param {string} paymentAccountId - payment account id
@ -426,7 +426,7 @@ export default class HavenoClient {
* @param {number} reserveExactAmount - reserve exact amount needed for offer, incurring on-chain transaction and 10 confirmations before the offer goes live (default = false)
* @return {OfferInfo} the posted offer
*/
postOffer(direction: string, amount: bigint, assetCode: string, paymentAccountId: string, securityDepositPct: number, price?: number, marketPriceMarginPct?: number, triggerPrice?: number, minAmount?: bigint, reserveExactAmount?: boolean): Promise<OfferInfo>;
postOffer(direction: OfferDirection, amount: bigint, assetCode: string, paymentAccountId: string, securityDepositPct: number, price?: number, marketPriceMarginPct?: number, triggerPrice?: number, minAmount?: bigint, reserveExactAmount?: boolean): Promise<OfferInfo>;
/**
* Remove a posted offer, releasing its reserved funds.
*

21
dist/HavenoClient.js vendored
View File

@ -4,11 +4,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
};
Object.defineProperty(exports, "__esModule", { value: true });
const console_1 = __importDefault(require("console"));
const HavenoError_1 = __importDefault(require("./utils/HavenoError"));
const HavenoError_1 = __importDefault(require("./types/HavenoError"));
const HavenoUtils_1 = __importDefault(require("./utils/HavenoUtils"));
const TaskLooper_1 = __importDefault(require("./utils/TaskLooper"));
const GrpcServiceClientPb_1 = require("./protobuf/GrpcServiceClientPb");
const grpc_pb_1 = require("./protobuf/grpc_pb");
const pb_pb_1 = require("./protobuf/pb_pb");
/**
* Haveno daemon client.
*/
@ -921,14 +922,14 @@ class HavenoClient {
* Get available offers to buy or sell XMR.
*
* @param {string} assetCode - traded asset code
* @param {string|undefined} direction - "buy" or "sell" (default all)
* @param {OfferDirection|undefined} direction - "buy" or "sell" (default all)
* @return {OfferInfo[]} the available offers
*/
async getOffers(assetCode, direction) {
try {
if (!direction)
return (await this.getOffers(assetCode, "buy")).concat(await this.getOffers(assetCode, "sell")); // TODO: implement in backend
return (await this._offersClient.getOffers(new grpc_pb_1.GetOffersRequest().setDirection(direction).setCurrencyCode(assetCode), { password: this._password })).getOffersList();
if (direction === undefined)
return (await this.getOffers(assetCode, pb_pb_1.OfferDirection.BUY)).concat(await this.getOffers(assetCode, pb_pb_1.OfferDirection.SELL)); // TODO: implement in backend
return (await this._offersClient.getOffers(new grpc_pb_1.GetOffersRequest().setDirection(direction === pb_pb_1.OfferDirection.BUY ? "buy" : "sell").setCurrencyCode(assetCode), { password: this._password })).getOffersList();
}
catch (e) {
throw new HavenoError_1.default(e.message, e.code);
@ -938,7 +939,7 @@ class HavenoClient {
* Get the user's posted offers to buy or sell XMR.
*
* @param {string|undefined} assetCode - traded asset code
* @param {string|undefined} direction - "buy" or "sell" XMR (default all)
* @param {OfferDirection|undefined} direction - get offers to buy or sell XMR (default all)
* @return {OfferInfo[]} the user's created offers
*/
async getMyOffers(assetCode, direction) {
@ -946,8 +947,8 @@ class HavenoClient {
const req = new grpc_pb_1.GetOffersRequest();
if (assetCode)
req.setCurrencyCode(assetCode);
if (direction)
req.setDirection(direction);
if (direction !== undefined)
req.setDirection(direction === pb_pb_1.OfferDirection.BUY ? "buy" : "sell"); // TODO: request should use OfferDirection too?
return (await this._offersClient.getMyOffers(req, { password: this._password })).getOffersList();
}
catch (e) {
@ -971,7 +972,7 @@ class HavenoClient {
/**
* Post an offer.
*
* @param {string} direction - "buy" or "sell" XMR
* @param {OfferDirection} direction - "buy" or "sell" XMR
* @param {bigint} amount - amount of XMR to trade
* @param {string} assetCode - asset code to trade for XMR
* @param {string} paymentAccountId - payment account id
@ -987,7 +988,7 @@ class HavenoClient {
console_1.default.log("Posting offer with security deposit %: " + securityDepositPct);
try {
const request = new grpc_pb_1.PostOfferRequest()
.setDirection(direction)
.setDirection(direction === pb_pb_1.OfferDirection.BUY ? "buy" : "sell")
.setAmount(amount.toString())
.setCurrencyCode(assetCode)
.setPaymentAccountId(paymentAccountId)

File diff suppressed because one or more lines are too long

2
dist/index.d.ts vendored
View File

@ -1,5 +1,5 @@
import HavenoClient from "./HavenoClient";
import HavenoError from "./utils/HavenoError";
import HavenoError from "./types/HavenoError";
import HavenoUtils from "./utils/HavenoUtils";
export { HavenoClient };
export { HavenoError };

2
dist/index.js vendored
View File

@ -20,7 +20,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
exports.HavenoUtils = exports.HavenoError = exports.HavenoClient = void 0;
const HavenoClient_1 = __importDefault(require("./HavenoClient"));
exports.HavenoClient = HavenoClient_1.default;
const HavenoError_1 = __importDefault(require("./utils/HavenoError"));
const HavenoError_1 = __importDefault(require("./types/HavenoError"));
exports.HavenoError = HavenoError_1.default;
const HavenoUtils_1 = __importDefault(require("./utils/HavenoUtils"));
exports.HavenoUtils = HavenoUtils_1.default;

View File

@ -7734,7 +7734,7 @@ export enum SupportType {
REFUND = 3,
}
export enum OfferDirection {
OFFER_DIRECTION_ERROR = 0,
OFFER_DIRECTION_UNDEFINED = 0,
BUY = 1,
SELL = 2,
}

View File

@ -61579,7 +61579,7 @@ proto.io.haveno.protobuffer.SupportType = {
* @enum {number}
*/
proto.io.haveno.protobuffer.OfferDirection = {
OFFER_DIRECTION_ERROR: 0,
OFFER_DIRECTION_UNDEFINED: 0,
BUY: 1,
SELL: 2
};

File diff suppressed because one or more lines are too long

13
dist/types/HavenoError.d.ts vendored Normal file
View File

@ -0,0 +1,13 @@
/**
* Haveno error with message and code.
*/
export default class HavenoError extends Error {
code: number | undefined;
/**
* Create the error with a message and code.
*
* @param {string} msg - the error message
* @param {number} code
*/
constructor(msg: string, code?: number);
}

19
dist/types/HavenoError.js vendored Normal file
View File

@ -0,0 +1,19 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
/**
* Haveno error with message and code.
*/
class HavenoError extends Error {
/**
* Create the error with a message and code.
*
* @param {string} msg - the error message
* @param {number} code
*/
constructor(msg, code) {
super(msg);
this.code = code;
}
}
exports.default = HavenoError;
//# sourceMappingURL=HavenoError.js.map

1
dist/types/HavenoError.js.map vendored Normal file
View File

@ -0,0 +1 @@
{"version":3,"file":"HavenoError.js","sourceRoot":"","sources":["../../src/types/HavenoError.ts"],"names":[],"mappings":";;AAAA;;GAEG;AACH,MAAqB,WAAY,SAAQ,KAAK;IAI5C;;;;;OAKG;IACH,YAAY,GAAW,EAAE,IAAa;QACpC,KAAK,CAAC,GAAG,CAAC,CAAC;QACX,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;CACF;AAdD,8BAcC"}

76
package-lock.json generated
View File

@ -28,7 +28,7 @@
"eslint-plugin-import": "^2.27.5",
"eslint-plugin-jsx-a11y": "^6.7.1",
"jest": "^26.6.0",
"monero-ts": "0.9.3",
"monero-ts": "^0.9.4",
"typedoc": "^0.23.26",
"typedoc-plugin-missing-exports": "^1.0.0",
"typedoc-plugin-rename-defaults": "^0.6.4",
@ -110,12 +110,12 @@
}
},
"node_modules/@babel/generator": {
"version": "7.23.0",
"resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.23.0.tgz",
"integrity": "sha512-lN85QRR+5IbYrMWM6Y4pE/noaQtg4pNiqeNGX60eqOfo6gtEj6uw/JagelB8vVztSd7R6M5n1+PQkDbHbBRU4g==",
"version": "7.23.3",
"resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.23.3.tgz",
"integrity": "sha512-keeZWAV4LU3tW0qRi19HRpabC/ilM0HRBBzf9/k8FFiG4KVpiv0FIy4hHfLfFQZNhziCTPTmd59zoyv6DNISzg==",
"dev": true,
"dependencies": {
"@babel/types": "^7.23.0",
"@babel/types": "^7.23.3",
"@jridgewell/gen-mapping": "^0.3.2",
"@jridgewell/trace-mapping": "^0.3.17",
"jsesc": "^2.5.1"
@ -458,9 +458,9 @@
}
},
"node_modules/@babel/parser": {
"version": "7.23.0",
"resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.23.0.tgz",
"integrity": "sha512-vvPKKdMemU85V9WE/l5wZEmImpCtLqbnTvqDS2U1fJ96KrxoW7KrXhNsNCblQlg8Ck4b85yxdTyelsMUgFUXiw==",
"version": "7.23.3",
"resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.23.3.tgz",
"integrity": "sha512-uVsWNvlVsIninV2prNz/3lHCb+5CJ+e+IUBfbjToAHODtfGYLfCFuY4AU7TskI+dAKk+njsPiBjq1gKTvZOBaw==",
"dev": true,
"bin": {
"parser": "bin/babel-parser.js"
@ -1714,9 +1714,9 @@
"dev": true
},
"node_modules/@babel/runtime": {
"version": "7.23.1",
"resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.23.1.tgz",
"integrity": "sha512-hC2v6p8ZSI/W0HUzh3V8C5g+NwSKzKPtJwSpTjwl0o297GP9+ZLQSkdvHz46CM3LqyoXxq+5G9komY+eSqSO0g==",
"version": "7.23.2",
"resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.23.2.tgz",
"integrity": "sha512-mM8eg4yl5D6i3lu2QKPuPH4FArvJ8KhTofbE7jwMUv9KX5mBvwPAqnV3MlyBNqdp9RyRKP6Yck8TrfYrPvX3bg==",
"dev": true,
"dependencies": {
"regenerator-runtime": "^0.14.0"
@ -1740,19 +1740,19 @@
}
},
"node_modules/@babel/traverse": {
"version": "7.23.0",
"resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.23.0.tgz",
"integrity": "sha512-t/QaEvyIoIkwzpiZ7aoSKK8kObQYeF7T2v+dazAYCb8SXtp58zEVkWW7zAnju8FNKNdr4ScAOEDmMItbyOmEYw==",
"version": "7.23.3",
"resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.23.3.tgz",
"integrity": "sha512-+K0yF1/9yR0oHdE0StHuEj3uTPzwwbrLGfNOndVJVV2TqA5+j3oljJUb4nmB954FLGjNem976+B+eDuLIjesiQ==",
"dev": true,
"dependencies": {
"@babel/code-frame": "^7.22.13",
"@babel/generator": "^7.23.0",
"@babel/generator": "^7.23.3",
"@babel/helper-environment-visitor": "^7.22.20",
"@babel/helper-function-name": "^7.23.0",
"@babel/helper-hoist-variables": "^7.22.5",
"@babel/helper-split-export-declaration": "^7.22.6",
"@babel/parser": "^7.23.0",
"@babel/types": "^7.23.0",
"@babel/parser": "^7.23.3",
"@babel/types": "^7.23.3",
"debug": "^4.1.0",
"globals": "^11.1.0"
},
@ -1761,9 +1761,9 @@
}
},
"node_modules/@babel/types": {
"version": "7.23.0",
"resolved": "https://registry.npmjs.org/@babel/types/-/types-7.23.0.tgz",
"integrity": "sha512-0oIyUfKoI3mSqMvsxBdclDwxXKXAUA8v/apZbc+iSyARYou1o8ZGDxbUYyLFoW2arqS2jDGqJuZvv1d/io1axg==",
"version": "7.23.3",
"resolved": "https://registry.npmjs.org/@babel/types/-/types-7.23.3.tgz",
"integrity": "sha512-OZnvoH2l8PK5eUvEcUyCt/sXgr/h+UWpVuBbOljwcrAgUl6lpchoQ++PHGyQy1AtYnVA6CEq3y5xeEI10brpXw==",
"dev": true,
"dependencies": {
"@babel/helper-string-parser": "^7.22.5",
@ -5472,9 +5472,9 @@
}
},
"node_modules/crypto-js": {
"version": "4.1.1",
"resolved": "https://registry.npmjs.org/crypto-js/-/crypto-js-4.1.1.tgz",
"integrity": "sha512-o2JlM7ydqd3Qk9CA0L4NL6mTzU2sdx96a+oOfPu8Mkl/PK51vSyoi8/rQ8NknZtk44vq15lmhAj9CIAGwgeWKw==",
"version": "4.2.0",
"resolved": "https://registry.npmjs.org/crypto-js/-/crypto-js-4.2.0.tgz",
"integrity": "sha512-KALDyEYgpY+Rlob/iriUtjV6d5Eq+Y191A5g4UqLAi8CyGP9N1+FdVbkc1SxKc2r4YAYqG8JzO2KGL+AizD70Q==",
"dev": true
},
"node_modules/cssom": {
@ -11905,11 +11905,12 @@
}
},
"node_modules/monero-ts": {
"version": "0.9.3",
"resolved": "https://registry.npmjs.org/monero-ts/-/monero-ts-0.9.3.tgz",
"integrity": "sha512-21HGBkBTx+J7vu/HiRmyXi81ET+4eucBHVFEpaqoT1i9/u8ed5V0YdN6G425XplijfYlqs5L6CAlvdwM0Pbz7A==",
"version": "0.9.4",
"resolved": "https://registry.npmjs.org/monero-ts/-/monero-ts-0.9.4.tgz",
"integrity": "sha512-sNQ17DMXg65S/4kQYeOrnYKCQRzIyBr7Q9CAIEQWMWJ7jfBFYeZrpnyi4dMXUJnbcLrw5IXweuiZ61dMC7tTkQ==",
"dev": true,
"dependencies": {
"@babel/runtime": "^7.23.2",
"@types/node": "^20.6.0",
"ajv": "^6.12.6",
"async": "2.6.4",
@ -11930,10 +11931,13 @@
}
},
"node_modules/monero-ts/node_modules/@types/node": {
"version": "20.8.0",
"resolved": "https://registry.npmjs.org/@types/node/-/node-20.8.0.tgz",
"integrity": "sha512-LzcWltT83s1bthcvjBmiBvGJiiUe84NWRHkw+ZV6Fr41z2FbIzvc815dk2nQ3RAKMuN2fkenM/z3Xv2QzEpYxQ==",
"dev": true
"version": "20.9.0",
"resolved": "https://registry.npmjs.org/@types/node/-/node-20.9.0.tgz",
"integrity": "sha512-nekiGu2NDb1BcVofVcEKMIwzlx4NjHlcjhoxxKBNLtz15Y1z7MYf549DFvkHSId02Ax6kGwWntIBPC3l/JZcmw==",
"dev": true,
"dependencies": {
"undici-types": "~5.26.4"
}
},
"node_modules/ms": {
"version": "2.1.2",
@ -13934,9 +13938,9 @@
"dev": true
},
"node_modules/sshpk": {
"version": "1.17.0",
"resolved": "https://registry.npmjs.org/sshpk/-/sshpk-1.17.0.tgz",
"integrity": "sha512-/9HIEs1ZXGhSPE8X6Ccm7Nam1z8KcoCqPdI7ecm1N33EzAetWahvQWVqLZtaZQ+IDKX4IyA2o0gBzqIMkAagHQ==",
"version": "1.18.0",
"resolved": "https://registry.npmjs.org/sshpk/-/sshpk-1.18.0.tgz",
"integrity": "sha512-2p2KJZTSqQ/I3+HX42EpYOa2l3f8Erv8MWKsy2I9uf4wA7yFIkXRffYdsx86y6z4vHtV8u7g+pPlr8/4ouAxsQ==",
"dev": true,
"dependencies": {
"asn1": "~0.2.3",
@ -14704,6 +14708,12 @@
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/undici-types": {
"version": "5.26.5",
"resolved": "https://registry.npmjs.org/undici-types/-/undici-types-5.26.5.tgz",
"integrity": "sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==",
"dev": true
},
"node_modules/unicode-canonical-property-names-ecmascript": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/unicode-canonical-property-names-ecmascript/-/unicode-canonical-property-names-ecmascript-2.0.0.tgz",

View File

@ -4,7 +4,9 @@
"description": "Haveno TypeScript interface",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"files": ["dist/**/*"],
"files": [
"dist/**/*"
],
"scripts": {
"prepare": "scripts/build_protobuf.sh",
"test": "node --no-experimental-fetch ./node_modules/.bin/jest",
@ -13,8 +15,13 @@
"typedoc": "typedoc ./src/index.ts --entryPointStrategy expand src/ --exclude **/*.test.ts --excludePrivate"
},
"jest": {
"testPathIgnorePatterns": ["<rootDir>/dist/", "/node_modules/"],
"globals": { "window": {} }
"testPathIgnorePatterns": [
"<rootDir>/dist/",
"/node_modules/"
],
"globals": {
"window": {}
}
},
"repository": {
"type": "git",
@ -47,7 +54,7 @@
"eslint-plugin-import": "^2.27.5",
"eslint-plugin-jsx-a11y": "^6.7.1",
"jest": "^26.6.0",
"monero-ts": "0.9.3",
"monero-ts": "^0.9.4",
"typedoc": "^0.23.26",
"typedoc-plugin-missing-exports": "^1.0.0",
"typedoc-plugin-rename-defaults": "^0.6.4",