Skip to content

Commit

Permalink
Count the membership's root/controller account into the validator mem…
Browse files Browse the repository at this point in the history
…bership
  • Loading branch information
eshark9312 committed Dec 24, 2023
1 parent afa815c commit 64b6ed0
Showing 1 changed file with 25 additions and 5 deletions.
30 changes: 25 additions & 5 deletions packages/ui/src/validators/providers/provider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,30 @@ export const ValidatorContextProvider = (props: Props) => {

const variables = {
where: {
boundAccounts_containsAny:
(allValidatorsWithCtrlAcc
?.concat(allValidators?.map(({ address }) => address))
.filter((element) => !!element) as string[]) ?? [],
OR: [
{
rootAccount_in:
(allValidatorsWithCtrlAcc
?.concat(allValidators?.map(({ address }) => address))
.filter((element) => !!element) as string[]) ?? [],
},
{
controllerAccount_in:
(allValidatorsWithCtrlAcc
?.concat(allValidators?.map(({ address }) => address))
.filter((element) => !!element) as string[]) ?? [],
},
{
boundAccounts_containsAny:
(allValidatorsWithCtrlAcc
?.concat(allValidators?.map(({ address }) => address))
.filter((element) => !!element) as string[]) ?? [],
},
],
},
}

const { data } = useGetMembersWithDetailsQuery({ variables, skip: !!allValidatorsWithCtrlAcc })
const { data } = useGetMembersWithDetailsQuery({ variables, skip: !allValidatorsWithCtrlAcc })

const memberships = data?.memberships?.map((rawMembership) => ({
membership: asMemberWithDetails(rawMembership),
Expand All @@ -81,6 +97,10 @@ export const ValidatorContextProvider = (props: Props) => {
commission,
...memberships.find(
({ membership }) =>
membership.rootAccount === address ||
membership.rootAccount === controllerAccount ||
membership.controllerAccount === address ||
membership.controllerAccount === controllerAccount ||
membership.boundAccounts.includes(address) ||
(controllerAccount && membership.boundAccounts.includes(controllerAccount))
),
Expand Down

0 comments on commit 64b6ed0

Please sign in to comment.