avm

package
v1.13.3 Latest Latest
Warning

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

Go to latest
Published: Jul 18, 2025 License: BSD-3-Clause Imports: 56 Imported by: 71

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultConfig = Config{
	Network:          network.DefaultConfig,
	ChecksumsEnabled: false,
}
View Source
var ErrRejected = errors.New("rejected")

Functions

func AwaitTxAccepted added in v1.11.9

func AwaitTxAccepted(
	c *Client,
	ctx context.Context,
	txID ids.ID,
	freq time.Duration,
	options ...rpc.Option,
) error

Types

type AssetDefinition

type AssetDefinition struct {
	Name         string
	Symbol       string
	Denomination uint8
	InitialState AssetInitialState
	Memo         []byte
}

AssetDefinition describes a genesis asset and its initial state

type AssetInitialState added in v1.13.1

type AssetInitialState struct {
	FixedCap    []Holder
	VariableCap []Owners
}

AssetInitialState describes the initial state of an asset

type Balance added in v0.8.0

type Balance struct {
	AssetID string         `json:"asset"`
	Balance avajson.Uint64 `json:"balance"`
}

type Client added in v1.0.6

type Client struct {
	Requester rpc.EndpointRequester
}

func NewClient added in v1.0.6

func NewClient(uri, chain string) *Client

func (*Client) GetAllBalances deprecated added in v1.0.6

func (c *Client) GetAllBalances(
	ctx context.Context,
	addr ids.ShortID,
	includePartial bool,
	options ...rpc.Option,
) ([]Balance, error)

GetAllBalances returns all asset balances for addr.

Deprecated: GetUTXOs should be used instead.

func (*Client) GetAssetDescription added in v1.0.6

func (c *Client) GetAssetDescription(ctx context.Context, assetID string, options ...rpc.Option) (*GetAssetDescriptionReply, error)

GetAssetDescription returns a description of assetID.

func (*Client) GetAtomicUTXOs added in v1.1.3

func (c *Client) GetAtomicUTXOs(
	ctx context.Context,
	addrs []ids.ShortID,
	sourceChain string,
	limit uint32,
	startAddress ids.ShortID,
	startUTXOID ids.ID,
	options ...rpc.Option,
) ([][]byte, ids.ShortID, ids.ID, error)

GetAtomicUTXOs returns the byte representation of the atomic UTXOs controlled by addrs from sourceChain.

func (*Client) GetBalance deprecated added in v1.0.6

func (c *Client) GetBalance(
	ctx context.Context,
	addr ids.ShortID,
	assetID string,
	includePartial bool,
	options ...rpc.Option,
) (*GetBalanceReply, error)

GetBalance returns the balance of assetID held by addr.

If includePartial is set, balance includes partial owned (i.e. in a multisig) funds.

Deprecated: GetUTXOs should be used instead.

func (*Client) GetBlock added in v1.9.12

func (c *Client) GetBlock(ctx context.Context, blkID ids.ID, options ...rpc.Option) ([]byte, error)

GetBlock returns the block with the given id.

func (*Client) GetBlockByHeight added in v1.9.12

func (c *Client) GetBlockByHeight(ctx context.Context, height uint64, options ...rpc.Option) ([]byte, error)

GetBlockByHeight returns the block at the given height.

func (*Client) GetHeight added in v1.9.12

func (c *Client) GetHeight(ctx context.Context, options ...rpc.Option) (uint64, error)

GetHeight returns the height of the last accepted block.

func (*Client) GetTx added in v1.0.6

func (c *Client) GetTx(ctx context.Context, txID ids.ID, options ...rpc.Option) ([]byte, error)

GetTx returns the byte representation of txID.

func (*Client) GetTxFee added in v1.12.2

func (c *Client) GetTxFee(ctx context.Context, options ...rpc.Option) (uint64, uint64, error)

GetTxFee returns the cost to issue certain transactions.

func (*Client) GetTxStatus deprecated added in v1.0.6

func (c *Client) GetTxStatus(ctx context.Context, txID ids.ID, options ...rpc.Option) (choices.Status, error)

GetTxStatus returns the status of [txID]

