From a8fc6bcf61cfddf29f0ec349760952973f616cb2 Mon Sep 17 00:00:00 2001 From: pkudinov Date: Thu, 18 Jul 2024 16:06:44 -0700 Subject: [PATCH 1/2] Add statusFilter to functionCallsToReceiver --- .../near-lake-primitives/src/types/block.ts | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/packages/near-lake-primitives/src/types/block.ts b/packages/near-lake-primitives/src/types/block.ts index 6d3a244..edd2d7a 100644 --- a/packages/near-lake-primitives/src/types/block.ts +++ b/packages/near-lake-primitives/src/types/block.ts @@ -137,23 +137,16 @@ export class Block { * Returns an Array of function calls to receivers matching receiverFilter. * @param receiverFilter - filter by contract name (e.g. `*.pool.near,*.poolv1.near`). Default is `*` (all contracts). * @param method - name of the method to filter by. Returns all function calls to receiverFilter if not provided. + * @param statusFilter - filter by receipt status (all|onlySuccessful|onlyFailed). Default is `onlySuccessful`. */ functionCallsToReceiver( receiverFilter = "*", - method?: string + method?: string, + statusFilter: ReceiptStatusFilter = "onlySuccessful" ): FunctionCallView[] { - return this.actions() - .filter((action) => isMatchingReceiver(action.receiverId, receiverFilter)) - .flatMap((a) => - a.operations - .filter((op) => op.hasOwnProperty("FunctionCall")) - .filter((op) => - method ? Object(op).FunctionCall.methodName === method : true - ) - .map((op) => - FunctionCallView.fromFunctionCall(Object(op).FunctionCall, a) - ) - ); + return this.functionCalls(receiverFilter, statusFilter).filter((call) => + method ? call.methodName === method : true + ); } /** From 2c93adc2f6df5e9b4bc1e401a928bb6a1b9a64d9 Mon Sep 17 00:00:00 2001 From: pkudinov Date: Thu, 18 Jul 2024 16:09:36 -0700 Subject: [PATCH 2/2] Add changeset --- .changeset/fast-waves-tie.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/fast-waves-tie.md diff --git a/.changeset/fast-waves-tie.md b/.changeset/fast-waves-tie.md new file mode 100644 index 0000000..e30833a --- /dev/null +++ b/.changeset/fast-waves-tie.md @@ -0,0 +1,5 @@ +--- +"@near-lake/primitives": minor +--- + +Add statusFilter to functionCallsToReceiver