From f8d6a637c5e432aeabd3f4909fd870cd1b70836a Mon Sep 17 00:00:00 2001 From: Uladzislau Hubar Date: Mon, 25 Dec 2023 00:49:18 +0100 Subject: [PATCH 1/3] Added usage of decorator for contract instances autoupdate --- dkg/providers/blockchain.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/dkg/providers/blockchain.py b/dkg/providers/blockchain.py index a98f82b..3427f94 100644 --- a/dkg/providers/blockchain.py +++ b/dkg/providers/blockchain.py @@ -133,6 +133,7 @@ def wrapper(self, *args, **kwargs): return wrapper + @handle_updated_contract def call_function( self, contract: str, @@ -240,14 +241,10 @@ def _update_contract_instance(self, contract: str): self.contracts[contract] = self.w3.eth.contract( address=( self.contracts["Hub"] - .functions.getContractAddress( - contract if contract != "ERC20Token" else "Token" - ) - .call() + .functions.getContractAddress(contract).call() if not contract.endswith("AssetStorage") else self.contracts["Hub"] - .functions.getAssetStorageAddress(contract) - .call() + .functions.getAssetStorageAddress(contract).call() ), abi=self.abi[contract], ) From b628ee6a4781f63bc82ae687e4c8cbeb0a9ad4d8 Mon Sep 17 00:00:00 2001 From: Uladzislau Hubar Date: Mon, 25 Dec 2023 00:50:05 +0100 Subject: [PATCH 2/3] Bumped version --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index b1bed9b..48fae4d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "dkg" -version = "0.1.0-beta.3" +version = "0.1.0-beta.4" description = "Python library for interacting with the OriginTrail Decentralized Knowledge Graph" authors = ["Uladzislau Hubar "] license = "Apache-2.0" From 9b4b134faf3b1ae7aee2b0e19642ba80fc87c79f Mon Sep 17 00:00:00 2001 From: Uladzislau Hubar Date: Wed, 10 Jan 2024 15:21:01 +0100 Subject: [PATCH 3/3] Fixed contract name fetching in the wrapper --- dkg/providers/blockchain.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dkg/providers/blockchain.py b/dkg/providers/blockchain.py index 3427f94..429cdea 100644 --- a/dkg/providers/blockchain.py +++ b/dkg/providers/blockchain.py @@ -117,7 +117,7 @@ def make_json_rpc_request(self, endpoint: str, args: dict[str, Any] = {}) -> Any def handle_updated_contract(func): @wraps(func) def wrapper(self, *args, **kwargs): - contract_name = kwargs.get("contract_name") or (args[0] if args else None) + contract_name = kwargs.get("contract") or (args[0] if args else None) try: return func(self, *args, **kwargs)