From d4a4a105484d1f60ab733472f000b9ac4fe353c5 Mon Sep 17 00:00:00 2001 From: Melisa Anabella Rossi Date: Mon, 5 Aug 2024 10:28:39 -0300 Subject: [PATCH] Revert "feat: change bid receive notification (#289)" This reverts commit ef293ea1aaaf496cc7930424be62ff0c08dc720d. --- report/schemas.api.md | 41 ++++++---------------- src/platform/events/base.ts | 16 +++------ src/platform/events/blockchain.ts | 43 ++++++++++++++++++++++-- src/platform/events/index.ts | 1 - src/platform/events/marketplace.ts | 42 ----------------------- test/platform/events/blockchain.spec.ts | 27 +++++++++++++++ test/platform/events/marketplace.spec.ts | 30 ----------------- 7 files changed, 82 insertions(+), 118 deletions(-) delete mode 100644 src/platform/events/marketplace.ts delete mode 100644 test/platform/events/marketplace.spec.ts diff --git a/report/schemas.api.md b/report/schemas.api.md index 580aa2b..63d9037 100644 --- a/report/schemas.api.md +++ b/report/schemas.api.md @@ -261,7 +261,7 @@ export type BaseBid = { // @public (undocumented) export type BaseEvent = { type: Events.Type; - subType: Events.SubType.Blockchain | Events.SubType.CatalystDeployment | Events.SubType.Client | Events.SubType.Marketplace; + subType: Events.SubType.Blockchain | Events.SubType.CatalystDeployment | Events.SubType.Client; key: string; timestamp: number; }; @@ -296,7 +296,7 @@ export namespace Bid { export type BidAcceptedEvent = BaseEvent & { type: Events.Type.BLOCKCHAIN; subType: Events.SubType.Blockchain.BID_ACCEPTED; - metadata: BidEventMetadata; + metadata: BidMetadata; }; // @public (undocumented) @@ -307,23 +307,6 @@ export namespace BidAcceptedEvent { validate: ValidateFunction; } -// Warning: (ae-missing-release-tag) "BidEventMetadata" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) -// -// @public (undocumented) -export type BidEventMetadata = { - address: string; - image: string; - seller: string; - category: string; - rarity?: string; - link: string; - nftName?: string; - price: string; - title: string; - description: string; - network: string; -}; - // Warning: (ae-missing-release-tag) "BidFilters" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) // // @public (undocumented) @@ -345,9 +328,9 @@ export type BidFilters = { // // @public (undocumented) export type BidReceivedEvent = BaseEvent & { - type: Events.Type.MARKETPLACE; - subType: Events.SubType.Marketplace.BID_RECEIVED; - metadata: BidEventMetadata; + type: Events.Type.BLOCKCHAIN; + subType: Events.SubType.Blockchain.BID_RECEIVED; + metadata: BidMetadata; }; // @public (undocumented) @@ -970,6 +953,8 @@ export namespace Events { // (undocumented) BID_ACCEPTED = "bid-accepted", // (undocumented) + BID_RECEIVED = "bid-received", + // (undocumented) COLLECTION_CREATED = "collection-created", // (undocumented) ITEM_SOLD = "item-sold", @@ -1000,11 +985,6 @@ export namespace Events { // (undocumented) MOVE_TO_PARCEL = "move-to-parcel" } - // (undocumented) - export enum Marketplace { - // (undocumented) - BID_RECEIVED = "bid-received" - } } // (undocumented) export enum Type { @@ -1013,9 +993,7 @@ export namespace Events { // (undocumented) CATALYST_DEPLOYMENT = "catalyst-deployment", // (undocumented) - CLIENT = "client", - // (undocumented) - MARKETPLACE = "marketplace" + CLIENT = "client" } } @@ -3401,7 +3379,8 @@ export namespace WorldConfiguration { // src/dapps/trade.ts:79: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:90: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:91: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:124:3 - (ae-forgotten-export) The symbol "RentalMetadata" needs to be exported by the entry point index.d.ts +// src/platform/events/blockchain.ts:21:3 - (ae-forgotten-export) The symbol "BidMetadata" needs to be exported by the entry point index.d.ts +// src/platform/events/blockchain.ts:163:3 - (ae-forgotten-export) The symbol "RentalMetadata" 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 // src/platform/item/linked-wearable-mappings.ts:252:3 - (ae-incompatible-release-tags) The symbol "addMapping" is marked as @public, but its signature references "ContractNetwork" which is marked as @alpha diff --git a/src/platform/events/base.ts b/src/platform/events/base.ts index 7703c49..17511cc 100644 --- a/src/platform/events/base.ts +++ b/src/platform/events/base.ts @@ -1,5 +1,6 @@ import { BidAcceptedEvent, + BidReceivedEvent, CollectionCreatedEvent, ItemSoldEvent, RentalEndedEvent, @@ -8,19 +9,18 @@ import { } from './blockchain' import { CatalystDeploymentEvent } from './catalyst' import { MoveToParcelEvent } from './client' -import { BidReceivedEvent } from './marketplace' export namespace Events { export enum Type { BLOCKCHAIN = 'blockchain', CATALYST_DEPLOYMENT = 'catalyst-deployment', - CLIENT = 'client', - MARKETPLACE = 'marketplace' + CLIENT = 'client' } export namespace SubType { export enum Blockchain { BID_ACCEPTED = 'bid-accepted', + BID_RECEIVED = 'bid-received', ITEM_SOLD = 'item-sold', RENTAL_ENDED = 'land-rental-ended', RENTAL_STARTED = 'land-rental-started', @@ -28,10 +28,6 @@ export namespace Events { COLLECTION_CREATED = 'collection-created' } - export enum Marketplace { - BID_RECEIVED = 'bid-received' - } - export enum CatalystDeployment { SCENE = 'scene', PROFILE = 'profile', @@ -49,11 +45,7 @@ export namespace Events { export type BaseEvent = { type: Events.Type - subType: - | Events.SubType.Blockchain - | Events.SubType.CatalystDeployment - | Events.SubType.Client - | Events.SubType.Marketplace + subType: Events.SubType.Blockchain | Events.SubType.CatalystDeployment | Events.SubType.Client key: string timestamp: number } diff --git a/src/platform/events/blockchain.ts b/src/platform/events/blockchain.ts index ff5b42a..f51fc09 100644 --- a/src/platform/events/blockchain.ts +++ b/src/platform/events/blockchain.ts @@ -1,7 +1,7 @@ import { generateLazyValidator, JSONSchema, ValidateFunction } from '../../validation' import { BaseEvent, Events } from './base' -export type BidEventMetadata = { +type BidMetadata = { address: string image: string seller: string @@ -18,7 +18,7 @@ export type BidEventMetadata = { export type BidAcceptedEvent = BaseEvent & { type: Events.Type.BLOCKCHAIN subType: Events.SubType.Blockchain.BID_ACCEPTED - metadata: BidEventMetadata + metadata: BidMetadata } export namespace BidAcceptedEvent { @@ -54,6 +54,45 @@ export namespace BidAcceptedEvent { export const validate: ValidateFunction = generateLazyValidator(schema) } +export type BidReceivedEvent = BaseEvent & { + type: Events.Type.BLOCKCHAIN + subType: Events.SubType.Blockchain.BID_RECEIVED + metadata: BidMetadata +} + +export namespace BidReceivedEvent { + export const schema: JSONSchema = { + type: 'object', + properties: { + type: { type: 'string', const: Events.Type.BLOCKCHAIN }, + subType: { type: 'string', const: Events.SubType.Blockchain.BID_RECEIVED }, + key: { type: 'string' }, + timestamp: { type: 'number', minimum: 0 }, + metadata: { + type: 'object', + properties: { + address: { type: 'string' }, + image: { type: 'string' }, + seller: { type: 'string' }, + category: { type: 'string' }, + rarity: { type: 'string', nullable: true }, + link: { type: 'string' }, + nftName: { type: 'string', nullable: true }, + price: { type: 'string' }, + title: { type: 'string' }, + description: { type: 'string' }, + network: { type: 'string' } + }, + required: ['address', 'image', 'seller', 'category', 'link', 'price', 'title', 'network'] + } + }, + required: ['type', 'subType', 'key', 'timestamp', 'metadata'], + additionalProperties: false + } + + export const validate: ValidateFunction = generateLazyValidator(schema) +} + export type ItemSoldEvent = BaseEvent & { type: Events.Type.BLOCKCHAIN subType: Events.SubType.Blockchain.ITEM_SOLD diff --git a/src/platform/events/index.ts b/src/platform/events/index.ts index 716f6c6..54090c7 100644 --- a/src/platform/events/index.ts +++ b/src/platform/events/index.ts @@ -2,4 +2,3 @@ export * from './base' export * from './blockchain' export * from './catalyst' export * from './client' -export * from './marketplace' diff --git a/src/platform/events/marketplace.ts b/src/platform/events/marketplace.ts deleted file mode 100644 index a8a9284..0000000 --- a/src/platform/events/marketplace.ts +++ /dev/null @@ -1,42 +0,0 @@ -import { generateLazyValidator, JSONSchema, ValidateFunction } from '../../validation' -import { BaseEvent, Events } from './base' -import { BidEventMetadata } from './blockchain' - -export type BidReceivedEvent = BaseEvent & { - type: Events.Type.MARKETPLACE - subType: Events.SubType.Marketplace.BID_RECEIVED - metadata: BidEventMetadata -} - -export namespace BidReceivedEvent { - export const schema: JSONSchema = { - type: 'object', - properties: { - type: { type: 'string', const: Events.Type.MARKETPLACE }, - subType: { type: 'string', const: Events.SubType.Marketplace.BID_RECEIVED }, - key: { type: 'string' }, - timestamp: { type: 'number', minimum: 0 }, - metadata: { - type: 'object', - properties: { - address: { type: 'string' }, - image: { type: 'string' }, - seller: { type: 'string' }, - category: { type: 'string' }, - rarity: { type: 'string', nullable: true }, - link: { type: 'string' }, - nftName: { type: 'string', nullable: true }, - price: { type: 'string' }, - title: { type: 'string' }, - description: { type: 'string' }, - network: { type: 'string' } - }, - required: ['address', 'image', 'seller', 'category', 'link', 'price', 'title', 'network'] - } - }, - required: ['type', 'subType', 'key', 'timestamp', 'metadata'], - additionalProperties: false - } - - export const validate: ValidateFunction = generateLazyValidator(schema) -} diff --git a/test/platform/events/blockchain.spec.ts b/test/platform/events/blockchain.spec.ts index ff1ccd2..097c59f 100644 --- a/test/platform/events/blockchain.spec.ts +++ b/test/platform/events/blockchain.spec.ts @@ -1,6 +1,7 @@ import expect from 'expect' import { BidAcceptedEvent, + BidReceivedEvent, CollectionCreatedEvent, Events, ItemSoldEvent, @@ -36,6 +37,32 @@ describe('Blockchain Events tests', () => { expect(BidAcceptedEvent.validate({})).toEqual(false) }) + it('BidReceivedEvent static tests must pass', () => { + const event: BidReceivedEvent = { + type: Events.Type.BLOCKCHAIN, + subType: Events.SubType.Blockchain.BID_RECEIVED, + key: 'key', + timestamp: 1, + metadata: { + address: 'address', + image: 'image', + seller: 'seller', + category: 'category', + rarity: 'rarity', + link: 'link', + nftName: 'nftName', + price: '1', + title: 'title', + description: 'description', + network: 'network' + } + } + + expect(BidReceivedEvent.validate(event)).toEqual(true) + expect(BidReceivedEvent.validate(null)).toEqual(false) + expect(BidReceivedEvent.validate({})).toEqual(false) + }) + it('ItemSold static tests must pass', () => { const event: ItemSoldEvent = { type: Events.Type.BLOCKCHAIN, diff --git a/test/platform/events/marketplace.spec.ts b/test/platform/events/marketplace.spec.ts deleted file mode 100644 index d09d288..0000000 --- a/test/platform/events/marketplace.spec.ts +++ /dev/null @@ -1,30 +0,0 @@ -import expect from 'expect' -import { BidReceivedEvent, Events } from '../../../src' - -describe('Marketplace Events tests', () => { - it('BidReceivedEvent static tests must pass', () => { - const event: BidReceivedEvent = { - type: Events.Type.MARKETPLACE, - subType: Events.SubType.Marketplace.BID_RECEIVED, - key: 'key', - timestamp: 1, - metadata: { - address: 'address', - image: 'image', - seller: 'seller', - category: 'category', - rarity: 'rarity', - link: 'link', - nftName: 'nftName', - price: '1', - title: 'title', - description: 'description', - network: 'network' - } - } - - expect(BidReceivedEvent.validate(event)).toEqual(true) - expect(BidReceivedEvent.validate(null)).toEqual(false) - expect(BidReceivedEvent.validate({})).toEqual(false) - }) -})