Skip to content

Commit

Permalink
feat: add new bid schema
Browse files Browse the repository at this point in the history
  • Loading branch information
Melisa Anabella Rossi committed Jul 13, 2024
1 parent 30e09f4 commit 8fbd657
Show file tree
Hide file tree
Showing 2 changed files with 79 additions and 44 deletions.
25 changes: 4 additions & 21 deletions report/schemas.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -230,28 +230,13 @@ export type BaseEvent = {
timestamp: number;
};

// Warning: (ae-forgotten-export) The symbol "LegacyBid" needs to be exported by the entry point index.d.ts
// Warning: (ae-forgotten-export) The symbol "BidTrade" needs to be exported by the entry point index.d.ts
// Warning: (ae-missing-release-tag) "Bid" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal)
// Warning: (ae-missing-release-tag) "Bid" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public (undocumented)
export type Bid = {
id: string;
bidAddress: string;
bidder: string;
seller: string;
price: string;
fingerprint: string;
status: ListingStatus;
blockchainId: string;
blockNumber: string;
expiresAt: number;
createdAt: number;
updatedAt: number;
contractAddress: string;
tokenId: string;
network: Network.ETHEREUM | Network.MATIC;
chainId: ChainId;
};
export type Bid = LegacyBid | BidTrade;

// @public (undocumented)
export namespace Bid {
Expand Down Expand Up @@ -2974,9 +2959,7 @@ export namespace WorldConfiguration {
//
// src/dapps/account.ts:30:3 - (ae-incompatible-release-tags) The symbol "network" is marked as @public, but its signature references "Network" which is marked as @alpha
// src/dapps/analyticsDayData.ts:14:3 - (ae-incompatible-release-tags) The symbol "network" is marked as @public, but its signature references "Network" which is marked as @alpha
// src/dapps/bid.ts:21:3 - (ae-incompatible-release-tags) The symbol "network" is marked as @public, but its signature references "Network" which is marked as @alpha
// src/dapps/bid.ts:22:3 - (ae-incompatible-release-tags) The symbol "chainId" is marked as @public, but its signature references "ChainId" which is marked as @alpha
// src/dapps/bid.ts:41:3 - (ae-incompatible-release-tags) The symbol "network" is marked as @public, but its signature references "Network" which is marked as @alpha
// src/dapps/bid.ts:58:3 - (ae-incompatible-release-tags) The symbol "network" is marked as @public, but its signature references "Network" which is marked as @alpha
// src/dapps/collection.ts:15:3 - (ae-incompatible-release-tags) The symbol "network" is marked as @public, but its signature references "Network" which is marked as @alpha
// src/dapps/collection.ts:16:3 - (ae-incompatible-release-tags) The symbol "chainId" is marked as @public, but its signature references "ChainId" which is marked as @alpha
// src/dapps/collection.ts:39:3 - (ae-incompatible-release-tags) The symbol "network" is marked as @public, but its signature references "Network" which is marked as @alpha
Expand Down
98 changes: 75 additions & 23 deletions src/dapps/bid.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,42 @@ import { ChainId } from './chain-id'
import { ListingStatus } from './listing-status'
import { Network } from './network'

export type Bid = {
export type BaseBid = {
id: string
bidAddress: string
bidder: string
seller: string
price: string
fingerprint: string
status: ListingStatus
blockchainId: string
blockNumber: string
expiresAt: number
createdAt: number
updatedAt: number
contractAddress: string
tokenId: string
network: Network.ETHEREUM | Network.MATIC
chainId: ChainId
fingerprint: string
}

type LegacyBid = BaseBid & {
bidAddress: string
blockchainId: string
blockNumber: string
tokenId: string
}

export type ItemBid = BaseBid & {
tradeId: string
itemId: string
}

export type NFTBid = BaseBid & {
tradeId: string
tokenId: string
}

export type BidTrade = NFTBid | ItemBid

export type Bid = LegacyBid | BidTrade

export enum BidSortBy {
RECENTLY_OFFERED = 'recently_offered',
RECENTLY_UPDATED = 'recently_updated',
Expand All @@ -42,15 +59,12 @@ export type BidFilters = {
}

export namespace Bid {
export const schema: JSONSchema<Bid> = {
const baseBidSchema: JSONSchema<BaseBid> = {
type: 'object',
properties: {
id: {
type: 'string'
},
bidAddress: {
type: 'string'
},
bidder: {
type: 'string'
},
Expand All @@ -64,18 +78,9 @@ export namespace Bid {
type: 'string'
},
status: ListingStatus.schema,
blockchainId: {
type: 'string'
},
blockNumber: {
type: 'string'
},
contractAddress: {
type: 'string'
},
tokenId: {
type: 'string'
},
network: Network.schema,
chainId: ChainId.schema,
expiresAt: {
Expand All @@ -90,16 +95,12 @@ export namespace Bid {
},
required: [
'id',
'bidAddress',
'bidder',
'seller',
'price',
'fingerprint',
'status',
'blockchainId',
'blockNumber',
'contractAddress',
'tokenId',
'network',
'chainId',
'expiresAt',
Expand All @@ -108,5 +109,56 @@ export namespace Bid {
]
}

export const schema: JSONSchema<Bid> = {
type: 'object',
required: [],
oneOf: [
{
properties: {
...baseBidSchema.properties,
tradeId: {
type: 'string'
},
tokenId: {
type: 'string'
}
},
required: [...baseBidSchema.required, 'tradeId', 'tokenId']
},
{
type: 'object',
properties: {
...baseBidSchema.properties,
tradeId: {
type: 'string'
},
itemId: {
type: 'string'
}
},
required: [...baseBidSchema.required, 'tradeId', 'item']
},
{
type: 'object',
properties: {
...baseBidSchema.properties,
bidAddress: {
type: 'string'
},
blockchainId: {
type: 'string'
},
blockNumber: {
type: 'string'
},
tokenId: {
type: 'string'
}
},
required: [...baseBidSchema.required, 'bidAddress', 'blockchainId', 'blockNumber', 'tokenId']
}
]
}

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

0 comments on commit 8fbd657

Please sign in to comment.