-
Notifications
You must be signed in to change notification settings - Fork 257
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e7cac79
commit c2f2e58
Showing
18 changed files
with
1,012 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
'@moralisweb3/common-evm-utils': minor | ||
'@moralisweb3/evm-api': minor | ||
--- | ||
|
||
Expose `getNFTContractSalePrices` & `getNFTSalePrices` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 58 additions & 0 deletions
58
packages/common/evmUtils/src/generated/operations/GetNFTContractSalePricesOperation.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import { EvmChain, EvmChainInput, EvmChainJSON, EvmAddress, EvmAddressInput, EvmAddressJSON } from '../../dataTypes'; | ||
import { EvmSoldPrice, EvmSoldPriceJSON } from '../types/EvmSoldPrice'; | ||
|
||
// request parameters: | ||
// - chain ($ref: #/components/schemas/nftTradesChainList) | ||
// - days ($ref: #/paths/~1nft~1{address}~1price/get/parameters/1/schema) | ||
// - address ($ref: #/paths/~1nft~1{address}~1price/get/parameters/2/schema) | ||
|
||
export interface GetNFTContractSalePricesOperationRequest { | ||
/** | ||
* @description The chain to query | ||
*/ | ||
readonly chain?: EvmChainInput | EvmChain; | ||
/** | ||
* @description The number of days to look back to find the lowest price | ||
* If not provided 7 days will be the default | ||
*/ | ||
readonly days?: number; | ||
/** | ||
* @description The address of the NFT collection | ||
*/ | ||
readonly address: EvmAddressInput | EvmAddress; | ||
} | ||
|
||
export interface GetNFTContractSalePricesOperationRequestJSON { | ||
readonly chain?: EvmChainJSON; | ||
readonly days?: number; | ||
readonly address: EvmAddressJSON; | ||
} | ||
|
||
export type GetNFTContractSalePricesOperationResponse = EvmSoldPrice; | ||
export type GetNFTContractSalePricesOperationResponseJSON = EvmSoldPriceJSON; | ||
|
||
export const GetNFTContractSalePricesOperation = { | ||
operationId: "getNFTContractSalePrices", | ||
groupName: "nft", | ||
httpMethod: "get", | ||
routePattern: "/nft/{address}/price", | ||
parameterNames: ["chain","days","address"], | ||
hasResponse: true, | ||
hasBody: false, | ||
|
||
parseResponse(json: EvmSoldPriceJSON): EvmSoldPrice { | ||
return EvmSoldPrice.fromJSON(json); | ||
}, | ||
|
||
serializeRequest(request: GetNFTContractSalePricesOperationRequest): GetNFTContractSalePricesOperationRequestJSON { | ||
const chain = request.chain ? EvmChain.create(request.chain) : undefined; | ||
const days = request.days; | ||
const address = EvmAddress.create(request.address); | ||
return { | ||
chain: chain ? chain.toJSON() : undefined, | ||
days: days, | ||
address: address.toJSON(), | ||
}; | ||
}, | ||
|
||
} |
66 changes: 66 additions & 0 deletions
66
packages/common/evmUtils/src/generated/operations/GetNFTSalePricesOperation.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
import { EvmChain, EvmChainInput, EvmChainJSON, EvmAddress, EvmAddressInput, EvmAddressJSON } from '../../dataTypes'; | ||
import { EvmSoldPrice, EvmSoldPriceJSON } from '../types/EvmSoldPrice'; | ||
|
||
// request parameters: | ||
// - chain ($ref: #/components/schemas/nftTradesChainList) | ||
// - days ($ref: #/paths/~1nft~1{address}~1{token_id}~1price/get/parameters/1/schema) | ||
// - address ($ref: #/paths/~1nft~1{address}~1{token_id}~1price/get/parameters/2/schema) | ||
// - token_id ($ref: #/paths/~1nft~1{address}~1{token_id}~1price/get/parameters/3/schema) | ||
|
||
export interface GetNFTSalePricesOperationRequest { | ||
/** | ||
* @description The chain to query | ||
*/ | ||
readonly chain?: EvmChainInput | EvmChain; | ||
/** | ||
* @description The number of days to look back to find the lowest price | ||
* If not provided 7 days will be the default | ||
*/ | ||
readonly days?: number; | ||
/** | ||
* @description The address of the NFT collection | ||
*/ | ||
readonly address: EvmAddressInput | EvmAddress; | ||
/** | ||
* @description The token id of the NFT collection | ||
*/ | ||
readonly tokenId: string; | ||
} | ||
|
||
export interface GetNFTSalePricesOperationRequestJSON { | ||
readonly chain?: EvmChainJSON; | ||
readonly days?: number; | ||
readonly address: EvmAddressJSON; | ||
readonly token_id: string; | ||
} | ||
|
||
export type GetNFTSalePricesOperationResponse = EvmSoldPrice; | ||
export type GetNFTSalePricesOperationResponseJSON = EvmSoldPriceJSON; | ||
|
||
export const GetNFTSalePricesOperation = { | ||
operationId: "getNFTSalePrices", | ||
groupName: "nft", | ||
httpMethod: "get", | ||
routePattern: "/nft/{address}/{token_id}/price", | ||
parameterNames: ["chain","days","address","token_id"], | ||
hasResponse: true, | ||
hasBody: false, | ||
|
||
parseResponse(json: EvmSoldPriceJSON): EvmSoldPrice { | ||
return EvmSoldPrice.fromJSON(json); | ||
}, | ||
|
||
serializeRequest(request: GetNFTSalePricesOperationRequest): GetNFTSalePricesOperationRequestJSON { | ||
const chain = request.chain ? EvmChain.create(request.chain) : undefined; | ||
const days = request.days; | ||
const address = EvmAddress.create(request.address); | ||
const tokenId = request.tokenId; | ||
return { | ||
chain: chain ? chain.toJSON() : undefined, | ||
days: days, | ||
address: address.toJSON(), | ||
token_id: tokenId, | ||
}; | ||
}, | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
88 changes: 88 additions & 0 deletions
88
packages/common/evmUtils/src/generated/types/EvmSoldPrice.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
import { EvmSoldPriceLastSale, EvmSoldPriceLastSaleInput, EvmSoldPriceLastSaleJSON } from '../types/EvmSoldPriceLastSale'; | ||
import { EvmSoldPriceLowestSale, EvmSoldPriceLowestSaleInput, EvmSoldPriceLowestSaleJSON } from '../types/EvmSoldPriceLowestSale'; | ||
import { EvmSoldPriceHighestSale, EvmSoldPriceHighestSaleInput, EvmSoldPriceHighestSaleJSON } from '../types/EvmSoldPriceHighestSale'; | ||
import { EvmSoldPriceAverageSale, EvmSoldPriceAverageSaleInput, EvmSoldPriceAverageSaleJSON } from '../types/EvmSoldPriceAverageSale'; | ||
|
||
// $ref: #/components/schemas/soldPrice | ||
// type: soldPrice | ||
// properties: | ||
// - last_sale ($ref: #/components/schemas/soldPrice/properties/last_sale) | ||
// - lowest_sale ($ref: #/components/schemas/soldPrice/properties/lowest_sale) | ||
// - highest_sale ($ref: #/components/schemas/soldPrice/properties/highest_sale) | ||
// - average_sale ($ref: #/components/schemas/soldPrice/properties/average_sale) | ||
// - total_trades ($ref: #/components/schemas/soldPrice/properties/total_trades) | ||
|
||
export interface EvmSoldPriceJSON { | ||
readonly last_sale: EvmSoldPriceLastSaleJSON; | ||
readonly lowest_sale: EvmSoldPriceLowestSaleJSON; | ||
readonly highest_sale: EvmSoldPriceHighestSaleJSON; | ||
readonly average_sale: EvmSoldPriceAverageSaleJSON; | ||
readonly total_trades?: number; | ||
} | ||
|
||
export interface EvmSoldPriceInput { | ||
readonly lastSale: EvmSoldPriceLastSaleInput | EvmSoldPriceLastSale; | ||
readonly lowestSale: EvmSoldPriceLowestSaleInput | EvmSoldPriceLowestSale; | ||
readonly highestSale: EvmSoldPriceHighestSaleInput | EvmSoldPriceHighestSale; | ||
readonly averageSale: EvmSoldPriceAverageSaleInput | EvmSoldPriceAverageSale; | ||
readonly totalTrades?: number; | ||
} | ||
|
||
export class EvmSoldPrice { | ||
public static create(input: EvmSoldPriceInput | EvmSoldPrice): EvmSoldPrice { | ||
if (input instanceof EvmSoldPrice) { | ||
return input; | ||
} | ||
return new EvmSoldPrice(input); | ||
} | ||
|
||
public static fromJSON(json: EvmSoldPriceJSON): EvmSoldPrice { | ||
const input: EvmSoldPriceInput = { | ||
lastSale: EvmSoldPriceLastSale.fromJSON(json.last_sale), | ||
lowestSale: EvmSoldPriceLowestSale.fromJSON(json.lowest_sale), | ||
highestSale: EvmSoldPriceHighestSale.fromJSON(json.highest_sale), | ||
averageSale: EvmSoldPriceAverageSale.fromJSON(json.average_sale), | ||
totalTrades: json.total_trades, | ||
}; | ||
return EvmSoldPrice.create(input); | ||
} | ||
|
||
/** | ||
* @description The sales price of the NFT collection | ||
*/ | ||
public readonly lastSale: EvmSoldPriceLastSale; | ||
/** | ||
* @description The lowest sale of the NFT collection | ||
*/ | ||
public readonly lowestSale: EvmSoldPriceLowestSale; | ||
/** | ||
* @description The highest sale of the NFT collection | ||
*/ | ||
public readonly highestSale: EvmSoldPriceHighestSale; | ||
/** | ||
* @description The average sale of the NFT collection | ||
*/ | ||
public readonly averageSale: EvmSoldPriceAverageSale; | ||
/** | ||
* @description The total trades in the timeframe | ||
*/ | ||
public readonly totalTrades?: number; | ||
|
||
private constructor(input: EvmSoldPriceInput) { | ||
this.lastSale = EvmSoldPriceLastSale.create(input.lastSale); | ||
this.lowestSale = EvmSoldPriceLowestSale.create(input.lowestSale); | ||
this.highestSale = EvmSoldPriceHighestSale.create(input.highestSale); | ||
this.averageSale = EvmSoldPriceAverageSale.create(input.averageSale); | ||
this.totalTrades = input.totalTrades; | ||
} | ||
|
||
public toJSON(): EvmSoldPriceJSON { | ||
return { | ||
last_sale: this.lastSale.toJSON(), | ||
lowest_sale: this.lowestSale.toJSON(), | ||
highest_sale: this.highestSale.toJSON(), | ||
average_sale: this.averageSale.toJSON(), | ||
total_trades: this.totalTrades, | ||
} | ||
} | ||
} |
Oops, something went wrong.