consensusaccounts

package
v0.8.2 Latest Latest
Warning

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

Go to latest
Published: Mar 27, 2024 License: Apache-2.0 Imports: 8 Imported by: 9

Documentation

Index

Constants

View Source
const (
	// DepositEventCode is the event code for the deposit event.
	DepositEventCode = 1
	// WithdrawEventCode is the event code for the withdraw event.
	WithdrawEventCode = 2
	// DelegateEventCode is the event code for the delegate event.
	DelegateEventCode = 3
	// UndelegateStartEventCode is the event code for the undelegate start event.
	UndelegateStartEventCode = 4
	// UndelegateDoneEventCode is the event code for the undelegate done event.
	UndelegateDoneEventCode = 5
)
View Source
const ModuleName = "consensus_accounts"

ModuleName is the consensus accounts module name.

Variables

View Source
var (
	// PendingWithdrawalAddress is the address of the internal pending withdrawal account in the consensus_accounts module.
	PendingWithdrawalAddress = types.NewAddressForModule(ModuleName, []byte("pending-withdrawal"))
	// PendingDelegationAddress is the address of the internal pending delegation account in the consensus_accounts module.
	PendingDelegationAddress = types.NewAddressForModule(ModuleName, []byte("pending-delegation"))
)

Functions

func DecodeEvent added in v0.2.0

func DecodeEvent(event *types.Event) ([]client.DecodedEvent, error)

func NewDelegateTx added in v0.6.0

func NewDelegateTx(fee *types.Fee, body *Delegate) *types.Transaction

NewDelegateTx generates a new consensus.Delegate transaction.

func NewDepositTx

func NewDepositTx(fee *types.Fee, body *Deposit) *types.Transaction

NewDepositTx generates a new consensus.Deposit transaction.

func NewUndelegateTx added in v0.6.0

func NewUndelegateTx(fee *types.Fee, body *Undelegate) *types.Transaction

NewUndelegateTx generates a new consensus.Undelegate transaction.

func NewWithdrawTx

func NewWithdrawTx(fee *types.Fee, body *Withdraw) *types.Transaction

NewWithdrawTx generates a new consensus.Withdraw transaction.

Types

type AccountBalance

type AccountBalance struct {
	Balance types.Quantity `json:"balance"`
}

AccountBalance is the consensus balance in an account.

type AccountQuery

type AccountQuery struct {
	Address types.Address `json:"address"`
}

AccountQuery are the arguments for consensus.Account method.

type BalanceQuery

type BalanceQuery struct {
	Address types.Address `json:"address"`
}

BalanceQuery are the arguments for consensus.Balance method.

type ConsensusError added in v0.2.0

type ConsensusError struct {
	Module string `json:"module,omitempty"`
	Code   uint32 `json:"code,omitempty"`
}

ConsensusError contains error details from the consensus layer.

type Delegate added in v0.6.0

type Delegate struct {
	To     types.Address   `json:"to"`
	Amount types.BaseUnits `json:"amount"`
}

Delegate are the arguments for consensus.Delegate method.

func (*Delegate) PrettyPrint added in v0.6.0

func (d *Delegate) PrettyPrint(ctx context.Context, prefix string, w io.Writer)

PrettyPrint writes a pretty-printed representation of the transaction to the given writer.

func (*Delegate) PrettyType added in v0.6.0

func (d *Delegate) PrettyType() (interface{}, error)

PrettyType returns a representation of the type that can be used for pretty printing.

type DelegateEvent added in v0.6.0

type DelegateEvent struct {
	From   types.Address   `json:"from"`
	Nonce  uint64          `json:"nonce"`
	To     types.Address   `json:"to"`
	Amount types.BaseUnits `json:"amount"`
	Error  *ConsensusError `json:"error,omitempty"`
}

DelegateEvent is a delegate event.

func (*DelegateEvent) IsSuccess added in v0.6.0

func (we *DelegateEvent) IsSuccess() bool

IsSuccess checks whether the event indicates a successful operation.

type DelegationInfo added in v0.6.0

type DelegationInfo struct {
	Shares types.Quantity `json:"shares"`
}

