Skip to content

Commit

Permalink
fix error update
Browse files Browse the repository at this point in the history
  • Loading branch information
chrlschwb committed Aug 28, 2023
1 parent d144823 commit ea5b1a4
Show file tree
Hide file tree
Showing 12 changed files with 279 additions and 19 deletions.
113 changes: 113 additions & 0 deletions distributor-node/src/services/networking/query-node/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -2004,6 +2004,23 @@ enum MembershipExternalResourceType {
WHATSAPP
}

type Validator implements BaseGraphQLObject {
id: ID!
createdAt: DateTime!
createdById: ID!
updatedAt: DateTime
updatedById: ID
deletedAt: DateTime
deletedById: ID
version: Int!
isVerified: Boolean!
validatorAccount: String
member: Membership!
memberId: String!
memberMetadata: MemberMetadata!
memberMetadataId: String!
}

type MemberMetadata implements BaseGraphQLObject {
id: ID!
createdAt: DateTime!
Expand All @@ -2029,6 +2046,7 @@ type MemberMetadata implements BaseGraphQLObject {
memberprofileupdatedeventnewMetadata: [MemberProfileUpdatedEvent!]
membershipboughteventmetadata: [MembershipBoughtEvent!]
membershipgiftedeventmetadata: [MembershipGiftedEvent!]
validatormemberMetadata: [Validator!]
}

union Avatar = AvatarObject | AvatarUri
Expand Down Expand Up @@ -3297,6 +3315,7 @@ type Membership implements BaseGraphQLObject {
stakingaccountaddedeventmember: [StakingAccountAddedEvent!]
stakingaccountconfirmedeventmember: [StakingAccountConfirmedEvent!]
stakingaccountremovedeventmember: [StakingAccountRemovedEvent!]
validatormember: [Validator!]
videoreactedeventreactingMember: [VideoReactedEvent!]
videoreactionmember: [VideoReaction!]
workinggroupapplicationapplicant: [WorkingGroupApplication!]
Expand Down Expand Up @@ -5624,6 +5643,17 @@ type UpcomingWorkingGroupOpeningConnection {
pageInfo: PageInfo!
}

type ValidatorEdge {
node: Validator!
cursor: String!
}

type ValidatorConnection {
totalCount: Int!
edges: [ValidatorEdge!]!
pageInfo: PageInfo!
}

type VideoAssetsDeletedByModeratorEventEdge {
node: VideoAssetsDeletedByModeratorEvent!
cursor: String!
Expand Down Expand Up @@ -17675,6 +17705,63 @@ input MembershipBoughtEventUpdateInput {
referrer: ID
}

input ValidatorWhereInput {
id_eq: ID
id_in: [ID!]
createdAt_eq: DateTime
createdAt_lt: DateTime
createdAt_lte: DateTime
createdAt_gt: DateTime
createdAt_gte: DateTime
createdById_eq: ID
createdById_in: [ID!]
updatedAt_eq: DateTime
updatedAt_lt: DateTime
updatedAt_lte: DateTime
updatedAt_gt: DateTime
updatedAt_gte: DateTime
updatedById_eq: ID
updatedById_in: [ID!]
deletedAt_all: Boolean
deletedAt_eq: DateTime
deletedAt_lt: DateTime
deletedAt_lte: DateTime
deletedAt_gt: DateTime
deletedAt_gte: DateTime
deletedById_eq: ID
deletedById_in: [ID!]
isVerified_eq: Boolean
isVerified_in: [Boolean!]
validatorAccount_eq: String
validatorAccount_contains: String
validatorAccount_startsWith: String
validatorAccount_endsWith: String
validatorAccount_in: [String!]
member: MembershipWhereInput
memberMetadata: MemberMetadataWhereInput
AND: [ValidatorWhereInput!]
OR: [ValidatorWhereInput!]
NOT: [ValidatorWhereInput!]
}

input ValidatorWhereUniqueInput {
id: ID!
}

input ValidatorCreateInput {
isVerified: Boolean!
validatorAccount: String
member: ID!
memberMetadata: ID!
}

input ValidatorUpdateInput {
isVerified: Boolean
validatorAccount: String
member: ID
memberMetadata: ID
}

input MemberMetadataWhereInput {
id_eq: ID
id_in: [ID!]
Expand Down Expand Up @@ -17730,6 +17817,9 @@ input MemberMetadataWhereInput {
membershipgiftedeventmetadata_none: MembershipGiftedEventWhereInput
membershipgiftedeventmetadata_some: MembershipGiftedEventWhereInput
membershipgiftedeventmetadata_every: MembershipGiftedEventWhereInput
validatormemberMetadata_none: ValidatorWhereInput
validatormemberMetadata_some: ValidatorWhereInput
validatormemberMetadata_every: ValidatorWhereInput
AND: [MemberMetadataWhereInput!]
OR: [MemberMetadataWhereInput!]
NOT: [MemberMetadataWhereInput!]
Expand Down Expand Up @@ -21045,6 +21135,9 @@ input MembershipWhereInput {
stakingaccountremovedeventmember_none: StakingAccountRemovedEventWhereInput
stakingaccountremovedeventmember_some: StakingAccountRemovedEventWhereInput
stakingaccountremovedeventmember_every: StakingAccountRemovedEventWhereInput
validatormember_none: ValidatorWhereInput
validatormember_some: ValidatorWhereInput
validatormember_every: ValidatorWhereInput
videoreactedeventreactingMember_none: VideoReactedEventWhereInput
videoreactedeventreactingMember_some: VideoReactedEventWhereInput
videoreactedeventreactingMember_every: VideoReactedEventWhereInput
Expand Down Expand Up @@ -28206,6 +28299,9 @@ type Query {
upcomingWorkingGroupOpenings(offset: Int, limit: Int = 50, where: UpcomingWorkingGroupOpeningWhereInput, orderBy: [UpcomingWorkingGroupOpeningOrderByInput!]): [UpcomingWorkingGroupOpening!]!
upcomingWorkingGroupOpeningByUniqueInput(where: UpcomingWorkingGroupOpeningWhereUniqueInput!): UpcomingWorkingGroupOpening
upcomingWorkingGroupOpeningsConnection(first: Int, after: String, last: Int, before: String, where: UpcomingWorkingGroupOpeningWhereInput, orderBy: [UpcomingWorkingGroupOpeningOrderByInput!]): UpcomingWorkingGroupOpeningConnection!
validators(offset: Int, limit: Int = 50, where: ValidatorWhereInput, orderBy: [ValidatorOrderByInput!]): [Validator!]!
validatorByUniqueInput(where: ValidatorWhereUniqueInput!): Validator
validatorsConnection(first: Int, after: String, last: Int, before: String, where: ValidatorWhereInput, orderBy: [ValidatorOrderByInput!]): ValidatorConnection!
videoAssetsDeletedByModeratorEvents(offset: Int, limit: Int = 50, where: VideoAssetsDeletedByModeratorEventWhereInput, orderBy: [VideoAssetsDeletedByModeratorEventOrderByInput!]): [VideoAssetsDeletedByModeratorEvent!]!
videoAssetsDeletedByModeratorEventByUniqueInput(where: VideoAssetsDeletedByModeratorEventWhereUniqueInput!): VideoAssetsDeletedByModeratorEvent
videoAssetsDeletedByModeratorEventsConnection(first: Int, after: String, last: Int, before: String, where: VideoAssetsDeletedByModeratorEventWhereInput, orderBy: [VideoAssetsDeletedByModeratorEventOrderByInput!]): VideoAssetsDeletedByModeratorEventConnection!
Expand Down Expand Up @@ -32111,6 +32207,23 @@ enum UpcomingWorkingGroupOpeningOrderByInput {
metadata_DESC
}

enum ValidatorOrderByInput {
createdAt_ASC
createdAt_DESC
updatedAt_ASC
updatedAt_DESC
deletedAt_ASC
deletedAt_DESC
isVerified_ASC
isVerified_DESC
validatorAccount_ASC
validatorAccount_DESC
member_ASC
member_DESC
memberMetadata_ASC
memberMetadata_DESC
}

enum VideoAssetsDeletedByModeratorEventOrderByInput {
createdAt_ASC
createdAt_DESC
Expand Down
1 change: 1 addition & 0 deletions metadata-protobuf/proto/Membership.proto
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,5 @@ message MembershipMetadata {
optional string value = 2;
}
repeated ExternalResource externalResources = 5;
optional string validatorAccount = 6;
}
4 changes: 0 additions & 4 deletions query-node/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
### 1.3.0

- Fix external resources mapping of membership metadata to ignore unrecognized type.

### 1.2.2

- Integrates OpenTelemetry API/SDK with Query Node's Graphql Server for exporting improved tracing logs & metrics to Elasticsearch. Adds `./start-elasticsearch-stack.sh` script to bootstrap elasticsearch services (Elasticsearch + Kibana + APM Server) with all the required configurations.
Expand Down
6 changes: 5 additions & 1 deletion query-node/chain-metadata/1001.json

Large diffs are not rendered by default.

6 changes: 5 additions & 1 deletion query-node/chain-metadata/2001.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion query-node/mappings/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "query-node-mappings",
"version": "1.3.0",
"version": "1.2.1",
"description": "Mappings for hydra-processor",
"main": "lib/src/index.js",
"license": "MIT",
Expand Down
1 change: 1 addition & 0 deletions query-node/mappings/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@ export * from './bootstrap'
// export * from './system'
export * from './joystreamUtility'
export * from './temporaryConstants'
export * from './validator'
41 changes: 31 additions & 10 deletions query-node/mappings/src/membership.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ import {
StakingAccountAddedEvent,
StakingAccountConfirmedEvent,
StakingAccountRemovedEvent,
Validator,
WorkingGroup,
} from 'query-node/dist/model'
import {
Expand Down Expand Up @@ -73,7 +74,6 @@ import {
getMemberById,
getWorker,
getWorkingGroupByName,
invalidMetadata,
logger,
saveMetaprotocolTransactionErrored,
saveMetaprotocolTransactionSuccessful,
Expand Down Expand Up @@ -122,19 +122,18 @@ async function saveMembershipExternalResources(
return newExternalResources
}

function asMembershipExternalResource(
export function asMembershipExternalResource(
resource: MembershipMetadata.IExternalResource
): Pick<MembershipExternalResource, 'type' | 'value'>[] {
const typeKey = isSet(resource.type) && MembershipMetadata.ExternalResource.ResourceType[resource.type]

if (typeKey && typeKey in MembershipExternalResourceType) {
const type = MembershipExternalResourceType[typeKey]
const value = resource.value
return type && value ? [{ type, value }] : []
} else {
invalidMetadata(`Invalid ResourceType: ${resource.type}`)
return []
if (!typeKey || !(typeKey in MembershipExternalResourceType)) {
throw new Error(`Invalid ResourceType: ${typeKey}`)
}

const type = MembershipExternalResourceType[typeKey]
const value = resource.value
return type && value ? [{ type, value }] : []
}

async function saveMembershipMetadata(
Expand Down Expand Up @@ -236,13 +235,15 @@ export async function members_MembershipBought({ store, event }: EventContext &
inviteCount.toNumber()
)

const metadata = await saveMembershipMetadata(store, member)

const membershipBoughtEvent = new MembershipBoughtEvent({
...genericEventFields(event),
newMember: member,
controllerAccount: member.controllerAccount,
rootAccount: member.rootAccount,
handle: member.handle,
metadata: await saveMembershipMetadata(store, member),
metadata: metadata,
referrer: member.referredBy,
})

Expand Down Expand Up @@ -299,6 +300,16 @@ export async function members_MemberCreated({ store, event }: EventContext & Sto
isFoundingMember: memberParameters.isFoundingMember.isTrue,
})

const validator = new Validator({
id: member.id,
isVerified: false,
validatorAccount: member.metadata.validatorAccount,
member: member,
memberMetadata: member.metadata,
})

await store.save<Validator>(validator)

await store.save<MemberCreatedEvent>(memberCreatedEvent)

// Update the other side of event<->membership relation
Expand Down Expand Up @@ -330,6 +341,16 @@ export async function members_MemberProfileUpdated({ store, event }: EventContex
member.handle = bytesToString(newHandle.unwrap())
}

const validator = new Validator({
id: member.id,
isVerified: false,
validatorAccount: metadata.validatorAccount,
member: member,
memberMetadata: member.metadata,
})

await store.save<Validator>(validator)

await store.save<MemberMetadata>(member.metadata)
await store.save<Membership>(member)

Expand Down
2 changes: 1 addition & 1 deletion query-node/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "query-node-root",
"version": "1.3.0",
"version": "1.2.2",
"description": "GraphQL server and mappings. Generated with ♥ by Hydra-CLI",
"scripts": {
"build": "./build.sh",
Expand Down
2 changes: 1 addition & 1 deletion query-node/schemas/content.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ type Channel @entity {

"List of all claimed rewards"
claimedRewards: [ChannelRewardClaimedEvent!] @derivedFrom(field: "channel")

"Number of videos ever created in this channel"
totalVideosCreated: Int!
}
Expand Down
7 changes: 7 additions & 0 deletions query-node/schemas/validator.graphql
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
type Validator @entity {
id: ID!
isVerified: Boolean!
validatorAccount: String
member: Membership!
memberMetadata: MemberMetadata!
}
Loading

0 comments on commit ea5b1a4

Please sign in to comment.