Skip to content

Commit

Permalink
feat: update swagger. (#1224)
Browse files Browse the repository at this point in the history
  • Loading branch information
b4rtaz authored Jul 26, 2024
1 parent 738d7d5 commit 061df23
Show file tree
Hide file tree
Showing 17 changed files with 389 additions and 54 deletions.
7 changes: 7 additions & 0 deletions .changeset/rotten-months-care.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'@moralisweb3/common-evm-utils': minor
'@moralisweb3/evm-api': minor
'moralis': minor
---

Update SDK to reflect minor changes in the swagger file.
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,7 @@ export abstract class AbstractClient {
* @param request Request with parameters.
* @param {Object} [request.chain] The chain to query (optional)
* @param {Object} [request.include] If the result should contain the 24hr percent change (optional)
* @param {Number} [request.maxTokenInactivity] Exclude tokens inactive for more than the given amount of days (optional)
* @param body Request body.
* @param {Object[]} body.tokens The tokens to be fetched
* @returns {Object[]} Response for the request.
Expand Down Expand Up @@ -339,7 +340,7 @@ export abstract class AbstractClient {
* @description Retrieves a list of the top profitable wallets for a specific ERC20 token.
* @param request Request with parameters.
* @param {Object} request.address The ERC20 token address.
* @param {String} [request.days] Timeframe in days for which profitability is calculated, can be 'all', '7d' or '30d' (optional)
* @param {String} [request.days] Timeframe in days for which profitability is calculated, Options include 'all', '7', '30', '60', '90' default is 'all'. (optional)
* @param {Object} [request.chain] The chain to query (optional)
* @returns {Object} Response for the request.
*/
Expand Down Expand Up @@ -410,7 +411,6 @@ export abstract class AbstractClient {
* * If 'to_date' and 'to_block' are provided, 'to_block' will be used. (optional)
* @param {Boolean} [request.includeInternalTransactions] If the result should contain the internal transactions. (optional)
* @param {Boolean} [request.includeInputData] Set the input data from the result (optional)
* @param {Boolean} [request.includeLogsData] Set the logs data from the result (optional)
* @param {Boolean} [request.nftMetadata] If the result should contain the nft metadata. (optional)
* @param {String} [request.cursor] The cursor returned in the previous response (used for getting the next page). (optional)
* @param {Object} [request.order] The order of the result, in ascending (ASC) or descending (DESC) (optional)
Expand All @@ -435,6 +435,7 @@ export abstract class AbstractClient {
* @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)
* @param {Number} [request.maxTokenInactivity] Exclude tokens inactive for more than the given amount of days (optional)
* @returns {Object} Response for the request.
*/
getWalletTokenBalancesPrice: this.createEndpoint<
Expand All @@ -450,6 +451,7 @@ export abstract class AbstractClient {
* @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)
* @param {Number} [request.maxTokenInactivity] Exclude tokens inactive for more than the given amount of days (optional)
* @returns {Object} Response for the request.
*/
getWalletNetWorth: this.createEndpoint<
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { EvmGetMultipleTokenPricesDto, EvmGetMultipleTokenPricesDtoInput, EvmGet
// request parameters:
// - chain ($ref: #/components/schemas/chainList)
// - include ($ref: #/paths/~1erc20~1prices/post/parameters/1/schema)
// - max_token_inactivity ($ref: #/paths/~1erc20~1prices/post/parameters/2/schema)

export interface GetMultipleTokenPricesOperationRequest {
/**
Expand All @@ -16,11 +17,16 @@ export interface GetMultipleTokenPricesOperationRequest {
* @description If the result should contain the 24hr percent change
*/
readonly include?: EvmGetMultipleTokenPricesIncludeEnumInput | EvmGetMultipleTokenPricesIncludeEnumValue;
/**
* @description Exclude tokens inactive for more than the given amount of days
*/
readonly maxTokenInactivity?: number;
}

export interface GetMultipleTokenPricesOperationRequestJSON {
readonly chain?: EvmChainJSON;
readonly include?: EvmGetMultipleTokenPricesIncludeEnumJSON;
readonly max_token_inactivity?: number;
}

export type GetMultipleTokenPricesOperationResponse = EvmErc20Price[];
Expand All @@ -33,7 +39,7 @@ export const GetMultipleTokenPricesOperation = {
groupName: "token",
httpMethod: "post",
routePattern: "/erc20/prices",
parameterNames: ["chain","include"],
parameterNames: ["chain","include","max_token_inactivity"],
hasResponse: true,
hasBody: true,

Expand All @@ -44,9 +50,11 @@ export const GetMultipleTokenPricesOperation = {
serializeRequest(request: GetMultipleTokenPricesOperationRequest): GetMultipleTokenPricesOperationRequestJSON {
const chain = request.chain ? EvmChain.create(request.chain) : undefined;
const include = request.include ? EvmGetMultipleTokenPricesIncludeEnum.create(request.include) : undefined;
const maxTokenInactivity = request.maxTokenInactivity;
return {
chain: chain ? chain.toJSON() : undefined,
include: include ? include : undefined,
max_token_inactivity: maxTokenInactivity,
};
},

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export interface GetTopProfitableWalletPerTokenOperationRequest {
*/
readonly address: EvmAddressInput | EvmAddress;
/**
* @description Timeframe in days for which profitability is calculated, can be 'all', '7d' or '30d'
* @description Timeframe in days for which profitability is calculated, Options include 'all', '7', '30', '60', '90' default is 'all'.
*/
readonly days?: string;
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,10 @@ import { EvmWalletHistory, EvmWalletHistoryJSON } from '../types/EvmWalletHistor
// - address ($ref: #/paths/~1wallets~1{address}~1history/get/parameters/5/schema)
// - include_internal_transactions ($ref: #/paths/~1wallets~1{address}~1history/get/parameters/6/schema)
// - include_input_data ($ref: #/paths/~1wallets~1{address}~1history/get/parameters/7/schema)
// - include_logs_data ($ref: #/paths/~1wallets~1{address}~1history/get/parameters/8/schema)
// - nft_metadata ($ref: #/paths/~1wallets~1{address}~1history/get/parameters/9/schema)
// - cursor ($ref: #/paths/~1wallets~1{address}~1history/get/parameters/10/schema)
// - nft_metadata ($ref: #/paths/~1wallets~1{address}~1history/get/parameters/8/schema)
// - cursor ($ref: #/paths/~1wallets~1{address}~1history/get/parameters/9/schema)
// - order ($ref: #/components/schemas/orderList)
// - limit ($ref: #/paths/~1wallets~1{address}~1history/get/parameters/12/schema)
// - limit ($ref: #/paths/~1wallets~1{address}~1history/get/parameters/11/schema)

export interface GetWalletHistoryOperationRequest {
/**
Expand Down Expand Up @@ -58,10 +57,6 @@ export interface GetWalletHistoryOperationRequest {
* @description Set the input data from the result
*/
readonly includeInputData?: boolean;
/**
* @description Set the logs data from the result
*/
readonly includeLogsData?: boolean;
/**
* @description If the result should contain the nft metadata.
*/
Expand Down Expand Up @@ -89,7 +84,6 @@ export interface GetWalletHistoryOperationRequestJSON {
readonly address: EvmAddressJSON;
readonly include_internal_transactions?: boolean;
readonly include_input_data?: boolean;
readonly include_logs_data?: boolean;
readonly nft_metadata?: boolean;
readonly cursor?: string;
readonly order?: EvmOrderListJSON;
Expand All @@ -104,7 +98,7 @@ export const GetWalletHistoryOperation = {
groupName: "wallets",
httpMethod: "get",
routePattern: "/wallets/{address}/history",
parameterNames: ["chain","from_block","to_block","from_date","to_date","address","include_internal_transactions","include_input_data","include_logs_data","nft_metadata","cursor","order","limit"],
parameterNames: ["chain","from_block","to_block","from_date","to_date","address","include_internal_transactions","include_input_data","nft_metadata","cursor","order","limit"],
hasResponse: true,
hasBody: false,

Expand All @@ -121,7 +115,6 @@ export const GetWalletHistoryOperation = {
const address = EvmAddress.create(request.address);
const includeInternalTransactions = request.includeInternalTransactions;
const includeInputData = request.includeInputData;
const includeLogsData = request.includeLogsData;
const nftMetadata = request.nftMetadata;
const cursor = request.cursor;
const order = request.order ? EvmOrderList.create(request.order) : undefined;
Expand All @@ -135,7 +128,6 @@ export const GetWalletHistoryOperation = {
address: address.toJSON(),
include_internal_transactions: includeInternalTransactions,
include_input_data: includeInputData,
include_logs_data: includeLogsData,
nft_metadata: nftMetadata,
cursor: cursor,
order: order ? order : undefined,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { EvmNetWorthResult, EvmNetWorthResultJSON } from '../types/EvmNetWorthRe
// - 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)
// - max_token_inactivity ($ref: #/paths/~1wallets~1{address}~1net-worth/get/parameters/4/schema)

export interface GetWalletNetWorthOperationRequest {
/**
Expand All @@ -24,13 +25,18 @@ export interface GetWalletNetWorthOperationRequest {
* @description Exclude unverified contracts from the result
*/
readonly excludeUnverifiedContracts?: boolean;
/**
* @description Exclude tokens inactive for more than the given amount of days
*/
readonly maxTokenInactivity?: number;
}

export interface GetWalletNetWorthOperationRequestJSON {
readonly chains?: EvmChainJSON[];
readonly address: EvmAddressJSON;
readonly exclude_spam?: boolean;
readonly exclude_unverified_contracts?: boolean;
readonly max_token_inactivity?: number;
}

export type GetWalletNetWorthOperationResponse = EvmNetWorthResult;
Expand All @@ -41,7 +47,7 @@ export const GetWalletNetWorthOperation = {
groupName: "wallets",
httpMethod: "get",
routePattern: "/wallets/{address}/net-worth",
parameterNames: ["chains","address","exclude_spam","exclude_unverified_contracts"],
parameterNames: ["chains","address","exclude_spam","exclude_unverified_contracts","max_token_inactivity"],
hasResponse: true,
hasBody: false,

Expand All @@ -54,11 +60,13 @@ export const GetWalletNetWorthOperation = {
const address = EvmAddress.create(request.address);
const excludeSpam = request.excludeSpam;
const excludeUnverifiedContracts = request.excludeUnverifiedContracts;
const maxTokenInactivity = request.maxTokenInactivity;
return {
chains: chains ? chains.map((item) => item.toJSON()) : undefined,
address: address.toJSON(),
exclude_spam: excludeSpam,
exclude_unverified_contracts: excludeUnverifiedContracts,
max_token_inactivity: maxTokenInactivity,
};
},

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { EvmErc20TokenBalanceWithPriceResult, EvmErc20TokenBalanceWithPriceResul
// - 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)
// - max_token_inactivity ($ref: #/paths/~1wallets~1{address}~1tokens/get/parameters/9/schema)

export interface GetWalletTokenBalancesPriceOperationRequest {
/**
Expand Down Expand Up @@ -49,6 +50,10 @@ export interface GetWalletTokenBalancesPriceOperationRequest {
* @description Exclude native balance from the result
*/
readonly excludeNative?: boolean;
/**
* @description Exclude tokens inactive for more than the given amount of days
*/
readonly maxTokenInactivity?: number;
}

export interface GetWalletTokenBalancesPriceOperationRequestJSON {
Expand All @@ -61,6 +66,7 @@ export interface GetWalletTokenBalancesPriceOperationRequestJSON {
readonly cursor?: string;
readonly limit?: number;
readonly exclude_native?: boolean;
readonly max_token_inactivity?: number;
}

export type GetWalletTokenBalancesPriceOperationResponse = EvmErc20TokenBalanceWithPriceResult;
Expand All @@ -71,7 +77,7 @@ export const GetWalletTokenBalancesPriceOperation = {
groupName: "wallets",
httpMethod: "get",
routePattern: "/wallets/{address}/tokens",
parameterNames: ["chain","address","to_block","token_addresses","exclude_spam","exclude_unverified_contracts","cursor","limit","exclude_native"],
parameterNames: ["chain","address","to_block","token_addresses","exclude_spam","exclude_unverified_contracts","cursor","limit","exclude_native","max_token_inactivity"],
hasResponse: true,
hasBody: false,

Expand All @@ -89,6 +95,7 @@ export const GetWalletTokenBalancesPriceOperation = {
const cursor = request.cursor;
const limit = request.limit;
const excludeNative = request.excludeNative;
const maxTokenInactivity = request.maxTokenInactivity;
return {
chain: chain ? chain.toJSON() : undefined,
address: address.toJSON(),
Expand All @@ -99,6 +106,7 @@ export const GetWalletTokenBalancesPriceOperation = {
cursor: cursor,
limit: limit,
exclude_native: excludeNative,
max_token_inactivity: maxTokenInactivity,
};
},

Expand Down
63 changes: 63 additions & 0 deletions packages/common/evmUtils/src/generated/types/EvmDecodedEvent.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
import { EvmDecodedEventParamsItem, EvmDecodedEventParamsItemInput, EvmDecodedEventParamsItemJSON } from '../types/EvmDecodedEventParamsItem';

// $ref: #/components/schemas/decodedEvent
// type: decodedEvent
// properties:
// - signature ($ref: #/components/schemas/decodedEvent/properties/signature)
// - label ($ref: #/components/schemas/decodedEvent/properties/label)
// - type ($ref: #/components/schemas/decodedEvent/properties/type)
// - params ($ref: #/components/schemas/decodedEvent/properties/params/items)

export interface EvmDecodedEventJSON {
readonly signature?: string;
readonly label?: string;
readonly type?: string;
readonly params?: EvmDecodedEventParamsItemJSON[];
}

export interface EvmDecodedEventInput {
readonly signature?: string;
readonly label?: string;
readonly type?: string;
readonly params?: EvmDecodedEventParamsItemInput[] | EvmDecodedEventParamsItem[];
}

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

public static fromJSON(json: EvmDecodedEventJSON): EvmDecodedEvent {
const input: EvmDecodedEventInput = {
signature: json.signature,
label: json.label,
type: json.type,
params: json.params ? json.params.map((item) => EvmDecodedEventParamsItem.fromJSON(item)) : undefined,
};
return EvmDecodedEvent.create(input);
}

public readonly signature?: string;
public readonly label?: string;
public readonly type?: string;
public readonly params?: EvmDecodedEventParamsItem[];

private constructor(input: EvmDecodedEventInput) {
this.signature = input.signature;
this.label = input.label;
this.type = input.type;
this.params = input.params ? input.params.map((item) => EvmDecodedEventParamsItem.create(item)) : undefined;
}

public toJSON(): EvmDecodedEventJSON {
return {
signature: this.signature,
label: this.label,
type: this.type,
params: this.params ? this.params.map((item) => item.toJSON()) : undefined,
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
// $ref: #/components/schemas/decodedEvent/properties/params/items
// type: decodedEvent_params_Item
// properties:
// - name ($ref: #/components/schemas/decodedEvent/properties/params/items/properties/name)
// - value ($ref: #/components/schemas/decodedEvent/properties/params/items/properties/value)
// - type ($ref: #/components/schemas/decodedEvent/properties/params/items/properties/type)

export interface EvmDecodedEventParamsItemJSON {
readonly name?: string;
readonly value?: string;
readonly type?: string;
}

export interface EvmDecodedEventParamsItemInput {
readonly name?: string;
readonly value?: string;
readonly type?: string;
}

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

public static fromJSON(json: EvmDecodedEventParamsItemJSON): EvmDecodedEventParamsItem {
const input: EvmDecodedEventParamsItemInput = {
name: json.name,
value: json.value,
type: json.type,
};
return EvmDecodedEventParamsItem.create(input);
}

public readonly name?: string;
public readonly value?: string;
public readonly type?: string;

private constructor(input: EvmDecodedEventParamsItemInput) {
this.name = input.name;
this.value = input.value;
this.type = input.type;
}

public toJSON(): EvmDecodedEventParamsItemJSON {
return {
name: this.name,
value: this.value,
type: this.type,
}
}
}
Loading

1 comment on commit 061df23

@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: 76%
78.26% (90/115) 66.66% (6/9) 69.13% (56/81)
common-aptos-utils Coverage: 4%
4.56% (151/3306) 4.49% (25/556) 5.53% (45/813)
common-evm-utils Coverage: 54%
54.96% (2226/4050) 16.07% (172/1070) 36.24% (489/1349)
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.