client

package
v0.0.17 Latest Latest
Warning

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

Go to latest
Published: May 8, 2026 License: Apache-2.0 Imports: 62 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CertificateStateValid   = "valid"
	CertificateStateExpired = "expired"
	CertificateStateRevoked = "revoked"
)

Certificate states

View Source
const (
	// Default key and keyring settings
	DefaultKeyName        = "default"
	DefaultKeyringBackend = "test"

	// Default network settings
	DefaultNet     = "mainnet"
	DefaultChainId = "akashnet-2"
	DefaultNode    = "https://rpc.akashnet.io:443"

	// Default version and paths
	DefaultVersion      = "0.18.0"
	DefaultHome         = "/tmp/.akash"
	DefaultPath         = "/usr/local/bin/akash"
	DefaultProvidersApi = "https://akash-api.polkachu.com"

	// Validation constants
	KeyringBackendOS     = "os"
	KeyringBackendFile   = "file"
	KeyringBackendTest   = "test"
	KeyringBackendMemory = "memory"

	NetworkMainnet = "mainnet"
	NetworkTestnet = "testnet"
	NetworkSandbox = "sandbox"
)

Default configuration constants for Akash provider

View Source
const (
	// Akash network constants
	Bech32PrefixAccAddr = "akash"
)
View Source
const DepositDenom = "uact"

DepositDenom is the deposit denomination required by node v2 BME for new deployments.

Variables

View Source
var ErrManifestNotFound = errors.New("manifest not found on provider")

Functions

func DebugBroadcastError

func DebugBroadcastError(err error) string

DebugBroadcastError provides detailed debugging information for broadcast errors

func ExtractTxHashFromResponse

func ExtractTxHashFromResponse(resp interface{}) string

ExtractTxHashFromResponse attempts to extract transaction hash from broadcast response

func ExtractTxResponseFromError

func ExtractTxResponseFromError(err error) *sdktypes.TxResponse

ExtractTxResponseFromError attempts to extract transaction response details from an error

func GenerateSDLHash

func GenerateSDLHash(sdl string) []byte

GenerateSDLHash returns manifest.Version() bytes for the given SDL.

func LogTransactionDetails

func LogTransactionDetails(txResp *sdktypes.TxResponse)

LogTransactionDetails logs comprehensive transaction information

func ParseAkashError

func ParseAkashError(rawLog string) map[string]string

ParseAkashError extracts meaningful information from Akash-specific errors

func RenderSDLToYAML

func RenderSDLToYAML(sdl *resourcev1alpha1.SDL) (string, error)

RenderSDLToYAML produces the canonical YAML SDL string from a SDL CR.

func ValidateTransactionPreBroadcast

func ValidateTransactionPreBroadcast(msg sdktypes.Msg, accountAddress string) error

ValidateTransactionPreBroadcast performs pre-flight checks before broadcasting

Types

type AkashClient

type AkashClient struct {
	Config AkashProviderConfiguration
	// contains filtered or unexported fields
}

func New

func New(ctx context.Context, configuration AkashProviderConfiguration) *AkashClient

New creates a new AkashClient with direct credential configuration (legacy)

func NewFromManagedResource

func NewFromManagedResource(ctx context.Context, kubeClient client.Client, usage resource.Tracker, mg resource.Managed, pcInfo ProviderConfigInfo) (*AkashClient, error)

NewFromManagedResource creates a new AkashClient that automatically loads credentials and configuration from the ProviderConfig referenced by the managed resource

func NewFromProviderConfig

func NewFromProviderConfig(ctx context.Context, kubeClient client.Client, credSource xpv1.CredentialsSource, credSelectors xpv1.CommonCredentialSelectors, config AkashProviderConfiguration) (*AkashClient, error)

NewFromProviderConfig creates a new AkashClient from ProviderConfig credentials (legacy)

func NewWithSecretRef

func NewWithSecretRef(ctx context.Context, kubeClient client.Client, secretRef SecretReference, config AkashProviderConfiguration) *AkashClient

