@nervosnetwork/fiber-js 0.5.1

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 ADDED
@@ -0,0 +1,16 @@
1
+ # Fiber JS
2
+
3
+ This is a JavaScript wrapper over Fiber wasm, to make Fiber wasm usable in JavaScript projects.
4
+
5
+ ## Build
6
+
7
+ In the root of fiber, run:
8
+ ```
9
+ npm install
10
+ npm build -ws
11
+ ```
12
+ After that, `fiber-js` will be ready to use in npm.
13
+
14
+ ## APIs
15
+
16
+ `fiber-js` provide the same API ad Fiber RPC, see `fiber-js/src/index.ts` for details. For documentation, please refer to the docs of Fiber RPC.
@@ -0,0 +1,5 @@
1
+ declare const _default: typeof Worker & {
2
+ new (): Worker;
3
+ };
4
+ export default _default;
5
+ //# sourceMappingURL=../src/dist/db.worker.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"db.worker.d.ts","sourceRoot":"","sources":["../db.worker.ts"],"names":[],"mappings":"wBAcqB,OAAO,MAAM,GAAG;IAAE,QAAO,MAAM,CAAA;CAAE;AAAtD,wBAAuD"}
@@ -0,0 +1,5 @@
1
+ declare const _default: typeof Worker & {
2
+ new (): Worker;
3
+ };
4
+ export default _default;
5
+ //# sourceMappingURL=../src/dist/fiber.worker.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fiber.worker.d.ts","sourceRoot":"","sources":["../fiber.worker.ts"],"names":[],"mappings":"wBA6CqB,OAAO,MAAM,GAAG;IAAE,QAAO,MAAM,CAAA;CAAE;AAAtD,wBAAuD"}
@@ -0,0 +1,67 @@
1
+ import { AbandonChannelParams, AcceptChannelParams, AcceptChannelResult, ListChannelsParams, ListChannelsResult, OpenChannelParams, OpenChannelResult, ShutdownChannelParams, UpdateChannelParams } from "./types/channel.ts";
2
+ import { GraphChannelsParams, GraphChannelsResult, GraphNodesParams, GraphNodesResult } from "./types/graph.ts";
3
+ import { NodeInfoResult } from "./types/info.ts";
4
+ import { GetInvoiceResult, InvoiceParams, InvoiceResult, NewInvoiceParams, ParseInvoiceParams, ParseInvoiceResult } from "./types/invoice.ts";
5
+ import { BuildPaymentRouterResult, BuildRouterParams, GetPaymentCommandParams, GetPaymentCommandResult, SendPaymentCommandParams, SendPaymentWithRouterParams } from "./types/payment.ts";
6
+ import { ConnectPeerParams, DisconnectPeerParams, ListPeerResult } from "./types/peer.ts";
7
+ /**
8
+ * A Fiber Wasm instance
9
+ */
10
+ declare class Fiber {
11
+ private dbWorker;
12
+ private fiberWorker;
13
+ private inputBuffer;
14
+ private outputBuffer;
15
+ private commandInvokeLock;
16
+ /**
17
+ * Construct a Fiber Wasm instance.
18
+ * inputBuffer and outputBuffer are buffers used for transporting data between database and fiber wasm. Set them to appropriate sizes.
19
+ * @param inputBufferSize Size of inputBuffer
20
+ * @param outputBufferSize Size of outputBuffer
21
+ */
22
+ constructor(inputBufferSize?: number, outputBufferSize?: number);
23
+ /**
24
+ * Start the Fiber Wasm instance.
25
+ * @param config Config file for fiber
26
+ * @param fiberKeyPair keypair used for fiber
27
+ * @param ckbSecretKey secret key for CKB
28
+ * @param chainSpec Chain spec if chain is neither testnet nor mainnet
29
+ * @param logLevel log level, such as `trace`, `debug`, `info`, `error`
30
+ * @param databasePrefix Name prefix of IndexedDB store. Defaults to `/wasm`
31
+ *
32
+ */
33
+ start(config: string, fiberKeyPair: Uint8Array, ckbSecretKey: Uint8Array, chainSpec?: string, logLevel?: "trace" | "debug" | "info" | "error", databasePrefix?: string): Promise<void>;
34
+ invokeCommand(name: string, args?: any[]): Promise<any>;
35
+ /**
36
+ * Stop the fiber instance.
37
+ */
38
+ stop(): Promise<void>;
39
+ openChannel(params: OpenChannelParams): Promise<OpenChannelResult>;
40
+ acceptChannel(params: AcceptChannelParams): Promise<AcceptChannelResult>;
41
+ abandonChannel(params: AbandonChannelParams): Promise<void>;
42
+ listChannels(params: ListChannelsParams): Promise<ListChannelsResult>;
43
+ shutdownChannel(params: ShutdownChannelParams): Promise<void>;
44
+ updateChannel(params: UpdateChannelParams): Promise<void>;
45
+ graphNodes(params: GraphNodesParams): Promise<GraphNodesResult>;
46
+ graphChannels(params: GraphChannelsParams): Promise<GraphChannelsResult>;
47
+ nodeInfo(): Promise<NodeInfoResult>;
48
+ newInvoice(params: NewInvoiceParams): Promise<InvoiceResult>;
49
+ parseInvoice(params: ParseInvoiceParams): Promise<ParseInvoiceResult>;
50
+ getInvoice(params: InvoiceParams): Promise<GetInvoiceResult>;
51
+ cancelInvoice(params: InvoiceParams): Promise<GetInvoiceResult>;
52
+ sendPayment(params: SendPaymentCommandParams): Promise<GetPaymentCommandResult>;
53
+ getPayment(params: GetPaymentCommandParams): Promise<GetPaymentCommandResult>;
54
+ buildRouter(params: BuildRouterParams): Promise<BuildPaymentRouterResult>;
55
+ sendPaymentWithRouter(params: SendPaymentWithRouterParams): Promise<GetPaymentCommandResult>;
56
+ connectPeer(params: ConnectPeerParams): Promise<void>;
57
+ disconnectPeer(params: DisconnectPeerParams): Promise<void>;
58
+ listPeers(): Promise<ListPeerResult>;
59
+ }
60
+ export { Fiber };
61
+ /**
62
+ * Generate a random 32-byte secret key.
63
+ * @returns The secret key.
64
+ */
65
+ export declare function randomSecretKey(): Uint8Array;
66
+ export * from "./types/general.ts";
67
+ //# sourceMappingURL=../src/dist/index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,qBAAqB,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAC9N,OAAO,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAChH,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACjD,OA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