Skip to content

Commit

Permalink
return None for the external optional fields
Browse files Browse the repository at this point in the history
  • Loading branch information
jianlunz-cb committed Dec 17, 2024
1 parent fd61201 commit 66ebef8
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions cdp/smart_contract.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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:
Expand All @@ -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")

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 66ebef8

Please sign in to comment.