NewWithSecretRef creates a new AkashClient that loads credentials from a Kubernetes secret

func (*AkashClient) AddFunds

func (ak *AkashClient) AddFunds(ctx context.Context, dseq string, amount int64) error

AddFunds adds funds to a deployment's escrow account

func (*AkashClient) BroadcastWithMonitoring

func (ak *AkashClient) BroadcastWithMonitoring(ctx context.Context, msgs []sdktypes.Msg) (*sdktypes.TxResponse, error)

BroadcastWithMonitoring broadcasts a transaction with enhanced error handling

func (*AkashClient) CloseDeployment

func (ak *AkashClient) CloseDeployment(ctx context.Context, dseq string, owner string) error

CloseDeployment closes an existing deployment

func (*AkashClient) CloseLease

func (ak *AkashClient) CloseLease(ctx context.Context, seqs clienttypes.Seqs, provider string) (string, error)

CloseLease broadcasts MsgCloseLease for the lease identified by the given sequence numbers + provider. The reason is recorded as Owner-initiated close.

func (*AkashClient) CreateCertificate

func (ak *AkashClient) CreateCertificate(ctx context.Context, domains []string, owner string) (*CertificateInfo, error)

CreateCertificate generates a fresh ECDSA-P256 keypair, builds an Akash-format self-signed x509 certificate, and broadcasts MsgCreateCertificate so the chain registers the public key. Returns the cert + key PEM bytes so callers can persist them (typically to a Kubernetes Secret) for later mTLS use.

func (*AkashClient) CreateDeployment

CreateDeployment creates a new deployment with SDL content and deposit amount. The deposit denom is fixed to uact (DepositDenom) per node v2 BME.

func (*AkashClient) CreateLease

func (ak *AkashClient) CreateLease(ctx context.Context, seqs clienttypes.Seqs, provider string) (string, error)

CreateLease broadcasts MsgCreateLease for the given bid (owner from client configuration, sequence numbers + provider identify the bid). Returns the transaction hash on success.

func (*AkashClient) GenerateSDLHash

func (ak *AkashClient) GenerateSDLHash(sdl *types.SDL) (string, error)

GenerateSDLHash creates a deterministic hash of the SDL

func (*AkashClient) GetBid

func (ak *AkashClient) GetBid(ctx context.Context, bidId string) (*clienttypes.Bid, error)

GetBid retrieves a specific bid by its bidId (format: owner-dseq-gseq-oseq-provider)

func (*AkashClient) GetBids

func (ak *AkashClient) GetBids(ctx context.Context, dseq string, owner string) (clienttypes.Bids, error)

GetBids retrieves all bids on chain for the given owner+dseq. Queries the market module via chain-sdk gRPC.

func (*AkashClient) GetCertificate

func (ak *AkashClient) GetCertificate(ctx context.Context, serial string, owner string) (*CertificateInfo, error)

GetCertificate fetches a certificate from chain by (owner, serial).

func (*AkashClient) GetCertificates

func (ak *AkashClient) GetCertificates(ctx context.Context, owner string) ([]CertificateInfo, error)

GetCertificates lists all certificates on chain for a given owner.

func (*AkashClient) GetContext

func (ak *AkashClient) GetContext() context.Context

func (*AkashClient) GetCredentials

func (ak *AkashClient) GetCredentials() ([]byte, error)

GetCredentials returns the current credentials, loading from secret if needed

func (*AkashClient) GetDeployment

func (ak *AkashClient) GetDeployment(ctx context.Context, dseq string, owner string) (clienttypes.Deployment, error)

GetDeployment retrieves deployment details by DSEQ and owner

func (*AkashClient) GetDeployments

func (ak *AkashClient) GetDeployments(owner string) ([]clienttypes.DeploymentId, error)

func (*AkashClient) GetLease

func (ak *AkashClient) GetLease(ctx context.Context, seqs clienttypes.Seqs, provider string) (string, error)