Deprecated: GetTxStatus only returns Accepted or Unknown, GetTx should be used instead to determine if the tx was accepted.

func (*Client) GetUTXOs added in v1.0.6

func (c *Client) GetUTXOs(
	ctx context.Context,
	addrs []ids.ShortID,
	limit uint32,
	startAddress ids.ShortID,
	startUTXOID ids.ID,
	options ...rpc.Option,
) ([][]byte, ids.ShortID, ids.ID, error)

GetUTXOs returns the byte representation of the UTXOs controlled by addrs.

func (*Client) IssueTx added in v1.0.6

func (c *Client) IssueTx(ctx context.Context, txBytes []byte, options ...rpc.Option) (ids.ID, error)

IssueTx issues a transaction to a node and returns the TxID

type Config added in v1.5.0

type Config struct {
	Network          network.Config `json:"network"`
	ChecksumsEnabled bool           `json:"checksums-enabled"`
}

func ParseConfig added in v1.10.18

func ParseConfig(configBytes []byte) (Config, error)

type Factory

type Factory struct {
	config.Config
}

func (*Factory) New

func (f *Factory) New(logging.Logger) (interface{}, error)

type FormattedAssetID added in v0.8.0

type FormattedAssetID struct {
	AssetID ids.ID `json:"assetID"`
}

FormattedAssetID defines a JSON formatted struct containing an assetID as a string

type Genesis

type Genesis struct {
	Txs []*GenesisAsset `serialize:"true"`
}

func NewGenesis added in v1.13.1

func NewGenesis(
	networkID uint32,
	genesisData map[string]AssetDefinition,
) (*Genesis, error)

NewGenesis creates a new Genesis from genesis data

func (*Genesis) Bytes added in v1.13.1

func (g *Genesis) Bytes() ([]byte, error)

Bytes serializes the Genesis to bytes using the AVM genesis codec

type GenesisAsset

type GenesisAsset struct {
	Alias             string `serialize:"true"`
	txs.CreateAssetTx `serialize:"true"`
}

func (*GenesisAsset) Compare added in v1.10.18

func (g *GenesisAsset) Compare(other *GenesisAsset) int

type GetAllBalancesArgs added in v1.1.4

type GetAllBalancesArgs struct {
	api.JSONAddress
	IncludePartial bool `json:"includePartial"`
}

type GetAllBalancesReply added in v0.8.0

type GetAllBalancesReply struct {
	Balances []Balance `json:"balances"`
}

GetAllBalancesReply is the response from a call to GetAllBalances

type GetAssetDescriptionArgs

type GetAssetDescriptionArgs struct {
	AssetID string `json:"assetID"`
}

GetAssetDescriptionArgs are arguments for passing into GetAssetDescription requests

type GetAssetDescriptionReply

type GetAssetDescriptionReply struct {
	FormattedAssetID
	Name         string        `json:"name"`
	Symbol       string        `json:"symbol"`
	Denomination avajson.Uint8 `json:"denomination"`
}

GetAssetDescriptionReply defines the GetAssetDescription replies returned from the API

type GetBalanceArgs

type GetBalanceArgs struct {
	Address        string `json:"address"`
	AssetID        string `json:"assetID"`
	IncludePartial bool   `json:"includePartial"`
}

GetBalanceArgs are arguments for passing into GetBalance requests

type GetBalanceReply

type GetBalanceReply struct {
	Balance avajson.Uint64 `json:"balance"`
	UTXOIDs []avax.UTXOID  `json:"utxoIDs"`
}

GetBalanceReply defines the GetBalance replies returned from the API

type GetTxFeeReply added in v1.12.2

type GetTxFeeReply struct {
	TxFee            avajson.Uint64 `json:"txFee"`
	CreateAssetTxFee avajson.Uint64 `json:"createAssetTxFee"`
}

type GetTxStatusReply

type GetTxStatusReply struct {
	Status choices.Status `json:"status"`
}

GetTxStatusReply defines the GetTxStatus replies returned from the API

type Holder

type Holder struct {
	Amount  uint64
	Address string
}

Holder describes how much asset is owned by an address

