Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/update get top profitable wallet per token return object #1222

Merged
merged 2 commits into from
Jul 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
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
Loading