models

package
v0.1.0-alpha.3 Latest Latest
Warning

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

Go to latest
Published: Mar 20, 2024 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var EmptyTempOutputID = TempOutputID{}
View Source
var ParamsTool = &ParametersTool{}

Functions

This section is empty.

Types

type AccountData

type AccountData struct {
	Status   AccountStatus
	Account  wallet.Account
	OutputID iotago.OutputID
	Index    uint32
}

type AccountStatus

type AccountStatus uint8
const (
	AccountPending AccountStatus = iota
	AccountReady
)

type Client

type Client interface {
	Client() *nodeclient.Client
	Indexer() nodeclient.IndexerClient
	// URL returns a client API url.
	URL() (cltID string)
	// PostBlock sends a block to the Tangle via a given client.
	PostBlock(ctx context.Context, block *iotago.Block) (iotago.BlockID, error)
	// PostData sends the given data (payload) by creating a block in the backend.
	PostData(ctx context.Context, data []byte) (blkID string, err error)
	// GetBlockConfirmationState returns the AcceptanceState of a given block ID.
	GetBlockConfirmationState(ctx context.Context, blkID iotago.BlockID) (resp *api.BlockMetadataResponse, err error)
	// GetBlockStateFromTransaction returns the AcceptanceState of a given transaction ID.
	GetBlockStateFromTransaction(ctx context.Context, txID iotago.TransactionID) (resp *api.BlockMetadataResponse, err error)
	// GetOutput gets the output of a given outputID.
	GetOutput(ctx context.Context, outputID iotago.OutputID) iotago.Output
	// GetTransaction gets the transaction.
	GetTransaction(ctx context.Context, txID iotago.TransactionID) (resp *iotago.SignedTransaction, err error)
	// GetTransactionMetadata gets the transaction metadata.
	GetTransactionMetadata(ctx context.Context, txID iotago.TransactionID) (resp *api.TransactionMetadataResponse, err error)
	// GetBlockIssuance returns the latest commitment and data needed to create a new block.
	GetBlockIssuance(ctx context.Context) (resp *api.IssuanceBlockHeaderResponse, err error)
	// GetCongestion returns congestion data such as rmc or issuing readiness.
	GetCongestion(ctx context.Context, addr *iotago.AccountAddress, optCommitmentID ...iotago.CommitmentID) (resp *api.CongestionResponse, err error)
	// RequestFaucetFunds requests funds from the faucet.
	RequestFaucetFunds(ctx context.Context, address iotago.Address) (err error)
	// GetAccountFromIndexer returns the outputID, accountOutput and slotIndex of a given accountAddress.
	GetAccountFromIndexer(ctx context.Context, accountAddress *iotago.AccountAddress) (*iotago.OutputID, *iotago.AccountOutput, iotago.SlotIndex, error)
	// GetCommittee returns the committee for a given epoch.
	GetCommittee(ctx context.Context) (*api.CommitteeResponse, error)
	// GetValidators returns the validators for the current epoch.
	GetValidators(ctx context.Context) (*api.ValidatorsResponse, bool, error)
	// GetValidator returns the validator data of a given accountAddress.
	GetValidator(ctx context.Context, accountAddress *iotago.AccountAddress) (resp *api.ValidatorResponse, err error)
	// GetRewards returns the rewards of a given outputID.
	GetRewards(ctx context.Context, outputID iotago.OutputID) (resp *api.ManaRewardsResponse, err error)

	iotago.APIProvider
}

type Connector

type Connector interface {
	// ServersStatuses retrieves the connected server status for each client.
	ServersStatuses() ServerInfos
	// ServerStatus retrieves the connected server status.
	ServerStatus(cltIdx int) (status *ServerInfo, err error)
	// Clients returns list of all clients.
	Clients() []Client
	// GetClients returns the numOfClt client instances that were used the longest time ago.
	GetClients(numOfClt int) []Client
	// AddClient adds a client to WebClients based on provided GoShimmerAPI url.
	AddClient(url string, setters ...options.Option[WebClient])
	// RemoveClient removes a client with the provided url from the WebClients.
	RemoveClient(url string)
	// GetClient returns the client instance that was used the longest time ago.
	GetClient() Client
}

type FaucetEnqueueRequest

