-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Configuration file #131
Configuration file #131
Conversation
New dependencies detected. Learn more about Socket for GitHub ↗︎
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice refactor!
Some nitpicks.
Co-authored-by: Leandro <alfetopito@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Half way in my review, i need to try it more. I send a few comments.
In general I feel that given the size of the change:
- you could have waited a bit for the review, is good that for such a change we have more eyes
- it looks like this PR does a bunch of things that would be better to keep in separate PRs
I like the config. Feels much better
|
||
## Overview | ||
|
||
The [`ComposableCoW`](https://github.com/cowprotocol/composable-cow) conditional order framework requires a watch-tower to monitor the blockchain for new orders, and to post them to the [CoW Protocol `OrderBook` API](https://api.cow.fi/docs/#/). The watch-tower is a standalone application that can be run locally as a script for development, or deployed as a docker container to a server, or dappnode. | ||
The [programmatic order](https://docs.cow.fi/cow-protocol/concepts/order-types/programmatic-orders) framework requires a watch-tower to monitor the blockchain for new orders, and to post them to the [CoW Protocol `OrderBook` API](https://docs.cow.fi/cow-protocol/reference/apis/orderbook). The watch-tower is a standalone application that can be run locally as a script for development, or deployed as a docker container to a server, or dappnode. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not from this PR, I would start saying with what it is and not what it requires.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about something in these lines:
The programatic orders allow you to automatically place unlimited order, following your arbitrary trading strategy defined using the programmatic order frameworks.
Because smart contracts can't place orders in the Orderbook API, you will need a Watch-Tower that monitors these contracts and places an order on your behalf.
This project contains a general-purpose watch tower that will monitor all or some specific accounts, or orders depending on configuration.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While nice, the idea is mostly that there is a hyperlink there that explains it, and reduces duplication of typing / explanation.
@@ -0,0 +1,12 @@ | |||
{ | |||
"networks": [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is nicer indeed. But now we have an hybrid of envs and config.
Shouldn't we add all the config in the config file if we just made it mandatory to add one?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could, I don't have a strong opinion either way on this, and only did this way so as to minimise work, and minimise type duplication between the watch-tower
and the Pulumi configuration for infrastructure (not a strong argument though).
@@ -1,5 +1,2 @@ | |||
export * from "./run"; | |||
export * from "./runMulti"; | |||
export * from "./replayBlock"; | |||
export * from "./replayTx"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
was this necesary in this PR? now is ok, but feels like could be done in a different PR
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we want to remove these features?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
runMulti
has been superceded (actually,run
was removed andrunMulti
was repurposed torun
).replayBlock
andreplayTx
weren't actually implemented (so removed dead stubs).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Worked great!
soft approve
@@ -343,6 +162,30 @@ function parseAddressOption(option: string, previous: string[] = []): string[] { | |||
return [...previous, option]; | |||
} | |||
|
|||
function validateJSON(filePath: string): Config { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could we reflect in the name this is the JSON of the config file?
validate json sounds too generic.
// Validate the data against the schema | ||
if (!validate(data)) { | ||
console.error("Configuration file validation failed:", validate.errors); | ||
process.exit(1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not a good practice to terminate the program just like that
normally you throw and whomever needs to handle, handles
"type": "array", | ||
"items": { | ||
"type": "object", | ||
"properties": { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit, you can add descriptions to the fields and/or examples
{ | ||
"$schema": "http://json-schema.org/draft-07/schema#", | ||
"type": "object", | ||
"properties": { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what are required
? also default
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure what you mean by this?
protected config: PolicyConfig | undefined; | ||
|
||
constructor({ configBaseUrl }: FilterPolicyParams) { | ||
this.configUrl = configBaseUrl; | ||
constructor(config: Config["networks"][number]["filterPolicy"]) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you give a name to this type? feels hard to read
"defaultAction": { | ||
"$ref": "#/$defs/filterAction" | ||
}, | ||
"owners": { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
owners and handlers have the same type. would it be worth it to reference it?
Actually would be probably be nice to define the FilterPolicy too. This way you will get a Typescript definition for it you can reuse, so you don't need to do things like:
constructor(config: Config["networks"][number]["filterPolicy"]) {
Description
Configuration methodology (via CLI options) has been outgrown with the number of options. This PR removes all chain / network related configuration and moves to a configuration file.
Changes
README.md
How to test
config.json.example
for suitable configurationRelated Issues
Fixes #129