Skip to content

Commit 803dd4f

Browse files
committed
proto: add patch to fix pool GetInfo response
1 parent 4fb4666 commit 803dd4f

File tree

7 files changed

+507
-49
lines changed

7 files changed

+507
-49
lines changed

app/scripts/build-protos.js

Lines changed: 32 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -52,28 +52,28 @@ const protoSources = async () => {
5252
const filePatches = {
5353
lnd: {
5454
patch: 'lnrpc: {}',
55-
folder: 'proto'
55+
folder: 'proto',
5656
},
5757
loop: {
5858
patch: 'looprpc: {}',
59-
folder: 'proto'
59+
folder: 'proto',
6060
},
6161
common: {
6262
patch: 'looprpc: {}',
63-
folder: 'proto'
63+
folder: 'proto',
6464
},
6565
trader: {
6666
patch: 'poolrpc: {}',
67-
folder: 'proto'
67+
folder: 'proto',
6868
},
6969
'auctioneerrpc/auctioneer': {
7070
patch: 'poolrpc: {}',
71-
folder: 'proto'
71+
folder: 'proto',
7272
},
7373
'lit-sessions': {
7474
patch: 'litrpc: {}',
75-
folder: 'litrpc'
76-
}
75+
folder: 'litrpc',
76+
},
7777
};
7878

7979
/**
@@ -132,9 +132,9 @@ const generate = async () => {
132132
'.bin',
133133
platform() === 'win32' ? 'protoc-gen-ts.cmd' : 'protoc-gen-ts',
134134
);
135-
const files = Object
136-
.keys(filePatches)
137-
.map(name => `../${filePatches[name].folder}/${name}.proto`);
135+
const files = Object.keys(filePatches).map(
136+
name => `../${filePatches[name].folder}/${name}.proto`,
137+
);
138138
const protocCmd = [
139139
'protoc',
140140
`-I../proto`,
@@ -185,13 +185,35 @@ const patch = async () => {
185185
}
186186
};
187187

188+
/**
189+
* *Temporary* patch to workaround a grpc-web issue with deserializing the GetInfoResponse.market_info field.
190+
* This patch will just comment it out in the proto file, which will omit the field in the JS/TS serialization
191+
* code that is generated by the protoc-gen-ts plugin.
192+
* See: https://github.com/lightninglabs/lightning-terminal/pull/337
193+
*/
194+
const patchPool = async () => {
195+
console.log('\nPatching Pool proto file');
196+
const path = join(appPath, '..', 'proto', 'trader.proto');
197+
198+
console.log(` - ${path}`);
199+
let content = await fs.readFile(path);
200+
201+
// comment out the `market_info` field
202+
const line = 'map<uint32, MarketInfo> market_info = 15;';
203+
const patch = '// [workaround, see patchPool() in build-protos.js] ';
204+
content = content.toString().replace(line, patch + line);
205+
206+
await fs.writeFile(path, content);
207+
};
208+
188209
/**
189210
* An async wrapper with error handling around the two funcs above
190211
*/
191212
const main = async () => {
192213
try {
193214
await download();
194215
await sanitize();
216+
await patchPool();
195217
await generate();
196218
await patch();
197219
} catch (error) {

app/src/types/generated/lnd_pb.d.ts

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

app/src/types/generated/lnd_pb.js

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

app/src/types/generated/trader_pb.d.ts

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

0 commit comments

Comments
 (0)