types

package
v0.39.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 11, 2020 License: Apache-2.0 Imports: 12 Imported by: 2,212

Documentation

Overview

nolint noalias

Index

Constants

This section is empty.

Variables

View Source
var VestingCdc *codec.Codec

VestingCdc module wide codec

Functions

func KeyTestPubAddr

func KeyTestPubAddr() (crypto.PrivKey, crypto.PubKey, sdk.AccAddress)

KeyTestPubAddr generates a test key pair

func NewTestCoins

func NewTestCoins() sdk.Coins

NewTestCoins coins to more than cover the fee

func NewTestMsg

func NewTestMsg(addrs ...sdk.AccAddress) *sdk.TestMsg

NewTestMsg generates a test message

func RegisterCodec

func RegisterCodec(cdc *codec.Codec)

RegisterCodec registers concrete types on the codec

Types

type BaseVestingAccount

type BaseVestingAccount struct {
	*authtypes.BaseAccount

	OriginalVesting  sdk.Coins `json:"original_vesting" yaml:"original_vesting"`   // coins in account upon initialization
	DelegatedFree    sdk.Coins `json:"delegated_free" yaml:"delegated_free"`       // coins that are vested and delegated
	DelegatedVesting sdk.Coins `json:"delegated_vesting" yaml:"delegated_vesting"` // coins that vesting and delegated
	EndTime          int64     `json:"end_time" yaml:"end_time"`                   // when the coins become unlocked
}

BaseVestingAccount implements the VestingAccount interface. It contains all the necessary fields needed for any vesting account implementation.

func NewBaseVestingAccount

func NewBaseVestingAccount(baseAccount *authtypes.BaseAccount, originalVesting sdk.Coins, endTime int64) (*BaseVestingAccount, error)

NewBaseVestingAccount creates a new BaseVestingAccount object

func (BaseVestingAccount) GetDelegatedFree

func (bva BaseVestingAccount) GetDelegatedFree() sdk.Coins

GetDelegatedFree returns a vesting account's delegation amount that is not vesting.

func (BaseVestingAccount) GetDelegatedVesting

func (bva BaseVestingAccount) GetDelegatedVesting() sdk.Coins

GetDelegatedVesting returns a vesting account's delegation amount that is still vesting.

func (BaseVestingAccount) GetEndTime

func (bva BaseVestingAccount) GetEndTime() int64

GetEndTime returns a vesting account's end time

func (BaseVestingAccount) GetOriginalVesting

func (bva BaseVestingAccount) GetOriginalVesting() sdk.Coins

GetOriginalVesting returns a vesting account's original vesting amount

func (BaseVestingAccount) MarshalJSON

func (bva BaseVestingAccount) MarshalJSON() ([]byte, error)

MarshalJSON returns the JSON representation of a BaseVestingAccount.

func (BaseVestingAccount) MarshalYAML

func (bva BaseVestingAccount) MarshalYAML() (interface{}, error)

MarshalYAML returns the YAML representation of a BaseVestingAccount.

func (BaseVestingAccount) SpendableCoinsVestingAccount added in v0.38.0

func (bva BaseVestingAccount) SpendableCoinsVestingAccount(vestingCoins sdk.Coins) sdk.Coins

SpendableCoinsVestingAccount returns all the spendable coins for a vesting account given a set of vesting coins.

CONTRACT: The account's coins, delegated vesting coins, vestingCoins must be sorted.

func (BaseVestingAccount) String

func (bva BaseVestingAccount) String() string

func (*BaseVestingAccount) TrackDelegation

func (bva *BaseVestingAccount) TrackDelegation(vestingCoins, amount sdk.Coins)

TrackDelegation tracks a delegation amount for any given vesting account type given the amount of coins currently vesting.

CONTRACT: The account's coins, delegation coins, vesting coins, and delegated vesting coins must be sorted.

func (*BaseVestingAccount) TrackUndelegation

func (bva *BaseVestingAccount) TrackUndelegation(amount sdk.Coins)

TrackUndelegation tracks an undelegation amount by setting the necessary values by which delegated vesting and delegated vesting need to decrease and by which amount the base coins need to increase.

NOTE: The undelegation (bond refund) amount may exceed the delegated vesting (bond) amount due to the way undelegation truncates the bond refund, which can increase the validator's exchange rate (tokens/shares) slightly if the undelegated tokens are non-integral.

CONTRACT: The account's coins and undelegation coins must be sorted.

func (*BaseVestingAccount) UnmarshalJSON

func (bva *BaseVestingAccount) UnmarshalJSON(bz []byte) error

UnmarshalJSON unmarshals raw JSON bytes into a BaseVestingAccount.

func (BaseVestingAccount) Validate

func (bva BaseVestingAccount) Validate() error

