Documentation ¶
Overview ¶
Package state provides a structure for celestia-node's ability to access state-relevant information from as well as submit transactions/messages to the celestia network.
This package contains one main interface, `Accessor`, that defines the methods available for both accessing and updating state on the celestia network.
`Accessor` will contain three different implementations:
- Implementation over a gRPC connection with a celestia-core node called `CoreAccess`.
- Implementation over a libp2p stream with a state-providing node.
- Implementation over a local running instance of the celestia-application (this feature will be implemented in *Full* nodes).
Index ¶
- type AccAddress
- type Accessor
- type Address
- type Balance
- type CoreAccessor
- func (ca *CoreAccessor) Balance(ctx context.Context) (*Balance, error)
- func (ca *CoreAccessor) BalanceForAddress(ctx context.Context, addr Address) (*Balance, error)
- func (ca *CoreAccessor) BeginRedelegate(ctx context.Context, srcValAddr, dstValAddr ValAddress, amount Int, ...) (*TxResponse, error)
- func (ca *CoreAccessor) CancelUnbondingDelegation(ctx context.Context, valAddr ValAddress, amount, height Int, gasLim uint64) (*TxResponse, error)
- func (ca *CoreAccessor) Delegate(ctx context.Context, delAddr ValAddress, amount Int, gasLim uint64) (*TxResponse, error)
- func (ca *CoreAccessor) QueryDelegation(ctx context.Context, valAddr ValAddress) (*stakingtypes.QueryDelegationResponse, error)
- func (ca *CoreAccessor) QueryRedelegations(ctx context.Context, srcValAddr, dstValAddr ValAddress) (*stakingtypes.QueryRedelegationsResponse, error)
- func (ca *CoreAccessor) QueryUnbonding(ctx context.Context, valAddr ValAddress) (*stakingtypes.QueryUnbondingDelegationResponse, error)
- func (ca *CoreAccessor) Start(ctx context.Context) error
- func (ca *CoreAccessor) Stop(context.Context) error
- func (ca *CoreAccessor) SubmitPayForData(ctx context.Context, nID namespace.ID, data []byte, gasLim uint64) (*TxResponse, error)
- func (ca *CoreAccessor) SubmitTx(ctx context.Context, tx Tx) (*TxResponse, error)
- func (ca *CoreAccessor) SubmitTxWithBroadcastMode(ctx context.Context, tx Tx, mode sdktx.BroadcastMode) (*TxResponse, error)
- func (ca *CoreAccessor) Transfer(ctx context.Context, addr AccAddress, amount Int, gasLim uint64) (*TxResponse, error)
- func (ca *CoreAccessor) Undelegate(ctx context.Context, delAddr ValAddress, amount Int, gasLim uint64) (*TxResponse, error)
- type Int
- type Service
- func (s *Service) Balance(ctx context.Context) (*Balance, error)
- func (s *Service) BalanceForAddress(ctx context.Context, addr Address) (*Balance, error)
- func (s *Service) BeginRedelegate(ctx context.Context, srcValAddr, dstValAddr ValAddress, amount Int, ...) (*TxResponse, error)
- func (s *Service) CancelUnbondingDelegation(ctx context.Context, valAddr ValAddress, amount, height Int, gasLim uint64) (*TxResponse, error)
- func (s *Service) Delegate(ctx context.Context, delAddr ValAddress, amount Int, gasLim uint64) (*TxResponse, error)
- func (s *Service) IsStopped() bool
- func (s *Service) QueryDelegation(ctx context.Context, valAddr ValAddress) (*types.QueryDelegationResponse, error)
- func (s *Service) QueryRedelegations(ctx context.Context, srcValAddr, dstValAddr ValAddress) (*types.QueryRedelegationsResponse, error)
- func (s *Service) QueryUnbonding(ctx context.Context, valAddr ValAddress) (*types.QueryUnbondingDelegationResponse, error)
- func (s *Service) Start(context.Context) error
- func (s *Service) Stop(context.Context) error
- func (s *Service) SubmitPayForData(ctx context.Context, nID namespace.ID, data []byte, gasLim uint64) (*TxResponse, error)
- func (s *Service) SubmitTx(ctx context.Context, tx Tx) (*TxResponse, error)
- func (s *Service) Transfer(ctx context.Context, to AccAddress, amount Int, gasLimit uint64) (*TxResponse, error)
- func (s *Service) Undelegate(ctx context.Context, delAddr ValAddress, amount Int, gasLim uint64) (*TxResponse, error)
- type Tx
- type TxResponse
- type ValAddress
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AccAddress ¶ added in v0.3.1
type AccAddress = sdk.AccAddress
AccAddress is an alias to the AccAddress type from Cosmos-SDK.
type Accessor ¶
type Accessor interface { // Start starts the state Accessor. Start(context.Context) error // Stop stops the state Accessor. Stop(context.Context) error // Balance retrieves the Celestia coin balance for the node's account/signer // and verifies it against the corresponding block's AppHash. Balance(ctx context.Context) (*Balance, error) // BalanceForAddress retrieves the Celestia coin balance for the given address and verifies // the returned balance against the corresponding block's AppHash. // // NOTE: the balance returned is the balance reported by the block right before // the node's current head (head-1). This is due to the fact that for block N, the block's // `AppHash` is the result of applying the previous block's transaction list. BalanceForAddress(ctx context.Context, addr Address) (*Balance, error) // Transfer sends the given amount of coins from default wallet of the node to the given account address. Transfer(ctx context.Context, to AccAddress, amount math.Int, gasLimit uint64) (*TxResponse, error) // SubmitTx submits the given transaction/message to the // Celestia network and blocks until the tx is included in // a block. SubmitTx(ctx context.Context, tx Tx) (*TxResponse, error) // SubmitPayForData builds, signs and submits a PayForData transaction. SubmitPayForData(ctx context.Context, nID namespace.ID, data []byte, gasLim uint64) (*TxResponse, error) // CancelUnbondingDelegation cancels a user's pending undelegation from a validator. CancelUnbondingDelegation( ctx context.Context, valAddr ValAddress, amount, height Int, gasLim uint64, ) (*TxResponse, error) // BeginRedelegate sends a user's delegated tokens to a new validator for redelegation. BeginRedelegate(ctx context.Context, srcValAddr, dstValAddr ValAddress, amount Int, gasLim uint64) (*TxResponse, error) // Undelegate undelegates a user's delegated tokens, unbonding them from the current validator. Undelegate(ctx context.Context, delAddr ValAddress, amount Int, gasLim uint64) (*TxResponse, error) // Delegate sends a user's liquid tokens to a validator for delegation. Delegate(ctx context.Context, delAddr ValAddress, amount Int, gasLim uint64) (*TxResponse, error) // QueryDelegation retrieves the delegation information between a delegator and a validator. QueryDelegation(ctx context.Context, valAddr ValAddress) (*types.QueryDelegationResponse, error) // QueryUnbonding retrieves the unbonding status between a delegator and a validator. QueryUnbonding(ctx context.Context, valAddr ValAddress) (*types.QueryUnbondingDelegationResponse, error) // QueryRedelegations retrieves the status of the redelegations between a delegator and a validator. QueryRedelegations(ctx context.Context, srcValAddr, dstValAddr ValAddress) (*types.QueryRedelegationsResponse, error) }
Accessor represents the behaviors necessary for a user to query for state-related information and submit transactions/ messages to the Celestia network.
type CoreAccessor ¶
type CoreAccessor struct {
// contains filtered or unexported fields
}
CoreAccessor implements Accessor over a gRPC connection with a celestia-core node.
func NewCoreAccessor ¶
func NewCoreAccessor( signer *apptypes.KeyringSigner, getter header.Head, coreIP, rpcPort string, grpcPort string, ) *CoreAccessor
NewCoreAccessor dials the given celestia-core endpoint and constructs and returns a new CoreAccessor with the active connection.
func (*CoreAccessor) Balance ¶
func (ca *CoreAccessor) Balance(ctx context.Context) (*Balance, error)
func (*CoreAccessor) BalanceForAddress ¶
func (*CoreAccessor) BeginRedelegate ¶
func (ca *CoreAccessor) BeginRedelegate( ctx context.Context, srcValAddr, dstValAddr ValAddress, amount Int, gasLim uint64, ) (*TxResponse, error)
func (*CoreAccessor) CancelUnbondingDelegation ¶
func (ca *CoreAccessor) CancelUnbondingDelegation( ctx context.Context, valAddr ValAddress, amount, height Int, gasLim uint64, ) (*TxResponse, error)
func (*CoreAccessor) Delegate ¶
func (ca *CoreAccessor) Delegate( ctx context.Context, delAddr ValAddress, amount Int, gasLim uint64, ) (*TxResponse, error)
func (*CoreAccessor) QueryDelegation ¶ added in v0.3.1
func (ca *CoreAccessor) QueryDelegation( ctx context.Context, valAddr ValAddress, ) (*stakingtypes.QueryDelegationResponse, error)
func (*CoreAccessor) QueryRedelegations ¶ added in v0.3.1
func (ca *CoreAccessor) QueryRedelegations( ctx context.Context, srcValAddr, dstValAddr ValAddress, ) (*stakingtypes.QueryRedelegationsResponse, error)
func (*CoreAccessor) QueryUnbonding ¶ added in v0.3.1
func (ca *CoreAccessor) QueryUnbonding( ctx context.Context, valAddr ValAddress, ) (*stakingtypes.QueryUnbondingDelegationResponse, error)
func (*CoreAccessor) SubmitPayForData ¶
func (ca *CoreAccessor) SubmitPayForData( ctx context.Context, nID namespace.ID, data []byte, gasLim uint64, ) (*TxResponse, error)
func (*CoreAccessor) SubmitTx ¶
func (ca *CoreAccessor) SubmitTx(ctx context.Context, tx Tx) (*TxResponse, error)
func (*CoreAccessor) SubmitTxWithBroadcastMode ¶
func (ca *CoreAccessor) SubmitTxWithBroadcastMode( ctx context.Context, tx Tx, mode sdktx.BroadcastMode, ) (*TxResponse, error)
func (*CoreAccessor) Transfer ¶
func (ca *CoreAccessor) Transfer( ctx context.Context, addr AccAddress, amount Int, gasLim uint64, ) (*TxResponse, error)
func (*CoreAccessor) Undelegate ¶
func (ca *CoreAccessor) Undelegate( ctx context.Context, delAddr ValAddress, amount Int, gasLim uint64, ) (*TxResponse, error)
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service can access state-related information via the given Accessor.
func NewService ¶
NewService constructs a new state Service.
func (*Service) BalanceForAddress ¶
func (*Service) BeginRedelegate ¶
func (s *Service) BeginRedelegate( ctx context.Context, srcValAddr, dstValAddr ValAddress, amount Int, gasLim uint64, ) (*TxResponse, error)
func (*Service) CancelUnbondingDelegation ¶
func (s *Service) CancelUnbondingDelegation( ctx context.Context, valAddr ValAddress, amount, height Int, gasLim uint64, ) (*TxResponse, error)
func (*Service) Delegate ¶
func (s *Service) Delegate(ctx context.Context, delAddr ValAddress, amount Int, gasLim uint64) (*TxResponse, error)
func (*Service) QueryDelegation ¶ added in v0.3.1
func (s *Service) QueryDelegation( ctx context.Context, valAddr ValAddress, ) (*types.QueryDelegationResponse, error)
func (*Service) QueryRedelegations ¶ added in v0.3.1
func (s *Service) QueryRedelegations( ctx context.Context, srcValAddr, dstValAddr ValAddress, ) (*types.QueryRedelegationsResponse, error)
func (*Service) QueryUnbonding ¶ added in v0.3.1
func (s *Service) QueryUnbonding( ctx context.Context, valAddr ValAddress, ) (*types.QueryUnbondingDelegationResponse, error)
func (*Service) SubmitPayForData ¶
func (*Service) Transfer ¶
func (s *Service) Transfer(ctx context.Context, to AccAddress, amount Int, gasLimit uint64) (*TxResponse, error)
func (*Service) Undelegate ¶
func (s *Service) Undelegate(ctx context.Context, delAddr ValAddress, amount Int, gasLim uint64) (*TxResponse, error)
type TxResponse ¶
type TxResponse = sdk.TxResponse
TxResponse is an alias to the TxResponse type from Cosmos-SDK.
type ValAddress ¶ added in v0.3.1
type ValAddress = sdk.ValAddress
ValAddress is an alias to the ValAddress type from Cosmos-SDK.