@near-lake/framework
TypeScript icon, indicating that this package has built-in type declarations

0.1.4 • Public • Published

NEAR Lake Framework

NEAR Lake Framework is a syntactical framework for accessing the NEAR Lake Indexer Data. It is a wrapper around the AWS API.

Has @near-lake/primitives as a dependency, which contains the types for the data with associated helper functions.

Simple Example

import { startStream, types } from '@near-lake/framework';

const lakeConfig: types.LakeConfig = {
    s3BucketName: 'near-lake-data-mainnet',
    s3RegionName: 'eu-central-1',
    startBlockHeight: 66264389,
};

async function handleBlock(
    block: types.Block,
    context: types.LakeContext
): Promise<void> {
    // custom logic for handling the block
    let events = block.eventsByAccountId("x.paras.near")
    console.log(events)
}

(async () => {
    await startStream(lakeConfig, handleStreamerMessage);
})();

The main function in this example is handleBlock(block, context), which contains custom logic for how to handle a given block. block is of type Block from @near-lake/primitives which gives access to helper methods to make it easier to extract data. You may find a list of helper functions here.

Package Sidebar

Install

npm i @near-lake/framework

Weekly Downloads

24

Version

0.1.4

License

(MIT OR Apache-2.0)

Unpacked Size

21.3 kB

Total Files

12

Last publish

Collaborators

  • roshaan
  • nearmorgan