Skip to content

Commit 3c1c76d

Browse files
committed
Use custom encoder for encode_single and is_encodable
1 parent caccebb commit 3c1c76d

File tree

8 files changed

+20
-20
lines changed

8 files changed

+20
-20
lines changed

tests/core/contracts/test_contract_constructor_encoding.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,9 @@ def test_contract_constructor_encoding_encoding(web3, WithConstructorArgumentsCo
6262

6363

6464
def test_contract_constructor_encoding_encoding_warning(web3, WithConstructorArgumentsContract):
65-
with pytest.warns(DeprecationWarning,
66-
match="in v6 it will be invalid to pass a hexstring without the \"0x\" prefix"
65+
with pytest.warns(
66+
DeprecationWarning,
67+
match="in v6 it will be invalid to pass a hexstring without the \"0x\" prefix"
6768
):
6869

6970
deploy_data = WithConstructorArgumentsContract._encode_constructor_data([1234, '61626364'])

tests/core/utilities/test_construct_event_data_set.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,6 @@ def hex_and_pad(i):
6868
),
6969
)
7070
)
71-
def test_construct_event_data_set(event_abi, arguments, expected):
72-
actual = construct_event_data_set(event_abi, arguments)
71+
def test_construct_event_data_set(web3, event_abi, arguments, expected):
72+
actual = construct_event_data_set(event_abi, web3, arguments)
7373
assert actual == expected

tests/core/utilities/test_construct_event_filter_params.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@
4646
}),
4747
),
4848
)
49-
def test_construct_event_filter_params(event_abi, fn_kwargs, expected):
50-
_, actual = construct_event_filter_params(event_abi, **fn_kwargs)
49+
def test_construct_event_filter_params(web3, event_abi, fn_kwargs, expected):
50+
_, actual = construct_event_filter_params(event_abi, web3, **fn_kwargs)
5151
assert actual == expected
5252

5353

@@ -68,7 +68,7 @@ def hex_and_pad(i):
6868
]),
6969
),
7070
)
71-
def test_construct_event_filter_params_for_data_filters(event_abi, fn_kwargs,
71+
def test_construct_event_filter_params_for_data_filters(event_abi, web3, fn_kwargs,
7272
expected):
73-
actual, _ = construct_event_filter_params(event_abi, **fn_kwargs)
73+
actual, _ = construct_event_filter_params(event_abi, web3, **fn_kwargs)
7474
assert actual == expected

tests/core/utilities/test_construct_event_topics.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,6 @@ def hex_and_pad(i):
7575
),
7676
)
7777
)
78-
def test_construct_event_topics(event_abi, arguments, expected):
79-
actual = construct_event_topic_set(event_abi, arguments)
78+
def test_construct_event_topics(web3, event_abi, arguments, expected):
79+
actual = construct_event_topic_set(event_abi, web3, arguments)
8080
assert actual == expected

web3/_utils/contracts.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
import functools
22

3-
from eth_abi import (
4-
encode_abi as eth_abi_encode_abi,
5-
)
63
from eth_utils import (
74
add_0x_prefix,
85
encode_hex,
@@ -148,7 +145,7 @@ def encode_abi(web3, abi, arguments, data=None):
148145
argument_types,
149146
arguments,
150147
)
151-
encoded_arguments = eth_abi_encode_abi(
148+
encoded_arguments = web3.codec.encode_abi(
152149
argument_types,
153150
normalized_arguments,
154151
)

web3/_utils/events.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@
6161
)
6262

6363

64-
def construct_event_topic_set(event_abi, arguments=None):
64+
def construct_event_topic_set(event_abi, web3, arguments=None):
6565
if arguments is None:
6666
arguments = {}
6767
if isinstance(arguments, (list, tuple)):
@@ -89,7 +89,7 @@ def construct_event_topic_set(event_abi, arguments=None):
8989
]
9090
encoded_args = [
9191
[
92-
None if option is None else encode_hex(encode_single(arg['type'], option))
92+
None if option is None else encode_hex(web3.codec.encode_single(arg['type'], option))
9393
for option in arg_options]
9494
for arg, arg_options in zipped_abi_and_args
9595
]
@@ -98,7 +98,7 @@ def construct_event_topic_set(event_abi, arguments=None):
9898
return topics
9999

100100

101-
def construct_event_data_set(event_abi, arguments=None):
101+
def construct_event_data_set(event_abi, web3, arguments=None):
102102
if arguments is None:
103103
arguments = {}
104104
if isinstance(arguments, (list, tuple)):
@@ -125,7 +125,7 @@ def construct_event_data_set(event_abi, arguments=None):
125125
]
126126
encoded_args = [
127127
[
128-
None if option is None else encode_hex(encode_single(arg['type'], option))
128+
None if option is None else encode_hex(web3.codec.encode_single(arg['type'], option))
129129
for option in arg_options]
130130
for arg, arg_options in zipped_abi_and_args
131131
]

web3/_utils/filters.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,15 @@
3131

3232

3333
def construct_event_filter_params(event_abi,
34+
web3,
3435
contract_address=None,
3536
argument_filters=None,
3637
topics=None,
3738
fromBlock=None,
3839
toBlock=None,
3940
address=None):
4041
filter_params = {}
41-
topic_set = construct_event_topic_set(event_abi, argument_filters)
42+
topic_set = construct_event_topic_set(event_abi, web3, argument_filters)
4243

4344
if topics is not None:
4445
if len(topic_set) > 1:
@@ -80,7 +81,7 @@ def construct_event_filter_params(event_abi,
8081
if toBlock is not None:
8182
filter_params['toBlock'] = toBlock
8283

83-
data_filters_set = construct_event_data_set(event_abi, argument_filters)
84+
data_filters_set = construct_event_data_set(event_abi, web3, argument_filters)
8485

8586
return data_filters_set, filter_params
8687

web3/contract.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1066,6 +1066,7 @@ def createFilter(
10661066

10671067
_, event_filter_params = construct_event_filter_params(
10681068
self._get_event_abi(),
1069+
self.web3,
10691070
contract_address=self.address,
10701071
argument_filters=_filters,
10711072
fromBlock=fromBlock,

0 commit comments

Comments
 (0)