-
Notifications
You must be signed in to change notification settings - Fork 12
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
Init start support gatewayconfig #231
Init start support gatewayconfig #231
Conversation
…ases for getConfig method
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.
Good work 👍
Some feedback and comments.
src/Config/Config.ts
Outdated
const facilitator: FacilitatorConfig = FacilitatorConfig.fromFile(facilitatorConfigPath); | ||
const gatewayAddresses = mosaicConfigPath |
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.
Both params mosaicConfig and gatewayConfig are optional. It should check one of both exists.
Compiler is also complaining on same point on statement gatewayConfigPath!
because of !
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.
As discussed, added configType parameters in fromFile.
); | ||
} else { | ||
// only facilitator config is given. |
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.
It should check if mosaic config exists
. Because from chain with return blank object if it doesn't exist.
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.
I have added suggested approach.
But i think, fromChain should throw error when path is not present.
It will be aligned to what we do in fromFile method.
What do you think ?
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.
Created ticket to align fromChain and fromFile methods OpenST/mosaic-chains#196
src/bin/facilitator-init.ts
Outdated
* @param mosaicConfigPath Path to mosaic config. | ||
* @returns originchain id and gatewayaddresses object. | ||
*/ | ||
function getFromMosaicConfig( |
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.
Please move these methods to some other class.
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.
You could move whole logic to file lib/facilitator-init
and commander method will have only one statement of calling class in lib.
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.
I would suggest to create new ticket for moving other logic to file lib/facilitator-init
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.
Created ticket #240 to address it.
src/bin/facilitator-init.ts
Outdated
commander | ||
.option('-m, --mosaic-config <mosaic-config>', 'path to mosaic configuration') | ||
.option('-q, --gateway-config <gateway-config>', 'path to gateway 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.
why did you decide on q
as option?
I think we should revisit all the options.
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.
I initially thought of -g, but it's already being used for --origin-graph-rpc option in facilitator-init command.
To make short-name for --gateway-config, I used -q in both init and start command.
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.
@abhayks1 @puneet-khushwani-eth what do you think?
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.
As discussed with @puneet-khushwani-eth and @abhayks1 , decided to go for -g for --gateway-config. So, -n is now used for --origin-graph-rpc.
src/bin/facilitator.ts
Outdated
@@ -20,6 +20,6 @@ | |||
import facilitator from 'commander'; | |||
|
|||
facilitator | |||
.command('init <mosaic-config> <aux-chain-id> <origin-password> <auxiliary-password> <origin-rpc> <auxiliary-rpc> <origin-graph-ws> <origin-graph-rpc> <auxiliary-graph-ws> <auxiliary-graph-rpc> <db-path>', 'initializes the facilitator config') | |||
.command('init <token-config> <mosaic-config> <aux-chain-id> <origin-password> <auxiliary-password> <origin-rpc> <auxiliary-rpc> <origin-graph-ws> <origin-graph-rpc> <auxiliary-graph-ws> <auxiliary-graph-rpc> <db-path>', 'initializes the facilitator 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.
what is token 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.
Changed it to gateway-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.
Her does mosaic-config option needed if gateway-config is present?
test/ConfigFactory/getConfig.test.ts
Outdated
const originChain = '2'; | ||
const auxChain = 3; | ||
const facilitatorConfigPath = './facilitator-config.json'; | ||
const mosaicConfigPath = './test/mosaic-config.json'; | ||
const gatewayConfigPath = './gateway-config.json'; | ||
const mosaicJson = `{"originChain":{"chain":"${originChain}"},"auxiliaryChains":{"${auxChain}":{"chainId": ${auxChain}}}}`; |
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 unreadable, extract this json out in a method.
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.
Done
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.
Instead of json, method can return JS object directly because you are parsing json.
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.
Done
test/ConfigFactory/getConfig.test.ts
Outdated
@@ -40,6 +56,16 @@ describe('FacilitatorOptionParser.getConfig()', () => { | |||
return spy; | |||
} | |||
|
|||
function spyGatewayConfigFromFile(gatewayConfig: any): any { |
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.
Please remove any type
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.
There are still many any
types 🤔
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.
for method creating stub should return SinonStubStatic
.
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.
Done
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.
Few inline comments.
src/bin/facilitator.ts
Outdated
@@ -20,6 +20,6 @@ | |||
import facilitator from 'commander'; | |||
|
|||
facilitator | |||
.command('init <mosaic-config> <aux-chain-id> <origin-password> <auxiliary-password> <origin-rpc> <auxiliary-rpc> <origin-graph-ws> <origin-graph-rpc> <auxiliary-graph-ws> <auxiliary-graph-rpc> <db-path>', 'initializes the facilitator config') | |||
.command('init <token-config> <mosaic-config> <aux-chain-id> <origin-password> <auxiliary-password> <origin-rpc> <auxiliary-rpc> <origin-graph-ws> <origin-graph-rpc> <auxiliary-graph-ws> <auxiliary-graph-rpc> <db-path>', 'initializes the facilitator 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.
Her does mosaic-config option needed if gateway-config is present?
@sarvesh-ost @abhayks1 |
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.
LGTM 👍
Do not merge before #225
PR contains following changes :
fixes #212