Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: AppClient, AppFactory, AppDeployer interface and various refinements on top of existing new interfaces #124

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
chore: make some asset param fields optional; add subtraction dunder …
…to AlgoAmount
  • Loading branch information
aorumbayev committed Dec 10, 2024
commit 415c6ab33c4393cbf88086b7cfea5d047aeda6d3
24 changes: 24 additions & 0 deletions src/algokit_utils/models/amount.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,3 +121,27 @@ def __ge__(self, other: object) -> bool:
elif isinstance(other, int | Decimal):
return self.amount_in_micro_algo >= int(other)
raise TypeError(f"Unsupported operand type(s) for >=: 'AlgoAmount' and '{type(other).__name__}'")

def __sub__(self, other: int | Decimal | AlgoAmount) -> AlgoAmount:
if isinstance(other, AlgoAmount):
total_micro_algos = self.micro_algos - other.micro_algos
elif isinstance(other, (int | Decimal)):
total_micro_algos = self.micro_algos - int(other)
else:
raise TypeError(f"Unsupported operand type(s) for -: 'AlgoAmount' and '{type(other).__name__}'")
return AlgoAmount.from_micro_algos(total_micro_algos)

def __rsub__(self, other: int | Decimal) -> AlgoAmount:
if isinstance(other, (int | Decimal)):
total_micro_algos = int(other) - self.micro_algos
return AlgoAmount.from_micro_algos(total_micro_algos)
raise TypeError(f"Unsupported operand type(s) for -: '{type(other).__name__}' and 'AlgoAmount'")

def __isub__(self, other: int | Decimal | AlgoAmount) -> Self:
if isinstance(other, AlgoAmount):
self.amount_in_micro_algo -= other.micro_algos
elif isinstance(other, (int | Decimal)):
self.amount_in_micro_algo -= int(other)
else:
raise TypeError(f"Unsupported operand type(s) for -: 'AlgoAmount' and '{type(other).__name__}'")
return self
6 changes: 3 additions & 3 deletions src/algokit_utils/transactions/transaction_composer.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,9 @@ class AssetCreateParams(
"""

total: int
asset_name: str
unit_name: str
url: str
asset_name: str | None = None
unit_name: str | None = None
url: str | None = None
decimals: int | None = None
default_frozen: bool | None = None
manager: str | None = None
Expand Down
Loading