Introdice types module: reflect on-chain structs.

pull/2037/head
Kieran Prasch 2020-05-24 02:37:52 -07:00 committed by Kieran R. Prasch
parent bb3a0aa083
commit e5f167eb20
1 changed files with 97 additions and 0 deletions

97
nucypher/types.py Normal file
View File

@ -0,0 +1,97 @@
"""
This file is part of nucypher.
nucypher is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
nucypher is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with nucypher. If not, see <https://www.gnu.org/licenses/>.
"""
from eth_typing.evm import ChecksumAddress
from typing import TypeVar, NewType, Tuple
from web3.types import Wei, Timestamp
NuNits = NewType("NuNits", int)
Agent = TypeVar('Agent', bound='EthereumContractAgent')
Period = NewType('Period', int)
PeriodDelta = NewType('Period', int)
class ContractParams(Tuple):
pass
class ContractStruct(Tuple):
pass
class WorklockParameters(ContractParams):
token_supply: NuNits
start_bid_date: Timestamp
end_bid_date: Timestamp
end_cancellation_date: Timestamp
boosting_refund: int
staking_periods: int
min_allowed_bid: Wei
class StakingEscrowParameters(ContractParams):
seconds_per_period: int
minting_coefficient: int
lock_duration_coefficient_1: int
lock_duration_coefficient_2: int
maximum_rewarded_periods: int
first_phase_total_supply: NuNits
first_phase_max_issuance: NuNits
min_locked_periods: PeriodDelta
min_allowable_locked_tokens: NuNits
max_allowable_locked_tokens: NuNits
min_worker_periods: PeriodDelta
class SubStakeInfo(ContractStruct):
first_period: Period
last_period: Period
locked_value: NuNits
class RawSubStakeInfo(ContractStruct):
first_period: Period
last_period: Period
periods: int
locked_value: NuNits
class Downtime(ContractStruct):
start_period: Period
end_period: Period
class StakerFlags(ContractStruct):
wind_down_flag: bool
restake_flag: bool
measure_work_flag: bool
snapshot_flag: bool
class StakerInfo(ContractStruct):
value: NuNits
current_committed_period: Period
next_committed_period: Period
last_committed_period: Period
lock_restake_until_period: Period
completed_work: NuNits
worker_start_period: Period
worker: ChecksumAddress
flags: int
downtime: Tuple[Downtime]
substake_info: Tuple[RawSubStakeInfo]
history: Tuple[int]