Type issues on 'EvmApi'

I got type issues and i am unable to solve them, please help me solve it:

  • Property ‘native’ does not exist on type ‘EvmApi’.

  • Property ‘native’ does not exist on type ‘EvmApi’.

  • Property ‘account’ does not exist on type ‘EvmApi’.

  • Property ‘getNFTTransfersFromToBlock’ does not exist on type ‘{ getErc20Approvals: (request: GetErc20ApprovalsRequest) => Promise; … 9 more …; getWalletTokenTransfers: (request: GetWalletTokenTransfersRequest) => Promise<…>; }’.

  • 456 const result = await Moralis.EvmApi.token.getNFTTransfersFromToBlock(request);

Hi @roba

Can you share your code that shows these type errors?

@johnversus
Here is the code:

/* eslint-disable @typescript-eslint/no-var-requires */
/* eslint-disable @typescript-eslint/no-explicit-any */
/* eslint-disable @typescript-eslint/no-unused-vars */
import Moralis from 'moralis'
import { MoralisError, Operation } from '@moralisweb3/common-core';
import { handleRateLimit } from '../../rateLimit';
import { upgradeRequest } from '../upgradeRequest'
import { AxiosError } from 'axios';
import { operations } from '@moralisweb3/common-evm-utils';
declare const Parse: any;

function getErrorMessage(error: Error, name: string) {
  // Resolve Axios data inside the MoralisError
  if (
    error instanceof MoralisError &&
    error.cause &&
    error.cause instanceof AxiosError &&
    error.cause.response &&
    error.cause.response.data
  ) {
    return JSON.stringify(error.cause.response.data);
  }

  if (error instanceof Error) {
    return error.message;
  }

  return `API error while calling ${name}`
}

function getOperation(operationName: string): Operation<unknown, unknown, unknown, unknown> {
  const operation = operations.find((o) => o.name === operationName);
  if (!operation) {
    throw new Error(`Not supported operation ${operationName}`);
  }
  return operation as Operation<unknown, unknown, unknown, unknown>;
}

async function beforeApiRequest(user: any, ip: any, name: string) {
  if (!(await handleRateLimit(user, ip))) {
    throw new Error(
      `Too many requests to ${name} API from this particular client, the clients needs to wait before sending more requests.`
    );
  }
}


const getBlockOperation = getOperation('getBlock');
Parse.Cloud.define("getBlock", async ({params, user, ip}: any) => {
  try {
    await beforeApiRequest(user, ip, 'getBlock');
    const request = upgradeRequest(params, getBlockOperation);
    const result = await Moralis.EvmApi.block.getBlock(request);
    return result?.raw;
  } catch (error) {
    throw new Error(getErrorMessage(error, 'getBlock'));
  }
})


const getDateToBlockOperation = getOperation('getDateToBlock');
Parse.Cloud.define("getDateToBlock", async ({params, user, ip}: any) => {
  try {
    await beforeApiRequest(user, ip, 'getDateToBlock');
    const request = upgradeRequest(params, getDateToBlockOperation);
    const result = await Moralis.EvmApi.block.getDateToBlock(request);
    return result?.raw;
  } catch (error) {
    throw new Error(getErrorMessage(error, 'getDateToBlock'));
  }
})


const getLogsByAddressOperation = getOperation('getContractLogs');
Parse.Cloud.define("getLogsByAddress", async ({params, user, ip}: any) => {
  try {
    await beforeApiRequest(user, ip, 'getLogsByAddress');
    const request = upgradeRequest(params, getLogsByAddressOperation);
    const result = await Moralis.EvmApi.events.getContractLogs(request);
    return result?.raw;
  } catch (error) {
    throw new Error(getErrorMessage(error, 'getLogsByAddress'));
  }
})


const getNFTTransfersByBlockOperation = getOperation('getNFTTransfersByBlock');
Parse.Cloud.define("getNFTTransfersByBlock", async ({params, user, ip}: any) => {
  try {
    await beforeApiRequest(user, ip, 'getNFTTransfersByBlock');
    const request = upgradeRequest(params, getNFTTransfersByBlockOperation);
    const result = await Moralis.EvmApi.nft.getNFTTransfersByBlock(request);
    return result?.raw;
  } catch (error) {
    throw new Error(getErrorMessage(error, 'getNFTTransfersByBlock'));
  }
})


