Skip to content

Commit

Permalink
💥 Fix: some breaking changes
Browse files Browse the repository at this point in the history
  • Loading branch information
roninjin10 committed Oct 18, 2024
1 parent a0622ee commit bb0ffd9
Show file tree
Hide file tree
Showing 19 changed files with 87 additions and 179 deletions.
4 changes: 2 additions & 2 deletions packages/address/src/create2ContractAddress.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { create2ContractAddress } from './create2ContractAddress.js'

describe('create2ContractAddress', () => {
it('should create a valid contract address using CREATE2', () => {
const from = EthjsAddress.fromString(`0x${'11'.repeat(20)}`)
const from = new EthjsAddress(hexToBytes(`0x${'11'.repeat(20)}`))
const salt = `0x${'00'.repeat(32)}` as const
const code = `0x${'60'.repeat(10)}` as const
const expectedAddress = keccak256(
Expand All @@ -21,7 +21,7 @@ describe('create2ContractAddress', () => {
})

it('should throw InvalidSaltError if salt is not 32 bytes', () => {
const from = EthjsAddress.fromString(`0x${'11'.repeat(20)}`)
const from = new EthjsAddress(hexToBytes(`0x${'11'.repeat(20)}`))
const invalidSalt = `0x${'00'.repeat(16)}` as const
const code = `0x${'60'.repeat(10)}` as const

Expand Down
8 changes: 4 additions & 4 deletions packages/address/src/createContractAddress.spec.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { InvalidAddressError } from '@tevm/errors'
import { EthjsAddress, keccak256, toRlp } from '@tevm/utils'
import { numberToBytes } from 'viem'
import { keccak256, toRlp } from '@tevm/utils'
import { hexToBytes, numberToBytes } from 'viem'
import { describe, expect, it } from 'vitest'
import { Address } from './Address.js'
import { createContractAddress } from './createContractAddress.js'

describe('createContractAddress', () => {
it('should create a valid contract address with nonce 0', () => {
const from = EthjsAddress.fromString(`0x${'11'.repeat(20)}`)
const from = new Address(hexToBytes(`0x${'11'.repeat(20)}`))
const nonce = 0n
const expectedAddress = keccak256(toRlp([from.bytes, Uint8Array.from([])]), 'bytes').subarray(-20)

Expand All @@ -18,7 +18,7 @@ describe('createContractAddress', () => {
})

it('should create a valid contract address with a non-zero nonce', () => {
const from = EthjsAddress.fromString(`0x${'22'.repeat(20)}`)
const from = new Address(hexToBytes(`0x${'22'.repeat(20)}`))
const nonce = 1n
const expectedAddress = keccak256(toRlp([from.bytes, numberToBytes(nonce)]), 'bytes').subarray(-20)

Expand Down
2 changes: 1 addition & 1 deletion packages/common/docs/globals.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions packages/common/docs/interfaces/EvmStateManagerInterface.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 3 additions & 5 deletions packages/common/src/createCommon.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Common } from '@ethereumjs/common'
import { createCustomCommon } from '@ethereumjs/common'
import { InvalidParamsError } from '@tevm/errors'
import { createLogger } from '@tevm/logger'
import { createMockKzg } from './createMockKzg.js'
Expand Down Expand Up @@ -59,15 +59,13 @@ export const createCommon = ({
}) => {
try {
const logger = createLogger({ level: loggingLevel, name: '@tevm/common' })
const ethjsCommon = Common.custom(
const ethjsCommon = createCustomCommon(
{
name: 'TevmCustom',
chainId: chain.id,
// TODO what is diff between chainId and networkId???
networkId: chain.id,
},
{
hardfork,
hardfork: hardfork,
baseChain: 1,
eips: [...eips, 1559, 4895, 4844, 4788],
customCrypto: {
Expand Down
2 changes: 1 addition & 1 deletion packages/common/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export type { Common } from './Common.js'
export {
type CustomCrypto,
type StorageDump,
type EVMStateManagerInterface as EvmStateManagerInterface,
type StateManagerInterface as StateManagerInterface,
type AccountFields,
type StorageRange,
ConsensusAlgorithm,
Expand Down
92 changes: 0 additions & 92 deletions packages/errors/src/ethereum/ethereumjs/AuthCallUnsetError.js

This file was deleted.

1 change: 0 additions & 1 deletion packages/errors/src/ethereum/ethereumjs/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// index.ts

export { AuthCallUnsetError, type AuthCallUnsetErrorParameters } from './AuthCallUnsetError.js'
export { BLS12381FpNotInFieldError, type BLS12381FpNotInFieldErrorParameters } from './BLS12381FpNotInFieldError.js'
export { BLS12381InputEmptyError, type BLS12381InputEmptyErrorParameters } from './BLS12381InputEmptyError.js'
export {
Expand Down
2 changes: 0 additions & 2 deletions packages/errors/src/ethereum/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,6 @@ export { UnknownBlockError, type UnknownBlockErrorParameters } from './UnknownBl
export { UnsupportedChainError, type UnsupportedChainErrorParameters } from './UnsupportedChainError.js'
export { AccountNotFoundError } from './AccountNotFoundError.js'
export {
AuthCallUnsetError,
type AuthCallUnsetErrorParameters,
BLS12381FpNotInFieldError,
type BLS12381FpNotInFieldErrorParameters,
BLS12381InputEmptyError,
Expand Down
2 changes: 0 additions & 2 deletions packages/errors/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,6 @@ export {
InternalEvmError,
InvalidJumpError,
InvalidProofError,
AuthCallUnsetError,
StackOverflowError,
InvalidJumpSubError,
StackUnderflowError,
Expand All @@ -162,7 +161,6 @@ export {
type InvalidJumpErrorParameters,
CodeSizeExceedsMaximumError,
type InvalidProofErrorParameters,
type AuthCallUnsetErrorParameters,
BLS12381PointNotOnCurveError,
type StackOverflowErrorParameters,
type InvalidJumpSubErrorParameters,
Expand Down
2 changes: 1 addition & 1 deletion packages/evm/docs/interfaces/InterpreterStep.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit bb0ffd9

Please sign in to comment.