|
| 1 | +from typing import ( |
| 2 | + Any, |
| 3 | + Callable, |
| 4 | + List, |
| 5 | +) |
| 6 | + |
1 | 7 | from eth_utils.curried import (
|
| 8 | + apply_formatter_to_array, |
| 9 | + apply_formatters_to_dict, |
2 | 10 | apply_formatters_to_sequence,
|
3 | 11 | encode_hex,
|
4 | 12 | to_checksum_address,
|
5 | 13 | to_hex,
|
6 | 14 | )
|
7 | 15 |
|
8 | 16 | from eth_utils.toolz import curried
|
9 |
| -import eth_utils.curried |
10 | 17 |
|
11 | 18 |
|
12 |
| -environment_formatter = eth_utils.curried.apply_formatters_to_dict({ |
| 19 | +environment_formatter = apply_formatters_to_dict({ |
13 | 20 | "currentCoinbase": to_checksum_address,
|
14 | 21 | "previousHash": encode_hex,
|
15 | 22 | "currentNumber": to_hex,
|
|
19 | 26 | })
|
20 | 27 |
|
21 | 28 |
|
| 29 | +storage_item_formatter: Callable[[List[Any]], List[Any]] |
22 | 30 | storage_item_formatter = apply_formatters_to_sequence([to_hex, to_hex])
|
23 | 31 | storage_formatter = curried.itemmap(storage_item_formatter)
|
24 | 32 |
|
25 | 33 |
|
26 |
| -account_state_formatter = eth_utils.curried.apply_formatters_to_dict({ |
| 34 | +account_state_formatter = apply_formatters_to_dict({ |
27 | 35 | "balance": to_hex,
|
28 | 36 | "nonce": to_hex,
|
29 | 37 | "code": encode_hex,
|
30 | 38 | "storage": storage_formatter,
|
31 | 39 | })
|
32 | 40 |
|
33 | 41 |
|
| 42 | +state_item_formatter: Callable[[List[Any]], List[Any]] |
34 | 43 | state_item_formatter = apply_formatters_to_sequence([to_checksum_address, account_state_formatter])
|
35 | 44 | state_formatter = curried.itemmap(state_item_formatter)
|
36 | 45 |
|
37 | 46 |
|
38 |
| -transaction_group_formatter = eth_utils.curried.apply_formatters_to_dict({ |
| 47 | +transaction_group_formatter = apply_formatters_to_dict({ |
39 | 48 | # all transaction types
|
40 | 49 | "to": to_checksum_address,
|
41 |
| - "data": eth_utils.curried.apply_formatter_to_array(encode_hex), |
42 |
| - "gasLimit": eth_utils.curried.apply_formatter_to_array(to_hex), |
| 50 | + "data": apply_formatter_to_array(encode_hex), |
| 51 | + "gasLimit": apply_formatter_to_array(to_hex), |
43 | 52 | "gasPrice": to_hex,
|
44 | 53 | "nonce": to_hex,
|
45 | 54 | "secretKey": encode_hex,
|
46 |
| - "value": eth_utils.curried.apply_formatter_to_array(to_hex), |
| 55 | + "value": apply_formatter_to_array(to_hex), |
47 | 56 | })
|
48 | 57 |
|
49 | 58 |
|
50 |
| -execution_formatter = eth_utils.curried.apply_formatters_to_dict({ |
| 59 | +execution_formatter = apply_formatters_to_dict({ |
51 | 60 | "address": to_checksum_address,
|
52 | 61 | "origin": to_checksum_address,
|
53 | 62 | "caller": to_checksum_address,
|
|
59 | 68 | })
|
60 | 69 |
|
61 | 70 |
|
62 |
| -expect_element_formatter = eth_utils.curried.apply_formatters_to_dict({ |
| 71 | +expect_element_formatter = apply_formatters_to_dict({ |
63 | 72 | "result": state_formatter
|
64 | 73 | })
|
65 |
| -expect_formatter = eth_utils.curried.apply_formatter_to_array(expect_element_formatter) |
| 74 | +expect_formatter: Callable[[List[Any]], List[Any]] |
| 75 | +expect_formatter = apply_formatter_to_array(expect_element_formatter) |
66 | 76 |
|
67 | 77 |
|
68 |
| -test_formatter = eth_utils.curried.apply_formatters_to_dict({ |
| 78 | +test_formatter = apply_formatters_to_dict({ |
69 | 79 | "env": environment_formatter,
|
70 | 80 | "pre": state_formatter,
|
71 | 81 | "transaction": transaction_group_formatter,
|
|
75 | 85 | filler_formatter = curried.valmap(test_formatter)
|
76 | 86 |
|
77 | 87 |
|
78 |
| -state_post_formatter = eth_utils.curried.apply_formatters_to_dict({ |
| 88 | +state_post_formatter = apply_formatters_to_dict({ |
79 | 89 | "hash": encode_hex
|
80 | 90 | })
|
81 | 91 |
|
82 | 92 |
|
83 |
| -filled_state_test_formatter = curried.valmap(eth_utils.curried.apply_formatters_to_dict({ |
| 93 | +filled_state_test_formatter = curried.valmap(apply_formatters_to_dict({ |
84 | 94 | "env": environment_formatter,
|
85 | 95 | "pre": state_formatter,
|
86 | 96 | "transaction": transaction_group_formatter,
|
87 | 97 | "post": state_post_formatter,
|
88 | 98 | }))
|
89 | 99 |
|
90 |
| -call_create_item_formatter = eth_utils.curried.apply_formatters_to_dict({ |
| 100 | +call_create_item_formatter = apply_formatters_to_dict({ |
91 | 101 | "data": encode_hex,
|
92 | 102 | "destination": to_checksum_address,
|
93 | 103 | "gasLimit": to_hex,
|
94 | 104 | "value": to_hex,
|
95 | 105 | })
|
96 |
| -call_creates_formatter = eth_utils.curried.apply_formatter_to_array(call_create_item_formatter) |
| 106 | +call_creates_formatter: Callable[[List[Any]], List[Any]] |
| 107 | +call_creates_formatter = apply_formatter_to_array(call_create_item_formatter) |
97 | 108 |
|
98 |
| -filled_vm_test_formatter = curried.valmap(eth_utils.curried.apply_formatters_to_dict({ |
| 109 | +filled_vm_test_formatter = curried.valmap(apply_formatters_to_dict({ |
99 | 110 | "env": environment_formatter,
|
100 | 111 | "pre": state_formatter,
|
101 | 112 | "exec": execution_formatter,
|
|
0 commit comments