-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement function calls, improve events (#61)
* Implement function calls and blockDate * Add functionCalls, refactor events, prettier * chore: Revert manual package bump * chore: Add changeset --------- Co-authored-by: Morgan Mccauley <[email protected]>
- Loading branch information
1 parent
d33ca61
commit 7971e99
Showing
14 changed files
with
772 additions
and
333 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
--- | ||
"@near-lake/primitives": minor | ||
--- | ||
|
||
Added: | ||
- `Block.functionCalls` to get an array of FunctionCallView in this block, with different filters | ||
- `Block.functionCallsToReceiver` to get an array of FunctionCallView to a specific receiver, optionally specifying method name | ||
- `FunctionCallView` type that provides complete information about the function call, including parsed arguments and events | ||
|
||
Changed: | ||
- `Event` class has been changed to inline RawEvent fields. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,8 +5,8 @@ | |
"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" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"); | ||
} | ||
} |
Oops, something went wrong.