type Owners

type Owners struct {
	Threshold uint32
	Minters   []string
}

Owners describes who can perform an action

type Service

type Service struct {
	// contains filtered or unexported fields
}

Service defines the base service for the asset vm

func (*Service) GetAllBalances added in v0.8.0

func (s *Service) GetAllBalances(_ *http.Request, args *GetAllBalancesArgs, reply *GetAllBalancesReply) error

GetAllBalances returns a map where:

Key: ID of an asset such that [args.Address] has a non-zero balance of the asset Value: The balance of the asset held by the address

If ![args.IncludePartial], returns only unlocked balance/UTXOs with a 1-out-of-1 multisig. Otherwise, returned balance/UTXOs includes assets held only partially by the address, and includes balances with locktime in the future.

func (*Service) GetAssetDescription

func (s *Service) GetAssetDescription(_ *http.Request, args *GetAssetDescriptionArgs, reply *GetAssetDescriptionReply) error

GetAssetDescription creates an empty account with the name passed in

func (*Service) GetBalance

func (s *Service) GetBalance(_ *http.Request, args *GetBalanceArgs, reply *GetBalanceReply) error

GetBalance returns the balance of an asset held by an address. If ![args.IncludePartial], returns only the balance held solely (1 out of 1 multisig) by the address and with a locktime in the past. Otherwise, returned balance includes assets held only partially by the address, and includes balances with locktime in the future.

func (*Service) GetBlock added in v1.9.12

func (s *Service) GetBlock(_ *http.Request, args *api.GetBlockArgs, reply *api.GetBlockResponse) error

GetBlock returns the requested block.

func (*Service) GetBlockByHeight added in v1.9.12

func (s *Service) GetBlockByHeight(_ *http.Request, args *api.GetBlockByHeightArgs, reply *api.GetBlockResponse) error

GetBlockByHeight returns the block at the given height.

func (*Service) GetHeight added in v1.9.12

func (s *Service) GetHeight(_ *http.Request, _ *struct{}, reply *api.GetHeightResponse) error

GetHeight returns the height of the last accepted block.

func (*Service) GetTx added in v0.8.0

func (s *Service) GetTx(_ *http.Request, args *api.GetTxArgs, reply *api.GetTxReply) error

GetTx returns the specified transaction

func (*Service) GetTxFee added in v1.12.2

func (s *Service) GetTxFee(_ *http.Request, _ *struct{}, reply *GetTxFeeReply) error

func (*Service) GetTxStatus deprecated

func (s *Service) GetTxStatus(_ *http.Request, args *api.JSONTxID, reply *GetTxStatusReply) error

GetTxStatus returns the status of the specified transaction

Deprecated: GetTxStatus only returns Accepted or Unknown, GetTx should be used instead to determine if the tx was accepted.

func (*Service) GetUTXOs

func (s *Service) GetUTXOs(_ *http.Request, args *api.GetUTXOsArgs, reply *api.GetUTXOsReply) error

GetUTXOs gets all utxos for passed in addresses

func (*Service) IssueTx

func (s *Service) IssueTx(_ *http.Request, args *api.FormattedTx, reply *api.JSONTxID) error

IssueTx attempts to issue a transaction into consensus

type Tx

type Tx struct {
	// contains filtered or unexported fields
}

func (*Tx) Accept added in v1.10.4

func (tx *Tx) Accept(context.Context) error

func (*Tx) Bytes added in v1.10.4

func (tx *Tx) Bytes() []byte

func (*Tx) ID added in v1.10.4

func (tx *Tx) ID() ids.ID

func (*Tx) MissingDependencies added in v1.10.4

func (tx *Tx) MissingDependencies() (set.Set[ids.ID], error)

func (*Tx) Reject added in v1.10.4

func (*Tx) Reject(context.Context) error

func (*Tx) Status added in v1.10.4

func (tx *Tx) Status() choices.Status

func (*Tx) Verify added in v1.10.4

func (tx *Tx) Verify(context.Context) error

type VM

