Skip to content

Commit

Permalink
Add functionCalls, refactor events, prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
pkudinov committed Jun 28, 2024
1 parent 5e6614f commit bc27e19
Show file tree
Hide file tree
Showing 12 changed files with 681 additions and 370 deletions.
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",
"keywords": [
"lake-primitives",
"near-indexer"
],
"author": "NEAR Inc <hello@nearprotocol.com>",
"description": "Near Protocol primitive datatypes utilized by near-lake-framework",
"author": "Data Platform <dataplatform@near.org>",
"description": "Near Protocol primitive datatypes utilized by near-lake-framework and QueryAPI",
"main": "dist/src/index.js",
"files": [
"/dist"
Expand Down
43 changes: 29 additions & 14 deletions packages/near-lake-primitives/src/helpers.ts
Original file line number Diff line number Diff line change
@@ -1,28 +1,43 @@
import { ExecutionStatus, ReceiptStatusFilter } from "./types/core/types";

function isMatchingReceiverSingle(receiverId: string, wildcardFilter: string) {
if (wildcardFilter === '*') {
export function isMatchingReceiverSingle(
receiverId: string,
wildcardFilter: string
) {
if (wildcardFilter === "*") {
return true;
}
const regExp = new RegExp(wildcardFilter
.replace(/\*/g, '[\\w\\d]+')
.replace(/./g, '\.')
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 isMatchingReceiver(
receiverId: string,
contractFilter: string
): boolean {
const filters = contractFilter.split(",").map((f) => f.trim());
return filters.some((f) => isMatchingReceiverSingle(receiverId, f));
}

export function isMatchingReceiptStatus(receiptStatus: ExecutionStatus, statusFilter: ReceiptStatusFilter): boolean {
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 "all":
return true;
case "onlySuccessful":
return receiptStatus.hasOwnProperty('SuccessValue')
|| receiptStatus.hasOwnProperty('SuccessReceiptId');
return isSuccessfulReceipt(receiptStatus);
case "onlyFailed":
return receiptStatus.hasOwnProperty('Failure');
return receiptStatus.hasOwnProperty("Failure");
}
}
}
Loading

0 comments on commit bc27e19

Please sign in to comment.