Skip to content

Commit 7b1b8e3

Browse files
authored
Merge pull request #472 from lightninglabs/add-account-rpc-types
2 parents c9d5115 + 342cf24 commit 7b1b8e3

File tree

8 files changed

+2724
-38
lines changed

8 files changed

+2724
-38
lines changed

app/scripts/build-protos.js

Lines changed: 27 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -51,34 +51,14 @@ const protoSources = async () => {
5151

5252
/** list of proto files and patches to apply */
5353
const filePatches = {
54-
lnd: {
55-
patch: 'lnrpc: {}',
56-
folder: 'proto',
57-
},
58-
loop: {
59-
patch: 'looprpc: {}',
60-
folder: 'proto',
61-
},
62-
'swapserverrpc/common': {
63-
patch: 'looprpc: {}',
64-
folder: 'proto'
65-
},
66-
'swapserverrpc/server': {
67-
patch: 'looprpc: {}',
68-
folder: 'proto',
69-
},
70-
trader: {
71-
patch: 'poolrpc: {}',
72-
folder: 'proto',
73-
},
74-
'auctioneerrpc/auctioneer': {
75-
patch: 'poolrpc: {}',
76-
folder: 'proto',
77-
},
78-
'lit-sessions': {
79-
patch: 'litrpc: {}',
80-
folder: 'litrpc',
81-
},
54+
lnd: 'lnrpc: {}',
55+
loop: 'looprpc: {}',
56+
'swapserverrpc/common': 'looprpc: {}',
57+
'swapserverrpc/server': 'looprpc: {}',
58+
trader: 'poolrpc: {}',
59+
'auctioneerrpc/auctioneer': 'poolrpc: {}',
60+
'lit-sessions': 'litrpc: {}',
61+
'lit-accounts': 'litrpc: {}',
8262
};
8363

8464
/**
@@ -102,6 +82,14 @@ const download = async () => {
10282
});
10383
await fs.writeFile(filePath, content);
10484
}
85+
// copy the lit proto files from litrpc to the proto dir so that the original
86+
// files are not modified by `sanitize`
87+
const litProtoFiles = ['lit-sessions', 'lit-accounts'];
88+
for (name of litProtoFiles) {
89+
const src = join(appPath, '..', 'litrpc', `${name}.proto`);
90+
const dest = join(appPath, '..', 'proto', `${name}.proto`);
91+
await fs.copyFile(src, dest);
92+
}
10593
};
10694

10795
/**
@@ -110,19 +98,22 @@ const download = async () => {
11098
*/
11199
const sanitize = async () => {
112100
const filePaths = Object.keys(filePatches).map(name =>
113-
join(appPath, '..', filePatches[name].folder, `${name}.proto`),
101+
join(appPath, '..', 'proto', `${name}.proto`),
114102
);
115103
for (path of filePaths) {
116104
let content = (await fs.readFile(path)).toString();
117105
content = content.replace(
118-
/^(\s*)(repeated )?(u?int64) (\S+) = (\d+);$/gm,
119-
'$1$2$3 $4 = $5 [jstype = JS_STRING];'
106+
/^(\s*)(repeated )?(u?int64) (\S+) = (\d+);$/gm,
107+
'$1$2$3 $4 = $5 [jstype = JS_STRING];',
108+
);
109+
content = content.replace(
110+
/^(\s*)(repeated )?(u?int64) (\S+) = (\d+) \[((?!jstype).*)];$/gm,
111+
'$1$2$3 $4 = $5 [$6, jstype = JS_STRING];',
120112
);
121113
content = content.replace(
122-
/^(\s*)(repeated )?(u?int64) (\S+) = (\d+) \[((?!jstype).*)];$/gm,
123-
'$1$2$3 $4 = $5 [$6, jstype = JS_STRING];'
114+
'import "common.proto"',
115+
'import "swapserverrpc/common.proto"',
124116
);
125-
content = content.replace("import \"common.proto\"", "import \"swapserverrpc/common.proto\"")
126117
await fs.writeFile(path, content);
127118
}
128119
};
@@ -140,9 +131,7 @@ const generate = async () => {
140131
'.bin',
141132
platform() === 'win32' ? 'protoc-gen-ts.cmd' : 'protoc-gen-ts',
142133
);
143-
const files = Object.keys(filePatches).map(
144-
name => `../${filePatches[name].folder}/${name}.proto`,
145-
);
134+
const files = Object.keys(filePatches).map(name => `../proto/${name}.proto`);
146135
const protocCmd = [
147136
'protoc',
148137
`-I../proto`,
@@ -184,7 +173,7 @@ const patch = async () => {
184173
// apply the webpack patch
185174
const patch = [
186175
'/* eslint-disable */',
187-
`var proto = { ${filePatches[filename].patch} };`,
176+
`var proto = { ${filePatches[filename]} };`,
188177
'',
189178
].join('\n');
190179
content = `${patch}\n${content}`;

app/src/setupProxy.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ module.exports = function (app) {
1010
'/poolrpc.Trader',
1111
'/frdrpc.FaradayServer',
1212
'/litrpc.Session',
13+
'/litrpc.Accounts',
1314
],
1415
{
1516
target: 'https://localhost:8443',

app/src/types/generated/lit-accounts_pb.d.ts

Lines changed: 259 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)