p

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 22, 2022 License: BSD-3-Clause Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AXIAWallet

type AXIAWallet interface {
	Context

	// Builder returns the builder that will be used to create the transactions.
	Builder() Builder

	// Signer returns the signer that will be used to sign the transactions.
	Signer() Signer

	// IssueBaseTx creates, signs, and issues a new simple value transfer.
	// Because the Corechain doesn't intend for balance transfers to occur, this
	// method is expensive and abuses the creation of allychains.
	//
	// - [outputs] specifies all the recipients and amounts that should be sent
	//   from this transaction.
	IssueBaseTx(
		outputs []*axc.TransferableOutput,
		options ...common.Option,
	) (ids.ID, error)

	// IssueAddValidatorTx creates, signs, and issues a new validator of the
	// primary network.
	//
	// - [validator] specifies all the details of the validation period such as
	//   the startTime, endTime, stake weight, and nodeID.
	// - [rewardsOwner] specifies the owner of all the rewards this validator
	//   may accrue during its validation period.
	// - [shares] specifies the fraction (out of 1,000,000) that this validator
	//   will take from delegation rewards. If 1,000,000 is provided, 100% of
	//   the delegation reward will be sent to the validator's [rewardsOwner].
	IssueAddValidatorTx(
		validator *coreChainValidator.Validator,
		rewardsOwner *secp256k1fx.OutputOwners,
		shares uint32,
		options ...common.Option,
	) (ids.ID, error)

	// IssueAddAllychainValidatorTx creates, signs, and issues a new validator of a
	// allychain.
	//
	// - [validator] specifies all the details of the validation period such as
	//   the startTime, endTime, sampling weight, nodeID, and allychainID.
	IssueAddAllychainValidatorTx(
		validator *coreChainValidator.AllychainValidator,
		options ...common.Option,
	) (ids.ID, error)

	// IssueAddNominatorTx creates, signs, and issues a new nominator to a
	// validator on the primary network.
	//
	// - [validator] specifies all the details of the delegation period such as
	//   the startTime, endTime, stake weight, and validator's nodeID.
	// - [rewardsOwner] specifies the owner of all the rewards this nominator
	//   may accrue at the end of its delegation period.
	IssueAddNominatorTx(
		validator *coreChainValidator.Validator,
		rewardsOwner *secp256k1fx.OutputOwners,
		options ...common.Option,
	) (ids.ID, error)

	// IssueCreateChainTx creates, signs, and issues a new chain in the named
	// allychain.
	//
	// - [allychainID] specifies the allychain to launch the chain in.
	// - [genesis] specifies the initial state of the new chain.
	// - [vmID] specifies the vm that the new chain will run.
	// - [fxIDs] specifies all the feature extensions that the vm should be
	//   running with.
	// - [chainName] specifies a human readable name for the chain.
	IssueCreateChainTx(
		allychainID ids.ID,
		genesis []byte,
		vmID ids.ID,
		fxIDs []ids.ID,
		chainName string,
		options ...common.Option,
	) (ids.ID, error)

	// IssueCreateAllychainTx creates, signs, and issues a new allychain with the
	// specified owner.
	//
	// - [owner] specifies who has the ability to create new chains and add new
	//   validators to the allychain.
	IssueCreateAllychainTx(
		owner *secp256k1fx.OutputOwners,
		options ...common.Option,
	) (ids.ID, error)

	// IssueImportTx creates, signs, and issues an import transaction that
	// attempts to consume all the available UTXOs and import the funds to [to].
	//
	// - [chainID] specifies the chain to be importing funds from.
	// - [to] specifies where to send the imported funds to.
	IssueImportTx(
		chainID ids.ID,
		to *secp256k1fx.OutputOwners,
		options ...common.Option,
	) (ids.ID, error)

	// IssueExportTx creates, signs, and issues an export transaction that
	// attempts to send all the provided [outputs] to the requested [chainID].
	//
	// - [chainID] specifies the chain to be exporting the funds to.
	// - [outputs] specifies the outputs to send to the [chainID].
	IssueExportTx(
		chainID ids.ID,
		outputs []*axc.TransferableOutput,
		options ...common.Option,
	) (ids.ID, error)

	// IssueUnsignedTx signs and issues the unsigned tx.
	IssueUnsignedTx(
		utx platformvm.UnsignedTx,
		options ...common.Option,
	) (ids.ID, error)

	// IssueTx issues the signed tx.
	IssueTx(
		tx *platformvm.Tx,
		options ...common.Option,
	) (ids.ID, error)
}

