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

Add statusFilter to functionCallsToReceiver #63

Merged
merged 2 commits into from
Jul 23, 2024
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
5 changes: 5 additions & 0 deletions .changeset/fast-waves-tie.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@near-lake/primitives": minor
---

Add statusFilter to functionCallsToReceiver
19 changes: 6 additions & 13 deletions packages/near-lake-primitives/src/types/block.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
);
}

/**
Expand Down
Loading