Search in sources :

Example 1 with PreparedStake

use of com.radixdlt.application.tokens.state.PreparedStake in project radixdlt by radixdlt.

the class StakingConstraintScryptV4 method main.

@Override
public void main(Loader os) {
    os.substate(new SubstateDefinition<>(PreparedStake.class, SubstateTypeId.PREPARED_STAKE.id(), buf -> {
        REFieldSerialization.deserializeReservedByte(buf);
        var delegate = REFieldSerialization.deserializeKey(buf);
        var owner = REFieldSerialization.deserializeAccountREAddr(buf);
        var amount = REFieldSerialization.deserializeNonZeroUInt256(buf);
        return new PreparedStake(amount, owner, delegate);
    }, (s, buf) -> {
        REFieldSerialization.serializeReservedByte(buf);
        REFieldSerialization.serializeKey(buf, s.delegateKey());
        REFieldSerialization.serializeREAddr(buf, s.owner());
        buf.put(s.amount().toByteArray());
    }));
    os.substate(new SubstateDefinition<>(PreparedUnstakeOwnership.class, SubstateTypeId.PREPARED_UNSTAKE.id(), buf -> {
        REFieldSerialization.deserializeReservedByte(buf);
        var delegate = REFieldSerialization.deserializeKey(buf);
        var owner = REFieldSerialization.deserializeAccountREAddr(buf);
        var amount = REFieldSerialization.deserializeNonZeroUInt256(buf);
        return new PreparedUnstakeOwnership(delegate, owner, amount);
    }, (s, buf) -> {
        REFieldSerialization.serializeReservedByte(buf);
        REFieldSerialization.serializeKey(buf, s.delegateKey());
        REFieldSerialization.serializeREAddr(buf, s.owner());
        buf.put(s.amount().toByteArray());
    }));
    defineStaking(os);
}
Also used : SubstateTypeId(com.radixdlt.atom.SubstateTypeId) EndProcedure(com.radixdlt.constraintmachine.EndProcedure) StakeOwnership(com.radixdlt.application.system.state.StakeOwnership) PreparedUnstakeOwnership(com.radixdlt.application.tokens.state.PreparedUnstakeOwnership) VoidReducerState(com.radixdlt.constraintmachine.VoidReducerState) NotEnoughResourcesException(com.radixdlt.constraintmachine.exceptions.NotEnoughResourcesException) AllowDelegationFlag(com.radixdlt.application.validators.state.AllowDelegationFlag) InvalidDelegationException(com.radixdlt.constraintmachine.exceptions.InvalidDelegationException) Authorization(com.radixdlt.constraintmachine.Authorization) MismatchException(com.radixdlt.constraintmachine.exceptions.MismatchException) SubstateDefinition(com.radixdlt.atomos.SubstateDefinition) PermissionLevel(com.radixdlt.constraintmachine.PermissionLevel) ECPublicKey(com.radixdlt.crypto.ECPublicKey) UpProcedure(com.radixdlt.constraintmachine.UpProcedure) ConstraintScrypt(com.radixdlt.atomos.ConstraintScrypt) ValidatorOwnerCopy(com.radixdlt.application.validators.state.ValidatorOwnerCopy) DownProcedure(com.radixdlt.constraintmachine.DownProcedure) ProcedureException(com.radixdlt.constraintmachine.exceptions.ProcedureException) UInt256(com.radixdlt.utils.UInt256) InvalidResourceException(com.radixdlt.constraintmachine.exceptions.InvalidResourceException) PreparedStake(com.radixdlt.application.tokens.state.PreparedStake) ReducerResult(com.radixdlt.constraintmachine.ReducerResult) ReadProcedure(com.radixdlt.constraintmachine.ReadProcedure) Loader(com.radixdlt.atomos.Loader) ReducerState(com.radixdlt.constraintmachine.ReducerState) REFieldSerialization(com.radixdlt.atom.REFieldSerialization) Predicate(java.util.function.Predicate) REAddr(com.radixdlt.identifiers.REAddr) MinimumStakeException(com.radixdlt.constraintmachine.exceptions.MinimumStakeException) PreparedStake(com.radixdlt.application.tokens.state.PreparedStake) PreparedUnstakeOwnership(com.radixdlt.application.tokens.state.PreparedUnstakeOwnership)

Aggregations

StakeOwnership (com.radixdlt.application.system.state.StakeOwnership)1 PreparedStake (com.radixdlt.application.tokens.state.PreparedStake)1 PreparedUnstakeOwnership (com.radixdlt.application.tokens.state.PreparedUnstakeOwnership)1 AllowDelegationFlag (com.radixdlt.application.validators.state.AllowDelegationFlag)1 ValidatorOwnerCopy (com.radixdlt.application.validators.state.ValidatorOwnerCopy)1 REFieldSerialization (com.radixdlt.atom.REFieldSerialization)1 SubstateTypeId (com.radixdlt.atom.SubstateTypeId)1 ConstraintScrypt (com.radixdlt.atomos.ConstraintScrypt)1 Loader (com.radixdlt.atomos.Loader)1 SubstateDefinition (com.radixdlt.atomos.SubstateDefinition)1 Authorization (com.radixdlt.constraintmachine.Authorization)1 DownProcedure (com.radixdlt.constraintmachine.DownProcedure)1 EndProcedure (com.radixdlt.constraintmachine.EndProcedure)1 PermissionLevel (com.radixdlt.constraintmachine.PermissionLevel)1 ReadProcedure (com.radixdlt.constraintmachine.ReadProcedure)1 ReducerResult (com.radixdlt.constraintmachine.ReducerResult)1 ReducerState (com.radixdlt.constraintmachine.ReducerState)1 UpProcedure (com.radixdlt.constraintmachine.UpProcedure)1 VoidReducerState (com.radixdlt.constraintmachine.VoidReducerState)1 InvalidDelegationException (com.radixdlt.constraintmachine.exceptions.InvalidDelegationException)1