Skip to content

Commit

Permalink
delete totals and depreciated parameters.
Browse files Browse the repository at this point in the history
  • Loading branch information
b4rtaz committed Sep 9, 2023
1 parent d312b24 commit 04122f3
Show file tree
Hide file tree
Showing 59 changed files with 393 additions and 1,039 deletions.
26 changes: 16 additions & 10 deletions .changeset/light-mugs-promise.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,22 @@ This version implements [breaking changes](https://docs.moralis.io/changelog/ess

Deleted endpoints:

- `getErc20Approvals`
- `getErc20Burns`
- `getErc20Mints`
- `getErc20Transfers`
- `searchNFTs`
- `getErc20Approvals`,
- `getErc20Burns`,
- `getErc20Mints`,
- `getErc20Transfers`,
- `searchNFTs`.

New endpoints:

- `getBlockStats`
- `getNFTCollectionStats`
- `getNFTTokenStats`
- `getTokenStats`
- `getWalletStats`
- `getBlockStats`,
- `getNFTCollectionStats`,
- `getNFTTokenStats`,
- `getTokenStats`,
- `getWalletStats`.

Updated endpoints:

- `getTokenTransfers`, `getNFTs`, `getWalletNFTCollections`, `getNFTTrades`, `getNFTTransfers`, `getContractNFTTransfers`, `getNFTOwners`, `getTokenAddressTransfers`, `getWalletTokenIdTransfers`, `getAllTokenIds`, `getNFTTransfersFromToBlock`, `getNFTTransfersByBlock`, `getTokenIdOwners`, `getTransactions`, `getContractEvents` - the `total` field in the response is not available anymore, the `disable_total` parameter is now removed,
- `getNFTTransfers` - doesn't support the `direction` parameter anymore,
- `getLogsByAddress` - the `topic0` parameter is now required, `topic1`, `topic2` and `topic3` are now removed.
23 changes: 22 additions & 1 deletion demos/cli/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,28 @@ async function main() {
const blockStats = await Moralis.EvmApi.block.getBlockStats({
blockNumberOrHash: '18091265',
});
console.log(blockStats.result);
console.log('blockStats', blockStats.result.toJSON());

const nftCollectionStats = await Moralis.EvmApi.nft.getNFTCollectionStats({
address: '0x60e4d786628fea6478f785a6d7e704777c86a7c6',
});
console.log('nftCollectionStats', nftCollectionStats.result.toJSON());

const nftTokenStats = await Moralis.EvmApi.nft.getNFTTokenStats({
address: '0x60e4d786628fea6478f785a6d7e704777c86a7c6',
tokenId: '1',
});
console.log('nftTokenStats', nftTokenStats.result.toJSON());

const walletStats = await Moralis.EvmApi.wallets.getWalletStats({
address: '0xd8da6bf26964af9d7eed9e03e53415d37aa96045',
});
console.log('walletStats', walletStats.result.toJSON());

const tokenStats = await Moralis.EvmApi.token.getTokenStats({
address: '0x4a220e6096b25eadb88358cb44068a3248254675',
});
console.log('tokenStats', tokenStats.result.toJSON());
}

main();
2 changes: 1 addition & 1 deletion packages/common/evmUtils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
"clean": "rm -rf lib && rm -rf ./node_modules/.cache/nx",
"build": "rollup -c",
"dev": "tsc --watch",
"gen:api-types": "openapi-typescript https://deep-index.moralis.io/api-docs-2.1/v2.1/swagger.json --output src/operations/openapi.ts"
"gen:api-types": "openapi-typescript https://deep-index.moralis.io/api-docs-2.2/v2.2/swagger.json --output src/operations/openapi.ts"
},
"devDependencies": {
"@moralisweb3/eslint-config": "^1.0.3",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ describe('getContractEventsOperation', () => {
limit: 100,
offset: 0,
topic: 'topic0',
disableTotal: true,
cursor: '0xCURSOR',
};

Expand All @@ -48,7 +47,6 @@ describe('getContractEventsOperation', () => {
expect(serializedRequest.fromDate).toBe(fromDate);
expect(serializedRequest.toDate).toBe(toDate);
expect(serializedRequest.abi).toBe(request.abi);
expect(serializedRequest.disableTotal).toBe(true);
expect(serializedRequest.cursor).toBe(request.cursor);

const deserializedRequest = getContractEventsOperation.deserializeRequest(serializedRequest, core);
Expand All @@ -62,7 +60,6 @@ describe('getContractEventsOperation', () => {
expect(deserializedRequest.offset).toBe(request.offset);
expect(deserializedRequest.topic).toBe(request.topic);
expect(deserializedRequest.abi).toBe(request.abi);
expect(deserializedRequest.disableTotal).toBe(true);
expect(deserializedRequest.cursor).toBe(request.cursor);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -52,18 +52,7 @@ export const getContractEventsOperation: PaginatedOperation<
groupName: 'events',
urlPathPattern: '/{address}/events',
urlPathParamNames: ['address'],
urlSearchParamNames: [
'chain',
'fromBlock',
'toBlock',
'fromDate',
'toDate',
'topic',
'offset',
'limit',
'disableTotal',
'cursor',
],
urlSearchParamNames: ['chain', 'fromBlock', 'toBlock', 'fromDate', 'toDate', 'topic', 'offset', 'limit', 'cursor'],
bodyParamNames: ['abi'],
bodyType: 'raw',
firstPageIndex: 0,
Expand All @@ -88,7 +77,6 @@ function getRequestUrlParams(request: GetContractEventsRequest, core: Core) {
offset: maybe(request.offset, String),
limit: maybe(request.limit, String),
address: EvmAddress.create(request.address).lowercase,
disable_total: request.disableTotal,
cursor: request.cursor,
};
}
Expand Down Expand Up @@ -131,7 +119,6 @@ function serializeRequest(request: GetContractEventsRequest, core: Core) {
limit: request.limit,
address: EvmAddress.create(request.address).lowercase,
abi: request.abi,
disableTotal: request.disableTotal,
cursor: request.cursor,
};
}
Expand All @@ -148,7 +135,6 @@ function deserializeRequest(jsonRequest: GetContractEventsJSONRequest): GetContr
limit: jsonRequest.limit,
address: EvmAddress.create(jsonRequest.address),
abi: jsonRequest.abi,
disableTotal: jsonRequest.disableTotal,
cursor: jsonRequest.cursor,
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,8 @@ describe('getContractLogsOperation', () => {
address: EvmAddress.create(address),
limit: 100,
topic0: 'topic0',
topic1: 'topic1',
topic2: 'topic2',
topic3: 'topic3',
blockNumber: '123',
cursor: 'cursor',
disableTotal: true,
};

const serializedRequest = getContractLogsOperation.serializeRequest(request, core);
Expand All @@ -39,15 +35,11 @@ describe('getContractLogsOperation', () => {
expect(serializedRequest.blockNumber).toBe(request.blockNumber);
expect(serializedRequest.limit).toBe(request.limit);
expect(serializedRequest.topic0).toBe(request.topic0);
expect(serializedRequest.topic1).toBe(request.topic1);
expect(serializedRequest.topic2).toBe(request.topic2);
expect(serializedRequest.topic3).toBe(request.topic3);
expect(serializedRequest.toBlock).toBe(request.toBlock);
expect(serializedRequest.fromDate).toBe(fromDate);
expect(serializedRequest.toDate).toBe(toDate);
expect(serializedRequest.cursor).toBe(request.cursor);
expect(serializedRequest.fromBlock).toBe(request.fromBlock);
expect(serializedRequest.disableTotal).toBe(true);

const deserializedRequest = getContractLogsOperation.deserializeRequest(serializedRequest, core);

Expand All @@ -59,11 +51,7 @@ describe('getContractLogsOperation', () => {
expect(deserializedRequest.limit).toBe(request.limit);
expect(deserializedRequest.cursor).toBe(request.cursor);
expect(deserializedRequest.topic0).toBe(request.topic0);
expect(deserializedRequest.topic1).toBe(request.topic1);
expect(deserializedRequest.topic2).toBe(request.topic2);
expect(deserializedRequest.topic3).toBe(request.topic3);
expect(deserializedRequest.blockNumber).toBe(request.blockNumber);
expect(deserializedRequest.fromBlock).toBe(request.fromBlock);
expect(deserializedRequest.disableTotal).toBe(true);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,8 @@ export const getContractLogsOperation: PaginatedOperation<
'fromDate',
'toDate',
'topic0',
'topic1',
'topic2',
'topic3',
'limit',
'cursor',
'disableTotal',
],
firstPageIndex: 0,

Expand All @@ -85,13 +81,9 @@ function getRequestUrlParams(request: GetContractLogsRequest, core: Core) {
from_date: request.fromDate ? new Date(request.fromDate).toISOString() : undefined,
to_date: request.toDate ? new Date(request.toDate).toISOString() : undefined,
topic0: request.topic0,
topic1: request.topic1,
topic2: request.topic2,
topic3: request.topic3,
limit: maybe(request.limit, String),
cursor: request.cursor,
address: EvmAddress.create(request.address).lowercase,
disable_total: request.disableTotal,
};
}

Expand All @@ -104,13 +96,9 @@ function serializeRequest(request: GetContractLogsRequest, core: Core) {
fromDate: request.fromDate ? new Date(request.fromDate).toISOString() : undefined,
toDate: request.toDate ? new Date(request.toDate).toISOString() : undefined,
topic0: request.topic0,
topic1: request.topic1,
topic2: request.topic2,
topic3: request.topic3,
limit: request.limit,
cursor: request.cursor,
address: EvmAddress.create(request.address).lowercase,
disableTotal: request.disableTotal,
};
}

Expand All @@ -123,13 +111,9 @@ function deserializeRequest(jsonRequest: GetContractLogsJSONRequest): GetContrac
fromDate: jsonRequest.fromDate ? new Date(jsonRequest.fromDate) : undefined,
toDate: jsonRequest.toDate ? new Date(jsonRequest.toDate) : undefined,
topic0: jsonRequest.topic0,
topic1: jsonRequest.topic1,
topic2: jsonRequest.topic2,
topic3: jsonRequest.topic3,
limit: jsonRequest.limit,
cursor: jsonRequest.cursor,
address: EvmAddress.create(jsonRequest.address),
disableTotal: jsonRequest.disableTotal,
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ describe('getContractNfTsOperation', () => {
range: 20,
totalRanges: 10,
normalizeMetadata: false,
disableTotal: true,
mediaItems: true,
};

Expand All @@ -36,7 +35,6 @@ describe('getContractNfTsOperation', () => {
expect(serializedRequest.range).toBe(request.range);
expect(serializedRequest.totalRanges).toBe(request.totalRanges);
expect(serializedRequest.normalizeMetadata).toBe(request.normalizeMetadata);
expect(serializedRequest.disableTotal).toBe(true);

const deserializedRequest = getContractNFTsOperation.deserializeRequest(serializedRequest, core);

Expand All @@ -48,6 +46,5 @@ describe('getContractNfTsOperation', () => {
expect(deserializedRequest.range).toBe(request.range);
expect(deserializedRequest.totalRanges).toBe(request.totalRanges);
expect(deserializedRequest.normalizeMetadata).toBe(request.normalizeMetadata);
expect(deserializedRequest.disableTotal).toBe(true);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ export const getContractNFTsOperation: PaginatedOperation<
'range',
'cursor',
'normalizeMetadata',
'disableTotal',
'mediaItems',
],
firstPageIndex: 0,
Expand All @@ -81,7 +80,6 @@ function getRequestUrlParams(request: GetContractNFTsRequest, core: Core) {
range: maybe(request.range, String),
cursor: request.cursor,
normalizeMetadata: request.normalizeMetadata,
disable_total: request.disableTotal,
media_items: request.mediaItems,
};
}
Expand Down Expand Up @@ -116,7 +114,6 @@ function serializeRequest(request: GetContractNFTsRequest, core: Core) {
cursor: request.cursor,
address: EvmAddress.create(request.address).checksum,
normalizeMetadata: request.normalizeMetadata,
disableTotal: request.disableTotal,
mediaItems: request.mediaItems,
};
}
Expand All @@ -131,7 +128,6 @@ function deserializeRequest(jsonRequest: GetContractNFTsJSONRequest): GetContrac
cursor: jsonRequest.cursor,
address: EvmAddress.create(jsonRequest.address),
normalizeMetadata: jsonRequest.normalizeMetadata,
disableTotal: jsonRequest.disableTotal,
mediaItems: jsonRequest.mediaItems,
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ describe('getNftContractTransfersOperation', () => {
toBlock: 16225608,
toDate: new Date(toDate),
fromDate: new Date(fromDate),
disableTotal: true,
};

const serializedRequest = getNFTContractTransfersOperation.serializeRequest(request, core);
Expand All @@ -38,7 +37,6 @@ describe('getNftContractTransfersOperation', () => {
expect(serializedRequest.toBlock).toBe(request.toBlock);
expect(serializedRequest.fromDate).toBe(fromDate);
expect(serializedRequest.toDate).toBe(toDate);
expect(serializedRequest.disableTotal).toBe(true);

const deserializedRequest = getNFTContractTransfersOperation.deserializeRequest(serializedRequest, core);

Expand All @@ -51,6 +49,5 @@ describe('getNftContractTransfersOperation', () => {
expect(deserializedRequest.toBlock).toBe(request.toBlock);
expect((deserializedRequest.fromDate as Date | undefined)?.toISOString()).toBe(fromDate);
expect((deserializedRequest.toDate as Date | undefined)?.toISOString()).toBe(toDate);
expect(deserializedRequest.disableTotal).toBe(true);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -51,17 +51,7 @@ export const getNFTContractTransfersOperation: PaginatedOperation<
groupName: 'nft',
urlPathPattern: '/nft/{address}/transfers',
urlPathParamNames: ['address'],
urlSearchParamNames: [
'chain',
'format',
'limit',
'cursor',
'fromBlock',
'fromDate',
'toBlock',
'toDate',
'disableTotal',
],
urlSearchParamNames: ['chain', 'format', 'limit', 'cursor', 'fromBlock', 'fromDate', 'toBlock', 'toDate'],
firstPageIndex: 0,
getRequestUrlParams,
serializeRequest,
Expand All @@ -82,7 +72,6 @@ function getRequestUrlParams(request: GetNFTContractTransfersRequest, core: Core
to_block: maybe(request.toBlock, String),
to_date: request.toDate ? new Date(request.toDate).toISOString() : undefined,
cursor: request.cursor,
disable_total: request.disableTotal,
};
}

Expand Down Expand Up @@ -116,7 +105,6 @@ function serializeRequest(request: GetNFTContractTransfersRequest, core: Core) {
toBlock: request.toBlock,
fromDate: request.fromDate ? new Date(request.fromDate).toISOString() : undefined,
toDate: request.toDate ? new Date(request.toDate).toISOString() : undefined,
disableTotal: request.disableTotal,
};
}

Expand All @@ -131,6 +119,5 @@ function deserializeRequest(jsonRequest: GetNFTContractTransfersJSONRequest): Ge
toBlock: jsonRequest.toBlock,
fromDate: jsonRequest.fromDate ? new Date(jsonRequest.fromDate) : undefined,
toDate: jsonRequest.toDate ? new Date(jsonRequest.toDate) : undefined,
disableTotal: jsonRequest.disableTotal,
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ describe('getNFTOwnersOperation', () => {
limit: 100,
cursor: 'CURSOR1',
normalizeMetadata: false,
disableTotal: true,
mediaItems: true,
};

Expand All @@ -32,7 +31,6 @@ describe('getNFTOwnersOperation', () => {
expect(serializedRequest.limit).toBe(request.limit);
expect(serializedRequest.cursor).toBe(request.cursor);
expect(serializedRequest.normalizeMetadata).toBe(request.normalizeMetadata);
expect(serializedRequest.disableTotal).toBe(true);

const deserializedRequest = getNFTOwnersOperation.deserializeRequest(serializedRequest, core);

Expand All @@ -42,6 +40,5 @@ describe('getNFTOwnersOperation', () => {
expect(deserializedRequest.limit).toBe(request.limit);
expect(deserializedRequest.cursor).toBe(request.cursor);
expect(deserializedRequest.normalizeMetadata).toBe(request.normalizeMetadata);
expect(deserializedRequest.disableTotal).toBe(true);
});
});
Loading

0 comments on commit 04122f3

Please sign in to comment.