update dist

This commit is contained in:
woodser 2025-01-19 09:57:25 -05:00
parent 42656e2d63
commit 38ee63cdf4
13 changed files with 1425 additions and 1386 deletions

View File

@ -219,11 +219,11 @@ export default class HavenoClient {
*/
stopCheckingConnection(): Promise<void>;
/**
* Get the best available connection in order of priority then response time.
* Get the best connection in order of priority then response time.
*
* @return {UrlConnection | undefined} the best available connection in order of priority then response time, undefined if no connections available
* @return {UrlConnection | undefined} the best connection in order of priority then response time, undefined if no connections
*/
getBestAvailableConnection(): Promise<UrlConnection | undefined>;
getBestConnection(): Promise<UrlConnection | undefined>;
/**
* Automatically switch to the best available connection if current connection is disconnected after being checked.
*
@ -328,9 +328,9 @@ export default class HavenoClient {
* Get 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
* @return {number|undefined} the price of the asset per 1 XMR
*/
getPrice(assetCode: string): Promise<number>;
getPrice(assetCode: string): Promise<number | undefined>;
/**
* Get the current market prices of all a.
*

23
dist/HavenoClient.js vendored
View File

@ -537,13 +537,13 @@ class HavenoClient {
}
}
/**
* Get the best available connection in order of priority then response time.
* Get the best connection in order of priority then response time.
*
* @return {UrlConnection | undefined} the best available connection in order of priority then response time, undefined if no connections available
* @return {UrlConnection | undefined} the best connection in order of priority then response time, undefined if no connections
*/
async getBestAvailableConnection() {
async getBestConnection() {
try {
return (await this._xmrConnectionsClient.getBestAvailableConnection(new grpc_pb_1.GetBestAvailableConnectionRequest(), { password: this._password })).getConnection();
return (await this._xmrConnectionsClient.getBestConnection(new grpc_pb_1.GetBestConnectionRequest(), { password: this._password })).getConnection();
}
catch (e) {
throw new HavenoError_1.default(e.message, e.code);
@ -775,13 +775,15 @@ class HavenoClient {
* Get 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
* @return {number|undefined} the price of the asset per 1 XMR
*/
async getPrice(assetCode) {
try {
return (await this._priceClient.getMarketPrice(new grpc_pb_1.MarketPriceRequest().setCurrencyCode(assetCode), { password: this._password })).getPrice();
}
catch (e) {
if (e.message.indexOf("not found") >= 0)
return undefined; // TODO: return unknown price server side (0?)
throw new HavenoError_1.default(e.message, e.code);
}
}
@ -1305,7 +1307,16 @@ class HavenoClient {
await HavenoUtils_1.default.kill(this._process);
}
catch (e) {
throw new HavenoError_1.default(e.message, e.code);
console_1.default.error("Error gracefully shutting down havenod: " + e.message);
if (this._process) {
try {
await HavenoUtils_1.default.kill(this._process);
}
catch (e) {
console_1.default.error("Error terminating havenod process: " + e.message + ". Stopping forcefully");
await HavenoUtils_1.default.kill(this._process, "SIGKILL");
}
}
}
}
// ------------------------------- HELPERS ----------------------------------

File diff suppressed because one or more lines are too long

View File

@ -197,9 +197,9 @@ export declare class XmrConnectionsClient {
methodDescriptorStopCheckingConnection: grpcWeb.MethodDescriptor<grpc_pb.StopCheckingConnectionRequest, grpc_pb.StopCheckingConnectionReply>;
stopCheckingConnection(request: grpc_pb.StopCheckingConnectionRequest, metadata?: grpcWeb.Metadata | null): Promise<grpc_pb.StopCheckingConnectionReply>;
stopCheckingConnection(request: grpc_pb.StopCheckingConnectionRequest, metadata: grpcWeb.Metadata | null, callback: (err: grpcWeb.RpcError, response: grpc_pb.StopCheckingConnectionReply) => void): grpcWeb.ClientReadableStream<grpc_pb.StopCheckingConnectionReply>;
methodDescriptorGetBestAvailableConnection: grpcWeb.MethodDescriptor<grpc_pb.GetBestAvailableConnectionRequest, grpc_pb.GetBestAvailableConnectionReply>;
getBestAvailableConnection(request: grpc_pb.GetBestAvailableConnectionRequest, metadata?: grpcWeb.Metadata | null): Promise<grpc_pb.GetBestAvailableConnectionReply>;
getBestAvailableConnection(request: grpc_pb.GetBestAvailableConnectionRequest, metadata: grpcWeb.Metadata | null, callback: (err: grpcWeb.RpcError, response: grpc_pb.GetBestAvailableConnectionReply) => void): grpcWeb.ClientReadableStream<grpc_pb.GetBestAvailableConnectionReply>;
methodDescriptorGetBestConnection: grpcWeb.MethodDescriptor<grpc_pb.GetBestConnectionRequest, grpc_pb.GetBestConnectionReply>;
getBestConnection(request: grpc_pb.GetBestConnectionRequest, metadata?: grpcWeb.Metadata | null): Promise<grpc_pb.GetBestConnectionReply>;
getBestConnection(request: grpc_pb.GetBestConnectionRequest, metadata: grpcWeb.Metadata | null, callback: (err: grpcWeb.RpcError, response: grpc_pb.GetBestConnectionReply) => void): grpcWeb.ClientReadableStream<grpc_pb.GetBestConnectionReply>;
methodDescriptorSetAutoSwitch: grpcWeb.MethodDescriptor<grpc_pb.SetAutoSwitchRequest, grpc_pb.SetAutoSwitchReply>;
setAutoSwitch(request: grpc_pb.SetAutoSwitchRequest, metadata?: grpcWeb.Metadata | null): Promise<grpc_pb.SetAutoSwitchReply>;
setAutoSwitch(request: grpc_pb.SetAutoSwitchRequest, metadata: grpcWeb.Metadata | null, callback: (err: grpcWeb.RpcError, response: grpc_pb.SetAutoSwitchReply) => void): grpcWeb.ClientReadableStream<grpc_pb.SetAutoSwitchReply>;

View File

@ -32,7 +32,7 @@ exports.WalletsClient = exports.TradesClient = exports.ShutdownServerClient = ex
// Code generated by protoc-gen-grpc-web. DO NOT EDIT.
// versions:
// protoc-gen-grpc-web v1.5.0
// protoc v3.20.3
// protoc v5.29.3
// source: grpc.proto
/* eslint-disable */
// @ts-nocheck
@ -374,9 +374,9 @@ class XmrConnectionsClient {
this.methodDescriptorStopCheckingConnection = new grpcWeb.MethodDescriptor('/io.haveno.protobuffer.XmrConnections/StopCheckingConnection', grpcWeb.MethodType.UNARY, grpc_pb.StopCheckingConnectionRequest, grpc_pb.StopCheckingConnectionReply, (request) => {
return request.serializeBinary();
}, grpc_pb.StopCheckingConnectionReply.deserializeBinary);
this.methodDescriptorGetBestAvailableConnection = new grpcWeb.MethodDescriptor('/io.haveno.protobuffer.XmrConnections/GetBestAvailableConnection', grpcWeb.MethodType.UNARY, grpc_pb.GetBestAvailableConnectionRequest, grpc_pb.GetBestAvailableConnectionReply, (request) => {
this.methodDescriptorGetBestConnection = new grpcWeb.MethodDescriptor('/io.haveno.protobuffer.XmrConnections/GetBestConnection', grpcWeb.MethodType.UNARY, grpc_pb.GetBestConnectionRequest, grpc_pb.GetBestConnectionReply, (request) => {
return request.serializeBinary();
}, grpc_pb.GetBestAvailableConnectionReply.deserializeBinary);
}, grpc_pb.GetBestConnectionReply.deserializeBinary);
this.methodDescriptorSetAutoSwitch = new grpcWeb.MethodDescriptor('/io.haveno.protobuffer.XmrConnections/SetAutoSwitch', grpcWeb.MethodType.UNARY, grpc_pb.SetAutoSwitchRequest, grpc_pb.SetAutoSwitchReply, (request) => {
return request.serializeBinary();
}, grpc_pb.SetAutoSwitchReply.deserializeBinary);
@ -465,13 +465,13 @@ class XmrConnectionsClient {
return this.client_.unaryCall(this.hostname_ +
'/io.haveno.protobuffer.XmrConnections/StopCheckingConnection', request, metadata || {}, this.methodDescriptorStopCheckingConnection);
}
getBestAvailableConnection(request, metadata, callback) {
getBestConnection(request, metadata, callback) {
if (callback !== undefined) {
return this.client_.rpcCall(this.hostname_ +
'/io.haveno.protobuffer.XmrConnections/GetBestAvailableConnection', request, metadata || {}, this.methodDescriptorGetBestAvailableConnection, callback);
'/io.haveno.protobuffer.XmrConnections/GetBestConnection', request, metadata || {}, this.methodDescriptorGetBestConnection, callback);
}
return this.client_.unaryCall(this.hostname_ +
'/io.haveno.protobuffer.XmrConnections/GetBestAvailableConnection', request, metadata || {}, this.methodDescriptorGetBestAvailableConnection);
'/io.haveno.protobuffer.XmrConnections/GetBestConnection', request, metadata || {}, this.methodDescriptorGetBestConnection);
}
setAutoSwitch(request, metadata, callback) {
if (callback !== undefined) {

File diff suppressed because one or more lines are too long

View File

@ -1117,35 +1117,35 @@ export namespace StopCheckingConnectionReply {
}
}
export class GetBestAvailableConnectionRequest extends jspb.Message {
export class GetBestConnectionRequest extends jspb.Message {
serializeBinary(): Uint8Array;
toObject(includeInstance?: boolean): GetBestAvailableConnectionRequest.AsObject;
static toObject(includeInstance: boolean, msg: GetBestAvailableConnectionRequest): GetBestAvailableConnectionRequest.AsObject;
static serializeBinaryToWriter(message: GetBestAvailableConnectionRequest, writer: jspb.BinaryWriter): void;
static deserializeBinary(bytes: Uint8Array): GetBestAvailableConnectionRequest;
static deserializeBinaryFromReader(message: GetBestAvailableConnectionRequest, reader: jspb.BinaryReader): GetBestAvailableConnectionRequest;
toObject(includeInstance?: boolean): GetBestConnectionRequest.AsObject;
static toObject(includeInstance: boolean, msg: GetBestConnectionRequest): GetBestConnectionRequest.AsObject;
static serializeBinaryToWriter(message: GetBestConnectionRequest, writer: jspb.BinaryWriter): void;
static deserializeBinary(bytes: Uint8Array): GetBestConnectionRequest;
static deserializeBinaryFromReader(message: GetBestConnectionRequest, reader: jspb.BinaryReader): GetBestConnectionRequest;
}
export namespace GetBestAvailableConnectionRequest {
export namespace GetBestConnectionRequest {
export type AsObject = {
}
}
export class GetBestAvailableConnectionReply extends jspb.Message {
export class GetBestConnectionReply extends jspb.Message {
getConnection(): UrlConnection | undefined;
setConnection(value?: UrlConnection): GetBestAvailableConnectionReply;
setConnection(value?: UrlConnection): GetBestConnectionReply;
hasConnection(): boolean;
clearConnection(): GetBestAvailableConnectionReply;
clearConnection(): GetBestConnectionReply;
serializeBinary(): Uint8Array;
toObject(includeInstance?: boolean): GetBestAvailableConnectionReply.AsObject;
static toObject(includeInstance: boolean, msg: GetBestAvailableConnectionReply): GetBestAvailableConnectionReply.AsObject;
static serializeBinaryToWriter(message: GetBestAvailableConnectionReply, writer: jspb.BinaryWriter): void;
static deserializeBinary(bytes: Uint8Array): GetBestAvailableConnectionReply;
static deserializeBinaryFromReader(message: GetBestAvailableConnectionReply, reader: jspb.BinaryReader): GetBestAvailableConnectionReply;
toObject(includeInstance?: boolean): GetBestConnectionReply.AsObject;
static toObject(includeInstance: boolean, msg: GetBestConnectionReply): GetBestConnectionReply.AsObject;
static serializeBinaryToWriter(message: GetBestConnectionReply, writer: jspb.BinaryWriter): void;
static deserializeBinary(bytes: Uint8Array): GetBestConnectionReply;
static deserializeBinaryFromReader(message: GetBestConnectionReply, reader: jspb.BinaryReader): GetBestConnectionReply;
}
export namespace GetBestAvailableConnectionReply {
export namespace GetBestConnectionReply {
export type AsObject = {
connection?: UrlConnection.AsObject,
}

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

2056
dist/protobuf/pb_pb.js vendored

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

View File

@ -98,7 +98,7 @@ class HavenoUtils {
* @return {bigint} amount in atomic units
*/
static xmrToAtomicUnits(amountXmr) {
return BigInt(new decimal_js_1.default(amountXmr).mul(HavenoUtils.AU_PER_XMR.toString()).toFixed(0));
return BigInt(new decimal_js_1.default(amountXmr).mul(HavenoUtils.AU_PER_XMR.toString()).toDecimalPlaces(0, decimal_js_1.default.ROUND_HALF_UP).toFixed(0));
}
/**
* Convert atomic units to XMR.
@ -107,7 +107,7 @@ class HavenoUtils {
* @return {number} amount in XMR
*/
static atomicUnitsToXmr(amountAtomicUnits) {
return new decimal_js_1.default(amountAtomicUnits.toString()).div(HavenoUtils.AU_PER_XMR.toString()).toNumber();
return new decimal_js_1.default(amountAtomicUnits.toString()).div(HavenoUtils.AU_PER_XMR.toString()).toDecimalPlaces(12, decimal_js_1.default.ROUND_HALF_UP).toNumber();
}
/**
* Divide one atomic units by another.
@ -117,7 +117,7 @@ class HavenoUtils {
* @returns {number} the result
*/
static divide(au1, au2) {
return this.atomicUnitsToXmr(au1) / this.atomicUnitsToXmr(au2);
return new decimal_js_1.default(au1.toString()).div(new decimal_js_1.default(au2.toString())).toDecimalPlaces(12, decimal_js_1.default.ROUND_HALF_UP).toNumber();
}
/**
* Multiply a bigint by a number or bigint.
@ -127,7 +127,7 @@ class HavenoUtils {
* @returns the product as a bigint
*/
static multiply(a, b) {
return BigInt((new decimal_js_1.default(a.toString()).mul(new decimal_js_1.default(b.toString())).toFixed(0)));
return BigInt(new decimal_js_1.default(a.toString()).mul(new decimal_js_1.default(b.toString())).toDecimalPlaces(0, decimal_js_1.default.ROUND_HALF_UP).toString());
}
/**
* Calculate the difference from a first bigint to a second, as a percentage (float).

File diff suppressed because one or more lines are too long