const getInternalTransactionsOperation = getOperation('getInternalTransactions');
Parse.Cloud.define("getInternalTransactions", async ({params, user, ip}: any) => {
  try {
    await beforeApiRequest(user, ip, 'getInternalTransactions');
    const request = upgradeRequest(params, getInternalTransactionsOperation);
    const result = await Moralis.EvmApi.native.getInternalTransactions(request);
    return result?.raw;
  } catch (error) {
    throw new Error(getErrorMessage(error, 'getInternalTransactions'));
  }
})


const getTransactionOperation = getOperation('getTransaction');
Parse.Cloud.define("getTransaction", async ({params, user, ip}: any) => {
  try {
    await beforeApiRequest(user, ip, 'getTransaction');
    const request = upgradeRequest(params, getTransactionOperation);
    const result = await Moralis.EvmApi.transaction.getTransaction(request);
    return result?.raw;
  } catch (error) {
    throw new Error(getErrorMessage(error, 'getTransaction'));
  }
})


const getTransactionVerboseOperation = getOperation('getTransactionVerbose');
Parse.Cloud.define("getTransactionVerbose", async ({params, user, ip}: any) => {
  try {
    await beforeApiRequest(user, ip, 'getTransactionVerbose');
    const request = upgradeRequest(params, getTransactionVerboseOperation);
    const result = await Moralis.EvmApi.native.getTransactionVerbose(request);
    return result?.raw;
  } catch (error) {
    throw new Error(getErrorMessage(error, 'getTransactionVerbose'));
  }
})


const getContractEventsOperation = getOperation('getContractEvents');
Parse.Cloud.define("getContractEvents", async ({params, user, ip}: any) => {
  try {
    await beforeApiRequest(user, ip, 'getContractEvents');
    const request = upgradeRequest(params, getContractEventsOperation);
    const result = await Moralis.EvmApi.events.getContractEvents(request);
    return result?.raw;
  } catch (error) {
    throw new Error(getErrorMessage(error, 'getContractEvents'));
  }
})


const runContractFunctionOperation = getOperation('runContractFunction');
Parse.Cloud.define("runContractFunction", async ({params, user, ip}: any) => {
  try {
    await beforeApiRequest(user, ip, 'runContractFunction');
    const request = upgradeRequest(params, runContractFunctionOperation);
    const result = await Moralis.EvmApi.utils.runContractFunction(request);
    return result?.raw;
  } catch (error) {
    throw new Error(getErrorMessage(error, 'runContractFunction'));
  }
})


const getTransactionsOperation = getOperation('getWalletTransactions');
Parse.Cloud.define("getTransactions", async ({params, user, ip}: any) => {
  try {
    await beforeApiRequest(user, ip, 'getTransactions');
    const request = upgradeRequest(params, getTransactionsOperation);
    const result = await Moralis.EvmApi.transaction.getWalletTransactions(request);
    return result?.raw;
  } catch (error) {
    throw new Error(getErrorMessage(error, 'getTransactions'));
  }
})


const getTransactionsVerboseOperation = getOperation('getWalletTransactionsVerbose');
Parse.Cloud.define("getTransactionsVerbose", async ({params, user, ip}: any) => {
  try {
    await beforeApiRequest(user, ip, 'getTransactionsVerbose');
    const request = upgradeRequest(params, getTransactionsVerboseOperation);
    const result = await Moralis.EvmApi.transaction.getWalletTransactionsVerbose(request);
    return result?.raw;
  } catch (error) {
    throw new Error(getErrorMessage(error, 'getTransactionsVerbose'));
  }
})


const getNativeBalanceOperation = getOperation('getNativeBalance');
Parse.Cloud.define("getNativeBalance", async ({params, user, ip}: any) => {
  try {
    await beforeApiRequest(user, ip, 'getNativeBalance');
    const request = upgradeRequest(params, getNativeBalanceOperation);
    const result = await Moralis.EvmApi.balance.getNativeBalance(request);
    return result?.raw;
  } catch (error) {
    throw new Error(getErrorMessage(error, 'getNativeBalance'));
  }
})


const getNativeBalancesForAddressesOperation = getOperation('getNativeBalancesForAddresses');
Parse.Cloud.define("getNativeBalancesForAddresses", async ({params, user, ip}: any) => {
  try {
    await beforeApiRequest(user, ip, 'getNativeBalancesForAddresses');
    const request = upgradeRequest(params, getNativeBalancesForAddressesOperation);
    const result = await Moralis.EvmApi.account.getNativeBalancesForAddresses(request);
    return result?.raw;
  } catch (error) {
    throw new Error(getErrorMessage(error, 'getNativeBalancesForAddresses'));
  }
})