GetLease queries the chain for a single lease and returns its state string ("active" | "insufficient_funds" | "closed" | "reclaiming" | "invalid").

func (*AkashClient) GetLeaseManifest

func (ak *AkashClient) GetLeaseManifest(seqs clienttypes.Seqs, provider string) (string, error)

func (*AkashClient) GetLeaseServices

func (ak *AkashClient) GetLeaseServices(seqs clienttypes.Seqs, provider string) (string, error)

func (*AkashClient) GetLeases

func (ak *AkashClient) GetLeases(ctx context.Context, dseq string, owner string) ([]bidv1.Lease, error)

GetLeases returns all leases on chain for the given owner+dseq. Used by the Deployment controller to derive the deployment phase (e.g., active lease implies "leased"; no leases + closed orders implies "expired").

func (*AkashClient) GetManifestStatus

func (ak *AkashClient) GetManifestStatus(
	ctx context.Context,
	lease LeaseInfo,
	certPEM, keyPEM []byte,
) (*ManifestStatus, error)

GetManifestStatus queries the provider's lease status endpoint over mTLS.

func (*AkashClient) GetOrders

func (ak *AkashClient) GetOrders(ctx context.Context, dseq string, owner string) ([]marketv1beta5.Order, error)

GetOrders returns all orders on chain for the given owner+dseq. Used by the Deployment controller to derive whether a bid window is currently open.

func (*AkashClient) GetPath

func (ak *AkashClient) GetPath() string

func (*AkashClient) GetServiceStatus

func (ak *AkashClient) GetServiceStatus(seqs clienttypes.Seqs, provider, serviceName string) (string, error)

func (*AkashClient) NetworkDiagnostics

func (ak *AkashClient) NetworkDiagnostics(ctx context.Context) error

NetworkDiagnostics performs comprehensive network and client diagnostics

func (*AkashClient) ProviderHostURI

func (ak *AkashClient) ProviderHostURI(ctx context.Context, providerAddr string) (string, error)

ProviderHostURI returns the on-chain HostURI for a provider by bech32 address.

func (*AkashClient) QuickDiagnostic

func (ak *AkashClient) QuickDiagnostic() error

QuickDiagnostic performs a quick diagnostic check before transactions

func (*AkashClient) RefreshCredentials

func (ak *AkashClient) RefreshCredentials() error

RefreshCredentials forces a refresh of cached credentials from the secret

func (*AkashClient) RevokeCertificate

func (ak *AkashClient) RevokeCertificate(ctx context.Context, serial string, owner string) error

RevokeCertificate broadcasts MsgRevokeCertificate for the given certificate.

func (*AkashClient) SendManifest

func (ak *AkashClient) SendManifest(dseq string, provider string, manifestLocation string) (string, error)

func (*AkashClient) SendManifestToProvider

func (ak *AkashClient) SendManifestToProvider(
	ctx context.Context,
	lease LeaseInfo,
	sdl string,
	certPEM, keyPEM []byte,
) (*ManifestStatus, error)

SendManifestToProvider PUTs the manifest to the provider over mTLS.

func (*AkashClient) SetCredentialCacheTTL

func (ak *AkashClient) SetCredentialCacheTTL(ttl time.Duration)

SetCredentialCacheTTL sets the time-to-live for credential caching

func (*AkashClient) SetGlobalTransactionNote

func (ak *AkashClient) SetGlobalTransactionNote(note string)

func (*AkashClient) UpdateDeployment

func (ak *AkashClient) UpdateDeployment(ctx context.Context, dseq string, sdl string) error

UpdateDeployment updates an existing deployment with new SDL content

func (*AkashClient) UpdateManifest

func (ak *AkashClient) UpdateManifest(
	ctx context.Context,
	lease LeaseInfo,
	sdl string,
	certPEM, keyPEM []byte,
) (*ManifestStatus, error)

UpdateManifest pushes a new SDL to the provider — same endpoint as create.