type FaucetEnqueueRequest struct {
	// The bech32 address.
	Address string `json:"address"`
}

FaucetEnqueueRequest defines the request for a POST RouteFaucetEnqueue REST API call.

type Input

type Input struct {
	OutputID iotago.OutputID
	Address  iotago.Address
}

Input contains details of an input.

type OutputData

type OutputData struct {
	OutputID     iotago.OutputID
	TempID       TempOutputID
	Address      iotago.Address
	AddressIndex uint32
	PrivateKey   ed25519.PrivateKey

	OutputStruct iotago.Output
}

OutputData contains details of an output ID.

func NewOutputDataWithEmptyID

func NewOutputDataWithEmptyID(api iotago.API, addr iotago.Address, index uint32, privateKey ed25519.PrivateKey, out iotago.Output) (*OutputData, error)

func NewOutputDataWithID

func NewOutputDataWithID(api iotago.API, outputID iotago.OutputID, addr iotago.Address, index uint32, privateKey ed25519.PrivateKey, out iotago.Output) (*OutputData, error)

type Outputs

type Outputs []*OutputData

Outputs is a list of Output.

type ParametersTool

type ParametersTool struct {
	NodeURLs          []string `default:"http://localhost:8050" usage:"API URLs for clients used in test separated with commas"`
	FaucetURL         string   `default:"http://localhost:8088" usage:"Faucet URL used in test"`
	FaucetSplitNumber int      `` /* 202-byte string literal not displayed */

	AccountStatesFile                   string `default:"wallet.dat" usage:"File to store account states in"`
	BlockIssuerPrivateKey               string `` /* 213-byte string literal not displayed */
	AccountID                           string `default:"0x6aee704f25558e8aa7630fed0121da53074188abc423b3c5810f80be4936eb6e" usage:"Account ID to use for genesis account"`
	FaucetRequestsBlockIssuerPrivateKey string `default:"" usage:"Block issuer private key (in hex) to use for funds preparation from faucet outputs"`
	FaucetRequestsAccountID             string `default:"" usage:"Account ID to use for fund preparation."`
}

type PayloadIssuanceData

type PayloadIssuanceData struct {
	Type               iotago.PayloadType
	TransactionBuilder *builder.TransactionBuilder
	Payload            iotago.Payload
}

PayloadIssuanceData contains data for issuing a payload. Either ready payload or transaction build data along with issuer account required for signing.

type ServerInfo

type ServerInfo struct {
	Healthy bool
	Version string
}

type ServerInfos

type ServerInfos []*ServerInfo

type TempOutputID

type TempOutputID [32]byte

func NewTempOutputID

func NewTempOutputID(api iotago.API, out iotago.Output) (TempOutputID, error)

func (TempOutputID) Bytes

func (f TempOutputID) Bytes() []byte

func (TempOutputID) String

func (f TempOutputID) String() string

type WebClient

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

WebClient contains a GoShimmer web API to interact with a node.

func NewWebClient

func NewWebClient(url, faucetURL string, opts ...options.Option[WebClient]) (*WebClient, error)

NewWebClient creates Connector from provided iota-core API urls.

func (*WebClient) APIForEpoch

func (c *WebClient) APIForEpoch(index iotago.EpochIndex) iotago.API

func (*WebClient) APIForSlot

func (c *WebClient) APIForSlot(index iotago.SlotIndex) iotago.API

func (*WebClient) APIForTime

func (c *WebClient) APIForTime(t time.Time) iotago.API

func (*WebClient) APIForVersion

func (c *WebClient) APIForVersion(version iotago.Version) (iotago.API, error)

func (*WebClient) Client

func (c *WebClient) Client() *nodeclient.Client

func (*WebClient) CommittedAPI

func (c *WebClient) CommittedAPI() iotago.API

func (*WebClient) GetAccountFromIndexer

func (c *WebClient) GetAccountFromIndexer(ctx context.Context, accountAddress *iotago.AccountAddress) (*iotago.OutputID, *iotago.AccountOutput, iotago.SlotIndex, error)

func (*WebClient) GetBlockConfirmationState

func (c *WebClient) GetBlockConfirmationState(ctx context.Context, blkID iotago.BlockID) (*api.BlockMetadataResponse, error)

