Skip to content

Commit e8a13bf

Browse files
author
Stuart Reed
committed
Pass codec from contract class
1 parent cf9362b commit e8a13bf

File tree

3 files changed

+25
-5
lines changed

3 files changed

+25
-5
lines changed

web3/_utils/contracts.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,9 @@ def encode_transaction_data(
280280
raise Web3TypeError("Unsupported function identifier")
281281

282282
return add_0x_prefix(
283-
encode_abi(fn_abi, fn_arguments, strict=w3.strict_bytes_type_checking)
283+
encode_abi(
284+
fn_abi, fn_arguments, data=fn_selector, strict=w3.strict_bytes_type_checking
285+
)
284286
)
285287

286288

web3/contract/base_contract.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -613,7 +613,13 @@ def _build_transaction(self, transaction: Optional[TxParams] = None) -> TxParams
613613
@combomethod
614614
def _encode_transaction_data(cls) -> HexStr:
615615
return add_0x_prefix(
616-
encode_abi(cls.abi, cls.arguments, strict=cls.w3.strict_bytes_type_checking)
616+
encode_abi(
617+
cls.abi,
618+
cls.arguments,
619+
data=cls.selector,
620+
abi_codec=cls.w3.codec,
621+
strict=cls.w3.strict_bytes_type_checking,
622+
)
617623
)
618624

619625
_return_data_normalizers: Optional[Tuple[Callable[..., Any], ...]] = tuple()
@@ -754,7 +760,11 @@ def encode_abi(
754760
data = fn_selector
755761

756762
return encode_abi(
757-
fn_abi, fn_arguments, data, strict=cls.w3.strict_bytes_type_checking
763+
fn_abi,
764+
fn_arguments,
765+
data,
766+
abi_codec=cls.w3.codec,
767+
strict=cls.w3.strict_bytes_type_checking,
758768
)
759769

760770
@combomethod
@@ -899,6 +909,7 @@ def _encode_constructor_data(
899909
constructor_abi,
900910
arguments,
901911
data=cls.bytecode,
912+
abi_codec=cls.w3.codec,
902913
strict=cls.w3.strict_bytes_type_checking,
903914
)
904915
)
@@ -1086,6 +1097,7 @@ def _encode_data_in_transaction(self, *args: Any, **kwargs: Any) -> HexStr:
10861097
constructor_abi,
10871098
arguments,
10881099
data=self.bytecode,
1100+
abi_codec=self.w3.codec,
10891101
strict=self.w3.strict_bytes_type_checking,
10901102
)
10911103
)

web3/contract/utils.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,10 @@ def call_contract_function(
108108
contract_abi, w3.codec, function_identifier, args, kwargs
109109
)
110110

111-
output_types = get_abi_output_types(fn_abi)
111+
try:
112+
output_types = get_abi_output_types(fn_abi)
113+
except ValueError:
114+
output_types = []
112115

113116
try:
114117
output_data = w3.codec.decode(output_types, return_data)
@@ -319,7 +322,10 @@ async def async_call_contract_function(
319322
contract_abi, async_w3.codec, function_identifier, args, kwargs
320323
)
321324

322-
output_types = get_abi_output_types(fn_abi)
325+
try:
326+
output_types = get_abi_output_types(fn_abi)
327+
except ValueError:
328+
output_types = []
323329

324330
try:
325331
output_data = async_w3.codec.decode(output_types, return_data)

0 commit comments

Comments
 (0)