func (*AkashClient) ValidateCertificate

func (ak *AkashClient) ValidateCertificate(certInfo *CertificateInfo, autoRenew bool, validityDays int32) (bool, error)

ValidateCertificate decides whether a certificate needs renewal under an auto-renew policy. Currently checks: expired/revoked are terminal failures; otherwise renewal is needed when within 30 days of expiry.

func (*AkashClient) ValidateManifestSDL

func (ak *AkashClient) ValidateManifestSDL(sdlContent string) []ManifestError

ValidateManifestSDL parses the SDL as YAML and checks required fields.

func (*AkashClient) ValidateSDL

func (ak *AkashClient) ValidateSDL(sdl *types.SDL) []string

ValidateSDL validates an SDL structure according to Akash requirements

func (*AkashClient) WaitForTransactionConfirmation

func (ak *AkashClient) WaitForTransactionConfirmation(txHash string, timeoutSeconds int) error

WaitForTransactionConfirmation provides a simple wait mechanism

type AkashProviderConfiguration

type AkashProviderConfiguration struct {
	Creds               []byte
	Passphrase          []byte
	KeyName             string
	KeyringBackend      string
	AccountAddress      string
	Net                 string
	Version             string
	ChainId             string
	Node                string
	Home                string
	Path                string
	ProvidersApi        string
	SkipTLSVerification bool
}

type CertificateInfo

type CertificateInfo struct {
	Serial      string `json:"serial"`
	Owner       string `json:"owner"`
	Issuer      string `json:"issuer"`
	Subject     string `json:"subject"`
	NotBefore   int64  `json:"notBefore"`
	NotAfter    int64  `json:"notAfter"`
	State       string `json:"state"`
	Fingerprint string `json:"fingerprint"`
	// PEM is the certificate PEM block (CERTIFICATE).
	PEM string `json:"pem"`
	// PubkeyPEM is the public key PEM block (EC PUBLIC KEY) — what was sent
	// to the chain alongside Cert.
	PubkeyPEM string `json:"pubkeyPem,omitempty"`
	// PrivateKeyPEM is the freshly generated private key PEM block
	// (EC PRIVATE KEY). Only populated by CreateCertificate; queries from
	// chain leave this empty since the chain never stores private keys.
	// Controllers route this into a Kubernetes Secret for downstream
	// mTLS clients (Manifest delivery, lease status, etc.).
	PrivateKeyPEM string `json:"privateKeyPem,omitempty"`
	CreatedAt     int64  `json:"createdAt"`
	ExpiresAt     int64  `json:"expiresAt"`
}

CertificateInfo represents detailed certificate information from the Akash network

type EncodingConfig

type EncodingConfig struct {
	InterfaceRegistry types.InterfaceRegistry
	Codec             codec.Codec
	TxConfig          sdkclient.TxConfig
	Amino             *codec.LegacyAmino
}

EncodingConfig specifies the concrete encoding types to use for a given app.

type Expose

type Expose struct {
	Port    int                      `yaml:"port"`
	As      int                      `yaml:"as,omitempty"`
	Proto   string                   `yaml:"proto,omitempty"`
	Service string                   `yaml:"service,omitempty"`
	Global  bool                     `yaml:"global,omitempty"`
	To      []map[string]interface{} `yaml:"to,omitempty"`
	Hosts   []string                 `yaml:"hosts,omitempty"`
}

type LeaseInfo

type LeaseInfo struct {
	Owner    string
	Dseq     string
	Gseq     string
	Oseq     string
	Provider string
}

LeaseInfo contains the lease information needed for manifest operations

type ManifestError

type ManifestError struct {
	Field   string `json:"field"`
	Message string `json:"message"`
	Code    string `json:"code"`
}

ManifestError represents a validation error from the provider

type ManifestServiceInfo

type ManifestServiceInfo struct {
	Name      string            `json:"name"`
	Image     string            `json:"image"`
	Available bool              `json:"available"`
	Endpoints []ServiceEndpoint `json:"endpoints"`
}

