Skip to content

Commit

Permalink
mypy fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
philogicae committed Feb 3, 2025
1 parent fa60a8a commit 813cf75
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 11 deletions.
16 changes: 6 additions & 10 deletions src/aleph/sdk/chains/ethereum.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,39 +163,35 @@ def get_super_token_balance(self) -> Decimal:
return Decimal(contract.functions.balanceOf(self.get_address()).call())
return Decimal(0)

@property
def has_superfluid_connector(self) -> bool:
return self.superfluid_connector is not None

def can_start_flow(self, flow: Decimal) -> Awaitable[bool]:
"""Check if the account has enough funds to start a Superfluid flow of the given size."""
if not self.has_superfluid_connector:
if not self.superfluid_connector:
raise ValueError("Superfluid connector is required to check a flow")
return self.superfluid_connector.can_start_flow(flow)

def create_flow(self, receiver: str, flow: Decimal) -> Awaitable[str]:
"""Creat a Superfluid flow between this account and the receiver address."""
if not self.has_superfluid_connector:
if not self.superfluid_connector:
raise ValueError("Superfluid connector is required to create a flow")
return self.superfluid_connector.create_flow(receiver=receiver, flow=flow)

def get_flow(self, receiver: str) -> Awaitable[Web3FlowInfo]:
"""Get the Superfluid flow between this account and the receiver address."""
if not self.has_superfluid_connector:
if not self.superfluid_connector:
raise ValueError("Superfluid connector is required to get a flow")
return self.superfluid_connector.get_flow(
sender=self.get_address(), receiver=receiver
)

def update_flow(self, receiver: str, flow: Decimal) -> Awaitable[str]:
"""Update the Superfluid flow between this account and the receiver address."""
if not self.has_superfluid_connector:
if not self.superfluid_connector:
raise ValueError("Superfluid connector is required to update a flow")
return self.superfluid_connector.update_flow(receiver=receiver, flow=flow)

def delete_flow(self, receiver: str) -> Awaitable[str]:
"""Delete the Superfluid flow between this account and the receiver address."""
if not self.has_superfluid_connector:
if not self.superfluid_connector:
raise ValueError("Superfluid connector is required to delete a flow")
return self.superfluid_connector.delete_flow(receiver=receiver)

Expand All @@ -206,7 +202,7 @@ def manage_flow(
update_type: FlowUpdate,
) -> Awaitable[Optional[str]]:
"""Manage the Superfluid flow between this account and the receiver address."""
if not self.has_superfluid_connector:
if not self.superfluid_connector:
raise ValueError("Superfluid connector is required to manage a flow")
return self.superfluid_connector.manage_flow(
receiver=receiver, flow=flow, update_type=update_type
Expand Down
2 changes: 1 addition & 1 deletion src/aleph/sdk/connectors/superfluid.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ async def manage_flow(
# Retrieve current flow info
flow_info: Web3FlowInfo = await self.account.get_flow(receiver)

current_flow_rate_wei: Decimal = Decimal(flow_info["flowRate"] or "0")
current_flow_rate_wei: Decimal = Decimal(flow_info["flowRate"] or 0)
flow_rate_wei: int = int(to_wei_token(flow))

if update_type == FlowUpdate.INCREASE:
Expand Down

0 comments on commit 813cf75

Please sign in to comment.