const getTokenBalancesOperation = getOperation('getWalletTokenBalances');
Parse.Cloud.define("getTokenBalances", async ({params, user, ip}: any) => {
  try {
    await beforeApiRequest(user, ip, 'getTokenBalances');
    const request = upgradeRequest(params, getTokenBalancesOperation);
    const result = await Moralis.EvmApi.token.getWalletTokenBalances(request);
    return result?.raw;
  } catch (error) {
    throw new Error(getErrorMessage(error, 'getTokenBalances'));
  }
})


const getTokenTransfersOperation = getOperation('getWalletTokenTransfers');
Parse.Cloud.define("getTokenTransfers", async ({params, user, ip}: any) => {
  try {
    await beforeApiRequest(user, ip, 'getTokenTransfers');
    const request = upgradeRequest(params, getTokenTransfersOperation);
    const result = await Moralis.EvmApi.token.getWalletTokenTransfers(request);
    return result?.raw;
  } catch (error) {
    throw new Error(getErrorMessage(error, 'getTokenTransfers'));
  }
})


const getNFTsOperation = getOperation('getWalletNFTs');
Parse.Cloud.define("getNFTs", async ({params, user, ip}: any) => {
  try {
    await beforeApiRequest(user, ip, 'getNFTs');
    const request = upgradeRequest(params, getNFTsOperation);
    const result = await Moralis.EvmApi.nft.getWalletNFTs(request);
    return result?.raw;
  } catch (error) {
    throw new Error(getErrorMessage(error, 'getNFTs'));
  }
})


const getNFTTransfersOperation = getOperation('getWalletNFTTransfers');
Parse.Cloud.define("getNFTTransfers", async ({params, user, ip}: any) => {
  try {
    await beforeApiRequest(user, ip, 'getNFTTransfers');
    const request = upgradeRequest(params, getNFTTransfersOperation);
    const result = await Moralis.EvmApi.nft.getWalletNFTTransfers(request);
    return result?.raw;
  } catch (error) {
    throw new Error(getErrorMessage(error, 'getNFTTransfers'));
  }
})


const getWalletNFTCollectionsOperation = getOperation('getWalletNFTCollections');
Parse.Cloud.define("getWalletNFTCollections", async ({params, user, ip}: any) => {
  try {
    await beforeApiRequest(user, ip, 'getWalletNFTCollections');
    const request = upgradeRequest(params, getWalletNFTCollectionsOperation);
    const result = await Moralis.EvmApi.nft.getWalletNFTCollections(request);
    return result?.raw;
  } catch (error) {
    throw new Error(getErrorMessage(error, 'getWalletNFTCollections'));
  }
})


const getNFTsForContractOperation = getOperation('getWalletNFTs');
Parse.Cloud.define("getNFTsForContract", async ({params, user, ip}: any) => {
  try {
    await beforeApiRequest(user, ip, 'getNFTsForContract');
    const request = upgradeRequest(params, getNFTsForContractOperation);
    const result = await Moralis.EvmApi.nft.getWalletNFTs(request);
    return result?.raw;
  } catch (error) {
    throw new Error(getErrorMessage(error, 'getNFTsForContract'));
  }
})


const getTokenMetadataOperation = getOperation('getTokenMetadata');
Parse.Cloud.define("getTokenMetadata", async ({params, user, ip}: any) => {
  try {
    await beforeApiRequest(user, ip, 'getTokenMetadata');
    const request = upgradeRequest(params, getTokenMetadataOperation);
    const result = await Moralis.EvmApi.token.getTokenMetadata(request);
    return result?.raw;
  } catch (error) {
    throw new Error(getErrorMessage(error, 'getTokenMetadata'));
  }
})


const getNFTTradesOperation = getOperation('getNFTTrades');
Parse.Cloud.define("getNFTTrades", async ({params, user, ip}: any) => {
  try {
    await beforeApiRequest(user, ip, 'getNFTTrades');
    const request = upgradeRequest(params, getNFTTradesOperation);
    const result = await Moralis.EvmApi.nft.getNFTTrades(request);
    return result?.raw;
  } catch (error) {
    throw new Error(getErrorMessage(error, 'getNFTTrades'));
  }
})


