mirror of
https://github.com/haveno-dex/haveno-ts.git
synced 2024-12-24 06:49:28 -05:00
update typedocs and dist
This commit is contained in:
parent
f3469f067a
commit
476d566a7f
22
dist/HavenoClient.d.ts
vendored
22
dist/HavenoClient.d.ts
vendored
@ -30,6 +30,7 @@ export default class HavenoClient {
|
||||
_registerNotificationListenerCalled: boolean;
|
||||
_keepAliveLooper: any;
|
||||
_keepAlivePeriodMs: number;
|
||||
_paymentMethods: PaymentMethod[] | undefined;
|
||||
static readonly _fullyInitializedMessage = "Application fully initialized";
|
||||
static readonly _loginRequiredMessage = "Interactive login required";
|
||||
/**
|
||||
@ -296,17 +297,25 @@ export default class HavenoClient {
|
||||
* @return {string} the hash of the relayed transaction
|
||||
*/
|
||||
relayXmrTx(metadata: string): Promise<string>;
|
||||
/**
|
||||
* Get all supported assets codes.
|
||||
*
|
||||
* TODO: replace this with getSupportedAssetCodes(): Promise<TradeCurrency[]>)
|
||||
*
|
||||
* @return {Promise<string[]>} all supported trade assets
|
||||
*/
|
||||
getSupportedAssetCodes(): Promise<string[]>;
|
||||
/**
|
||||
* Get the current market price per 1 XMR in the given currency.
|
||||
*
|
||||
* @param {string} currencyCode - currency code (fiat or crypto) to get the price of
|
||||
* @return {number} the current market price per 1 XMR in the given currency
|
||||
* @param {string} assetCode - asset code to get the price of
|
||||
* @return {number} the price of the asset per 1 XMR
|
||||
*/
|
||||
getPrice(currencyCode: string): Promise<number>;
|
||||
getPrice(assetCode: string): Promise<number>;
|
||||
/**
|
||||
* Get the current market prices of all currencies.
|
||||
* Get the current market prices of all a.
|
||||
*
|
||||
* @return {MarketPrice[]} price per 1 XMR in all supported currencies (fiat & crypto)
|
||||
* @return {MarketPrice[]} prices of the assets per 1 XMR
|
||||
*/
|
||||
getPrices(): Promise<MarketPriceInfo[]>;
|
||||
/**
|
||||
@ -319,9 +328,10 @@ export default class HavenoClient {
|
||||
/**
|
||||
* Get payment methods.
|
||||
*
|
||||
* @param {string} assetCode - get payment methods supporting this asset code (optional)
|
||||
* @return {PaymentMethod[]} the payment methods
|
||||
*/
|
||||
getPaymentMethods(): Promise<PaymentMethod[]>;
|
||||
getPaymentMethods(assetCode?: string): Promise<PaymentMethod[]>;
|
||||
/**
|
||||
* Get payment accounts.
|
||||
*
|
||||
|
234
dist/HavenoClient.js
vendored
234
dist/HavenoClient.js
vendored
@ -1,13 +1,18 @@
|
||||
import console from "console";
|
||||
import HavenoUtils from "./utils/HavenoUtils";
|
||||
import TaskLooper from "./utils/TaskLooper";
|
||||
import { GetVersionClient, AccountClient, MoneroConnectionsClient, DisputesClient, DisputeAgentsClient, NotificationsClient, WalletsClient, PriceClient, OffersClient, PaymentAccountsClient, TradesClient, ShutdownServerClient, MoneroNodeClient } from './protobuf/GrpcServiceClientPb';
|
||||
import { GetVersionRequest, IsAppInitializedRequest, RegisterDisputeAgentRequest, MarketPriceRequest, MarketPricesRequest, MarketDepthRequest, GetBalancesRequest, GetMyOfferRequest, GetOffersRequest, GetPaymentMethodsRequest, GetPaymentAccountFormRequest, CreatePaymentAccountRequest, GetPaymentAccountsRequest, CreateCryptoCurrencyPaymentAccountRequest, CreateOfferRequest, CancelOfferRequest, TakeOfferRequest, GetTradeRequest, GetTradesRequest, GetXmrSeedRequest, GetNewDepositAddressRequest, ConfirmPaymentStartedRequest, ConfirmPaymentReceivedRequest, GetXmrTxsRequest, CreateXmrTxRequest, RelayXmrTxRequest, CreateAccountRequest, AccountExistsRequest, DeleteAccountRequest, OpenAccountRequest, IsAccountOpenRequest, CloseAccountRequest, ChangePasswordRequest, BackupAccountRequest, RestoreAccountRequest, StopRequest, NotificationMessage, RegisterNotificationListenerRequest, SendNotificationRequest, UrlConnection, AddConnectionRequest, RemoveConnectionRequest, GetConnectionRequest, GetConnectionsRequest, SetConnectionRequest, CheckConnectionRequest, CheckConnectionsRequest, StartCheckingConnectionsRequest, StopCheckingConnectionsRequest, GetBestAvailableConnectionRequest, SetAutoSwitchRequest, GetDisputeRequest, GetDisputesRequest, OpenDisputeRequest, ResolveDisputeRequest, SendDisputeChatMessageRequest, SendChatMessageRequest, GetChatMessagesRequest, StartMoneroNodeRequest, StopMoneroNodeRequest, IsMoneroNodeRunningRequest, GetMoneroNodeSettingsRequest } from "./protobuf/grpc_pb";
|
||||
import { AvailabilityResult } from "./protobuf/pb_pb";
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const console_1 = __importDefault(require("console"));
|
||||
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.
|
||||
*/
|
||||
export default class HavenoClient {
|
||||
class HavenoClient {
|
||||
/**
|
||||
* Construct a client connected to a Haveno daemon.
|
||||
*
|
||||
@ -23,22 +28,22 @@ export default class HavenoClient {
|
||||
throw new Error("Must provide URL of Haveno daemon");
|
||||
if (!password)
|
||||
throw new Error("Must provide password of Haveno daemon");
|
||||
HavenoUtils.log(2, "Creating Haveno client connected to " + url);
|
||||
HavenoUtils_1.default.log(2, "Creating Haveno client connected to " + url);
|
||||
this._url = url;
|
||||
this._password = password;
|
||||
this._getVersionClient = new GetVersionClient(this._url);
|
||||
this._accountClient = new AccountClient(this._url);
|
||||
this._moneroConnectionsClient = new MoneroConnectionsClient(this._url);
|
||||
this._moneroNodeClient = new MoneroNodeClient(this._url);
|
||||
this._disputeAgentsClient = new DisputeAgentsClient(this._url);
|
||||
this._disputesClient = new DisputesClient(this._url);
|
||||
this._walletsClient = new WalletsClient(this._url);
|
||||
this._priceClient = new PriceClient(this._url);
|
||||
this._paymentAccountsClient = new PaymentAccountsClient(this._url);
|
||||
this._offersClient = new OffersClient(this._url);
|
||||
this._tradesClient = new TradesClient(this._url);
|
||||
this._notificationsClient = new NotificationsClient(this._url);
|
||||
this._shutdownServerClient = new ShutdownServerClient(this._url);
|
||||
this._getVersionClient = new GrpcServiceClientPb_1.GetVersionClient(this._url);
|
||||
this._accountClient = new GrpcServiceClientPb_1.AccountClient(this._url);
|
||||
this._moneroConnectionsClient = new GrpcServiceClientPb_1.MoneroConnectionsClient(this._url);
|
||||
this._moneroNodeClient = new GrpcServiceClientPb_1.MoneroNodeClient(this._url);
|
||||
this._disputeAgentsClient = new GrpcServiceClientPb_1.DisputeAgentsClient(this._url);
|
||||
this._disputesClient = new GrpcServiceClientPb_1.DisputesClient(this._url);
|
||||
this._walletsClient = new GrpcServiceClientPb_1.WalletsClient(this._url);
|
||||
this._priceClient = new GrpcServiceClientPb_1.PriceClient(this._url);
|
||||
this._paymentAccountsClient = new GrpcServiceClientPb_1.PaymentAccountsClient(this._url);
|
||||
this._offersClient = new GrpcServiceClientPb_1.OffersClient(this._url);
|
||||
this._tradesClient = new GrpcServiceClientPb_1.TradesClient(this._url);
|
||||
this._notificationsClient = new GrpcServiceClientPb_1.NotificationsClient(this._url);
|
||||
this._shutdownServerClient = new GrpcServiceClientPb_1.ShutdownServerClient(this._url);
|
||||
}
|
||||
/**
|
||||
* Start a new Haveno process.
|
||||
@ -52,7 +57,7 @@ export default class HavenoClient {
|
||||
static async startProcess(havenoPath, cmd, url, enableLogging) {
|
||||
// return promise which resolves after starting havenod
|
||||
return new Promise((resolve, reject) => {
|
||||
HavenoUtils.log(2, "Starting Haveno process: " + cmd + " on proxy url: " + url);
|
||||
HavenoUtils_1.default.log(2, "Starting Haveno process: " + cmd + " on proxy url: " + url);
|
||||
// state variables
|
||||
let output = "";
|
||||
let isStarted = false;
|
||||
@ -114,12 +119,12 @@ export default class HavenoClient {
|
||||
});
|
||||
// handle uncaught exception
|
||||
childProcess.on("uncaughtException", async function (err, origin) {
|
||||
console.error("Uncaught exception in Haveno process: " + err.message);
|
||||
console.error(origin);
|
||||
console_1.default.error("Uncaught exception in Haveno process: " + err.message);
|
||||
console_1.default.error(origin);
|
||||
await rejectStartup(err);
|
||||
});
|
||||
async function rejectStartup(err) {
|
||||
await HavenoUtils.kill(childProcess);
|
||||
await HavenoUtils_1.default.kill(childProcess);
|
||||
reject(err);
|
||||
}
|
||||
function loggingEnabled() {
|
||||
@ -174,7 +179,7 @@ export default class HavenoClient {
|
||||
*/
|
||||
async getVersion() {
|
||||
return new Promise((resolve, reject) => {
|
||||
this._getVersionClient.getVersion(new GetVersionRequest(), { password: this._password }, function (err, response) {
|
||||
this._getVersionClient.getVersion(new grpc_pb_1.GetVersionRequest(), { password: this._password }, function (err, response) {
|
||||
if (err)
|
||||
reject(err);
|
||||
else
|
||||
@ -203,7 +208,7 @@ export default class HavenoClient {
|
||||
*/
|
||||
async accountExists() {
|
||||
return new Promise((resolve, reject) => {
|
||||
this._accountClient.accountExists(new AccountExistsRequest(), { password: this._password }, function (err, response) {
|
||||
this._accountClient.accountExists(new grpc_pb_1.AccountExistsRequest(), { password: this._password }, function (err, response) {
|
||||
if (err)
|
||||
reject(err);
|
||||
else
|
||||
@ -218,7 +223,7 @@ export default class HavenoClient {
|
||||
*/
|
||||
async isAccountOpen() {
|
||||
return new Promise((resolve, reject) => {
|
||||
this._accountClient.isAccountOpen(new IsAccountOpenRequest(), { password: this._password }, function (err, response) {
|
||||
this._accountClient.isAccountOpen(new grpc_pb_1.IsAccountOpenRequest(), { password: this._password }, function (err, response) {
|
||||
if (err)
|
||||
reject(err);
|
||||
else
|
||||
@ -233,7 +238,7 @@ export default class HavenoClient {
|
||||
*/
|
||||
async createAccount(password) {
|
||||
await new Promise((resolve, reject) => {
|
||||
this._accountClient.createAccount(new CreateAccountRequest().setPassword(password), { password: this._password }, function (err) {
|
||||
this._accountClient.createAccount(new grpc_pb_1.CreateAccountRequest().setPassword(password), { password: this._password }, function (err) {
|
||||
if (err)
|
||||
reject(err);
|
||||
else
|
||||
@ -249,7 +254,7 @@ export default class HavenoClient {
|
||||
*/
|
||||
async openAccount(password) {
|
||||
await new Promise((resolve, reject) => {
|
||||
this._accountClient.openAccount(new OpenAccountRequest().setPassword(password), { password: this._password }, function (err) {
|
||||
this._accountClient.openAccount(new grpc_pb_1.OpenAccountRequest().setPassword(password), { password: this._password }, function (err) {
|
||||
if (err)
|
||||
reject(err);
|
||||
else
|
||||
@ -265,7 +270,7 @@ export default class HavenoClient {
|
||||
*/
|
||||
async changePassword(password) {
|
||||
return new Promise((resolve, reject) => {
|
||||
this._accountClient.changePassword(new ChangePasswordRequest().setPassword(password), { password: this._password }, function (err) {
|
||||
this._accountClient.changePassword(new grpc_pb_1.ChangePasswordRequest().setPassword(password), { password: this._password }, function (err) {
|
||||
if (err)
|
||||
reject(err);
|
||||
else
|
||||
@ -278,7 +283,7 @@ export default class HavenoClient {
|
||||
*/
|
||||
async closeAccount() {
|
||||
return new Promise((resolve, reject) => {
|
||||
this._accountClient.closeAccount(new CloseAccountRequest(), { password: this._password }, function (err) {
|
||||
this._accountClient.closeAccount(new grpc_pb_1.CloseAccountRequest(), { password: this._password }, function (err) {
|
||||
if (err)
|
||||
reject(err);
|
||||
else
|
||||
@ -291,7 +296,7 @@ export default class HavenoClient {
|
||||
*/
|
||||
async deleteAccount() {
|
||||
return new Promise((resolve, reject) => {
|
||||
this._accountClient.deleteAccount(new DeleteAccountRequest(), { password: this._password }, async function (err) {
|
||||
this._accountClient.deleteAccount(new grpc_pb_1.DeleteAccountRequest(), { password: this._password }, async function (err) {
|
||||
if (err)
|
||||
reject(err);
|
||||
else
|
||||
@ -305,7 +310,7 @@ export default class HavenoClient {
|
||||
async backupAccount(stream) {
|
||||
return new Promise((resolve, reject) => {
|
||||
let total = 0;
|
||||
const response = this._accountClient.backupAccount(new BackupAccountRequest(), { password: this._password });
|
||||
const response = this._accountClient.backupAccount(new grpc_pb_1.BackupAccountRequest(), { password: this._password });
|
||||
response.on('data', (chunk) => {
|
||||
const bytes = chunk.getZipBytes(); // TODO: right api?
|
||||
total += bytes.length;
|
||||
@ -377,8 +382,8 @@ export default class HavenoClient {
|
||||
async isConnectedToMonero() {
|
||||
const connection = await this.getMoneroConnection();
|
||||
return connection !== undefined &&
|
||||
connection.getOnlineStatus() === UrlConnection.OnlineStatus.ONLINE &&
|
||||
connection.getAuthenticationStatus() !== UrlConnection.AuthenticationStatus.NOT_AUTHENTICATED;
|
||||
connection.getOnlineStatus() === grpc_pb_1.UrlConnection.OnlineStatus.ONLINE &&
|
||||
connection.getAuthenticationStatus() !== grpc_pb_1.UrlConnection.AuthenticationStatus.NOT_AUTHENTICATED;
|
||||
}
|
||||
/**
|
||||
* Add a Monero daemon connection.
|
||||
@ -387,7 +392,7 @@ export default class HavenoClient {
|
||||
*/
|
||||
async addMoneroConnection(connection) {
|
||||
return new Promise((resolve, reject) => {
|
||||
this._moneroConnectionsClient.addConnection(new AddConnectionRequest().setConnection(typeof connection === "string" ? new UrlConnection().setUrl(connection) : connection), { password: this._password }, function (err) {
|
||||
this._moneroConnectionsClient.addConnection(new grpc_pb_1.AddConnectionRequest().setConnection(typeof connection === "string" ? new grpc_pb_1.UrlConnection().setUrl(connection) : connection), { password: this._password }, function (err) {
|
||||
if (err)
|
||||
reject(err);
|
||||
else
|
||||
@ -402,7 +407,7 @@ export default class HavenoClient {
|
||||
*/
|
||||
async removeMoneroConnection(url) {
|
||||
return new Promise((resolve, reject) => {
|
||||
this._moneroConnectionsClient.removeConnection(new RemoveConnectionRequest().setUrl(url), { password: this._password }, function (err) {
|
||||
this._moneroConnectionsClient.removeConnection(new grpc_pb_1.RemoveConnectionRequest().setUrl(url), { password: this._password }, function (err) {
|
||||
if (err)
|
||||
reject(err);
|
||||
else
|
||||
@ -417,7 +422,7 @@ export default class HavenoClient {
|
||||
*/
|
||||
async getMoneroConnection() {
|
||||
return new Promise((resolve, reject) => {
|
||||
this._moneroConnectionsClient.getConnection(new GetConnectionRequest(), { password: this._password }, function (err, response) {
|
||||
this._moneroConnectionsClient.getConnection(new grpc_pb_1.GetConnectionRequest(), { password: this._password }, function (err, response) {
|
||||
if (err)
|
||||
reject(err);
|
||||
else
|
||||
@ -432,7 +437,7 @@ export default class HavenoClient {
|
||||
*/
|
||||
async getMoneroConnections() {
|
||||
return new Promise((resolve, reject) => {
|
||||
this._moneroConnectionsClient.getConnections(new GetConnectionsRequest(), { password: this._password }, function (err, response) {
|
||||
this._moneroConnectionsClient.getConnections(new grpc_pb_1.GetConnectionsRequest(), { password: this._password }, function (err, response) {
|
||||
if (err)
|
||||
reject(err);
|
||||
else
|
||||
@ -451,7 +456,7 @@ export default class HavenoClient {
|
||||
* @param {string | UrlConnection} connection - connection to set as current
|
||||
*/
|
||||
async setMoneroConnection(connection) {
|
||||
const request = new SetConnectionRequest();
|
||||
const request = new grpc_pb_1.SetConnectionRequest();
|
||||
if (typeof connection === "string")
|
||||
request.setUrl(connection);
|
||||
else
|
||||
@ -474,7 +479,7 @@ export default class HavenoClient {
|
||||
*/
|
||||
async checkMoneroConnection() {
|
||||
return new Promise((resolve, reject) => {
|
||||
this._moneroConnectionsClient.checkConnection(new CheckConnectionRequest(), { password: this._password }, function (err, response) {
|
||||
this._moneroConnectionsClient.checkConnection(new grpc_pb_1.CheckConnectionRequest(), { password: this._password }, function (err, response) {
|
||||
if (err)
|
||||
reject(err);
|
||||
else
|
||||
@ -489,7 +494,7 @@ export default class HavenoClient {
|
||||
*/
|
||||
async checkMoneroConnections() {
|
||||
return new Promise((resolve, reject) => {
|
||||
this._moneroConnectionsClient.checkConnections(new CheckConnectionsRequest(), { password: this._password }, function (err, response) {
|
||||
this._moneroConnectionsClient.checkConnections(new grpc_pb_1.CheckConnectionsRequest(), { password: this._password }, function (err, response) {
|
||||
if (err)
|
||||
reject(err);
|
||||
else
|
||||
@ -504,7 +509,7 @@ export default class HavenoClient {
|
||||
*/
|
||||
async startCheckingConnection(refreshPeriod) {
|
||||
return new Promise((resolve, reject) => {
|
||||
this._moneroConnectionsClient.startCheckingConnections(new StartCheckingConnectionsRequest().setRefreshPeriod(refreshPeriod), { password: this._password }, function (err) {
|
||||
this._moneroConnectionsClient.startCheckingConnections(new grpc_pb_1.StartCheckingConnectionsRequest().setRefreshPeriod(refreshPeriod), { password: this._password }, function (err) {
|
||||
if (err)
|
||||
reject(err);
|
||||
else
|
||||
@ -517,7 +522,7 @@ export default class HavenoClient {
|
||||
*/
|
||||
async stopCheckingConnection() {
|
||||
return new Promise((resolve, reject) => {
|
||||
this._moneroConnectionsClient.stopCheckingConnections(new StopCheckingConnectionsRequest(), { password: this._password }, function (err) {
|
||||
this._moneroConnectionsClient.stopCheckingConnections(new grpc_pb_1.StopCheckingConnectionsRequest(), { password: this._password }, function (err) {
|
||||
if (err)
|
||||
reject(err);
|
||||
else
|
||||
@ -532,7 +537,7 @@ export default class HavenoClient {
|
||||
*/
|
||||
async getBestAvailableConnection() {
|
||||
return new Promise((resolve, reject) => {
|
||||
this._moneroConnectionsClient.getBestAvailableConnection(new GetBestAvailableConnectionRequest(), { password: this._password }, function (err, response) {
|
||||
this._moneroConnectionsClient.getBestAvailableConnection(new grpc_pb_1.GetBestAvailableConnectionRequest(), { password: this._password }, function (err, response) {
|
||||
if (err)
|
||||
reject(err);
|
||||
else
|
||||
@ -547,7 +552,7 @@ export default class HavenoClient {
|
||||
*/
|
||||
async setAutoSwitch(autoSwitch) {
|
||||
return new Promise((resolve, reject) => {
|
||||
this._moneroConnectionsClient.setAutoSwitch(new SetAutoSwitchRequest().setAutoSwitch(autoSwitch), { password: this._password }, function (err) {
|
||||
this._moneroConnectionsClient.setAutoSwitch(new grpc_pb_1.SetAutoSwitchRequest().setAutoSwitch(autoSwitch), { password: this._password }, function (err) {
|
||||
if (err)
|
||||
reject(err);
|
||||
else
|
||||
@ -560,7 +565,7 @@ export default class HavenoClient {
|
||||
*/
|
||||
async isMoneroNodeRunning() {
|
||||
return new Promise((resolve, reject) => {
|
||||
this._moneroNodeClient.isMoneroNodeRunning(new IsMoneroNodeRunningRequest(), { password: this._password }, function (err, response) {
|
||||
this._moneroNodeClient.isMoneroNodeRunning(new grpc_pb_1.IsMoneroNodeRunningRequest(), { password: this._password }, function (err, response) {
|
||||
if (err)
|
||||
reject(err);
|
||||
else
|
||||
@ -573,7 +578,7 @@ export default class HavenoClient {
|
||||
*/
|
||||
async getMoneroNodeSettings() {
|
||||
return new Promise((resolve, reject) => {
|
||||
const request = new GetMoneroNodeSettingsRequest();
|
||||
const request = new grpc_pb_1.GetMoneroNodeSettingsRequest();
|
||||
this._moneroNodeClient.getMoneroNodeSettings(request, { password: this._password }, function (err, response) {
|
||||
if (err)
|
||||
reject(err);
|
||||
@ -589,7 +594,7 @@ export default class HavenoClient {
|
||||
*/
|
||||
async startMoneroNode(settings) {
|
||||
return new Promise((resolve, reject) => {
|
||||
const request = new StartMoneroNodeRequest().setSettings(settings);
|
||||
const request = new grpc_pb_1.StartMoneroNodeRequest().setSettings(settings);
|
||||
this._moneroNodeClient.startMoneroNode(request, { password: this._password }, function (err) {
|
||||
if (err)
|
||||
reject(err);
|
||||
@ -603,7 +608,7 @@ export default class HavenoClient {
|
||||
*/
|
||||
async stopMoneroNode() {
|
||||
return new Promise((resolve, reject) => {
|
||||
this._moneroNodeClient.stopMoneroNode(new StopMoneroNodeRequest(), { password: this._password }, function (err) {
|
||||
this._moneroNodeClient.stopMoneroNode(new grpc_pb_1.StopMoneroNodeRequest(), { password: this._password }, function (err) {
|
||||
if (err)
|
||||
reject(err);
|
||||
else
|
||||
@ -618,7 +623,7 @@ export default class HavenoClient {
|
||||
* @param {string} registrationKey - registration key
|
||||
*/
|
||||
async registerDisputeAgent(disputeAgentType, registrationKey) {
|
||||
const request = new RegisterDisputeAgentRequest()
|
||||
const request = new grpc_pb_1.RegisterDisputeAgentRequest()
|
||||
.setDisputeAgentType(disputeAgentType)
|
||||
.setRegistrationKey(registrationKey);
|
||||
return new Promise((resolve, reject) => {
|
||||
@ -637,7 +642,7 @@ export default class HavenoClient {
|
||||
*/
|
||||
async getBalances() {
|
||||
return new Promise((resolve, reject) => {
|
||||
this._walletsClient.getBalances(new GetBalancesRequest().setCurrencyCode("XMR"), { password: this._password }, function (err, response) {
|
||||
this._walletsClient.getBalances(new grpc_pb_1.GetBalancesRequest().setCurrencyCode("XMR"), { password: this._password }, function (err, response) {
|
||||
if (err)
|
||||
reject(err);
|
||||
else
|
||||
@ -652,7 +657,7 @@ export default class HavenoClient {
|
||||
*/
|
||||
async getXmrSeed() {
|
||||
return new Promise((resolve, reject) => {
|
||||
this._walletsClient.getXmrSeed(new GetXmrSeedRequest(), { password: this._password }, function (err, response) {
|
||||
this._walletsClient.getXmrSeed(new grpc_pb_1.GetXmrSeedRequest(), { password: this._password }, function (err, response) {
|
||||
if (err)
|
||||
reject(err);
|
||||
else
|
||||
@ -667,7 +672,7 @@ export default class HavenoClient {
|
||||
*/
|
||||
async getNewDepositAddress() {
|
||||
return new Promise((resolve, reject) => {
|
||||
this._walletsClient.getNewDepositAddress(new GetNewDepositAddressRequest(), { password: this._password }, function (err, response) {
|
||||
this._walletsClient.getNewDepositAddress(new grpc_pb_1.GetNewDepositAddressRequest(), { password: this._password }, function (err, response) {
|
||||
if (err)
|
||||
reject(err);
|
||||
else
|
||||
@ -682,7 +687,7 @@ export default class HavenoClient {
|
||||
*/
|
||||
async getXmrTxs() {
|
||||
return new Promise((resolve, reject) => {
|
||||
this._walletsClient.getXmrTxs(new GetXmrTxsRequest(), { password: this._password }, function (err, response) {
|
||||
this._walletsClient.getXmrTxs(new grpc_pb_1.GetXmrTxsRequest(), { password: this._password }, function (err, response) {
|
||||
if (err)
|
||||
reject(err);
|
||||
else
|
||||
@ -711,7 +716,7 @@ export default class HavenoClient {
|
||||
*/
|
||||
async createXmrTx(destinations) {
|
||||
return new Promise((resolve, reject) => {
|
||||
this._walletsClient.createXmrTx(new CreateXmrTxRequest().setDestinationsList(destinations), { password: this._password }, function (err, response) {
|
||||
this._walletsClient.createXmrTx(new grpc_pb_1.CreateXmrTxRequest().setDestinationsList(destinations), { password: this._password }, function (err, response) {
|
||||
if (err)
|
||||
reject(err);
|
||||
else
|
||||
@ -726,7 +731,7 @@ export default class HavenoClient {
|
||||
*/
|
||||
async relayXmrTx(metadata) {
|
||||
return new Promise((resolve, reject) => {
|
||||
this._walletsClient.relayXmrTx(new RelayXmrTxRequest().setMetadata(metadata), { password: this._password }, function (err, response) {
|
||||
this._walletsClient.relayXmrTx(new grpc_pb_1.RelayXmrTxRequest().setMetadata(metadata), { password: this._password }, function (err, response) {
|
||||
if (err)
|
||||
reject(err);
|
||||
else
|
||||
@ -734,15 +739,28 @@ export default class HavenoClient {
|
||||
});
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Get all supported assets codes.
|
||||
*
|
||||
* TODO: replace this with getSupportedAssetCodes(): Promise<TradeCurrency[]>)
|
||||
*
|
||||
* @return {Promise<string[]>} all supported trade assets
|
||||
*/
|
||||
async getSupportedAssetCodes() {
|
||||
const assetCodes = [];
|
||||
for (const price of await this.getPrices())
|
||||
assetCodes.push(price.getCurrencyCode());
|
||||
return assetCodes;
|
||||
}
|
||||
/**
|
||||
* Get the current market price per 1 XMR in the given currency.
|
||||
*
|
||||
* @param {string} currencyCode - currency code (fiat or crypto) to get the price of
|
||||
* @return {number} the current market price per 1 XMR in the given currency
|
||||
* @param {string} assetCode - asset code to get the price of
|
||||
* @return {number} the price of the asset per 1 XMR
|
||||
*/
|
||||
async getPrice(currencyCode) {
|
||||
async getPrice(assetCode) {
|
||||
return new Promise((resolve, reject) => {
|
||||
this._priceClient.getMarketPrice(new MarketPriceRequest().setCurrencyCode(currencyCode), { password: this._password }, function (err, response) {
|
||||
this._priceClient.getMarketPrice(new grpc_pb_1.MarketPriceRequest().setCurrencyCode(assetCode), { password: this._password }, function (err, response) {
|
||||
if (err)
|
||||
reject(err);
|
||||
else
|
||||
@ -751,13 +769,13 @@ export default class HavenoClient {
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Get the current market prices of all currencies.
|
||||
* Get the current market prices of all a.
|
||||
*
|
||||
* @return {MarketPrice[]} price per 1 XMR in all supported currencies (fiat & crypto)
|
||||
* @return {MarketPrice[]} prices of the assets per 1 XMR
|
||||
*/
|
||||
async getPrices() {
|
||||
return new Promise((resolve, reject) => {
|
||||
this._priceClient.getMarketPrices(new MarketPricesRequest(), { password: this._password }, function (err, response) {
|
||||
this._priceClient.getMarketPrices(new grpc_pb_1.MarketPricesRequest(), { password: this._password }, function (err, response) {
|
||||
if (err)
|
||||
reject(err);
|
||||
else
|
||||
@ -773,7 +791,7 @@ export default class HavenoClient {
|
||||
*/
|
||||
async getMarketDepth(assetCode) {
|
||||
return new Promise((resolve, reject) => {
|
||||
this._priceClient.getMarketDepth(new MarketDepthRequest().setCurrencyCode(assetCode), { password: this._password }, function (err, response) {
|
||||
this._priceClient.getMarketDepth(new grpc_pb_1.MarketDepthRequest().setCurrencyCode(assetCode), { password: this._password }, function (err, response) {
|
||||
if (err)
|
||||
reject(err);
|
||||
else
|
||||
@ -784,11 +802,13 @@ export default class HavenoClient {
|
||||
/**
|
||||
* Get payment methods.
|
||||
*
|
||||
* @param {string} assetCode - get payment methods supporting this asset code (optional)
|
||||
* @return {PaymentMethod[]} the payment methods
|
||||
*/
|
||||
async getPaymentMethods() {
|
||||
return new Promise((resolve, reject) => {
|
||||
this._paymentAccountsClient.getPaymentMethods(new GetPaymentMethodsRequest(), { password: this._password }, function (err, response) {
|
||||
async getPaymentMethods(assetCode) {
|
||||
if (!this._paymentMethods) {
|
||||
this._paymentMethods = await new Promise((resolve, reject) => {
|
||||
this._paymentAccountsClient.getPaymentMethods(new grpc_pb_1.GetPaymentMethodsRequest(), { password: this._password }, function (err, response) {
|
||||
if (err)
|
||||
reject(err);
|
||||
else
|
||||
@ -796,6 +816,15 @@ export default class HavenoClient {
|
||||
});
|
||||
});
|
||||
}
|
||||
if (!assetCode)
|
||||
return this._paymentMethods;
|
||||
const assetPaymentMethods = [];
|
||||
for (const paymentMethod of this._paymentMethods) {
|
||||
if (paymentMethod.getSupportedAssetCodesList().includes(assetCode))
|
||||
assetPaymentMethods.push(paymentMethod);
|
||||
}
|
||||
return assetPaymentMethods;
|
||||
}
|
||||
/**
|
||||
* Get payment accounts.
|
||||
*
|
||||
@ -803,7 +832,7 @@ export default class HavenoClient {
|
||||
*/
|
||||
async getPaymentAccounts() {
|
||||
return new Promise((resolve, reject) => {
|
||||
this._paymentAccountsClient.getPaymentAccounts(new GetPaymentAccountsRequest(), { password: this._password }, function (err, response) {
|
||||
this._paymentAccountsClient.getPaymentAccounts(new grpc_pb_1.GetPaymentAccountsRequest(), { password: this._password }, function (err, response) {
|
||||
if (err)
|
||||
reject(err);
|
||||
else
|
||||
@ -833,7 +862,7 @@ export default class HavenoClient {
|
||||
*/
|
||||
async getPaymentAccountForm(paymentMethodId) {
|
||||
return new Promise((resolve, reject) => {
|
||||
this._paymentAccountsClient.getPaymentAccountForm(new GetPaymentAccountFormRequest().setPaymentMethodId(paymentMethodId), { password: this._password }, function (err, response) {
|
||||
this._paymentAccountsClient.getPaymentAccountForm(new grpc_pb_1.GetPaymentAccountFormRequest().setPaymentMethodId(paymentMethodId), { password: this._password }, function (err, response) {
|
||||
if (err)
|
||||
reject(err);
|
||||
else
|
||||
@ -849,7 +878,7 @@ export default class HavenoClient {
|
||||
*/
|
||||
async createPaymentAccount(paymentAccountForm) {
|
||||
return new Promise((resolve, reject) => {
|
||||
this._paymentAccountsClient.createPaymentAccount(new CreatePaymentAccountRequest().setPaymentAccountForm(JSON.stringify(paymentAccountForm)), { password: this._password }, function (err, response) {
|
||||
this._paymentAccountsClient.createPaymentAccount(new grpc_pb_1.CreatePaymentAccountRequest().setPaymentAccountForm(JSON.stringify(paymentAccountForm)), { password: this._password }, function (err, response) {
|
||||
if (err)
|
||||
reject(err);
|
||||
else
|
||||
@ -866,7 +895,7 @@ export default class HavenoClient {
|
||||
* @return {PaymentAccount} the created payment account
|
||||
*/
|
||||
async createCryptoPaymentAccount(accountName, assetCode, address) {
|
||||
const request = new CreateCryptoCurrencyPaymentAccountRequest()
|
||||
const request = new grpc_pb_1.CreateCryptoCurrencyPaymentAccountRequest()
|
||||
.setAccountName(accountName)
|
||||
.setCurrencyCode(assetCode)
|
||||
.setAddress(address)
|
||||
@ -891,7 +920,7 @@ export default class HavenoClient {
|
||||
if (!direction)
|
||||
return (await this.getOffers(assetCode, "buy")).concat(await this.getOffers(assetCode, "sell")); // TODO: implement in backend
|
||||
return new Promise((resolve, reject) => {
|
||||
this._offersClient.getOffers(new GetOffersRequest().setDirection(direction).setCurrencyCode(assetCode), { password: this._password }, function (err, response) {
|
||||
this._offersClient.getOffers(new grpc_pb_1.GetOffersRequest().setDirection(direction).setCurrencyCode(assetCode), { password: this._password }, function (err, response) {
|
||||
if (err)
|
||||
reject(err);
|
||||
else
|
||||
@ -910,7 +939,7 @@ export default class HavenoClient {
|
||||
if (!direction)
|
||||
return (await this.getMyOffers(assetCode, "buy")).concat(await this.getMyOffers(assetCode, "sell")); // TODO: implement in backend
|
||||
return new Promise((resolve, reject) => {
|
||||
this._offersClient.getMyOffers(new GetOffersRequest().setDirection(direction).setCurrencyCode(assetCode), { password: this._password }, function (err, response) {
|
||||
this._offersClient.getMyOffers(new grpc_pb_1.GetOffersRequest().setDirection(direction).setCurrencyCode(assetCode), { password: this._password }, function (err, response) {
|
||||
if (err)
|
||||
reject(err);
|
||||
else
|
||||
@ -926,7 +955,7 @@ export default class HavenoClient {
|
||||
*/
|
||||
async getMyOffer(offerId) {
|
||||
return new Promise((resolve, reject) => {
|
||||
this._offersClient.getMyOffer(new GetMyOfferRequest().setId(offerId), { password: this._password }, function (err, response) {
|
||||
this._offersClient.getMyOffer(new grpc_pb_1.GetMyOfferRequest().setId(offerId), { password: this._password }, function (err, response) {
|
||||
if (err)
|
||||
reject(err);
|
||||
else
|
||||
@ -949,7 +978,7 @@ export default class HavenoClient {
|
||||
* @return {OfferInfo} the posted offer
|
||||
*/
|
||||
async postOffer(direction, amount, assetCode, paymentAccountId, buyerSecurityDeposit, price, marketPriceMargin, triggerPrice, minAmount) {
|
||||
const request = new CreateOfferRequest()
|
||||
const request = new grpc_pb_1.CreateOfferRequest()
|
||||
.setDirection(direction)
|
||||
.setAmount(amount.toString())
|
||||
.setCurrencyCode(assetCode)
|
||||
@ -978,7 +1007,7 @@ export default class HavenoClient {
|
||||
*/
|
||||
async removeOffer(offerId) {
|
||||
return new Promise((resolve, reject) => {
|
||||
this._offersClient.cancelOffer(new CancelOfferRequest().setId(offerId), { password: this._password }, function (err) {
|
||||
this._offersClient.cancelOffer(new grpc_pb_1.CancelOfferRequest().setId(offerId), { password: this._password }, function (err) {
|
||||
if (err)
|
||||
reject(err);
|
||||
else
|
||||
@ -994,14 +1023,14 @@ export default class HavenoClient {
|
||||
* @return {TradeInfo} the initialized trade
|
||||
*/
|
||||
async takeOffer(offerId, paymentAccountId) {
|
||||
const request = new TakeOfferRequest()
|
||||
const request = new grpc_pb_1.TakeOfferRequest()
|
||||
.setOfferId(offerId)
|
||||
.setPaymentAccountId(paymentAccountId);
|
||||
return new Promise((resolve, reject) => {
|
||||
this._tradesClient.takeOffer(request, { password: this._password }, function (err, response) {
|
||||
if (err)
|
||||
reject(err);
|
||||
else if (response.getFailureReason() && response.getFailureReason().getAvailabilityResult() !== AvailabilityResult.AVAILABLE)
|
||||
else if (response.getFailureReason() && response.getFailureReason().getAvailabilityResult() !== pb_pb_1.AvailabilityResult.AVAILABLE)
|
||||
reject(new Error(response.getFailureReason().getDescription())); // TODO: api should throw grpcWeb.RpcError
|
||||
else
|
||||
resolve(response.getTrade());
|
||||
@ -1016,7 +1045,7 @@ export default class HavenoClient {
|
||||
*/
|
||||
async getTrade(tradeId) {
|
||||
return new Promise((resolve, reject) => {
|
||||
this._tradesClient.getTrade(new GetTradeRequest().setTradeId(tradeId), { password: this._password }, function (err, response) {
|
||||
this._tradesClient.getTrade(new grpc_pb_1.GetTradeRequest().setTradeId(tradeId), { password: this._password }, function (err, response) {
|
||||
if (err)
|
||||
reject(err);
|
||||
else
|
||||
@ -1031,7 +1060,7 @@ export default class HavenoClient {
|
||||
*/
|
||||
async getTrades() {
|
||||
return new Promise((resolve, reject) => {
|
||||
this._tradesClient.getTrades(new GetTradesRequest(), { password: this._password }, function (err, response) {
|
||||
this._tradesClient.getTrades(new grpc_pb_1.GetTradesRequest(), { password: this._password }, function (err, response) {
|
||||
if (err)
|
||||
reject(err);
|
||||
else
|
||||
@ -1046,7 +1075,7 @@ export default class HavenoClient {
|
||||
*/
|
||||
async confirmPaymentStarted(tradeId) {
|
||||
return new Promise((resolve, reject) => {
|
||||
this._tradesClient.confirmPaymentStarted(new ConfirmPaymentStartedRequest().setTradeId(tradeId), { password: this._password }, function (err) {
|
||||
this._tradesClient.confirmPaymentStarted(new grpc_pb_1.ConfirmPaymentStartedRequest().setTradeId(tradeId), { password: this._password }, function (err) {
|
||||
if (err)
|
||||
reject(err);
|
||||
else
|
||||
@ -1061,7 +1090,7 @@ export default class HavenoClient {
|
||||
*/
|
||||
async confirmPaymentReceived(tradeId) {
|
||||
return new Promise((resolve, reject) => {
|
||||
this._tradesClient.confirmPaymentReceived(new ConfirmPaymentReceivedRequest().setTradeId(tradeId), { password: this._password }, function (err) {
|
||||
this._tradesClient.confirmPaymentReceived(new grpc_pb_1.ConfirmPaymentReceivedRequest().setTradeId(tradeId), { password: this._password }, function (err) {
|
||||
if (err)
|
||||
reject(err);
|
||||
else
|
||||
@ -1076,7 +1105,7 @@ export default class HavenoClient {
|
||||
*/
|
||||
async getChatMessages(tradeId) {
|
||||
return new Promise((resolve, reject) => {
|
||||
const request = new GetChatMessagesRequest().setTradeId(tradeId);
|
||||
const request = new grpc_pb_1.GetChatMessagesRequest().setTradeId(tradeId);
|
||||
this._tradesClient.getChatMessages(request, { password: this._password }, function (err, response) {
|
||||
if (err)
|
||||
reject(err);
|
||||
@ -1093,7 +1122,7 @@ export default class HavenoClient {
|
||||
*/
|
||||
async sendChatMessage(tradeId, message) {
|
||||
return new Promise((resolve, reject) => {
|
||||
const request = new SendChatMessageRequest()
|
||||
const request = new grpc_pb_1.SendChatMessageRequest()
|
||||
.setTradeId(tradeId)
|
||||
.setMessage(message);
|
||||
this._tradesClient.sendChatMessage(request, { password: this._password }, function (err) {
|
||||
@ -1111,7 +1140,7 @@ export default class HavenoClient {
|
||||
*/
|
||||
async getDispute(tradeId) {
|
||||
return new Promise((resolve, reject) => {
|
||||
this._disputesClient.getDispute(new GetDisputeRequest().setTradeId(tradeId), { password: this._password }, function (err, response) {
|
||||
this._disputesClient.getDispute(new grpc_pb_1.GetDisputeRequest().setTradeId(tradeId), { password: this._password }, function (err, response) {
|
||||
if (err)
|
||||
reject(err);
|
||||
else
|
||||
@ -1124,7 +1153,7 @@ export default class HavenoClient {
|
||||
*/
|
||||
async getDisputes() {
|
||||
return new Promise((resolve, reject) => {
|
||||
this._disputesClient.getDisputes(new GetDisputesRequest(), { password: this._password }, function (err, response) {
|
||||
this._disputesClient.getDisputes(new grpc_pb_1.GetDisputesRequest(), { password: this._password }, function (err, response) {
|
||||
if (err)
|
||||
reject(err);
|
||||
else
|
||||
@ -1139,7 +1168,7 @@ export default class HavenoClient {
|
||||
*/
|
||||
async openDispute(tradeId) {
|
||||
return new Promise((resolve, reject) => {
|
||||
this._disputesClient.openDispute(new OpenDisputeRequest().setTradeId(tradeId), { password: this._password }, function (err) {
|
||||
this._disputesClient.openDispute(new grpc_pb_1.OpenDisputeRequest().setTradeId(tradeId), { password: this._password }, function (err) {
|
||||
if (err)
|
||||
reject(err);
|
||||
else
|
||||
@ -1159,7 +1188,7 @@ export default class HavenoClient {
|
||||
*/
|
||||
async resolveDispute(tradeId, winner, reason, summaryNotes, customWinnerAmount) {
|
||||
return new Promise((resolve, reject) => {
|
||||
const request = new ResolveDisputeRequest()
|
||||
const request = new grpc_pb_1.ResolveDisputeRequest()
|
||||
.setTradeId(tradeId)
|
||||
.setWinner(winner)
|
||||
.setReason(reason)
|
||||
@ -1182,7 +1211,7 @@ export default class HavenoClient {
|
||||
*/
|
||||
async sendDisputeChatMessage(disputeId, message, attachments) {
|
||||
return new Promise((resolve, reject) => {
|
||||
const request = new SendDisputeChatMessageRequest()
|
||||
const request = new grpc_pb_1.SendDisputeChatMessageRequest()
|
||||
.setDisputeId(disputeId)
|
||||
.setMessage(message)
|
||||
.setAttachmentsList(attachments);
|
||||
@ -1207,7 +1236,7 @@ export default class HavenoClient {
|
||||
async shutdownServer() {
|
||||
await this.disconnect();
|
||||
await new Promise((resolve, reject) => {
|
||||
this._shutdownServerClient.stop(new StopRequest(), { password: this._password }, function (err) {
|
||||
this._shutdownServerClient.stop(new grpc_pb_1.StopRequest(), { password: this._password }, function (err) {
|
||||
if (err)
|
||||
reject(err);
|
||||
else
|
||||
@ -1215,7 +1244,7 @@ export default class HavenoClient {
|
||||
});
|
||||
});
|
||||
if (this._process)
|
||||
return HavenoUtils.kill(this._process);
|
||||
return HavenoUtils_1.default.kill(this._process);
|
||||
}
|
||||
// ------------------------------- HELPERS ----------------------------------
|
||||
/**
|
||||
@ -1246,7 +1275,7 @@ export default class HavenoClient {
|
||||
resolve();
|
||||
};
|
||||
const listener = async function (notification) {
|
||||
if (notification.getType() === NotificationMessage.NotificationType.APP_INITIALIZED)
|
||||
if (notification.getType() === grpc_pb_1.NotificationMessage.NotificationType.APP_INITIALIZED)
|
||||
await resolveOnce();
|
||||
};
|
||||
await this.addNotificationListener(listener);
|
||||
@ -1257,7 +1286,7 @@ export default class HavenoClient {
|
||||
// @hidden
|
||||
async _isAppInitialized() {
|
||||
return new Promise((resolve, reject) => {
|
||||
this._accountClient.isAppInitialized(new IsAppInitializedRequest(), { password: this._password }, function (err, response) {
|
||||
this._accountClient.isAppInitialized(new grpc_pb_1.IsAppInitializedRequest(), { password: this._password }, function (err, response) {
|
||||
if (err)
|
||||
reject(err);
|
||||
else
|
||||
@ -1277,22 +1306,22 @@ export default class HavenoClient {
|
||||
if (listening) {
|
||||
return new Promise((resolve) => {
|
||||
// send request to register client listener
|
||||
this._notificationStream = this._notificationsClient.registerNotificationListener(new RegisterNotificationListenerRequest(), { password: this._password })
|
||||
this._notificationStream = this._notificationsClient.registerNotificationListener(new grpc_pb_1.RegisterNotificationListenerRequest(), { password: this._password })
|
||||
.on('data', (data) => {
|
||||
if (data instanceof NotificationMessage) {
|
||||
if (data instanceof grpc_pb_1.NotificationMessage) {
|
||||
for (const listener of this._notificationListeners)
|
||||
listener(data);
|
||||
}
|
||||
});
|
||||
// periodically send keep alive requests // TODO (woodser): better way to keep notification stream alive?
|
||||
let firstRequest = true;
|
||||
this._keepAliveLooper = new TaskLooper(async () => {
|
||||
this._keepAliveLooper = new TaskLooper_1.default(async () => {
|
||||
if (firstRequest) {
|
||||
firstRequest = false;
|
||||
return;
|
||||
}
|
||||
await this._sendNotification(new NotificationMessage()
|
||||
.setType(NotificationMessage.NotificationType.KEEP_ALIVE)
|
||||
await this._sendNotification(new grpc_pb_1.NotificationMessage()
|
||||
.setType(grpc_pb_1.NotificationMessage.NotificationType.KEEP_ALIVE)
|
||||
.setTimestamp(Date.now()));
|
||||
});
|
||||
this._keepAliveLooper.start(this._keepAlivePeriodMs);
|
||||
@ -1313,7 +1342,7 @@ export default class HavenoClient {
|
||||
*/
|
||||
async _sendNotification(notification) {
|
||||
return new Promise((resolve, reject) => {
|
||||
this._notificationsClient.sendNotification(new SendNotificationRequest().setNotification(notification), { password: this._password }, function (err) {
|
||||
this._notificationsClient.sendNotification(new grpc_pb_1.SendNotificationRequest().setNotification(notification), { password: this._password }, function (err) {
|
||||
if (err)
|
||||
reject(err);
|
||||
else
|
||||
@ -1327,7 +1356,7 @@ export default class HavenoClient {
|
||||
* @hidden
|
||||
*/
|
||||
async _restoreAccountChunk(zipBytes, offset, totalLength, hasMore) {
|
||||
const request = new RestoreAccountRequest()
|
||||
const request = new grpc_pb_1.RestoreAccountRequest()
|
||||
.setZipBytes(zipBytes)
|
||||
.setOffset(offset)
|
||||
.setTotalLength(totalLength)
|
||||
@ -1342,6 +1371,7 @@ export default class HavenoClient {
|
||||
});
|
||||
}
|
||||
}
|
||||
exports.default = HavenoClient;
|
||||
// constants
|
||||
HavenoClient._fullyInitializedMessage = "Application fully initialized";
|
||||
HavenoClient._loginRequiredMessage = "Interactive login required";
|
||||
|
2
dist/HavenoClient.js.map
vendored
2
dist/HavenoClient.js.map
vendored
File diff suppressed because one or more lines are too long
32
dist/index.js
vendored
32
dist/index.js
vendored
@ -1,7 +1,27 @@
|
||||
import HavenoClient from "./HavenoClient";
|
||||
import HavenoUtils from "./utils/HavenoUtils";
|
||||
export { HavenoClient };
|
||||
export { HavenoUtils };
|
||||
export * from "./protobuf/grpc_pb";
|
||||
export * from "./protobuf/pb_pb";
|
||||
"use strict";
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
||||
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
||||
};
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.HavenoUtils = exports.HavenoClient = void 0;
|
||||
const HavenoClient_1 = __importDefault(require("./HavenoClient"));
|
||||
exports.HavenoClient = HavenoClient_1.default;
|
||||
const HavenoUtils_1 = __importDefault(require("./utils/HavenoUtils"));
|
||||
exports.HavenoUtils = HavenoUtils_1.default;
|
||||
__exportStar(require("./protobuf/grpc_pb"), exports);
|
||||
__exportStar(require("./protobuf/pb_pb"), exports);
|
||||
//# sourceMappingURL=index.js.map
|
2
dist/index.js.map
vendored
2
dist/index.js.map
vendored
@ -1 +1 @@
|
||||
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,YAAY,MAAM,gBAAgB,CAAC;AAC1C,OAAO,WAAW,MAAM,qBAAqB,CAAC;AAE9C,OAAO,EAAE,YAAY,EAAE,CAAC;AACxB,OAAO,EAAE,WAAW,EAAE,CAAC;AACvB,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC"}
|
||||
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA,kEAA0C;AAGjC,uBAHF,sBAAY,CAGE;AAFrB,sEAA8C;AAGrC,sBAHF,qBAAW,CAGE;AACpB,qDAAmC;AACnC,mDAAiC"}
|
75
dist/protobuf/GrpcServiceClientPb.js
vendored
75
dist/protobuf/GrpcServiceClientPb.js
vendored
@ -1,14 +1,40 @@
|
||||
"use strict";
|
||||
/**
|
||||
* @fileoverview gRPC-Web generated client stub for io.bisq.protobuffer
|
||||
* @enhanceable
|
||||
* @public
|
||||
*/
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.WalletsClient = exports.TradesClient = exports.ShutdownServerClient = exports.GetTradeStatisticsClient = exports.PriceClient = exports.PaymentAccountsClient = exports.OffersClient = exports.MoneroNodeClient = exports.MoneroConnectionsClient = exports.NotificationsClient = exports.DisputeAgentsClient = exports.DisputesClient = exports.AccountClient = exports.GetVersionClient = exports.HelpClient = void 0;
|
||||
// GENERATED CODE -- DO NOT EDIT!
|
||||
/* eslint-disable */
|
||||
// @ts-nocheck
|
||||
import * as grpcWeb from 'grpc-web';
|
||||
import * as grpc_pb from './grpc_pb';
|
||||
export class HelpClient {
|
||||
const grpcWeb = __importStar(require("grpc-web"));
|
||||
const grpc_pb = __importStar(require("./grpc_pb"));
|
||||
class HelpClient {
|
||||
constructor(hostname, credentials, options) {
|
||||
this.methodInfoGetMethodHelp = new grpcWeb.MethodDescriptor('/io.bisq.protobuffer.Help/GetMethodHelp', grpcWeb.MethodType.UNARY, grpc_pb.GetMethodHelpRequest, grpc_pb.GetMethodHelpReply, (request) => {
|
||||
return request.serializeBinary();
|
||||
@ -32,7 +58,8 @@ export class HelpClient {
|
||||
'/io.bisq.protobuffer.Help/GetMethodHelp', request, metadata || {}, this.methodInfoGetMethodHelp);
|
||||
}
|
||||
}
|
||||
export class GetVersionClient {
|
||||
exports.HelpClient = HelpClient;
|
||||
class GetVersionClient {
|
||||
constructor(hostname, credentials, options) {
|
||||
this.methodInfoGetVersion = new grpcWeb.MethodDescriptor('/io.bisq.protobuffer.GetVersion/GetVersion', grpcWeb.MethodType.UNARY, grpc_pb.GetVersionRequest, grpc_pb.GetVersionReply, (request) => {
|
||||
return request.serializeBinary();
|
||||
@ -56,7 +83,8 @@ export class GetVersionClient {
|
||||
'/io.bisq.protobuffer.GetVersion/GetVersion', request, metadata || {}, this.methodInfoGetVersion);
|
||||
}
|
||||
}
|
||||
export class AccountClient {
|
||||
exports.GetVersionClient = GetVersionClient;
|
||||
class AccountClient {
|
||||
constructor(hostname, credentials, options) {
|
||||
this.methodInfoAccountExists = new grpcWeb.MethodDescriptor('/io.bisq.protobuffer.Account/AccountExists', grpcWeb.MethodType.UNARY, grpc_pb.AccountExistsRequest, grpc_pb.AccountExistsReply, (request) => {
|
||||
return request.serializeBinary();
|
||||
@ -175,7 +203,8 @@ export class AccountClient {
|
||||
'/io.bisq.protobuffer.Account/RestoreAccount', request, metadata || {}, this.methodInfoRestoreAccount);
|
||||
}
|
||||
}
|
||||
export class DisputesClient {
|
||||
exports.AccountClient = AccountClient;
|
||||
class DisputesClient {
|
||||
constructor(hostname, credentials, options) {
|
||||
this.methodInfoGetDispute = new grpcWeb.MethodDescriptor('/io.bisq.protobuffer.Disputes/GetDispute', grpcWeb.MethodType.UNARY, grpc_pb.GetDisputeRequest, grpc_pb.GetDisputeReply, (request) => {
|
||||
return request.serializeBinary();
|
||||
@ -243,7 +272,8 @@ export class DisputesClient {
|
||||
'/io.bisq.protobuffer.Disputes/SendDisputeChatMessage', request, metadata || {}, this.methodInfoSendDisputeChatMessage);
|
||||
}
|
||||
}
|
||||
export class DisputeAgentsClient {
|
||||
exports.DisputesClient = DisputesClient;
|
||||
class DisputeAgentsClient {
|
||||
constructor(hostname, credentials, options) {
|
||||
this.methodInfoRegisterDisputeAgent = new grpcWeb.MethodDescriptor('/io.bisq.protobuffer.DisputeAgents/RegisterDisputeAgent', grpcWeb.MethodType.UNARY, grpc_pb.RegisterDisputeAgentRequest, grpc_pb.RegisterDisputeAgentReply, (request) => {
|
||||
return request.serializeBinary();
|
||||
@ -267,7 +297,8 @@ export class DisputeAgentsClient {
|
||||
'/io.bisq.protobuffer.DisputeAgents/RegisterDisputeAgent', request, metadata || {}, this.methodInfoRegisterDisputeAgent);
|
||||
}
|
||||
}
|
||||
export class NotificationsClient {
|
||||
exports.DisputeAgentsClient = DisputeAgentsClient;
|
||||
class NotificationsClient {
|
||||
constructor(hostname, credentials, options) {
|
||||
this.methodInfoRegisterNotificationListener = new grpcWeb.MethodDescriptor('/io.bisq.protobuffer.Notifications/RegisterNotificationListener', grpcWeb.MethodType.SERVER_STREAMING, grpc_pb.RegisterNotificationListenerRequest, grpc_pb.NotificationMessage, (request) => {
|
||||
return request.serializeBinary();
|
||||
@ -298,7 +329,8 @@ export class NotificationsClient {
|
||||
'/io.bisq.protobuffer.Notifications/SendNotification', request, metadata || {}, this.methodInfoSendNotification);
|
||||
}
|
||||
}
|
||||
export class MoneroConnectionsClient {
|
||||
exports.NotificationsClient = NotificationsClient;
|
||||
class MoneroConnectionsClient {
|
||||
constructor(hostname, credentials, options) {
|
||||
this.methodInfoAddConnection = new grpcWeb.MethodDescriptor('/io.bisq.protobuffer.MoneroConnections/AddConnection', grpcWeb.MethodType.UNARY, grpc_pb.AddConnectionRequest, grpc_pb.AddConnectionReply, (request) => {
|
||||
return request.serializeBinary();
|
||||
@ -432,7 +464,8 @@ export class MoneroConnectionsClient {
|
||||
'/io.bisq.protobuffer.MoneroConnections/SetAutoSwitch', request, metadata || {}, this.methodInfoSetAutoSwitch);
|
||||
}
|
||||
}
|
||||
export class MoneroNodeClient {
|
||||
exports.MoneroConnectionsClient = MoneroConnectionsClient;
|
||||
class MoneroNodeClient {
|
||||
constructor(hostname, credentials, options) {
|
||||
this.methodInfoIsMoneroNodeRunning = new grpcWeb.MethodDescriptor('/io.bisq.protobuffer.MoneroNode/IsMoneroNodeRunning', grpcWeb.MethodType.UNARY, grpc_pb.IsMoneroNodeRunningRequest, grpc_pb.IsMoneroNodeRunningReply, (request) => {
|
||||
return request.serializeBinary();
|
||||
@ -489,7 +522,8 @@ export class MoneroNodeClient {
|
||||
'/io.bisq.protobuffer.MoneroNode/StopMoneroNode', request, metadata || {}, this.methodInfoStopMoneroNode);
|
||||
}
|
||||
}
|
||||
export class OffersClient {
|
||||
exports.MoneroNodeClient = MoneroNodeClient;
|
||||
class OffersClient {
|
||||
constructor(hostname, credentials, options) {
|
||||
this.methodInfoGetOffer = new grpcWeb.MethodDescriptor('/io.bisq.protobuffer.Offers/GetOffer', grpcWeb.MethodType.UNARY, grpc_pb.GetOfferRequest, grpc_pb.GetOfferReply, (request) => {
|
||||
return request.serializeBinary();
|
||||
@ -568,7 +602,8 @@ export class OffersClient {
|
||||
'/io.bisq.protobuffer.Offers/CancelOffer', request, metadata || {}, this.methodInfoCancelOffer);
|
||||
}
|
||||
}
|
||||
export class PaymentAccountsClient {
|
||||
exports.OffersClient = OffersClient;
|
||||
class PaymentAccountsClient {
|
||||
constructor(hostname, credentials, options) {
|
||||
this.methodInfoCreatePaymentAccount = new grpcWeb.MethodDescriptor('/io.bisq.protobuffer.PaymentAccounts/CreatePaymentAccount', grpcWeb.MethodType.UNARY, grpc_pb.CreatePaymentAccountRequest, grpc_pb.CreatePaymentAccountReply, (request) => {
|
||||
return request.serializeBinary();
|
||||
@ -647,7 +682,8 @@ export class PaymentAccountsClient {
|
||||
'/io.bisq.protobuffer.PaymentAccounts/GetCryptoCurrencyPaymentMethods', request, metadata || {}, this.methodInfoGetCryptoCurrencyPaymentMethods);
|
||||
}
|
||||
}
|
||||
export class PriceClient {
|
||||
exports.PaymentAccountsClient = PaymentAccountsClient;
|
||||
class PriceClient {
|
||||
constructor(hostname, credentials, options) {
|
||||
this.methodInfoGetMarketPrice = new grpcWeb.MethodDescriptor('/io.bisq.protobuffer.Price/GetMarketPrice', grpcWeb.MethodType.UNARY, grpc_pb.MarketPriceRequest, grpc_pb.MarketPriceReply, (request) => {
|
||||
return request.serializeBinary();
|
||||
@ -693,7 +729,8 @@ export class PriceClient {
|
||||
'/io.bisq.protobuffer.Price/GetMarketDepth', request, metadata || {}, this.methodInfoGetMarketDepth);
|
||||
}
|
||||
}
|
||||
export class GetTradeStatisticsClient {
|
||||
exports.PriceClient = PriceClient;
|
||||
class GetTradeStatisticsClient {
|
||||
constructor(hostname, credentials, options) {
|
||||
this.methodInfoGetTradeStatistics = new grpcWeb.MethodDescriptor('/io.bisq.protobuffer.GetTradeStatistics/GetTradeStatistics', grpcWeb.MethodType.UNARY, grpc_pb.GetTradeStatisticsRequest, grpc_pb.GetTradeStatisticsReply, (request) => {
|
||||
return request.serializeBinary();
|
||||
@ -717,7 +754,8 @@ export class GetTradeStatisticsClient {
|
||||
'/io.bisq.protobuffer.GetTradeStatistics/GetTradeStatistics', request, metadata || {}, this.methodInfoGetTradeStatistics);
|
||||
}
|
||||
}
|
||||
export class ShutdownServerClient {
|
||||
exports.GetTradeStatisticsClient = GetTradeStatisticsClient;
|
||||
class ShutdownServerClient {
|
||||
constructor(hostname, credentials, options) {
|
||||
this.methodInfoStop = new grpcWeb.MethodDescriptor('/io.bisq.protobuffer.ShutdownServer/Stop', grpcWeb.MethodType.UNARY, grpc_pb.StopRequest, grpc_pb.StopReply, (request) => {
|
||||
return request.serializeBinary();
|
||||
@ -741,7 +779,8 @@ export class ShutdownServerClient {
|
||||
'/io.bisq.protobuffer.ShutdownServer/Stop', request, metadata || {}, this.methodInfoStop);
|
||||
}
|
||||
}
|
||||
export class TradesClient {
|
||||
exports.ShutdownServerClient = ShutdownServerClient;
|
||||
class TradesClient {
|
||||
constructor(hostname, credentials, options) {
|
||||
this.methodInfoGetTrade = new grpcWeb.MethodDescriptor('/io.bisq.protobuffer.Trades/GetTrade', grpcWeb.MethodType.UNARY, grpc_pb.GetTradeRequest, grpc_pb.GetTradeReply, (request) => {
|
||||
return request.serializeBinary();
|
||||
@ -853,7 +892,8 @@ export class TradesClient {
|
||||
'/io.bisq.protobuffer.Trades/SendChatMessage', request, metadata || {}, this.methodInfoSendChatMessage);
|
||||
}
|
||||
}
|
||||
export class WalletsClient {
|
||||
exports.TradesClient = TradesClient;
|
||||
class WalletsClient {
|
||||
constructor(hostname, credentials, options) {
|
||||
this.methodInfoGetBalances = new grpcWeb.MethodDescriptor('/io.bisq.protobuffer.Wallets/GetBalances', grpcWeb.MethodType.UNARY, grpc_pb.GetBalancesRequest, grpc_pb.GetBalancesReply, (request) => {
|
||||
return request.serializeBinary();
|
||||
@ -1053,4 +1093,5 @@ export class WalletsClient {
|
||||
'/io.bisq.protobuffer.Wallets/UnlockWallet', request, metadata || {}, this.methodInfoUnlockWallet);
|
||||
}
|
||||
}
|
||||
exports.WalletsClient = WalletsClient;
|
||||
//# sourceMappingURL=GrpcServiceClientPb.js.map
|
2
dist/protobuf/GrpcServiceClientPb.js.map
vendored
2
dist/protobuf/GrpcServiceClientPb.js.map
vendored
File diff suppressed because one or more lines are too long
6
dist/protobuf/pb_pb.d.ts
vendored
6
dist/protobuf/pb_pb.d.ts
vendored
@ -7650,6 +7650,11 @@ export class PaymentMethod extends jspb.Message {
|
||||
getMaxTradeLimit(): string;
|
||||
setMaxTradeLimit(value: string): PaymentMethod;
|
||||
|
||||
getSupportedAssetCodesList(): Array<string>;
|
||||
setSupportedAssetCodesList(value: Array<string>): PaymentMethod;
|
||||
clearSupportedAssetCodesList(): PaymentMethod;
|
||||
addSupportedAssetCodes(value: string, index?: number): PaymentMethod;
|
||||
|
||||
serializeBinary(): Uint8Array;
|
||||
toObject(includeInstance?: boolean): PaymentMethod.AsObject;
|
||||
static toObject(includeInstance: boolean, msg: PaymentMethod): PaymentMethod.AsObject;
|
||||
@ -7663,6 +7668,7 @@ export namespace PaymentMethod {
|
||||
id: string,
|
||||
maxTradePeriod: string,
|
||||
maxTradeLimit: string,
|
||||
supportedAssetCodesList: Array<string>,
|
||||
}
|
||||
}
|
||||
|
||||
|
60
dist/protobuf/pb_pb.js
vendored
60
dist/protobuf/pb_pb.js
vendored
@ -3760,7 +3760,7 @@ if (goog.DEBUG && !COMPILED) {
|
||||
* @constructor
|
||||
*/
|
||||
proto.io.bisq.protobuffer.PaymentMethod = function(opt_data) {
|
||||
jspb.Message.initialize(this, opt_data, 0, -1, null, null);
|
||||
jspb.Message.initialize(this, opt_data, 0, -1, proto.io.bisq.protobuffer.PaymentMethod.repeatedFields_, null);
|
||||
};
|
||||
goog.inherits(proto.io.bisq.protobuffer.PaymentMethod, jspb.Message);
|
||||
if (goog.DEBUG && !COMPILED) {
|
||||
@ -61725,6 +61725,13 @@ proto.io.bisq.protobuffer.PaymentAccount.prototype.hasPaymentAccountPayload = fu
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* List of repeated fields within this message type.
|
||||
* @private {!Array<number>}
|
||||
* @const
|
||||
*/
|
||||
proto.io.bisq.protobuffer.PaymentMethod.repeatedFields_ = [4];
|
||||
|
||||
|
||||
|
||||
if (jspb.Message.GENERATE_TO_OBJECT) {
|
||||
@ -61758,7 +61765,8 @@ proto.io.bisq.protobuffer.PaymentMethod.toObject = function(includeInstance, msg
|
||||
var f, obj = {
|
||||
id: jspb.Message.getFieldWithDefault(msg, 1, ""),
|
||||
maxTradePeriod: jspb.Message.getFieldWithDefault(msg, 2, "0"),
|
||||
maxTradeLimit: jspb.Message.getFieldWithDefault(msg, 3, "0")
|
||||
maxTradeLimit: jspb.Message.getFieldWithDefault(msg, 3, "0"),
|
||||
supportedAssetCodesList: (f = jspb.Message.getRepeatedField(msg, 4)) == null ? undefined : f
|
||||
};
|
||||
|
||||
if (includeInstance) {
|
||||
@ -61807,6 +61815,10 @@ proto.io.bisq.protobuffer.PaymentMethod.deserializeBinaryFromReader = function(m
|
||||
var value = /** @type {string} */ (reader.readInt64String());
|
||||
msg.setMaxTradeLimit(value);
|
||||
break;
|
||||
case 4:
|
||||
var value = /** @type {string} */ (reader.readString());
|
||||
msg.addSupportedAssetCodes(value);
|
||||
break;
|
||||
default:
|
||||
reader.skipField();
|
||||
break;
|
||||
@ -61857,6 +61869,13 @@ proto.io.bisq.protobuffer.PaymentMethod.serializeBinaryToWriter = function(messa
|
||||
f
|
||||
);
|
||||
}
|
||||
f = message.getSupportedAssetCodesList();
|
||||
if (f.length > 0) {
|
||||
writer.writeRepeatedString(
|
||||
4,
|
||||
f
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@ -61914,6 +61933,43 @@ proto.io.bisq.protobuffer.PaymentMethod.prototype.setMaxTradeLimit = function(va
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* repeated string supported_asset_codes = 4;
|
||||
* @return {!Array<string>}
|
||||
*/
|
||||
proto.io.bisq.protobuffer.PaymentMethod.prototype.getSupportedAssetCodesList = function() {
|
||||
return /** @type {!Array<string>} */ (jspb.Message.getRepeatedField(this, 4));
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @param {!Array<string>} value
|
||||
* @return {!proto.io.bisq.protobuffer.PaymentMethod} returns this
|
||||
*/
|
||||
proto.io.bisq.protobuffer.PaymentMethod.prototype.setSupportedAssetCodesList = function(value) {
|
||||
return jspb.Message.setField(this, 4, value || []);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @param {string} value
|
||||
* @param {number=} opt_index
|
||||
* @return {!proto.io.bisq.protobuffer.PaymentMethod} returns this
|
||||
*/
|
||||
proto.io.bisq.protobuffer.PaymentMethod.prototype.addSupportedAssetCodes = function(value, opt_index) {
|
||||
return jspb.Message.addToRepeatedField(this, 4, value, opt_index);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Clears the list making it empty but non-null.
|
||||
* @return {!proto.io.bisq.protobuffer.PaymentMethod} returns this
|
||||
*/
|
||||
proto.io.bisq.protobuffer.PaymentMethod.prototype.clearSupportedAssetCodesList = function() {
|
||||
return this.setSupportedAssetCodesList([]);
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
18
dist/utils/HavenoUtils.js
vendored
18
dist/utils/HavenoUtils.js
vendored
@ -1,16 +1,21 @@
|
||||
import assert from "assert";
|
||||
import console from 'console';
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const assert_1 = __importDefault(require("assert"));
|
||||
const console_1 = __importDefault(require("console"));
|
||||
/**
|
||||
* Collection of utilities for working with Haveno.
|
||||
*/
|
||||
export default class HavenoUtils {
|
||||
class HavenoUtils {
|
||||
/**
|
||||
* Set the log level with 0 being least verbose.
|
||||
*
|
||||
* @param {int} level - the log level
|
||||
*/
|
||||
static async setLogLevel(level) {
|
||||
assert(level === parseInt(level + "", 10) && level >= 0, "Log level must be an integer >= 0");
|
||||
(0, assert_1.default)(level === parseInt(level + "", 10) && level >= 0, "Log level must be an integer >= 0");
|
||||
HavenoUtils.logLevel = level;
|
||||
}
|
||||
/**
|
||||
@ -29,12 +34,12 @@ export default class HavenoUtils {
|
||||
* @param {boolean?} warn - log the message as a warning if true
|
||||
*/
|
||||
static log(level, msg) {
|
||||
assert(level === parseInt(level + "", 10) && level >= 0, "Log level must be an integer >= 0");
|
||||
(0, assert_1.default)(level === parseInt(level + "", 10) && level >= 0, "Log level must be an integer >= 0");
|
||||
if (HavenoUtils.logLevel >= level) {
|
||||
const now = Date.now();
|
||||
const formattedTimeSinceLastLog = HavenoUtils.lastLogTimeMs ? " (+" + (now - HavenoUtils.lastLogTimeMs) + " ms)" : "\t";
|
||||
HavenoUtils.lastLogTimeMs = now;
|
||||
console.log(HavenoUtils.formatTimestamp(now) + formattedTimeSinceLastLog + "\t[L" + level + "] " + msg);
|
||||
console_1.default.log(HavenoUtils.formatTimestamp(now) + formattedTimeSinceLastLog + "\t[L" + level + "] " + msg);
|
||||
}
|
||||
}
|
||||
/**
|
||||
@ -72,6 +77,7 @@ export default class HavenoUtils {
|
||||
return BigInt(centineros) * BigInt(HavenoUtils.centinerosToAUMultiplier);
|
||||
}
|
||||
}
|
||||
exports.default = HavenoUtils;
|
||||
HavenoUtils.logLevel = 0;
|
||||
HavenoUtils.centinerosToAUMultiplier = 10000;
|
||||
HavenoUtils.months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
|
||||
|
2
dist/utils/HavenoUtils.js.map
vendored
2
dist/utils/HavenoUtils.js.map
vendored
@ -1 +1 @@
|
||||
{"version":3,"file":"HavenoUtils.js","sourceRoot":"","sources":["../../src/utils/HavenoUtils.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,QAAQ,CAAC;AAC5B,OAAO,OAAO,MAAM,SAAS,CAAC;AAE9B;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,WAAW;IAO9B;;;;OAIG;IACH,MAAM,CAAC,KAAK,CAAC,WAAW,CAAC,KAAa;QACpC,MAAM,CAAC,KAAK,KAAK,QAAQ,CAAC,KAAK,GAAG,EAAE,EAAE,EAAE,CAAC,IAAI,KAAK,IAAI,CAAC,EAAE,mCAAmC,CAAC,CAAC;QAC9F,WAAW,CAAC,QAAQ,GAAG,KAAK,CAAC;IAC/B,CAAC;IAED;;;;OAIG;IACH,MAAM,CAAC,WAAW;QAChB,OAAO,WAAW,CAAC,QAAQ,CAAC;IAC9B,CAAC;IAED;;;;;;OAMG;IACH,MAAM,CAAC,GAAG,CAAC,KAAa,EAAE,GAAW;QACnC,MAAM,CAAC,KAAK,KAAK,QAAQ,CAAC,KAAK,GAAG,EAAE,EAAE,EAAE,CAAC,IAAI,KAAK,IAAI,CAAC,EAAE,mCAAmC,CAAC,CAAC;QAC9F,IAAI,WAAW,CAAC,QAAQ,IAAI,KAAK,EAAE;YACjC,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;YACvB,MAAM,yBAAyB,GAAG,WAAW,CAAC,aAAa,CAAC,CAAC,CAAC,KAAK,GAAG,CAAC,GAAG,GAAG,WAAW,CAAC,aAAa,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC;YACxH,WAAW,CAAC,aAAa,GAAG,GAAG,CAAC;YAChC,OAAO,CAAC,GAAG,CAA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AAC,CAAC,CAAC;YACzD,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC;QAC3C,CAAC,CAAC,CAAC;IACL,CAAC;IAED;;;;;OAKG;IACH,MAAM,CAAC,uBAAuB,CAAC,UAAkB;QAC/C,OAAO,MAAM,CAAC,UAAU,CAAC,GAAG,MAAM,CAAC,WAAW,CAAC,wBAAwB,CAAC,CAAC;IAC3E,CAAC;;AA9EH,8BA+EC;AA7EQ,oBAAQ,GAAG,CAAC,CAAC;AACb,oCAAwB,GAAG,KAAK,CAAC;AACjC,kBAAM,GAAG,CAAC,KAAK,EAAC,KAAK,EAAC,KAAK,EAAC,KAAK,EAAC,KAAK,EAAC,KAAK,EAAC,KAAK,EAAC,KAAK,EAAC,KAAK,EAAC,KAAK,EAAC,KAAK,EAAC,KAAK,CAAC,CAAC;AACnF,yBAAa,GAAG,CAAC,CAAC"}
|
5
dist/utils/TaskLooper.js
vendored
5
dist/utils/TaskLooper.js
vendored
@ -1,7 +1,9 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
/**
|
||||
* Run a task in a fixed period loop.
|
||||
*/
|
||||
export default class TaskLooper {
|
||||
class TaskLooper {
|
||||
/**
|
||||
* Build the looper with a function to invoke on a fixed period loop.
|
||||
*
|
||||
@ -44,4 +46,5 @@ export default class TaskLooper {
|
||||
this._isLooping = false;
|
||||
}
|
||||
}
|
||||
exports.default = TaskLooper;
|
||||
//# sourceMappingURL=TaskLooper.js.map
|
2
dist/utils/TaskLooper.js.map
vendored
2
dist/utils/TaskLooper.js.map
vendored
@ -1 +1 @@
|
||||
{"version":3,"file":"TaskLooper.js","sourceRoot":"","sources":["../../src/utils/TaskLooper.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,UAAU;IAO7B;;;;OAIG;IACH,YAAY,EAAuB;QACjC,IAAI,CAAC,GAAG,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I,CAAC,GAAG,GAAG,EAAE,CAAC;QACd,IAAI,CAAC,UAAU,GAAG,KAAK,CAAC;QACxB,IAAI,CAAC,UAAU,GAAG,KAAK,CAAC;IAC1B,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,UAAkB;QACtB,IAAI,IAAI,CAAC,UAAU;YAAE,OAAO;QAC5B,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC;QACvB,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC;IAC5B,CAAC;IAED;;OAEG;IACH,IAAI;QACF,IAAI,CAAC,IAAI,CAAC,UAAU;YAAE,MAAM,IAAI,KAAK,CAAC,iDAAiD,CAAC,CAAC;QACzF,IAAI,CAAC,UAAU,GAAG,KAAK,CAAC;QACxB,YAAY,CAAC,IAAI,CAAC,QAAS,CAAC,CAAC;QAC7B,IAAI,CAAC,QAAQ,GAAG,SAAS,CAAC;IAC5B,CAAC;IAED,KAAK,CAAC,QAAQ,CAAC,UAAkB;QAC/B,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC;QACvB,OAAO,IAAI,CAAC,UAAU,EAAE;YACtB,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;YAC7B,MAAM,IAAI,CAAC,GAAG,EAAE,CAAC;YACjB,IAAI,IAAI,CAAC,UAAU;gBAAE,MAAM,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,GAAG,IAAI,CAAC,QAAQ,GAAG,UAAU,CAAC,OAAO,EAAE,UAAU,GAAG,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;SACtI;QACD,IAAI,CAAC,UAAU,GAAG,KAAK,CAAC;IAC1B,CAAC;CACF;AAhDD,6BAgDC"}
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user