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 new bid schema #280

Merged
merged 3 commits into from
Jul 15, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
80 changes: 52 additions & 28 deletions report/schemas.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -230,29 +230,23 @@ export type BaseEvent = {
timestamp: number;
};

// 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)
// Warning: (ae-missing-release-tag) "BaseTradeAsset" 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;
export type BaseTradeAsset = {
assetType: TradeAssetType;
contractAddress: string;
tokenId: string;
network: Network.ETHEREUM | Network.MATIC;
chainId: ChainId;
extra: string;
};

// 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 = LegacyBid | BidTrade;

// @public (undocumented)
export namespace Bid {
const // (undocumented)
Expand Down Expand Up @@ -495,6 +489,14 @@ export type CollectionFilters = {
network?: Network;
};

// Warning: (ae-missing-release-tag) "CollectionItemTradeAsset" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public (undocumented)
export type CollectionItemTradeAsset = BaseTradeAsset & {
assetType: TradeAssetType.COLLECTION_ITEM;
itemId: string;
};

// Warning: (ae-missing-release-tag) "CollectionSortBy" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public (undocumented)
Expand Down Expand Up @@ -789,6 +791,22 @@ export enum EntityType {
WEARABLE = "wearable"
}

// Warning: (ae-missing-release-tag) "ERC20TradeAsset" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public (undocumented)
export type ERC20TradeAsset = BaseTradeAsset & {
assetType: TradeAssetType.ERC20;
amount: string;
};

// Warning: (ae-missing-release-tag) "ERC721TradeAsset" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public (undocumented)
export type ERC721TradeAsset = BaseTradeAsset & {
assetType: TradeAssetType.ERC721;
tokenId: string;
};

// @public
export type EthAddress = string;

Expand Down Expand Up @@ -2649,6 +2667,7 @@ export type ThirdPartyProps = {
// @public (undocumented)
export type Trade = {
id: string;
signature: string;
signer: string;
network: Network;
chainId: ChainId;
Expand All @@ -2659,14 +2678,21 @@ export type Trade = {
received: TradeAssetWithBeneficiary[];
};

// Warning: (ae-forgotten-export) The symbol "CollectionItemTradeAsset" needs to be exported by the entry point index.d.ts
// Warning: (ae-forgotten-export) The symbol "ERC20TradeAsset" needs to be exported by the entry point index.d.ts
// Warning: (ae-forgotten-export) The symbol "ERC721TradeAsset" needs to be exported by the entry point index.d.ts
// Warning: (ae-missing-release-tag) "TradeAsset" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public (undocumented)
export type TradeAsset = CollectionItemTradeAsset | ERC20TradeAsset | ERC721TradeAsset;

// Warning: (ae-missing-release-tag) "TradeAssetDirection" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public (undocumented)
export enum TradeAssetDirection {
// (undocumented)
RECEIVED = "received",
// (undocumented)
SENT = "sent"
}

// Warning: (ae-missing-release-tag) "TradeAssetType" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public (undocumented)
Expand Down Expand Up @@ -2974,9 +3000,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 Expand Up @@ -3012,10 +3036,10 @@ export namespace WorldConfiguration {
// src/dapps/sale.ts:18:3 - (ae-incompatible-release-tags) The symbol "network" is marked as @public, but its signature references "Network" which is marked as @alpha
// src/dapps/sale.ts:19:3 - (ae-incompatible-release-tags) The symbol "chainId" is marked as @public, but its signature references "ChainId" which is marked as @alpha
// src/dapps/sale.ts:42: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:69: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:70: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:81: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:82: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:70: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:71: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:82: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:83: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:19:3 - (ae-forgotten-export) The symbol "BidMetadata" needs to be exported by the entry point index.d.ts
// src/platform/events/blockchain.ts:60: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
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', 'itemId']
},
{
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)
}
1 change: 1 addition & 0 deletions src/dapps/trade.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ export type TradeAssetWithBeneficiary = TradeAsset & {

export type Trade = {
id: string
signature: string
signer: string
network: Network
chainId: ChainId
Expand Down
7 changes: 6 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,16 @@ export {
Trade,
TradeAsset,
TradeAssetType,
TradeAssetDirection,
TradeChecks,
TradeExternalCheck,
TradeCreation,
TradeType,
TradeAssetWithBeneficiary
TradeAssetWithBeneficiary,
BaseTradeAsset,
ERC20TradeAsset,
ERC721TradeAsset,
CollectionItemTradeAsset
} from './dapps/trade'
export {
RentalStatus,
Expand Down
Loading