api

package
v0.3.3 Latest Latest
Warning

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

Go to latest
Published: Aug 28, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package api implements the vault backend API.

Package api implements the vault backend API.

Index

Constants

View Source
const (
	// GasOpCreate is the gas operation identifier for creating a vault.
	GasOpCreate transaction.Op = "create"
	// GasOpAuthorizeAction is the gas operation identifier for authorizing an action.
	GasOpAuthorizeAction transaction.Op = "authorize_action"
	// GasOpCancelAction is the gas operation identifier for canceling an action.
	GasOpCancelAction transaction.Op = "cancel_action"
)
View Source
const (
	StateSuspended = 0
	StateActive    = 1
)
View Source
const (
	// ModuleName is a unique module name for the vault module.
	ModuleName = "vault"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Action

type Action struct {
	// Suspend is the suspend action.
	Suspend *ActionSuspend `json:"suspend,omitempty"`
	// Resume is the resume action.
	Resume *ActionResume `json:"resume,omitempty"`
	// ExecuteMessage is the execute message action.
	ExecuteMessage *ActionExecuteMessage `json:"execute_msg,omitempty"`
	// UpdateWithdrawPolicy is the withdraw policy update action.
	UpdateWithdrawPolicy *ActionUpdateWithdrawPolicy `json:"update_withdraw_policy,omitempty"`
	// UpdateAuthority is the authority update action.
	UpdateAuthority *ActionUpdateAuthority `json:"update_authority,omitempty"`
}

Action is a vault action.

type ActionCanceledEvent

type ActionCanceledEvent struct {
	// Vault is the vault address.
	Vault staking.Address `json:"vault"`
	// Nonce is the action nonce.
	Nonce uint64 `json:"nonce"`
}

ActionCanceledEvent is the event emitted when a vault action is canceled.

type ActionExecuteMessage

type ActionExecuteMessage struct {
	// Method is the method that should be called.
	Method transaction.MethodName `json:"method"`
	// Body is the method call body.
	Body cbor.RawMessage `json:"body,omitempty"`
}

ActionExecuteMessage is the action to execute a message on behalf of the vault. The message is dispatched as if the vault originated a transaction.

type ActionExecutedEvent

type ActionExecutedEvent struct {
	// Vault is the vault address.
	Vault staking.Address `json:"vault"`
	// Nonce is the action nonce.
	Nonce uint64 `json:"nonce"`
	// Result is the action execution result.
	Result ActionExecutionResult `json:"result,omitempty"`
}

ActionExecutedEvent is the event emitted when a new vault action is executed.

type ActionExecutionResult

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

ActionExecutionResult is the result of executing an action.

type ActionResume

type ActionResume struct{}

ActionResume is the action to suspend the vault.

type ActionSubmittedEvent

type ActionSubmittedEvent struct {
	// Submitter is the account address of the submitter.
	Submitter staking.Address `json:"submitter"`
	// Vault is the vault address.
	Vault staking.Address `json:"vault"`
	// Nonce is the action nonce.
	Nonce uint64 `json:"nonce"`
}

ActionSubmittedEvent is the event emitted when a new vault action is submitted.

type ActionSuspend

type ActionSuspend struct{}

ActionSuspend is the action to suspend the vault.

type ActionUpdateAuthority

type ActionUpdateAuthority struct {
	// AdminAuthority is the new admin authority. If the field is nil no update should be done.
	AdminAuthority *Authority `json:"admin_authority,omitempty"`
	// SuspendAuthority is the new suspend authority. If the field is nil no update should be done.
	SuspendAuthority *Authority `json:"suspend_authority,omitempty"`
}

ActionUpdateAuthority is the action to update one of the vault authorities.

type ActionUpdateWithdrawPolicy

type ActionUpdateWithdrawPolicy struct {
	// Address is the address the policy update is for.
	Address staking.Address `json:"address"`
	// Policy is the new withdraw policy.
	Policy WithdrawPolicy `json:"policy"`
}

ActionUpdateWithdrawPolicy is the action to update the withdraw policy for a given address.

type AddressQuery

type AddressQuery struct {
	// Height is the query height.
	Height int64 `json:"height"`
	// Vault is the vault address.
	Vault staking.Address `json:"vault"`
	// Address is the queried address.
	Address staking.Address `json:"address"`
}

AddressQuery is a query for data about a given address for the given vault.

type AddressState

type AddressState struct {
	// WithdrawPolicy is the active withdraw policy.
	WithdrawPolicy WithdrawPolicy `json:"withdraw_policy"`

	// CurrentBucket specifies the interval we are currently doing accounting for.
	CurrentBucket uint64 `json:"bucket"`
	// CurrentAmount specifies the amount already withdrawn in the current interval.
	CurrentAmount quantity.Quantity `json:"amount"`
}

AddressState is the state stored for the given address.

type Authority

type Authority struct {
	// Addresses are the addresses that can authorize an action.
	Addresses []staking.Address `json:"addresses"`
	// Threshold is the minimum number of addresses that must authorize an action.
	Threshold uint8 `json:"threshold"`
}

Authority is the vault multisig authority.

type AuthorityUpdatedEvent

type AuthorityUpdatedEvent struct {
	// Vault is the vault address.
	Vault staking.Address `json:"vault"`
}

AuthorityUpdatedEvent is the event emitted when a vault authority is updated.

type AuthorizeAction

type AuthorizeAction struct {
	// Vault is the address of the target vault.
	Vault staking.Address `json:"vault"`
	// Nonce is the action nonce.
	Nonce uint64 `json:"nonce"`
	// Action is the action that should be authorized.
	Action Action `json:"action"`
}

AuthorizeAction is an action authorization call body.

type CancelAction

type CancelAction struct {
	// Vault is the address of the target vault.
	Vault staking.Address `json:"vault"`
	// Nonce is the action nonce.
	Nonce uint64 `json:"nonce"`
}

CancelAction is an action cancelation call body.

type ConsensusParameterChanges

type ConsensusParameterChanges struct {
	// MaxAuthorityAddresses is the new maximum number of addresses that can be configured for each
	// authority.
	MaxAuthorityAddresses *uint8 `json:"max_authority_addresses,omitempty"`

	// GasCosts are the new gas costs.
	GasCosts transaction.Costs `json:"gas_costs,omitempty"`
}

ConsensusParameterChanges are allowed vault consensus parameter changes.

type ConsensusParameters

type ConsensusParameters struct {
	// Enabled specifies whether the vault service is enabled.
	Enabled bool `json:"enabled,omitempty"`

	// MaxAuthorityAddresses is the maximum number of addresses that can be configured for each
	// authority.
	MaxAuthorityAddresses uint8 `json:"max_authority_addresses,omitempty"`

	// GasCosts are the vault transaction gas costs.
	GasCosts transaction.Costs `json:"gas_costs,omitempty"`
}

ConsensusParameters are the vault consensus parameters.

type Create

type Create struct {
	// AdminAuthority specifies the vault's admin authority.
	AdminAuthority Authority `json:"admin_authority"`
	// SuspendAuthority specifies the vault's suspend authority.
	SuspendAuthority Authority `json:"suspend_authority"`
}

Create is a create call body.

type Event

type Event struct {
	Height int64     `json:"height,omitempty"`
	TxHash hash.Hash `json:"tx_hash,omitempty"`

	ActionSubmitted  *ActionSubmittedEvent  `json:"action_submitted,omitempty"`
	ActionCanceled   *ActionCanceledEvent   `json:"action_canceled,omitempty"`
	ActionExecuted   *ActionExecutedEvent   `json:"action_executed,omitempty"`
	StateChanged     *StateChangedEvent     `json:"state_changed,omitempty"`
	PolicyUpdated    *PolicyUpdatedEvent    `json:"policy_updated"`
	AuthorityUpdated *AuthorityUpdatedEvent `json:"authority_updated"`
}

Event signifies a vault event.

type Genesis

type Genesis struct {
	// Parameters are the genesis consensus parameters.
	Parameters ConsensusParameters `json:"params"`

	// Vaults are the vaults.
	Vaults []*Vault `json:"vaults,omitempty"`
	// States are the per vault per-address states.
	States map[staking.Address]map[staking.Address]*AddressState `json:"states,omitempty"`
	// PendingActions are the per-vault pending actions.
	PendingActions map[staking.Address][]*PendingAction `json:"pending_actions,omitempty"`
}

Genesis is the initial vault state for use in the genesis block.

type PendingAction

type PendingAction struct {
	// Nonce is the action nonce.
	Nonce uint64 `json:"nonce"`
	// AuthorizedBy contains the addresses that have authorized the action.
	AuthorizedBy []staking.Address `json:"authorized_by"`
	// Action is the pending action itself.
	Action Action `json:"action"`
}

PendingAction is an action waiting for authorizations in order to be executed.

type PolicyUpdatedEvent

type PolicyUpdatedEvent struct {
	// Vault is the vault address.
	Vault staking.Address `json:"vault"`
	// Address is the address for which the policy has been updated.
	Address staking.Address `json:"address"`
}

PolicyUpdatedEvent is the event emitted when a vault policy for an address is updated.

type PrettyActionExecuteMessage

type PrettyActionExecuteMessage struct {
	Method transaction.MethodName `json:"method"`
	Body   interface{}            `json:"body,omitempty"`
}

PrettyActionExecuteMessage is used for pretty-printing execute message actions so that the actual content is displayed instead of the binary blob.

It should only be used for pretty printing.

type State

type State uint8

State is the vault state.

type StateChangedEvent

type StateChangedEvent struct {
	// Vault is the vault address.
	Vault staking.Address `json:"vault"`
	// OldState is the old vault state.
	OldState State `json:"old_state"`
	// NewState is the new vault state.
	NewState State `json:"new_state"`
}

StateChangedEvent is the event emitted when a vault state is changed.

type Vault

type Vault struct {
	// Creator is the address of the vault creator.
	Creator staking.Address `json:"creator"`
	// ID is the unique per-creator identifier of the vault.
	ID uint64 `json:"id"`
	// State is the vault state.
	State State `json:"state"`
	// Nonce is the nonce to use for the next action.
	Nonce uint64 `json:"nonce,omitempty"`

	// AdminAuthority specifies the vault's admin authority.
	AdminAuthority Authority `json:"admin_authority"`
	// SuspendAuthority specifies the vault's suspend authority.
	SuspendAuthority Authority `json:"suspend_authority"`
}

Vault contains metadata about a vault.

type VaultQuery

type VaultQuery struct {
	// Height is the query height.
	Height int64 `json:"height"`
	// Address is the vault address.
	Address staking.Address `json:"address"`
}

VaultQuery is a query for data about a given vault.

type WithdrawPolicy

type WithdrawPolicy struct {
	// LimitAmount is the maximum amount of tokens that may be withdrawn in the given interval.
	LimitAmount quantity.Quantity `json:"limit_amount"`
	// LimitInterval is the interval (in blocks) when the limit amount resets.
	LimitInterval uint64 `json:"limit_interval"`
}

WithdrawPolicy is the per-address withdraw policy.

Jump to

Keyboard shortcuts

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