Skip to content

Commit 5e9dd19

Browse files
authored
Merge pull request #311 from valory-xyz/fix/staking_data_type
Fix staking data type
2 parents 9692ab6 + 825cd0f commit 5e9dd19

File tree

3 files changed

+19
-1
lines changed

3 files changed

+19
-1
lines changed

run_service.sh

+11
Original file line numberDiff line numberDiff line change
@@ -1057,6 +1057,17 @@ if [ "${USE_STAKING}" = true ]; then
10571057
perform_staking_ops
10581058
fi
10591059

1060+
1061+
# ensure Safe owner is agent
1062+
# (This may occur if update flow was interrupted)
1063+
service_safe_address=$(<"../$service_safe_address_path")
1064+
current_safe_owners=$(poetry run python "../scripts/get_safe_owners.py" "$service_safe_address" "../$agent_pkey_path" "$rpc" $password_argument | awk '{gsub(/"/, "\047", $0); print $0}')
1065+
if [[ "$current_safe_owners" == "['$operator_address']" ]]; then
1066+
echo "[Operator] Swapping Safe owner..."
1067+
poetry run python "../scripts/swap_safe_owner.py" "$service_safe_address" "../$operator_pkey_path" "$agent_address" "$rpc" $password_argument
1068+
fi
1069+
1070+
10601071
echo ""
10611072
echo "Finished checking Autonolas Protocol service $service_id state."
10621073

scripts/staking.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@ def main() -> None:
353353
sys.exit(0)
354354

355355
print(
356-
f"Service {args.service_id} is already staked on {staking_program}."
356+
f"Service {args.service_id} is already staked on {staking_program}. "
357357
f"Checking if the staking contract has any rewards..."
358358
)
359359
available_rewards = get_available_rewards(

scripts/utils.py

+7
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,10 @@ def is_service_staked(
179179
service_staking_state = staking_contract.get_service_staking_state(
180180
ledger_api, staking_contract_address, service_id
181181
).pop("data")
182+
183+
if isinstance(service_staking_state, int):
184+
service_staking_state = StakingState(service_staking_state)
185+
182186
is_staked = service_staking_state == StakingState.STAKED or service_staking_state == StakingState.EVICTED
183187
return is_staked
184188

@@ -191,6 +195,9 @@ def is_service_evicted(
191195
ledger_api, staking_contract_address, service_id
192196
).pop("data")
193197

198+
if isinstance(service_staking_state, int):
199+
service_staking_state = StakingState(service_staking_state)
200+
194201
is_evicted = service_staking_state == StakingState.EVICTED
195202
return is_evicted
196203

0 commit comments

Comments
 (0)