From cbaa0ace79a84fc1c3f667bd8f22bbe30b870183 Mon Sep 17 00:00:00 2001 From: Alex Lewin <43247027+alexlwn123@users.noreply.github.com> Date: Tue, 17 Sep 2024 12:34:28 -0400 Subject: [PATCH] feat: add invoice generation (#16) --- examples/vite-core/src/App.tsx | 2 +- examples/vite-core/src/index.css | 13 +++++++++++++ packages/core-web/src/FedimintWallet.ts | 12 ++++++++++-- 3 files changed, 24 insertions(+), 3 deletions(-) diff --git a/examples/vite-core/src/App.tsx b/examples/vite-core/src/App.tsx index dff2c89..78297bb 100644 --- a/examples/vite-core/src/App.tsx +++ b/examples/vite-core/src/App.tsx @@ -256,7 +256,7 @@ const GenerateLightningInvoice = () => { {invoice && (
Generated Invoice: -
{invoice}
+
{invoice}
)} {error &&
{error}
} diff --git a/examples/vite-core/src/index.css b/examples/vite-core/src/index.css index 0850ebb..bc3c1e9 100644 --- a/examples/vite-core/src/index.css +++ b/examples/vite-core/src/index.css @@ -106,6 +106,9 @@ button:disabled { padding: 0.75rem; box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1); font-size: 1.1rem; + display: flex; + flex-direction: column; + gap: 0.5rem; } .input-group { @@ -164,3 +167,13 @@ button[type='submit'] { padding: 0.5em 1em; } } + +.invoice-wrap { + white-space: pre-wrap; + word-wrap: break-word; + max-width: 100%; + overflow-x: auto; + background-color: #333; + padding: 0.5rem; + border-radius: 4px; +} diff --git a/packages/core-web/src/FedimintWallet.ts b/packages/core-web/src/FedimintWallet.ts index 6c3ef83..9819869 100644 --- a/packages/core-web/src/FedimintWallet.ts +++ b/packages/core-web/src/FedimintWallet.ts @@ -124,6 +124,14 @@ export class FedimintWallet { // }) // } + private _unsubscribe(requestId: number) { + this.worker?.postMessage({ + type: 'unsubscribe', + requestId, + }) + this.requestCallbacks.delete(requestId) + } + // RPC private _rpcStream< Response extends JSONValue = JSONValue, @@ -147,7 +155,7 @@ export class FedimintWallet { onEnd, ) const unsubscribe = () => { - /// + this._unsubscribe(requestId) } return unsubscribe } @@ -432,7 +440,7 @@ export class FedimintWallet { description, expiry_time: expiryTime, extra_meta: extraMeta, - gateway, + gateway: gateway.info, }) }