Skip to content

Commit

Permalink
Format things
Browse files Browse the repository at this point in the history
  • Loading branch information
aguillon committed Mar 13, 2024
1 parent d2e8cf2 commit 66c1621
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 20 deletions.
20 changes: 6 additions & 14 deletions src/crud.py
Original file line number Diff line number Diff line change
Expand Up @@ -391,9 +391,7 @@ def create_max_calls_per_entrypoint_condition(
)


def check_max_calls_per_sponsee(
db: Session, contract_id: UUID4, vault_id: UUID4
):
def check_max_calls_per_sponsee(db: Session, contract_id: UUID4, vault_id: UUID4):
return (
db.query(models.Condition)
.filter(models.Condition.type == schemas.ConditionType.MAX_CALLS_PER_SPONSEE)
Expand Down Expand Up @@ -435,15 +433,11 @@ def check_max_sponsee_condition(
.filter(models.Operation.created_at >= sponsee_condition.created_at)
.count()
)
print(nb_operations)
return nb_operations >= sponsee_condition.max


def check_conditions(db: Session, data: schemas.CheckConditions):
print(data)
sponsee_condition = check_max_calls_per_sponsee(
db, data.contract_id, data.vault_id
)
sponsee_condition = check_max_calls_per_sponsee(db, data.contract_id, data.vault_id)
entrypoint_condition = check_max_calls_per_entrypoint(
db, data.contract_id, data.entrypoint_id, data.vault_id
)
Expand All @@ -452,16 +446,14 @@ def check_conditions(db: Session, data: schemas.CheckConditions):
if sponsee_condition is None and entrypoint_condition is None:
return True
# Check max_entrypoint condition
if (
entrypoint_condition is not None and
(entrypoint_condition.current >= entrypoint_condition.max)
if entrypoint_condition is not None and (
entrypoint_condition.current >= entrypoint_condition.max
):
return False

# Check max_sponsee condition
if (
sponsee_condition is not None and
check_max_sponsee_condition(db, data, sponsee_condition)
if sponsee_condition is not None and check_max_sponsee_condition(
db, data, sponsee_condition
):
return False

Expand Down
7 changes: 2 additions & 5 deletions src/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,7 @@
# Healthcheck
@router.get("/")
async def root():
return {
"status": "healthy",
"tezos_address": tezos.public_address
}
return {"status": "healthy", "tezos_address": tezos.public_address}


# POST endpoints
Expand Down Expand Up @@ -365,7 +362,7 @@ async def post_operation(
contract_id=str(contract.id),
entrypoint_id=str(entrypoint.id),
hash=result["transaction_hash"],
status=result["result"] # type: ignore
status=result["result"], # type: ignore
),
)
except MichelsonError as e:
Expand Down
2 changes: 1 addition & 1 deletion src/tezos.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ async def confirm_deposit(tx_hash, payer, amount: Union[int, str]):
receiver = ptz.key.public_key_hash()
block_time = int(constants["minimal_block_delay"])
try:
async with asyncio.timeout(2*block_time):
async with asyncio.timeout(2 * block_time):
op_result = await find_transaction(tx_hash)
return any(
op
Expand Down

0 comments on commit 66c1621

Please sign in to comment.