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

Implement function calls, improve events #61

Merged
merged 4 commits into from
Jul 15, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"type": "git",
"url": "git+https://github.com/near/near-lake-framework-js.git"
},
"homepage": "https://near-indexers.io",
"homepage": "https://docs.near.org/concepts/advanced/near-lake-framework",
"scripts": {
"build": "turbo run build",
"clean": "turbo run clean",
Expand Down
6 changes: 3 additions & 3 deletions packages/near-lake-primitives/package.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
"name": "@near-lake/primitives",
"version": "0.4.0",
"version": "0.5.0",
morgsmccauley marked this conversation as resolved.
Show resolved Hide resolved
"keywords": [
"lake-primitives",
"near-indexer"
],
"author": "NEAR Inc <[email protected]>",
"description": "Near Protocol primitive datatypes utilized by near-lake-framework",
"author": "Data Platform <[email protected]>",
"description": "Near Protocol primitive datatypes utilized by near-lake-framework and QueryAPI",
"main": "dist/src/index.js",
"files": [
"/dist"
Expand Down
43 changes: 43 additions & 0 deletions packages/near-lake-primitives/src/helpers.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import { ExecutionStatus, ReceiptStatusFilter } from "./types/core/types";

export function isMatchingReceiverSingle(
receiverId: string,
wildcardFilter: string
) {
if (wildcardFilter === "*") {
return true;
}
const regExp = new RegExp(
wildcardFilter.replace(/\*/g, "[\\w\\d]+").replace(/\./g, "\\.")
);
return regExp.test(receiverId);
}

export function isMatchingReceiver(
receiverId: string,
contractFilter: string
): boolean {
const filters = contractFilter.split(",").map((f) => f.trim());
return filters.some((f) => isMatchingReceiverSingle(receiverId, f));
}

export function isSuccessfulReceipt(receiptStatus: ExecutionStatus): boolean {
return (
receiptStatus.hasOwnProperty("SuccessValue") ||
receiptStatus.hasOwnProperty("SuccessReceiptId")
);
}

export function isMatchingReceiptStatus(
receiptStatus: ExecutionStatus,
statusFilter: ReceiptStatusFilter
): boolean {
switch (statusFilter) {
case "all":
return true;
case "onlySuccessful":
return isSuccessfulReceipt(receiptStatus);
case "onlyFailed":
return receiptStatus.hasOwnProperty("Failure");
}
}
Loading
Loading