From 66ebef8c98d7f5810256863d3f7c41cbd0dcae58 Mon Sep 17 00:00:00 2001 From: Jianlun Zhong Date: Tue, 17 Dec 2024 14:39:20 -0800 Subject: [PATCH] return None for the external optional fields --- cdp/smart_contract.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/cdp/smart_contract.py b/cdp/smart_contract.py index f1fa4fa..dd5379c 100644 --- a/cdp/smart_contract.py +++ b/cdp/smart_contract.py @@ -117,13 +117,15 @@ def network_id(self) -> str: return self._model.network_id @property - def wallet_id(self) -> str: + def wallet_id(self) -> str | None: """Get the wallet ID that deployed the smart contract. Returns: The wallet ID. """ + if self._model.is_external: + return None return self._model.wallet_id @property @@ -147,13 +149,15 @@ def contract_name(self) -> str: return self._model.contract_name @property - def deployer_address(self) -> str: + def deployer_address(self) -> str | None: """Get the deployer address of the smart contract. Returns: The deployer address. """ + if self._model.is_external: + return None return self._model.deployer_address @property @@ -180,7 +184,7 @@ def type(self) -> Type: return self.Type(self._model.type) @property - def options(self) -> TokenContractOptions | NFTContractOptions | MultiTokenContractOptions: + def options(self) -> TokenContractOptions | NFTContractOptions | MultiTokenContractOptions | None: """Get the options of the smart contract. Returns: @@ -190,6 +194,8 @@ def options(self) -> TokenContractOptions | NFTContractOptions | MultiTokenContr ValueError: If the smart contract type is unknown or if options are not set. """ + if self._model.is_external: + return None if self._model.options is None or self._model.options.actual_instance is None: raise ValueError("Smart contract options are not set") @@ -221,6 +227,8 @@ def transaction(self) -> Transaction | None: Transaction: The transaction. """ + if self._model.is_external: + return None if self._transaction is None and self._model.transaction is not None: self._update_transaction(self._model) return self._transaction