Skip to content
This repository has been archived by the owner on Jan 10, 2025. It is now read-only.

Commit

Permalink
stake-pool-py: revert StakeStateV2
Browse files Browse the repository at this point in the history
  • Loading branch information
2501babe committed Oct 19, 2023
1 parent d6491c0 commit b9443f4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
14 changes: 7 additions & 7 deletions stake-pool/py/stake/state.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,24 +48,24 @@ class StakeAuthorize(IntEnum):
WITHDRAWER = 1


class StakeStateV2Type(IntEnum):
class StakeStakeType(IntEnum):
"""Stake State Types."""
UNINITIALIZED = 0
INITIALIZED = 1
STAKE = 2
REWARDS_POOL = 3


class StakeStateV2(NamedTuple):
state_type: StakeStateV2Type
class StakeStake(NamedTuple):
state_type: StakeStakeType
state: Container

"""Stake state."""
@classmethod
def decode(cls, data: str, encoding: str):
data_bytes = decode_byte_string(data, encoding)
parsed = STAKE_STATE_LAYOUT.parse(data_bytes)
return StakeStateV2(
return StakeStake(
state_type=parsed['state_type'],
state=parsed['state'],
)
Expand Down Expand Up @@ -122,9 +122,9 @@ def decode(cls, data: str, encoding: str):
# Switch(
# lambda this: this.state,
# {
# StakeStateV2Type.UNINITIALIZED: Pass,
# StakeStateV2Type.INITIALIZED: META_LAYOUT,
# StakeStateV2Type.STAKE: STAKE_AND_META_LAYOUT,
# StakeStakeType.UNINITIALIZED: Pass,
# StakeStakeType.INITIALIZED: META_LAYOUT,
# StakeStakeType.STAKE: STAKE_AND_META_LAYOUT,
# }
# ),
#
Expand Down
4 changes: 2 additions & 2 deletions stake-pool/py/tests/test_deposit_withdraw_stake.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

from stake.actions import create_stake, delegate_stake
from stake.constants import STAKE_LEN
from stake.state import StakeStateV2
from stake.state import StakeStake
from stake_pool.actions import deposit_stake, withdraw_stake, update_stake_pool
from stake_pool.constants import MINIMUM_ACTIVE_STAKE
from stake_pool.state import StakePool
Expand All @@ -25,7 +25,7 @@ async def test_deposit_withdraw_stake(async_client, validators, payer, stake_poo
await delegate_stake(async_client, payer, payer, stake, validator)
resp = await async_client.get_account_info(stake, commitment=Confirmed)
data = resp['result']['value']['data']
stake_state = StakeStateV2.decode(data[0], data[1])
stake_state = StakeStake.decode(data[0], data[1])
token_account = get_associated_token_address(payer.public_key, stake_pool.pool_mint)
pre_pool_token_balance = await async_client.get_token_account_balance(token_account, Confirmed)
pre_pool_token_balance = int(pre_pool_token_balance['result']['value']['amount'])
Expand Down

0 comments on commit b9443f4

Please sign in to comment.