balance

package
v0.131.0 Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2026 License: MIT Imports: 9 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CheckOption

type CheckOption func(*config)

func WithChainParams

func WithChainParams(p map[uint64]Params) CheckOption

func WithCheckers

func WithCheckers(rs ...Checker) CheckOption

func WithConcurrency

func WithConcurrency(n int) CheckOption

func WithLowGasLimit

func WithLowGasLimit(l *big.Int) CheckOption

func WithTimeout

func WithTimeout(d time.Duration) CheckOption

type Checker

type Checker interface {
	Family() string
	Decimals(cldfchain.BlockChain) uint8
	Address(cldfchain.BlockChain) (string, error)
	Balance(context.Context, cldfchain.BlockChain) (*big.Int, error)
	EstimateThreshold(context.Context, cldfchain.BlockChain, *big.Int) (*big.Int, error)
}

Checker knows how to read the signer address and native balance for one chain family.

type Params

type Params struct {
	LowBalanceThreshold *big.Int `json:"low_balance_threshold,omitempty" yaml:"low_balance_threshold"`
	LowBalanceGasLimit  *big.Int `json:"low_balance_gas_limit,omitempty" yaml:"low_balance_gas_limit"`
}

Params holds the parameters used for the balance check. LowBalanceThreshold is the absolute amount compared against the signer balance, in base units of the native token (e.g. "50000000000000000"). LowGasLimit is the gas limit used to estimate the threshold if LowBalanceThreshold is not set. It is multiplied by the suggested gas price to arrive at a LowBalanceThreshold.

func (Params) Validate

func (p Params) Validate() error

type Result

type Result struct {
	ChainSelector      uint64 `json:"chain_selector"`
	ChainName          string `json:"chain_name"`
	Family             string `json:"family"`
	Address            string `json:"address,omitempty"`
	Balance            string `json:"balance,omitempty"`             // base units (wei, lamports, ...)
	BalanceFormatted   string `json:"balance_formatted,omitempty"`   // human units
	Threshold          string `json:"threshold,omitempty"`           // base units (wei, lamports, ...)
	ThresholdFormatted string `json:"threshold_formatted,omitempty"` // human units
	Status             Status `json:"status"`
	Message            string `json:"message,omitempty"`
}

func Check

func Check(ctx context.Context, chains cldfchain.BlockChains, opts ...CheckOption) []Result

Check reads the signer balance on every chain and classifies it against thresholds. It never returns an error: per-chain failures are reported as StatusError.

type Status

type Status string
const (
	StatusOK           Status = "ok"
	StatusLow          Status = "low"
	StatusUnconfigured Status = "unconfigured" // no threshold for this chain
	StatusUnsupported  Status = "unsupported"  // no Checker for this family
	StatusError        Status = "error"
)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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