Skip to content

Commit

Permalink
chore: update
Browse files Browse the repository at this point in the history
  • Loading branch information
jmoreira-valory committed Aug 13, 2024
1 parent c4884ab commit f78a343
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 277 deletions.
20 changes: 0 additions & 20 deletions operate/data/contracts/staking_token/__init__.py

This file was deleted.

192 changes: 0 additions & 192 deletions operate/data/contracts/staking_token/contract.py

This file was deleted.

23 changes: 0 additions & 23 deletions operate/data/contracts/staking_token/contract.yaml

This file was deleted.

14 changes: 13 additions & 1 deletion operate/services/manage.py
Original file line number Diff line number Diff line change
Expand Up @@ -684,17 +684,29 @@ def terminate_service_on_chain_from_safe(self, hash: str, chain_id: int) -> None
ic(info)


# Determine if the service is staked in a known staking program
current_staking_program = None
for staking_program in STAKING[ledger_config.chain]:
state = sftxb.staking_status(
service_id=chain_data.token,
staking_contract=STAKING[ledger_config.chain][staking_program],
)
if state in (StakingState.STAKED, StakingState.EVICTED):
current_staking_program = staking_program

print(state)
is_staked = current_staking_program is not None

# if is_staked:
# can_unstake = and not self._can_unstake_service_from_safe(hash=hash)

print(current_staking_program)
print(is_staked)
import sys
sys.exit(1)




if (
chain_data.user_params.use_staking
and not self._can_unstake_service_from_safe(hash=hash)
Expand Down
54 changes: 13 additions & 41 deletions operate/services/protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,6 @@
from operate.data.contracts.service_staking_token.contract import (
ServiceStakingTokenContract,
)
from operate.data.contracts.staking_token.contract import (
StakingTokenContract,
)
from operate.types import ContractAddresses
from operate.utils.gnosis import (
MultiSendOperation,
Expand Down Expand Up @@ -203,48 +200,23 @@ def __init__(
directory=str(DATA_DIR / "contracts" / "service_staking_token")
),
)
self.staking_token_ctr = t.cast(
StakingTokenContract,
StakingTokenContract.from_dir(
directory=str(DATA_DIR / "contracts" / "staking_token")
),
)
# self.staking_token_ctr = t.cast(
# StakingTokenContract,
# StakingTokenContract.from_dir(
# directory=str(DATA_DIR / "contracts" / "staking_token")
# ),
# )

def status(self, service_id: int, staking_contract: str) -> StakingState:
"""Is the service staked?"""
staking_state = None

print(staking_contract)
try:
print("a")
staking_state = StakingState(
self.staking_ctr.get_instance(
ledger_api=self.ledger_api,
contract_address=staking_contract,
)
.functions.getStakingState(service_id)
.call()
return StakingState(
self.staking_ctr.get_instance(
ledger_api=self.ledger_api,
contract_address=staking_contract,
)
print("b")
return staking_state
except Exception:
print("c")

try:
staking_state = StakingState(
self.staking_token_ctr.get_instance(
ledger_api=self.ledger_api,
contract_address=staking_contract,
)
.functions.getStakingState(service_id)
.call()
)
return staking_state
except Exception:
print("EXCEPTION")
print("d")

return staking_state
.functions.getStakingState(service_id)
.call()
)

def slots_available(self, staking_contract: str) -> bool:
"""Check if there are available slots on the staking contract"""
Expand Down

0 comments on commit f78a343

Please sign in to comment.