Skip to content

Commit

Permalink
Some more solid/qualified EVM dummy blockchain + interface naming to …
Browse files Browse the repository at this point in the history
…allow for exporting
  • Loading branch information
holgerd77 committed Aug 17, 2024
1 parent 57cad15 commit b903ad4
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
4 changes: 2 additions & 2 deletions packages/evm/src/constructors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Common, Mainnet } from '@ethereumjs/common'
import { SimpleStateManager } from '@ethereumjs/statemanager'

import { NobleBN254 } from './precompiles/index.js'
import { DefaultBlockchain } from './types.js'
import { EVMMockBlockchain } from './types.js'

import { EVM } from './index.js'

Expand All @@ -25,7 +25,7 @@ export async function createEVM(createOpts?: EVMOpts) {
}

if (opts.blockchain === undefined) {
opts.blockchain = new DefaultBlockchain()
opts.blockchain = new EVMMockBlockchain()
}

if (opts.stateManager === undefined) {
Expand Down
16 changes: 10 additions & 6 deletions packages/evm/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -343,9 +343,13 @@ export interface EVMOpts {
stateManager?: StateManagerInterface

/**
* The EVM comes with a basic mock blockchain interface and implementation for
* non-block containing use cases.
*
* For block-containing setups use the full blockchain implementation from the
* `@ethereumjs/blockchain package.
*/
blockchain?: Blockchain
blockchain?: EVMMockBlockchainInterface

/**
*
Expand Down Expand Up @@ -472,16 +476,16 @@ export interface TransientStorageInterface {
clear(): void
}

type MockBlock = {
export type EVMMockBlock = {
hash(): Uint8Array
}

export interface Blockchain {
getBlock(blockId: number): Promise<MockBlock>
shallowCopy(): Blockchain
export interface EVMMockBlockchainInterface {
getBlock(blockId: number): Promise<EVMMockBlock>
shallowCopy(): EVMMockBlockchainInterface
}

export class DefaultBlockchain implements Blockchain {
export class EVMMockBlockchain implements EVMMockBlockchainInterface {
async getBlock() {
return {
hash() {
Expand Down

0 comments on commit b903ad4

Please sign in to comment.