lightningdevkit
Version:
Lightning Development Kit
167 lines • 7.04 kB
JavaScript
import { LSPSResponseError } from '../structs/LSPSResponseError.mjs';
import { LSPS1GetInfoResponse } from '../structs/LSPS1GetInfoResponse.mjs';
import { LSPS1CreateOrderResponse } from '../structs/LSPS1CreateOrderResponse.mjs';
import { CommonBase } from './CommonBase.mjs';
import * as bindings from '../bindings.mjs';
/**
* An enum that captures all the valid JSON-RPC responses in the bLIP-51 / LSPS1 protocol.
*/
export class LSPS1Response extends CommonBase {
constructor(_dummy, ptr) { super(ptr, bindings.LSPS1Response_free); }
/* @internal */
static constr_from_ptr(ptr) {
const raw_ty = bindings.LDKLSPS1Response_ty_from_ptr(ptr);
switch (raw_ty) {
case 0: return new LSPS1Response_GetInfo(ptr);
case 1: return new LSPS1Response_GetInfoError(ptr);
case 2: return new LSPS1Response_CreateOrder(ptr);
case 3: return new LSPS1Response_CreateOrderError(ptr);
case 4: return new LSPS1Response_GetOrder(ptr);
case 5: return new LSPS1Response_GetOrderError(ptr);
default:
throw new Error('oops, this should be unreachable'); // Unreachable without extending the (internal) bindings interface
}
}
clone_ptr() {
const ret = bindings.LSPS1Response_clone_ptr(this.ptr);
return ret;
}
/**
* Creates a copy of the LSPS1Response
*/
clone() {
const ret = bindings.LSPS1Response_clone(this.ptr);
const ret_hu_conv = LSPS1Response.constr_from_ptr(ret);
CommonBase.add_ref_from(ret_hu_conv, this);
return ret_hu_conv;
}
/**
* Utility method to constructs a new GetInfo-variant LSPS1Response
*/
static constructor_get_info(a) {
const ret = bindings.LSPS1Response_get_info(CommonBase.get_ptr_of(a));
const ret_hu_conv = LSPS1Response.constr_from_ptr(ret);
CommonBase.add_ref_from(ret_hu_conv, ret_hu_conv);
return ret_hu_conv;
}
/**
* Utility method to constructs a new GetInfoError-variant LSPS1Response
*/
static constructor_get_info_error(a) {
const ret = bindings.LSPS1Response_get_info_error(CommonBase.get_ptr_of(a));
const ret_hu_conv = LSPS1Response.constr_from_ptr(ret);
CommonBase.add_ref_from(ret_hu_conv, ret_hu_conv);
return ret_hu_conv;
}
/**
* Utility method to constructs a new CreateOrder-variant LSPS1Response
*/
static constructor_create_order(a) {
const ret = bindings.LSPS1Response_create_order(CommonBase.get_ptr_of(a));
const ret_hu_conv = LSPS1Response.constr_from_ptr(ret);
CommonBase.add_ref_from(ret_hu_conv, ret_hu_conv);
return ret_hu_conv;
}
/**
* Utility method to constructs a new CreateOrderError-variant LSPS1Response
*/
static constructor_create_order_error(a) {
const ret = bindings.LSPS1Response_create_order_error(CommonBase.get_ptr_of(a));
const ret_hu_conv = LSPS1Response.constr_from_ptr(ret);
CommonBase.add_ref_from(ret_hu_conv, ret_hu_conv);
return ret_hu_conv;
}
/**
* Utility method to constructs a new GetOrder-variant LSPS1Response
*/
static constructor_get_order(a) {
const ret = bindings.LSPS1Response_get_order(CommonBase.get_ptr_of(a));
const ret_hu_conv = LSPS1Response.constr_from_ptr(ret);
CommonBase.add_ref_from(ret_hu_conv, ret_hu_conv);
return ret_hu_conv;
}
/**
* Utility method to constructs a new GetOrderError-variant LSPS1Response
*/
static constructor_get_order_error(a) {
const ret = bindings.LSPS1Response_get_order_error(CommonBase.get_ptr_of(a));
const ret_hu_conv = LSPS1Response.constr_from_ptr(ret);
CommonBase.add_ref_from(ret_hu_conv, ret_hu_conv);
return ret_hu_conv;
}
/**
* Checks if two LSPS1Responses contain equal inner contents.
* This ignores pointers and is_owned flags and looks at the values in fields.
*/
eq(b) {
const ret = bindings.LSPS1Response_eq(this.ptr, CommonBase.get_ptr_of(b));
return ret;
}
}
/** A LSPS1Response of type GetInfo */
export class LSPS1Response_GetInfo extends LSPS1Response {
/* @internal */
constructor(ptr) {
super(null, ptr);
const get_info = bindings.LDKLSPS1Response_GetInfo_get_get_info(ptr);
const get_info_hu_conv = new LSPS1GetInfoResponse(null, get_info);
CommonBase.add_ref_from(get_info_hu_conv, this);
this.get_info = get_info_hu_conv;
}
}
/** A LSPS1Response of type GetInfoError */
export class LSPS1Response_GetInfoError extends LSPS1Response {
/* @internal */
constructor(ptr) {
super(null, ptr);
const get_info_error = bindings.LDKLSPS1Response_GetInfoError_get_get_info_error(ptr);
const get_info_error_hu_conv = new LSPSResponseError(null, get_info_error);
CommonBase.add_ref_from(get_info_error_hu_conv, this);
this.get_info_error = get_info_error_hu_conv;
}
}
/** A LSPS1Response of type CreateOrder */
export class LSPS1Response_CreateOrder extends LSPS1Response {
/* @internal */
constructor(ptr) {
super(null, ptr);
const create_order = bindings.LDKLSPS1Response_CreateOrder_get_create_order(ptr);
const create_order_hu_conv = new LSPS1CreateOrderResponse(null, create_order);
CommonBase.add_ref_from(create_order_hu_conv, this);
this.create_order = create_order_hu_conv;
}
}
/** A LSPS1Response of type CreateOrderError */
export class LSPS1Response_CreateOrderError extends LSPS1Response {
/* @internal */
constructor(ptr) {
super(null, ptr);
const create_order_error = bindings.LDKLSPS1Response_CreateOrderError_get_create_order_error(ptr);
const create_order_error_hu_conv = new LSPSResponseError(null, create_order_error);
CommonBase.add_ref_from(create_order_error_hu_conv, this);
this.create_order_error = create_order_error_hu_conv;
}
}
/** A LSPS1Response of type GetOrder */
export class LSPS1Response_GetOrder extends LSPS1Response {
/* @internal */
constructor(ptr) {
super(null, ptr);
const get_order = bindings.LDKLSPS1Response_GetOrder_get_get_order(ptr);
const get_order_hu_conv = new LSPS1CreateOrderResponse(null, get_order);
CommonBase.add_ref_from(get_order_hu_conv, this);
this.get_order = get_order_hu_conv;
}
}
/** A LSPS1Response of type GetOrderError */
export class LSPS1Response_GetOrderError extends LSPS1Response {
/* @internal */
constructor(ptr) {
super(null, ptr);
const get_order_error = bindings.LDKLSPS1Response_GetOrderError_get_get_order_error(ptr);
const get_order_error_hu_conv = new LSPSResponseError(null, get_order_error);
CommonBase.add_ref_from(get_order_error_hu_conv, this);
this.get_order_error = get_order_error_hu_conv;
}
}
//# sourceMappingURL=LSPS1Response.mjs.map