cosmosutils

package
v0.3.6 Latest Latest
Warning

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

Go to latest
Published: Feb 12, 2026 License: BSD-3-Clause Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultMinitiadQuerierAppName string = "minitiad"
	DefaultMinitiadQuerierVM      string = "evm"
)
View Source
const (
	DefaultGasAdjustment = "1.4"
	TmpKeyName           = "weave.clitx.executor"
)
View Source
const (
	PolkachuBaseURL     string = "https://www.polkachu.com"
	PolkachuSnapshotURL        = PolkachuBaseURL + "/%s"
	PolkachuChainAPI           = PolkachuBaseURL + "/api/v2/chains/%s"
	PolkachuPeersAPI           = PolkachuBaseURL + "/api/v2/chains/%s/live_peers"

	PolkachuAddrBookAPI = "https://snapshots.polkachu.com/%saddrbook/%s/addrbook.json"

	DefaultInitiaPolkachuName    string = "initia"
	DefaultSnapshotFileExtension string = ".tar.lz4"
)
View Source
const (
	NoBalancesText string = "No Balances"
)

Variables

View Source
var (
	MaxIntPadding = strconv.Itoa(math.MaxInt)
)

Functions

func AddOrReplace

func AddOrReplace(appName, keyname string) (string, error)

AddOrReplace adds or replaces a key using `initiad keys add <keyname> --keyring-backend test` with 'y' confirmation

func CompareSemVer

func CompareSemVer(v1, v2 string) bool

CompareSemVer compares two semantic version strings and returns true if v1 is greater than v2. Examples:

  • CompareSemVer("v2.0.0", "v1.0.0") returns true
  • CompareSemVer("v1.2.0", "v1.1.0") returns true
  • CompareSemVer("v1.0.0", "v1.0.0-beta") returns true
  • CompareSemVer("v1.0.0-beta.2", "v1.0.0-beta.1") returns true
  • CompareSemVer("v1.0.0", "v2.0.0") returns false

func CreateOPChildUpdateParamsMsg

func CreateOPChildUpdateParamsMsg(filePath string, params OPChildParams) error

func DeleteKey

func DeleteKey(appName, keyname string) error

func DownloadPolkachuAddrBook added in v0.1.2

func DownloadPolkachuAddrBook(chainType registry.ChainType, dest string) error

func FetchPolkachuPersistentPeers added in v0.1.0

func FetchPolkachuPersistentPeers(chainType registry.ChainType) (string, error)

func FetchPolkachuSnapshotDownloadURL

func FetchPolkachuSnapshotDownloadURL(chainSlug string) (string, error)

func FetchPolkachuStateSyncPeers

func FetchPolkachuStateSyncPeers(chainType registry.ChainType) (string, error)

func FetchPolkachuStateSyncURL

func FetchPolkachuStateSyncURL(chainType registry.ChainType) (string, error)

func GetAddressFromMnemonic

func GetAddressFromMnemonic(appName, mnemonic string) (string, error)

func GetBinaryVersion

func GetBinaryVersion(appName string) (string, error)

func GetInitiaBinaryPath

func GetInitiaBinaryPath(version string) (string, error)

func GetInitiaBinaryUrlFromLcd

func GetInitiaBinaryUrlFromLcd(httpClient *client.HTTPClient, rest string) (string, string, error)

func GetLatestMinitiaVersion

func GetLatestMinitiaVersion(vm string) (string, string, error)

func GetLatestOPInitBotVersion added in v0.1.6

func GetLatestOPInitBotVersion() (string, string, error)

func GetLatestRapidRelayerVersion added in v0.3.4

func GetLatestRapidRelayerVersion() (string, error)

GetLatestRapidRelayerVersion fetches the latest release tag from the rapid-relayer GitHub repository. Returns only the tag name (e.g., "v1.0.7") since rapid-relayer is distributed as a Docker image.

func GetLatestWeaveVersion added in v0.1.6

func GetLatestWeaveVersion() (string, string, error)

func GetMinitiadBinaryPath added in v0.3.4

func GetMinitiadBinaryPath(vm, version string) (string, error)