Validate checks for errors on the account fields

type ContinuousVestingAccount

type ContinuousVestingAccount struct {
	*BaseVestingAccount

	StartTime int64 `json:"start_time" yaml:"start_time"` // when the coins start to vest
}

ContinuousVestingAccount implements the VestingAccount interface. It continuously vests by unlocking coins linearly with respect to time.

func NewContinuousVestingAccount

func NewContinuousVestingAccount(baseAcc *authtypes.BaseAccount, startTime, endTime int64) *ContinuousVestingAccount

NewContinuousVestingAccount returns a new ContinuousVestingAccount

func NewContinuousVestingAccountRaw

func NewContinuousVestingAccountRaw(bva *BaseVestingAccount, startTime int64) *ContinuousVestingAccount

NewContinuousVestingAccountRaw creates a new ContinuousVestingAccount object from BaseVestingAccount

func (ContinuousVestingAccount) GetStartTime

func (cva ContinuousVestingAccount) GetStartTime() int64

GetStartTime returns the time when vesting starts for a continuous vesting account.

func (ContinuousVestingAccount) GetVestedCoins

func (cva ContinuousVestingAccount) GetVestedCoins(blockTime time.Time) sdk.Coins

GetVestedCoins returns the total number of vested coins. If no coins are vested, nil is returned.

func (ContinuousVestingAccount) GetVestingCoins

func (cva ContinuousVestingAccount) GetVestingCoins(blockTime time.Time) sdk.Coins

GetVestingCoins returns the total number of vesting coins. If no coins are vesting, nil is returned.

func (ContinuousVestingAccount) MarshalJSON

func (cva ContinuousVestingAccount) MarshalJSON() ([]byte, error)

MarshalJSON returns the JSON representation of a ContinuousVestingAccount.

func (ContinuousVestingAccount) MarshalYAML

func (cva ContinuousVestingAccount) MarshalYAML() (interface{}, error)

MarshalYAML returns the YAML representation of a ContinuousVestingAccount.

func (ContinuousVestingAccount) SpendableCoins added in v0.38.0

func (cva ContinuousVestingAccount) SpendableCoins(blockTime time.Time) sdk.Coins

SpendableCoins returns the total number of spendable coins per denom for a continuous vesting account.

func (ContinuousVestingAccount) String

func (cva ContinuousVestingAccount) String() string

func (*ContinuousVestingAccount) TrackDelegation

func (cva *ContinuousVestingAccount) TrackDelegation(blockTime time.Time, amount sdk.Coins)

TrackDelegation tracks a desired delegation amount by setting the appropriate values for the amount of delegated vesting, delegated free, and reducing the overall amount of base coins.

func (*ContinuousVestingAccount) UnmarshalJSON

func (cva *ContinuousVestingAccount) UnmarshalJSON(bz []byte) error

UnmarshalJSON unmarshals raw JSON bytes into a ContinuousVestingAccount.

func (ContinuousVestingAccount) Validate

func (cva ContinuousVestingAccount) Validate() error

Validate checks for errors on the account fields

type DelayedVestingAccount

type DelayedVestingAccount struct {
	*BaseVestingAccount
}

DelayedVestingAccount implements the VestingAccount interface. It vests all coins after a specific time, but non prior. In other words, it keeps them locked until a specified time.

func NewDelayedVestingAccount

func NewDelayedVestingAccount(baseAcc *authtypes.BaseAccount, endTime int64) *DelayedVestingAccount

NewDelayedVestingAccount returns a DelayedVestingAccount

func NewDelayedVestingAccountRaw

func NewDelayedVestingAccountRaw(bva *BaseVestingAccount) *DelayedVestingAccount

NewDelayedVestingAccountRaw creates a new DelayedVestingAccount object from BaseVestingAccount

func (DelayedVestingAccount) GetStartTime

func (dva DelayedVestingAccount) GetStartTime() int64

GetStartTime returns zero since a delayed vesting account has no start time.

func (DelayedVestingAccount) GetVestedCoins

func (dva DelayedVestingAccount) GetVestedCoins(blockTime time.Time) sdk.Coins

GetVestedCoins returns the total amount of vested coins for a delayed vesting account. All coins are only vested once the schedule has elapsed.

func (DelayedVestingAccount) GetVestingCoins

func (dva DelayedVestingAccount) GetVestingCoins(blockTime time.Time) sdk.Coins

GetVestingCoins returns the total number of vesting coins for a delayed vesting account.

func (DelayedVestingAccount) MarshalJSON

func (dva DelayedVestingAccount) MarshalJSON() ([]byte, error)

MarshalJSON returns the JSON representation of a DelayedVestingAccount.

func (DelayedVestingAccount) SpendableCoins added in v0.38.0

