Skip to content

Commit

Permalink
fix: add missing fields to response of getWalletTokenBalancesPrice.
Browse files Browse the repository at this point in the history
  • Loading branch information
b4rtaz committed Jul 31, 2024
1 parent 24376d1 commit 0672a58
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 13 deletions.
7 changes: 7 additions & 0 deletions .changeset/six-bananas-crash.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 missing fields to the response of the `getWalletTokenBalancesPrice` endpoint.
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,6 @@ export abstract class AbstractClient {
* * Provide the param 'to_block' or 'to_date'
* * 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.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 Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,10 @@ import { EvmWalletHistory, EvmWalletHistoryJSON } from '../types/EvmWalletHistor
// - to_date ($ref: #/paths/~1wallets~1{address}~1history/get/parameters/4/schema)
// - 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)
// - nft_metadata ($ref: #/paths/~1wallets~1{address}~1history/get/parameters/8/schema)
// - cursor ($ref: #/paths/~1wallets~1{address}~1history/get/parameters/9/schema)
// - nft_metadata ($ref: #/paths/~1wallets~1{address}~1history/get/parameters/7/schema)
// - cursor ($ref: #/paths/~1wallets~1{address}~1history/get/parameters/8/schema)
// - order ($ref: #/components/schemas/orderList)
// - limit ($ref: #/paths/~1wallets~1{address}~1history/get/parameters/11/schema)
// - limit ($ref: #/paths/~1wallets~1{address}~1history/get/parameters/10/schema)

export interface GetWalletHistoryOperationRequest {
/**
Expand Down Expand Up @@ -53,10 +52,6 @@ export interface GetWalletHistoryOperationRequest {
* @description If the result should contain the internal transactions.
*/
readonly includeInternalTransactions?: boolean;
/**
* @description Set the input data from the result
*/
readonly includeInputData?: boolean;
/**
* @description If the result should contain the nft metadata.
*/
Expand All @@ -83,7 +78,6 @@ export interface GetWalletHistoryOperationRequestJSON {
readonly to_date?: string;
readonly address: EvmAddressJSON;
readonly include_internal_transactions?: boolean;
readonly include_input_data?: boolean;
readonly nft_metadata?: boolean;
readonly cursor?: string;
readonly order?: EvmOrderListJSON;
Expand All @@ -98,7 +92,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","nft_metadata","cursor","order","limit"],
parameterNames: ["chain","from_block","to_block","from_date","to_date","address","include_internal_transactions","nft_metadata","cursor","order","limit"],
hasResponse: true,
hasBody: false,

Expand All @@ -114,7 +108,6 @@ export const GetWalletHistoryOperation = {
const toDate = request.toDate;
const address = EvmAddress.create(request.address);
const includeInternalTransactions = request.includeInternalTransactions;
const includeInputData = request.includeInputData;
const nftMetadata = request.nftMetadata;
const cursor = request.cursor;
const order = request.order ? EvmOrderList.create(request.order) : undefined;
Expand All @@ -127,7 +120,6 @@ export const GetWalletHistoryOperation = {
to_date: toDate !== undefined ? toDate.toISOString() : undefined,
address: address.toJSON(),
include_internal_transactions: includeInternalTransactions,
include_input_data: includeInputData,
nft_metadata: nftMetadata,
cursor: cursor,
order: order ? order : undefined,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ import { EvmAddress, EvmAddressInput, EvmAddressJSON, EvmNative, EvmNativeInput,
// - portfolio_percentage ($ref: #/components/schemas/erc20TokenBalanceWithPrice/properties/portfolio_percentage)
// - balance_formatted ($ref: #/components/schemas/erc20TokenBalanceWithPrice/properties/balance_formatted)
// - native_token ($ref: #/components/schemas/erc20TokenBalanceWithPrice/properties/native_token)
// - total_supply ($ref: #/components/schemas/erc20TokenBalanceWithPrice/properties/total_supply)
// - total_supply_formatted ($ref: #/components/schemas/erc20TokenBalanceWithPrice/properties/total_supply_formatted)
// - percentage_relative_to_total_supply ($ref: #/components/schemas/erc20TokenBalanceWithPrice/properties/percentage_relative_to_total_supply)

export interface EvmErc20TokenBalanceWithPriceJSON {
readonly token_address?: EvmAddressJSON;
Expand All @@ -39,6 +42,9 @@ export interface EvmErc20TokenBalanceWithPriceJSON {
readonly portfolio_percentage: number;
readonly balance_formatted: string;
readonly native_token: boolean;
readonly total_supply?: string;
readonly total_supply_formatted?: string;
readonly percentage_relative_to_total_supply?: number;
}

export interface EvmErc20TokenBalanceWithPriceInput {
Expand All @@ -59,6 +65,9 @@ export interface EvmErc20TokenBalanceWithPriceInput {
readonly portfolioPercentage: number;
readonly balanceFormatted: string;
readonly nativeToken: boolean;
readonly totalSupply?: string;
readonly totalSupplyFormatted?: string;
readonly percentageRelativeToTotalSupply?: number;
}

export class EvmErc20TokenBalanceWithPrice {
Expand Down Expand Up @@ -88,6 +97,9 @@ export class EvmErc20TokenBalanceWithPrice {
portfolioPercentage: json.portfolio_percentage,
balanceFormatted: json.balance_formatted,
nativeToken: json.native_token,
totalSupply: json.total_supply,
totalSupplyFormatted: json.total_supply_formatted,
percentageRelativeToTotalSupply: json.percentage_relative_to_total_supply,
};
return EvmErc20TokenBalanceWithPrice.create(input);
}
Expand Down Expand Up @@ -160,6 +172,18 @@ export class EvmErc20TokenBalanceWithPrice {
* @description Indicates if the token is a native coin
*/
public readonly nativeToken: boolean;
/**
* @description Total supply of the token
*/
public readonly totalSupply?: string;
/**
* @description Total supply of the token in decimal format
*/
public readonly totalSupplyFormatted?: string;
/**
* @description Percentage of the token in the total supply
*/
public readonly percentageRelativeToTotalSupply?: number;

private constructor(input: EvmErc20TokenBalanceWithPriceInput) {
this.tokenAddress = input.tokenAddress ? EvmAddress.create(input.tokenAddress) : undefined;
Expand All @@ -179,6 +203,9 @@ export class EvmErc20TokenBalanceWithPrice {
this.portfolioPercentage = input.portfolioPercentage;
this.balanceFormatted = input.balanceFormatted;
this.nativeToken = input.nativeToken;
this.totalSupply = input.totalSupply;
this.totalSupplyFormatted = input.totalSupplyFormatted;
this.percentageRelativeToTotalSupply = input.percentageRelativeToTotalSupply;
}

public toJSON(): EvmErc20TokenBalanceWithPriceJSON {
Expand All @@ -200,6 +227,9 @@ export class EvmErc20TokenBalanceWithPrice {
portfolio_percentage: this.portfolioPercentage,
balance_formatted: this.balanceFormatted,
native_token: this.nativeToken,
total_supply: this.totalSupply,
total_supply_formatted: this.totalSupplyFormatted,
percentage_relative_to_total_supply: this.percentageRelativeToTotalSupply,
}
}
}

0 comments on commit 0672a58

Please sign in to comment.