casper-js-sdk
Version:
SDK to interact with the Casper blockchain
277 lines (276 loc) • 8.04 kB
TypeScript
import { Hash, TransferHash, Key } from './key';
import { InitiatorAddr } from './InitiatorAddr';
import { Transfer } from './Transfer';
import { Transform, TransformKey } from './Transform';
import { Message } from './MessageTopic';
/**
* Represents an operation performed during a transaction.
*/
export declare class Operation {
/**
* The key associated with the operation.
*/
key: Key;
/**
* The type of the operation (e.g., "Write", "Transfer").
*/
kind: string;
}
/**
* Represents the effect of a transaction, including the operations and transformations.
*/
export declare class Effect {
/**
* The operations performed as part of this effect.
*/
operations: Operation[];
/**
* The transformations applied as part of this effect.
*/
transforms: TransformKey[];
}
/**
* Contains the result of a transaction's execution, including the effect and related transfers.
*/
export declare class ExecutionResultStatusData {
/**
* The effect of the transaction execution, including operations and transformations.
*/
effect: Effect;
/**
* The transfers that were part of the transaction execution.
*/
transfers: TransferHash[];
/**
* The cost of the transaction execution.
*/
cost: number;
/**
* The error message, if any, generated during the transaction execution.
*/
errorMessage: string;
}
/**
* Represents version 2 of the execution result, containing more detailed information.
*/
export declare class ExecutionResultV2 {
/**
* The address of the initiator of the execution.
*/
initiator: InitiatorAddr;
/**
* The error message, if any, generated during the execution.
*/
errorMessage?: string;
/**
* The execution limit for the transaction.
*/
limit: number;
/**
* The amount of resources consumed during the transaction execution.
*/
consumed: number;
refund: number;
/**
* The gas price of the era.
*/
currentPrice: number;
/**
* The cost associated with the transaction execution.
*/
cost: number;
/**
* The payment made for the transaction, if any.
*/
payment?: any;
/**
* The transfers included in the transaction execution.
*/
transfers: Transfer[];
/**
* The estimated size of the transaction execution.
*/
sizeEstimate: number;
/**
* The effects applied during the transaction execution.
*/
effects: Transform[];
}
/**
* Represents version 1 of the execution result, containing basic information on success or failure.
*/
export declare class ExecutionResultV1 {
/**
* The status data for a successful execution.
*/
success?: ExecutionResultStatusData;
/**
* The status data for a failed execution.
*/
failure?: ExecutionResultStatusData;
}
/**
* Contains the block hash and execution result of a deploy execution.
*/
export declare class DeployExecutionResult {
/**
* The block hash where the deploy was executed.
*/
blockHash: Hash;
/**
* The execution result for the deploy.
*/
result: ExecutionResultV1;
}
/**
* Represents the result of a transaction execution, which includes the initiator, cost, transfers, and effects.
*/
export declare class ExecutionResult {
/**
* The address of the initiator of the execution.
*/
initiator: InitiatorAddr;
/**
* The error message, if any, generated during the execution.
*/
errorMessage?: string;
/**
* The execution limit for the transaction.
*/
limit: number;
/**
* The amount of resources consumed during the transaction execution.
*/
consumed: number;
refund: number;
/**
* The gas price of the era.
*/
currentPrice: number;
/**
* The cost associated with the transaction execution.
*/
cost: number;
/**
* The payment made for the transaction, if any.
*/
payment?: any;
/**
* The transfers included in the transaction execution.
*/
transfers: Transfer[];
/**
* The estimated size of the transaction execution.
*/
sizeEstimate: number;
/**
* The effects applied during the transaction execution.
*/
effects: Transform[];
/**
* The original execution result in version 1 format, if applicable.
*/
originExecutionResultV1?: ExecutionResultV1;
/**
* The original execution result in version 2 format, if applicable.
*/
originExecutionResultV2?: ExecutionResultV2;
/**
* Deserializes an `ExecutionResult` from JSON data.
* Supports both version 1 and version 2 formats.
*
* @param data The JSON data representing the execution result.
* @returns The deserialized `ExecutionResult`.
* @throws Error if the data format is invalid or unknown.
*/
static fromJSON(data: any): ExecutionResult;
/**
* Creates an `ExecutionResult` from version 1 of the execution result.
*
* @param v1 The version 1 execution result.
* @returns The `ExecutionResult` created from version 1 data.
*/
static fromV1(v1: ExecutionResultV1): ExecutionResult;
/**
* Converts an `ExecutionResult` instance to a plain JSON object.
*
* This method serializes an `ExecutionResult` object into a plain JSON structure
* using the `TypedJSON` serializer. It allows for easy conversion of the
* `ExecutionResult` to a JSON-compatible format that can be used for logging,
* transmission over the network, or storage.
*
* @param executionResult - The `ExecutionResult` instance to be converted into a plain JSON object.
*
* @returns A plain JSON object representing the `ExecutionResult`.
*
*/
static toJSON(executionResult: ExecutionResult): import("typedjson").JsonTypes;
}
export declare class SpeculativeExecutionResult {
blockHash: Hash;
/**
* The transfers included in the transaction execution.
*/
transfers: Transfer[];
/**
* The execution limit for the transaction.
*/
limit: number;
/**
* The amount of resources consumed during the transaction execution.
*/
consumed: number;
/**
* The effects applied during the transaction execution.
*/
effects: Transform[];
messages: Message[];
/**
* The error message, if any, generated during the execution.
*/
errorMessage?: string;
}
/**
* Represents execution information about a deploy, including the block hash, height, and execution result.
*/
export declare class ExecutionInfo {
/**
* The block hash where the deploy was executed.
*/
blockHash: Hash;
/**
* The block height at the time the deploy was executed.
*/
blockHeight: number;
/**
* The execution result associated with the deploy.
*/
executionResult: ExecutionResult;
constructor(blockHash: Hash, blockHeight: number, executionResult: ExecutionResult);
static fromV1(results: DeployExecutionResult[], height?: number): ExecutionInfo;
}
/**
* Represents execution information for a deploy, including the block hash, height, and execution result.
*/
export declare class DeployExecutionInfo {
/**
* The block hash where the deploy was executed.
*/
blockHash: Hash;
/**
* The block height at the time the deploy was executed.
*/
blockHeight: number;
/**
* The execution result associated with the deploy.
*/
executionResult: ExecutionResult;
/**
* Creates a `DeployExecutionInfo` instance from version 1 data.
*
* @param results The results of the deploy execution.
* @param height The block height, if available.
* @returns The `DeployExecutionInfo` instance created from version 1 data.
*/
static fromV1(results: DeployExecutionResult[], height?: number): DeployExecutionInfo;
}