From 6c36832f0e2b727cfbdfe2949109fa5b15fbbfd1 Mon Sep 17 00:00:00 2001 From: Ryan Chow Date: Tue, 9 Apr 2019 06:33:36 -0700 Subject: [PATCH] Stop using deprecated web3.py interface (#1759) * Refactor contract function call to support web3.py v5.0.0. (backwards compatible with v4) --- .../order_utils/src/zero_ex/order_utils/__init__.py | 4 ++-- .../order_utils/stubs/web3/utils/datatypes.pyi | 13 +++++++++++-- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/python-packages/order_utils/src/zero_ex/order_utils/__init__.py b/python-packages/order_utils/src/zero_ex/order_utils/__init__.py index c1fea8c21c..40f2bf0b77 100644 --- a/python-packages/order_utils/src/zero_ex/order_utils/__init__.py +++ b/python-packages/order_utils/src/zero_ex/order_utils/__init__.py @@ -428,9 +428,9 @@ def is_valid_signature( ) try: return ( - contract.call().isValidSignature( + contract.functions.isValidSignature( data, to_checksum_address(signer_address), signature - ), + ).call(), "", ) except web3.exceptions.BadFunctionCallOutput as exception: diff --git a/python-packages/order_utils/stubs/web3/utils/datatypes.pyi b/python-packages/order_utils/stubs/web3/utils/datatypes.pyi index 70baff3728..826fa5590c 100644 --- a/python-packages/order_utils/stubs/web3/utils/datatypes.pyi +++ b/python-packages/order_utils/stubs/web3/utils/datatypes.pyi @@ -1,3 +1,12 @@ -class Contract: - def call(self): ... +from typing import Callable + + +class ContractFunctions: + def __getattr__(self, function_name) -> Callable: + ... + ... + + +class Contract: + functions: ContractFunctions ...