DelegationInfo is information about a delegation.

type DelegationQuery added in v0.6.0

type DelegationQuery struct {
	From types.Address `json:"from"`
	To   types.Address `json:"to"`
}

DelegationQuery are the arguments for consensus.Delegation method.

type DelegationsQuery added in v0.6.0

type DelegationsQuery struct {
	From types.Address `json:"from"`
}

DelegationsQuery are the arguments for consensus.Delegations method.

type Deposit

type Deposit struct {
	To     *types.Address  `json:"to,omitempty"`
	Amount types.BaseUnits `json:"amount"`
}

Deposit are the arguments for consensus.Deposit method.

func (*Deposit) PrettyPrint added in v0.4.0

func (f *Deposit) PrettyPrint(ctx context.Context, prefix string, w io.Writer)

PrettyPrint writes a pretty-printed representation of the transaction to the given writer.

func (*Deposit) PrettyType added in v0.4.0

func (f *Deposit) PrettyType() (interface{}, error)

PrettyType returns a representation of the type that can be used for pretty printing.

type DepositEvent added in v0.2.0

type DepositEvent struct {
	From   types.Address   `json:"from"`
	Nonce  uint64          `json:"nonce"`
	To     types.Address   `json:"to"`
	Amount types.BaseUnits `json:"amount"`
	Error  *ConsensusError `json:"error,omitempty"`
}

DepositEvent is a deposit event.

func (*DepositEvent) IsSuccess added in v0.2.0

func (de *DepositEvent) IsSuccess() bool

IsSuccess checks whether the event indicates a successful operation.

type Event added in v0.2.0

type Event struct {
	Deposit         *DepositEvent
	Withdraw        *WithdrawEvent
	Delegate        *DelegateEvent
	UndelegateStart *UndelegateStartEvent
	UndelegateDone  *UndelegateDoneEvent
}

Event is a consensus account event.

type ExtendedDelegationInfo added in v0.6.0

type ExtendedDelegationInfo struct {
	To     types.Address  `json:"to"`
	Shares types.Quantity `json:"shares"`
}

ExtendedDelegationInfo is extended information about a delegation.

type GasCosts added in v0.2.0

type GasCosts struct {
	TxDeposit    uint64 `json:"tx_deposit"`
	TxWithdraw   uint64 `json:"tx_withdraw"`
	TxDelegate   uint64 `json:"tx_delegate"`
	TxUndelegate uint64 `json:"tx_undelegate"`
}

GasCosts are the consensus accounts module gas costs.

type Parameters added in v0.2.0

type Parameters struct {
	GasCosts GasCosts `json:"gas_costs"`

	DisableDelegate   bool `json:"disable_delegate"`
	DisableUndelegate bool `json:"disable_undelegate"`
	DisableDeposit    bool `json:"disable_deposit"`
	DisableWithdraw   bool `json:"disable_withdraw"`
}

Parameters are the parameters for the consensus accounts module.

type Undelegate added in v0.6.0

type Undelegate struct {
	From   types.Address  `json:"from"`
	Shares types.Quantity `json:"shares"`
}

Undelegate are the arguments for consensus.Undelegate method.

func (*Undelegate) PrettyPrint added in v0.6.0

func (ud *Undelegate) PrettyPrint(_ context.Context, prefix string, w io.Writer)

PrettyPrint writes a pretty-printed representation of the transaction to the given writer.

func (*Undelegate) PrettyType added in v0.6.0

func (ud *Undelegate) PrettyType() (interface{}, error)

PrettyType returns a representation of the type that can be used for pretty printing.

type UndelegateDoneEvent added in v0.6.0

type UndelegateDoneEvent struct {
	From   types.Address   `json:"from"`
	To     types.Address   `json:"to"`
	Shares types.Quantity  `json:"shares"`
	Amount types.BaseUnits `json:"amount"`
}

UndelegateDoneEvent is an undelegate done event.

type UndelegateStartEvent added in v0.6.0

