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: updated getBlockStats. #1166

Merged
merged 1 commit into from
Sep 12, 2023
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/silly-mugs-agree.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
---

Updated the response of the `getBlockStats` endpoint.
Original file line number Diff line number Diff line change
@@ -1,24 +1,20 @@
import { EvmBlockTokenStatTransactions, EvmBlockTokenStatTransactionsInput, EvmBlockTokenStatTransactionsJSON } from '../types/EvmBlockTokenStatTransactions';
import { EvmBlockTokenStatNftTransfers, EvmBlockTokenStatNftTransfersInput, EvmBlockTokenStatNftTransfersJSON } from '../types/EvmBlockTokenStatNftTransfers';
import { EvmBlockTokenStatTokenTransfers, EvmBlockTokenStatTokenTransfersInput, EvmBlockTokenStatTokenTransfersJSON } from '../types/EvmBlockTokenStatTokenTransfers';

// $ref: #/components/schemas/blockTokenStat
// type: blockTokenStat
// properties:
// - transactions ($ref: #/components/schemas/blockTokenStat/properties/transactions)
// - nft_transfers ($ref: #/components/schemas/blockTokenStat/properties/nft_transfers)
// - token_transfers ($ref: #/components/schemas/blockTokenStat/properties/token_transfers)

export interface EvmBlockTokenStatJSON {
readonly transactions: EvmBlockTokenStatTransactionsJSON;
readonly nft_transfers: EvmBlockTokenStatNftTransfersJSON;
readonly token_transfers: EvmBlockTokenStatTokenTransfersJSON;
}

export interface EvmBlockTokenStatInput {
readonly transactions: EvmBlockTokenStatTransactionsInput | EvmBlockTokenStatTransactions;
readonly nftTransfers: EvmBlockTokenStatNftTransfersInput | EvmBlockTokenStatNftTransfers;
readonly tokenTransfers: EvmBlockTokenStatTokenTransfersInput | EvmBlockTokenStatTokenTransfers;
}

export class EvmBlockTokenStat {
Expand All @@ -33,7 +29,6 @@ export class EvmBlockTokenStat {
const input: EvmBlockTokenStatInput = {
transactions: EvmBlockTokenStatTransactions.fromJSON(json.transactions),
nftTransfers: EvmBlockTokenStatNftTransfers.fromJSON(json.nft_transfers),
tokenTransfers: EvmBlockTokenStatTokenTransfers.fromJSON(json.token_transfers),
};
return EvmBlockTokenStat.create(input);
}
Expand All @@ -46,22 +41,16 @@ export class EvmBlockTokenStat {
* @description NFT transfer stats
*/
public readonly nftTransfers: EvmBlockTokenStatNftTransfers;
/**
* @description Token transfer stats
*/
public readonly tokenTransfers: EvmBlockTokenStatTokenTransfers;

private constructor(input: EvmBlockTokenStatInput) {
this.transactions = EvmBlockTokenStatTransactions.create(input.transactions);
this.nftTransfers = EvmBlockTokenStatNftTransfers.create(input.nftTransfers);
this.tokenTransfers = EvmBlockTokenStatTokenTransfers.create(input.tokenTransfers);
}

public toJSON(): EvmBlockTokenStatJSON {
return {
transactions: this.transactions.toJSON(),
nft_transfers: this.nftTransfers.toJSON(),
token_transfers: this.tokenTransfers.toJSON(),
}
}
}

This file was deleted.

1 change: 0 additions & 1 deletion packages/common/evmUtils/src/generated/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,4 @@ export * from './EvmNftTokenStatTransfers';
export * from './EvmErc20TokenStatTransfers';
export * from './EvmBlockTokenStatTransactions';
export * from './EvmBlockTokenStatNftTransfers';
export * from './EvmBlockTokenStatTokenTransfers';
export * from './EvmTransactionTimestamp';
Loading