Skip to content

Commit

Permalink
feat: cursor property for getContractEvents.
Browse files Browse the repository at this point in the history
  • Loading branch information
b4rtaz committed Aug 17, 2023
1 parent ee426bc commit a1dca27
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
7 changes: 7 additions & 0 deletions .changeset/dirty-hotels-sparkle.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
---

Extend the arguments of the `getContractEvents` endpoint to include the `cursor` property.
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ describe('getContractEventsOperation', () => {
offset: 0,
topic: 'topic0',
disableTotal: true,
cursor: '0xCURSOR',
};

const serializedRequest = getContractEventsOperation.serializeRequest(request, core);
Expand All @@ -48,6 +49,7 @@ describe('getContractEventsOperation', () => {
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 @@ -61,5 +63,6 @@ describe('getContractEventsOperation', () => {
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 @@ -27,6 +27,7 @@ export interface GetContractEventsRequest
abi: EvmAbiItem;
fromDate?: DateInput;
toDate?: DateInput;
cursor?: string;
}

export type GetContractEventsJSONRequest = ReturnType<typeof serializeRequest>;
Expand Down Expand Up @@ -61,6 +62,7 @@ export const getContractEventsOperation: PaginatedOperation<
'offset',
'limit',
'disableTotal',
'cursor',
],
bodyParamNames: ['abi'],
bodyType: 'raw',
Expand All @@ -87,6 +89,7 @@ function getRequestUrlParams(request: GetContractEventsRequest, core: Core) {
limit: maybe(request.limit, String),
address: EvmAddress.create(request.address).lowercase,
disable_total: request.disableTotal,
cursor: request.cursor,
};
}

Expand Down Expand Up @@ -129,6 +132,7 @@ function serializeRequest(request: GetContractEventsRequest, core: Core) {
address: EvmAddress.create(request.address).lowercase,
abi: request.abi,
disableTotal: request.disableTotal,
cursor: request.cursor,
};
}

Expand All @@ -145,5 +149,6 @@ function deserializeRequest(jsonRequest: GetContractEventsJSONRequest): GetContr
address: EvmAddress.create(jsonRequest.address),
abi: jsonRequest.abi,
disableTotal: jsonRequest.disableTotal,
cursor: jsonRequest.cursor,
};
}

0 comments on commit a1dca27

Please sign in to comment.