Skip to content

Commit 5b7a4dc

Browse files
committed
fix(evm): use relative transaction imports and extend EvmTypeError helpers
Add a changeset for ethereum-types and evm patch releases.
1 parent 4696e1d commit 5b7a4dc

7 files changed

Lines changed: 39 additions & 18 deletions

File tree

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
"@evm-effect/ethereum-types": patch
3+
"@evm-effect/evm": patch
4+
---
5+
6+
- Add `EvmTypeError.invalidValue` and `EvmTypeError.invalidSize` static factory helpers.
7+
- Fix incorrect `packages/evm/src/` import paths to relative imports across evm internals and state tests.
Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,23 @@
1+
import { bufferToHex } from "@evm-effect/shared/bytes";
12
import { Data } from "effect";
23

34
export class EvmTypeError extends Data.TaggedError("EvmTypeError")<{
45
readonly message: string;
56
readonly input?: unknown;
6-
}> {}
7+
}> {
8+
static invalidValue(input: unknown, expected: string): EvmTypeError {
9+
return new EvmTypeError({
10+
message: `Invalid input value: '${input}' expected '${expected}'`,
11+
input,
12+
});
13+
}
14+
static invalidSize(
15+
input: { readonly type: string; readonly value: Uint8Array },
16+
expected: number,
17+
): EvmTypeError {
18+
return new EvmTypeError({
19+
message: `Invalid input value for ${input.type}: '${bufferToHex(input.value)}' expected size '${expected}'`,
20+
input,
21+
});
22+
}
23+
}

packages/evm/src/transactions/processor.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import rlp from "@evm-effect/rlp";
1010
import { annotateSafe } from "@evm-effect/shared/annotateSafe";
1111
import { HashSet } from "@evm-effect/shared/hashset";
1212
import { Effect, Option, Result, type Schema } from "effect";
13-
import { encodeTransaction } from "packages/evm/src/transactions.js";
1413
import type { BlockOutput } from "../blockchain.js";
1514
import { logsBloom } from "../receipts/bloom.js";
1615
import * as State from "../state.js";
@@ -25,7 +24,11 @@ import {
2524
TransactionProcessingEnd,
2625
TransactionProcessingStart,
2726
} from "../trace.js";
28-
import { LegacyTransaction, type Transaction } from "../transactions.js";
27+
import {
28+
encodeTransaction,
29+
LegacyTransaction,
30+
type Transaction,
31+
} from "../transactions.js";
2932
import { LegacyReceipt, Receipt } from "../types/Receipt.js";
3033
import { Fork } from "../vm/ForkService.js";
3134
import { processMessageCall } from "../vm/interpreter.js";

packages/evm/src/transactions/validator.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,6 @@ import {
77
} from "@evm-effect/ethereum-types";
88
import { annotateSafe } from "@evm-effect/shared/annotateSafe";
99
import { Data, Effect } from "effect";
10-
import {
11-
recoverSender,
12-
type Transaction,
13-
} from "packages/evm/src/transactions.js";
1410
import type { BlockOutput } from "../blockchain.js";
1511
import { TX_MAX_GAS_LIMIT, VERSIONED_HASH_VERSION_KZG } from "../constants.js";
1612
import {
@@ -40,6 +36,7 @@ import {
4036
Type4TxPreForkError,
4137
} from "../exceptions.js";
4238
import State from "../state.js";
39+
import { recoverSender, type Transaction } from "../transactions.js";
4340
import { Fork } from "../vm/ForkService.js";
4441
import { GasCosts } from "../vm/gas.js";
4542
import { MAX_INIT_CODE_SIZE } from "../vm/interpreter.js";

packages/evm/src/vm/eoa_delegation.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import { Address, Bytes, U64, U256 } from "@evm-effect/ethereum-types";
22
import { annotateSafe } from "@evm-effect/shared/annotateSafe";
33
import { Effect, Equal, Option } from "effect";
4-
import { recoverAuthority } from "packages/evm/src/transactions.js";
54
import { InvalidBlock } from "../exceptions.js";
65
import State from "../state.js";
6+
import { recoverAuthority } from "../transactions.js";
77
import type { Message } from "./message.js";
88
import { Code } from "./runtime.js";
99

packages/evm/src/vm/precompiles/01-erecover.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
import { Bytes, Bytes32, U256 } from "@evm-effect/ethereum-types";
22
import { Effect, Ref, Result } from "effect";
3-
import {
4-
publicKeyToAddress,
5-
secp256k1Recover,
6-
} from "packages/evm/src/transactions.js";
3+
import { publicKeyToAddress, secp256k1Recover } from "../../transactions.js";
74
import { Evm } from "../evm.js";
85
import * as Gas from "../gas.js";
96

packages/evm/test/state-tests/index.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,6 @@ import {
1111
} from "@evm-effect/ethereum-types";
1212
import rlp from "@evm-effect/rlp";
1313
import { Effect, Predicate, Result, Schema } from "effect";
14-
import {
15-
Access,
16-
decodeTransaction,
17-
encodeTransaction,
18-
signTransaction,
19-
} from "packages/evm/src/transactions.js";
2014
import { dedent } from "ts-dedent";
2115
import {
2216
AccessListTransaction,
@@ -33,6 +27,12 @@ import {
3327
type Transaction,
3428
} from "../../src/index.js";
3529
import { Rlp } from "../../src/rlp.js";
30+
import {
31+
Access,
32+
decodeTransaction,
33+
encodeTransaction,
34+
signTransaction,
35+
} from "../../src/transactions.js";
3636
import { Log } from "../../src/types/Receipt.js";
3737
import { ExecutionSpecTestError } from "../utils/ExecutionSpecTestError.js";
3838
import { getFork } from "../utils/getFork.js";

0 commit comments

Comments
 (0)