const getNFTLowestPriceOperation = getOperation('getNFTLowestPrice');
Parse.Cloud.define("getNFTLowestPrice", async ({params, user, ip}: any) => {
  try {
    await beforeApiRequest(user, ip, 'getNFTLowestPrice');
    const request = upgradeRequest(params, getNFTLowestPriceOperation);
    const result = await Moralis.EvmApi.nft.getNFTLowestPrice(request);
    return result?.raw;
  } catch (error) {
    throw new Error(getErrorMessage(error, 'getNFTLowestPrice'));
  }
})


const getTokenMetadataBySymbolOperation = getOperation('getTokenMetadataBySymbol');
Parse.Cloud.define("getTokenMetadataBySymbol", async ({params, user, ip}: any) => {
  try {
    await beforeApiRequest(user, ip, 'getTokenMetadataBySymbol');
    const request = upgradeRequest(params, getTokenMetadataBySymbolOperation);
    const result = await Moralis.EvmApi.token.getTokenMetadataBySymbol(request);
    return result?.raw;
  } catch (error) {
    throw new Error(getErrorMessage(error, 'getTokenMetadataBySymbol'));
  }
})


const getTokenPriceOperation = getOperation('getTokenPrice');
Parse.Cloud.define("getTokenPrice", async ({params, user, ip}: any) => {
  try {
    await beforeApiRequest(user, ip, 'getTokenPrice');
    const request = upgradeRequest(params, getTokenPriceOperation);
    const result = await Moralis.EvmApi.token.getTokenPrice(request);
    return result?.raw;
  } catch (error) {
    throw new Error(getErrorMessage(error, 'getTokenPrice'));
  }
})


const getTokenAddressTransfersOperation = getOperation('getTokenTransfers');
Parse.Cloud.define("getTokenAddressTransfers", async ({params, user, ip}: any) => {
  try {
    await beforeApiRequest(user, ip, 'getTokenAddressTransfers');
    const request = upgradeRequest(params, getTokenAddressTransfersOperation);
    const result = await Moralis.EvmApi.token.getTokenTransfers(request);
    return result?.raw;
  } catch (error) {
    throw new Error(getErrorMessage(error, 'getTokenAddressTransfers'));
  }
})


const getTokenAllowanceOperation = getOperation('getTokenAllowance');
Parse.Cloud.define("getTokenAllowance", async ({params, user, ip}: any) => {
  try {
    await beforeApiRequest(user, ip, 'getTokenAllowance');
    const request = upgradeRequest(params, getTokenAllowanceOperation);
    const result = await Moralis.EvmApi.token.getTokenAllowance(request);
    return result?.raw;
  } catch (error) {
    throw new Error(getErrorMessage(error, 'getTokenAllowance'));
  }
})


const getErc20TransfersOperation = getOperation('getErc20Transfers');
Parse.Cloud.define("getErc20Transfers", async ({params, user, ip}: any) => {
  try {
    await beforeApiRequest(user, ip, 'getErc20Transfers');
    const request = upgradeRequest(params, getErc20TransfersOperation);
    const result = await Moralis.EvmApi.token.getErc20Transfers(request);
    return result?.raw;
  } catch (error) {
    throw new Error(getErrorMessage(error, 'getErc20Transfers'));
  }
})


const getErc20MintsOperation = getOperation('getErc20Mints');
Parse.Cloud.define("getErc20Mints", async ({params, user, ip}: any) => {
  try {
    await beforeApiRequest(user, ip, 'getErc20Mints');
    const request = upgradeRequest(params, getErc20MintsOperation);
    const result = await Moralis.EvmApi.token.getErc20Mints(request);
    return result?.raw;
  } catch (error) {
    throw new Error(getErrorMessage(error, 'getErc20Mints'));
  }
})


const getErc20BurnsOperation = getOperation('getErc20Burns');
Parse.Cloud.define("getErc20Burns", async ({params, user, ip}: any) => {
  try {
    await beforeApiRequest(user, ip, 'getErc20Burns');
    const request = upgradeRequest(params, getErc20BurnsOperation);
    const result = await Moralis.EvmApi.token.getErc20Burns(request);
    return result?.raw;
  } catch (error) {
    throw new Error(getErrorMessage(error, 'getErc20Burns'));
  }
})


const getErc20ApprovalsOperation = getOperation('getErc20Approvals');
Parse.Cloud.define("getErc20Approvals", async ({params, user, ip}: any) => {
  try {
    await beforeApiRequest(user, ip, 'getErc20Approvals');
    const request = upgradeRequest(params, getErc20ApprovalsOperation);
    const result = await Moralis.EvmApi.token.getErc20Approvals(request);
    return result?.raw;
  } catch (error) {
    throw new Error(getErrorMessage(error, 'getErc20Approvals'));
  }
})


const searchNFTsOperation = getOperation('searchNFTs');
Parse.Cloud.define("searchNFTs", async ({params, user, ip}: any) => {
  try {
    await beforeApiRequest(user, ip, 'searchNFTs');
    const request = upgradeRequest(params, searchNFTsOperation);
    const result = await Moralis.EvmApi.nft.searchNFTs(request);
    return result?.raw;
  } catch (error) {
    throw new Error(getErrorMessage(error, 'searchNFTs'));
  }
})


const getNFTTransfersFromToBlockOperation = getOperation('getNFTTransfersFromToBlock');
Parse.Cloud.define("getNFTTransfersFromToBlock", async ({params, user, ip}: any) => {
  try {
    await beforeApiRequest(user, ip, 'getNFTTransfersFromToBlock');
    const request = upgradeRequest(params, getNFTTransfersFromToBlockOperation);
    const result = await Moralis.EvmApi.token.getNFTTransfersFromToBlock(request);
    return result?.raw;
  } catch (error) {
    throw new Error(getErrorMessage(error, 'getNFTTransfersFromToBlock'));
  }
})


const getAllTokenIdsOperation = getOperation('getContractNFTs');
Parse.Cloud.define("getAllTokenIds", async ({params, user, ip}: any) => {
  try {
    await beforeApiRequest(user, ip, 'getAllTokenIds');
    const request = upgradeRequest(params, getAllTokenIdsOperation);
    const result = await Moralis.EvmApi.nft.getContractNFTs(request);
    return result?.raw;
  } catch (error) {
    throw new Error(getErrorMessage(error, 'getAllTokenIds'));
  }
})


const getMultipleNFTsOperation = getOperation('getMultipleNFTs');
Parse.Cloud.define("getMultipleNFTs", async ({params, user, ip}: any) => {
  try {
    await beforeApiRequest(user, ip, 'getMultipleNFTs');
    const request = upgradeRequest(params, getMultipleNFTsOperation);
    const result = await Moralis.EvmApi.nft.getMultipleNFTs(request);
    return result?.raw;
  } catch (error) {
    throw new Error(getErrorMessage(error, 'getMultipleNFTs'));
  }
})


const getContractNFTTransfersOperation = getOperation('getNFTContractTransfers');
Parse.Cloud.define("getContractNFTTransfers", async ({params, user, ip}: any) => {
  try {
    await beforeApiRequest(user, ip, 'getContractNFTTransfers');
    const request = upgradeRequest(params, getContractNFTTransfersOperation);
    const result = await Moralis.EvmApi.nft.getNFTContractTransfers(request);
    return result?.raw;
  } catch (error) {
    throw new Error(getErrorMessage(error, 'getContractNFTTransfers'));
  }
})


const getNFTOwnersOperation = getOperation('getNFTOwners');
Parse.Cloud.define("getNFTOwners", async ({params, user, ip}: any) => {
  try {
    await beforeApiRequest(user, ip, 'getNFTOwners');
    const request = upgradeRequest(params, getNFTOwnersOperation);
    const result = await Moralis.EvmApi.nft.getNFTOwners(request);
    return result?.raw;
  } catch (error) {
    throw new Error(getErrorMessage(error, 'getNFTOwners'));
  }
})


const getNFTMetadataOperation = getOperation('getNFTContractMetadata');
Parse.Cloud.define("getNFTMetadata", async ({params, user, ip}: any) => {
  try {
    await beforeApiRequest(user, ip, 'getNFTMetadata');
    const request = upgradeRequest(params, getNFTMetadataOperation);
    const result = await Moralis.EvmApi.nft.getNFTContractMetadata(request);
    return result?.raw;
  } catch (error) {
    throw new Error(getErrorMessage(error, 'getNFTMetadata'));
  }
})


const reSyncMetadataOperation = getOperation('reSyncMetadata');
Parse.Cloud.define("reSyncMetadata", async ({params, user, ip}: any) => {
  try {
    await beforeApiRequest(user, ip, 'reSyncMetadata');
    const request = upgradeRequest(params, reSyncMetadataOperation);
    const result = await Moralis.EvmApi.nft.reSyncMetadata(request);
    return result?.raw;
  } catch (error) {
    throw new Error(getErrorMessage(error, 'reSyncMetadata'));
  }
})