func (dva DelayedVestingAccount) SpendableCoins(blockTime time.Time) sdk.Coins

SpendableCoins returns the total number of spendable coins for a delayed vesting account.

func (*DelayedVestingAccount) TrackDelegation

func (dva *DelayedVestingAccount) TrackDelegation(blockTime time.Time, amount sdk.Coins)

TrackDelegation tracks a desired delegation amount by setting the appropriate values for the amount of delegated vesting, delegated free, and reducing the overall amount of base coins.

func (*DelayedVestingAccount) UnmarshalJSON

func (dva *DelayedVestingAccount) UnmarshalJSON(bz []byte) error

UnmarshalJSON unmarshals raw JSON bytes into a DelayedVestingAccount.

func (DelayedVestingAccount) Validate

func (dva DelayedVestingAccount) Validate() error

Validate checks for errors on the account fields

type Period

type Period struct {
	Length int64     `json:"length" yaml:"length"` // length of the period, in seconds
	Amount sdk.Coins `json:"amount" yaml:"amount"` // amount of coins vesting during this period
}

Period defines a length of time and amount of coins that will vest

func (Period) String

func (p Period) String() string

String Period implements stringer interface

type PeriodicVestingAccount

type PeriodicVestingAccount struct {
	*BaseVestingAccount
	StartTime      int64   `json:"start_time" yaml:"start_time"`           // when the coins start to vest
	VestingPeriods Periods `json:"vesting_periods" yaml:"vesting_periods"` // the vesting schedule
}

PeriodicVestingAccount implements the VestingAccount interface. It periodically vests by unlocking coins during each specified period

func NewPeriodicVestingAccount

func NewPeriodicVestingAccount(baseAcc *authtypes.BaseAccount, startTime int64, periods Periods) *PeriodicVestingAccount

NewPeriodicVestingAccount returns a new PeriodicVestingAccount

func NewPeriodicVestingAccountRaw

func NewPeriodicVestingAccountRaw(bva *BaseVestingAccount, startTime int64, periods Periods) *PeriodicVestingAccount

NewPeriodicVestingAccountRaw creates a new PeriodicVestingAccount object from BaseVestingAccount

func (PeriodicVestingAccount) GetStartTime

func (pva PeriodicVestingAccount) GetStartTime() int64

GetStartTime returns the time when vesting starts for a periodic vesting account.

func (PeriodicVestingAccount) GetVestedCoins

func (pva PeriodicVestingAccount) GetVestedCoins(blockTime time.Time) sdk.Coins

GetVestedCoins returns the total number of vested coins. If no coins are vested, nil is returned.

func (PeriodicVestingAccount) GetVestingCoins

func (pva PeriodicVestingAccount) GetVestingCoins(blockTime time.Time) sdk.Coins

GetVestingCoins returns the total number of vesting coins. If no coins are vesting, nil is returned.

func (PeriodicVestingAccount) GetVestingPeriods

func (pva PeriodicVestingAccount) GetVestingPeriods() Periods

GetVestingPeriods returns vesting periods associated with periodic vesting account.

func (PeriodicVestingAccount) MarshalJSON

func (pva PeriodicVestingAccount) MarshalJSON() ([]byte, error)

MarshalJSON returns the JSON representation of a PeriodicVestingAccount.

func (PeriodicVestingAccount) MarshalYAML

func (pva PeriodicVestingAccount) MarshalYAML() (interface{}, error)

MarshalYAML returns the YAML representation of a PeriodicVestingAccount.

func (PeriodicVestingAccount) SpendableCoins added in v0.38.0

func (pva PeriodicVestingAccount) SpendableCoins(blockTime time.Time) sdk.Coins

SpendableCoins returns the total number of spendable coins per denom for a periodic vesting account.

func (PeriodicVestingAccount) String

func (pva PeriodicVestingAccount) String() string

func (*PeriodicVestingAccount) TrackDelegation

func (pva *PeriodicVestingAccount) TrackDelegation(blockTime time.Time, amount sdk.Coins)

TrackDelegation tracks a desired delegation amount by setting the appropriate values for the amount of delegated vesting, delegated free, and reducing the overall amount of base coins.

func (*PeriodicVestingAccount) UnmarshalJSON

func (pva *PeriodicVestingAccount) UnmarshalJSON(bz []byte) error

UnmarshalJSON unmarshals raw JSON bytes into a PeriodicVestingAccount.

func (PeriodicVestingAccount) Validate

func (pva PeriodicVestingAccount) Validate() error

Validate checks for errors on the account fields

type Periods

type Periods []Period

Periods stores all vesting periods passed as part of a PeriodicVestingAccount

func (Periods) String

func (vp Periods) String() string

String Periods implements stringer interface

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL