UNPKG

@near-lake/primitives

Version:

Near Protocol primitive datatypes utilized by near-lake-framework and QueryAPI

212 lines (211 loc) 7.14 kB
import { ExecutionOutcomeWithReceipt, ExecutionStatus, ReceiptView } from "./core/types"; import { Events, Event } from "./events"; /** * This field is a simplified representation of the `ReceiptView` structure from [near-primitives](https://github.com/near/nearcore/tree/master/core/primitives). */ export declare class Receipt implements Events { /** * Defined the type of the `Receipt`: `Action` or `Data` representing the `ActionReceipt` and `DataReceipt`. */ readonly receiptKind: ReceiptKind; /** * The ID of the `Receipt` of the `CryptoHash` type. */ readonly receiptId: string; /** * The receiver account id of the `Receipt`. */ readonly receiverId: string; /** * The predecessor account id of the `Receipt`. */ readonly predecessorId: string; /** * Represents the status of `ExecutionOutcome` of the `Receipt`. */ readonly status: ExecutionStatus; /** * The id of the `ExecutionOutcome` for the `Receipt`. Returns `null` if the `Receipt` isn’t executed yet and has a postponed status. */ readonly executionOutcomeId?: string | undefined; /** * The original logs of the corresponding `ExecutionOutcome` of the `Receipt`. * * **Note:** not all the logs might be parsed as JSON Events (`Events`). */ readonly logs: string[]; constructor( /** * Defined the type of the `Receipt`: `Action` or `Data` representing the `ActionReceipt` and `DataReceipt`. */ receiptKind: ReceiptKind, /** * The ID of the `Receipt` of the `CryptoHash` type. */ receiptId: string, /** * The receiver account id of the `Receipt`. */ receiverId: string, /** * The predecessor account id of the `Receipt`. */ predecessorId: string, /** * Represents the status of `ExecutionOutcome` of the `Receipt`. */ status: ExecutionStatus, /** * The id of the `ExecutionOutcome` for the `Receipt`. Returns `null` if the `Receipt` isn’t executed yet and has a postponed status. */ executionOutcomeId?: string | undefined, /** * The original logs of the corresponding `ExecutionOutcome` of the `Receipt`. * * **Note:** not all the logs might be parsed as JSON Events (`Events`). */ logs?: string[]); /** * Returns an Array of `Events` for the `Receipt`, if any. This might be empty if the `logs` field is empty or doesn’t contain JSON Events compatible log records. */ get events(): Event[]; static fromOutcomeWithReceipt: (outcomeWithReceipt: ExecutionOutcomeWithReceipt) => Receipt; } /** * `ReceiptKind` a simple `enum` to represent the `Receipt` type: either `Action` or `Data`. */ export declare enum ReceiptKind { Action = "Action", Data = "Data" } /** * `Action` is the structure with the fields and data relevant to an `ActionReceipt`. * * Basically, `Action` is the structure that indexer developers will be encouraged to work the most in their action-oriented indexers. */ export declare class Action { /** * The id of the corresponding `Receipt` */ readonly receiptId: string; /** * The status of the corresponding `Receipt` */ readonly receiptStatus: ExecutionStatus; /** * The predecessor account id of the corresponding `Receipt`. * This field is a piece of denormalization of the structures (`Receipt` and `Action`). */ readonly predecessorId: string; /** * The receiver account id of the corresponding `Receipt`. * This field is a piece of denormalization of the structures (`Receipt` and `Action`). */ readonly receiverId: string; /** * The signer account id of the corresponding `Receipt` */ readonly signerId: string; /** * The signer’s PublicKey for the corresponding `Receipt` */ readonly signerPublicKey: string; /** * An array of `Operation` for this `ActionReceipt` */ readonly operations: Operation[]; /** * An array of log messages for this `ActionReceipt` */ readonly logs: string[]; constructor( /** * The id of the corresponding `Receipt` */ receiptId: string, /** * The status of the corresponding `Receipt` */ receiptStatus: ExecutionStatus, /** * The predecessor account id of the corresponding `Receipt`. * This field is a piece of denormalization of the structures (`Receipt` and `Action`). */ predecessorId: string, /** * The receiver account id of the corresponding `Receipt`. * This field is a piece of denormalization of the structures (`Receipt` and `Action`). */ receiverId: string, /** * The signer account id of the corresponding `Receipt` */ signerId: string, /** * The signer’s PublicKey for the corresponding `Receipt` */ signerPublicKey: string, /** * An array of `Operation` for this `ActionReceipt` */ operations: Operation[], /** * An array of log messages for this `ActionReceipt` */ logs?: string[]); /** * An array of events complying to NEP-0297 standard for this `ActionReceipt` */ get events(): Event[]; static isActionReceipt: (receipt: ReceiptView) => any; static fromOutcomeWithReceipt: (outcomeWithReceipt: ExecutionOutcomeWithReceipt) => Action | null; } export declare class DeployContract { readonly code: Uint8Array; constructor(code: Uint8Array); } export declare class FunctionCall { readonly methodName: string; readonly args: string; readonly gas: number; readonly deposit: string; constructor(methodName: string, args: string, gas: number, deposit: string); } export declare class Transfer { readonly deposit: string; constructor(deposit: string); } export declare class Stake { readonly stake: number; readonly publicKey: string; constructor(stake: number, publicKey: string); } export declare class AddKey { readonly publicKey: string; readonly accessKey: AccessKey; constructor(publicKey: string, accessKey: AccessKey); } export declare class DeleteKey { readonly publicKey: string; constructor(publicKey: string); } export declare class DeleteAccount { readonly beneficiaryId: string; constructor(beneficiaryId: string); } /** * A representation of the original `ActionView` from [near-primitives](https://github.com/near/nearcore/tree/master/core/primitives). */ export type Operation = "CreateAccount" | DeployContract | FunctionCall | Transfer | Stake | AddKey | DeleteKey | DeleteAccount; export declare class AccessKey { readonly nonce: number; readonly permission: string | AccessKeyFunctionCallPermission; constructor(nonce: number, permission: string | AccessKeyFunctionCallPermission); } declare class AccessKeyFunctionCallPermission { readonly allowance: string; readonly receiverId: string; readonly methodNames: string[]; constructor(allowance: string, receiverId: string, methodNames: string[]); } export {};