diff --git a/.changeset/selfish-nails-exist.md b/.changeset/selfish-nails-exist.md new file mode 100644 index 0000000000..4b695de918 --- /dev/null +++ b/.changeset/selfish-nails-exist.md @@ -0,0 +1,7 @@ +--- +'@moralisweb3/common-evm-utils': minor +'@moralisweb3/evm-api': minor +'moralis': minor +--- + +Updated the types of the `toBlock` and `toDate` properties in the `GetNFTTradesOperationRequest` interface to number and Date, respectively. diff --git a/.changeset/tasty-planes-admire.md b/.changeset/tasty-planes-admire.md new file mode 100644 index 0000000000..3d5895bd54 --- /dev/null +++ b/.changeset/tasty-planes-admire.md @@ -0,0 +1,7 @@ +--- +'@moralisweb3/common-evm-utils': patch +'@moralisweb3/evm-api': patch +'moralis': patch +--- + +Added `getWalletTokenBalancesPrice`, `getPairPrice`, `resolveAddressToDomain`, `resolveENSAddress`, `getWalletNetWorth` methods to the EVM API. diff --git a/packages/apiGenerator/src/generator/fileGenerators/codeGenerators/TypeConversionCodeGenerator.spec.ts b/packages/apiGenerator/src/generator/fileGenerators/codeGenerators/TypeConversionCodeGenerator.spec.ts index d8ec3b9127..b892a764a5 100644 --- a/packages/apiGenerator/src/generator/fileGenerators/codeGenerators/TypeConversionCodeGenerator.spec.ts +++ b/packages/apiGenerator/src/generator/fileGenerators/codeGenerators/TypeConversionCodeGenerator.spec.ts @@ -2,19 +2,26 @@ import { TypeConversionCodeGenerator } from './TypeConversionCodeGenerator'; describe('TypeConversionCodeGenerator', () => { it('does not change value if types are the same', () => { - expect(TypeConversionCodeGenerator.generate('string', 'string', 'value')).toEqual('value'); - expect(TypeConversionCodeGenerator.generate('number', 'number', 'this.value')).toEqual('this.value'); + expect(TypeConversionCodeGenerator.generate(true, 'string', 'string', 'value')).toEqual('value'); + expect(TypeConversionCodeGenerator.generate(true, 'number', 'number', 'this.value')).toEqual('this.value'); + expect(TypeConversionCodeGenerator.generate(false, 'number', 'number', 'this.value')).toEqual('this.value'); }); it('converts string to Date', () => { - expect(TypeConversionCodeGenerator.generate('string', 'Date', 'value')).toEqual('new Date(value)'); + expect(TypeConversionCodeGenerator.generate(true, 'string', 'Date', 'value')).toEqual('new Date(value)'); }); it('converts string to number', () => { - expect(TypeConversionCodeGenerator.generate('string', 'number', 'value')).toEqual('Number(value)'); + expect(TypeConversionCodeGenerator.generate(true, 'string', 'number', 'value')).toEqual('Number(value)'); + expect(TypeConversionCodeGenerator.generate(false, 'string', 'number', 'this.value')).toEqual( + 'this.value !== undefined ? Number(this.value) : undefined', + ); }); it('converts Date to string', () => { - expect(TypeConversionCodeGenerator.generate('Date', 'string', 'value')).toEqual('value.toISOString()'); + expect(TypeConversionCodeGenerator.generate(true, 'Date', 'string', 'value')).toEqual('value.toISOString()'); + expect(TypeConversionCodeGenerator.generate(false, 'Date', 'string', 'value')).toEqual( + 'value !== undefined ? value.toISOString() : undefined', + ); }); }); diff --git a/packages/apiGenerator/src/generator/fileGenerators/codeGenerators/TypeConversionCodeGenerator.ts b/packages/apiGenerator/src/generator/fileGenerators/codeGenerators/TypeConversionCodeGenerator.ts index 1b572ac107..46e8449ee5 100644 --- a/packages/apiGenerator/src/generator/fileGenerators/codeGenerators/TypeConversionCodeGenerator.ts +++ b/packages/apiGenerator/src/generator/fileGenerators/codeGenerators/TypeConversionCodeGenerator.ts @@ -1,34 +1,47 @@ export class TypeConversionCodeGenerator { - public static generate(sourceNativeType: string, targetNativeType: string, valueCode: string): string { + public static generate( + isRequired: boolean, + sourceNativeType: string, + targetNativeType: string, + valueCode: string, + ): string { if (sourceNativeType === targetNativeType) { return valueCode; } + let code: string | undefined; switch (targetNativeType) { case 'number': switch (sourceNativeType) { case 'string': - return `Number(${valueCode})`; + code = `Number(${valueCode})`; + break; } break; case 'string': switch (sourceNativeType) { case 'number': - return `String(${valueCode})`; + code = `String(${valueCode})`; + break; case 'Date': - return `${valueCode}.toISOString()`; + code = `${valueCode}.toISOString()`; + break; } break; case 'Date': switch (sourceNativeType) { case 'string': - return `new Date(${valueCode})`; + code = `new Date(${valueCode})`; + break; } break; } + if (code) { + return isRequired ? code : `${valueCode} !== undefined ? ${code} : undefined`; + } throw new Error(`Conversion from ${sourceNativeType} to ${targetNativeType} is not supported`); } } diff --git a/packages/apiGenerator/src/generator/fileGenerators/codeGenerators/ValueMappingCodeGenerator.ts b/packages/apiGenerator/src/generator/fileGenerators/codeGenerators/ValueMappingCodeGenerator.ts index 6fd77a5721..9db32642e0 100644 --- a/packages/apiGenerator/src/generator/fileGenerators/codeGenerators/ValueMappingCodeGenerator.ts +++ b/packages/apiGenerator/src/generator/fileGenerators/codeGenerators/ValueMappingCodeGenerator.ts @@ -15,6 +15,7 @@ export class ValueMappingCodeGenerator { if (resolvedType.nativeType) { return TypeConversionCodeGenerator.generate( + isRequired, resolvedType.nativeType.jsonType, resolvedType.nativeType.valueType, valueCode, @@ -46,6 +47,7 @@ export class ValueMappingCodeGenerator { if (resolvedType.nativeType) { return TypeConversionCodeGenerator.generate( + isRequired, resolvedType.nativeType.valueType, resolvedType.nativeType.jsonType, valueCode, diff --git a/packages/common/evmUtils/generator.config.json b/packages/common/evmUtils/generator.config.json index 47d745bf3d..ebf4de762f 100644 --- a/packages/common/evmUtils/generator.config.json +++ b/packages/common/evmUtils/generator.config.json @@ -8,7 +8,11 @@ "types": [], "refs": [ { - "refs": ["#/components/schemas/trade/properties/price"], + "refs": [ + "#/components/schemas/trade/properties/price", + "#/components/schemas/erc20TokenBalanceWithPrice/properties/balance", + "#/components/schemas/chainNetWorth/properties/native_balance" + ], "className": "EvmNative", "import": "../../dataTypes" }, @@ -42,7 +46,7 @@ "import": "@moralisweb3/common-core" }, { - "names": ["transaction_index", "token_decimals", "log_index"], + "names": ["transaction_index", "token_decimals", "log_index", "decimals"], "nativeType": "number" } ], @@ -53,9 +57,26 @@ "import": "../../dataTypes" }, { - "names": ["address", "contract_addresses", "wallet_addresses", "exclude_wallets", "exclude_contracts"], + "names": [ + "address", + "contract_addresses", + "wallet_addresses", + "exclude_wallets", + "exclude_contracts", + "token0_address", + "token1_address", + "token_addresses" + ], "className": "EvmAddress", "import": "../../dataTypes" + }, + { + "names": ["to_block"], + "nativeType": "number" + }, + { + "names": "to_date", + "nativeType": "Date" } ] }, @@ -81,7 +102,12 @@ "getNFTCollectionStats", "getBlockStats", "getTokenStats", - "getMultipleTokenPrices" + "getMultipleTokenPrices", + "getWalletNetWorth", + "getWalletTokenBalancesPrice", + "getPairPrice", + "resolveAddressToDomain", + "resolveENSAddress" ] } } diff --git a/packages/common/evmUtils/src/generated/client/abstractClient.ts b/packages/common/evmUtils/src/generated/client/abstractClient.ts index 5c8f7a25eb..cd4378b285 100644 --- a/packages/common/evmUtils/src/generated/client/abstractClient.ts +++ b/packages/common/evmUtils/src/generated/client/abstractClient.ts @@ -3,10 +3,18 @@ import { EvmTradeCollection, EvmTradeCollectionJSON } from '../types/EvmTradeCol import { GetMultipleTokenPricesOperation, GetMultipleTokenPricesOperationRequest, GetMultipleTokenPricesOperationRequestJSON } from '../operations/GetMultipleTokenPricesOperation'; import { EvmErc20Price, EvmErc20PriceJSON } from '../types/EvmErc20Price'; import { EvmGetMultipleTokenPricesDto, EvmGetMultipleTokenPricesDtoInput, EvmGetMultipleTokenPricesDtoJSON } from '../types/EvmGetMultipleTokenPricesDto'; +import { GetWalletTokenBalancesPriceOperation, GetWalletTokenBalancesPriceOperationRequest, GetWalletTokenBalancesPriceOperationRequestJSON } from '../operations/GetWalletTokenBalancesPriceOperation'; +import { EvmErc20TokenBalanceWithPriceResult, EvmErc20TokenBalanceWithPriceResultJSON } from '../types/EvmErc20TokenBalanceWithPriceResult'; +import { GetWalletNetWorthOperation, GetWalletNetWorthOperationRequest, GetWalletNetWorthOperationRequestJSON } from '../operations/GetWalletNetWorthOperation'; +import { EvmNetWorthResult, EvmNetWorthResultJSON } from '../types/EvmNetWorthResult'; import { Web3ApiVersionOperation, Web3ApiVersionOperationRequest, Web3ApiVersionOperationRequestJSON } from '../operations/Web3ApiVersionOperation'; import { EvmWeb3version, EvmWeb3versionJSON } from '../types/EvmWeb3version'; import { EndpointWeightsOperation, EndpointWeightsOperationRequest, EndpointWeightsOperationRequestJSON } from '../operations/EndpointWeightsOperation'; import { EvmEndpointWeights, EvmEndpointWeightsJSON } from '../types/EvmEndpointWeights'; +import { ResolveAddressToDomainOperation, ResolveAddressToDomainOperationRequest, ResolveAddressToDomainOperationRequestJSON } from '../operations/ResolveAddressToDomainOperation'; +import { EvmUnstoppableDomain, EvmUnstoppableDomainJSON } from '../types/EvmUnstoppableDomain'; +import { GetPairPriceOperation, GetPairPriceOperationRequest, GetPairPriceOperationRequestJSON } from '../operations/GetPairPriceOperation'; +import { EvmGetPairPrice, EvmGetPairPriceJSON } from '../types/EvmGetPairPrice'; import { GetTopERC20TokensByMarketCapOperation, GetTopERC20TokensByMarketCapOperationRequest, GetTopERC20TokensByMarketCapOperationRequestJSON } from '../operations/GetTopERC20TokensByMarketCapOperation'; import { EvmMarketDataERC20TokenItem, EvmMarketDataERC20TokenItemJSON } from '../types/EvmMarketDataERC20TokenItem'; import { GetTopERC20TokensByPriceMoversOperation, GetTopERC20TokensByPriceMoversOperationRequest, GetTopERC20TokensByPriceMoversOperationRequestJSON } from '../operations/GetTopERC20TokensByPriceMoversOperation'; @@ -67,6 +75,27 @@ export abstract class AbstractClient { EvmBlockTokenStatJSON >(GetBlockStatsOperation), }; + public readonly defi = { + /** + * @description Get the price of a given token pair. Only Uniswap V2 based exchanges supported at the moment. + * @param request Request with parameters. + * @param {Object} request.token0Address The token0 address + * @param {Object} request.token1Address The token1 address + * @param {Object} [request.chain] The chain to query (optional) + * @param {Number} [request.toBlock] The block number to get the reserves from (optional) + * @param {Date} [request.toDate] Get the price up to this date (format in seconds or datestring accepted by momentjs) + * * Provide the param 'to_block' or 'to_date' + * * If 'to_date' and 'to_block' are provided, 'to_block' will be used. (optional) + * @param {String} [request.exchange] The factory name or address of the token exchange (optional) + * @returns {Object} Response for the request. + */ + getPairPrice: this.createEndpoint< + GetPairPriceOperationRequest, + GetPairPriceOperationRequestJSON, + EvmGetPairPrice, + EvmGetPairPriceJSON + >(GetPairPriceOperation), + }; public readonly marketData = { /** * @description Get the top ERC20 tokens by market cap @@ -122,11 +151,11 @@ export abstract class AbstractClient { * @param {Number} [request.fromBlock] The minimum block number from which to get the transfers * * Provide the param 'from_block' or 'from_date' * * If 'from_date' and 'from_block' are provided, 'from_block' will be used. (optional) - * @param {String} [request.toBlock] The block number to get the trades from (optional) + * @param {Number} [request.toBlock] The block number to get the trades from (optional) * @param {String} [request.fromDate] The start date from which to get the transfers (format in seconds or datestring accepted by momentjs) * * Provide the param 'from_block' or 'from_date' * * If 'from_date' and 'from_block' are provided, 'from_block' will be used. (optional) - * @param {String} [request.toDate] The end date from which to get the transfers (format in seconds or datestring accepted by momentjs) + * @param {Date} [request.toDate] The end date from which to get the transfers (format in seconds or datestring accepted by momentjs) * * Provide the param 'to_block' or 'to_date' * * If 'to_date' and 'to_block' are provided, 'to_block' will be used. (optional) * @param {Object} [request.marketplace] Marketplace from which to get the trades (only OpenSea is supported at the moment) (optional) @@ -168,6 +197,21 @@ export abstract class AbstractClient { EvmNftTokenStatJSON >(GetNFTTokenStatsOperation), }; + public readonly resolve = { + /** + * @description Resolve a specific address to its Unstoppable domain + * @param request Request with parameters. + * @param {Object} request.address The address to be resolved + * @param {Object} [request.currency] The currency to query (optional) + * @returns {Object} Response for the request. + */ + resolveAddressToDomain: this.createEndpoint< + ResolveAddressToDomainOperationRequest, + ResolveAddressToDomainOperationRequestJSON, + EvmUnstoppableDomain, + EvmUnstoppableDomainJSON + >(ResolveAddressToDomainOperation), + }; public readonly token = { /** * @description Returns an array of token prices denominated in the blockchain's native token and USD for a given token contract address @@ -241,6 +285,41 @@ export abstract class AbstractClient { >(ReviewContractsOperation), }; public readonly wallets = { + /** + * @description Get token balances for a specific wallet address and their token prices in USD. + * @param request Request with parameters. + * @param {Object} request.address The address from which token balances will be checked + * @param {Object} [request.chain] The chain to query (optional) + * @param {Number} [request.toBlock] The block number up to which the balances will be checked. (optional) + * @param {Object[]} [request.tokenAddresses] The addresses to get balances for (optional) (optional) + * @param {Boolean} [request.excludeSpam] Exclude spam tokens from the result (optional) + * @param {Boolean} [request.excludeUnverifiedContracts] Exclude unverified contracts from the result (optional) + * @param {String} [request.cursor] The cursor returned in the previous response (used for getting the next page). (optional) + * @param {Number} [request.limit] The desired page size of the result. (optional) + * @param {Boolean} [request.excludeNative] Exclude native balance from the result (optional) + * @returns {Object} Response for the request. + */ + getWalletTokenBalancesPrice: this.createEndpoint< + GetWalletTokenBalancesPriceOperationRequest, + GetWalletTokenBalancesPriceOperationRequestJSON, + EvmErc20TokenBalanceWithPriceResult, + EvmErc20TokenBalanceWithPriceResultJSON + >(GetWalletTokenBalancesPriceOperation), + /** + * @description Get the net worth of a wallet in USD. We recommend to filter out spam tokens and unverified contracts to get a more accurate result. + * @param request Request with parameters. + * @param {Object} request.address The wallet address + * @param {Object[]} [request.chains] The chains to query (optional) + * @param {Boolean} [request.excludeSpam] Exclude spam tokens from the result (optional) + * @param {Boolean} [request.excludeUnverifiedContracts] Exclude unverified contracts from the result (optional) + * @returns {Object} Response for the request. + */ + getWalletNetWorth: this.createEndpoint< + GetWalletNetWorthOperationRequest, + GetWalletNetWorthOperationRequestJSON, + EvmNetWorthResult, + EvmNetWorthResultJSON + >(GetWalletNetWorthOperation), /** * @description Get the active chains for a wallet address. * @param request Request with parameters. diff --git a/packages/common/evmUtils/src/generated/operations/GetNFTTradesOperation.ts b/packages/common/evmUtils/src/generated/operations/GetNFTTradesOperation.ts index 8529549b0b..b3c1ebecc5 100644 --- a/packages/common/evmUtils/src/generated/operations/GetNFTTradesOperation.ts +++ b/packages/common/evmUtils/src/generated/operations/GetNFTTradesOperation.ts @@ -27,7 +27,7 @@ export interface GetNFTTradesOperationRequest { /** * @description The block number to get the trades from */ - readonly toBlock?: string; + readonly toBlock?: number; /** * @description The start date from which to get the transfers (format in seconds or datestring accepted by momentjs) * * Provide the param 'from_block' or 'from_date' @@ -39,7 +39,7 @@ export interface GetNFTTradesOperationRequest { * * Provide the param 'to_block' or 'to_date' * * If 'to_date' and 'to_block' are provided, 'to_block' will be used. */ - readonly toDate?: string; + readonly toDate?: Date; /** * @description Marketplace from which to get the trades (only OpenSea is supported at the moment) */ @@ -99,9 +99,9 @@ export const GetNFTTradesOperation = { return { chain: chain ? chain.toJSON() : undefined, from_block: fromBlock, - to_block: toBlock, + to_block: toBlock !== undefined ? String(toBlock) : undefined, from_date: fromDate, - to_date: toDate, + to_date: toDate !== undefined ? toDate.toISOString() : undefined, marketplace: marketplace ? marketplace : undefined, cursor: cursor, limit: limit, diff --git a/packages/common/evmUtils/src/generated/operations/GetPairPriceOperation.ts b/packages/common/evmUtils/src/generated/operations/GetPairPriceOperation.ts new file mode 100644 index 0000000000..a5cb57a637 --- /dev/null +++ b/packages/common/evmUtils/src/generated/operations/GetPairPriceOperation.ts @@ -0,0 +1,83 @@ +import { EvmChain, EvmChainInput, EvmChainJSON, EvmAddress, EvmAddressInput, EvmAddressJSON } from '../../dataTypes'; +import { EvmGetPairPrice, EvmGetPairPriceJSON } from '../types/EvmGetPairPrice'; + +// request parameters: +// - chain ($ref: #/components/schemas/chainList) +// - to_block ($ref: #/paths/~1{token0_address}~1{token1_address}~1price/get/parameters/1/schema) +// - to_date ($ref: #/paths/~1{token0_address}~1{token1_address}~1price/get/parameters/2/schema) +// - token0_address ($ref: #/paths/~1{token0_address}~1{token1_address}~1price/get/parameters/3/schema) +// - token1_address ($ref: #/paths/~1{token0_address}~1{token1_address}~1price/get/parameters/4/schema) +// - exchange ($ref: #/paths/~1{token0_address}~1{token1_address}~1price/get/parameters/5/schema) + +export interface GetPairPriceOperationRequest { + /** + * @description The chain to query + */ + readonly chain?: EvmChainInput | EvmChain; + /** + * @description The block number to get the reserves from + */ + readonly toBlock?: number; + /** + * @description Get the price up to this date (format in seconds or datestring accepted by momentjs) + * * Provide the param 'to_block' or 'to_date' + * * If 'to_date' and 'to_block' are provided, 'to_block' will be used. + */ + readonly toDate?: Date; + /** + * @description The token0 address + */ + readonly token0Address: EvmAddressInput | EvmAddress; + /** + * @description The token1 address + */ + readonly token1Address: EvmAddressInput | EvmAddress; + /** + * @description The factory name or address of the token exchange + */ + readonly exchange?: string; +} + +export interface GetPairPriceOperationRequestJSON { + readonly chain?: EvmChainJSON; + readonly to_block?: string; + readonly to_date?: string; + readonly token0_address: EvmAddressJSON; + readonly token1_address: EvmAddressJSON; + readonly exchange?: string; +} + +export type GetPairPriceOperationResponse = EvmGetPairPrice; +export type GetPairPriceOperationResponseJSON = EvmGetPairPriceJSON; + +export const GetPairPriceOperation = { + operationId: "getPairPrice", + groupName: "defi", + httpMethod: "get", + routePattern: "/{token0_address}/{token1_address}/price", + parameterNames: ["chain","to_block","to_date","token0_address","token1_address","exchange"], + hasResponse: true, + hasBody: false, + + parseResponse(json: EvmGetPairPriceJSON): EvmGetPairPrice { + return EvmGetPairPrice.fromJSON(json); + }, + + serializeRequest(request: GetPairPriceOperationRequest): GetPairPriceOperationRequestJSON { + const chain = request.chain ? EvmChain.create(request.chain) : undefined; + const toBlock = request.toBlock; + const toDate = request.toDate; + const token0Address = EvmAddress.create(request.token0Address); + const token1Address = EvmAddress.create(request.token1Address); + const exchange = request.exchange; + return { + chain: chain ? chain.toJSON() : undefined, + to_block: toBlock !== undefined ? String(toBlock) : undefined, + to_date: toDate !== undefined ? toDate.toISOString() : undefined, + token0_address: token0Address.toJSON(), + token1_address: token1Address.toJSON(), + exchange: exchange, + }; + }, + +} diff --git a/packages/common/evmUtils/src/generated/operations/GetWalletNetWorthOperation.ts b/packages/common/evmUtils/src/generated/operations/GetWalletNetWorthOperation.ts new file mode 100644 index 0000000000..ae35f93dcb --- /dev/null +++ b/packages/common/evmUtils/src/generated/operations/GetWalletNetWorthOperation.ts @@ -0,0 +1,65 @@ +import { EvmChain, EvmChainInput, EvmChainJSON, EvmAddress, EvmAddressInput, EvmAddressJSON } from '../../dataTypes'; +import { EvmNetWorthResult, EvmNetWorthResultJSON } from '../types/EvmNetWorthResult'; + +// request parameters: +// - chains ($ref: #/components/schemas/chainList) +// - address ($ref: #/paths/~1wallets~1{address}~1net-worth/get/parameters/1/schema) +// - exclude_spam ($ref: #/paths/~1wallets~1{address}~1net-worth/get/parameters/2/schema) +// - exclude_unverified_contracts ($ref: #/paths/~1wallets~1{address}~1net-worth/get/parameters/3/schema) + +export interface GetWalletNetWorthOperationRequest { + /** + * @description The chains to query + */ + readonly chains?: EvmChainInput[] | EvmChain[]; + /** + * @description The wallet address + */ + readonly address: EvmAddressInput | EvmAddress; + /** + * @description Exclude spam tokens from the result + */ + readonly excludeSpam?: boolean; + /** + * @description Exclude unverified contracts from the result + */ + readonly excludeUnverifiedContracts?: boolean; +} + +export interface GetWalletNetWorthOperationRequestJSON { + readonly chains?: EvmChainJSON[]; + readonly address: EvmAddressJSON; + readonly exclude_spam?: boolean; + readonly exclude_unverified_contracts?: boolean; +} + +export type GetWalletNetWorthOperationResponse = EvmNetWorthResult; +export type GetWalletNetWorthOperationResponseJSON = EvmNetWorthResultJSON; + +export const GetWalletNetWorthOperation = { + operationId: "getWalletNetWorth", + groupName: "wallets", + httpMethod: "get", + routePattern: "/wallets/{address}/net-worth", + parameterNames: ["chains","address","exclude_spam","exclude_unverified_contracts"], + hasResponse: true, + hasBody: false, + + parseResponse(json: EvmNetWorthResultJSON): EvmNetWorthResult { + return EvmNetWorthResult.fromJSON(json); + }, + + serializeRequest(request: GetWalletNetWorthOperationRequest): GetWalletNetWorthOperationRequestJSON { + const chains = request.chains ? request.chains.map((item) => EvmChain.create(item)) : undefined; + const address = EvmAddress.create(request.address); + const excludeSpam = request.excludeSpam; + const excludeUnverifiedContracts = request.excludeUnverifiedContracts; + return { + chains: chains ? chains.map((item) => item.toJSON()) : undefined, + address: address.toJSON(), + exclude_spam: excludeSpam, + exclude_unverified_contracts: excludeUnverifiedContracts, + }; + }, + +} diff --git a/packages/common/evmUtils/src/generated/operations/GetWalletTokenBalancesPriceOperation.ts b/packages/common/evmUtils/src/generated/operations/GetWalletTokenBalancesPriceOperation.ts new file mode 100644 index 0000000000..3f25e40768 --- /dev/null +++ b/packages/common/evmUtils/src/generated/operations/GetWalletTokenBalancesPriceOperation.ts @@ -0,0 +1,105 @@ +import { EvmChain, EvmChainInput, EvmChainJSON, EvmAddress, EvmAddressInput, EvmAddressJSON } from '../../dataTypes'; +import { EvmErc20TokenBalanceWithPriceResult, EvmErc20TokenBalanceWithPriceResultJSON } from '../types/EvmErc20TokenBalanceWithPriceResult'; + +// request parameters: +// - chain ($ref: #/components/schemas/chainList) +// - address ($ref: #/paths/~1wallets~1{address}~1tokens/get/parameters/1/schema) +// - to_block ($ref: #/paths/~1wallets~1{address}~1tokens/get/parameters/2/schema) +// - token_addresses ($ref: #/paths/~1wallets~1{address}~1tokens/get/parameters/3/schema) +// - exclude_spam ($ref: #/paths/~1wallets~1{address}~1tokens/get/parameters/4/schema) +// - exclude_unverified_contracts ($ref: #/paths/~1wallets~1{address}~1tokens/get/parameters/5/schema) +// - cursor ($ref: #/paths/~1wallets~1{address}~1tokens/get/parameters/6/schema) +// - limit ($ref: #/paths/~1wallets~1{address}~1tokens/get/parameters/7/schema) +// - exclude_native ($ref: #/paths/~1wallets~1{address}~1tokens/get/parameters/8/schema) + +export interface GetWalletTokenBalancesPriceOperationRequest { + /** + * @description The chain to query + */ + readonly chain?: EvmChainInput | EvmChain; + /** + * @description The address from which token balances will be checked + */ + readonly address: EvmAddressInput | EvmAddress; + /** + * @description The block number up to which the balances will be checked. + */ + readonly toBlock?: number; + /** + * @description The addresses to get balances for (optional) + */ + readonly tokenAddresses?: EvmAddressInput[] | EvmAddress[]; + /** + * @description Exclude spam tokens from the result + */ + readonly excludeSpam?: boolean; + /** + * @description Exclude unverified contracts from the result + */ + readonly excludeUnverifiedContracts?: boolean; + /** + * @description The cursor returned in the previous response (used for getting the next page). + */ + readonly cursor?: string; + /** + * @description The desired page size of the result. + */ + readonly limit?: number; + /** + * @description Exclude native balance from the result + */ + readonly excludeNative?: boolean; +} + +export interface GetWalletTokenBalancesPriceOperationRequestJSON { + readonly chain?: EvmChainJSON; + readonly address: EvmAddressJSON; + readonly to_block?: number; + readonly token_addresses?: EvmAddressJSON[]; + readonly exclude_spam?: boolean; + readonly exclude_unverified_contracts?: boolean; + readonly cursor?: string; + readonly limit?: number; + readonly exclude_native?: boolean; +} + +export type GetWalletTokenBalancesPriceOperationResponse = EvmErc20TokenBalanceWithPriceResult; +export type GetWalletTokenBalancesPriceOperationResponseJSON = EvmErc20TokenBalanceWithPriceResultJSON; + +export const GetWalletTokenBalancesPriceOperation = { + operationId: "getWalletTokenBalancesPrice", + groupName: "wallets", + httpMethod: "get", + routePattern: "/wallets/{address}/tokens", + parameterNames: ["chain","address","to_block","token_addresses","exclude_spam","exclude_unverified_contracts","cursor","limit","exclude_native"], + hasResponse: true, + hasBody: false, + + parseResponse(json: EvmErc20TokenBalanceWithPriceResultJSON): EvmErc20TokenBalanceWithPriceResult { + return EvmErc20TokenBalanceWithPriceResult.fromJSON(json); + }, + + serializeRequest(request: GetWalletTokenBalancesPriceOperationRequest): GetWalletTokenBalancesPriceOperationRequestJSON { + const chain = request.chain ? EvmChain.create(request.chain) : undefined; + const address = EvmAddress.create(request.address); + const toBlock = request.toBlock; + const tokenAddresses = request.tokenAddresses ? request.tokenAddresses.map((item) => EvmAddress.create(item)) : undefined; + const excludeSpam = request.excludeSpam; + const excludeUnverifiedContracts = request.excludeUnverifiedContracts; + const cursor = request.cursor; + const limit = request.limit; + const excludeNative = request.excludeNative; + return { + chain: chain ? chain.toJSON() : undefined, + address: address.toJSON(), + to_block: toBlock, + token_addresses: tokenAddresses ? tokenAddresses.map((item) => item.toJSON()) : undefined, + exclude_spam: excludeSpam, + exclude_unverified_contracts: excludeUnverifiedContracts, + cursor: cursor, + limit: limit, + exclude_native: excludeNative, + }; + }, + +} diff --git a/packages/common/evmUtils/src/generated/operations/ResolveAddressToDomainOperation.ts b/packages/common/evmUtils/src/generated/operations/ResolveAddressToDomainOperation.ts new file mode 100644 index 0000000000..8a74ce0048 --- /dev/null +++ b/packages/common/evmUtils/src/generated/operations/ResolveAddressToDomainOperation.ts @@ -0,0 +1,50 @@ +import { EvmResolveAddressToDomainCurrencyEnum, EvmResolveAddressToDomainCurrencyEnumValue, EvmResolveAddressToDomainCurrencyEnumInput, EvmResolveAddressToDomainCurrencyEnumJSON } from '../types/EvmResolveAddressToDomainCurrencyEnum'; +import { EvmAddress, EvmAddressInput, EvmAddressJSON } from '../../dataTypes'; +import { EvmUnstoppableDomain, EvmUnstoppableDomainJSON } from '../types/EvmUnstoppableDomain'; + +// request parameters: +// - currency ($ref: #/paths/~1resolve~1{address}~1domain/get/parameters/0/schema) +// - address ($ref: #/paths/~1resolve~1{address}~1domain/get/parameters/1/schema) + +export interface ResolveAddressToDomainOperationRequest { + /** + * @description The currency to query + */ + readonly currency?: EvmResolveAddressToDomainCurrencyEnumInput | EvmResolveAddressToDomainCurrencyEnumValue; + /** + * @description The address to be resolved + */ + readonly address: EvmAddressInput | EvmAddress; +} + +export interface ResolveAddressToDomainOperationRequestJSON { + readonly currency?: EvmResolveAddressToDomainCurrencyEnumJSON; + readonly address: EvmAddressJSON; +} + +export type ResolveAddressToDomainOperationResponse = EvmUnstoppableDomain; +export type ResolveAddressToDomainOperationResponseJSON = EvmUnstoppableDomainJSON; + +export const ResolveAddressToDomainOperation = { + operationId: "resolveAddressToDomain", + groupName: "resolve", + httpMethod: "get", + routePattern: "/resolve/{address}/domain", + parameterNames: ["currency","address"], + hasResponse: true, + hasBody: false, + + parseResponse(json: EvmUnstoppableDomainJSON): EvmUnstoppableDomain { + return EvmUnstoppableDomain.fromJSON(json); + }, + + serializeRequest(request: ResolveAddressToDomainOperationRequest): ResolveAddressToDomainOperationRequestJSON { + const currency = request.currency ? EvmResolveAddressToDomainCurrencyEnum.create(request.currency) : undefined; + const address = EvmAddress.create(request.address); + return { + currency: currency ? currency : undefined, + address: address.toJSON(), + }; + }, + +} diff --git a/packages/common/evmUtils/src/generated/operations/index.ts b/packages/common/evmUtils/src/generated/operations/index.ts index 7b9a62ed29..f8e28f1388 100644 --- a/packages/common/evmUtils/src/generated/operations/index.ts +++ b/packages/common/evmUtils/src/generated/operations/index.ts @@ -1,7 +1,11 @@ export * from './GetNFTTradesOperation'; export * from './GetMultipleTokenPricesOperation'; +export * from './GetWalletTokenBalancesPriceOperation'; +export * from './GetWalletNetWorthOperation'; export * from './Web3ApiVersionOperation'; export * from './EndpointWeightsOperation'; +export * from './ResolveAddressToDomainOperation'; +export * from './GetPairPriceOperation'; export * from './GetTopERC20TokensByMarketCapOperation'; export * from './GetTopERC20TokensByPriceMoversOperation'; export * from './GetTopNFTCollectionsByMarketCapOperation'; diff --git a/packages/common/evmUtils/src/generated/operations/operations.ts b/packages/common/evmUtils/src/generated/operations/operations.ts index 76527996a1..fe92c71034 100644 --- a/packages/common/evmUtils/src/generated/operations/operations.ts +++ b/packages/common/evmUtils/src/generated/operations/operations.ts @@ -1,7 +1,11 @@ import { GetNFTTradesOperation } from './GetNFTTradesOperation'; import { GetMultipleTokenPricesOperation } from './GetMultipleTokenPricesOperation'; +import { GetWalletTokenBalancesPriceOperation } from './GetWalletTokenBalancesPriceOperation'; +import { GetWalletNetWorthOperation } from './GetWalletNetWorthOperation'; import { Web3ApiVersionOperation } from './Web3ApiVersionOperation'; import { EndpointWeightsOperation } from './EndpointWeightsOperation'; +import { ResolveAddressToDomainOperation } from './ResolveAddressToDomainOperation'; +import { GetPairPriceOperation } from './GetPairPriceOperation'; import { GetTopERC20TokensByMarketCapOperation } from './GetTopERC20TokensByMarketCapOperation'; import { GetTopERC20TokensByPriceMoversOperation } from './GetTopERC20TokensByPriceMoversOperation'; import { GetTopNFTCollectionsByMarketCapOperation } from './GetTopNFTCollectionsByMarketCapOperation'; @@ -17,8 +21,12 @@ import { GetBlockStatsOperation } from './GetBlockStatsOperation'; export const operations = [ GetNFTTradesOperation, GetMultipleTokenPricesOperation, + GetWalletTokenBalancesPriceOperation, + GetWalletNetWorthOperation, Web3ApiVersionOperation, EndpointWeightsOperation, + ResolveAddressToDomainOperation, + GetPairPriceOperation, GetTopERC20TokensByMarketCapOperation, GetTopERC20TokensByPriceMoversOperation, GetTopNFTCollectionsByMarketCapOperation, diff --git a/packages/common/evmUtils/src/generated/types/EvmChainNetWorth.ts b/packages/common/evmUtils/src/generated/types/EvmChainNetWorth.ts new file mode 100644 index 0000000000..bcb877546e --- /dev/null +++ b/packages/common/evmUtils/src/generated/types/EvmChainNetWorth.ts @@ -0,0 +1,95 @@ +import { EvmNative, EvmNativeInput, EvmNativeJSON } from '../../dataTypes'; + +// $ref: #/components/schemas/chainNetWorth +// type: chainNetWorth +// properties: +// - chain ($ref: #/components/schemas/chainNetWorth/properties/chain) +// - native_balance ($ref: #/components/schemas/chainNetWorth/properties/native_balance) +// - native_balance_formatted ($ref: #/components/schemas/chainNetWorth/properties/native_balance_formatted) +// - native_balance_usd ($ref: #/components/schemas/chainNetWorth/properties/native_balance_usd) +// - token_balance_usd ($ref: #/components/schemas/chainNetWorth/properties/token_balance_usd) +// - networth_usd ($ref: #/components/schemas/chainNetWorth/properties/networth_usd) + +export interface EvmChainNetWorthJSON { + readonly chain: string; + readonly native_balance: EvmNativeJSON; + readonly native_balance_formatted: string; + readonly native_balance_usd: string; + readonly token_balance_usd: string; + readonly networth_usd: string; +} + +export interface EvmChainNetWorthInput { + readonly chain: string; + readonly nativeBalance: EvmNativeInput | EvmNative; + readonly nativeBalanceFormatted: string; + readonly nativeBalanceUsd: string; + readonly tokenBalanceUsd: string; + readonly networthUsd: string; +} + +export class EvmChainNetWorth { + public static create(input: EvmChainNetWorthInput | EvmChainNetWorth): EvmChainNetWorth { + if (input instanceof EvmChainNetWorth) { + return input; + } + return new EvmChainNetWorth(input); + } + + public static fromJSON(json: EvmChainNetWorthJSON): EvmChainNetWorth { + const input: EvmChainNetWorthInput = { + chain: json.chain, + nativeBalance: EvmNative.fromJSON(json.native_balance), + nativeBalanceFormatted: json.native_balance_formatted, + nativeBalanceUsd: json.native_balance_usd, + tokenBalanceUsd: json.token_balance_usd, + networthUsd: json.networth_usd, + }; + return EvmChainNetWorth.create(input); + } + + /** + * @description The chain + */ + public readonly chain: string; + /** + * @description The native balance + */ + public readonly nativeBalance: EvmNative; + /** + * @description The native balance formatted + */ + public readonly nativeBalanceFormatted: string; + /** + * @description The native balance in USD + */ + public readonly nativeBalanceUsd: string; + /** + * @description The token balance in USD + */ + public readonly tokenBalanceUsd: string; + /** + * @description The networth in USD + */ + public readonly networthUsd: string; + + private constructor(input: EvmChainNetWorthInput) { + this.chain = input.chain; + this.nativeBalance = EvmNative.create(input.nativeBalance); + this.nativeBalanceFormatted = input.nativeBalanceFormatted; + this.nativeBalanceUsd = input.nativeBalanceUsd; + this.tokenBalanceUsd = input.tokenBalanceUsd; + this.networthUsd = input.networthUsd; + } + + public toJSON(): EvmChainNetWorthJSON { + return { + chain: this.chain, + native_balance: this.nativeBalance.toJSON(), + native_balance_formatted: this.nativeBalanceFormatted, + native_balance_usd: this.nativeBalanceUsd, + token_balance_usd: this.tokenBalanceUsd, + networth_usd: this.networthUsd, + } + } +} diff --git a/packages/common/evmUtils/src/generated/types/EvmErc20Metadata.ts b/packages/common/evmUtils/src/generated/types/EvmErc20Metadata.ts new file mode 100644 index 0000000000..47a53e4fd5 --- /dev/null +++ b/packages/common/evmUtils/src/generated/types/EvmErc20Metadata.ts @@ -0,0 +1,159 @@ +import { BigNumber, BigNumberInput, BigNumberJSON } from '@moralisweb3/common-core'; + +// $ref: #/components/schemas/erc20Metadata +// type: erc20Metadata +// properties: +// - address ($ref: #/components/schemas/erc20Metadata/properties/address) +// - address_label ($ref: #/components/schemas/erc20Metadata/properties/address_label) +// - name ($ref: #/components/schemas/erc20Metadata/properties/name) +// - symbol ($ref: #/components/schemas/erc20Metadata/properties/symbol) +// - decimals ($ref: #/components/schemas/erc20Metadata/properties/decimals) +// - logo ($ref: #/components/schemas/erc20Metadata/properties/logo) +// - logo_hash ($ref: #/components/schemas/erc20Metadata/properties/logo_hash) +// - thumbnail ($ref: #/components/schemas/erc20Metadata/properties/thumbnail) +// - 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) + +export interface EvmErc20MetadataJSON { + readonly address: string; + readonly address_label?: string; + readonly name: string; + readonly symbol: string; + readonly decimals: string; + readonly logo?: string; + readonly logo_hash?: string; + readonly thumbnail?: string; + readonly block_number?: BigNumberJSON; + readonly validated?: number; + readonly created_at: string; + readonly possible_spam: boolean; + readonly verified_contract?: boolean; +} + +export interface EvmErc20MetadataInput { + readonly address: string; + readonly addressLabel?: string; + readonly name: string; + readonly symbol: string; + readonly decimals: number; + readonly logo?: string; + readonly logoHash?: string; + readonly thumbnail?: string; + readonly blockNumber?: BigNumberInput | BigNumber; + readonly validated?: number; + readonly createdAt: string; + readonly possibleSpam: boolean; + readonly verifiedContract?: boolean; +} + +export class EvmErc20Metadata { + public static create(input: EvmErc20MetadataInput | EvmErc20Metadata): EvmErc20Metadata { + if (input instanceof EvmErc20Metadata) { + return input; + } + return new EvmErc20Metadata(input); + } + + public static fromJSON(json: EvmErc20MetadataJSON): EvmErc20Metadata { + const input: EvmErc20MetadataInput = { + address: json.address, + addressLabel: json.address_label, + name: json.name, + symbol: json.symbol, + decimals: Number(json.decimals), + logo: json.logo, + logoHash: json.logo_hash, + thumbnail: json.thumbnail, + 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, + }; + return EvmErc20Metadata.create(input); + } + + /** + * @description The address of the token contract + */ + public readonly address: string; + /** + * @description The label of the address + */ + public readonly addressLabel?: string; + /** + * @description The name of the token contract + */ + public readonly name: string; + /** + * @description The symbol of the NFT contract + */ + public readonly symbol: string; + /** + * @description The number of decimals on the token + */ + public readonly decimals: number; + /** + * @description The logo of the token + */ + public readonly logo?: string; + /** + * @description The logo hash + */ + public readonly logoHash?: string; + /** + * @description The thumbnail of the logo + */ + public readonly thumbnail?: string; + public readonly blockNumber?: BigNumber; + public readonly validated?: number; + /** + * @description The timestamp of when the erc20 token was created + */ + public readonly createdAt: string; + /** + * @description Indicates if a contract is possibly a spam contract + */ + public readonly possibleSpam: boolean; + /** + * @description Indicates if a contract is verified + */ + public readonly verifiedContract?: boolean; + + private constructor(input: EvmErc20MetadataInput) { + this.address = input.address; + this.addressLabel = input.addressLabel; + this.name = input.name; + this.symbol = input.symbol; + this.decimals = input.decimals; + this.logo = input.logo; + this.logoHash = input.logoHash; + this.thumbnail = input.thumbnail; + 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; + } + + public toJSON(): EvmErc20MetadataJSON { + return { + address: this.address, + address_label: this.addressLabel, + name: this.name, + symbol: this.symbol, + decimals: String(this.decimals), + logo: this.logo, + logo_hash: this.logoHash, + thumbnail: this.thumbnail, + block_number: this.blockNumber ? this.blockNumber.toJSON() : undefined, + validated: this.validated, + created_at: this.createdAt, + possible_spam: this.possibleSpam, + verified_contract: this.verifiedContract, + } + } +} diff --git a/packages/common/evmUtils/src/generated/types/EvmErc20TokenBalanceWithPrice.ts b/packages/common/evmUtils/src/generated/types/EvmErc20TokenBalanceWithPrice.ts new file mode 100644 index 0000000000..e72daf05fb --- /dev/null +++ b/packages/common/evmUtils/src/generated/types/EvmErc20TokenBalanceWithPrice.ts @@ -0,0 +1,205 @@ +import { EvmAddress, EvmAddressInput, EvmAddressJSON, EvmNative, EvmNativeInput, EvmNativeJSON } from '../../dataTypes'; + +// $ref: #/components/schemas/erc20TokenBalanceWithPrice +// type: erc20TokenBalanceWithPrice +// properties: +// - token_address ($ref: #/components/schemas/erc20TokenBalanceWithPrice/properties/token_address) +// - name ($ref: #/components/schemas/erc20TokenBalanceWithPrice/properties/name) +// - symbol ($ref: #/components/schemas/erc20TokenBalanceWithPrice/properties/symbol) +// - logo ($ref: #/components/schemas/erc20TokenBalanceWithPrice/properties/logo) +// - thumbnail ($ref: #/components/schemas/erc20TokenBalanceWithPrice/properties/thumbnail) +// - decimals ($ref: #/components/schemas/erc20TokenBalanceWithPrice/properties/decimals) +// - balance ($ref: #/components/schemas/erc20TokenBalanceWithPrice/properties/balance) +// - possible_spam ($ref: #/components/schemas/erc20TokenBalanceWithPrice/properties/possible_spam) +// - verified_contract ($ref: #/components/schemas/erc20TokenBalanceWithPrice/properties/verified_contract) +// - usd_price ($ref: #/components/schemas/erc20TokenBalanceWithPrice/properties/usd_price) +// - usd_price_24hr_percent_change ($ref: #/components/schemas/erc20TokenBalanceWithPrice/properties/usd_price_24hr_percent_change) +// - usd_price_24hr_usd_change ($ref: #/components/schemas/erc20TokenBalanceWithPrice/properties/usd_price_24hr_usd_change) +// - usd_value_24hr_usd_change ($ref: #/components/schemas/erc20TokenBalanceWithPrice/properties/usd_value_24hr_usd_change) +// - usd_value ($ref: #/components/schemas/erc20TokenBalanceWithPrice/properties/usd_value) +// - portfolio_percentage ($ref: #/components/schemas/erc20TokenBalanceWithPrice/properties/portfolio_percentage) +// - balance_formatted ($ref: #/components/schemas/erc20TokenBalanceWithPrice/properties/balance_formatted) +// - native_token ($ref: #/components/schemas/erc20TokenBalanceWithPrice/properties/native_token) + +export interface EvmErc20TokenBalanceWithPriceJSON { + readonly token_address?: EvmAddressJSON; + readonly name: string; + readonly symbol: string; + readonly logo?: string; + readonly thumbnail?: string; + readonly decimals: number; + readonly balance: EvmNativeJSON; + readonly possible_spam: boolean; + readonly verified_contract?: boolean; + readonly usd_price: string; + readonly usd_price_24hr_percent_change: string; + readonly usd_price_24hr_usd_change: string; + readonly usd_value_24hr_usd_change?: string; + readonly usd_value: number; + readonly portfolio_percentage: number; + readonly balance_formatted: string; + readonly native_token: boolean; +} + +export interface EvmErc20TokenBalanceWithPriceInput { + readonly tokenAddress?: EvmAddressInput | EvmAddress; + readonly name: string; + readonly symbol: string; + readonly logo?: string; + readonly thumbnail?: string; + readonly decimals: number; + readonly balance: EvmNativeInput | EvmNative; + readonly possibleSpam: boolean; + readonly verifiedContract?: boolean; + readonly usdPrice: string; + readonly usdPrice24hrPercentChange: string; + readonly usdPrice24hrUsdChange: string; + readonly usdValue24hrUsdChange?: string; + readonly usdValue: number; + readonly portfolioPercentage: number; + readonly balanceFormatted: string; + readonly nativeToken: boolean; +} + +export class EvmErc20TokenBalanceWithPrice { + public static create(input: EvmErc20TokenBalanceWithPriceInput | EvmErc20TokenBalanceWithPrice): EvmErc20TokenBalanceWithPrice { + if (input instanceof EvmErc20TokenBalanceWithPrice) { + return input; + } + return new EvmErc20TokenBalanceWithPrice(input); + } + + public static fromJSON(json: EvmErc20TokenBalanceWithPriceJSON): EvmErc20TokenBalanceWithPrice { + const input: EvmErc20TokenBalanceWithPriceInput = { + tokenAddress: json.token_address ? EvmAddress.fromJSON(json.token_address) : undefined, + name: json.name, + symbol: json.symbol, + logo: json.logo, + thumbnail: json.thumbnail, + decimals: json.decimals, + balance: EvmNative.fromJSON(json.balance), + possibleSpam: json.possible_spam, + verifiedContract: json.verified_contract, + usdPrice: json.usd_price, + usdPrice24hrPercentChange: json.usd_price_24hr_percent_change, + usdPrice24hrUsdChange: json.usd_price_24hr_usd_change, + usdValue24hrUsdChange: json.usd_value_24hr_usd_change, + usdValue: json.usd_value, + portfolioPercentage: json.portfolio_percentage, + balanceFormatted: json.balance_formatted, + nativeToken: json.native_token, + }; + return EvmErc20TokenBalanceWithPrice.create(input); + } + + /** + * @description The address of the token contract + */ + public readonly tokenAddress?: EvmAddress; + /** + * @description The name of the token + */ + public readonly name: string; + /** + * @description The symbol of the token + */ + public readonly symbol: string; + /** + * @description The logo of the token + */ + public readonly logo?: string; + /** + * @description The thumbnail of the token logo + */ + public readonly thumbnail?: string; + /** + * @description The number of decimals on the token + */ + public readonly decimals: number; + /** + * @description The balance of the token + */ + public readonly balance: EvmNative; + /** + * @description Indicates if a contract is possibly a spam contract + */ + public readonly possibleSpam: boolean; + /** + * @description Indicates if a contract is verified + */ + public readonly verifiedContract?: boolean; + /** + * @description USD price of the token + */ + public readonly usdPrice: string; + /** + * @description 24-hour percent change in USD price of the token + */ + public readonly usdPrice24hrPercentChange: string; + /** + * @description 24-hour change in USD price of the token + */ + public readonly usdPrice24hrUsdChange: string; + /** + * @description 24-hour change in USD value of the token based on the balance + */ + public readonly usdValue24hrUsdChange?: string; + /** + * @description USD value of the token balance + */ + public readonly usdValue: number; + /** + * @description Percentage of the token in the entire portfolio + */ + public readonly portfolioPercentage: number; + /** + * @description Balance of the token in decimal format + */ + public readonly balanceFormatted: string; + /** + * @description Indicates if the token is a native coin + */ + public readonly nativeToken: boolean; + + private constructor(input: EvmErc20TokenBalanceWithPriceInput) { + this.tokenAddress = input.tokenAddress ? EvmAddress.create(input.tokenAddress) : undefined; + this.name = input.name; + this.symbol = input.symbol; + this.logo = input.logo; + this.thumbnail = input.thumbnail; + this.decimals = input.decimals; + this.balance = EvmNative.create(input.balance); + this.possibleSpam = input.possibleSpam; + this.verifiedContract = input.verifiedContract; + this.usdPrice = input.usdPrice; + this.usdPrice24hrPercentChange = input.usdPrice24hrPercentChange; + this.usdPrice24hrUsdChange = input.usdPrice24hrUsdChange; + this.usdValue24hrUsdChange = input.usdValue24hrUsdChange; + this.usdValue = input.usdValue; + this.portfolioPercentage = input.portfolioPercentage; + this.balanceFormatted = input.balanceFormatted; + this.nativeToken = input.nativeToken; + } + + public toJSON(): EvmErc20TokenBalanceWithPriceJSON { + return { + token_address: this.tokenAddress ? this.tokenAddress.toJSON() : undefined, + name: this.name, + symbol: this.symbol, + logo: this.logo, + thumbnail: this.thumbnail, + decimals: this.decimals, + balance: this.balance.toJSON(), + possible_spam: this.possibleSpam, + verified_contract: this.verifiedContract, + usd_price: this.usdPrice, + usd_price_24hr_percent_change: this.usdPrice24hrPercentChange, + usd_price_24hr_usd_change: this.usdPrice24hrUsdChange, + usd_value_24hr_usd_change: this.usdValue24hrUsdChange, + usd_value: this.usdValue, + portfolio_percentage: this.portfolioPercentage, + balance_formatted: this.balanceFormatted, + native_token: this.nativeToken, + } + } +} diff --git a/packages/common/evmUtils/src/generated/types/EvmErc20TokenBalanceWithPriceResult.ts b/packages/common/evmUtils/src/generated/types/EvmErc20TokenBalanceWithPriceResult.ts new file mode 100644 index 0000000000..1224b565cc --- /dev/null +++ b/packages/common/evmUtils/src/generated/types/EvmErc20TokenBalanceWithPriceResult.ts @@ -0,0 +1,72 @@ +import { EvmErc20TokenBalanceWithPrice, EvmErc20TokenBalanceWithPriceInput, EvmErc20TokenBalanceWithPriceJSON } from '../types/EvmErc20TokenBalanceWithPrice'; + +// $ref: #/components/schemas/erc20TokenBalanceWithPriceResult +// type: erc20TokenBalanceWithPriceResult +// properties: +// - page ($ref: #/components/schemas/erc20TokenBalanceWithPriceResult/properties/page) +// - page_size ($ref: #/components/schemas/erc20TokenBalanceWithPriceResult/properties/page_size) +// - cursor ($ref: #/components/schemas/erc20TokenBalanceWithPriceResult/properties/cursor) +// - result ($ref: #/components/schemas/erc20TokenBalanceWithPrice) + +export interface EvmErc20TokenBalanceWithPriceResultJSON { + readonly page?: number; + readonly page_size?: number; + readonly cursor?: string; + readonly result: EvmErc20TokenBalanceWithPriceJSON[]; +} + +export interface EvmErc20TokenBalanceWithPriceResultInput { + readonly page?: number; + readonly pageSize?: number; + readonly cursor?: string; + readonly result: EvmErc20TokenBalanceWithPriceInput[] | EvmErc20TokenBalanceWithPrice[]; +} + +export class EvmErc20TokenBalanceWithPriceResult { + public static create(input: EvmErc20TokenBalanceWithPriceResultInput | EvmErc20TokenBalanceWithPriceResult): EvmErc20TokenBalanceWithPriceResult { + if (input instanceof EvmErc20TokenBalanceWithPriceResult) { + return input; + } + return new EvmErc20TokenBalanceWithPriceResult(input); + } + + public static fromJSON(json: EvmErc20TokenBalanceWithPriceResultJSON): EvmErc20TokenBalanceWithPriceResult { + const input: EvmErc20TokenBalanceWithPriceResultInput = { + page: json.page, + pageSize: json.page_size, + cursor: json.cursor, + result: json.result.map((item) => EvmErc20TokenBalanceWithPrice.fromJSON(item)), + }; + return EvmErc20TokenBalanceWithPriceResult.create(input); + } + + /** + * @description The current page of the result + */ + public readonly page?: number; + /** + * @description The number of results per page + */ + public readonly pageSize?: number; + /** + * @description The cursor to get to the next page + */ + public readonly cursor?: string; + public readonly result: EvmErc20TokenBalanceWithPrice[]; + + private constructor(input: EvmErc20TokenBalanceWithPriceResultInput) { + this.page = input.page; + this.pageSize = input.pageSize; + this.cursor = input.cursor; + this.result = input.result.map((item) => EvmErc20TokenBalanceWithPrice.create(item)); + } + + public toJSON(): EvmErc20TokenBalanceWithPriceResultJSON { + return { + page: this.page, + page_size: this.pageSize, + cursor: this.cursor, + result: this.result.map((item) => item.toJSON()), + } + } +} diff --git a/packages/common/evmUtils/src/generated/types/EvmGetPairPrice.ts b/packages/common/evmUtils/src/generated/types/EvmGetPairPrice.ts new file mode 100644 index 0000000000..f7a967d16c --- /dev/null +++ b/packages/common/evmUtils/src/generated/types/EvmGetPairPrice.ts @@ -0,0 +1,84 @@ +import { EvmErc20Metadata, EvmErc20MetadataInput, EvmErc20MetadataJSON } from '../types/EvmErc20Metadata'; + +// $ref: #/paths/~1{token0_address}~1{token1_address}~1price/get/responses/200/content/application~1json/schema +// type: getPairPrice +// properties: +// - pair_address ($ref: #/paths/~1{token0_address}~1{token1_address}~1price/get/responses/200/content/application~1json/schema/properties/pair_address) +// - pair_label ($ref: #/paths/~1{token0_address}~1{token1_address}~1price/get/responses/200/content/application~1json/schema/properties/pair_label) +// - exchange ($ref: #/paths/~1{token0_address}~1{token1_address}~1price/get/responses/200/content/application~1json/schema/properties/exchange) +// - quote_price ($ref: #/paths/~1{token0_address}~1{token1_address}~1price/get/responses/200/content/application~1json/schema/properties/quote_price) +// - price_usd ($ref: #/paths/~1{token0_address}~1{token1_address}~1price/get/responses/200/content/application~1json/schema/properties/price_usd) +// - base_token ($ref: #/components/schemas/erc20Metadata) +// - quote_token ($ref: #/components/schemas/erc20Metadata) + +export interface EvmGetPairPriceJSON { + readonly pair_address?: string; + readonly pair_label?: string; + readonly exchange?: string; + readonly quote_price?: string; + readonly price_usd?: string; + readonly base_token?: EvmErc20MetadataJSON; + readonly quote_token?: EvmErc20MetadataJSON; +} + +export interface EvmGetPairPriceInput { + readonly pairAddress?: string; + readonly pairLabel?: string; + readonly exchange?: string; + readonly quotePrice?: string; + readonly priceUsd?: string; + readonly baseToken?: EvmErc20MetadataInput | EvmErc20Metadata; + readonly quoteToken?: EvmErc20MetadataInput | EvmErc20Metadata; +} + +export class EvmGetPairPrice { + public static create(input: EvmGetPairPriceInput | EvmGetPairPrice): EvmGetPairPrice { + if (input instanceof EvmGetPairPrice) { + return input; + } + return new EvmGetPairPrice(input); + } + + public static fromJSON(json: EvmGetPairPriceJSON): EvmGetPairPrice { + const input: EvmGetPairPriceInput = { + pairAddress: json.pair_address, + pairLabel: json.pair_label, + exchange: json.exchange, + quotePrice: json.quote_price, + priceUsd: json.price_usd, + baseToken: json.base_token ? EvmErc20Metadata.fromJSON(json.base_token) : undefined, + quoteToken: json.quote_token ? EvmErc20Metadata.fromJSON(json.quote_token) : undefined, + }; + return EvmGetPairPrice.create(input); + } + + public readonly pairAddress?: string; + public readonly pairLabel?: string; + public readonly exchange?: string; + public readonly quotePrice?: string; + public readonly priceUsd?: string; + public readonly baseToken?: EvmErc20Metadata; + public readonly quoteToken?: EvmErc20Metadata; + + private constructor(input: EvmGetPairPriceInput) { + this.pairAddress = input.pairAddress; + this.pairLabel = input.pairLabel; + this.exchange = input.exchange; + this.quotePrice = input.quotePrice; + this.priceUsd = input.priceUsd; + this.baseToken = input.baseToken ? EvmErc20Metadata.create(input.baseToken) : undefined; + this.quoteToken = input.quoteToken ? EvmErc20Metadata.create(input.quoteToken) : undefined; + } + + public toJSON(): EvmGetPairPriceJSON { + return { + pair_address: this.pairAddress, + pair_label: this.pairLabel, + exchange: this.exchange, + quote_price: this.quotePrice, + price_usd: this.priceUsd, + base_token: this.baseToken ? this.baseToken.toJSON() : undefined, + quote_token: this.quoteToken ? this.quoteToken.toJSON() : undefined, + } + } +} diff --git a/packages/common/evmUtils/src/generated/types/EvmNetWorthResult.ts b/packages/common/evmUtils/src/generated/types/EvmNetWorthResult.ts new file mode 100644 index 0000000000..f784a53d8c --- /dev/null +++ b/packages/common/evmUtils/src/generated/types/EvmNetWorthResult.ts @@ -0,0 +1,52 @@ +import { EvmChainNetWorth, EvmChainNetWorthInput, EvmChainNetWorthJSON } from '../types/EvmChainNetWorth'; + +// $ref: #/components/schemas/netWorthResult +// type: netWorthResult +// properties: +// - total_networth_usd ($ref: #/components/schemas/netWorthResult/properties/total_networth_usd) +// - chains ($ref: #/components/schemas/chainNetWorth) + +export interface EvmNetWorthResultJSON { + readonly total_networth_usd: string; + readonly chains: EvmChainNetWorthJSON[]; +} + +export interface EvmNetWorthResultInput { + readonly totalNetworthUsd: string; + readonly chains: EvmChainNetWorthInput[] | EvmChainNetWorth[]; +} + +export class EvmNetWorthResult { + public static create(input: EvmNetWorthResultInput | EvmNetWorthResult): EvmNetWorthResult { + if (input instanceof EvmNetWorthResult) { + return input; + } + return new EvmNetWorthResult(input); + } + + public static fromJSON(json: EvmNetWorthResultJSON): EvmNetWorthResult { + const input: EvmNetWorthResultInput = { + totalNetworthUsd: json.total_networth_usd, + chains: json.chains.map((item) => EvmChainNetWorth.fromJSON(item)), + }; + return EvmNetWorthResult.create(input); + } + + /** + * @description The total networth in USD + */ + public readonly totalNetworthUsd: string; + public readonly chains: EvmChainNetWorth[]; + + private constructor(input: EvmNetWorthResultInput) { + this.totalNetworthUsd = input.totalNetworthUsd; + this.chains = input.chains.map((item) => EvmChainNetWorth.create(item)); + } + + public toJSON(): EvmNetWorthResultJSON { + return { + total_networth_usd: this.totalNetworthUsd, + chains: this.chains.map((item) => item.toJSON()), + } + } +} diff --git a/packages/common/evmUtils/src/generated/types/EvmResolveAddressToDomainCurrencyEnum.ts b/packages/common/evmUtils/src/generated/types/EvmResolveAddressToDomainCurrencyEnum.ts new file mode 100644 index 0000000000..7d1c178a29 --- /dev/null +++ b/packages/common/evmUtils/src/generated/types/EvmResolveAddressToDomainCurrencyEnum.ts @@ -0,0 +1,16 @@ +// $ref: #/paths/~1resolve~1{address}~1domain/get/parameters/0/schema +// typeName: resolveAddressToDomain_currency_Enum + +export type EvmResolveAddressToDomainCurrencyEnumJSON = "eth" | "0x1"; +export type EvmResolveAddressToDomainCurrencyEnumInput = "eth" | "0x1"; +export type EvmResolveAddressToDomainCurrencyEnumValue = "eth" | "0x1"; + +export abstract class EvmResolveAddressToDomainCurrencyEnum { + public static create(input: EvmResolveAddressToDomainCurrencyEnumInput | EvmResolveAddressToDomainCurrencyEnumValue): EvmResolveAddressToDomainCurrencyEnumValue { + return input; + } + + public static fromJSON(json: EvmResolveAddressToDomainCurrencyEnumJSON): EvmResolveAddressToDomainCurrencyEnumValue { + return json; + } +} diff --git a/packages/common/evmUtils/src/generated/types/EvmUnstoppableDomain.ts b/packages/common/evmUtils/src/generated/types/EvmUnstoppableDomain.ts new file mode 100644 index 0000000000..89f90c660f --- /dev/null +++ b/packages/common/evmUtils/src/generated/types/EvmUnstoppableDomain.ts @@ -0,0 +1,43 @@ +// $ref: #/components/schemas/unstoppableDomain +// type: unstoppableDomain +// properties: +// - name ($ref: #/components/schemas/unstoppableDomain/properties/name) + +export interface EvmUnstoppableDomainJSON { + readonly name: string; +} + +export interface EvmUnstoppableDomainInput { + readonly name: string; +} + +export class EvmUnstoppableDomain { + public static create(input: EvmUnstoppableDomainInput | EvmUnstoppableDomain): EvmUnstoppableDomain { + if (input instanceof EvmUnstoppableDomain) { + return input; + } + return new EvmUnstoppableDomain(input); + } + + public static fromJSON(json: EvmUnstoppableDomainJSON): EvmUnstoppableDomain { + const input: EvmUnstoppableDomainInput = { + name: json.name, + }; + return EvmUnstoppableDomain.create(input); + } + + /** + * @description Resolved unstoppable domain address + */ + public readonly name: string; + + private constructor(input: EvmUnstoppableDomainInput) { + this.name = input.name; + } + + public toJSON(): EvmUnstoppableDomainJSON { + return { + name: this.name, + } + } +} diff --git a/packages/common/evmUtils/src/generated/types/index.ts b/packages/common/evmUtils/src/generated/types/index.ts index c7983879f9..212a45c24d 100644 --- a/packages/common/evmUtils/src/generated/types/index.ts +++ b/packages/common/evmUtils/src/generated/types/index.ts @@ -1,13 +1,18 @@ export * from './EvmChainList'; export * from './EvmGetNFTTradesMarketplaceEnum'; export * from './EvmGetMultipleTokenPricesIncludeEnum'; +export * from './EvmResolveAddressToDomainCurrencyEnum'; export * from './EvmContractsReviewItemReportTypeEnum'; export * from './EvmContractsReviewItemContractTypeEnum'; export * from './EvmTradeCollection'; export * from './EvmErc20Price'; export * from './EvmGetMultipleTokenPricesDto'; +export * from './EvmErc20TokenBalanceWithPriceResult'; +export * from './EvmNetWorthResult'; export * from './EvmWeb3version'; export * from './EvmEndpointWeights'; +export * from './EvmUnstoppableDomain'; +export * from './EvmGetPairPrice'; export * from './EvmMarketDataERC20TokenItem'; export * from './EvmMarketDataERC20TokensByPriceMovers'; export * from './EvmMarketDataTopNFTCollectionByMarketCapItem'; @@ -23,6 +28,9 @@ export * from './EvmBlockTokenStat'; export * from './EvmTrade'; export * from './EvmNativeErc20Price'; export * from './EvmTokenPriceItem'; +export * from './EvmErc20TokenBalanceWithPrice'; +export * from './EvmChainNetWorth'; +export * from './EvmErc20Metadata'; export * from './EvmContractsReviewItem'; export * from './EvmWalletActiveChain'; export * from './EvmWalletStatTransactions'; diff --git a/packages/common/evmUtils/src/operations/openapi.ts b/packages/common/evmUtils/src/operations/openapi.ts index 35a4bef909..2a71a1146c 100644 --- a/packages/common/evmUtils/src/operations/openapi.ts +++ b/packages/common/evmUtils/src/operations/openapi.ts @@ -4111,7 +4111,7 @@ export interface operations { /** Returns token balances with prices for a specific address */ 200: { content: { - "application/json": components["schemas"]["erc20TokenBalanceWithPriceResult"][]; + "application/json": components["schemas"]["erc20TokenBalanceWithPriceResult"]; }; }; }; diff --git a/packages/evmApi/src/generated/ClientEvmApi.ts b/packages/evmApi/src/generated/ClientEvmApi.ts index 30d6c25ac9..014196d3f2 100644 --- a/packages/evmApi/src/generated/ClientEvmApi.ts +++ b/packages/evmApi/src/generated/ClientEvmApi.ts @@ -1,6 +1,6 @@ // CAUTION: This file is automatically generated. Do not edit it manually! -import { getBlockOperation, GetBlockRequest, GetBlockResponseAdapter, getDateToBlockOperation, GetDateToBlockRequest, GetDateToBlockResponseAdapter, GetBlockStatsOperationResponseJSON, GetBlockStatsOperation, GetBlockStatsOperationRequest, GetBlockStatsOperationResponse, getContractEventsOperation, GetContractEventsRequest, GetContractEventsResponseAdapter, getContractLogsOperation, GetContractLogsRequest, GetContractLogsResponseAdapter, getContractNFTsOperation, GetContractNFTsRequest, GetContractNFTsResponseAdapter, getMultipleNFTsOperation, GetMultipleNFTsRequest, GetMultipleNFTsResponseAdapter, getNFTContractMetadataOperation, GetNFTContractMetadataRequest, GetNFTContractMetadataResponseAdapter, getNFTContractTransfersOperation, GetNFTContractTransfersRequest, GetNFTContractTransfersResponseAdapter, getNFTLowestPriceOperation, GetNFTLowestPriceRequest, GetNFTLowestPriceResponseAdapter, getNFTMetadataOperation, GetNFTMetadataRequest, GetNFTMetadataResponseAdapter, getNFTOwnersOperation, GetNFTOwnersRequest, GetNFTOwnersResponseAdapter, getNFTTokenIdOwnersOperation, GetNFTTokenIdOwnersRequest, GetNFTTokenIdOwnersResponseAdapter, getNFTTransfersByBlockOperation, GetNFTTransfersByBlockRequest, GetNFTTransfersByBlockResponseAdapter, getNFTTransfersFromToBlockOperation, GetNFTTransfersFromToBlockRequest, GetNFTTransfersFromToBlockResponseAdapter, getNFTTransfersOperation, GetNFTTransfersRequest, GetNFTTransfersResponseAdapter, getWalletNFTCollectionsOperation, GetWalletNFTCollectionsRequest, GetWalletNFTCollectionsResponseAdapter, getWalletNFTsOperation, GetWalletNFTsRequest, GetWalletNFTsResponseAdapter, getWalletNFTTransfersOperation, GetWalletNFTTransfersRequest, GetWalletNFTTransfersResponseAdapter, reSyncMetadataOperation, ReSyncMetadataRequest, ReSyncMetadataResponseAdapter, syncNFTContractOperation, SyncNFTContractRequest, SyncNFTContractResponseAdapter, GetNFTTradesOperationResponseJSON, GetNFTTradesOperation, GetNFTTradesOperationRequest, GetNFTTradesOperationResponse, GetNFTCollectionStatsOperationResponseJSON, GetNFTCollectionStatsOperation, GetNFTCollectionStatsOperationRequest, GetNFTCollectionStatsOperationResponse, GetNFTTokenStatsOperationResponseJSON, GetNFTTokenStatsOperation, GetNFTTokenStatsOperationRequest, GetNFTTokenStatsOperationResponse, getInternalTransactionsOperation, GetInternalTransactionsRequest, GetInternalTransactionsResponseAdapter, getTransactionOperation, GetTransactionRequest, GetTransactionResponseAdapter, getTransactionVerboseOperation, GetTransactionVerboseRequest, GetTransactionVerboseResponseAdapter, getWalletTransactionsOperation, GetWalletTransactionsRequest, GetWalletTransactionsResponseAdapter, getWalletTransactionsVerboseOperation, GetWalletTransactionsVerboseRequest, GetWalletTransactionsVerboseResponseAdapter, getNativeBalanceOperation, GetNativeBalanceRequest, GetNativeBalanceResponseAdapter, getNativeBalancesForAddressesOperation, GetNativeBalancesForAddressesRequest, GetNativeBalancesForAddressesResponseAdapter, getPairAddressOperation, GetPairAddressRequest, GetPairAddressResponseAdapter, getPairReservesOperation, GetPairReservesRequest, GetPairReservesResponseAdapter, getTokenAllowanceOperation, GetTokenAllowanceRequest, GetTokenAllowanceResponseAdapter, getTokenMetadataBySymbolOperation, GetTokenMetadataBySymbolRequest, GetTokenMetadataBySymbolResponseAdapter, getTokenMetadataOperation, GetTokenMetadataRequest, GetTokenMetadataResponseAdapter, getTokenPriceOperation, GetTokenPriceRequest, GetTokenPriceResponseAdapter, getTokenTransfersOperation, GetTokenTransfersRequest, GetTokenTransfersResponseAdapter, getWalletTokenBalancesOperation, GetWalletTokenBalancesRequest, GetWalletTokenBalancesResponseAdapter, getWalletTokenTransfersOperation, GetWalletTokenTransfersRequest, GetWalletTokenTransfersResponseAdapter, GetMultipleTokenPricesOperationResponseJSON, GetMultipleTokenPricesOperation, GetMultipleTokenPricesOperationRequest, GetMultipleTokenPricesOperationBody, GetMultipleTokenPricesOperationResponse, GetTokenStatsOperationResponseJSON, GetTokenStatsOperation, GetTokenStatsOperationRequest, GetTokenStatsOperationResponse, resolveAddressOperation, ResolveAddressRequest, ResolveAddressResponseAdapter, resolveDomainOperation, ResolveDomainRequest, ResolveDomainResponseAdapter, resolveENSDomainOperation, ResolveENSDomainRequest, ResolveENSDomainResponseAdapter, runContractFunctionOperation, RunContractFunctionRequest, RunContractFunctionResponseAdapter, Web3ApiVersionOperationResponseJSON, Web3ApiVersionOperation, Web3ApiVersionOperationResponse, EndpointWeightsOperationResponseJSON, EndpointWeightsOperation, EndpointWeightsOperationResponse, ReviewContractsOperationResponseJSON, ReviewContractsOperation, ReviewContractsOperationRequest, ReviewContractsOperationBody, ReviewContractsOperationResponse, uploadFolderOperation, UploadFolderRequest, UploadFolderResponseAdapter, GetTopERC20TokensByMarketCapOperationResponseJSON, GetTopERC20TokensByMarketCapOperation, GetTopERC20TokensByMarketCapOperationResponse, GetTopERC20TokensByPriceMoversOperationResponseJSON, GetTopERC20TokensByPriceMoversOperation, GetTopERC20TokensByPriceMoversOperationResponse, GetTopNFTCollectionsByMarketCapOperationResponseJSON, GetTopNFTCollectionsByMarketCapOperation, GetTopNFTCollectionsByMarketCapOperationResponse, GetHottestNFTCollectionsByTradingVolumeOperationResponseJSON, GetHottestNFTCollectionsByTradingVolumeOperation, GetHottestNFTCollectionsByTradingVolumeOperationResponse, GetWalletActiveChainsOperationResponseJSON, GetWalletActiveChainsOperation, GetWalletActiveChainsOperationRequest, GetWalletActiveChainsOperationResponse, GetWalletStatsOperationResponseJSON, GetWalletStatsOperation, GetWalletStatsOperationRequest, GetWalletStatsOperationResponse } from '@moralisweb3/common-evm-utils'; +import { getBlockOperation, GetBlockRequest, GetBlockResponseAdapter, getDateToBlockOperation, GetDateToBlockRequest, GetDateToBlockResponseAdapter, GetBlockStatsOperationResponseJSON, GetBlockStatsOperation, GetBlockStatsOperationRequest, GetBlockStatsOperationResponse, getContractEventsOperation, GetContractEventsRequest, GetContractEventsResponseAdapter, getContractLogsOperation, GetContractLogsRequest, GetContractLogsResponseAdapter, getContractNFTsOperation, GetContractNFTsRequest, GetContractNFTsResponseAdapter, getMultipleNFTsOperation, GetMultipleNFTsRequest, GetMultipleNFTsResponseAdapter, getNFTContractMetadataOperation, GetNFTContractMetadataRequest, GetNFTContractMetadataResponseAdapter, getNFTContractTransfersOperation, GetNFTContractTransfersRequest, GetNFTContractTransfersResponseAdapter, getNFTLowestPriceOperation, GetNFTLowestPriceRequest, GetNFTLowestPriceResponseAdapter, getNFTMetadataOperation, GetNFTMetadataRequest, GetNFTMetadataResponseAdapter, getNFTOwnersOperation, GetNFTOwnersRequest, GetNFTOwnersResponseAdapter, getNFTTokenIdOwnersOperation, GetNFTTokenIdOwnersRequest, GetNFTTokenIdOwnersResponseAdapter, getNFTTransfersByBlockOperation, GetNFTTransfersByBlockRequest, GetNFTTransfersByBlockResponseAdapter, getNFTTransfersFromToBlockOperation, GetNFTTransfersFromToBlockRequest, GetNFTTransfersFromToBlockResponseAdapter, getNFTTransfersOperation, GetNFTTransfersRequest, GetNFTTransfersResponseAdapter, getWalletNFTCollectionsOperation, GetWalletNFTCollectionsRequest, GetWalletNFTCollectionsResponseAdapter, getWalletNFTsOperation, GetWalletNFTsRequest, GetWalletNFTsResponseAdapter, getWalletNFTTransfersOperation, GetWalletNFTTransfersRequest, GetWalletNFTTransfersResponseAdapter, reSyncMetadataOperation, ReSyncMetadataRequest, ReSyncMetadataResponseAdapter, syncNFTContractOperation, SyncNFTContractRequest, SyncNFTContractResponseAdapter, GetNFTTradesOperationResponseJSON, GetNFTTradesOperation, GetNFTTradesOperationRequest, GetNFTTradesOperationResponse, GetNFTCollectionStatsOperationResponseJSON, GetNFTCollectionStatsOperation, GetNFTCollectionStatsOperationRequest, GetNFTCollectionStatsOperationResponse, GetNFTTokenStatsOperationResponseJSON, GetNFTTokenStatsOperation, GetNFTTokenStatsOperationRequest, GetNFTTokenStatsOperationResponse, getInternalTransactionsOperation, GetInternalTransactionsRequest, GetInternalTransactionsResponseAdapter, getTransactionOperation, GetTransactionRequest, GetTransactionResponseAdapter, getTransactionVerboseOperation, GetTransactionVerboseRequest, GetTransactionVerboseResponseAdapter, getWalletTransactionsOperation, GetWalletTransactionsRequest, GetWalletTransactionsResponseAdapter, getWalletTransactionsVerboseOperation, GetWalletTransactionsVerboseRequest, GetWalletTransactionsVerboseResponseAdapter, getNativeBalanceOperation, GetNativeBalanceRequest, GetNativeBalanceResponseAdapter, getNativeBalancesForAddressesOperation, GetNativeBalancesForAddressesRequest, GetNativeBalancesForAddressesResponseAdapter, getPairAddressOperation, GetPairAddressRequest, GetPairAddressResponseAdapter, getPairReservesOperation, GetPairReservesRequest, GetPairReservesResponseAdapter, GetPairPriceOperationResponseJSON, GetPairPriceOperation, GetPairPriceOperationRequest, GetPairPriceOperationResponse, getTokenAllowanceOperation, GetTokenAllowanceRequest, GetTokenAllowanceResponseAdapter, getTokenMetadataBySymbolOperation, GetTokenMetadataBySymbolRequest, GetTokenMetadataBySymbolResponseAdapter, getTokenMetadataOperation, GetTokenMetadataRequest, GetTokenMetadataResponseAdapter, getTokenPriceOperation, GetTokenPriceRequest, GetTokenPriceResponseAdapter, getTokenTransfersOperation, GetTokenTransfersRequest, GetTokenTransfersResponseAdapter, getWalletTokenBalancesOperation, GetWalletTokenBalancesRequest, GetWalletTokenBalancesResponseAdapter, getWalletTokenTransfersOperation, GetWalletTokenTransfersRequest, GetWalletTokenTransfersResponseAdapter, GetMultipleTokenPricesOperationResponseJSON, GetMultipleTokenPricesOperation, GetMultipleTokenPricesOperationRequest, GetMultipleTokenPricesOperationBody, GetMultipleTokenPricesOperationResponse, GetTokenStatsOperationResponseJSON, GetTokenStatsOperation, GetTokenStatsOperationRequest, GetTokenStatsOperationResponse, resolveAddressOperation, ResolveAddressRequest, ResolveAddressResponseAdapter, resolveDomainOperation, ResolveDomainRequest, ResolveDomainResponseAdapter, resolveENSDomainOperation, ResolveENSDomainRequest, ResolveENSDomainResponseAdapter, ResolveAddressToDomainOperationResponseJSON, ResolveAddressToDomainOperation, ResolveAddressToDomainOperationRequest, ResolveAddressToDomainOperationResponse, runContractFunctionOperation, RunContractFunctionRequest, RunContractFunctionResponseAdapter, Web3ApiVersionOperationResponseJSON, Web3ApiVersionOperation, Web3ApiVersionOperationResponse, EndpointWeightsOperationResponseJSON, EndpointWeightsOperation, EndpointWeightsOperationResponse, ReviewContractsOperationResponseJSON, ReviewContractsOperation, ReviewContractsOperationRequest, ReviewContractsOperationBody, ReviewContractsOperationResponse, uploadFolderOperation, UploadFolderRequest, UploadFolderResponseAdapter, GetWalletTokenBalancesPriceOperationResponseJSON, GetWalletTokenBalancesPriceOperation, GetWalletTokenBalancesPriceOperationRequest, GetWalletTokenBalancesPriceOperationResponse, GetWalletNetWorthOperationResponseJSON, GetWalletNetWorthOperation, GetWalletNetWorthOperationRequest, GetWalletNetWorthOperationResponse, GetWalletActiveChainsOperationResponseJSON, GetWalletActiveChainsOperation, GetWalletActiveChainsOperationRequest, GetWalletActiveChainsOperationResponse, GetWalletStatsOperationResponseJSON, GetWalletStatsOperation, GetWalletStatsOperationRequest, GetWalletStatsOperationResponse, GetTopERC20TokensByMarketCapOperationResponseJSON, GetTopERC20TokensByMarketCapOperation, GetTopERC20TokensByMarketCapOperationResponse, GetTopERC20TokensByPriceMoversOperationResponseJSON, GetTopERC20TokensByPriceMoversOperation, GetTopERC20TokensByPriceMoversOperationResponse, GetTopNFTCollectionsByMarketCapOperationResponseJSON, GetTopNFTCollectionsByMarketCapOperation, GetTopNFTCollectionsByMarketCapOperationResponse, GetHottestNFTCollectionsByTradingVolumeOperationResponseJSON, GetHottestNFTCollectionsByTradingVolumeOperation, GetHottestNFTCollectionsByTradingVolumeOperationResponse } from '@moralisweb3/common-evm-utils'; import { NullableOperationResolver, OperationResolver, OperationV3Resolver, PaginatedOperationResolver, PaginatedResponseV3Adapter, PaginatedOperationV3Resolver } from '@moralisweb3/api-utils'; import { ApiModule, ResponseAdapter } from '@moralisweb3/common-core'; export abstract class ClientEvmApi extends ApiModule { @@ -125,6 +125,9 @@ export abstract class ClientEvmApi extends ApiModule { getPairReserves: (request: GetPairReservesRequest): Promise => { return new OperationResolver(getPairReservesOperation, this.baseUrl, this.core).fetch(request); }, + getPairPrice: (request: GetPairPriceOperationRequest): Promise> => { + return new OperationV3Resolver(GetPairPriceOperation, this.baseUrl, this.core).fetch(request, null); + }, }; @@ -169,6 +172,9 @@ export abstract class ClientEvmApi extends ApiModule { resolveENSDomain: (request: ResolveENSDomainRequest): Promise => { return new NullableOperationResolver(resolveENSDomainOperation, this.baseUrl, this.core).fetch(request); }, + resolveAddressToDomain: (request: ResolveAddressToDomainOperationRequest): Promise> => { + return new OperationV3Resolver(ResolveAddressToDomainOperation, this.baseUrl, this.core).fetch(request, null); + }, }; @@ -195,6 +201,22 @@ export abstract class ClientEvmApi extends ApiModule { }; + public readonly wallets = { + getWalletTokenBalancesPrice: (request: GetWalletTokenBalancesPriceOperationRequest): Promise> => { + return new PaginatedOperationV3Resolver(GetWalletTokenBalancesPriceOperation, this.baseUrl, this.core).fetch(request, null); + }, + getWalletNetWorth: (request: GetWalletNetWorthOperationRequest): Promise> => { + return new OperationV3Resolver(GetWalletNetWorthOperation, this.baseUrl, this.core).fetch(request, null); + }, + getWalletActiveChains: (request: GetWalletActiveChainsOperationRequest): Promise> => { + return new OperationV3Resolver(GetWalletActiveChainsOperation, this.baseUrl, this.core).fetch(request, null); + }, + getWalletStats: (request: GetWalletStatsOperationRequest): Promise> => { + return new OperationV3Resolver(GetWalletStatsOperation, this.baseUrl, this.core).fetch(request, null); + }, + + }; + public readonly marketData = { getTopERC20TokensByMarketCap: (): Promise> => { return new OperationV3Resolver(GetTopERC20TokensByMarketCapOperation, this.baseUrl, this.core).fetch({}, null); @@ -211,14 +233,4 @@ export abstract class ClientEvmApi extends ApiModule { }; - public readonly wallets = { - getWalletActiveChains: (request: GetWalletActiveChainsOperationRequest): Promise> => { - return new OperationV3Resolver(GetWalletActiveChainsOperation, this.baseUrl, this.core).fetch(request, null); - }, - getWalletStats: (request: GetWalletStatsOperationRequest): Promise> => { - return new OperationV3Resolver(GetWalletStatsOperation, this.baseUrl, this.core).fetch(request, null); - }, - - }; - }