GetBlockConfirmationState returns the AcceptanceState of a given block ID.

func (*WebClient) GetBlockIssuance

func (c *WebClient) GetBlockIssuance(ctx context.Context) (resp *api.IssuanceBlockHeaderResponse, err error)

func (*WebClient) GetBlockStateFromTransaction

func (c *WebClient) GetBlockStateFromTransaction(ctx context.Context, txID iotago.TransactionID) (*api.BlockMetadataResponse, error)

GetBlockStateFromTransaction returns the AcceptanceState of a given transaction ID.

func (*WebClient) GetCommittee

func (c *WebClient) GetCommittee(ctx context.Context) (*api.CommitteeResponse, error)

func (*WebClient) GetCongestion

func (c *WebClient) GetCongestion(ctx context.Context, accAddress *iotago.AccountAddress, optCommitmentID ...iotago.CommitmentID) (resp *api.CongestionResponse, err error)

func (*WebClient) GetOutput

func (c *WebClient) GetOutput(ctx context.Context, outputID iotago.OutputID) iotago.Output

GetOutput gets the output of a given outputID.

func (*WebClient) GetRewards

func (c *WebClient) GetRewards(ctx context.Context, outputID iotago.OutputID) (*api.ManaRewardsResponse, error)

func (*WebClient) GetTransaction

func (c *WebClient) GetTransaction(ctx context.Context, txID iotago.TransactionID) (tx *iotago.SignedTransaction, err error)

GetTransaction gets the transaction.

func (*WebClient) GetTransactionMetadata

func (c *WebClient) GetTransactionMetadata(ctx context.Context, txID iotago.TransactionID) (*api.TransactionMetadataResponse, error)

GetTransactionMetadata gets the transaction metadata.

func (*WebClient) GetValidator

func (c *WebClient) GetValidator(ctx context.Context, accountAddress *iotago.AccountAddress) (resp *api.ValidatorResponse, err error)

func (*WebClient) GetValidators

func (c *WebClient) GetValidators(ctx context.Context) (*api.ValidatorsResponse, bool, error)

func (*WebClient) Indexer

func (c *WebClient) Indexer() nodeclient.IndexerClient

func (*WebClient) LatestAPI

func (c *WebClient) LatestAPI() iotago.API

func (*WebClient) PostBlock

func (c *WebClient) PostBlock(ctx context.Context, block *iotago.Block) (blockID iotago.BlockID, err error)

func (*WebClient) PostData

func (c *WebClient) PostData(ctx context.Context, data []byte) (blkID string, err error)

PostData sends the given data (payload) by creating a block in the backend.

func (*WebClient) RequestFaucetFunds

func (c *WebClient) RequestFaucetFunds(ctx context.Context, address iotago.Address) (err error)

func (*WebClient) URL

func (c *WebClient) URL() string

URL returns a client API Url.

type WebClients

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

WebClients is responsible for handling connections via GoShimmerAPI.

func NewWebClients

func NewWebClients(urls []string, faucetURL string, setters ...options.Option[WebClient]) (*WebClients, error)

NewWebClients creates Connector from provided GoShimmerAPI urls.

func (*WebClients) AddClient

func (c *WebClients) AddClient(url string, setters ...options.Option[WebClient])

AddClient adds client to WebClients based on provided GoShimmerAPI url.

func (*WebClients) Clients

func (c *WebClients) Clients() []Client

Clients returns list of all clients.

func (*WebClients) GetClient

func (c *WebClients) GetClient() Client

GetClient returns the client instance that was used the longest time ago.

func (*WebClients) GetClients

func (c *WebClients) GetClients(numOfClt int) []Client

GetClients returns the numOfClt client instances that were used the longest time ago.

func (*WebClients) RemoveClient

func (c *WebClients) RemoveClient(url string)

RemoveClient removes client with the provided url from the WebClients.

func (*WebClients) ServerStatus

func (c *WebClients) ServerStatus(cltIdx int) (status *ServerInfo, err error)

ServerStatus retrieves the connected server status.

func (*WebClients) ServersStatuses

func (c *WebClients) ServersStatuses() ServerInfos

ServersStatuses retrieves the connected server status for each client.

Jump to

Keyboard shortcuts

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