Documentation
¶
Index ¶
- Constants
- Variables
- func DefaultFeeGranter() string
- func GenerateMnemonic() (string, error)
- func NewMarshaler() codec.ProtoCodecMarshaler
- func ParseTxResponse(marshaler codec.ProtoCodecMarshaler, txResponse *tx.GetTxResponse, ...) error
- func StoreInFile(mnemonic string) error
- func StoreInKeyring(mnemonic string) error
- type Account
- type AutoGeneratedWallet
- type FeeGrantSetter
- type FeeGrantStatus
- type GitopiaWallet
- func (gw GitopiaWallet) Address() string
- func (gw GitopiaWallet) Export() ([]byte, error)
- func (gw GitopiaWallet) IsAutoGenerated() bool
- func (gw *GitopiaWallet) SetFeeGranter(granter string)
- func (gw GitopiaWallet) SignAndBroadcast(ctx context.Context, grpcConn *grpc.ClientConn, msgs []sdk.Msg) (*tx.GetTxResponse, error)
- func (gw GitopiaWallet) SignData(data []byte) (string, error)
- func (gw GitopiaWallet) Type() secretType
- type GitopiaWalletFile
- type Wallet
- func FromFile(ctx context.Context, bankClient banktypes.QueryClient, ...) (Wallet, error)
- func FromKeyring(ctx context.Context, bankClient banktypes.QueryClient, ...) (Wallet, error)
- func FromMnemonic(mnemonic string) (Wallet, error)
- func FromMnemonicWithFeegrant(ctx context.Context, mnemonic string, bankClient banktypes.QueryClient, ...) (Wallet, error)
- func InitGitopiaWallet(ctx context.Context, bankClient banktypes.QueryClient, ...) (Wallet, error)
- func InitWallet(ctx context.Context, bankClient banktypes.QueryClient, ...) (Wallet, error)
- func NewTestWallet(address string, signErr error) Wallet
Constants ¶
const ( UNKNOWN secretType = iota ENV_VAR LEDGER KEYRING_BACKEND GITHUB_SEC )
const DefaultFaucetURL = "https://faucet.gitopia.com/"
const (
GAS_ADJUSTMENT = 1.8
)
Variables ¶
var ErrGitopiaKeyNotConfigured = errors.New("gitopia key not configured in OS keyring")
ErrGitopiaKeyNotConfigured is returned when no mnemonic is found in the OS keyring.
Functions ¶
func DefaultFeeGranter ¶
func DefaultFeeGranter() string
DefaultFeeGranter returns the configured fee granter address.
func GenerateMnemonic ¶
GenerateMnemonic creates a new 24-word BIP-39 mnemonic using 256-bit entropy.
func NewMarshaler ¶
func NewMarshaler() codec.ProtoCodecMarshaler
func ParseTxResponse ¶
func ParseTxResponse(marshaler codec.ProtoCodecMarshaler, txResponse *tx.GetTxResponse, resp codec.ProtoMarshaler) error
ParseTxResponse parses the data from a transaction response and unmarshals the first message response into the provided type.
func StoreInFile ¶
StoreInFile persists a mnemonic to the wallet key file with secure permissions.
func StoreInKeyring ¶
StoreInKeyring stores a mnemonic in the OS keyring under the gitopia service.
Types ¶
type AutoGeneratedWallet ¶
type AutoGeneratedWallet interface {
IsAutoGenerated() bool
}
AutoGeneratedWallet is optionally implemented by wallets that were auto-generated.
type FeeGrantSetter ¶
type FeeGrantSetter interface {
SetFeeGranter(granter string)
}
FeeGrantSetter is optionally implemented by wallets that can have a fee granter set.
type FeeGrantStatus ¶
type FeeGrantStatus struct {
Claimed bool `json:"claimed"`
Error string `json:"error,omitempty"`
Message string `json:"message,omitempty"`
}
FeeGrantStatus reports the outcome of a fee grant claim attempt.
func ClaimFeeGrant ¶
func ClaimFeeGrant(ctx context.Context, address, faucetURL string) FeeGrantStatus
ClaimFeeGrant sends a POST request to the faucet to claim a fee grant for the given address. It is best-effort: on any failure (network, timeout, non-200) it returns a FeeGrantStatus with Claimed=false and an error description, but never a Go error.
type GitopiaWallet ¶
type GitopiaWallet struct {
// contains filtered or unexported fields
}
func (GitopiaWallet) Address ¶
func (gw GitopiaWallet) Address() string
func (GitopiaWallet) Export ¶
func (gw GitopiaWallet) Export() ([]byte, error)
Export returns the wallet data in JSON format for git-remote-gitopia
func (GitopiaWallet) IsAutoGenerated ¶
func (gw GitopiaWallet) IsAutoGenerated() bool
IsAutoGenerated returns true if this wallet was auto-generated (not from user config).
func (*GitopiaWallet) SetFeeGranter ¶
func (gw *GitopiaWallet) SetFeeGranter(granter string)
SetFeeGranter sets the fee granter address so transactions use fee grants.
func (GitopiaWallet) SignAndBroadcast ¶
func (gw GitopiaWallet) SignAndBroadcast(ctx context.Context, grpcConn *grpc.ClientConn, msgs []sdk.Msg) (*tx.GetTxResponse, error)
func (GitopiaWallet) Type ¶
func (gw GitopiaWallet) Type() secretType
type GitopiaWalletFile ¶
type Wallet ¶
type Wallet interface {
SignData(data []byte) (string, error)
SignAndBroadcast(ctx context.Context, grpcConn *grpc.ClientConn, msgs []sdk.Msg) (*tx.GetTxResponse, error)
Type() secretType
Address() string
Export() ([]byte, error) // Export wallet data for git-remote-gitopia
}
func FromFile ¶
func FromFile(ctx context.Context, bankClient banktypes.QueryClient, feegrantClient feegrant.QueryClient) (Wallet, error)
FromFile reads the mnemonic from the wallet key file and constructs a Wallet.
func FromKeyring ¶
func FromKeyring(ctx context.Context, bankClient banktypes.QueryClient, feegrantClient feegrant.QueryClient) (Wallet, error)
FromKeyring opens the OS keyring, retrieves the stored mnemonic, and constructs a Wallet with feegrant support.
func FromMnemonic ¶
FromMnemonic constructs a GitopiaWallet from a raw BIP-39 mnemonic. This is a convenience helper so that callers (e.g. WalletFromHeaders) can build a signing.Wallet without needing to parse wallet files or keyrings.
It derives the first Cosmos HD path (m/44'/118'/0'/0/0) using Secp256k1. NOTE: This should be used only in trusted environments, as the mnemonic is handled in-memory.
func FromMnemonicWithFeegrant ¶
func FromMnemonicWithFeegrant(ctx context.Context, mnemonic string, bankClient banktypes.QueryClient, feegrantClient feegrant.QueryClient) (Wallet, error)
FromMnemonicWithFeegrant constructs a GitopiaWallet from a mnemonic and sets feegrant if available.
func InitGitopiaWallet ¶
func InitGitopiaWallet(ctx context.Context, bankClient banktypes.QueryClient, feegrantClient feegrant.QueryClient) (Wallet, error)
func InitWallet ¶
func InitWallet(ctx context.Context, bankClient banktypes.QueryClient, feegrantClient feegrant.QueryClient, backend string) (Wallet, error)
InitWallet creates a Wallet using the specified backend. Supported backends: "keyring", "mnemonic", "file", "auto" (or empty). The "auto" backend tries: env var -> wallet key file -> legacy wallet file -> auto-generate. OS keyring is only used when explicitly set via GITOPIA_WALLET_BACKEND=keyring.
func NewTestWallet ¶
NewTestWallet returns a Wallet suitable for handler-level testing. If signErr is non-nil, SignAndBroadcast will return it.