func GetMinitiadBinaryUrlFromLcd added in v0.3.4

func GetMinitiadBinaryUrlFromLcd(httpClient *client.HTTPClient, rest string) (vm string, version string, url string, err error)

func InstallCosmovisor

func InstallCosmovisor(version string) (string, error)

func InstallInitiaBinary

func InstallInitiaBinary(version, url, binaryPath string) error

func InstallMinitiadBinary added in v0.3.4

func InstallMinitiadBinary(vm, version, url, binaryPath string) error

func KeyExists

func KeyExists(appName, keyname string) bool

KeyExists checks if a key with the given keyName exists using `initiad keys show`

func OPInitAddOrReplace

func OPInitAddOrReplace(appName, keyname string, isCelestia bool, opInitHome string) (string, error)

OPInitAddOrReplace adds or replaces a key using `opinitd keys add <keyname> --keyring-backend test` with 'y' confirmation

func OPInitGetAddressForKey

func OPInitGetAddressForKey(appName, keyname, opInitHome string) (string, error)

OPInitGetAddressForKey retrieves the address for a given key using opinitd.

func OPInitGrantOracle

func OPInitGrantOracle(appName, address, opInitHome string) error

OPInitGrantOracle grants oracle permissions to a specific address.

func OPInitKeyExist

func OPInitKeyExist(appName, keyname, opInitHome string) bool

func OPInitRecoverKeyFromMnemonic

func OPInitRecoverKeyFromMnemonic(appName, keyname, mnemonic string, isCelestia bool, opInitHome string) (string, error)

OPInitRecoverKeyFromMnemonic recovers or replaces a key using a mnemonic phrase If the key already exists, it will replace the key and confirm with 'y' before adding the mnemonic

func QueryChannels added in v0.3.0

func QueryChannels(addresses []string) (params types.ChannelsResponse, err error)

func QueryCreateBridgeHeight

func QueryCreateBridgeHeight(client *client.GraphQLClient, bridgeId string) (int, error)

func QueryLatestDepositHeight

func QueryLatestDepositHeight(client *client.GraphQLClient, bridgeId, sequence string) (int, error)

func RecoverKeyFromMnemonic

func RecoverKeyFromMnemonic(appName, keyname, mnemonic string) (string, error)

RecoverKeyFromMnemonic recovers or replaces a key using a mnemonic phrase If the key already exists, it will replace the key and confirm with 'y' before adding the mnemonic Uses default coin type: 60 for gas station keys, 118 for others

func RecoverKeyFromMnemonicWithCoinType added in v0.3.6

func RecoverKeyFromMnemonicWithCoinType(appName, keyname, mnemonic string, coinType int) (string, error)

RecoverKeyFromMnemonicWithCoinType recovers or replaces a key using a mnemonic phrase with specified coin type If the key already exists, it will replace the key and confirm with 'y' before adding the mnemonic coinType must be explicitly provided (60 or 118), 0 is not allowed

func SetSymlink(targetPath string) error

SetSymlink sets a symbolic link in the parent directory pointing to the target binary.

func SortVersions

func SortVersions(versions BinaryVersionWithDownloadURL) []string

SortVersions sorts the versions based on semantic versioning, including pre-release handling

Types

type BinaryRelease

type BinaryRelease struct {
	TagName     string `json:"tag_name"`
	PublishedAt string `json:"published_at"`
	Prerelease  bool   `json:"prerelease"`
	Assets      []struct {
		BrowserDownloadURL string `json:"browser_download_url"`
	} `json:"assets"`
}

type BinaryVersionWithDownloadURL

type BinaryVersionWithDownloadURL map[string]string

func GetOPInitVersions

func GetOPInitVersions() (BinaryVersionWithDownloadURL, string, error)

func ListBinaryReleases

func ListBinaryReleases(url string) (BinaryVersionWithDownloadURL, error)

func ListWeaveReleases

func ListWeaveReleases(url string) (BinaryVersionWithDownloadURL, error)

type BlockResponse

type BlockResponse struct {
	Result struct {
		Block struct {
			Header struct {
				Height string `json:"height"`
			} `json:"header"`
		} `json:"block"`
	} `json:"result"`
}

