From e78f291fa8bbd0faebf165606910d3fdd244ebe8 Mon Sep 17 00:00:00 2001 From: unparalleled-js Date: Sat, 25 Feb 2023 09:16:57 -0600 Subject: [PATCH 01/12] feat: wip --- src/ape/managers/converters.py | 13 +++++++++++-- src/ape_ethereum/ecosystem.py | 6 +++++- tests/functional/test_ecosystem.py | 23 ++++++++++++++++++++++- 3 files changed, 38 insertions(+), 4 deletions(-) diff --git a/src/ape/managers/converters.py b/src/ape/managers/converters.py index 3859d9fcd2..77e68327be 100644 --- a/src/ape/managers/converters.py +++ b/src/ape/managers/converters.py @@ -278,7 +278,7 @@ def is_type(self, value: Any, type: Type) -> bool: else: return isinstance(value, type) - def convert(self, value: Any, type: Type) -> Any: + def convert(self, value: Any, type: Union[Type, Tuple[Type], List[Type]]) -> Any: """ Convert the given value to the given type. This method accesses all :class:`~ape.api.convert.ConverterAPI` instances known to @@ -296,7 +296,16 @@ def convert(self, value: Any, type: Type) -> Any: any: The same given value but with the new given type. """ - if type not in self._converters: + if isinstance(value, (list, tuple)) and isinstance(type, (list, tuple)): + # Was given multiple values and types, such as from encode_calldata. + return [self.convert(v, t) for v, t in zip(value, type)] + + elif isinstance(type, (list, tuple)): + raise ConversionError( + f"Value '{value}' must be a list or tuple when given multiple types." + ) + + elif type not in self._converters: options = ", ".join([t.__name__ for t in self._converters]) raise ConversionError(f"Type '{type}' must be one of [{options}].") diff --git a/src/ape_ethereum/ecosystem.py b/src/ape_ethereum/ecosystem.py index d49a982276..0881fa446b 100644 --- a/src/ape_ethereum/ecosystem.py +++ b/src/ape_ethereum/ecosystem.py @@ -345,7 +345,11 @@ def encode_calldata(self, abi: Union[ConstructorABI, MethodABI], *args) -> HexBy parser = StructParser(abi) arguments = parser.encode_input(args) input_types = [i.canonical_type for i in abi.inputs] - converted_args = self.conversion_manager.convert(arguments, tuple) + + # TODO: Convert input_types to python_types. e.g. uint256 -> int, bytes4 -> HexBytes etc. + python_types: List[Type] = [] + + converted_args = self.conversion_manager.convert(arguments, python_types) encoded_calldata = encode(input_types, converted_args) return HexBytes(encoded_calldata) diff --git a/tests/functional/test_ecosystem.py b/tests/functional/test_ecosystem.py index 46380d59a2..816534202f 100644 --- a/tests/functional/test_ecosystem.py +++ b/tests/functional/test_ecosystem.py @@ -2,7 +2,8 @@ import pytest from eth_typing import HexAddress, HexStr -from hexbytes import HexBytes +from ethpm_types import HexBytes +from ethpm_types.abi import ABIType, MethodABI from ape.api.networks import LOCAL_NETWORK_NAME from ape.types import AddressType @@ -52,6 +53,26 @@ def test_encode_address(ethereum): assert actual == raw_address +def test_encode_calldata(ethereum): + abi = MethodABI( + type="function", + name="callMe", + inputs=[ + ABIType(name="a", type="bytes4"), + ABIType(name="b", type="address"), + ABIType(name="c", type="uint256"), + ABIType(name="d", type="bytes4[]"), + ], + ) + address = "0xd8da6bf26964af9d7eed9e03e53415d37aa96045" + byte_array = ["0x456", "0x678"] + values = ("0x123", address, HexBytes(55), byte_array) + + actual = ethereum.encode_calldata(abi, *values) + expected = [HexBytes("0x123"), address, 55, [HexBytes(x) for x in byte_array]] + assert actual == expected + + def test_block_handles_snake_case_parent_hash(eth_tester_provider, sender, receiver): # Transaction to change parent hash of next block sender.transfer(receiver, "1 gwei") From 47d19a4121786f8bc219d8d9e82ce84a9eff4b33 Mon Sep 17 00:00:00 2001 From: "15219900+Ninjagod1251@users.noreply.github.com" <15219900+Ninjagod1251@users.noreply.github.com> Date: Mon, 27 Feb 2023 15:38:06 -0800 Subject: [PATCH 02/12] fix: converters, ecosystem to convert strings into hexbytes --- src/ape/managers/converters.py | 14 +++++++++--- src/ape_ethereum/ecosystem.py | 36 ++++++++++++++++++++++++++---- tests/functional/test_ecosystem.py | 14 +++++++++++- 3 files changed, 56 insertions(+), 8 deletions(-) diff --git a/src/ape/managers/converters.py b/src/ape/managers/converters.py index 77e68327be..24998bcf44 100644 --- a/src/ape/managers/converters.py +++ b/src/ape/managers/converters.py @@ -27,7 +27,7 @@ class HexConverter(ConverterAPI): """ A converter that converts ``str`` to ``HexBytes``. """ - + def is_convertible(self, value: Any) -> bool: return isinstance(value, str) and is_hex(value) @@ -246,6 +246,8 @@ def _converters(self) -> Dict[Type, List[ConverterAPI]]: Decimal: [], list: [ListTupleConverter()], tuple: [ListTupleConverter()], + bool: [], + str: [], } for plugin_name, (conversion_type, converter_class) in self.plugin_manager.converters: @@ -296,9 +298,15 @@ def convert(self, value: Any, type: Union[Type, Tuple[Type], List[Type]]) -> Any any: The same given value but with the new given type. """ - if isinstance(value, (list, tuple)) and isinstance(type, (list, tuple)): - # Was given multiple values and types, such as from encode_calldata. + if isinstance(value, (list, tuple)) and isinstance(type,tuple): + # We expected to convert a tuple type, so convert each item in the tuple. + # NOTE: We allow values to be a list, just incase it is a list return [self.convert(v, t) for v, t in zip(value, type)] + + elif isinstance(value, list) and isinstance(type, list) and len(type) == 1: + # We expected to convert an array type(dynamic or static), so convert each item in the list. + # NOTE: type for static and dynamic array is a single item list containing the type of the array. + return [self.convert(v, type[0]) for v in value] elif isinstance(type, (list, tuple)): raise ConversionError( diff --git a/src/ape_ethereum/ecosystem.py b/src/ape_ethereum/ecosystem.py index 0881fa446b..05aabceb0f 100644 --- a/src/ape_ethereum/ecosystem.py +++ b/src/ape_ethereum/ecosystem.py @@ -338,17 +338,45 @@ def decode_block(self, data: Dict) -> BlockAPI: return Block.parse_obj(data) + def _python_type_for_abi_type(self, abi_type:ABIType) -> Type: + # NOTE: An array can be an array of tuples, so we start with an array check + if abi_type.type.endswith("]"): + # remove one layer of the potential onion of array + new_type = "[".join(str(abi_type.type).split('[')[:-1]) + # create a new type with the inner type of array + new_abi_type = ABIType(type = new_type, **abi_type.dict(exclude={"type"})) + # NOTE: type for static and dynamic array is a single item list containing the type of the array + return [self._python_type_for_abi_type(new_abi_type)] + + if abi_type.components is not None: + return tuple(self._python_type_for_abi_type(c) for c in abi_type.components) + + if abi_type.type == "address": + return AddressType + + elif abi_type.type == "bool": + return bool + + elif abi_type.type == "string": + return str + + elif "bytes" in abi_type.type: + return bytes + + elif "int" in abi_type.type: + return int + + raise + def encode_calldata(self, abi: Union[ConstructorABI, MethodABI], *args) -> HexBytes: if not abi.inputs: return HexBytes("") - parser = StructParser(abi) arguments = parser.encode_input(args) - input_types = [i.canonical_type for i in abi.inputs] - # TODO: Convert input_types to python_types. e.g. uint256 -> int, bytes4 -> HexBytes etc. - python_types: List[Type] = [] + input_types = [i.canonical_type for i in abi.inputs] + python_types: Tuple[Type] = tuple(self._python_type_for_abi_type(i) for i in abi.inputs) converted_args = self.conversion_manager.convert(arguments, python_types) encoded_calldata = encode(input_types, converted_args) return HexBytes(encoded_calldata) diff --git a/tests/functional/test_ecosystem.py b/tests/functional/test_ecosystem.py index 816534202f..0056b194fb 100644 --- a/tests/functional/test_ecosystem.py +++ b/tests/functional/test_ecosystem.py @@ -69,7 +69,19 @@ def test_encode_calldata(ethereum): values = ("0x123", address, HexBytes(55), byte_array) actual = ethereum.encode_calldata(abi, *values) - expected = [HexBytes("0x123"), address, 55, [HexBytes(x) for x in byte_array]] + expected = HexBytes( + # 0x123 + '0123000000000000000000000000000000000000000000000000000000000000' + # address + '000000000000000000000000d8da6bf26964af9d7eed9e03e53415d37aa96045' + # HexBytes(55) + '0000000000000000000000000000000000000000000000000000000000000037' + # byte_array + '0000000000000000000000000000000000000000000000000000000000000080' + '0000000000000000000000000000000000000000000000000000000000000002' + '0456000000000000000000000000000000000000000000000000000000000000' + '0678000000000000000000000000000000000000000000000000000000000000' + ) assert actual == expected From 7d99dddb8612f7b065cc08565e55b11f033464f8 Mon Sep 17 00:00:00 2001 From: "15219900+Ninjagod1251@users.noreply.github.com" <15219900+Ninjagod1251@users.noreply.github.com> Date: Mon, 27 Feb 2023 17:43:24 -0800 Subject: [PATCH 03/12] chore: pr suggestions --- src/ape/managers/converters.py | 8 ++++---- src/ape_ethereum/ecosystem.py | 16 ++++++++-------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/ape/managers/converters.py b/src/ape/managers/converters.py index 24998bcf44..32bfa9a7bb 100644 --- a/src/ape/managers/converters.py +++ b/src/ape/managers/converters.py @@ -27,7 +27,7 @@ class HexConverter(ConverterAPI): """ A converter that converts ``str`` to ``HexBytes``. """ - + def is_convertible(self, value: Any) -> bool: return isinstance(value, str) and is_hex(value) @@ -298,11 +298,11 @@ def convert(self, value: Any, type: Union[Type, Tuple[Type], List[Type]]) -> Any any: The same given value but with the new given type. """ - if isinstance(value, (list, tuple)) and isinstance(type,tuple): + if isinstance(value, (list, tuple)) and isinstance(type, tuple): # We expected to convert a tuple type, so convert each item in the tuple. - # NOTE: We allow values to be a list, just incase it is a list + # NOTE: We allow values to be a list, just in case it is a list return [self.convert(v, t) for v, t in zip(value, type)] - + elif isinstance(value, list) and isinstance(type, list) and len(type) == 1: # We expected to convert an array type(dynamic or static), so convert each item in the list. # NOTE: type for static and dynamic array is a single item list containing the type of the array. diff --git a/src/ape_ethereum/ecosystem.py b/src/ape_ethereum/ecosystem.py index 05aabceb0f..6ac05354bc 100644 --- a/src/ape_ethereum/ecosystem.py +++ b/src/ape_ethereum/ecosystem.py @@ -338,13 +338,13 @@ def decode_block(self, data: Dict) -> BlockAPI: return Block.parse_obj(data) - def _python_type_for_abi_type(self, abi_type:ABIType) -> Type: + def _python_type_for_abi_type(self, abi_type: ABIType) -> Any[Type[Any]]: # NOTE: An array can be an array of tuples, so we start with an array check if abi_type.type.endswith("]"): - # remove one layer of the potential onion of array - new_type = "[".join(str(abi_type.type).split('[')[:-1]) + # remove one layer of the potential onion of array + new_type = "[".join(str(abi_type.type).split("[")[:-1]) # create a new type with the inner type of array - new_abi_type = ABIType(type = new_type, **abi_type.dict(exclude={"type"})) + new_abi_type = ABIType(type=new_type, **abi_type.dict(exclude={"type"})) # NOTE: type for static and dynamic array is a single item list containing the type of the array return [self._python_type_for_abi_type(new_abi_type)] @@ -353,19 +353,19 @@ def _python_type_for_abi_type(self, abi_type:ABIType) -> Type: if abi_type.type == "address": return AddressType - + elif abi_type.type == "bool": return bool elif abi_type.type == "string": return str - + elif "bytes" in abi_type.type: return bytes - + elif "int" in abi_type.type: return int - + raise def encode_calldata(self, abi: Union[ConstructorABI, MethodABI], *args) -> HexBytes: From 634ffcb68a5e0e0163f5981f8026493ffa773399 Mon Sep 17 00:00:00 2001 From: unparalleled-js Date: Tue, 28 Feb 2023 16:41:34 -0600 Subject: [PATCH 04/12] chore: fix mypy --- src/ape/managers/converters.py | 8 +++++--- src/ape_ethereum/ecosystem.py | 9 ++++++--- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/ape/managers/converters.py b/src/ape/managers/converters.py index 32bfa9a7bb..179f812119 100644 --- a/src/ape/managers/converters.py +++ b/src/ape/managers/converters.py @@ -280,7 +280,7 @@ def is_type(self, value: Any, type: Type) -> bool: else: return isinstance(value, type) - def convert(self, value: Any, type: Union[Type, Tuple[Type], List[Type]]) -> Any: + def convert(self, value: Any, type: Union[Type, Tuple[Type, ...], List[Type]]) -> Any: """ Convert the given value to the given type. This method accesses all :class:`~ape.api.convert.ConverterAPI` instances known to @@ -304,8 +304,10 @@ def convert(self, value: Any, type: Union[Type, Tuple[Type], List[Type]]) -> Any return [self.convert(v, t) for v, t in zip(value, type)] elif isinstance(value, list) and isinstance(type, list) and len(type) == 1: - # We expected to convert an array type(dynamic or static), so convert each item in the list. - # NOTE: type for static and dynamic array is a single item list containing the type of the array. + # We expected to convert an array type(dynamic or static), + # so convert each item in the list. + # NOTE: type for static and dynamic array is a single item + # list containing the type of the array. return [self.convert(v, type[0]) for v in value] elif isinstance(type, (list, tuple)): diff --git a/src/ape_ethereum/ecosystem.py b/src/ape_ethereum/ecosystem.py index 6ac05354bc..ab08b83483 100644 --- a/src/ape_ethereum/ecosystem.py +++ b/src/ape_ethereum/ecosystem.py @@ -340,12 +340,13 @@ def decode_block(self, data: Dict) -> BlockAPI: def _python_type_for_abi_type(self, abi_type: ABIType) -> Any[Type[Any]]: # NOTE: An array can be an array of tuples, so we start with an array check - if abi_type.type.endswith("]"): + if str(abi_type.type).endswith("]"): # remove one layer of the potential onion of array new_type = "[".join(str(abi_type.type).split("[")[:-1]) # create a new type with the inner type of array new_abi_type = ABIType(type=new_type, **abi_type.dict(exclude={"type"})) - # NOTE: type for static and dynamic array is a single item list containing the type of the array + # NOTE: type for static and dynamic array is a single item list + # containing the type of the array return [self._python_type_for_abi_type(new_abi_type)] if abi_type.components is not None: @@ -376,7 +377,9 @@ def encode_calldata(self, abi: Union[ConstructorABI, MethodABI], *args) -> HexBy input_types = [i.canonical_type for i in abi.inputs] - python_types: Tuple[Type] = tuple(self._python_type_for_abi_type(i) for i in abi.inputs) + python_types: Tuple[Type, ...] = tuple( + self._python_type_for_abi_type(i) for i in abi.inputs + ) converted_args = self.conversion_manager.convert(arguments, python_types) encoded_calldata = encode(input_types, converted_args) return HexBytes(encoded_calldata) From 0f132ba159406ad9eb8a2b3b0727cee8e75dd032 Mon Sep 17 00:00:00 2001 From: "15219900+Ninjagod1251@users.noreply.github.com" <15219900+Ninjagod1251@users.noreply.github.com> Date: Tue, 28 Feb 2023 14:53:08 -0800 Subject: [PATCH 05/12] fix: valueerror instead of raid --- src/ape_ethereum/ecosystem.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ape_ethereum/ecosystem.py b/src/ape_ethereum/ecosystem.py index ab08b83483..eb2aa81cba 100644 --- a/src/ape_ethereum/ecosystem.py +++ b/src/ape_ethereum/ecosystem.py @@ -367,7 +367,7 @@ def _python_type_for_abi_type(self, abi_type: ABIType) -> Any[Type[Any]]: elif "int" in abi_type.type: return int - raise + ValueError def encode_calldata(self, abi: Union[ConstructorABI, MethodABI], *args) -> HexBytes: if not abi.inputs: From 27668575fbee684c7894303837a2eb05f2666515 Mon Sep 17 00:00:00 2001 From: unparalleled-js Date: Tue, 28 Feb 2023 17:26:01 -0600 Subject: [PATCH 06/12] chore: less is more --- src/ape/managers/converters.py | 2 +- src/ape_ethereum/ecosystem.py | 9 +++------ tests/functional/test_ecosystem.py | 14 +++++++------- 3 files changed, 11 insertions(+), 14 deletions(-) diff --git a/src/ape/managers/converters.py b/src/ape/managers/converters.py index 179f812119..ae82b7771e 100644 --- a/src/ape/managers/converters.py +++ b/src/ape/managers/converters.py @@ -280,7 +280,7 @@ def is_type(self, value: Any, type: Type) -> bool: else: return isinstance(value, type) - def convert(self, value: Any, type: Union[Type, Tuple[Type, ...], List[Type]]) -> Any: + def convert(self, value: Any, type: Union[Type, Tuple, List]) -> Any: """ Convert the given value to the given type. This method accesses all :class:`~ape.api.convert.ConverterAPI` instances known to diff --git a/src/ape_ethereum/ecosystem.py b/src/ape_ethereum/ecosystem.py index eb2aa81cba..6078bb833c 100644 --- a/src/ape_ethereum/ecosystem.py +++ b/src/ape_ethereum/ecosystem.py @@ -338,7 +338,7 @@ def decode_block(self, data: Dict) -> BlockAPI: return Block.parse_obj(data) - def _python_type_for_abi_type(self, abi_type: ABIType) -> Any[Type[Any]]: + def _python_type_for_abi_type(self, abi_type: ABIType) -> Union[Type, Tuple, List]: # NOTE: An array can be an array of tuples, so we start with an array check if str(abi_type.type).endswith("]"): # remove one layer of the potential onion of array @@ -372,14 +372,11 @@ def _python_type_for_abi_type(self, abi_type: ABIType) -> Any[Type[Any]]: def encode_calldata(self, abi: Union[ConstructorABI, MethodABI], *args) -> HexBytes: if not abi.inputs: return HexBytes("") + parser = StructParser(abi) arguments = parser.encode_input(args) - input_types = [i.canonical_type for i in abi.inputs] - - python_types: Tuple[Type, ...] = tuple( - self._python_type_for_abi_type(i) for i in abi.inputs - ) + python_types = tuple(self._python_type_for_abi_type(i) for i in abi.inputs) converted_args = self.conversion_manager.convert(arguments, python_types) encoded_calldata = encode(input_types, converted_args) return HexBytes(encoded_calldata) diff --git a/tests/functional/test_ecosystem.py b/tests/functional/test_ecosystem.py index 0056b194fb..ac35340fb2 100644 --- a/tests/functional/test_ecosystem.py +++ b/tests/functional/test_ecosystem.py @@ -71,16 +71,16 @@ def test_encode_calldata(ethereum): actual = ethereum.encode_calldata(abi, *values) expected = HexBytes( # 0x123 - '0123000000000000000000000000000000000000000000000000000000000000' + "0123000000000000000000000000000000000000000000000000000000000000" # address - '000000000000000000000000d8da6bf26964af9d7eed9e03e53415d37aa96045' + "000000000000000000000000d8da6bf26964af9d7eed9e03e53415d37aa96045" # HexBytes(55) - '0000000000000000000000000000000000000000000000000000000000000037' + "0000000000000000000000000000000000000000000000000000000000000037" # byte_array - '0000000000000000000000000000000000000000000000000000000000000080' - '0000000000000000000000000000000000000000000000000000000000000002' - '0456000000000000000000000000000000000000000000000000000000000000' - '0678000000000000000000000000000000000000000000000000000000000000' + "0000000000000000000000000000000000000000000000000000000000000080" + "0000000000000000000000000000000000000000000000000000000000000002" + "0456000000000000000000000000000000000000000000000000000000000000" + "0678000000000000000000000000000000000000000000000000000000000000" ) assert actual == expected From ed9369067b668dcc501042e567fc9b3dc5fb07ef Mon Sep 17 00:00:00 2001 From: unparalleled-js Date: Tue, 28 Feb 2023 17:27:53 -0600 Subject: [PATCH 07/12] fix: error --- src/ape_ethereum/ecosystem.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/ape_ethereum/ecosystem.py b/src/ape_ethereum/ecosystem.py index 6078bb833c..8ea1f76084 100644 --- a/src/ape_ethereum/ecosystem.py +++ b/src/ape_ethereum/ecosystem.py @@ -23,7 +23,13 @@ from ape.api import BlockAPI, EcosystemAPI, PluginConfig, ReceiptAPI, TransactionAPI from ape.api.networks import LOCAL_NETWORK_NAME, ProxyInfoAPI from ape.contracts.base import ContractCall -from ape.exceptions import ApeException, APINotImplementedError, ContractError, DecodingError +from ape.exceptions import ( + ApeException, + APINotImplementedError, + ContractError, + ConversionError, + DecodingError, +) from ape.logging import logger from ape.types import ( AddressType, @@ -367,7 +373,7 @@ def _python_type_for_abi_type(self, abi_type: ABIType) -> Union[Type, Tuple, Lis elif "int" in abi_type.type: return int - ValueError + raise ConversionError(f"Unable to convert '{abi_type}'.") def encode_calldata(self, abi: Union[ConstructorABI, MethodABI], *args) -> HexBytes: if not abi.inputs: From 2b2d606877b917b80339b53160eeb2cc2d7c1ac2 Mon Sep 17 00:00:00 2001 From: "15219900+Ninjagod1251@users.noreply.github.com" <15219900+Ninjagod1251@users.noreply.github.com> Date: Tue, 28 Feb 2023 15:56:27 -0800 Subject: [PATCH 08/12] fix: test_ether with expected err --- tests/functional/conversion/test_ether.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/functional/conversion/test_ether.py b/tests/functional/conversion/test_ether.py index b108d3e63a..c48e9ddc3f 100644 --- a/tests/functional/conversion/test_ether.py +++ b/tests/functional/conversion/test_ether.py @@ -27,9 +27,9 @@ def test_ether_conversions(value, unit): def test_bad_type(): with pytest.raises(ConversionError) as err: convert(value="something", type=float) - + breakpoint() expected = ( - "Type '' must be one of [ChecksumAddress, bytes, int, Decimal, list, tuple]." + "Type '' must be one of [ChecksumAddress, bytes, int, Decimal, list, tuple, bool, str]]." ) assert str(err.value) == expected From a7ca6fd52468d26f09dec41cb005c6ed2de87812 Mon Sep 17 00:00:00 2001 From: "15219900+Ninjagod1251@users.noreply.github.com" <15219900+Ninjagod1251@users.noreply.github.com> Date: Tue, 28 Feb 2023 15:57:13 -0800 Subject: [PATCH 09/12] fix: test_ether with expected err --- tests/functional/conversion/test_ether.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/functional/conversion/test_ether.py b/tests/functional/conversion/test_ether.py index c48e9ddc3f..d7acc66d9a 100644 --- a/tests/functional/conversion/test_ether.py +++ b/tests/functional/conversion/test_ether.py @@ -29,7 +29,7 @@ def test_bad_type(): convert(value="something", type=float) breakpoint() expected = ( - "Type '' must be one of [ChecksumAddress, bytes, int, Decimal, list, tuple, bool, str]]." + "Type '' must be one of [ChecksumAddress, bytes, int, Decimal, list, tuple, bool, str]." ) assert str(err.value) == expected From a6fd0b7763c58981d196e27aa49644e08cf96ac7 Mon Sep 17 00:00:00 2001 From: "15219900+Ninjagod1251@users.noreply.github.com" <15219900+Ninjagod1251@users.noreply.github.com> Date: Tue, 28 Feb 2023 16:06:20 -0800 Subject: [PATCH 10/12] fix: black --- tests/functional/conversion/test_ether.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/tests/functional/conversion/test_ether.py b/tests/functional/conversion/test_ether.py index d7acc66d9a..d88b4b8a4d 100644 --- a/tests/functional/conversion/test_ether.py +++ b/tests/functional/conversion/test_ether.py @@ -28,9 +28,7 @@ def test_bad_type(): with pytest.raises(ConversionError) as err: convert(value="something", type=float) breakpoint() - expected = ( - "Type '' must be one of [ChecksumAddress, bytes, int, Decimal, list, tuple, bool, str]." - ) + expected = "Type '' must be one of [ChecksumAddress, bytes, int, Decimal, list, tuple, bool, str]." assert str(err.value) == expected From 614ab05e4bf2708603fe8fb93c5abc13c05977a5 Mon Sep 17 00:00:00 2001 From: "15219900+Ninjagod1251@users.noreply.github.com" <15219900+Ninjagod1251@users.noreply.github.com> Date: Tue, 28 Feb 2023 16:21:19 -0800 Subject: [PATCH 11/12] chore: rm breakpoint --- tests/functional/conversion/test_ether.py | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/functional/conversion/test_ether.py b/tests/functional/conversion/test_ether.py index d88b4b8a4d..c60fef486f 100644 --- a/tests/functional/conversion/test_ether.py +++ b/tests/functional/conversion/test_ether.py @@ -27,7 +27,6 @@ def test_ether_conversions(value, unit): def test_bad_type(): with pytest.raises(ConversionError) as err: convert(value="something", type=float) - breakpoint() expected = "Type '' must be one of [ChecksumAddress, bytes, int, Decimal, list, tuple, bool, str]." assert str(err.value) == expected From 88b2cf15c78166d3f972b40e7622486ce9e5637f Mon Sep 17 00:00:00 2001 From: unparalleled-js Date: Thu, 2 Mar 2023 08:39:06 -0700 Subject: [PATCH 12/12] fix: add newlines --- tests/functional/conversion/test_ether.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tests/functional/conversion/test_ether.py b/tests/functional/conversion/test_ether.py index c60fef486f..4473bea787 100644 --- a/tests/functional/conversion/test_ether.py +++ b/tests/functional/conversion/test_ether.py @@ -27,7 +27,11 @@ def test_ether_conversions(value, unit): def test_bad_type(): with pytest.raises(ConversionError) as err: convert(value="something", type=float) - expected = "Type '' must be one of [ChecksumAddress, bytes, int, Decimal, list, tuple, bool, str]." + + expected = ( + "Type '' must be one of " + "[ChecksumAddress, bytes, int, Decimal, list, tuple, bool, str]." + ) assert str(err.value) == expected