type UndelegateStartEvent struct {
	From          types.Address    `json:"from"`
	Nonce         uint64           `json:"nonce"`
	To            types.Address    `json:"to"`
	Shares        types.Quantity   `json:"shares"`
	DebondEndTime beacon.EpochTime `json:"debond_end_time"`
	Error         *ConsensusError  `json:"error,omitempty"`
}

UndelegateStartEvent is an undelegate start event.

func (*UndelegateStartEvent) IsSuccess added in v0.6.0

func (we *UndelegateStartEvent) IsSuccess() bool

IsSuccess checks whether the event indicates a successful operation.

type UndelegationInfo added in v0.6.1

type UndelegationInfo struct {
	From   types.Address    `json:"from"`
	Epoch  beacon.EpochTime `json:"epoch"`
	Shares types.Quantity   `json:"shares"`
}

UndelegationInfo is information about an undelegation.

type UndelegationsQuery added in v0.6.1

type UndelegationsQuery struct {
	To types.Address `json:"to"`
}

UndelegationsQuery are the arguments for consensus.Undelegations method.

type V1

type V1 interface {
	client.EventDecoder

	// Deposit generates a consensus.Deposit transaction.
	Deposit(to *types.Address, amount types.BaseUnits) *client.TransactionBuilder

	// Withdraw generates a consensus.Withdraw transaction.
	Withdraw(to *types.Address, amount types.BaseUnits) *client.TransactionBuilder

	// Delegate generates a consensus.Delegate transaction.
	Delegate(to types.Address, amount types.BaseUnits) *client.TransactionBuilder

	// Undelegate generates a consensus.Undelegate transaction.
	Undelegate(from types.Address, shares types.Quantity) *client.TransactionBuilder

	// Parameters queries the consensus accounts module parameters.
	Parameters(ctx context.Context, round uint64) (*Parameters, error)

	// Balance queries the given account's balance of consensus denomination tokens.
	Balance(ctx context.Context, round uint64, query *BalanceQuery) (*AccountBalance, error)

	// ConsensusAccount queries the given consensus layer account.
	ConsensusAccount(ctx context.Context, round uint64, query *AccountQuery) (*staking.Account, error)

	// Delegation queries the given delegation metadata based on a (from, to) address pair.
	Delegation(ctx context.Context, round uint64, query *DelegationQuery) (*DelegationInfo, error)

	// Delegations queries all delegation metadata originating from a given account.
	Delegations(ctx context.Context, round uint64, query *DelegationsQuery) ([]*ExtendedDelegationInfo, error)

	// Undelegations queries all undelegation metadata to a given account.
	Undelegations(ctx context.Context, round uint64, query *UndelegationsQuery) ([]*UndelegationInfo, error)

	// GetEvents returns all consensus accounts events emitted in a given block.
	GetEvents(ctx context.Context, round uint64) ([]*Event, error)
}

V1 is the v1 consensus accounts module interface.

func NewV1

func NewV1(rc client.RuntimeClient) V1

NewV1 generates a V1 client helper for the consensus accounts module.

type Withdraw

type Withdraw struct {
	To     *types.Address  `json:"to,omitempty"`
	Amount types.BaseUnits `json:"amount"`
}

Withdraw are the arguments for consensus.Withdraw method.

func (*Withdraw) PrettyPrint added in v0.4.0

func (f *Withdraw) PrettyPrint(ctx context.Context, prefix string, w io.Writer)

PrettyPrint writes a pretty-printed representation of the transaction to the given writer.

func (*Withdraw) PrettyType added in v0.4.0

func (f *Withdraw) PrettyType() (interface{}, error)

PrettyType returns a representation of the type that can be used for pretty printing.

type WithdrawEvent added in v0.2.0

type WithdrawEvent struct {
	From   types.Address   `json:"from"`
	Nonce  uint64          `json:"nonce"`
	To     types.Address   `json:"to"`
	Amount types.BaseUnits `json:"amount"`
	Error  *ConsensusError `json:"error,omitempty"`
}

WithdrawEvent is a withdraw event.

func (*WithdrawEvent) IsSuccess added in v0.2.0

func (we *WithdrawEvent) IsSuccess() bool

IsSuccess checks whether the event indicates a successful operation.

Jump to

Keyboard shortcuts

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