const syncNFTContractOperation = getOperation('syncNFTContract');
Parse.Cloud.define("syncNFTContract", async ({params, user, ip}: any) => {
  try {
    await beforeApiRequest(user, ip, 'syncNFTContract');
    const request = upgradeRequest(params, syncNFTContractOperation);
    const result = await Moralis.EvmApi.nft.syncNFTContract(request);
    return result?.raw;
  } catch (error) {
    throw new Error(getErrorMessage(error, 'syncNFTContract'));
  }
})


const getTokenIdMetadataOperation = getOperation('getNFTMetadata');
Parse.Cloud.define("getTokenIdMetadata", async ({params, user, ip}: any) => {
  try {
    await beforeApiRequest(user, ip, 'getTokenIdMetadata');
    const request = upgradeRequest(params, getTokenIdMetadataOperation);
    const result = await Moralis.EvmApi.nft.getNFTMetadata(request);
    return result?.raw;
  } catch (error) {
    throw new Error(getErrorMessage(error, 'getTokenIdMetadata'));
  }
})


const getTokenIdOwnersOperation = getOperation('getNFTTokenIdOwners');
Parse.Cloud.define("getTokenIdOwners", async ({params, user, ip}: any) => {
  try {
    await beforeApiRequest(user, ip, 'getTokenIdOwners');
    const request = upgradeRequest(params, getTokenIdOwnersOperation);
    const result = await Moralis.EvmApi.nft.getNFTTokenIdOwners(request);
    return result?.raw;
  } catch (error) {
    throw new Error(getErrorMessage(error, 'getTokenIdOwners'));
  }
})


const getWalletTokenIdTransfersOperation = getOperation('getNFTTransfers');
Parse.Cloud.define("getWalletTokenIdTransfers", async ({params, user, ip}: any) => {
  try {
    await beforeApiRequest(user, ip, 'getWalletTokenIdTransfers');
    const request = upgradeRequest(params, getWalletTokenIdTransfersOperation);
    const result = await Moralis.EvmApi.nft.getNFTTransfers(request);
    return result?.raw;
  } catch (error) {
    throw new Error(getErrorMessage(error, 'getWalletTokenIdTransfers'));
  }
})


const resolveDomainOperation = getOperation('resolveDomain');
Parse.Cloud.define("resolveDomain", async ({params, user, ip}: any) => {
  try {
    await beforeApiRequest(user, ip, 'resolveDomain');
    const request = upgradeRequest(params, resolveDomainOperation);
    const result = await Moralis.EvmApi.resolve.resolveDomain(request);
    return result?.raw;
  } catch (error) {
    throw new Error(getErrorMessage(error, 'resolveDomain'));
  }
})


const resolveENSDomainOperation = getOperation('resolveENSDomain');
Parse.Cloud.define("resolveENSDomain", async ({params, user, ip}: any) => {
  try {
    await beforeApiRequest(user, ip, 'resolveENSDomain');
    const request = upgradeRequest(params, resolveENSDomainOperation);
    const result = await Moralis.EvmApi.resolve.resolveENSDomain(request);
    return result?.raw;
  } catch (error) {
    throw new Error(getErrorMessage(error, 'resolveENSDomain'));
  }
})


const resolveAddressOperation = getOperation('resolveAddress');
Parse.Cloud.define("resolveAddress", async ({params, user, ip}: any) => {
  try {
    await beforeApiRequest(user, ip, 'resolveAddress');
    const request = upgradeRequest(params, resolveAddressOperation);
    const result = await Moralis.EvmApi.resolve.resolveAddress(request);
    return result?.raw;
  } catch (error) {
    throw new Error(getErrorMessage(error, 'resolveAddress'));
  }
})


const getPairReservesOperation = getOperation('getPairReserves');
Parse.Cloud.define("getPairReserves", async ({params, user, ip}: any) => {
  try {
    await beforeApiRequest(user, ip, 'getPairReserves');
    const request = upgradeRequest(params, getPairReservesOperation);
    const result = await Moralis.EvmApi.defi.getPairReserves(request);
    return result?.raw;
  } catch (error) {
    throw new Error(getErrorMessage(error, 'getPairReserves'));
  }
})


