///
import { Capacity } from "./miner/miner";
import Database from "./database";
import Emittery from "emittery";
import { BlockLogs, Account, StorageRangeAtResult, StructLog, TraceTransactionOptions } from "@ganache/ethereum-utils";
import { Common } from "@ethereumjs/common";
import { VM } from "@ethereumjs/vm";
import { EthereumInternalOptions } from "@ganache/ethereum-options";
import { Quantity, Data, Logger } from "@ganache/utils";
import AccountManager from "./data-managers/account-manager";
import BlockManager from "./data-managers/block-manager";
import BlockLogManager from "./data-managers/blocklog-manager";
import TransactionManager from "./data-managers/transaction-manager";
import { Fork } from "./forking/fork";
import { Address } from "@ganache/ethereum-address";
import { TypedTransaction } from "@ganache/ethereum-transaction";
import { Block } from "@ganache/ethereum-block";
import { SimulationTransaction, CallOverrides } from "./helpers/run-call";
import { GanacheTrie } from "./helpers/trie";
import { ForkTrie } from "./forking/trie";
import TransactionReceiptManager from "./data-managers/transaction-receipt-manager";
import { VmAfterTransactionEvent, VmBeforeTransactionEvent, VmConsoleLogEvent, VmStepEvent } from "./provider-events";
export declare enum Status {
started = 1,
starting = 2,
stopped = 4,
stopping = 8,
paused = 16
}
type BlockchainTypedEvents = {
block: Block;
blockLogs: BlockLogs;
pendingTransaction: TypedTransaction;
"ganache:vm:tx:step": VmStepEvent;
"ganache:vm:tx:before": VmBeforeTransactionEvent;
"ganache:vm:tx:after": VmAfterTransactionEvent;
"ganache:vm:tx:console.log": VmConsoleLogEvent;
ready: undefined;
stop: undefined;
};
export type BlockchainOptions = {
db?: string | object;
db_path?: string;
initialAccounts?: Account[];
hardfork?: string;
allowUnlimitedContractSize?: boolean;
allowUnlimitedInitCodeSize?: boolean;
gasLimit?: Quantity;
time?: Date;
blockTime?: number;
coinbase: Account;
chainId: number;
common: Common;
instamine: "eager" | "strict";
vmErrorsOnRPCResponse: boolean;
logger: Logger;
};
export default class Blockchain extends Emittery {
#private;
blocks: BlockManager;
blockLogs: BlockLogManager;
transactions: TransactionManager;
transactionReceipts: TransactionReceiptManager;
storageKeys: Database["storageKeys"];
accounts: AccountManager;
vm: VM;
trie: GanacheTrie;
common: Common;
fallback: Fork;
/**
* Initializes the underlying Database and handles synchronization between
* the API and the database.
*
* Emits a `ready` event once the database and all dependencies are fully
* initialized.
* @param options -
*/
constructor(options: EthereumInternalOptions, coinbase: Address, fallback?: Fork);
initialize(initialAccounts: Account[]): Promise;
coinbase: Address;
getMixHash(data: Buffer): Buffer;
isStarted: () => boolean;
mine: (maxTransactions: number | Capacity, onlyOneBlock?: boolean, timestamp?: number) => Promise<{
transactions: TypedTransaction[];
blockNumber: bigint;
}>;
pause(): void;
resume(_threads?: number): Promise<{
transactions: TypedTransaction[];
blockNumber: bigint;
}>;
createVmFromStateTrie: (stateTrie: GanacheTrie | ForkTrie, allowUnlimitedContractSize: boolean, activatePrecompile: boolean, common?: Common) => Promise;
/**
* @param milliseconds - the number of milliseconds to adjust the time by.
* Negative numbers are treated as 0.
* @returns the total time offset *in milliseconds*
*/
increaseTime(milliseconds: number): number;
/**
* Adjusts the internal time adjustment such that the provided time is considered the "current" time.
* @param newTime - the time (in milliseconds) that will be considered the "current" time
* @returns the total time offset *in milliseconds*
*/
setTimeDiff(newTime: number): number;
snapshot(): number;
revert(snapshotId: Quantity): Promise;
queueTransaction(transaction: TypedTransaction, secretKey?: Data): Promise;
simulateTransaction(transaction: SimulationTransaction, parentBlock: Block, overrides: CallOverrides): Promise;
isPostMerge: boolean;
/**
* traceTransaction
*
* Run a previously-run transaction in the same state in which it occurred at the time it was run.
* This will return the vm-level trace output for debugging purposes.
*
* Strategy:
*
* 1. Find block where transaction occurred
* 2. Set state root of that block
* 3. Rerun every transaction in that block prior to and including the requested transaction
* 4. Send trace results back.
*
* @param transactionHash -
* @param options -
*/
traceTransaction(transactionHash: string, options: TraceTransactionOptions): Promise<{
gas: Quantity;
structLogs: StructLog[];
returnValue: string;
storage: Record;
}>;
/**
* storageRangeAt
*
* Returns a contract's storage given a starting key and max number of
* entries to return.
*
*
* @param blockHash -
* @param txIndex -
* @param contractAddress -
* @param startKey -
* @param maxResult -
*/
storageRangeAt(blockHash: string, txIndex: number, contractAddress: string, startKey: string, maxResult: number): Promise;
toggleStepEvent(enable: boolean): void;
/**
* Gracefully shuts down the blockchain service and all of its dependencies.
*/
stop(): Promise;
}
export {};
//# sourceMappingURL=blockchain.d.ts.map