Skip to content

Commit

Permalink
fix: update to use json descriptors
Browse files Browse the repository at this point in the history
  • Loading branch information
JackieJoo committed Nov 5, 2024
1 parent 17593ed commit 4c56466
Show file tree
Hide file tree
Showing 3 changed files with 79 additions and 2 deletions.
72 changes: 72 additions & 0 deletions src/dex/bebop/bebop.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
{
"options": {
"syntax": "proto3"
},
"nested": {
"bebop": {
"nested": {
"PriceUpdate": {
"oneofs": {
"_base": {
"oneof": ["base"]
},
"_quote": {
"oneof": ["quote"]
},
"_lastUpdateTs": {
"oneof": ["lastUpdateTs"]
}
},
"fields": {
"base": {
"type": "bytes",
"id": 1,
"options": {
"proto3_optional": true
}
},
"quote": {
"type": "bytes",
"id": 2,
"options": {
"proto3_optional": true
}
},
"lastUpdateTs": {
"type": "uint64",
"id": 3,
"options": {
"proto3_optional": true
}
},
"bids": {
"rule": "repeated",
"type": "float",
"id": 4,
"options": {
"packed": true
}
},
"asks": {
"rule": "repeated",
"type": "float",
"id": 5,
"options": {
"packed": true
}
}
}
},
"BebopPricingUpdate": {
"fields": {
"pairs": {
"rule": "repeated",
"type": "PriceUpdate",
"id": 1
}
}
}
}
}
}
}
7 changes: 6 additions & 1 deletion src/dex/bebop/validators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,10 @@ export const blacklistResponseValidator = joi.object({
blacklist: joi.array().items(joi.string().min(1)).required(),
});

const root = protobuf.loadSync('src/dex/bebop/bebop.proto');
// Original .proto def
// const root = protobuf.loadSync(__dirname + '/bebop.proto');
// Use .json to not include .proto files
// console.log(JSON.stringify(root.toJSON(), null, 4));

const root = protobuf.loadSync(__dirname + '/bebop.json');
export const BebopPricingUpdate = root.lookupType('bebop.BebopPricingUpdate');
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@
"typeRoots": ["node_modules/@types"],
"esModuleInterop": true
},
"include": ["src/**/*"],
"include": ["src/**/*", "src/dex/bebop/bebop.json"],
"exclude": ["**/*.test.ts"]
}

0 comments on commit 4c56466

Please sign in to comment.