const getPairAddressOperation = getOperation('getPairAddress');
Parse.Cloud.define("getPairAddress", async ({params, user, ip}: any) => {
  try {
    await beforeApiRequest(user, ip, 'getPairAddress');
    const request = upgradeRequest(params, getPairAddressOperation);
    const result = await Moralis.EvmApi.defi.getPairAddress(request);
    return result?.raw;
  } catch (error) {
    throw new Error(getErrorMessage(error, 'getPairAddress'));
  }
})


const uploadFolderOperation = getOperation('uploadFolder');
Parse.Cloud.define("uploadFolder", async ({params, user, ip}: any) => {
  try {
    await beforeApiRequest(user, ip, 'uploadFolder');
    const request = upgradeRequest(params, uploadFolderOperation);
    const result = await Moralis.EvmApi.ipfs.uploadFolder(request);
    return result?.raw;
  } catch (error) {
    throw new Error(getErrorMessage(error, 'uploadFolder'));
  }
})


const web3ApiVersionOperation = getOperation('web3ApiVersion');
Parse.Cloud.define("web3ApiVersion", async ({params, user, ip}: any) => {
  try {
    await beforeApiRequest(user, ip, 'web3ApiVersion');
    const request = upgradeRequest(params, web3ApiVersionOperation);
    const result = await Moralis.EvmApi.utils.web3ApiVersion();
    return result?.raw;
  } catch (error) {
    throw new Error(getErrorMessage(error, 'web3ApiVersion'));
  }
})


const endpointWeightsOperation = getOperation('endpointWeights');
Parse.Cloud.define("endpointWeights", async ({params, user, ip}: any) => {
  try {
    await beforeApiRequest(user, ip, 'endpointWeights');
    const request = upgradeRequest(params, endpointWeightsOperation);
    const result = await Moralis.EvmApi.utils.endpointWeights();
    return result?.raw;
  } catch (error) {
    throw new Error(getErrorMessage(error, 'endpointWeights'));
  }
})


The errors occurred while running the following script from package.json:

"**gen:cloud": "ts-node ./scripts/generateCloudCode.ts"**

It seems like you might have updated the Moralis sdk version in the parse server code so you have to update some of the function.

Example:
Moralis.EvmApi.native.getInternalTransactions will be replaced with Moralis.EvmApi.transaction.getWalletTransactions

You can find in these docs on how the API endpoints are grouped in the latest sdk.

Let us know if you have any issues updating it.

Thanks, I was able to update it. But while starting the server, i encountered the following issue:

Hi @roba

What was the module that was not found as per the error logs?

Maybe installing the missing module might solve it

can you please help me solve the type issue in the following code:

function getOperation(operationName: string): Operation<unknown, unknown, unknown, unknown> {
  // initialize 
  const operation = operations.find((op) => op.operationId === operationName);
    
  if (!operation) {
    throw new Error(`Not supported operation ${operationName}`);
  }
  return operation as Operation<unknown, unknown, unknown, unknown>

}

Hi @roba

What was the type error you are seeing?

My error message as following:

C:\Users\pdd-u02\Downloads\parse-server-migration>npm run build
npm WARN config global --global, --local are deprecated. Use --location=global instead.

[email protected] build
tsc

src/cloud/generated/evmApi.ts:32:46 - error TS2339: Property ‘name’ does not exist on type ‘{ operationId: string; groupName: string; httpMethod: string; routePattern: string; parameterNames: string[]; hasResponse: boolean; hasBody: boolean; parseResponse(json: EvmTradeCollectionJSON): EvmTradeCollection; serializeRequest(request: GetNFTTradesOperationRequest): GetNFTTradesOperationRequestJSON; } | … 6 m…’.
Property ‘name’ does not exist on type ‘{ operationId: string; groupName: string; httpMethod: string; routePattern: string; parameterNames: string[]; hasResponse: boolean; hasBody: boolean; parseResponse(json: EvmTradeCollectionJSON): EvmTradeCollection; serializeRequest(request: GetNFTTradesOperationRequest): GetNFTTradesOperationRequestJSON; }’.

32 const operation = operations.find((o) => o.name === operationName);
~~~~

