Skip to content

Commit

Permalink
feat: add invoice generation (#16)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexlwn123 authored Sep 17, 2024
1 parent 2185071 commit cbaa0ac
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 3 deletions.
2 changes: 1 addition & 1 deletion examples/vite-core/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ const GenerateLightningInvoice = () => {
{invoice && (
<div className="success">
<strong>Generated Invoice:</strong>
<pre>{invoice}</pre>
<pre className="invoice-wrap">{invoice}</pre>
</div>
)}
{error && <div className="error">{error}</div>}
Expand Down
13 changes: 13 additions & 0 deletions examples/vite-core/src/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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;
}
12 changes: 10 additions & 2 deletions packages/core-web/src/FedimintWallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -147,7 +155,7 @@ export class FedimintWallet {
onEnd,
)
const unsubscribe = () => {
///
this._unsubscribe(requestId)
}
return unsubscribe
}
Expand Down Expand Up @@ -432,7 +440,7 @@ export class FedimintWallet {
description,
expiry_time: expiryTime,
extra_meta: extraMeta,
gateway,
gateway: gateway.info,
})
}

Expand Down

0 comments on commit cbaa0ac

Please sign in to comment.