func NewAXIAWallet

func NewAXIAWallet(
	builder Builder,
	signer Signer,
	client platformvm.Client,
	backend Backend,
) AXIAWallet

func NewAXIAWalletWithOptions

func NewAXIAWalletWithOptions(
	axiawallet AXIAWallet,
	options ...common.Option,
) AXIAWallet

type Backend

type Backend interface {
	ChainUTXOs
	BuilderBackend
	SignerBackend

	AcceptTx(ctx stdcontext.Context, tx *platformvm.Tx) error
}

Backend defines the full interface required to support a Corechain axiawallet.

func NewBackend

func NewBackend(ctx Context, utxos ChainUTXOs, txs map[ids.ID]*platformvm.Tx) Backend

type Builder

type Builder interface {
	// GetBalance calculates the amount of each asset that this builder has
	// control over.
	GetBalance(
		options ...common.Option,
	) (map[ids.ID]uint64, error)

	// GetImportableBalance calculates the amount of each asset that this
	// builder could import from the provided chain.
	//
	// - [chainID] specifies the chain the funds are from.
	GetImportableBalance(
		chainID ids.ID,
		options ...common.Option,
	) (map[ids.ID]uint64, error)

	// NewBaseTx creates a new simple value transfer. Because the Corechain
	// doesn't intend for balance transfers to occur, this method is expensive
	// and abuses the creation of allychains.
	//
	// - [outputs] specifies all the recipients and amounts that should be sent
	//   from this transaction.
	NewBaseTx(
		outputs []*axc.TransferableOutput,
		options ...common.Option,
	) (*platformvm.UnsignedCreateAllychainTx, error)

	// NewAddValidatorTx creates a new validator of the primary network.
	//
	// - [validator] specifies all the details of the validation period such as
	//   the startTime, endTime, stake weight, and nodeID.
	// - [rewardsOwner] specifies the owner of all the rewards this validator
	//   may accrue during its validation period.
	// - [shares] specifies the fraction (out of 1,000,000) that this validator
	//   will take from delegation rewards. If 1,000,000 is provided, 100% of
	//   the delegation reward will be sent to the validator's [rewardsOwner].
	NewAddValidatorTx(
		validator *coreChainValidator.Validator,
		rewardsOwner *secp256k1fx.OutputOwners,
		shares uint32,
		options ...common.Option,
	) (*platformvm.UnsignedAddValidatorTx, error)

	// NewAddAllychainValidatorTx creates a new validator of a allychain.
	//
	// - [validator] specifies all the details of the validation period such as
	//   the startTime, endTime, sampling weight, nodeID, and allychainID.
	NewAddAllychainValidatorTx(
		validator *coreChainValidator.AllychainValidator,
		options ...common.Option,
	) (*platformvm.UnsignedAddAllychainValidatorTx, error)

	// NewAddNominatorTx creates a new nominator to a validator on the primary
	// network.
	//
	// - [validator] specifies all the details of the delegation period such as
	//   the startTime, endTime, stake weight, and validator's nodeID.
	// - [rewardsOwner] specifies the owner of all the rewards this nominator
	//   may accrue at the end of its delegation period.
	NewAddNominatorTx(
		validator *coreChainValidator.Validator,
		rewardsOwner *secp256k1fx.OutputOwners,
		options ...common.Option,
	) (*platformvm.UnsignedAddNominatorTx, error)

	// NewCreateChainTx creates a new chain in the named allychain.
	//
	// - [allychainID] specifies the allychain to launch the chain in.
	// - [genesis] specifies the initial state of the new chain.
	// - [vmID] specifies the vm that the new chain will run.
	// - [fxIDs] specifies all the feature extensions that the vm should be
	//   running with.
	// - [chainName] specifies a human readable name for the chain.
	NewCreateChainTx(
		allychainID ids.ID,
		genesis []byte,
		vmID ids.ID,
		fxIDs []ids.ID,
		chainName string,
		options ...common.Option,
	) (*platformvm.UnsignedCreateChainTx, error)

	// NewCreateAllychainTx creates a new allychain with the specified owner.
	//
	// - [owner] specifies who has the ability to create new chains and add new
	//   validators to the allychain.
	NewCreateAllychainTx(
		owner *secp256k1fx.OutputOwners,
		options ...common.Option,
	) (*platformvm.UnsignedCreateAllychainTx, error)

	// NewImportTx creates an import transaction that attempts to consume all
	// the available UTXOs and import the funds to [to].
	//
	// - [chainID] specifies the chain to be importing funds from.
	// - [to] specifies where to send the imported funds to.
	NewImportTx(
		chainID ids.ID,
		to *secp256k1fx.OutputOwners,
		options ...common.Option,
	) (*platformvm.UnsignedImportTx, error)

	// NewExportTx creates an export transaction that attempts to send all the
	// provided [outputs] to the requested [chainID].
	//
	// - [chainID] specifies the chain to be exporting the funds to.
	// - [outputs] specifies the outputs to send to the [chainID].
	NewExportTx(
		chainID ids.ID,
		outputs []*axc.TransferableOutput,
		options ...common.Option,
	) (*platformvm.UnsignedExportTx, error)
}