src/cloud/generated/evmApi.ts:36:10 - error TS2352: Conversion of type ‘{ operationId: string; groupName: string; httpMethod: string; routePattern: string; parameterNames: string[]; hasResponse: boolean; hasBody: boolean; parseResponse(json: EvmTradeCollectionJSON): EvmTradeCollection; serializeRequest(request: GetNFTTradesOperationRequest): GetNFTTradesOperationRequestJSON; } | … 6 m…’ to type ‘Operation<unknown, unknown, unknown, unknown>’ may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to ‘unknown’ first.
Type ‘{ operationId: string; groupName: string; httpMethod: string; routePattern: string; parameterNames: never[]; hasResponse: boolean; hasBody: boolean; parseResponse(json: EvmMarketDataHottestNFTCollectionByTradingVolumeItemJSON[]): EvmMarketDataHottestNFTCollectionByTradingVolumeItem[]; serializeRequest(request: GetHo…’ is missing the following properties from type ‘Operation<unknown, unknown, unknown, unknown>’: name, id, method, urlPathPattern, and 3 more.

36 return operation as Operation<unknown, unknown, unknown, unknown>;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Found 2 errors in the same file, starting at: src/cloud/generated/evmApi.ts:32

@cryptokid same issue i have facing right now

#13 12.94 src/cloud/generated/evmApi.ts(32,46): error TS2339: Property 'name' does not exist on type '{ operationId: string; groupName: string; httpMethod: string; routePattern: string; parameterNames: string[]; hasResponse: boolean; hasBody: boolean; parseResponse(json: EvmTradeCollectionJSON): EvmTradeCollection; serializeRequest(request: GetNFTTradesOperationRequest): GetNFTTradesOperationRequestJSON; } | ... 7 m...'.
#13 12.94   Property 'name' does not exist on type '{ operationId: string; groupName: string; httpMethod: string; routePattern: string; parameterNames: string[]; hasResponse: boolean; hasBody: boolean; parseResponse(json: EvmTradeCollectionJSON): EvmTradeCollection; serializeRequest(request: GetNFTTradesOperationRequest): GetNFTTradesOperationRequestJSON; }'.
 
#13 12.94 src/cloud/generated/evmApi.ts(36,10): error TS2352: Conversion of type '{ operationId: string; groupName: string; httpMethod: string; routePattern: string; parameterNames: string[]; hasResponse: boolean; hasBody: boolean; parseResponse(json: EvmTradeCollectionJSON): EvmTradeCollection; serializeRequest(request: GetNFTTradesOperationRequest): GetNFTTradesOperationRequestJSON; } | ... 7 m...' to type 'Operation<unknown, unknown, unknown, unknown>' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first.
#13 12.94   Type '{ operationId: string; groupName: string; httpMethod: string; routePattern: string; parameterNames: string[]; hasResponse: boolean; hasBody: boolean; parseResponse(json: EvmReviewContractsJSON): EvmReviewContracts; serializeRequest(request: ReviewContractsOperationRequest): ReviewContractsOperationRequestJSON; seria...' is missing the following properties from type 'Operation<unknown, unknown, unknown, unknown>': name, id, method, urlPathPattern, and 3 more.
#13 12.94 src/cloud/generated/solApi.ts(32,46): error TS2339: Property 'name' does not exist on type '{ operationId: string; groupName: string; httpMethod: string; routePattern: string; parameterNames: string[]; hasResponse: boolean; hasBody: boolean; parseResponse(json: SolSPLTokenPriceJSON): SolSPLTokenPrice; serializeRequest(request: GetTokenPriceOperationRequest): GetTokenPriceOperationRequestJSON; }'.
#13 12.94 src/cloud/generated/solApi.ts(36,10): error TS2352: Conversion of type '{ operationId: string; groupName: string; httpMethod: string; routePattern: string; parameterNames: string[]; hasResponse: boolean; hasBody: boolean; parseResponse(json: SolSPLTokenPriceJSON): SolSPLTokenPrice; serializeRequest(request: GetTokenPriceOperationRequest): GetTokenPriceOperationRequestJSON; }' to type 'Operation<unknown, unknown, unknown, unknown>' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first.
#13 12.94   Type '{ operationId: string; groupName: string; httpMethod: string; routePattern: string; parameterNames: string[]; hasResponse: boolean; hasBody: boolean; parseResponse(json: SolSPLTokenPriceJSON): SolSPLTokenPrice; serializeRequest(request: GetTokenPriceOperationRequest): GetTokenPriceOperationRequestJSON; }' is missing the following properties from type 'Operation<unknown, unknown, unknown, unknown>': name, id, method, urlPathPattern, and 3 more.
-----
1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.