From e9508aaeb8b45a7c9b7f2fe429831a86b42814dd Mon Sep 17 00:00:00 2001 From: Evan Kaloudis Date: Fri, 24 Jun 2022 11:56:31 -0400 Subject: [PATCH 1/2] Bump CDN instance of LNC wasm client to v0.1.11-alpha --- lib/lnc.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/lnc.ts b/lib/lnc.ts index 87c78a4..2d7d9b5 100644 --- a/lib/lnc.ts +++ b/lib/lnc.ts @@ -6,7 +6,7 @@ import { snakeKeysToCamel } from './util/objects'; /** The default values for the LncConfig options */ const DEFAULT_CONFIG = { - wasmClientCode: 'https://lightning.engineering/lnc-v0.1.10-alpha.wasm', + wasmClientCode: 'https://lightning.engineering/lnc-v0.1.11-alpha.wasm', namespace: 'default', serverHost: 'mailbox.terminal.lightning.today:443' } as Required; From a8e46f5478f4a21124023a576456d87964b1370a Mon Sep 17 00:00:00 2001 From: Evan Kaloudis Date: Fri, 24 Jun 2022 15:34:58 -0400 Subject: [PATCH 2/2] lnc-web: expose wasmClientGetExpiry(), wasmClientHasPerms(), wasmClientIsReadOnly(), and wasmClientStatus() --- lib/lnc.ts | 32 ++++++++++++++++++++++++++++++++ lib/types/lnc.ts | 17 +++++++++++++++++ 2 files changed, 49 insertions(+) diff --git a/lib/lnc.ts b/lib/lnc.ts index 2d7d9b5..f153b70 100644 --- a/lib/lnc.ts +++ b/lib/lnc.ts @@ -78,6 +78,38 @@ export default class LNC { ); } + get status() { + return ( + this.wasm && + this.wasm.wasmClientStatus && + this.wasm.wasmClientStatus() + ); + } + + get expiry(): Date { + return ( + this.wasm && + this.wasm.wasmClientGetExpiry && + new Date(this.wasm.wasmClientGetExpiry() * 1000) + ); + } + + get isReadOnly() { + return ( + this.wasm && + this.wasm.wasmClientIsReadOnly && + this.wasm.wasmClientIsReadOnly() + ); + } + + hasPerms(permission: string) { + return ( + this.wasm && + this.wasm.wasmClientHasPerms && + this.wasm.wasmClientHasPerms(permission) + ); + } + /** * Downloads the WASM client binary */ diff --git a/lib/types/lnc.ts b/lib/types/lnc.ts index bd6df10..bd7ea90 100644 --- a/lib/types/lnc.ts +++ b/lib/types/lnc.ts @@ -31,6 +31,23 @@ export interface WasmGlobal { request: any, callback: (response: string) => any ) => void; + /** + * Returns true if client has specific permissions + * e.g. 'lnrpc.Lightning.GetInfo' + */ + wasmClientHasPerms: (permission: string) => boolean; + /** + * Returns true if the WASM client is read only + */ + wasmClientIsReadOnly: () => boolean; + /** + * Returns the WASM client status + */ + wasmClientStatus: () => string; + /** + * Returns the WASM client expiry time + */ + wasmClientGetExpiry: () => number; } export interface LncConfig {