@fedimint/core-web 0.0.3 → 0.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -4
- package/dist/FedimintWallet.d.ts +42 -65
- package/dist/FedimintWallet.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/services/BalanceService.d.ts +34 -0
- package/dist/services/BalanceService.d.ts.map +1 -0
- package/dist/services/FederationService.d.ts +11 -0
- package/dist/services/FederationService.d.ts.map +1 -0
- package/dist/services/LightningService.d.ts +18 -0
- package/dist/services/LightningService.d.ts.map +1 -0
- package/dist/services/MintService.d.ts +15 -0
- package/dist/services/MintService.d.ts.map +1 -0
- package/dist/services/RecoveryService.d.ts +13 -0
- package/dist/services/RecoveryService.d.ts.map +1 -0
- package/dist/services/index.d.ts +6 -0
- package/dist/services/index.d.ts.map +1 -0
- package/dist/types/wallet.d.ts +16 -11
- package/dist/types/wallet.d.ts.map +1 -1
- package/dist/utils/logger.d.ts +17 -0
- package/dist/utils/logger.d.ts.map +1 -0
- package/dist/worker/WorkerClient.d.ts +44 -0
- package/dist/worker/WorkerClient.d.ts.map +1 -0
- package/dist/worker/index.d.ts +2 -0
- package/dist/worker/index.d.ts.map +1 -0
- package/dist/worker.js +1 -1
- package/dist/worker.js.map +1 -1
- package/package.json +9 -9
- package/src/FedimintWallet.test.ts +77 -0
- package/src/FedimintWallet.ts +91 -466
- package/src/services/BalanceService.test.ts +50 -0
- package/src/services/BalanceService.ts +50 -0
- package/src/services/FederationService.test.ts +58 -0
- package/src/services/FederationService.ts +22 -0
- package/src/services/LightningService.test.ts +168 -0
- package/src/services/LightningService.ts +144 -0
- package/src/services/MintService.test.ts +19 -0
- package/src/services/MintService.ts +96 -0
- package/src/services/RecoveryService.ts +26 -0
- package/src/services/index.ts +5 -0
- package/src/test/TestFedimintWallet.ts +17 -0
- package/src/test/TestingService.ts +59 -0
- package/src/test/setupTests.ts +43 -0
- package/src/types/wallet.ts +20 -13
- package/src/utils/logger.ts +61 -0
- package/src/worker/WorkerClient.ts +229 -0
- package/src/worker/index.ts +1 -0
- package/src/worker/worker.js +96 -0
- package/src/worker/worker.test.ts +90 -0
- package/node_modules/fedimint-client-wasm/fedimint_client_wasm.d.ts +0 -49
- package/node_modules/fedimint-client-wasm/fedimint_client_wasm.js +0 -4
- package/node_modules/fedimint-client-wasm/fedimint_client_wasm_bg.js +0 -1411
- package/node_modules/fedimint-client-wasm/fedimint_client_wasm_bg.wasm +0 -0
- package/node_modules/fedimint-client-wasm/package.json +0 -26
- package/src/worker.js +0 -80
- package/wasm/fedimint_client_wasm.d.ts +0 -49
- package/wasm/fedimint_client_wasm.js +0 -4
- package/wasm/fedimint_client_wasm_bg.js +0 -1411
- package/wasm/fedimint_client_wasm_bg.wasm +0 -0
- package/wasm/fedimint_client_wasm_bg.wasm.d.ts +0 -110
- package/wasm/package.json +0 -26
package/README.md
CHANGED
|
@@ -57,19 +57,19 @@ if (!wallet.isOpen()) {
|
|
|
57
57
|
}
|
|
58
58
|
|
|
59
59
|
// Get Wallet Balance (sync)
|
|
60
|
-
const balance = await wallet.getBalance()
|
|
60
|
+
const balance = await wallet.balance.getBalance()
|
|
61
61
|
|
|
62
62
|
// Subscribe to Balance Updates
|
|
63
|
-
const unsubscribe = wallet.subscribeBalance((balance: number) => {
|
|
63
|
+
const unsubscribe = wallet.balance.subscribeBalance((balance: number) => {
|
|
64
64
|
console.log('updated balance', balance)
|
|
65
65
|
})
|
|
66
66
|
// Make sure to call `unsubscribe()` when you're done
|
|
67
67
|
|
|
68
68
|
// Receive Ecash Payments
|
|
69
|
-
await wallet.reissueNotes('A11qgqpw9thwvaz7t...')
|
|
69
|
+
await wallet.mint.reissueNotes('A11qgqpw9thwvaz7t...')
|
|
70
70
|
|
|
71
71
|
// Pay Lightning Invoice
|
|
72
|
-
await wallet.
|
|
72
|
+
await wallet.lightning.payInvoice('lnbc...')
|
|
73
73
|
```
|
|
74
74
|
|
|
75
75
|
### Check out the example
|
package/dist/FedimintWallet.d.ts
CHANGED
|
@@ -1,82 +1,59 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { BalanceService, MintService, LightningService, FederationService, RecoveryService } from './services';
|
|
2
|
+
import { type LogLevel } from './utils/logger';
|
|
2
3
|
export declare class FedimintWallet {
|
|
3
|
-
private
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
private _client;
|
|
5
|
+
balance: BalanceService;
|
|
6
|
+
mint: MintService;
|
|
7
|
+
lightning: LightningService;
|
|
8
|
+
federation: FederationService;
|
|
9
|
+
recovery: RecoveryService;
|
|
10
|
+
private _openPromise;
|
|
11
|
+
private _resolveOpen;
|
|
7
12
|
private _isOpen;
|
|
8
|
-
private requestCounter;
|
|
9
|
-
private requestCallbacks;
|
|
10
|
-
constructor(lazy?: boolean, open?: boolean);
|
|
11
|
-
waitForOpen(): Promise<void>;
|
|
12
|
-
private getNextRequestId;
|
|
13
|
-
private sendSingleMessage;
|
|
14
|
-
initialize(): Promise<void>;
|
|
15
|
-
private handleWorkerMessage;
|
|
16
|
-
open(clientName?: string): Promise<any>;
|
|
17
|
-
joinFederation(inviteCode: string, clientName?: string): Promise<void>;
|
|
18
13
|
/**
|
|
19
|
-
*
|
|
14
|
+
* Creates a new instance of FedimintWallet.
|
|
20
15
|
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
* correctly, even if the unsubscribe function is called before the subscription
|
|
25
|
-
* is fully established, by deferring the unsubscription attempt using `setTimeout`.
|
|
16
|
+
* This constructor initializes a FedimintWallet instance, which manages communication
|
|
17
|
+
* with a Web Worker. The Web Worker is responsible for running WebAssembly code that
|
|
18
|
+
* handles the core Fedimint Client operations.
|
|
26
19
|
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
20
|
+
* (default) When not in lazy mode, the constructor immediately initializes the
|
|
21
|
+
* Web Worker and begins loading the WebAssembly module in the background. This
|
|
22
|
+
* allows for faster subsequent operations but may increase initial load time.
|
|
29
23
|
*
|
|
24
|
+
* In lazy mode, the Web Worker and WebAssembly initialization are deferred until
|
|
25
|
+
* the first operation that requires them, reducing initial overhead at the cost
|
|
26
|
+
* of a slight delay on the first operation.
|
|
30
27
|
*
|
|
31
|
-
* @
|
|
32
|
-
*
|
|
33
|
-
* @param module - The module kind to interact with.
|
|
34
|
-
* @param method - The method name to invoke on the module.
|
|
35
|
-
* @param body - The request payload.
|
|
36
|
-
* @param onSuccess - Callback invoked with the response data on success.
|
|
37
|
-
* @param onError - Callback invoked with error information if an error occurs.
|
|
38
|
-
* @param onEnd - Optional callback invoked when the stream ends.
|
|
39
|
-
* @returns A function that can be called to cancel the subscription.
|
|
28
|
+
* @param {boolean} lazy - If true, delays Web Worker and WebAssembly initialization
|
|
29
|
+
* until needed. Default is false.
|
|
40
30
|
*
|
|
31
|
+
* @example
|
|
32
|
+
* // Create a wallet with immediate initialization
|
|
33
|
+
* const wallet = new FedimintWallet();
|
|
34
|
+
* wallet.open();
|
|
35
|
+
*
|
|
36
|
+
* // Create a wallet with lazy initialization
|
|
37
|
+
* const lazyWallet = new FedimintWallet(true);
|
|
38
|
+
* // Some time later...
|
|
39
|
+
* lazyWallet.initialize();
|
|
40
|
+
* lazyWallet.open();
|
|
41
41
|
*/
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
reissueExternalNotes(oobNotes: string, extraMeta: JSONObject): Promise<string>;
|
|
48
|
-
subscribeReissueExternalNotes(operationId: string, onSuccess?: (state: JSONValue) => void, onError?: (error: string) => void): CancelFunction;
|
|
49
|
-
spendNotes(minAmount: number, tryCancelAfter: number, includeInvite: boolean, extraMeta: JSONValue): Promise<JSONValue>;
|
|
50
|
-
validateNotes(oobNotes: string): Promise<number>;
|
|
51
|
-
tryCancelSpendNotes(operationId: string): Promise<void>;
|
|
52
|
-
subscribeSpendNotes(operationId: string, onSuccess?: (state: JSONValue) => void, onError?: (error: string) => void): CancelFunction;
|
|
53
|
-
awaitSpendOobRefund(operationId: string): Promise<JSONValue>;
|
|
42
|
+
constructor(lazy?: boolean);
|
|
43
|
+
initialize(): Promise<void>;
|
|
44
|
+
waitForOpen(): Promise<void | null>;
|
|
45
|
+
open(clientName?: string): Promise<any>;
|
|
46
|
+
joinFederation(inviteCode: string, clientName?: string): Promise<void>;
|
|
54
47
|
/**
|
|
55
48
|
* This should ONLY be called when UNLOADING the wallet client.
|
|
56
49
|
* After this call, the FedimintWallet instance should be discarded.
|
|
57
50
|
*/
|
|
58
51
|
cleanup(): Promise<void>;
|
|
59
52
|
isOpen(): boolean;
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
waitForAllRecoveries(): Promise<void>;
|
|
66
|
-
subscribeBalance(onSuccess?: (balance: number) => void, onError?: (error: string) => void): CancelFunction;
|
|
67
|
-
subscribeToRecoveryProgress(onSuccess?: (progress: {
|
|
68
|
-
module_id: number;
|
|
69
|
-
progress: JSONValue;
|
|
70
|
-
}) => void, onError?: (error: string) => void): CancelFunction;
|
|
71
|
-
createBolt11InvoiceWithGateway(amount: number, description: string, expiryTime: (number | null) | undefined, extraMeta: JSONObject | undefined, gatewayInfo: GatewayInfo): Promise<JSONValue>;
|
|
72
|
-
createBolt11Invoice(amount: number, description: string, expiryTime?: number | null, extraMeta?: JSONObject): Promise<CreateBolt11Response>;
|
|
73
|
-
payBolt11InvoiceWithGateway(invoice: string, gatewayInfo: GatewayInfo, extraMeta?: JSONObject): Promise<JSONValue>;
|
|
74
|
-
_getDefaultGatewayInfo(): Promise<LightningGateway>;
|
|
75
|
-
payBolt11Invoice(invoice: string, extraMeta?: JSONObject): Promise<OutgoingLightningPayment>;
|
|
76
|
-
subscribeLnPay(operationId: string, onSuccess?: (state: LnPayState) => void, onError?: (error: string) => void): CancelFunction;
|
|
77
|
-
subscribeLnReceive(operationId: string, onSuccess?: (state: LnReceiveState) => void, onError?: (error: string) => void): CancelFunction;
|
|
78
|
-
getGateway(gatewayId?: string | null, forceInternal?: boolean): Promise<LightningGateway | null>;
|
|
79
|
-
listGateways(): Promise<LightningGateway[]>;
|
|
80
|
-
updateGatewayCache(): Promise<void>;
|
|
53
|
+
/**
|
|
54
|
+
* Sets the log level for the library.
|
|
55
|
+
* @param level The desired log level ('DEBUG', 'INFO', 'WARN', 'ERROR', 'NONE').
|
|
56
|
+
*/
|
|
57
|
+
setLogLevel(level: LogLevel): void;
|
|
81
58
|
}
|
|
82
59
|
//# sourceMappingURL=FedimintWallet.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FedimintWallet.d.ts","sourceRoot":"","sources":["../src/FedimintWallet.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"FedimintWallet.d.ts","sourceRoot":"","sources":["../src/FedimintWallet.ts"],"names":[],"mappings":"AACA,OAAO,EACL,cAAc,EACd,WAAW,EACX,gBAAgB,EAChB,iBAAiB,EACjB,eAAe,EAChB,MAAM,YAAY,CAAA;AACnB,OAAO,EAAU,KAAK,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AAItD,qBAAa,cAAc;IACzB,OAAO,CAAC,OAAO,CAAc;IAEtB,OAAO,EAAE,cAAc,CAAA;IACvB,IAAI,EAAE,WAAW,CAAA;IACjB,SAAS,EAAE,gBAAgB,CAAA;IAC3B,UAAU,EAAE,iBAAiB,CAAA;IAC7B,QAAQ,EAAE,eAAe,CAAA;IAEhC,OAAO,CAAC,YAAY,CAA6B;IACjD,OAAO,CAAC,YAAY,CAAuB;IAC3C,OAAO,CAAC,OAAO,CAAiB;IAEhC;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA4BG;gBACS,IAAI,GAAE,OAAe;IAkB3B,UAAU;IAMV,WAAW;IAKX,IAAI,CAAC,UAAU,GAAE,MAA4B;IAc7C,cAAc,CAClB,UAAU,EAAE,MAAM,EAClB,UAAU,GAAE,MAA4B;IAkB1C;;;OAGG;IACG,OAAO;IAMb,MAAM;IAIN;;;OAGG;IACH,WAAW,CAAC,KAAK,EAAE,QAAQ;CAI5B"}
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const e="
|
|
1
|
+
const e=["debug","info","warn","error","none"];const t=new class{constructor(e="none"){this.level=e}setLevel(e){this.level=e}coerceLevel(t){return e.includes(t.toLocaleUpperCase())?t.toLocaleUpperCase():"info"}log(e,t,...i){const n=this.coerceLevel(e);if(!this.shouldLog(n))return;(0,console[n])(`[${n.toUpperCase()}] ${t}`,...i)}debug(e,...t){this.log("debug",e,...t)}info(e,...t){this.log("info",e,...t)}warn(e,...t){this.log("warn",e,...t)}error(e,...t){this.log("error",e,...t)}shouldLog(e){const t=["debug","info","warn","error","none"],i=t.indexOf(e);return t.indexOf(this.level)<=i&&"none"!==this.level&&"none"!==e}};class i{constructor(){this.requestCounter=0,this.requestCallbacks=new Map,this.initPromise=null,this.worker=new Worker(new URL("./worker.js",import.meta.url),{type:"module"}),this.worker.onmessage=this.handleWorkerMessage.bind(this),this.worker.onerror=this.handleWorkerError.bind(this),t.info("WorkerClient instantiated"),t.debug("WorkerClient",this.worker)}initialize(){return this.initPromise||(this.initPromise=this.sendSingleMessage("init")),this.initPromise}handleWorkerLogs(e){const{type:i,level:n,message:s,...r}=e.data;t.log(n,s,...r)}handleWorkerError(e){t.error("Worker error",e)}handleWorkerMessage(e){const{type:i,requestId:n,...s}=e.data;"log"===i&&this.handleWorkerLogs(e.data);const r=this.requestCallbacks.get(n);t.debug("WorkerClient - handleWorkerMessage",e.data),r?r(s):t.warn("WorkerClient - handleWorkerMessage - received message with no callback",n,e.data)}sendSingleMessage(e,i){return new Promise(((n,s)=>{const r=++this.requestCounter;t.debug("WorkerClient - sendSingleMessage",r,e,i),this.requestCallbacks.set(r,(e=>{this.requestCallbacks.delete(r),t.debug("WorkerClient - sendSingleMessage - response",r,e),e.data?n(e.data):e.error?s(e.error):t.warn("WorkerClient - sendSingleMessage - malformed response",r,e)})),this.worker.postMessage({type:e,payload:i,requestId:r})}))}rpcStream(e,i,n,s,r,a=()=>{}){const o=++this.requestCounter;t.debug("WorkerClient - rpcStream",o,e,i,n);let l=()=>{},c=!1;const h=new Promise((e=>{l=()=>{c?e():setTimeout((()=>l()),0)}}));return this._rpcStreamInner(o,e,i,n,s,r,a,h).then((()=>{c=!0})),l}async _rpcStreamInner(e,t,i,n,s,r,a=()=>{},o){this.requestCallbacks.set(e,(t=>{void 0!==t.error?r(t.error):void 0!==t.data?s(t.data):void 0!==t.end&&(this.requestCallbacks.delete(e),a())})),this.worker.postMessage({type:"rpc",payload:{module:t,method:i,body:n},requestId:e}),o.then((()=>{this.worker?.postMessage({type:"unsubscribe",requestId:e}),this.requestCallbacks.delete(e)}))}rpcSingle(e,i,n){return t.debug("WorkerClient - rpcSingle",e,i,n),new Promise(((t,s)=>{this.rpcStream(e,i,n,t,s)}))}cleanup(){this.worker.terminate(),this.initPromise=null,this.requestCallbacks.clear()}_getRequestCounter(){return this.requestCounter}_getRequestCallbackMap(){return this.requestCallbacks}}class n{constructor(e){this.client=e}async redeemEcash(e){await this.client.rpcSingle("mint","reissue_external_notes",{oob_notes:e,extra_meta:null})}async reissueExternalNotes(e,t={}){return await this.client.rpcSingle("mint","reissue_external_notes",{oob_notes:e,extra_meta:t})}subscribeReissueExternalNotes(e,t=()=>{},i=()=>{}){return this.client.rpcStream("mint","subscribe_reissue_external_notes",{operation_id:e},t,i)}async spendNotes(e,t=0,i=!1,n={}){return console.error("tryCancelAfter",t),await this.client.rpcSingle("mint","spend_notes",{min_amount:e,try_cancel_after:null,include_invite:i,extra_meta:n})}async validateNotes(e){return await this.client.rpcSingle("mint","validate_notes",{oob_notes:e})}async tryCancelSpendNotes(e){await this.client.rpcSingle("mint","try_cancel_spend_notes",{operation_id:e})}subscribeSpendNotes(e,t=()=>{},i=()=>{}){return this.client.rpcStream("mint","subscribe_spend_notes",{operation_id:e},(e=>t(e)),i)}async awaitSpendOobRefund(e){return await this.client.rpcSingle("mint","await_spend_oob_refund",{operation_id:e})}}class s{constructor(e){this.client=e}async getBalance(){return await this.client.rpcSingle("","get_balance",{})}subscribeBalance(e=()=>{},t=()=>{}){return this.client.rpcStream("","subscribe_balance_changes",{},(t=>e(parseInt(t))),t)}}class r{constructor(e){this.client=e}async createInvoiceWithGateway(e,t,i=null,n={},s){return await this.client.rpcSingle("ln","create_bolt11_invoice",{amount:e,description:t,expiry_time:i,extra_meta:n,gateway:s})}async createInvoice(e,t,i=null,n={}){await this.updateGatewayCache();const s=await this._getDefaultGatewayInfo();return await this.client.rpcSingle("ln","create_bolt11_invoice",{amount:e,description:t,expiry_time:i,extra_meta:n,gateway:s.info})}async payInvoiceWithGateway(e,t,i={}){return await this.client.rpcSingle("ln","pay_bolt11_invoice",{maybe_gateway:t,invoice:e,extra_meta:i})}async _getDefaultGatewayInfo(){return(await this.listGateways())[0]}async payInvoice(e,t={}){await this.updateGatewayCache();const i=await this._getDefaultGatewayInfo();return await this.client.rpcSingle("ln","pay_bolt11_invoice",{maybe_gateway:i.info,invoice:e,extra_meta:t})}subscribeLnPay(e,t=()=>{},i=()=>{}){return this.client.rpcStream("ln","subscribe_ln_pay",{operation_id:e},t,i)}subscribeLnReceive(e,t=()=>{},i=()=>{}){return this.client.rpcStream("ln","subscribe_ln_receive",{operation_id:e},t,i)}async waitForReceive(e){return new Promise(((t,i)=>{const n=this.subscribeLnReceive(e,(e=>{"claimed"===e&&t(e)}),i);setTimeout((()=>{n(),i(new Error("Timeout waiting for receive"))}),1e4)}))}async getGateway(e=null,t=!1){return await this.client.rpcSingle("ln","get_gateway",{gateway_id:e,force_internal:t})}async listGateways(){return await this.client.rpcSingle("ln","list_gateways",{})}async updateGatewayCache(){return await this.client.rpcSingle("ln","update_gateway_cache",{})}}class a{constructor(e){this.client=e}async hasPendingRecoveries(){return await this.client.rpcSingle("","has_pending_recoveries",{})}async waitForAllRecoveries(){await this.client.rpcSingle("","wait_for_all_recoveries",{})}subscribeToRecoveryProgress(e,t){return this.client.rpcStream("","subscribe_to_recovery_progress",{},e,t)}}class o{constructor(e){this.client=e}async getConfig(){return await this.client.rpcSingle("","get_config",{})}async getFederationId(){return await this.client.rpcSingle("","get_federation_id",{})}async getInviteCode(e){return await this.client.rpcSingle("","get_invite_code",{peer:e})}async listOperations(){return await this.client.rpcSingle("","list_operations",{})}}const l="fm-default";class c{constructor(e=!1){this._openPromise=null,this._resolveOpen=()=>{},this._isOpen=!1,this._openPromise=new Promise((e=>{this._resolveOpen=e})),this._client=new i,this.mint=new n(this._client),this.lightning=new r(this._client),this.balance=new s(this._client),this.federation=new o(this._client),this.recovery=new a(this._client),t.info("FedimintWallet instantiated"),e||this.initialize()}async initialize(){t.info("Initializing WorkerClient"),await this._client.initialize(),t.info("WorkerClient initialized")}async waitForOpen(){return this._isOpen?Promise.resolve():this._openPromise}async open(e=l){if(await this._client.initialize(),this._isOpen)throw new Error("The FedimintWallet is already open.");const{success:t}=await this._client.sendSingleMessage("open",{clientName:e});return t&&(this._isOpen=!!t,this._resolveOpen()),t}async joinFederation(e,t=l){if(await this._client.initialize(),this._isOpen)throw new Error("The FedimintWallet is already open. You can only call `joinFederation` on closed clients.");(await this._client.sendSingleMessage("join",{inviteCode:e,clientName:t})).success&&(this._isOpen=!0,this._resolveOpen())}async cleanup(){this._openPromise=null,this._isOpen=!1,this._client.cleanup()}isOpen(){return this._isOpen}setLogLevel(e){t.setLevel(e),t.info(`Log level set to ${e}.`)}}export{c as FedimintWallet};
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../src/FedimintWallet.ts"],"sourcesContent":[null],"names":["
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../src/utils/logger.ts","../src/worker/WorkerClient.ts","../src/services/MintService.ts","../src/services/BalanceService.ts","../src/services/LightningService.ts","../src/services/RecoveryService.ts","../src/services/FederationService.ts","../src/FedimintWallet.ts"],"sourcesContent":[null,null,null,null,null,null,null,null],"names":["logLevels","logger","constructor","level","this","setLevel","coerceLevel","includes","toLocaleUpperCase","log","message","args","logLevel","shouldLog","consoleFn","console","toUpperCase","debug","info","warn","error","messageLevel","levels","messageLevelIndex","indexOf","WorkerClient","requestCounter","requestCallbacks","Map","initPromise","worker","Worker","URL","url","type","onmessage","handleWorkerMessage","bind","onerror","handleWorkerError","initialize","sendSingleMessage","handleWorkerLogs","event","data","requestId","streamCallback","get","payload","Promise","resolve","reject","set","response","delete","postMessage","rpcStream","module","method","body","onSuccess","onError","onEnd","unsubscribe","isSubscribed","unsubscribePromise","setTimeout","_rpcStreamInner","then","undefined","end","rpcSingle","cleanup","terminate","clear","_getRequestCounter","_getRequestCallbackMap","MintService","client","redeemEcash","notes","oob_notes","extra_meta","reissueExternalNotes","oobNotes","extraMeta","subscribeReissueExternalNotes","operationId","operation_id","spendNotes","minAmount","tryCancelAfter","includeInvite","min_amount","try_cancel_after","include_invite","validateNotes","tryCancelSpendNotes","subscribeSpendNotes","res","awaitSpendOobRefund","BalanceService","getBalance","subscribeBalance","parseInt","LightningService","createInvoiceWithGateway","amount","description","expiryTime","gatewayInfo","expiry_time","gateway","createInvoice","updateGatewayCache","_getDefaultGatewayInfo","payInvoiceWithGateway","invoice","maybe_gateway","listGateways","payInvoice","subscribeLnPay","subscribeLnReceive","waitForReceive","Error","getGateway","gatewayId","forceInternal","gateway_id","force_internal","RecoveryService","hasPendingRecoveries","waitForAllRecoveries","subscribeToRecoveryProgress","FederationService","getConfig","getFederationId","getInviteCode","peer","listOperations","DEFAULT_CLIENT_NAME","FedimintWallet","lazy","_openPromise","_resolveOpen","_isOpen","_client","mint","lightning","balance","federation","recovery","waitForOpen","open","clientName","success","joinFederation","inviteCode","isOpen","setLogLevel"],"mappings":"AAAA,MAAMA,EAAY,CAAC,QAAS,OAAQ,OAAQ,QAAS,QA4D9C,MAAMC,EAAS,UAtDpB,WAAAC,C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
|
+
*
|
|
5
|
+
* The Balance Service provides methods to interact with the balance of a Fedimint wallet.
|
|
6
|
+
*/
|
|
7
|
+
export declare class BalanceService {
|
|
8
|
+
private client;
|
|
9
|
+
constructor(client: WorkerClient);
|
|
10
|
+
/**
|
|
11
|
+
* Get the balance of the current wallet
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```ts
|
|
15
|
+
* const balance = await wallet.balance.getBalance()
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
getBalance(): Promise<number>;
|
|
19
|
+
/**
|
|
20
|
+
* Subscribe to the balance of the current wallet
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* ```ts
|
|
24
|
+
* const unsubscribe = wallet.balance.subscribeBalance((balance) => {
|
|
25
|
+
* console.log(balance)
|
|
26
|
+
* })
|
|
27
|
+
*
|
|
28
|
+
* // ...Cleanup Later
|
|
29
|
+
* unsubscribe()
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
|
+
subscribeBalance(onSuccess?: (balance: number) => void, onError?: (error: string) => void): import("../types/wallet").CancelFunction;
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=BalanceService.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BalanceService.d.ts","sourceRoot":"","sources":["../../src/services/BalanceService.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAA;AAExC;;;;GAIG;AACH,qBAAa,cAAc;IACb,OAAO,CAAC,MAAM;gBAAN,MAAM,EAAE,YAAY;IAExC;;;;;;;OAOG;IACG,UAAU,IAAI,OAAO,CAAC,MAAM,CAAC;IAInC;;;;;;;;;;;;OAYG;IACH,gBAAgB,CACd,SAAS,GAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAe,EAC/C,OAAO,GAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAe;CAY9C"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { JSONValue } from '../types/wallet';
|
|
2
|
+
import { WorkerClient } from '../worker';
|
|
3
|
+
export declare class FederationService {
|
|
4
|
+
private client;
|
|
5
|
+
constructor(client: WorkerClient);
|
|
6
|
+
getConfig(): Promise<JSONValue>;
|
|
7
|
+
getFederationId(): Promise<string>;
|
|
8
|
+
getInviteCode(peer: number): Promise<string | null>;
|
|
9
|
+
listOperations(): Promise<JSONValue[]>;
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=FederationService.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FederationService.d.ts","sourceRoot":"","sources":["../../src/services/FederationService.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAC3C,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAA;AAExC,qBAAa,iBAAiB;IAChB,OAAO,CAAC,MAAM;gBAAN,MAAM,EAAE,YAAY;IAElC,SAAS,IAAI,OAAO,CAAC,SAAS,CAAC;IAI/B,eAAe,IAAI,OAAO,CAAC,MAAM,CAAC;IAIlC,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;IAInD,cAAc,IAAI,OAAO,CAAC,SAAS,EAAE,CAAC;CAG7C"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { WorkerClient } from '../worker';
|
|
2
|
+
import { CreateBolt11Response, GatewayInfo, JSONObject, JSONValue, LightningGateway, LnPayState, LnReceiveState, OutgoingLightningPayment } from '../types/wallet';
|
|
3
|
+
export declare class LightningService {
|
|
4
|
+
private client;
|
|
5
|
+
constructor(client: WorkerClient);
|
|
6
|
+
createInvoiceWithGateway(amount: number, description: string, expiryTime: (number | null) | undefined, extraMeta: JSONObject | undefined, gatewayInfo: GatewayInfo): Promise<JSONValue>;
|
|
7
|
+
createInvoice(amount: number, description: string, expiryTime?: number | null, extraMeta?: JSONObject): Promise<CreateBolt11Response>;
|
|
8
|
+
payInvoiceWithGateway(invoice: string, gatewayInfo: GatewayInfo, extraMeta?: JSONObject): Promise<JSONValue>;
|
|
9
|
+
private _getDefaultGatewayInfo;
|
|
10
|
+
payInvoice(invoice: string, extraMeta?: JSONObject): Promise<OutgoingLightningPayment>;
|
|
11
|
+
subscribeLnPay(operationId: string, onSuccess?: (state: LnPayState) => void, onError?: (error: string) => void): import("../types/wallet").CancelFunction;
|
|
12
|
+
subscribeLnReceive(operationId: string, onSuccess?: (state: LnReceiveState) => void, onError?: (error: string) => void): import("../types/wallet").CancelFunction;
|
|
13
|
+
waitForReceive(operationId: string): Promise<LnReceiveState>;
|
|
14
|
+
getGateway(gatewayId?: string | null, forceInternal?: boolean): Promise<LightningGateway | null>;
|
|
15
|
+
listGateways(): Promise<LightningGateway[]>;
|
|
16
|
+
updateGatewayCache(): Promise<JSONValue>;
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=LightningService.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LightningService.d.ts","sourceRoot":"","sources":["../../src/services/LightningService.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAA;AACxC,OAAO,EACL,oBAAoB,EACpB,WAAW,EACX,UAAU,EACV,SAAS,EACT,gBAAgB,EAChB,UAAU,EACV,cAAc,EACd,wBAAwB,EACzB,MAAM,iBAAiB,CAAA;AAExB,qBAAa,gBAAgB;IACf,OAAO,CAAC,MAAM;gBAAN,MAAM,EAAE,YAAY;IAElC,wBAAwB,CAC5B,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,MAAM,EACnB,UAAU,GAAE,MAAM,GAAG,IAAI,aAAO,EAChC,SAAS,EAAE,UAAU,YAAK,EAC1B,WAAW,EAAE,WAAW;IAWpB,aAAa,CACjB,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,MAAM,EACnB,UAAU,GAAE,MAAM,GAAG,IAAW,EAChC,SAAS,GAAE,UAAe,GACzB,OAAO,CAAC,oBAAoB,CAAC;IAY1B,qBAAqB,CACzB,OAAO,EAAE,MAAM,EACf,WAAW,EAAE,WAAW,EACxB,SAAS,GAAE,UAAe;YASd,sBAAsB;IAK9B,UAAU,CACd,OAAO,EAAE,MAAM,EACf,SAAS,GAAE,UAAe,GACzB,OAAO,CAAC,wBAAwB,CAAC;IAUpC,cAAc,CACZ,WAAW,EAAE,MAAM,EACnB,SAAS,GAAE,CAAC,KAAK,EAAE,UAAU,KAAK,IAAe,EACjD,OAAO,GAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAe;IAa7C,kBAAkB,CAChB,WAAW,EAAE,MAAM,EACnB,SAAS,GAAE,CAAC,KAAK,EAAE,cAAc,KAAK,IAAe,EACrD,OAAO,GAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAe;IAavC,cAAc,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC;IAgB5D,UAAU,CACd,SAAS,GAAE,MAAM,GAAG,IAAW,EAC/B,aAAa,GAAE,OAAe,GAC7B,OAAO,CAAC,gBAAgB,GAAG,IAAI,CAAC;IAO7B,YAAY,IAAI,OAAO,CAAC,gBAAgB,EAAE,CAAC;IAI3C,kBAAkB,IAAI,OAAO,CAAC,SAAS,CAAC;CAG/C"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { WorkerClient } from '../worker';
|
|
2
|
+
import { JSONObject, JSONValue } from '../types/wallet';
|
|
3
|
+
export declare class MintService {
|
|
4
|
+
private client;
|
|
5
|
+
constructor(client: WorkerClient);
|
|
6
|
+
redeemEcash(notes: string): Promise<void>;
|
|
7
|
+
reissueExternalNotes(oobNotes: string, extraMeta?: JSONObject): Promise<string>;
|
|
8
|
+
subscribeReissueExternalNotes(operationId: string, onSuccess?: (state: JSONValue) => void, onError?: (error: string) => void): import("../types/wallet").CancelFunction;
|
|
9
|
+
spendNotes(minAmount: number, tryCancelAfter?: number, includeInvite?: boolean, extraMeta?: JSONValue): Promise<JSONValue>;
|
|
10
|
+
validateNotes(oobNotes: string): Promise<number>;
|
|
11
|
+
tryCancelSpendNotes(operationId: string): Promise<void>;
|
|
12
|
+
subscribeSpendNotes(operationId: string, onSuccess?: (state: JSONValue) => void, onError?: (error: string) => void): import("../types/wallet").CancelFunction;
|
|
13
|
+
awaitSpendOobRefund(operationId: string): Promise<JSONValue>;
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=MintService.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MintService.d.ts","sourceRoot":"","sources":["../../src/services/MintService.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAA;AACxC,OAAO,EACL,UAAU,EACV,SAAS,EAEV,MAAM,iBAAiB,CAAA;AAExB,qBAAa,WAAW;IACV,OAAO,CAAC,MAAM;gBAAN,MAAM,EAAE,YAAY;IAElC,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAOzC,oBAAoB,CACxB,QAAQ,EAAE,MAAM,EAChB,SAAS,GAAE,UAAe,GACzB,OAAO,CAAC,MAAM,CAAC;IAOlB,6BAA6B,CAC3B,WAAW,EAAE,MAAM,EACnB,SAAS,GAAE,CAAC,KAAK,EAAE,SAAS,KAAK,IAAe,EAChD,OAAO,GAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAe;IAavC,UAAU,CACd,SAAS,EAAE,MAAM,EAKjB,cAAc,GAAE,MAAU,EAC1B,aAAa,GAAE,OAAe,EAC9B,SAAS,GAAE,SAAc,GACxB,OAAO,CAAC,SAAS,CAAC;IAUf,aAAa,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAMhD,mBAAmB,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAM7D,mBAAmB,CACjB,WAAW,EAAE,MAAM,EACnB,SAAS,GAAE,CAAC,KAAK,EAAE,SAAS,KAAK,IAAe,EAChD,OAAO,GAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAe;IAavC,mBAAmB,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,CAAC;CAKnE"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { JSONValue } from '../types/wallet';
|
|
2
|
+
import { WorkerClient } from '../worker';
|
|
3
|
+
export declare class RecoveryService {
|
|
4
|
+
private client;
|
|
5
|
+
constructor(client: WorkerClient);
|
|
6
|
+
hasPendingRecoveries(): Promise<boolean>;
|
|
7
|
+
waitForAllRecoveries(): Promise<void>;
|
|
8
|
+
subscribeToRecoveryProgress(onSuccess: (progress: {
|
|
9
|
+
module_id: number;
|
|
10
|
+
progress: JSONValue;
|
|
11
|
+
}) => void, onError: (error: string) => void): () => void;
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=RecoveryService.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RecoveryService.d.ts","sourceRoot":"","sources":["../../src/services/RecoveryService.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAC3C,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAA;AAExC,qBAAa,eAAe;IACd,OAAO,CAAC,MAAM;gBAAN,MAAM,EAAE,YAAY;IAElC,oBAAoB,IAAI,OAAO,CAAC,OAAO,CAAC;IAIxC,oBAAoB,IAAI,OAAO,CAAC,IAAI,CAAC;IAI3C,2BAA2B,CACzB,SAAS,EAAE,CAAC,QAAQ,EAAE;QAAE,SAAS,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,SAAS,CAAA;KAAE,KAAK,IAAI,EACzE,OAAO,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,GAC/B,MAAM,IAAI;CAQd"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { MintService } from './MintService';
|
|
2
|
+
export { BalanceService } from './BalanceService';
|
|
3
|
+
export { LightningService } from './LightningService';
|
|
4
|
+
export { RecoveryService } from './RecoveryService';
|
|
5
|
+
export { FederationService } from './FederationService';
|
|
6
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/services/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAC3C,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AACjD,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AACrD,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AACnD,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAA"}
|
package/dist/types/wallet.d.ts
CHANGED
|
@@ -31,37 +31,37 @@ type PayType = {
|
|
|
31
31
|
type: 'Internal' | 'Lightning';
|
|
32
32
|
operation_id: string;
|
|
33
33
|
};
|
|
34
|
-
type LnPayState = '
|
|
35
|
-
|
|
34
|
+
type LnPayState = 'created' | 'canceled' | {
|
|
35
|
+
funded: {
|
|
36
36
|
block_height: number;
|
|
37
37
|
};
|
|
38
38
|
} | {
|
|
39
|
-
|
|
39
|
+
waiting_for_refund: {
|
|
40
40
|
error_reason: string;
|
|
41
41
|
};
|
|
42
|
-
} | '
|
|
42
|
+
} | 'awaiting_change' | {
|
|
43
43
|
Success: {
|
|
44
44
|
preimage: string;
|
|
45
45
|
};
|
|
46
46
|
} | {
|
|
47
|
-
|
|
47
|
+
refunded: {
|
|
48
48
|
gateway_error: string;
|
|
49
49
|
};
|
|
50
50
|
} | {
|
|
51
|
-
|
|
51
|
+
unexpected_error: {
|
|
52
52
|
error_message: string;
|
|
53
53
|
};
|
|
54
54
|
};
|
|
55
|
-
type LnReceiveState = '
|
|
56
|
-
|
|
55
|
+
type LnReceiveState = 'created' | {
|
|
56
|
+
waiting_for_payment: {
|
|
57
57
|
invoice: string;
|
|
58
58
|
timeout: number;
|
|
59
59
|
};
|
|
60
60
|
} | {
|
|
61
|
-
|
|
61
|
+
canceled: {
|
|
62
62
|
reason: string;
|
|
63
63
|
};
|
|
64
|
-
} | '
|
|
64
|
+
} | 'funded' | 'awaiting_funds' | 'claimed';
|
|
65
65
|
type CreateBolt11Response = {
|
|
66
66
|
operation_id: string;
|
|
67
67
|
invoice: string;
|
|
@@ -83,5 +83,10 @@ type StreamEnd = {
|
|
|
83
83
|
};
|
|
84
84
|
type StreamResult<T extends JSONValue> = StreamSuccess<T> | StreamError | StreamEnd;
|
|
85
85
|
type CancelFunction = () => void;
|
|
86
|
-
|
|
86
|
+
type ReissueExternalNotesState = 'Created' | 'Issuing' | 'Done' | {
|
|
87
|
+
Failed: {
|
|
88
|
+
error: string;
|
|
89
|
+
};
|
|
90
|
+
};
|
|
91
|
+
export { JSONValue, JSONObject, LightningGateway, RouteHint, FeeToAmount, OutgoingLightningPayment, PayType, LnPayState, LnReceiveState, CreateBolt11Response, GatewayInfo, StreamError, StreamSuccess, StreamResult, ModuleKind, CancelFunction, ReissueExternalNotesState, };
|
|
87
92
|
//# sourceMappingURL=wallet.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wallet.d.ts","sourceRoot":"","sources":["../../src/types/wallet.ts"],"names":[],"mappings":"AAAA,QAAA,MAAM,YAAY,6BAA8B,CAAA;AAChD,KAAK,UAAU,GAAG,CAAC,OAAO,YAAY,CAAC,CAAC,MAAM,CAAC,CAAA;AAC/C,KAAK,SAAS,GACV,MAAM,GACN,MAAM,GACN,OAAO,GACP,IAAI,GACJ;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,CAAA;CAAE,GAC5B,SAAS,EAAE,CAAA;AAEf,KAAK,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,CAAA;AAE3C,KAAK,WAAW,GAAG;IACjB,UAAU,EAAE,MAAM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E,GAC7D;IAAE,QAAQ,EAAE;QAAE,MAAM,EAAE,MAAM,CAAA;KAAE,CAAA;CAAE,GAChC,QAAQ,GACR,gBAAgB,GAChB,SAAS,CAAA;AAEb,KAAK,oBAAoB,GAAG;IAC1B,YAAY,EAAE,MAAM,CAAA;IACpB,OAAO,EAAE,MAAM,CAAA;CAChB,CAAA;AAED,KAAK,WAAW,GAAG;IACjB,KAAK,EAAE,MAAM,CAAA;IACb,IAAI,EAAE,KAAK,CAAA;IACX,GAAG,EAAE,KAAK,CAAA;CACX,CAAA;AAED,KAAK,aAAa,CAAC,CAAC,SAAS,SAAS,IAAI;IACxC,IAAI,EAAE,CAAC,CAAA;IACP,KAAK,EAAE,KAAK,CAAA;IACZ,GAAG,EAAE,KAAK,CAAA;CACX,CAAA;AAED,KAAK,SAAS,GAAG;IACf,GAAG,EAAE,MAAM,CAAA;IACX,IAAI,EAAE,KAAK,CAAA;IACX,KAAK,EAAE,KAAK,CAAA;CACb,CAAA;AAED,KAAK,YAAY,CAAC,CAAC,SAAS,SAAS,IACjC,aAAa,CAAC,CAAC,CAAC,GAChB,WAAW,GACX,SAAS,CAAA;AAEb,KAAK,cAAc,GAAG,MAAM,IAAI,CAAA;AAEhC,KAAK,yBAAyB,GAC1B,SAAS,GACT,SAAS,GACT,MAAM,GACN;IAAE,MAAM,EAAE;QAAE,KAAK,EAAE,MAAM,CAAA;KAAE,CAAA;CAAE,CAAA;AAEjC,OAAO,EACL,SAAS,EACT,UAAU,EACV,gBAAgB,EAChB,SAAS,EACT,WAAW,EACX,wBAAwB,EACxB,OAAO,EACP,UAAU,EACV,cAAc,EACd,oBAAoB,EACpB,WAAW,EACX,WAAW,EACX,aAAa,EACb,YAAY,EACZ,UAAU,EACV,cAAc,EACd,yBAAyB,GAC1B,CAAA"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
declare const logLevels: readonly ["debug", "info", "warn", "error", "none"];
|
|
2
|
+
export type LogLevel = (typeof logLevels)[number];
|
|
3
|
+
export declare class Logger {
|
|
4
|
+
private level;
|
|
5
|
+
constructor(level?: LogLevel);
|
|
6
|
+
setLevel(level: LogLevel): void;
|
|
7
|
+
coerceLevel(level: string): LogLevel;
|
|
8
|
+
log(level: string, message: string, ...args: any[]): void;
|
|
9
|
+
debug(message: string, ...args: any[]): void;
|
|
10
|
+
info(message: string, ...args: any[]): void;
|
|
11
|
+
warn(message: string, ...args: any[]): void;
|
|
12
|
+
error(message: string, ...args: any[]): void;
|
|
13
|
+
private shouldLog;
|
|
14
|
+
}
|
|
15
|
+
export declare const logger: Logger;
|
|
16
|
+
export {};
|
|
17
|
+
//# sourceMappingURL=logger.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../src/utils/logger.ts"],"names":[],"mappings":"AAAA,QAAA,MAAM,SAAS,qDAAsD,CAAA;AACrE,MAAM,MAAM,QAAQ,GAAG,CAAC,OAAO,SAAS,CAAC,CAAC,MAAM,CAAC,CAAA;AAEjD,qBAAa,MAAM;IACjB,OAAO,CAAC,KAAK,CAAU;gBAEX,KAAK,GAAE,QAAiB;IAIpC,QAAQ,CAAC,KAAK,EAAE,QAAQ;IAIxB,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,QAAQ;IAOpC,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE;IASlD,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE;IAIrC,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE;IAIpC,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE;IAIpC,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE;IAIrC,OAAO,CAAC,SAAS;CAYlB;AAED,eAAO,MAAM,MAAM,QAAe,CAAA"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { CancelFunction, JSONValue, ModuleKind, StreamError } from '../types/wallet';
|
|
2
|
+
export declare class WorkerClient {
|
|
3
|
+
private worker;
|
|
4
|
+
private requestCounter;
|
|
5
|
+
private requestCallbacks;
|
|
6
|
+
private initPromise;
|
|
7
|
+
constructor();
|
|
8
|
+
initialize(): Promise<void>;
|
|
9
|
+
private handleWorkerLogs;
|
|
10
|
+
private handleWorkerError;
|
|
11
|
+
private handleWorkerMessage;
|
|
12
|
+
sendSingleMessage(type: string, payload?: any): Promise<any>;
|
|
13
|
+
/**
|
|
14
|
+
* @summary Initiates an RPC stream with the specified module and method.
|
|
15
|
+
*
|
|
16
|
+
* @description
|
|
17
|
+
* This function sets up an RPC stream by sending a request to a worker and
|
|
18
|
+
* handling responses asynchronously. It ensures that unsubscription is handled
|
|
19
|
+
* correctly, even if the unsubscribe function is called before the subscription
|
|
20
|
+
* is fully established, by deferring the unsubscription attempt using `setTimeout`.
|
|
21
|
+
*
|
|
22
|
+
* The function operates in a non-blocking manner, leveraging Promises to manage
|
|
23
|
+
* asynchronous operations and callbacks to handle responses.
|
|
24
|
+
*
|
|
25
|
+
*
|
|
26
|
+
* @template Response - The expected type of the successful response.
|
|
27
|
+
* @template Body - The type of the request body.
|
|
28
|
+
* @param module - The module kind to interact with.
|
|
29
|
+
* @param method - The method name to invoke on the module.
|
|
30
|
+
* @param body - The request payload.
|
|
31
|
+
* @param onSuccess - Callback invoked with the response data on success.
|
|
32
|
+
* @param onError - Callback invoked with error information if an error occurs.
|
|
33
|
+
* @param onEnd - Optional callback invoked when the stream ends.
|
|
34
|
+
* @returns A function that can be called to cancel the subscription.
|
|
35
|
+
*
|
|
36
|
+
*/
|
|
37
|
+
rpcStream<Response extends JSONValue = JSONValue, Body extends JSONValue = JSONValue>(module: ModuleKind, method: string, body: Body, onSuccess: (res: Response) => void, onError: (res: StreamError['error']) => void, onEnd?: () => void): CancelFunction;
|
|
38
|
+
private _rpcStreamInner;
|
|
39
|
+
rpcSingle<Response extends JSONValue = JSONValue>(module: ModuleKind, method: string, body: JSONValue): Promise<Response>;
|
|
40
|
+
cleanup(): void;
|
|
41
|
+
_getRequestCounter(): number;
|
|
42
|
+
_getRequestCallbackMap(): Map<number, (value: any) => void>;
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=WorkerClient.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"WorkerClient.d.ts","sourceRoot":"","sources":["../../src/worker/WorkerClient.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EACd,SAAS,EACT,UAAU,EACV,WAAW,EAEZ,MAAM,iBAAiB,CAAA;AAKxB,qBAAa,YAAY;IACvB,OAAO,CAAC,MAAM,CAAQ;IACtB,OAAO,CAAC,cAAc,CAAI;IAC1B,OAAO,CAAC,gBAAgB,CAA0C;IAClE,OAAO,CAAC,WAAW,CAA6B;;IAchD,UAAU;IAMV,OAAO,CAAC,gBAAgB;IAKxB,OAAO,CAAC,iBAAiB;IAIzB,OAAO,CAAC,mBAAmB;IAuB3B,iBAAiB,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC;IAwB5D;;;;;;;;;;;;;;;;;;;;;;;OAuBG;IACH,SAAS,CACP,QAAQ,SAAS,SAAS,GAAG,SAAS,EACtC,IAAI,SAAS,SAAS,GAAG,SAAS,EAElC,MAAM,EAAE,UAAU,EAClB,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,IAAI,EACV,SAAS,EAAE,CAAC,GAAG,EAAE,QAAQ,KAAK,IAAI,EAClC,OAAO,EAAE,CAAC,GAAG,EAAE,WAAW,CAAC,OAAO,CAAC,KAAK,IAAI,EAC5C,KAAK,GAAE,MAAM,IAAe,GAC3B,cAAc;YAoCH,eAAe;IA2C7B,SAAS,CAAC,QAAQ,SAAS,SAAS,GAAG,SAAS,EAC9C,MAAM,EAAE,UAAU,EAClB,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,SAAS,GACd,OAAO,CAAC,QAAQ,CAAC;IAOpB,OAAO;IAOP,kBAAkB;IAGlB,sBAAsB,wBAnN6B,GAAG,KAAK,IAAI;CAsNhE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/worker/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA"}
|
package/dist/worker.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
let e=null,s=null;const t=new Map;self.onmessage=async
|
|
1
|
+
globalThis.__vitest_browser_runner__={wrapDynamicImport:e=>e()};let e=null,s=null;const t=new Map;console.log("Worker - init"),self.onmessage=async o=>{const{type:r,payload:n,requestId:i}=o.data;try{if("init"===r)e=(await import("@fedimint/fedimint-client-wasm-bundler")).WasmClient,self.postMessage({type:"initialized",data:{},requestId:i});else if("open"===r){const{clientName:t}=n;s=await e.open(t)||null,self.postMessage({type:"open",data:{success:!!s},requestId:i})}else if("join"===r){const{inviteCode:t,clientName:o}=n;try{s=await e.join_federation(o,t),self.postMessage({type:"join",data:{success:!!s},requestId:i})}catch(e){self.postMessage({type:"error",error:e.message,requestId:i})}}else if("rpc"===r){const{module:e,method:o,body:r}=n;if(console.log("RPC received",e,o,r),!s)return void self.postMessage({type:"error",error:"WasmClient not initialized",requestId:i});const a=await s.rpc(e,o,JSON.stringify(r),(e=>{console.log("RPC response",i,e);const s=JSON.parse(e);if(self.postMessage({type:"rpcResponse",requestId:i,...s}),void 0!==s.end){const e=t.get(i);e?.free()}}));t.set(i,a)}else if("unsubscribe"===r){const e=t.get(i);e&&(e.cancel(),e.free(),t.delete(i))}else self.postMessage({type:"error",error:"Unknown message type",requestId:i})}catch(e){console.error("ERROR",e),self.postMessage({type:"error",error:e,requestId:i})}};
|
|
2
2
|
//# sourceMappingURL=worker.js.map
|