Skip to content

Commit

Permalink
Feat/update get top profitable wallet per token return object (#1222)
Browse files Browse the repository at this point in the history
* feat: Update getTopProfitableWalletPerToken return type
* fix: patch description
  • Loading branch information
gabkk authored Jul 12, 2024
1 parent 212e202 commit 7b334bf
Show file tree
Hide file tree
Showing 5 changed files with 119 additions and 7 deletions.
7 changes: 7 additions & 0 deletions .changeset/serious-olives-divide.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
---

Update `getTopProfitableWalletPerToken` return objects.
11 changes: 11 additions & 0 deletions packages/common/evmUtils/src/generated/types/EvmNetWorthResult.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,26 @@
import { EvmChainNetWorth, EvmChainNetWorthInput, EvmChainNetWorthJSON } from '../types/EvmChainNetWorth';
import { EvmUnavailableChainNetWorth, EvmUnavailableChainNetWorthInput, EvmUnavailableChainNetWorthJSON } from '../types/EvmUnavailableChainNetWorth';

// $ref: #/components/schemas/netWorthResult
// type: netWorthResult
// properties:
// - total_networth_usd ($ref: #/components/schemas/netWorthResult/properties/total_networth_usd)
// - chains ($ref: #/components/schemas/chainNetWorth)
// - unsupported_chain_ids ($ref: #/components/schemas/netWorthResult/properties/unsupported_chain_ids)
// - unavailable_chains ($ref: #/components/schemas/unavailableChainNetWorth)

export interface EvmNetWorthResultJSON {
readonly total_networth_usd: string;
readonly chains: EvmChainNetWorthJSON[];
readonly unsupported_chain_ids?: string[];
readonly unavailable_chains?: EvmUnavailableChainNetWorthJSON[];
}

export interface EvmNetWorthResultInput {
readonly totalNetworthUsd: string;
readonly chains: EvmChainNetWorthInput[] | EvmChainNetWorth[];
readonly unsupportedChainIds?: string[];
readonly unavailableChains?: EvmUnavailableChainNetWorthInput[] | EvmUnavailableChainNetWorth[];
}

export class EvmNetWorthResult {
Expand All @@ -32,6 +36,7 @@ export class EvmNetWorthResult {
totalNetworthUsd: json.total_networth_usd,
chains: json.chains.map((item) => EvmChainNetWorth.fromJSON(item)),
unsupportedChainIds: json.unsupported_chain_ids,
unavailableChains: json.unavailable_chains ? json.unavailable_chains.map((item) => EvmUnavailableChainNetWorth.fromJSON(item)) : undefined,
};
return EvmNetWorthResult.create(input);
}
Expand All @@ -45,18 +50,24 @@ export class EvmNetWorthResult {
* @description The chain ids that are not supported
*/
public readonly unsupportedChainIds?: string[];
/**
* @description The chains that are not available during the request
*/
public readonly unavailableChains?: EvmUnavailableChainNetWorth[];

private constructor(input: EvmNetWorthResultInput) {
this.totalNetworthUsd = input.totalNetworthUsd;
this.chains = input.chains.map((item) => EvmChainNetWorth.create(item));
this.unsupportedChainIds = input.unsupportedChainIds;
this.unavailableChains = input.unavailableChains ? input.unavailableChains.map((item) => EvmUnavailableChainNetWorth.create(item)) : undefined;
}

public toJSON(): EvmNetWorthResultJSON {
return {
total_networth_usd: this.totalNetworthUsd,
chains: this.chains.map((item) => item.toJSON()),
unsupported_chain_ids: this.unsupportedChainIds,
unavailable_chains: this.unavailableChains ? this.unavailableChains.map((item) => item.toJSON()) : undefined,
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
// $ref: #/components/schemas/unavailableChainNetWorth
// type: unavailableChainNetWorth
// properties:
// - chain_id ($ref: #/components/schemas/unavailableChainNetWorth/properties/chain_id)

export interface EvmUnavailableChainNetWorthJSON {
readonly chain_id: string;
}

export interface EvmUnavailableChainNetWorthInput {
readonly chainId: string;
}

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

public static fromJSON(json: EvmUnavailableChainNetWorthJSON): EvmUnavailableChainNetWorth {
const input: EvmUnavailableChainNetWorthInput = {
chainId: json.chain_id,
};
return EvmUnavailableChainNetWorth.create(input);
}

/**
* @description The chain id
*/
public readonly chainId: string;

private constructor(input: EvmUnavailableChainNetWorthInput) {
this.chainId = input.chainId;
}

public toJSON(): EvmUnavailableChainNetWorthJSON {
return {
chain_id: this.chainId,
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,29 @@ import { EvmTopProfitableWalletPerTokenResponse, EvmTopProfitableWalletPerTokenR
// $ref: #/components/schemas/WalletTopProfitableWalletPerTokenResponse
// type: WalletTopProfitableWalletPerTokenResponse
// properties:
// - wallets ($ref: #/components/schemas/TopProfitableWalletPerTokenResponse)
// - name ($ref: #/components/schemas/WalletTopProfitableWalletPerTokenResponse/properties/name)
// - symbol ($ref: #/components/schemas/WalletTopProfitableWalletPerTokenResponse/properties/symbol)
// - decimals ($ref: #/components/schemas/WalletTopProfitableWalletPerTokenResponse/properties/decimals)
// - logo ($ref: #/components/schemas/WalletTopProfitableWalletPerTokenResponse/properties/logo)
// - possible_spam ($ref: #/components/schemas/WalletTopProfitableWalletPerTokenResponse/properties/possible_spam)
// - result ($ref: #/components/schemas/TopProfitableWalletPerTokenResponse)

export interface EvmWalletTopProfitableWalletPerTokenResponseJSON {
readonly wallets: EvmTopProfitableWalletPerTokenResponseJSON[];
readonly name: string;
readonly symbol: string;
readonly decimals: number;
readonly logo: string;
readonly possible_spam: boolean;
readonly result: EvmTopProfitableWalletPerTokenResponseJSON[];
}

export interface EvmWalletTopProfitableWalletPerTokenResponseInput {
readonly wallets: EvmTopProfitableWalletPerTokenResponseInput[] | EvmTopProfitableWalletPerTokenResponse[];
readonly name: string;
readonly symbol: string;
readonly decimals: number;
readonly logo: string;
readonly possibleSpam: boolean;
readonly result: EvmTopProfitableWalletPerTokenResponseInput[] | EvmTopProfitableWalletPerTokenResponse[];
}

export class EvmWalletTopProfitableWalletPerTokenResponse {
Expand All @@ -23,23 +38,58 @@ export class EvmWalletTopProfitableWalletPerTokenResponse {

public static fromJSON(json: EvmWalletTopProfitableWalletPerTokenResponseJSON): EvmWalletTopProfitableWalletPerTokenResponse {
const input: EvmWalletTopProfitableWalletPerTokenResponseInput = {
wallets: json.wallets.map((item) => EvmTopProfitableWalletPerTokenResponse.fromJSON(item)),
name: json.name,
symbol: json.symbol,
decimals: json.decimals,
logo: json.logo,
possibleSpam: json.possible_spam,
result: json.result.map((item) => EvmTopProfitableWalletPerTokenResponse.fromJSON(item)),
};
return EvmWalletTopProfitableWalletPerTokenResponse.create(input);
}

/**
* @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 Indicates if a contract is possibly a spam contract
*/
public readonly possibleSpam: boolean;
/**
* @description List of top profitable wallets per token.
*/
public readonly wallets: EvmTopProfitableWalletPerTokenResponse[];
public readonly result: EvmTopProfitableWalletPerTokenResponse[];

private constructor(input: EvmWalletTopProfitableWalletPerTokenResponseInput) {
this.wallets = input.wallets.map((item) => EvmTopProfitableWalletPerTokenResponse.create(item));
this.name = input.name;
this.symbol = input.symbol;
this.decimals = input.decimals;
this.logo = input.logo;
this.possibleSpam = input.possibleSpam;
this.result = input.result.map((item) => EvmTopProfitableWalletPerTokenResponse.create(item));
}

public toJSON(): EvmWalletTopProfitableWalletPerTokenResponseJSON {
return {
wallets: this.wallets.map((item) => item.toJSON()),
name: this.name,
symbol: this.symbol,
decimals: this.decimals,
logo: this.logo,
possible_spam: this.possibleSpam,
result: this.result.map((item) => item.toJSON()),
}
}
}
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 @@ -54,6 +54,7 @@ export * from './EvmErc20TokenOwner';
export * from './EvmWalletHistoryTransaction';
export * from './EvmErc20TokenBalanceWithPrice';
export * from './EvmChainNetWorth';
export * from './EvmUnavailableChainNetWorth';
export * from './EvmErc20Metadata';
export * from './EvmContractsReviewItem';
export * from './EvmDefiProtocolBalance';
Expand Down

1 comment on commit 7b334bf

@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%
55.37% (2210/3991) 16.19% (172/1062) 36.45% (487/1336)
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.