-
Notifications
You must be signed in to change notification settings - Fork 115
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
Fix/4823 validator profile #4849
Conversation
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.
The mapping looks good. Please reset the changes to the .yarnrc.yml
and query-node/schemas/content.graphql
Also please test the mapping in tests/network-tests/src/flows/membership/updatingProfile.ts
@@ -47,6 +47,9 @@ type MemberMetadata @entity { | |||
|
|||
"Social media handles, email address..." | |||
externalResources: [MembershipExternalResource] @derivedFrom(field: "memberMetadata") | |||
|
|||
isVerified: Boolean! |
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.
Since this is not in a separate entity anymore. Please rename it to something more explicit like isVerifiedValidator
if (typeof metadata?.validatorAccount === 'string') { | ||
member.metadata.validatorAccount = (metadata.validatorAccount || null) as string |
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 could be:
if (typeof metadata?.validatorAccount === 'string') { | |
member.metadata.validatorAccount = (metadata.validatorAccount || null) as string | |
if (typeof metadata?.validatorAccount === 'string' && metadata.validatorAccount !== member.metadata.validatorAccount) { | |
member.metadata.validatorAccount = metadata.validatorAccount || undefined |
To prevent resetting the verification by mistake when the same account is passed and to allow removing the validator account by passing an empty string.
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.
removing null
creates error during membership update test where validatorAccount
should be set to null
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 catch ! I'm not sure of this but maybe null
actually unset the value on hydra while undefined
is ignored (I think I read an issue about something like that a while ago).
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.
The mappings and schema are great now but as I mentioned in the last review please add a test to the membership updating profile flow.
To run the tests locally you can follow the query node README:
- In
.env
uncommentJOYSTREAM_NODE_TAG
and set it to the latest testing image, currently it's:44832c0fe83c518779d52b5b3a2dcce94ae2d805
(do not commit this change. - Run the
./query-node/build.sh
script to build the schema and mappings locally. - Try running
DEBUG=true ./query-node/run-tests.sh memberships
. Hopefully it works otherwise you will have to run the full scenario all the time withDEBUG=true ./query-node/run-tests.sh
(which is more time consuming). - After running the tests once in (1) you might to modify them and re-run the a lot faster with
REUSE_KEYS=true yarn workspace network-tests run-test-scenario memberships
If you change the mappings or the schema, you will have to redo (2) and (3).
You can check this commit for more details and ask me if you get stuck.
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 can reset the yarn.lock
by running git checkout master -- yarn.lock
and committing the changes.
repeated ExternalResource externalResources = 5; | ||
|
||
optional bool isVerifiedValidator = 6; |
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 just realized there shouldn't be any isVerifiedValidator
here. The MembershipMetadata
can only define a validatorAccount
but not whether or not it's verified.
@@ -16,6 +16,8 @@ export type MemberProfileData = { | |||
about?: string | null | |||
avatarUri?: string | null | |||
externalResources?: MembershipMetadata.IExternalResource[] | null | |||
isVerifiedValidator?: boolean |
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.
Same here
isVerifiedValidator?: boolean |
tests/network-tests/src/fixtures/membership/UpdateProfileHappyCaseFixture.ts
Show resolved
Hide resolved
isVerifiedValidator: isSet(this.newValues.isVerifiedValidator) | ||
? this.newValues.isVerifiedValidator | ||
: this.oldValues.isVerifiedValidator, |
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.
So I don't think this is needed
isVerifiedValidator: isSet(this.newValues.isVerifiedValidator) | |
? this.newValues.isVerifiedValidator | |
: this.oldValues.isVerifiedValidator, |
isVerifiedValidator: false, | ||
validatorAccount: 'validator address', |
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.
So it actually test something:
isVerifiedValidator: false, | |
validatorAccount: 'validator address', | |
validatorAccount: 'validator address 2', |
isVerifiedValidator: false, | ||
validatorAccount: 'validator address', |
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.
Then you could try not to pass it to check it remains:
isVerifiedValidator: false, | |
validatorAccount: 'validator address', |
isVerifiedValidator: false, | ||
validatorAccount: 'validator address', |
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.
Finally based on the mappings it should be removable:
isVerifiedValidator: false, | |
validatorAccount: 'validator address', | |
validatorAccount: '', |
{ | ||
handle: 'New handle 1', | ||
name: 'New name', | ||
isVerifiedValidator: false, |
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.
isVerifiedValidator: false, |
? this.newValues.isVerifiedValidator | ||
: this.oldValues.isVerifiedValidator, | ||
validatorAccount: isSet(this.newValues.validatorAccount) | ||
? this.newValues.validatorAccount |
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 expect the validatorAccount
to be null
(i.e removed) when an empty string was passed:
? this.newValues.validatorAccount | |
? this.newValues.validatorAccount || null |
…stream into fix/4823-validator
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 job just a few last minor changes
tests/network-tests/src/Api.ts
Outdated
@@ -124,7 +124,10 @@ export class ApiFactory { | |||
|
|||
constructor(api: ApiPromise, treasuryAccountUri: string, miniSecret: string) { | |||
this.api = api | |||
this.keyring = new Keyring({ type: 'sr25519', ss58Format: JOYSTREAM_ADDRESS_PREFIX }) | |||
this.keyring = new Keyring({ |
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 use git to remove the changes on this file to reduce potential conflicts later
Co-authored-by: Theophile Sandoz <theophile.sandoz@gmail.com>
Co-authored-by: Theophile Sandoz <theophile.sandoz@gmail.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.
💯
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.
Looks good overall. Please revert the changes in query-node/chain-metadata/*.json
files. These are auto-generated files that should be edited.
…stream into fix/4823-validator
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
fix #4823