Builder provides a convenient interface for building unsigned Corechain transactions.

func NewBuilder

func NewBuilder(addrs ids.ShortSet, backend BuilderBackend) Builder

NewBuilder returns a new transaction builder.

  • [addrs] is the set of addresses that the builder assumes can be used when signing the transactions in the future.
  • [backend] provides the required access to the chain's context and state to build out the transactions.

func NewBuilderWithOptions

func NewBuilderWithOptions(builder Builder, options ...common.Option) Builder

NewBuilderWithOptions returns a new transaction builder that will use the given options by default.

  • [builder] is the builder that will be called to perform the underlying opterations.
  • [options] will be provided to the builder in addition to the options provided in the method calls.

type BuilderBackend

type BuilderBackend interface {
	Context
	UTXOs(ctx stdcontext.Context, sourceChainID ids.ID) ([]*axc.UTXO, error)
	GetTx(ctx stdcontext.Context, txID ids.ID) (*platformvm.Tx, error)
}

BuilderBackend specifies the required information needed to build unsigned Corechain transactions.

type ChainUTXOs

type ChainUTXOs interface {
	AddUTXO(ctx stdcontext.Context, destinationChainID ids.ID, utxo *axc.UTXO) error
	RemoveUTXO(ctx stdcontext.Context, sourceChainID, utxoID ids.ID) error

	UTXOs(ctx stdcontext.Context, sourceChainID ids.ID) ([]*axc.UTXO, error)
	GetUTXO(ctx stdcontext.Context, sourceChainID, utxoID ids.ID) (*axc.UTXO, error)
}

type Context

type Context interface {
	NetworkID() uint32
	HRP() string
	AXCAssetID() ids.ID
	BaseTxFee() uint64
	CreateAllychainTxFee() uint64
	CreateBlockchainTxFee() uint64
}

func NewContext

func NewContext(
	networkID uint32,
	axcAssetID ids.ID,
	baseTxFee uint64,
	createAllychainTxFee uint64,
	createBlockchainTxFee uint64,
) Context

func NewContextFromClients

func NewContextFromClients(
	ctx stdcontext.Context,
	infoClient info.Client,
	swapChainClient avm.Client,
) (Context, error)

func NewContextFromURI

func NewContextFromURI(ctx stdcontext.Context, uri string) (Context, error)

type Signer

type Signer interface {
	SignUnsigned(ctx stdcontext.Context, tx platformvm.UnsignedTx) (*platformvm.Tx, error)
	Sign(ctx stdcontext.Context, tx *platformvm.Tx) error
}

func NewSigner

func NewSigner(kc *secp256k1fx.Keychain, backend SignerBackend) Signer

type SignerBackend

type SignerBackend interface {
	GetUTXO(ctx stdcontext.Context, chainID, utxoID ids.ID) (*axc.UTXO, error)
	GetTx(ctx stdcontext.Context, txID ids.ID) (*platformvm.Tx, error)
}

Jump to

Keyboard shortcuts

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