ManifestServiceInfo represents information about a service in the manifest

type ManifestStatus

type ManifestStatus struct {
	State            string                `json:"state"`
	Version          string                `json:"version"`
	DeployedAt       int64                 `json:"deployedAt"`
	Services         []ManifestServiceInfo `json:"services"`
	ValidationErrors []ManifestError       `json:"validationErrors"`
	ProviderResponse string                `json:"providerResponse"`
}

ManifestStatus represents the status of a manifest

type NodeClient

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

NodeClient provides Akash node client functionality

func NewNodeClient

func NewNodeClient(ctx context.Context, clientCtx sdkclient.Context) *NodeClient

NewNodeClient creates a new NodeClient

func (*NodeClient) Context

func (c *NodeClient) Context() sdkclient.Context

Context returns the client context

func (*NodeClient) GetContext

func (c *NodeClient) GetContext() context.Context

GetContext returns the Go context

func (*NodeClient) Query

func (c *NodeClient) Query() *QueryClient

Query returns the query client

func (*NodeClient) Tx

func (c *NodeClient) Tx() *TxClient

Tx returns the transaction client

type Profiles

type Profiles struct {
	Compute   map[string]interface{} `yaml:"compute,omitempty"`
	Placement map[string]interface{} `yaml:"placement,omitempty"`
}

type ProviderConfigInfo

type ProviderConfigInfo struct {
	Source              xpv1.CredentialsSource
	CredentialSelectors xpv1.CommonCredentialSelectors
	PassphraseSource    *xpv1.CredentialsSource
	PassphraseSelectors *xpv1.CommonCredentialSelectors
	Configuration       *apisv1alpha1.AkashConfiguration
}

ProviderConfigInfo contains the credentials and configuration information from a ProviderConfig

type QueryClient

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

QueryClient provides query functionality

func (*QueryClient) Auth

func (q *QueryClient) Auth() authtypes.QueryClient

Auth returns the auth query client

func (*QueryClient) Bank

func (q *QueryClient) Bank() banktypes.QueryClient

Bank returns the bank query client

func (*QueryClient) Cert

func (q *QueryClient) Cert() certcli.QueryClient

Cert returns the certificate query client

func (*QueryClient) Deployment

func (q *QueryClient) Deployment() deploymentcli.QueryClient

Deployment returns the deployment query client

func (*QueryClient) Market

func (q *QueryClient) Market() marketcli.QueryClient

Market returns the market query client (orders, bids, leases)

func (*QueryClient) Provider

func (q *QueryClient) Provider() providercli.QueryClient

Provider returns the provider query client

func (*QueryClient) Staking

func (q *QueryClient) Staking() stakingtypes.QueryClient

Staking returns the staking query client

type SDLDocument

type SDLDocument struct {
	Version  string             `yaml:"version"`
	Services map[string]Service `yaml:"services"`
	Profiles *Profiles          `yaml:"profiles,omitempty"`
}

SDLDocument represents the structure of an Akash SDL document

type SecretReference

type SecretReference struct {
	Name      string
	Namespace string
	Key       string
}

type Service

type Service struct {
	Image   string            `yaml:"image"`
	Command []string          `yaml:"command,omitempty"`
	Args    []string          `yaml:"args,omitempty"`
	Env     map[string]string `yaml:"env,omitempty"`
	Expose  []Expose          `yaml:"expose,omitempty"`
}

type ServiceEndpoint

type ServiceEndpoint struct {
	URI  string `json:"uri"`
	Port int32  `json:"port"`
	Host string `json:"host"`
}

ServiceEndpoint represents an endpoint for a service

type TxClient

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

TxClient provides transaction functionality

func (*TxClient) BroadcastMsgs

func (t *TxClient) BroadcastMsgs(ctx context.Context, msgs ...sdktypes.Msg) (*sdktypes.TxResponse, error)

BroadcastMsgs broadcasts messages using the client context

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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