Skip to content

Commit ed251bf

Browse files
committed
lib: add service api definitions
1 parent ef525d2 commit ed251bf

File tree

7 files changed

+102
-1
lines changed

7 files changed

+102
-1
lines changed

lib/api/faraday.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import { FaradayServer } from '../types/proto/faraday/faraday';
2+
import { serviceNames as sn } from '../types/proto/schema';
3+
4+
/**
5+
* An API wrapper to communicate with the Faraday node via GRPC
6+
*/
7+
class FaradayApi {
8+
faradayServer: FaradayServer;
9+
10+
constructor(createRpc: Function, lnc: any) {
11+
this.faradayServer = createRpc(sn.frdrpc.FaradayServer, lnc);
12+
}
13+
}
14+
15+
export default FaradayApi;

lib/api/index.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
export { default as LndApi } from './lnd';
2+
export { default as LoopApi } from './loop';
3+
export { default as PoolApi } from './pool';
4+
export { default as FaradayApi } from './faraday';

lib/api/lnd.ts

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import { Autopilot } from '../types/proto/lnd/autopilotrpc/autopilot';
2+
import { ChainNotifier } from '../types/proto/lnd/chainrpc/chainnotifier';
3+
import { Invoices } from '../types/proto/lnd/invoicesrpc/invoices';
4+
import { Lightning } from '../types/proto/lnd/lightning';
5+
import { Router } from '../types/proto/lnd/routerrpc/router';
6+
import { Signer } from '../types/proto/lnd/signrpc/signer';
7+
import { WalletKit } from '../types/proto/lnd/walletrpc/walletkit';
8+
import { WalletUnlocker } from '../types/proto/lnd/walletunlocker';
9+
import { Watchtower } from '../types/proto/lnd/watchtowerrpc/watchtower';
10+
import { WatchtowerClient } from '../types/proto/lnd/wtclientrpc/wtclient';
11+
import { serviceNames as sn } from '../types/proto/schema';
12+
13+
/**
14+
* An API wrapper to communicate with the LND node via GRPC
15+
*/
16+
class LndApi {
17+
autopilot: Autopilot;
18+
chainNotifier: ChainNotifier;
19+
invoices: Invoices;
20+
lightning: Lightning;
21+
router: Router;
22+
signer: Signer;
23+
walletKit: WalletKit;
24+
walletUnlocker: WalletUnlocker;
25+
watchtower: Watchtower;
26+
watchtowerClient: WatchtowerClient;
27+
28+
constructor(createRpc: Function, lnc: any) {
29+
this.autopilot = createRpc(sn.autopilotrpc.Autopilot, lnc);
30+
this.chainNotifier = createRpc(sn.chainrpc.ChainNotifier, lnc);
31+
this.invoices = createRpc(sn.invoicesrpc.Invoices, lnc);
32+
this.lightning = createRpc(sn.lnrpc.Lightning, lnc);
33+
this.router = createRpc(sn.routerrpc.Router, lnc);
34+
this.signer = createRpc(sn.signrpc.Signer, lnc);
35+
this.walletKit = createRpc(sn.walletrpc.WalletKit, lnc);
36+
this.walletUnlocker = createRpc(sn.lnrpc.WalletUnlocker, lnc);
37+
this.watchtower = createRpc(sn.watchtowerrpc.Watchtower, lnc);
38+
this.watchtowerClient = createRpc(sn.wtclientrpc.WatchtowerClient, lnc);
39+
}
40+
}
41+
42+
export default LndApi;

lib/api/loop.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import { SwapClient } from '../types/proto/loop/client';
2+
import { Debug } from '../types/proto/loop/debug';
3+
import { serviceNames as sn } from '../types/proto/schema';
4+
5+
/**
6+
* An API wrapper to communicate with the Loop node via GRPC
7+
*/
8+
class LoopApi {
9+
swapClient: SwapClient;
10+
debug: Debug;
11+
12+
constructor(createRpc: Function, lnc: any) {
13+
this.swapClient = createRpc(sn.looprpc.SwapClient, lnc);
14+
this.debug = createRpc(sn.looprpc.Debug, lnc);
15+
}
16+
}
17+
18+
export default LoopApi;

lib/api/pool.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import { ChannelAuctioneer } from '../types/proto/pool/auctioneerrpc/auctioneer';
2+
import { HashMail } from '../types/proto/pool/auctioneerrpc/hashmail';
3+
import { Trader } from '../types/proto/pool/trader';
4+
import { serviceNames as sn } from '../types/proto/schema';
5+
6+
/**
7+
* An API wrapper to communicate with the Pool node via GRPC
8+
*/
9+
class PoolApi {
10+
trader: Trader;
11+
channelAuctioneer: ChannelAuctioneer;
12+
hashmail: HashMail;
13+
14+
constructor(createRpc: Function, lnc: any) {
15+
this.trader = createRpc(sn.poolrpc.Trader, lnc);
16+
this.channelAuctioneer = createRpc(sn.poolrpc.ChannelAuctioneer, lnc);
17+
this.hashmail = createRpc(sn.poolrpc.HashMail, lnc);
18+
}
19+
}
20+
21+
export default PoolApi;

lib/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
export * from './types/proto';
22
export { camelKeysToSnake, isObject, snakeKeysToCamel } from './util/objects';
3+
export { LndApi, LoopApi, PoolApi, FaradayApi } from './api';

tslint.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"extends": ["tslint:recommended", "tslint-config-prettier"],
33
"rules": {
4+
"ban-types": false,
45
"max-line-length": {
56
"options": [120]
67
},
@@ -23,4 +24,3 @@
2324
]
2425
}
2526
}
26-

0 commit comments

Comments
 (0)