Skip to content

Commit

Permalink
feat: added getTopCryptoCurrenciesByMarketCap, getTopCryptoCurrencies… (
Browse files Browse the repository at this point in the history
#1181)

feat: added getTopCryptoCurrenciesByMarketCap, getTopCryptoCurrenciesByTradingVolume methods.
  • Loading branch information
b4rtaz authored Feb 23, 2024
1 parent 31d73a7 commit 5caa827
Show file tree
Hide file tree
Showing 10 changed files with 336 additions and 2 deletions.
7 changes: 7 additions & 0 deletions .changeset/lazy-pots-explain.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'@moralisweb3/common-evm-utils': patch
'@moralisweb3/evm-api': patch
'moralis': patch
---

Added `getTopCryptoCurrenciesByMarketCap` and `getTopCryptoCurrenciesByTradingVolume` methods to the EVM API.
4 changes: 3 additions & 1 deletion packages/common/evmUtils/generator.config.json
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,9 @@
"getWalletTokenBalancesPrice",
"getPairPrice",
"resolveAddressToDomain",
"resolveENSAddress"
"resolveENSAddress",
"getTopCryptoCurrenciesByMarketCap",
"getTopCryptoCurrenciesByTradingVolume"
]
}
}
Expand Down
25 changes: 25 additions & 0 deletions packages/common/evmUtils/src/generated/client/abstractClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ import { GetTopNFTCollectionsByMarketCapOperation, GetTopNFTCollectionsByMarketC
import { EvmMarketDataTopNFTCollectionByMarketCapItem, EvmMarketDataTopNFTCollectionByMarketCapItemJSON } from '../types/EvmMarketDataTopNFTCollectionByMarketCapItem';
import { GetHottestNFTCollectionsByTradingVolumeOperation, GetHottestNFTCollectionsByTradingVolumeOperationRequest, GetHottestNFTCollectionsByTradingVolumeOperationRequestJSON } from '../operations/GetHottestNFTCollectionsByTradingVolumeOperation';
import { EvmMarketDataHottestNFTCollectionByTradingVolumeItem, EvmMarketDataHottestNFTCollectionByTradingVolumeItemJSON } from '../types/EvmMarketDataHottestNFTCollectionByTradingVolumeItem';
import { GetTopCryptoCurrenciesByMarketCapOperation, GetTopCryptoCurrenciesByMarketCapOperationRequest, GetTopCryptoCurrenciesByMarketCapOperationRequestJSON } from '../operations/GetTopCryptoCurrenciesByMarketCapOperation';
import { EvmMarketDataTopCryptoCurrenciesByMarketCapItem, EvmMarketDataTopCryptoCurrenciesByMarketCapItemJSON } from '../types/EvmMarketDataTopCryptoCurrenciesByMarketCapItem';
import { GetTopCryptoCurrenciesByTradingVolumeOperation, GetTopCryptoCurrenciesByTradingVolumeOperationRequest, GetTopCryptoCurrenciesByTradingVolumeOperationRequestJSON } from '../operations/GetTopCryptoCurrenciesByTradingVolumeOperation';
import { ReviewContractsOperation, ReviewContractsOperationRequest, ReviewContractsOperationRequestJSON } from '../operations/ReviewContractsOperation';
import { EvmReviewContracts, EvmReviewContractsJSON } from '../types/EvmReviewContracts';
import { EvmContractsReviewDto, EvmContractsReviewDtoInput, EvmContractsReviewDtoJSON } from '../types/EvmContractsReviewDto';
Expand Down Expand Up @@ -141,6 +144,28 @@ export abstract class AbstractClient {
EvmMarketDataHottestNFTCollectionByTradingVolumeItem[],
EvmMarketDataHottestNFTCollectionByTradingVolumeItemJSON[]
>(GetHottestNFTCollectionsByTradingVolumeOperation),
/**
* @description Get the top crypto currencies by market cap
* @param request Request with parameters.
* @returns {Object[]} Response for the request.
*/
getTopCryptoCurrenciesByMarketCap: this.createEndpoint<
GetTopCryptoCurrenciesByMarketCapOperationRequest,
GetTopCryptoCurrenciesByMarketCapOperationRequestJSON,
EvmMarketDataTopCryptoCurrenciesByMarketCapItem[],
EvmMarketDataTopCryptoCurrenciesByMarketCapItemJSON[]
>(GetTopCryptoCurrenciesByMarketCapOperation),
/**
* @description Get the top crypto currencies by trading volume
* @param request Request with parameters.
* @returns {Object[]} Response for the request.
*/
getTopCryptoCurrenciesByTradingVolume: this.createEndpoint<
GetTopCryptoCurrenciesByTradingVolumeOperationRequest,
GetTopCryptoCurrenciesByTradingVolumeOperationRequestJSON,
EvmMarketDataTopCryptoCurrenciesByMarketCapItem[],
EvmMarketDataTopCryptoCurrenciesByMarketCapItemJSON[]
>(GetTopCryptoCurrenciesByTradingVolumeOperation),
};
public readonly nft = {
/**
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { EvmMarketDataTopCryptoCurrenciesByMarketCapItem, EvmMarketDataTopCryptoCurrenciesByMarketCapItemJSON } from '../types/EvmMarketDataTopCryptoCurrenciesByMarketCapItem';

// request parameters:

export interface GetTopCryptoCurrenciesByMarketCapOperationRequest {
}

export interface GetTopCryptoCurrenciesByMarketCapOperationRequestJSON {
}

export type GetTopCryptoCurrenciesByMarketCapOperationResponse = EvmMarketDataTopCryptoCurrenciesByMarketCapItem[];
export type GetTopCryptoCurrenciesByMarketCapOperationResponseJSON = EvmMarketDataTopCryptoCurrenciesByMarketCapItemJSON[];

export const GetTopCryptoCurrenciesByMarketCapOperation = {
operationId: "getTopCryptoCurrenciesByMarketCap",
groupName: "marketData",
httpMethod: "get",
routePattern: "/market-data/global/market-cap",
parameterNames: [],
hasResponse: true,
hasBody: false,

parseResponse(json: EvmMarketDataTopCryptoCurrenciesByMarketCapItemJSON[]): EvmMarketDataTopCryptoCurrenciesByMarketCapItem[] {
return json.map((item) => EvmMarketDataTopCryptoCurrenciesByMarketCapItem.fromJSON(item));
},

serializeRequest(request: GetTopCryptoCurrenciesByMarketCapOperationRequest): GetTopCryptoCurrenciesByMarketCapOperationRequestJSON {
return {
};
},

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { EvmMarketDataTopCryptoCurrenciesByMarketCapItem, EvmMarketDataTopCryptoCurrenciesByMarketCapItemJSON } from '../types/EvmMarketDataTopCryptoCurrenciesByMarketCapItem';

// request parameters:

export interface GetTopCryptoCurrenciesByTradingVolumeOperationRequest {
}

export interface GetTopCryptoCurrenciesByTradingVolumeOperationRequestJSON {
}

export type GetTopCryptoCurrenciesByTradingVolumeOperationResponse = EvmMarketDataTopCryptoCurrenciesByMarketCapItem[];
export type GetTopCryptoCurrenciesByTradingVolumeOperationResponseJSON = EvmMarketDataTopCryptoCurrenciesByMarketCapItemJSON[];

export const GetTopCryptoCurrenciesByTradingVolumeOperation = {
operationId: "getTopCryptoCurrenciesByTradingVolume",
groupName: "marketData",
httpMethod: "get",
routePattern: "/market-data/global/volume",
parameterNames: [],
hasResponse: true,
hasBody: false,

parseResponse(json: EvmMarketDataTopCryptoCurrenciesByMarketCapItemJSON[]): EvmMarketDataTopCryptoCurrenciesByMarketCapItem[] {
return json.map((item) => EvmMarketDataTopCryptoCurrenciesByMarketCapItem.fromJSON(item));
},

serializeRequest(request: GetTopCryptoCurrenciesByTradingVolumeOperationRequest): GetTopCryptoCurrenciesByTradingVolumeOperationRequestJSON {
return {
};
},

}
2 changes: 2 additions & 0 deletions packages/common/evmUtils/src/generated/operations/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ export * from './GetTopERC20TokensByMarketCapOperation';
export * from './GetTopERC20TokensByPriceMoversOperation';
export * from './GetTopNFTCollectionsByMarketCapOperation';
export * from './GetHottestNFTCollectionsByTradingVolumeOperation';
export * from './GetTopCryptoCurrenciesByMarketCapOperation';
export * from './GetTopCryptoCurrenciesByTradingVolumeOperation';
export * from './ReviewContractsOperation';
export * from './GetWalletActiveChainsOperation';
export * from './GetWalletStatsOperation';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import { GetTopERC20TokensByMarketCapOperation } from './GetTopERC20TokensByMark
import { GetTopERC20TokensByPriceMoversOperation } from './GetTopERC20TokensByPriceMoversOperation';
import { GetTopNFTCollectionsByMarketCapOperation } from './GetTopNFTCollectionsByMarketCapOperation';
import { GetHottestNFTCollectionsByTradingVolumeOperation } from './GetHottestNFTCollectionsByTradingVolumeOperation';
import { GetTopCryptoCurrenciesByMarketCapOperation } from './GetTopCryptoCurrenciesByMarketCapOperation';
import { GetTopCryptoCurrenciesByTradingVolumeOperation } from './GetTopCryptoCurrenciesByTradingVolumeOperation';
import { ReviewContractsOperation } from './ReviewContractsOperation';
import { GetWalletActiveChainsOperation } from './GetWalletActiveChainsOperation';
import { GetWalletStatsOperation } from './GetWalletStatsOperation';
Expand All @@ -31,6 +33,8 @@ export const operations = [
GetTopERC20TokensByPriceMoversOperation,
GetTopNFTCollectionsByMarketCapOperation,
GetHottestNFTCollectionsByTradingVolumeOperation,
GetTopCryptoCurrenciesByMarketCapOperation,
GetTopCryptoCurrenciesByTradingVolumeOperation,
ReviewContractsOperation,
GetWalletActiveChainsOperation,
GetWalletStatsOperation,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,223 @@
// $ref: #/components/schemas/marketDataTopCryptoCurrenciesByMarketCap/items
// type: marketDataTopCryptoCurrenciesByMarketCap_Item
// properties:
// - symbol ($ref: #/components/schemas/marketDataTopCryptoCurrenciesByMarketCap/items/properties/symbol)
// - name ($ref: #/components/schemas/marketDataTopCryptoCurrenciesByMarketCap/items/properties/name)
// - logo ($ref: #/components/schemas/marketDataTopCryptoCurrenciesByMarketCap/items/properties/logo)
// - circulating_supply ($ref: #/components/schemas/marketDataTopCryptoCurrenciesByMarketCap/items/properties/circulating_supply)
// - total_supply ($ref: #/components/schemas/marketDataTopCryptoCurrenciesByMarketCap/items/properties/total_supply)
// - max_supply ($ref: #/components/schemas/marketDataTopCryptoCurrenciesByMarketCap/items/properties/max_supply)
// - market_cap_usd ($ref: #/components/schemas/marketDataTopCryptoCurrenciesByMarketCap/items/properties/market_cap_usd)
// - market_cap_rank ($ref: #/components/schemas/marketDataTopCryptoCurrenciesByMarketCap/items/properties/market_cap_rank)
// - market_cap_24h_change ($ref: #/components/schemas/marketDataTopCryptoCurrenciesByMarketCap/items/properties/market_cap_24h_change)
// - market_cap_24h_percent_change ($ref: #/components/schemas/marketDataTopCryptoCurrenciesByMarketCap/items/properties/market_cap_24h_percent_change)
// - total_volume ($ref: #/components/schemas/marketDataTopCryptoCurrenciesByMarketCap/items/properties/total_volume)
// - price_usd ($ref: #/components/schemas/marketDataTopCryptoCurrenciesByMarketCap/items/properties/price_usd)
// - usd_price_24h_high ($ref: #/components/schemas/marketDataTopCryptoCurrenciesByMarketCap/items/properties/usd_price_24h_high)
// - usd_price_24h_low ($ref: #/components/schemas/marketDataTopCryptoCurrenciesByMarketCap/items/properties/usd_price_24h_low)
// - usd_price_24h_change ($ref: #/components/schemas/marketDataTopCryptoCurrenciesByMarketCap/items/properties/usd_price_24h_change)
// - usd_price_24h_percent_change ($ref: #/components/schemas/marketDataTopCryptoCurrenciesByMarketCap/items/properties/usd_price_24h_percent_change)
// - usd_price_ath ($ref: #/components/schemas/marketDataTopCryptoCurrenciesByMarketCap/items/properties/usd_price_ath)
// - ath_percent_change ($ref: #/components/schemas/marketDataTopCryptoCurrenciesByMarketCap/items/properties/ath_percent_change)
// - ath_date ($ref: #/components/schemas/marketDataTopCryptoCurrenciesByMarketCap/items/properties/ath_date)

export interface EvmMarketDataTopCryptoCurrenciesByMarketCapItemJSON {
readonly symbol: string;
readonly name: string;
readonly logo: string;
readonly circulating_supply: string;
readonly total_supply: string;
readonly max_supply: string;
readonly market_cap_usd: string;
readonly market_cap_rank: string;
readonly market_cap_24h_change: string;
readonly market_cap_24h_percent_change: string;
readonly total_volume: string;
readonly price_usd: string;
readonly usd_price_24h_high: string;
readonly usd_price_24h_low: string;
readonly usd_price_24h_change: string;
readonly usd_price_24h_percent_change: string;
readonly usd_price_ath: string;
readonly ath_percent_change: string;
readonly ath_date: string;
}

export interface EvmMarketDataTopCryptoCurrenciesByMarketCapItemInput {
readonly symbol: string;
readonly name: string;
readonly logo: string;
readonly circulatingSupply: string;
readonly totalSupply: string;
readonly maxSupply: string;
readonly marketCapUsd: string;
readonly marketCapRank: string;
readonly marketCap24hChange: string;
readonly marketCap24hPercentChange: string;
readonly totalVolume: string;
readonly priceUsd: string;
readonly usdPrice24hHigh: string;
readonly usdPrice24hLow: string;
readonly usdPrice24hChange: string;
readonly usdPrice24hPercentChange: string;
readonly usdPriceAth: string;
readonly athPercentChange: string;
readonly athDate: string;
}

export class EvmMarketDataTopCryptoCurrenciesByMarketCapItem {
public static create(input: EvmMarketDataTopCryptoCurrenciesByMarketCapItemInput | EvmMarketDataTopCryptoCurrenciesByMarketCapItem): EvmMarketDataTopCryptoCurrenciesByMarketCapItem {
if (input instanceof EvmMarketDataTopCryptoCurrenciesByMarketCapItem) {
return input;
}
return new EvmMarketDataTopCryptoCurrenciesByMarketCapItem(input);
}

public static fromJSON(json: EvmMarketDataTopCryptoCurrenciesByMarketCapItemJSON): EvmMarketDataTopCryptoCurrenciesByMarketCapItem {
const input: EvmMarketDataTopCryptoCurrenciesByMarketCapItemInput = {
symbol: json.symbol,
name: json.name,
logo: json.logo,
circulatingSupply: json.circulating_supply,
totalSupply: json.total_supply,
maxSupply: json.max_supply,
marketCapUsd: json.market_cap_usd,
marketCapRank: json.market_cap_rank,
marketCap24hChange: json.market_cap_24h_change,
marketCap24hPercentChange: json.market_cap_24h_percent_change,
totalVolume: json.total_volume,
priceUsd: json.price_usd,
usdPrice24hHigh: json.usd_price_24h_high,
usdPrice24hLow: json.usd_price_24h_low,
usdPrice24hChange: json.usd_price_24h_change,
usdPrice24hPercentChange: json.usd_price_24h_percent_change,
usdPriceAth: json.usd_price_ath,
athPercentChange: json.ath_percent_change,
athDate: json.ath_date,
};
return EvmMarketDataTopCryptoCurrenciesByMarketCapItem.create(input);
}

/**
* @description The symbol of the token
*/
public readonly symbol: string;
/**
* @description The name of the token
*/
public readonly name: string;
/**
* @description The logo of the token
*/
public readonly logo: string;
/**
* @description The circulating supply
*/
public readonly circulatingSupply: string;
/**
* @description The total supply
*/
public readonly totalSupply: string;
/**
* @description The max supply
*/
public readonly maxSupply: string;
/**
* @description The market cap in USD
*/
public readonly marketCapUsd: string;
/**
* @description The market cap rank
*/
public readonly marketCapRank: string;
/**
* @description The market cap 24h change
*/
public readonly marketCap24hChange: string;
/**
* @description The market cap 24h percent change
*/
public readonly marketCap24hPercentChange: string;
/**
* @description The total volume
*/
public readonly totalVolume: string;
/**
* @description The price in USD
*/
public readonly priceUsd: string;
/**
* @description The price 24h high
*/
public readonly usdPrice24hHigh: string;
/**
* @description The price 24h low
*/
public readonly usdPrice24hLow: string;
/**
* @description The price 24h change
*/
public readonly usdPrice24hChange: string;
/**
* @description The price 24h percent change
*/
public readonly usdPrice24hPercentChange: string;
/**
* @description The price ath
*/
public readonly usdPriceAth: string;
/**
* @description The ath percent change
*/
public readonly athPercentChange: string;
/**
* @description The ath date
*/
public readonly athDate: string;

private constructor(input: EvmMarketDataTopCryptoCurrenciesByMarketCapItemInput) {
this.symbol = input.symbol;
this.name = input.name;
this.logo = input.logo;
this.circulatingSupply = input.circulatingSupply;
this.totalSupply = input.totalSupply;
this.maxSupply = input.maxSupply;
this.marketCapUsd = input.marketCapUsd;
this.marketCapRank = input.marketCapRank;
this.marketCap24hChange = input.marketCap24hChange;
this.marketCap24hPercentChange = input.marketCap24hPercentChange;
this.totalVolume = input.totalVolume;
this.priceUsd = input.priceUsd;
this.usdPrice24hHigh = input.usdPrice24hHigh;
this.usdPrice24hLow = input.usdPrice24hLow;
this.usdPrice24hChange = input.usdPrice24hChange;
this.usdPrice24hPercentChange = input.usdPrice24hPercentChange;
this.usdPriceAth = input.usdPriceAth;
this.athPercentChange = input.athPercentChange;
this.athDate = input.athDate;
}

public toJSON(): EvmMarketDataTopCryptoCurrenciesByMarketCapItemJSON {
return {
symbol: this.symbol,
name: this.name,
logo: this.logo,
circulating_supply: this.circulatingSupply,
total_supply: this.totalSupply,
max_supply: this.maxSupply,
market_cap_usd: this.marketCapUsd,
market_cap_rank: this.marketCapRank,
market_cap_24h_change: this.marketCap24hChange,
market_cap_24h_percent_change: this.marketCap24hPercentChange,
total_volume: this.totalVolume,
price_usd: this.priceUsd,
usd_price_24h_high: this.usdPrice24hHigh,
usd_price_24h_low: this.usdPrice24hLow,
usd_price_24h_change: this.usdPrice24hChange,
usd_price_24h_percent_change: this.usdPrice24hPercentChange,
usd_price_ath: this.usdPriceAth,
ath_percent_change: this.athPercentChange,
ath_date: this.athDate,
}
}
}
1 change: 1 addition & 0 deletions packages/common/evmUtils/src/generated/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export * from './EvmMarketDataERC20TokenItem';
export * from './EvmMarketDataERC20TokensByPriceMovers';
export * from './EvmMarketDataTopNFTCollectionByMarketCapItem';
export * from './EvmMarketDataHottestNFTCollectionByTradingVolumeItem';
export * from './EvmMarketDataTopCryptoCurrenciesByMarketCapItem';
export * from './EvmReviewContracts';
export * from './EvmContractsReviewDto';
export * from './EvmWalletActiveChains';
Expand Down
Loading

1 comment on commit 5caa827

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test coverage

Title Lines Statements Branches Functions
api-utils Coverage: 20%
20.6% (61/296) 20.48% (17/83) 19.04% (12/63)
auth Coverage: 89%
92.45% (98/106) 83.33% (20/24) 86.66% (26/30)
evm-api Coverage: 84%
85.71% (90/105) 66.66% (6/9) 78.87% (56/71)
common-aptos-utils Coverage: 4%
4.56% (151/3306) 4.49% (25/556) 5.53% (45/813)
common-evm-utils Coverage: 61%
61.84% (1799/2909) 23.04% (194/842) 41.53% (437/1052)
sol-api Coverage: 97%
97.56% (40/41) 66.66% (6/9) 93.75% (15/16)
common-sol-utils Coverage: 64%
65.42% (229/350) 41.86% (18/43) 50.89% (57/112)
common-streams-utils Coverage: 90%
90.73% (1204/1327) 73.63% (363/493) 82.07% (444/541)
streams Coverage: 91%
90.54% (603/666) 72.34% (68/94) 90.97% (131/144)

Please sign in to comment.