Documentation
¶
Index ¶
- Variables
- func CheckAccountExists(ctx context.Context, minion *Minion, networkClient NetworkClient, ...) (bool, string, error)
- func CheckSequenceRefresh(ctx context.Context, minion *Minion, networkClient NetworkClient) error
- type Account
- type AccountDetails
- type Bot
- type FriendbotHandler
- type Minion
- type NetworkClient
- type NetworkError
- type SimulateTransactionResult
- type SubmitResult
- type TransactionResult
Constants ¶
This section is empty.
Variables ¶
var ErrAccountExists error = errors.New(fmt.Sprintf("createAccountAlreadyExist (%s)", createAccountAlreadyExistXDR))
var ErrAccountFunded error = errors.New("account already funded to starting balance")
Functions ¶
func CheckAccountExists ¶
func CheckAccountExists(ctx context.Context, minion *Minion, networkClient NetworkClient, address string) (bool, string, error)
CheckAccountExists checks if the specified address exists as a Stellar account. And returns the current native balance of the account also. This should also be passed to the minion.
func CheckSequenceRefresh ¶
func CheckSequenceRefresh(ctx context.Context, minion *Minion, networkClient NetworkClient) error
CheckSequenceRefresh establishes the minion's initial sequence number, if needed. This should also be passed to the minion.
Types ¶
type Account ¶
Account implements the `txnbuild.Account` interface.
func (Account) GetAccountID ¶
GetAccountID returns the Account ID.
func (Account) GetSequenceNumber ¶
func (Account) IncrementSequenceNumber ¶
IncrementSequenceNumber increments the internal record of the account's sequence number by 1.
func (*Account) RefreshSequenceNumber ¶
func (a *Account) RefreshSequenceNumber(ctx context.Context, networkClient NetworkClient) error
RefreshSequenceNumber gets an Account's correct in-memory sequence number from the network.
type AccountDetails ¶
AccountDetails contains the minimal information needed about an account.
type Bot ¶
type Bot struct {
Minions []Minion
NetworkClient NetworkClient
FundContractAddresses bool
// contains filtered or unexported fields
}
Bot represents the friendbot subsystem and primarily delegates work to its Minions.
func (*Bot) SupportsContractAddresses ¶
SupportsContractAddresses returns true if the bot is configured to fund contract addresses (C addresses) and the network client supports it.
type FriendbotHandler ¶
type FriendbotHandler struct {
Friendbot *Bot
// contains filtered or unexported fields
}
FriendbotHandler causes an account at `Address` to be created.
func NewFriendbotHandler ¶
func NewFriendbotHandler(fb *Bot) *FriendbotHandler
NewFriendbotHandler returns friendbot handler based on the tracing enabled
func (*FriendbotHandler) Handle ¶
func (handler *FriendbotHandler) Handle(w http.ResponseWriter, r *http.Request)
Handle is a method that implements http.HandlerFunc
type Minion ¶
type Minion struct {
Account Account
Keypair *keypair.Full
BotAccount txnbuild.Account
BotKeypair *keypair.Full
NetworkClient NetworkClient
Network string
StartingBalance string
BaseFee int64
// Mockable functions
SubmitTransaction func(ctx context.Context, minion *Minion, networkClient NetworkClient, txHash [32]byte, tx string) (*TransactionResult, error)
CheckSequenceRefresh func(ctx context.Context, minion *Minion, networkClient NetworkClient) error
CheckAccountExists func(ctx context.Context, minion *Minion, networkClient NetworkClient, destAddress string) (bool, string, error)
// contains filtered or unexported fields
}
Minion contains a Stellar channel account and Go channels to communicate with friendbot.
type NetworkClient ¶
type NetworkClient interface {
// SubmitTransaction submits a transaction and blocks until it can return a result.
SubmitTransaction(ctx context.Context, txXDR string) error
// GetAccountDetails retrieves account information for the given account ID.
GetAccountDetails(ctx context.Context, accountID string) (*AccountDetails, error)
// SimulateTransaction simulates a transaction and returns the result.
// This is required for Soroban transactions to get resource fees and auth entries.
// For network clients that don't support simulation (like Horizon), this returns an error.
SimulateTransaction(ctx context.Context, txXDR string) (*SimulateTransactionResult, error)
// SupportsContractAddresses returns true if this network client can fund
// contract addresses (C addresses). RPC supports this, Horizon does not.
SupportsContractAddresses() bool
}
NetworkClient defines a general interface for interacting with Stellar network services. It abstracts the functionality needed for friendbot operations, allowing different implementations (Horizon, RPC, etc.) to be used interchangeably.
type NetworkError ¶
type NetworkError interface {
error
// IsNotFound returns true if the error indicates the requested resource was not found.
IsNotFound() bool
// IsBadSequence returns true if the error indicates a bad sequence number.
IsBadSequence() bool
// IsTimeout returns true if the error indicates a timeout occurred.
IsTimeout() bool
// ResultString returns the result string from the error, if available.
ResultString() (string, error)
// DiagnosticEventStrings returns the diagnostic event XDR strings from the error, if available.
DiagnosticEventStrings() []string
}
NetworkError represents a network operation error with abstracted checking methods.
type SimulateTransactionResult ¶
type SimulateTransactionResult struct {
// TransactionDataXDR is the SorobanTransactionData XDR in base64.
TransactionDataXDR string
// ResultXDR is the ScVal XDR return value from simulation in base64.
ResultXDR string
}
SimulateTransactionResult contains the result of simulating a transaction.
type SubmitResult ¶
type SubmitResult struct {
// contains filtered or unexported fields
}
SubmitResult is the result from the asynchronous tx submission.
type TransactionResult ¶
type TransactionResult struct {
Successful bool `json:"successful"`
Hash string `json:"hash"`
EnvelopeXdr string `json:"envelope_xdr"`
}
TransactionResult contains the final transaction result returned to callers.
func SubmitTransaction ¶
func SubmitTransaction(ctx context.Context, minion *Minion, networkClient NetworkClient, txHash [32]byte, tx string) (*TransactionResult, error)
SubmitTransaction should be passed to the Minion.