NEAR Lake Primitive Types
This article contains the primitive types used by the NEAR Lake Framework package. These types are used to define the data structures used by the framework as well as provide some popular helper functions.
Block
Block
- All the entities located on different shards were merged into one single list without differentiation.
Block
is not the fairest name for this structure either. NEAR Protocol is a sharded blockchain, so its block is actually an ephemeral structure that represents a collection of real blocks called chunks in NEAR Protocol.
Block
Structure Definition
The Block
type is used to represent a block in the NEAR Lake Framework. It is comprised by the following structure:
export class Block {
constructor(
readonly streamerMessage: StreamerMessage,
private executedReceipts: Receipt[],
readonly postponedReceipts: Receipt[],
readonly transactions: Transaction[],
private _actions: Map<string, Action>,
private _events: Map<string, Event[]>,
private _stateChanges: StateChange[]) {
}
... // helper methods and getters omitted for brevity
}
streamerMessage
Low-level structure for backward compatibility. As implemented in previous versions of near-lake-framework
.
postponedReceipts
Receipts included on the chain but not executed yet marked as “postponed”: they are represented by the same structure Receipt
(see the corresponding section in this doc for more details).
transactions
List of included Transactions
, converted into Receipts
.
Note: You might want to know about Transactions
to know where the action chain has begun. Unlike Ethereum, where a Transaction contains everything you may want to know about a particular interaction on the Ethereum blockchain, Near Protocol because of its asynchronous nature converts a Transaction
into a Receipt
before executing it. Thus, On NEAR, Receipts
are more important for figuring out what happened on-chain as a result of a Transaction signed by a user. Read more about Transactions on Near here.
Block
Helper Methods
export class Block {
... // constructor omitted for brevity
get blockHash(): string {}
get prevBlockHash(): string {}
get blockHeight(): number {}
header(): BlockHeader {}
receipts(): Receipt[] {}
actions(): Action[] {}
events(): Event[] {}
stateChanges(): StateChange[] {}
actionByReceiptId(receipt_id: string): Action | undefined {}
eventsByReceiptId(receipt_id: string): Event[] {}
eventsByAccountId(account_id: string): Event[] {}
private buildActionsHashmap() {}
private buildEventsHashmap(): Map<string, Event[]> {}
static fromStreamerMessage(streamerMessage: StreamerMessage): Block {}
}
blockHash
Returns the block hash. A shortcut to get the data from the block header.
prevBlockHash
Returns the previous block hash. A shortcut to get the data from the block header.
blockHeight
Returns the block height. A shortcut to get the data from the block header.
header(): BlockHeader
Returns a BlockHeader
structure of the block
See BlockHeader
structure sections for details.
receipts(): Receipt[]
Returns a slice of Receipts
executed in the block.
Basically is a getter for the executedReceipts
field.
actions(): Action[]
Returns an Array of Actions
executed in the block.
events(): Event[]
Returns Events
emitted in the block.
stateChanges(): StateChange[]
Returns an Array of StateChange
occurred in the block.