-
Notifications
You must be signed in to change notification settings - Fork 404
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
added getter for contract definitions #991
Conversation
Signed-off-by: RosieMurphy0 <[email protected]>
*/ | ||
getContractDefinitionsForChannelName(channelPassed) { | ||
const channelList = this.adapterConfiguration.channels; | ||
const channelWanted = channelList.filter(channelContracts => channelContracts.channelName === channelPassed); |
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 we don't have a validator yet and not sure when a validator would be made available for now lets add some defensive checks here to make sure that there is a channelList, so you can check the example used in getChannelNamesForCreation.
* @param {string} channelPassed channel wanted | ||
* @returns {Array} all of contract definitions for channel | ||
*/ | ||
getContractDefinitionsForChannelName(channelPassed) { |
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.
would suggest changing channelPassed
to channelName
for the parameter
getContractDefinitionsForChannelName(channelPassed) { | ||
const channelList = this.adapterConfiguration.channels; | ||
const channelWanted = channelList.filter(channelContracts => channelContracts.channelName === channelPassed); | ||
const contractDefinitions = channelWanted[0].contracts; |
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 consistency, if the contracts definition is not there, then we should just return an empty array. Currently if it wasn't present we would be returning null or undefined. This will need a further test to check for.
Signed-off-by: RosieMurphy0 <[email protected]>
|
||
if (channelList && Array.isArray(channelList)){ | ||
const channelWanted = channelList.filter(channelContracts => channelContracts.channelName === channelName); | ||
const contractDefinitions = channelWanted[0].contracts; |
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.
Should test here what is in contracts, eg
if (contractDefinitions &&
Array.isArray(contractDefinitions) {
return contractDefinitions;
}
Then add a test to see that you get an empty array is the contracts property hasn't been specified
Signed-off-by: RosieMurphy0 <[email protected]>
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
Signed-off-by: RosieMurphy0 [email protected]
Adds a function that returns the array that holds the contracts for a specified channel from the config file.
Contributes to #940