type VM struct {
	network.Atomic

	config.Config

	avax.AddressManager
	ids.Aliaser
	utxo.Spender

	// These values are only initialized after the chain has been linearized.
	blockbuilder.Builder
	// contains filtered or unexported fields
}

func (*VM) Connected added in v1.4.8

func (vm *VM) Connected(ctx context.Context, nodeID ids.NodeID, version *version.Application) error

func (*VM) CreateHandlers

func (vm *VM) CreateHandlers(context.Context) (map[string]http.Handler, error)

func (*VM) Disconnected added in v1.4.8

func (vm *VM) Disconnected(ctx context.Context, nodeID ids.NodeID) error

func (*VM) GetBlock added in v1.9.6

func (vm *VM) GetBlock(_ context.Context, blkID ids.ID) (snowman.Block, error)

func (*VM) GetBlockIDAtHeight added in v1.10.5

func (vm *VM) GetBlockIDAtHeight(_ context.Context, height uint64) (ids.ID, error)

func (*VM) HealthCheck added in v1.2.1

func (*VM) HealthCheck(context.Context) (interface{}, error)

TODO: add health checks

func (*VM) Initialize

func (vm *VM) Initialize(
	_ context.Context,
	ctx *snow.Context,
	db database.Database,
	genesisBytes []byte,
	_ []byte,
	configBytes []byte,
	fxs []*common.Fx,
	appSender common.AppSender,
) error

func (*VM) LastAccepted added in v1.9.6

func (vm *VM) LastAccepted(context.Context) (ids.ID, error)

func (*VM) Linearize added in v1.9.6

func (vm *VM) Linearize(ctx context.Context, stopVertexID ids.ID) error

func (*VM) NewHTTPHandler added in v1.13.3

func (*VM) NewHTTPHandler(context.Context) (http.Handler, error)

func (*VM) ParseBlock added in v1.9.6

func (vm *VM) ParseBlock(_ context.Context, blkBytes []byte) (snowman.Block, error)

func (*VM) ParseTx

func (vm *VM) ParseTx(_ context.Context, bytes []byte) (snowstorm.Tx, error)

func (*VM) SetPreference added in v1.9.6

func (vm *VM) SetPreference(_ context.Context, blkID ids.ID) error

func (*VM) SetState added in v1.7.5

func (vm *VM) SetState(_ context.Context, state snow.State) error

func (*VM) Shutdown

func (vm *VM) Shutdown(context.Context) error

func (*VM) Version added in v1.4.10

func (*VM) Version(context.Context) (string, error)

type WalletClient deprecated added in v1.1.2

type WalletClient struct {
	Requester rpc.EndpointRequester
}

WalletClient for interacting with avm managed wallet.

Deprecated: Transactions should be issued using the `avalanchego/wallet/chain/x.Wallet` utility.

func NewWalletClient deprecated added in v1.1.2

func NewWalletClient(uri, chain string) *WalletClient

NewWalletClient returns an AVM wallet client for interacting with avm managed wallet

Deprecated: Transactions should be issued using the `avalanchego/wallet/chain/x.Wallet` utility.

func (*WalletClient) IssueTx added in v1.1.2

func (c *WalletClient) IssueTx(ctx context.Context, txBytes []byte, options ...rpc.Option) (ids.ID, error)

IssueTx issues a transaction to a node and returns the TxID

type WalletService added in v1.0.3

type WalletService struct {
	// contains filtered or unexported fields
}

func (*WalletService) IssueTx added in v1.0.3

func (w *WalletService) IssueTx(_ *http.Request, args *api.FormattedTx, reply *api.JSONTxID) error

IssueTx attempts to issue a transaction into consensus

Directories

Path Synopsis
Package block is a generated GoMock package.
Package block is a generated GoMock package.
executor/executormock
Package executormock is a generated GoMock package.
Package executormock is a generated GoMock package.
metricsmock
Package metricsmock is a generated GoMock package.
Package metricsmock is a generated GoMock package.
statemock
Package statemock is a generated GoMock package.
Package statemock is a generated GoMock package.
txs
txsmock
Package txsmock is a generated GoMock package.
Package txsmock is a generated GoMock package.

Jump to

Keyboard shortcuts

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