Skip to content
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

feat: Add more Events related to Badges #309

Merged
merged 9 commits into from
Sep 24, 2024
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 52 additions & 17 deletions report/schemas.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -1045,7 +1045,7 @@ export namespace EthAddress {
// Warning: (ae-missing-release-tag) "Event" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public (undocumented)
export type Event = BidAcceptedEvent | BidReceivedEvent | ItemSoldEvent | RentalEndedEvent | RentalStartedEvent | RoyaltiesEarnedEvent | CollectionCreatedEvent | MoveToParcelEvent | CatalystDeploymentEvent | RewardInProgressEvent | RewardAssignedEvent | CampaignOutOfFundsEvent | CampaignGasPriceHigherThanExpectedEvent | CampaignOutOfStockEvent | RewardDelayedEvent | BadgeGrantedEvent | UsedEmoteEvent | PassportOpenedEvent;
export type Event = BadgeGrantedEvent | BidAcceptedEvent | BidReceivedEvent | CampaignGasPriceHigherThanExpectedEvent | CampaignOutOfFundsEvent | CampaignOutOfStockEvent | CatalystDeploymentEvent | CollectionCreatedEvent | ItemPublishedEvent | ItemSoldEvent | MoveToParcelEvent | PassportOpenedEvent | RentalEndedEvent | RentalStartedEvent | RewardAssignedEvent | RewardDelayedEvent | RewardInProgressEvent | RoyaltiesEarnedEvent | UsedEmoteEvent | VerticalHeightReachedEvent | WalkedDistanceEvent;

// Warning: (ae-missing-release-tag) "Events" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
Expand All @@ -1065,6 +1065,8 @@ export namespace Events {
// (undocumented)
COLLECTION_CREATED = "collection-created",
// (undocumented)
ITEM_PUBLISHED = "item-published",
// (undocumented)
ITEM_SOLD = "item-sold",
// (undocumented)
RENTAL_ENDED = "land-rental-ended",
Expand Down Expand Up @@ -1095,7 +1097,11 @@ export namespace Events {
// (undocumented)
PASSPORT_OPENED = "passport-opened",
// (undocumented)
USED_EMOTE = "used-emote"
USED_EMOTE = "used-emote",
// (undocumented)
VERTICAL_HEIGHT_REACHED = "vertical-height-reached",
// (undocumented)
WALKED_DISTANCE = "walked-distance"
}
// (undocumented)
export enum Marketplace {
Expand Down Expand Up @@ -1404,27 +1410,32 @@ export type ItemFilters = {
emoteHasGeometry?: boolean;
};

// Warning: (ae-missing-release-tag) "ItemPublishedEvent" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal)
// Warning: (ae-missing-release-tag) "ItemPublishedEvent" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public (undocumented)
export type ItemPublishedEvent = BaseEvent & {
type: Events.Type.BLOCKCHAIN;
subType: Events.SubType.Blockchain.ITEM_PUBLISHED;
metadata: ItemEventMetadata;
};

// @public (undocumented)
export namespace ItemPublishedEvent {
const // (undocumented)
schema: JSONSchema<ItemPublishedEvent>;
const // (undocumented)
validate: ValidateFunction<ItemPublishedEvent>;
}

// Warning: (ae-missing-release-tag) "ItemSoldEvent" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal)
// Warning: (ae-missing-release-tag) "ItemSoldEvent" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public (undocumented)
export type ItemSoldEvent = BaseEvent & {
type: Events.Type.BLOCKCHAIN;
subType: Events.SubType.Blockchain.ITEM_SOLD;
metadata: {
address: string;
image: string;
buyer: string;
seller: string;
category: string;
rarity?: string;
link: string;
nftName?: string;
tokenId: string;
network: string;
title: string;
description: string;
};
metadata: ItemEventMetadata;
};

// @public (undocumented)
Expand Down Expand Up @@ -3385,6 +3396,29 @@ export type ValidWorldRange = {
yMax: number;
};

// Warning: (ae-missing-release-tag) "VerticalHeightReachedEvent" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public (undocumented)
export type VerticalHeightReachedEvent = BaseEvent & {
type: Events.Type.CLIENT;
subType: Events.SubType.Client.VERTICAL_HEIGHT_REACHED;
metadata: ClientBaseMetadata & {
height: number;
};
};

// Warning: (ae-missing-release-tag) "WalkedDistanceEvent" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public (undocumented)
export type WalkedDistanceEvent = BaseEvent & {
type: Events.Type.CLIENT;
subType: Events.SubType.Client.WALKED_DISTANCE;
metadata: ClientBaseMetadata & {
distance: number;
stepCount: number;
};
};

// @alpha (undocumented)
export type Wearable = BaseItem & {
data: {
Expand Down Expand Up @@ -3626,7 +3660,8 @@ export namespace WorldConfiguration {
// src/dapps/trade.ts:80:3 - (ae-incompatible-release-tags) The symbol "chainId" is marked as @public, but its signature references "ChainId" which is marked as @alpha
// src/dapps/trade.ts:91:3 - (ae-incompatible-release-tags) The symbol "network" is marked as @public, but its signature references "Network" which is marked as @alpha
// src/dapps/trade.ts:92:3 - (ae-incompatible-release-tags) The symbol "chainId" is marked as @public, but its signature references "ChainId" which is marked as @alpha
// src/platform/events/blockchain.ts:128:3 - (ae-forgotten-export) The symbol "RentalMetadata" needs to be exported by the entry point index.d.ts
// src/platform/events/blockchain.ts:83:3 - (ae-forgotten-export) The symbol "ItemEventMetadata" needs to be exported by the entry point index.d.ts
// src/platform/events/blockchain.ts:143:3 - (ae-forgotten-export) The symbol "RentalMetadata" needs to be exported by the entry point index.d.ts
// src/platform/events/client.ts:16:3 - (ae-forgotten-export) The symbol "ClientBaseMetadata" needs to be exported by the entry point index.d.ts
// src/platform/item/emote/adr74/emote-data-adr74.ts:7:3 - (ae-incompatible-release-tags) The symbol "representations" is marked as @public, but its signature references "EmoteRepresentationADR74" which is marked as @alpha
// src/platform/item/linked-wearable-mappings.ts:251:3 - (ae-incompatible-release-tags) The symbol "getMappings" is marked as @public, but its signature references "Mappings" which is marked as @alpha
Expand Down
39 changes: 26 additions & 13 deletions src/platform/events/base.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,20 @@
import {
BidAcceptedEvent,
CollectionCreatedEvent,
ItemPublishedEvent,
ItemSoldEvent,
RentalEndedEvent,
RentalStartedEvent,
RoyaltiesEarnedEvent
} from './blockchain'
import { CatalystDeploymentEvent } from './catalyst'
import { MoveToParcelEvent, PassportOpenedEvent, UsedEmoteEvent } from './client'
import {
MoveToParcelEvent,
PassportOpenedEvent,
UsedEmoteEvent,
VerticalHeightReachedEvent,
WalkedDistanceEvent
} from './client'
import { BidReceivedEvent } from './marketplace'
import {
RewardInProgressEvent,
Expand Down Expand Up @@ -36,7 +43,8 @@ export namespace Events {
RENTAL_ENDED = 'land-rental-ended',
RENTAL_STARTED = 'land-rental-started',
ROYALTIES_EARNED = 'royalties-earned',
COLLECTION_CREATED = 'collection-created'
COLLECTION_CREATED = 'collection-created',
ITEM_PUBLISHED = 'item-published'
}

export enum Marketplace {
Expand All @@ -55,7 +63,9 @@ export namespace Events {
export enum Client {
MOVE_TO_PARCEL = 'move-to-parcel',
USED_EMOTE = 'used-emote',
PASSPORT_OPENED = 'passport-opened'
PASSPORT_OPENED = 'passport-opened',
WALKED_DISTANCE = 'walked-distance',
VERTICAL_HEIGHT_REACHED = 'vertical-height-reached'
}

export enum Rewards {
Expand Down Expand Up @@ -87,21 +97,24 @@ export type BaseEvent = {
}

export type Event =
| BadgeGrantedEvent
| BidAcceptedEvent
| BidReceivedEvent
| CampaignGasPriceHigherThanExpectedEvent
| CampaignOutOfFundsEvent
| CampaignOutOfStockEvent
| CatalystDeploymentEvent
| CollectionCreatedEvent
| ItemPublishedEvent
| ItemSoldEvent
| MoveToParcelEvent
| PassportOpenedEvent
| RentalEndedEvent
| RentalStartedEvent
| RoyaltiesEarnedEvent
| CollectionCreatedEvent
| MoveToParcelEvent
| CatalystDeploymentEvent
| RewardInProgressEvent
| RewardAssignedEvent
| CampaignOutOfFundsEvent
| CampaignGasPriceHigherThanExpectedEvent
| CampaignOutOfStockEvent
| RewardDelayedEvent
| BadgeGrantedEvent
| RewardInProgressEvent
| RoyaltiesEarnedEvent
| UsedEmoteEvent
| PassportOpenedEvent
| VerticalHeightReachedEvent
| WalkedDistanceEvent
101 changes: 58 additions & 43 deletions src/platform/events/blockchain.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { generateLazyValidator, JSONSchema, ValidateFunction } from '../../validation'
import { BaseEvent, Events } from './base'
import { createEventSchema } from './utils'

export type BidEventMetadata = {
address: string
Expand Down Expand Up @@ -54,59 +55,73 @@ export namespace BidAcceptedEvent {
export const validate: ValidateFunction<BidAcceptedEvent> = generateLazyValidator(schema)
}

type ItemEventMetadata = {
address: string
image: string
buyer: string
seller: string
category: string
rarity?: string
link: string
nftName?: string
tokenId: string
network: string
title: string
description: string
}

export type ItemSoldEvent = BaseEvent & {
type: Events.Type.BLOCKCHAIN
subType: Events.SubType.Blockchain.ITEM_SOLD
metadata: {
address: string
image: string
buyer: string
seller: string
category: string
rarity?: string
link: string
nftName?: string
tokenId: string
network: string
title: string
description: string
}
metadata: ItemEventMetadata
}

// TODO: should we use the itemId instead of tokenId?
kevinszuchet marked this conversation as resolved.
Show resolved Hide resolved
export type ItemPublishedEvent = BaseEvent & {
type: Events.Type.BLOCKCHAIN
subType: Events.SubType.Blockchain.ITEM_PUBLISHED
metadata: ItemEventMetadata
}

const itemEventMetadataSchema: JSONSchema<ItemEventMetadata> = {
type: 'object',
properties: {
address: { type: 'string' },
image: { type: 'string' },
buyer: { type: 'string' },
seller: { type: 'string' },
category: { type: 'string' },
rarity: { type: 'string', nullable: true },
link: { type: 'string' },
nftName: { type: 'string', nullable: true },
tokenId: { type: 'string' },
network: { type: 'string' },
title: { type: 'string' },
description: { type: 'string' }
},
required: ['address', 'image', 'seller', 'category', 'link', 'network', 'title', 'description']
}

export namespace ItemSoldEvent {
export const schema: JSONSchema<ItemSoldEvent> = {
type: 'object',
properties: {
type: { type: 'string', const: Events.Type.BLOCKCHAIN },
subType: { type: 'string', const: Events.SubType.Blockchain.ITEM_SOLD },
key: { type: 'string' },
timestamp: { type: 'number', minimum: 0 },
metadata: {
type: 'object',
properties: {
address: { type: 'string' },
image: { type: 'string' },
buyer: { type: 'string' },
seller: { type: 'string' },
category: { type: 'string' },
rarity: { type: 'string', nullable: true },
link: { type: 'string' },
nftName: { type: 'string', nullable: true },
tokenId: { type: 'string' },
network: { type: 'string' },
title: { type: 'string' },
description: { type: 'string' }
},
required: ['address', 'image', 'seller', 'category', 'link', 'network', 'title', 'description']
}
},
required: ['type', 'subType', 'key', 'timestamp', 'metadata'],
additionalProperties: false
}
export const schema: JSONSchema<ItemSoldEvent> = createEventSchema(
Events.Type.BLOCKCHAIN,
Events.SubType.Blockchain.ITEM_SOLD,
itemEventMetadataSchema
)

export const validate: ValidateFunction<ItemSoldEvent> = generateLazyValidator(schema)
}

export namespace ItemPublishedEvent {
export const schema: JSONSchema<ItemPublishedEvent> = createEventSchema(
Events.Type.BLOCKCHAIN,
Events.SubType.Blockchain.ITEM_PUBLISHED,
itemEventMetadataSchema
)

export const validate: ValidateFunction<ItemPublishedEvent> = generateLazyValidator(schema)
}

type RentalMetadata = {
address: string
contract: string
Expand Down
17 changes: 17 additions & 0 deletions src/platform/events/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,20 @@ export type PassportOpenedEvent = BaseEvent & {
}
}
}

export type WalkedDistanceEvent = BaseEvent & {
type: Events.Type.CLIENT
subType: Events.SubType.Client.WALKED_DISTANCE
metadata: ClientBaseMetadata & {
distance: number
stepCount: number
}
}

export type VerticalHeightReachedEvent = BaseEvent & {
type: Events.Type.CLIENT
subType: Events.SubType.Client.VERTICAL_HEIGHT_REACHED
metadata: ClientBaseMetadata & {
height: number
}
}
Loading
Loading