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: update swagger. #1204

Merged
merged 1 commit into from
May 17, 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
7 changes: 7 additions & 0 deletions .changeset/three-meals-drum.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'@moralisweb3/common-evm-utils': patch
'@moralisweb3/evm-api': patch
'moralis': patch
---

Updated the types to reflect the changes in the swagger file.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { EvmGetNFTTradesMarketplaceEnum, EvmGetNFTTradesMarketplaceEnumValue, Ev
import { EvmTradeCollection, EvmTradeCollectionJSON } from '../types/EvmTradeCollection';

// request parameters:
// - chain ($ref: #/components/schemas/chainList)
// - chain ($ref: #/components/schemas/nftTradesChainList)
// - from_block ($ref: #/paths/~1nft~1{address}~1trades/get/parameters/1/schema)
// - to_block ($ref: #/paths/~1nft~1{address}~1trades/get/parameters/2/schema)
// - from_date ($ref: #/paths/~1nft~1{address}~1trades/get/parameters/3/schema)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// $ref: #/components/schemas/chainList
// typeName: chainList

export type EvmChainListJSON = "eth" | "0x1" | "goerli" | "0x5" | "sepolia" | "0xaa36a7" | "polygon" | "0x89" | "mumbai" | "0x13881" | "bsc" | "0x38" | "bsc testnet" | "0x61" | "avalanche" | "0xa86a" | "fantom" | "0xfa" | "palm" | "0x2a15c308d" | "cronos" | "0x19" | "arbitrum" | "0xa4b1" | "chiliz" | "0x15b38" | "chiliz testnet" | "0x15b32" | "gnosis" | "0x64" | "gnosis testnet" | "0x27d8" | "base" | "0x2105" | "base testnet" | "0x14a33" | "base sepolia" | "0x14a34" | "optimism" | "0xa" | "holesky" | "0x4268" | "polygon amoy" | "0x13882" | "linea" | "0xe708";
export type EvmChainListInput = "eth" | "0x1" | "goerli" | "0x5" | "sepolia" | "0xaa36a7" | "polygon" | "0x89" | "mumbai" | "0x13881" | "bsc" | "0x38" | "bsc testnet" | "0x61" | "avalanche" | "0xa86a" | "fantom" | "0xfa" | "palm" | "0x2a15c308d" | "cronos" | "0x19" | "arbitrum" | "0xa4b1" | "chiliz" | "0x15b38" | "chiliz testnet" | "0x15b32" | "gnosis" | "0x64" | "gnosis testnet" | "0x27d8" | "base" | "0x2105" | "base testnet" | "0x14a33" | "base sepolia" | "0x14a34" | "optimism" | "0xa" | "holesky" | "0x4268" | "polygon amoy" | "0x13882" | "linea" | "0xe708";
export type EvmChainListValue = "eth" | "0x1" | "goerli" | "0x5" | "sepolia" | "0xaa36a7" | "polygon" | "0x89" | "mumbai" | "0x13881" | "bsc" | "0x38" | "bsc testnet" | "0x61" | "avalanche" | "0xa86a" | "fantom" | "0xfa" | "palm" | "0x2a15c308d" | "cronos" | "0x19" | "arbitrum" | "0xa4b1" | "chiliz" | "0x15b38" | "chiliz testnet" | "0x15b32" | "gnosis" | "0x64" | "gnosis testnet" | "0x27d8" | "base" | "0x2105" | "base testnet" | "0x14a33" | "base sepolia" | "0x14a34" | "optimism" | "0xa" | "holesky" | "0x4268" | "polygon amoy" | "0x13882" | "linea" | "0xe708";
export type EvmChainListJSON = "eth" | "0x1" | "sepolia" | "0xaa36a7" | "polygon" | "0x89" | "bsc" | "0x38" | "bsc testnet" | "0x61" | "avalanche" | "0xa86a" | "fantom" | "0xfa" | "palm" | "0x2a15c308d" | "cronos" | "0x19" | "arbitrum" | "0xa4b1" | "chiliz" | "0x15b38" | "chiliz testnet" | "0x15b32" | "gnosis" | "0x64" | "gnosis testnet" | "0x27d8" | "base" | "0x2105" | "base sepolia" | "0x14a34" | "optimism" | "0xa" | "holesky" | "0x4268" | "polygon amoy" | "0x13882" | "linea" | "0xe708" | "moonbeam" | "0x504" | "moonriver" | "0x505" | "moonbase" | "0x507" | "linea sepolia" | "0xe705";
export type EvmChainListInput = "eth" | "0x1" | "sepolia" | "0xaa36a7" | "polygon" | "0x89" | "bsc" | "0x38" | "bsc testnet" | "0x61" | "avalanche" | "0xa86a" | "fantom" | "0xfa" | "palm" | "0x2a15c308d" | "cronos" | "0x19" | "arbitrum" | "0xa4b1" | "chiliz" | "0x15b38" | "chiliz testnet" | "0x15b32" | "gnosis" | "0x64" | "gnosis testnet" | "0x27d8" | "base" | "0x2105" | "base sepolia" | "0x14a34" | "optimism" | "0xa" | "holesky" | "0x4268" | "polygon amoy" | "0x13882" | "linea" | "0xe708" | "moonbeam" | "0x504" | "moonriver" | "0x505" | "moonbase" | "0x507" | "linea sepolia" | "0xe705";
export type EvmChainListValue = "eth" | "0x1" | "sepolia" | "0xaa36a7" | "polygon" | "0x89" | "bsc" | "0x38" | "bsc testnet" | "0x61" | "avalanche" | "0xa86a" | "fantom" | "0xfa" | "palm" | "0x2a15c308d" | "cronos" | "0x19" | "arbitrum" | "0xa4b1" | "chiliz" | "0x15b38" | "chiliz testnet" | "0x15b32" | "gnosis" | "0x64" | "gnosis testnet" | "0x27d8" | "base" | "0x2105" | "base sepolia" | "0x14a34" | "optimism" | "0xa" | "holesky" | "0x4268" | "polygon amoy" | "0x13882" | "linea" | "0xe708" | "moonbeam" | "0x504" | "moonriver" | "0x505" | "moonbase" | "0x507" | "linea sepolia" | "0xe705";

export abstract class EvmChainList {
public static create(input: EvmChainListInput | EvmChainListValue): EvmChainListValue {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { EvmAddress, EvmAddressInput, EvmAddressJSON } from '../../dataTypes';
import { BigNumber, BigNumberInput, BigNumberJSON } from '@moralisweb3/common-core';
import { EvmErc20MetadataLinks, EvmErc20MetadataLinksValue, EvmErc20MetadataLinksInput, EvmErc20MetadataLinksJSON } from '../types/EvmErc20MetadataLinks';

// $ref: #/components/schemas/erc20Metadata
// type: erc20Metadata
Expand All @@ -12,11 +13,16 @@ import { BigNumber, BigNumberInput, BigNumberJSON } from '@moralisweb3/common-co
// - logo ($ref: #/components/schemas/erc20Metadata/properties/logo)
// - logo_hash ($ref: #/components/schemas/erc20Metadata/properties/logo_hash)
// - thumbnail ($ref: #/components/schemas/erc20Metadata/properties/thumbnail)
// - total_supply ($ref: #/components/schemas/erc20Metadata/properties/total_supply)
// - total_supply_formatted ($ref: #/components/schemas/erc20Metadata/properties/total_supply_formatted)
// - fully_diluted_valuation ($ref: #/components/schemas/erc20Metadata/properties/fully_diluted_valuation)
// - block_number ($ref: #/components/schemas/erc20Metadata/properties/block_number)
// - validated ($ref: #/components/schemas/erc20Metadata/properties/validated)
// - created_at ($ref: #/components/schemas/erc20Metadata/properties/created_at)
// - possible_spam ($ref: #/components/schemas/erc20Metadata/properties/possible_spam)
// - verified_contract ($ref: #/components/schemas/erc20Metadata/properties/verified_contract)
// - categories ($ref: #/components/schemas/erc20Metadata/properties/categories)
// - links ($ref: #/components/schemas/erc20Metadata/properties/links)

export interface EvmErc20MetadataJSON {
readonly address: EvmAddressJSON;
Expand All @@ -27,11 +33,16 @@ export interface EvmErc20MetadataJSON {
readonly logo?: string;
readonly logo_hash?: string;
readonly thumbnail?: string;
readonly total_supply?: string;
readonly total_supply_formatted?: string;
readonly fully_diluted_valuation?: string;
readonly block_number?: BigNumberJSON;
readonly validated?: number;
readonly created_at: string;
readonly possible_spam: boolean;
readonly verified_contract?: boolean;
readonly categories?: string[];
readonly links?: EvmErc20MetadataLinksJSON;
}

export interface EvmErc20MetadataInput {
Expand All @@ -43,11 +54,16 @@ export interface EvmErc20MetadataInput {
readonly logo?: string;
readonly logoHash?: string;
readonly thumbnail?: string;
readonly totalSupply?: string;
readonly totalSupplyFormatted?: string;
readonly fullyDilutedValuation?: string;
readonly blockNumber?: BigNumberInput | BigNumber;
readonly validated?: number;
readonly createdAt: string;
readonly possibleSpam: boolean;
readonly verifiedContract?: boolean;
readonly categories?: string[];
readonly links?: EvmErc20MetadataLinksInput | EvmErc20MetadataLinksValue;
}

export class EvmErc20Metadata {
Expand All @@ -68,11 +84,16 @@ export class EvmErc20Metadata {
logo: json.logo,
logoHash: json.logo_hash,
thumbnail: json.thumbnail,
totalSupply: json.total_supply,
totalSupplyFormatted: json.total_supply_formatted,
fullyDilutedValuation: json.fully_diluted_valuation,
blockNumber: json.block_number ? BigNumber.fromJSON(json.block_number) : undefined,
validated: json.validated,
createdAt: json.created_at,
possibleSpam: json.possible_spam,
verifiedContract: json.verified_contract,
categories: json.categories,
links: json.links ? EvmErc20MetadataLinks.fromJSON(json.links) : undefined,
};
return EvmErc20Metadata.create(input);
}
Expand Down Expand Up @@ -109,6 +130,18 @@ export class EvmErc20Metadata {
* @description The thumbnail of the logo
*/
public readonly thumbnail?: string;
/**
* @description Total tokens created minus any that have been burned
*/
public readonly totalSupply?: string;
/**
* @description Total tokens created minus any that have been burned (decimal formatted)
*/
public readonly totalSupplyFormatted?: string;
/**
* @description Fully Diluted Valuation (FDV), this represents the token's Current Price x Total Supply
*/
public readonly fullyDilutedValuation?: string;
public readonly blockNumber?: BigNumber;
public readonly validated?: number;
/**
Expand All @@ -123,6 +156,14 @@ export class EvmErc20Metadata {
* @description Indicates if a contract is verified
*/
public readonly verifiedContract?: boolean;
/**
* @description Categories of the token
*/
public readonly categories?: string[];
/**
* @description Social links of the token
*/
public readonly links?: EvmErc20MetadataLinksValue;

private constructor(input: EvmErc20MetadataInput) {
this.address = EvmAddress.create(input.address);
Expand All @@ -133,11 +174,16 @@ export class EvmErc20Metadata {
this.logo = input.logo;
this.logoHash = input.logoHash;
this.thumbnail = input.thumbnail;
this.totalSupply = input.totalSupply;
this.totalSupplyFormatted = input.totalSupplyFormatted;
this.fullyDilutedValuation = input.fullyDilutedValuation;
this.blockNumber = input.blockNumber ? BigNumber.create(input.blockNumber) : undefined;
this.validated = input.validated;
this.createdAt = input.createdAt;
this.possibleSpam = input.possibleSpam;
this.verifiedContract = input.verifiedContract;
this.categories = input.categories;
this.links = input.links ? EvmErc20MetadataLinks.create(input.links) : undefined;
}

public toJSON(): EvmErc20MetadataJSON {
Expand All @@ -150,11 +196,16 @@ export class EvmErc20Metadata {
logo: this.logo,
logo_hash: this.logoHash,
thumbnail: this.thumbnail,
total_supply: this.totalSupply,
total_supply_formatted: this.totalSupplyFormatted,
fully_diluted_valuation: this.fullyDilutedValuation,
block_number: this.blockNumber ? this.blockNumber.toJSON() : undefined,
validated: this.validated,
created_at: this.createdAt,
possible_spam: this.possibleSpam,
verified_contract: this.verifiedContract,
categories: this.categories,
links: this.links ? this.links : undefined,
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// $ref: #/components/schemas/erc20Metadata/properties/links
// typeName: erc20Metadata_links

export type EvmErc20MetadataLinksJSON = object;
export type EvmErc20MetadataLinksInput = object;
export type EvmErc20MetadataLinksValue = object;

export abstract class EvmErc20MetadataLinks {
public static create(input: EvmErc20MetadataLinksInput | EvmErc20MetadataLinksValue): EvmErc20MetadataLinksValue {
return input;
}

public static fromJSON(json: EvmErc20MetadataLinksJSON): EvmErc20MetadataLinksValue {
return json;
}
}
16 changes: 13 additions & 3 deletions packages/common/evmUtils/src/generated/types/EvmErc20Price.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { EvmNativeErc20Price, EvmNativeErc20PriceInput, EvmNativeErc20PriceJSON
// - exchangeName ($ref: #/components/schemas/erc20Price/properties/exchangeName)
// - tokenAddress ($ref: #/components/schemas/erc20Price/properties/tokenAddress)
// - toBlock ($ref: #/components/schemas/erc20Price/properties/toBlock)
// - possibleSpam ($ref: #/components/schemas/erc20Price/properties/possibleSpam)
// - verifiedContract ($ref: #/components/schemas/erc20Price/properties/verifiedContract)

export interface EvmErc20PriceJSON {
Expand All @@ -30,7 +31,8 @@ export interface EvmErc20PriceJSON {
readonly exchangeName?: string;
readonly tokenAddress?: string;
readonly toBlock?: string;
readonly verifiedContract?: boolean;
readonly possibleSpam: boolean;
readonly verifiedContract: boolean;
}

export interface EvmErc20PriceInput {
Expand All @@ -46,7 +48,8 @@ export interface EvmErc20PriceInput {
readonly exchangeName?: string;
readonly tokenAddress?: string;
readonly toBlock?: string;
readonly verifiedContract?: boolean;
readonly possibleSpam: boolean;
readonly verifiedContract: boolean;
}

export class EvmErc20Price {
Expand All @@ -71,6 +74,7 @@ export class EvmErc20Price {
exchangeName: json.exchangeName,
tokenAddress: json.tokenAddress,
toBlock: json.toBlock,
possibleSpam: json.possibleSpam,
verifiedContract: json.verifiedContract,
};
return EvmErc20Price.create(input);
Expand Down Expand Up @@ -121,10 +125,14 @@ export class EvmErc20Price {
* @description toBlock
*/
public readonly toBlock?: string;
/**
* @description Indicates if a contract is possibly a spam contract
*/
public readonly possibleSpam: boolean;
/**
* @description Indicates if the contract is verified
*/
public readonly verifiedContract?: boolean;
public readonly verifiedContract: boolean;

private constructor(input: EvmErc20PriceInput) {
this.tokenName = input.tokenName;
Expand All @@ -139,6 +147,7 @@ export class EvmErc20Price {
this.exchangeName = input.exchangeName;
this.tokenAddress = input.tokenAddress;
this.toBlock = input.toBlock;
this.possibleSpam = input.possibleSpam;
this.verifiedContract = input.verifiedContract;
}

Expand All @@ -156,6 +165,7 @@ export class EvmErc20Price {
exchangeName: this.exchangeName,
tokenAddress: this.tokenAddress,
toBlock: this.toBlock,
possibleSpam: this.possibleSpam,
verifiedContract: this.verifiedContract,
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// $ref: #/components/schemas/nftTradesChainList
// typeName: nftTradesChainList

export type EvmNftTradesChainListJSON = "eth" | "0x1" | "polygon" | "0x89" | "bsc" | "0x38" | "avalanche" | "0xa86a" | "arbitrum" | "0xa4b1" | "base" | "0x2105" | "optimism" | "0xa";
export type EvmNftTradesChainListInput = "eth" | "0x1" | "polygon" | "0x89" | "bsc" | "0x38" | "avalanche" | "0xa86a" | "arbitrum" | "0xa4b1" | "base" | "0x2105" | "optimism" | "0xa";
export type EvmNftTradesChainListValue = "eth" | "0x1" | "polygon" | "0x89" | "bsc" | "0x38" | "avalanche" | "0xa86a" | "arbitrum" | "0xa4b1" | "base" | "0x2105" | "optimism" | "0xa";

export abstract class EvmNftTradesChainList {
public static create(input: EvmNftTradesChainListInput | EvmNftTradesChainListValue): EvmNftTradesChainListValue {
return input;
}

public static fromJSON(json: EvmNftTradesChainListJSON): EvmNftTradesChainListValue {
return json;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export interface EvmWalletHistoryErc20TransferJSON {
readonly token_decimals: string;
readonly address: EvmAddressJSON;
readonly block_timestamp?: string;
readonly to_address: EvmAddressJSON;
readonly to_address?: EvmAddressJSON;
readonly to_address_label?: string;
readonly from_address: EvmAddressJSON;
readonly from_address_label?: string;
Expand All @@ -44,7 +44,7 @@ export interface EvmWalletHistoryErc20TransferInput {
readonly tokenDecimals: number;
readonly address: EvmAddressInput | EvmAddress;
readonly blockTimestamp?: string;
readonly toAddress: EvmAddressInput | EvmAddress;
readonly toAddress?: EvmAddressInput | EvmAddress;
readonly toAddressLabel?: string;
readonly fromAddress: EvmAddressInput | EvmAddress;
readonly fromAddressLabel?: string;
Expand All @@ -71,7 +71,7 @@ export class EvmWalletHistoryErc20Transfer {
tokenDecimals: Number(json.token_decimals),
address: EvmAddress.fromJSON(json.address),
blockTimestamp: json.block_timestamp,
toAddress: EvmAddress.fromJSON(json.to_address),
toAddress: json.to_address ? EvmAddress.fromJSON(json.to_address) : undefined,
toAddressLabel: json.to_address_label,
fromAddress: EvmAddress.fromJSON(json.from_address),
fromAddressLabel: json.from_address_label,
Expand Down Expand Up @@ -99,7 +99,7 @@ export class EvmWalletHistoryErc20Transfer {
/**
* @description The recipient
*/
public readonly toAddress: EvmAddress;
public readonly toAddress?: EvmAddress;
/**
* @description The label of the to address
*/
Expand Down Expand Up @@ -140,7 +140,7 @@ export class EvmWalletHistoryErc20Transfer {
this.tokenDecimals = input.tokenDecimals;
this.address = EvmAddress.create(input.address);
this.blockTimestamp = input.blockTimestamp;
this.toAddress = EvmAddress.create(input.toAddress);
this.toAddress = input.toAddress ? EvmAddress.create(input.toAddress) : undefined;
this.toAddressLabel = input.toAddressLabel;
this.fromAddress = EvmAddress.create(input.fromAddress);
this.fromAddressLabel = input.fromAddressLabel;
Expand All @@ -159,7 +159,7 @@ export class EvmWalletHistoryErc20Transfer {
token_decimals: String(this.tokenDecimals),
address: this.address.toJSON(),
block_timestamp: this.blockTimestamp,
to_address: this.toAddress.toJSON(),
to_address: this.toAddress ? this.toAddress.toJSON() : undefined,
to_address_label: this.toAddressLabel,
from_address: this.fromAddress.toJSON(),
from_address_label: this.fromAddressLabel,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export interface EvmWalletHistoryNftTransferJSON {
readonly token_id: string;
readonly from_address: EvmAddressJSON;
readonly from_address_label?: string;
readonly to_address: EvmAddressJSON;
readonly to_address?: EvmAddressJSON;
readonly to_address_label?: string;
readonly value: string;
readonly amount: string;
Expand All @@ -49,7 +49,7 @@ export interface EvmWalletHistoryNftTransferInput {
readonly tokenId: string;
readonly fromAddress: EvmAddressInput | EvmAddress;
readonly fromAddressLabel?: string;
readonly toAddress: EvmAddressInput | EvmAddress;
readonly toAddress?: EvmAddressInput | EvmAddress;
readonly toAddressLabel?: string;
readonly value: string;
readonly amount: string;
Expand Down Expand Up @@ -79,7 +79,7 @@ export class EvmWalletHistoryNftTransfer {
tokenId: json.token_id,
fromAddress: EvmAddress.fromJSON(json.from_address),
fromAddressLabel: json.from_address_label,
toAddress: EvmAddress.fromJSON(json.to_address),
toAddress: json.to_address ? EvmAddress.fromJSON(json.to_address) : undefined,
toAddressLabel: json.to_address_label,
value: json.value,
amount: json.amount,
Expand Down Expand Up @@ -116,7 +116,7 @@ export class EvmWalletHistoryNftTransfer {
/**
* @description The address that received the NFT
*/
public readonly toAddress: EvmAddress;
public readonly toAddress?: EvmAddress;
/**
* @description The label of the to address
*/
Expand Down Expand Up @@ -175,7 +175,7 @@ export class EvmWalletHistoryNftTransfer {
this.tokenId = input.tokenId;
this.fromAddress = EvmAddress.create(input.fromAddress);
this.fromAddressLabel = input.fromAddressLabel;
this.toAddress = EvmAddress.create(input.toAddress);
this.toAddress = input.toAddress ? EvmAddress.create(input.toAddress) : undefined;
this.toAddressLabel = input.toAddressLabel;
this.value = input.value;
this.amount = input.amount;
Expand All @@ -197,7 +197,7 @@ export class EvmWalletHistoryNftTransfer {
token_id: this.tokenId,
from_address: this.fromAddress.toJSON(),
from_address_label: this.fromAddressLabel,
to_address: this.toAddress.toJSON(),
to_address: this.toAddress ? this.toAddress.toJSON() : undefined,
to_address_label: this.toAddressLabel,
value: this.value,
amount: this.amount,
Expand Down
Loading
Loading