type Coin

type Coin struct {
	Denom  string `json:"denom"`
	Amount string `json:"amount"`
}

func (Coin) IsZero

func (coin Coin) IsZero() bool

type Coins

type Coins []Coin

func QueryBankBalances

func QueryBankBalances(addresses []string, address string) (*Coins, error)

func (*Coins) IsZero

func (cs *Coins) IsZero() bool

func (*Coins) Render

func (cs *Coins) Render(maxWidth int) string

type DecCoin

type DecCoin struct {
	Denom  string `protobuf:"bytes,1,opt,name=denom,proto3" json:"denom,omitempty"`
	Amount string `protobuf:"bytes,2,opt,name=amount,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"amount"`
}

type DecCoins

type DecCoins []DecCoin

DecCoins defines a slice of coins with decimal values

type HashResponse

type HashResponse struct {
	Result struct {
		BlockID struct {
			Hash string `json:"hash"`
		} `json:"block_id"`
	} `json:"result"`
}

type InitiadBankBalancesQueryResponse

type InitiadBankBalancesQueryResponse struct {
	Balances Coins `json:"balances"`
}

type InitiadQuerier

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

func NewInitiadQuerier

func NewInitiadQuerier(rest string) (*InitiadQuerier, error)

func (*InitiadQuerier) QueryBankBalances

func (iq *InitiadQuerier) QueryBankBalances(address, rpc string) (*Coins, error)

type InitiadTxExecutor

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

func NewInitiadTxExecutor

func NewInitiadTxExecutor(rest string) (*InitiadTxExecutor, error)

func (*InitiadTxExecutor) BroadcastMsgSend

func (te *InitiadTxExecutor) BroadcastMsgSend(senderMnemonic, recipientAddress, amount, gasPrices, rpc, chainId string, coinType int) (*InitiadTxResponse, error)

type InitiadTxResponse

type InitiadTxResponse struct {
	Height    string         `json:"height"`
	TxHash    string         `json:"txhash"`
	Codespace string         `json:"codespace"`
	Code      int            `json:"code"`
	Data      string         `json:"data"`
	RawLog    string         `json:"raw_log"`
	Logs      *[]interface{} `json:"logs"`
	Info      string         `json:"info"`
	GasWanted string         `json:"gas_wanted"`
	GasUsed   string         `json:"gas_used"`
	Tx        *[]interface{} `json:"tx"`
	Timestamp string         `json:"timestamp"`
	Events    *[]interface{} `json:"events"`
}

type JsonPayload

type JsonPayload struct {
	Messages []Message `json:"messages"`
}

type KeyInfo

type KeyInfo struct {
	Name     string `json:"name"`
	Type     string `json:"type"`
	Address  string `json:"address"`
	PubKey   string `json:"pubkey"`
	Mnemonic string `json:"mnemonic"`
}

func GenerateNewKeyInfo

func GenerateNewKeyInfo(appName, keyname string) (KeyInfo, error)

func UnmarshalKeyInfo

func UnmarshalKeyInfo(rawJson string) (KeyInfo, error)

type Message

type Message struct {
	Type      string        `json:"@type"`
	Authority string        `json:"authority"`
	Params    OPChildParams `json:"params"`
}

type MinimalRPCTxResponse added in v0.2.1

type MinimalRPCTxResponse struct {
	Result struct {
		TxResult struct {
			Code int    `json:"code"`
			Log  string `json:"log"`
		} `json:"tx_result"`
	} `json:"result"`
}

type MinimalTxResponse

type MinimalTxResponse struct {
	Code   int    `json:"code"`
	RawLog string `json:"raw_log"`
}

type MinitiadQuerier

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

func NewMinitiadQuerier

func NewMinitiadQuerier() (*MinitiadQuerier, error)

func (*MinitiadQuerier) QueryOPChildBridgeInfo

func (mq *MinitiadQuerier) QueryOPChildBridgeInfo(rpc string) (*types.Bridge, error)

func (*MinitiadQuerier) QueryOPChildNextL1Sequence

func (mq *MinitiadQuerier) QueryOPChildNextL1Sequence(rpc string) (string, error)

type MinitiadTxExecutor added in v0.3.4

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

func NewMinitiadTxExecutor added in v0.3.4

func NewMinitiadTxExecutor(rest string) (*MinitiadTxExecutor, error)

func (*MinitiadTxExecutor) BroadcastMsgSend added in v0.3.4

func (te *MinitiadTxExecutor) BroadcastMsgSend(senderMnemonic, recipientAddress, amount, gasPrices, rpc, chainId string, coinType int) (*InitiadTxResponse, error)

type MsgUpdateParams

type MsgUpdateParams struct {
	Authority string        `json:"authority"`
	Params    OPChildParams `json:"params"`
}

type NodeInfoResponse

type NodeInfoResponse struct {
	ApplicationVersion struct {
		Version string `json:"version"`
	} `json:"application_version"`
}

func QueryNodeInfo added in v0.3.0

func QueryNodeInfo(addresses []string) (response NodeInfoResponse, err error)

type OPChildBridgeInfoQueryResponse

type OPChildBridgeInfoQueryResponse struct {
	BridgeInfo struct {
		BridgeId string `json:"bridge_id"`
	} `json:"bridge_info"`
}

type OPChildNextL1SequenceResponse

type OPChildNextL1SequenceResponse struct {
	NextL1Sequence string `json:"next_l1_sequence"`
}

type OPChildParams

type OPChildParams struct {
	// max_validators is the maximum number of validators.
	MaxValidators uint32 `protobuf:"varint,1,opt,name=max_validators,json=maxValidators,proto3" json:"max_validators,omitempty" yaml:"max_validators"`
	// historical_entries is the number of historical entries to persist.
	HistoricalEntries uint32   `` /* 139-byte string literal not displayed */
	MinGasPrices      DecCoins `` /* 167-byte string literal not displayed */
	// the account address of bridge executor who can execute permissioned bridge
	// messages.
	BridgeExecutors []string `` /* 130-byte string literal not displayed */
	// the account address of admin who can execute permissioned cosmos messages.
	Admin string `protobuf:"bytes,5,opt,name=admin,proto3" json:"admin,omitempty" yaml:"admin"`
	// the list of addresses that are allowed to pay zero fee.
	FeeWhitelist []string `protobuf:"bytes,6,rep,name=fee_whitelist,json=feeWhitelist,proto3" json:"fee_whitelist,omitempty" yaml:"fee_whitelist"`
	// Max gas for hook execution of `MsgFinalizeTokenDeposit`
	HookMaxGas string `protobuf:"varint,7,opt,name=hook_max_gas,json=hookMaxGas,proto3" json:"hook_max_gas,omitempty" yaml:"hook_max_gas"`
}

Params defines the set of opchild parameters.

func QueryOPChildParams

func QueryOPChildParams(addresses []string) (params OPChildParams, err error)

type OPChildParamsResponse

type OPChildParamsResponse struct {
	Params OPChildParams `protobuf:"bytes,1,opt,name=params,proto3" json:"params,omitempty"`
}

type PolkachuChainAPIResponse added in v0.1.0

type PolkachuChainAPIResponse struct {
	PolkachuServices struct {
		StateSync struct {
			Active bool   `json:"active"`
			Node   string `json:"node"`
		} `json:"state_sync"`
	} `json:"polkachu_services"`
}

type PolkachuPeersAPIResponse added in v0.1.0

type PolkachuPeersAPIResponse struct {
	PolkachuPeer string   `json:"polkachu_peer"`
	LivePeers    []string `json:"live_peers"`
}

type StateSyncInfo

type StateSyncInfo struct {
	TrustHeight int
	TrustHash   string
}

func GetStateSyncInfo

func GetStateSyncInfo(url string) (*StateSyncInfo, error)

type TransactionEventsResponse

type TransactionEventsResponse struct {
	Data struct {
		TransactionEvents []struct {
			BlockHeight     int    `json:"block_height,omitempty"`
			TransactionHash string `json:"transaction_hash,omitempty"`
		} `json:"transaction_events"`
	} `json:"data"`
}

Jump to

Keyboard shortcuts

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