spawn

package
v0.50.12 Latest Latest
Warning

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

Go to latest
Published: Mar 1, 2025 License: Apache-2.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultWebsite                   = "https://example.com"
	DefaultDiscord                   = "https://discord.gg/your-discord"
	DefaultEmail                     = "example@example.com"
	DefaultLogoPNG                   = "https://raw.githubusercontent.com/cosmos/chain-registry/master/cosmoshub/images/atom.png"
	DefaultLogoSVG                   = "https://raw.githubusercontent.com/cosmos/chain-registry/master/cosmoshub/images/atom.svg"
	DefaultDescription               = "A short description of your project"
	DefaultChainID                   = "localchain-1"
	DefaultNetworkType               = "testnet" // or mainnet
	DefaultSlip44CoinType            = 118
	DefaultChainRegistrySchema       = "https://raw.githubusercontent.com/cosmos/chain-registry/master/chain.schema.json"
	DefaultChainRegistryAssetsSchema = "https://github.com/cosmos/chain-registry/blob/master/assetlist.schema.json"
	DefaultThemeHexColor             = "#FF2D00"
)
View Source
const (
	// StdFormat is the standard format for removing a line if a feature is removed.
	StdFormat = "spawntag:%s"

	// ExpectedFormat is the standard format for removing a line if a module is removed.
	// e.g. // spawntag:tokenfactory would remove the line if tokenfactory is removed.
	// NOTE: This is not user facing, and is only used for internal parsing of the simapp.
	ExpectedFormat = "// spawntag:"

	// CommentSwapFormat is the format for swapping a line with another if a module is removed.
	CommentSwapFormat = "?spawntag:%s"

	// MultiLineStartFormat is the format for starting a multi-line comment which removes all text
	// until the end of the comment.
	// <spawntag:[searchTerm]
	MultiLineStartFormat = "<" + StdFormat

	// spawntag:[searchTerm]>
	MultiLineEndFormat = StdFormat + ">"
)

Variables

View Source
var (
	CosmosHubProvider *localictypes.Chain
	IgnoredFiles      = []string{"embed.go", "heighliner/"}
)
View Source
var (
	// AlreadyChecked allows for better debugging to reduce fc spam
	AlreadyCheckedDeletion      = make(map[string]bool)
	AlreadyCheckedGoModDeletion = make(map[string]bool)
)
View Source
var (
	TokenFactory        = "tokenfactory"
	POA                 = "poa"
	POS                 = "staking" // if ICS is used, we remove staking
	CosmWasm            = "cosmwasm"
	WasmLC              = "wasmlc"
	PacketForward       = "packetforward"
	IBCRateLimit        = "ibc-ratelimit"
	InterchainSecurity  = "ics"
	OptimisticExecution = "optimistic-execution"
	BlockExplorer       = "block-explorer"
)
View Source
var (
	RunCheckInterval = 24 * time.Hour

	BinaryToGithubAPI = map[string]string{
		"local-ic": "https://api.github.com/repos/strangelove-ventures/interchaintest/releases",
		"spawn":    "https://api.github.com/repos/rollchains/spawn/releases",
	}
)

used for fuzz testing

Functions

func AliasName

func AliasName(name string) string

Given a string, return the reduced name for the module e.g. "tf" and "token-factory" both return "tokenfactory"

func ApplyMissingRPCMethodsToGoSourceFiles

func ApplyMissingRPCMethodsToGoSourceFiles(logger *slog.Logger, missingRPCMethods ModuleMapping) error

ApplyMissingRPCMethodsToGoSourceFiles builds the proto interface stubs and appends them to the file for missing methods. If .proto file contained an rpc method for `Params` and `Other` but only `Params` is found in the querier, then `Other` is generated, appended, and saved.

func DoOutdatedNotificationRunCheck added in v0.50.5

func DoOutdatedNotificationRunCheck(logger *slog.Logger) bool

DoOutdatedNotificationRunCheck returns true if it is time to run the check again. It saves the last run time to a file for future runs.

func DoesLineEndWithOpenSymbol

func DoesLineEndWithOpenSymbol(line string) bool

doesLineEndWithOpenSymbol returns true if the end of a line opens a statement such as a multi-line function.

func ExecCommand

func ExecCommand(command string, args ...string) error

func ExecCommandWithOutput added in v0.50.5

func ExecCommandWithOutput(command string, args ...string) ([]byte, error)

func FindLineWithText

func FindLineWithText(src []string, text string) (lineNum int)

FindLineWithText returns the index of a line in a slice of strings that contains the given text.

func FindLinesWithText

func FindLinesWithText(src []string, text string) (startIdx, endIdx int)

FindLinesWithText returns the start and end index of a block of text in a slice of strings. This starts with the text searched for, and continues to look until and end bracket or parenthesis is found. This allows for the finding of multi-line function signatures, if-else blocks, etc.

func GetInstallMsg added in v0.50.5

func GetInstallMsg(msg, latestVer string) string

func GetLatestVersionCheckFile added in v0.50.5

func GetLatestVersionCheckFile(logger *slog.Logger) (string, error)

GetLatestVersionCheckFile grabs the check file used to determine when to run the version check.

func GetLocalVersion added in v0.50.5

func GetLocalVersion(logger *slog.Logger, binName, latestVer string) string

func GetProtoPackageName

func GetProtoPackageName(content []byte) string

GetProtoPackageName inputs proto file content, then parse out the package (cosmos module) name package cnd.v1; returns cnd as the name.

func NormalizeDisabledNames

func NormalizeDisabledNames(disabled []string, improperPairs map[string][]string) []string

NormalizeDisabledNames normalizes the names, removes any parent dependencies, and removes duplicates. It then returns the cleaned list of disabled modules.

func OutOfDateCheckLog added in v0.50.5

func OutOfDateCheckLog(logger *slog.Logger, binName, current, latest string) bool

OutOfDateCheckLog logs & returns true if it is out of date.

func ParseFileImports

func ParseFileImports(filePath string) ([]string, int, int, error)

ParseFileImports reads the content of a file and returns the import strings, the start and end line numbers of the import block. It starts reading at `import (` and stops at the first `)`. in the file.

func ReadCurrentGoModuleName

func ReadCurrentGoModuleName(loc string) string

ReadCurrentModuleName reads the go package module name from the go.mod file on the host machine.

func RemoveDuplicates

func RemoveDuplicates(disabled []string) []string

func RemoveSpawnTagLineComment

func RemoveSpawnTagLineComment(line string, tag string) string

removeSpawnTagLineComment removes just the spawntag comment from a line of code.

func WhereIsBinInstalled added in v0.50.5

func WhereIsBinInstalled(binName string) string

func WriteLastTimeToFile added in v0.50.5

func WriteLastTimeToFile(logger *slog.Logger, lastCheckFile string, t time.Time) error

Types

type Asset added in v0.50.5

type Asset struct {
	URL      string `json:"url"`
	ID       int    `json:"id"`
	NodeID   string `json:"node_id"`
	Name     string `json:"name"`
	Label    string `json:"label"`
	Uploader struct {
		Login             string `json:"login"`
		ID                int    `json:"id"`
		NodeID            string `json:"node_id"`
		AvatarURL         string `json:"avatar_url"`
		GravatarID        string `json:"gravatar_id"`
		URL               string `json:"url"`
		HTMLURL           string `json:"html_url"`
		FollowersURL      string `json:"followers_url"`
		FollowingURL      string `json:"following_url"`
		GistsURL          string `json:"gists_url"`
		StarredURL        string `json:"starred_url"`
		SubscriptionsURL  string `json:"subscriptions_url"`
		OrganizationsURL  string `json:"organizations_url"`
		ReposURL          string `json:"repos_url"`
		EventsURL         string `json:"events_url"`
		ReceivedEventsURL string `json:"received_events_url"`
		Type              string `json:"type"`
		SiteAdmin         bool   `json:"site_admin"`
	} `json:"uploader"`
	ContentType        string    `json:"content_type"`
	State              string    `json:"state"`
	Size               int       `json:"size"`
	DownloadCount      int       `json:"download_count"`
	CreatedAt          time.Time `json:"created_at"`
	UpdatedAt          time.Time `json:"updated_at"`
	BrowserDownloadURL string    `json:"browser_download_url"`
}

type ChainExplorer added in v0.50.5

type ChainExplorer struct {
	ChainName  string               `json:"chain_name"`
	Api        []Endpoint           `json:"api"`
	Rpc        []Endpoint           `json:"rpc"`
	SdkVersion string               `json:"sdk_version"`
	CoinType   string               `json:"coin_type"`
	MinTxFee   string               `json:"min_tx_fee"`
	AddrPrefix string               `json:"addr_prefix"`
	ThemeColor string               `json:"theme_color"`
	Assets     []ChainExplorerAsset `json:"assets"`
}

type ChainExplorerAsset added in v0.50.5

type ChainExplorerAsset struct {
	Base        string `json:"base"`
	Symbol      string `json:"symbol"`
	Exponent    string `json:"exponent"`
	CoingeckoId string `json:"coingecko_id"`
}

type Display added in v0.50.9

type Display struct {
	Name        string  `json:"name"`
	Description string  `json:"description"`
	Links       Links   `json:"links"`
	Widget      *Widget `json:"widget,omitempty"`
}

type Endpoint added in v0.50.5

type Endpoint struct {
	Provider string `json:"provider"`
	Address  string `json:"address"`
}

func NewEndpoint added in v0.50.5

func NewEndpoint(provider, address string) Endpoint

type FileContent

type FileContent struct {
	// The path from within the embedded FileSystem
	RelativePath string
	// The new location of the file
	NewPath string
	// The contents of the file from the embededFileSystem (initially unmodified)
	Contents string

	Logger *slog.Logger
}

func GetFileContent

func GetFileContent(logger *slog.Logger, newFilePath string, fs embed.FS, relPath string, d fs.DirEntry) (*FileContent, error)

func NewFileContent

func NewFileContent(logger *slog.Logger, relativePath, newPath string) *FileContent

func (*FileContent) ContainsPath

func (fc *FileContent) ContainsPath(relPath string) bool

func (*FileContent) DeleteDirectoryContents

func (fc *FileContent) DeleteDirectoryContents(path string)

func (*FileContent) DeleteFile

func (fc *FileContent) DeleteFile(path string)

DeleteFile sets the content of the file to nothing. On save, the file is ignored if there is no content.

func (*FileContent) FindAndReplaceAddressBech32

func (fc *FileContent) FindAndReplaceAddressBech32(oldPrefix, newPrefix string)

FindAndReplaceStandardWalletsBech32 finds a prefix1... address and replaces it with a new prefix1... address This works for both standard wallets (38 length after prefix1) and also smart contracts (58)

func (*FileContent) FormatGoFile

func (fc *FileContent) FormatGoFile() error

func (*FileContent) HandleAllTagged added in v0.50.3

func (fc *FileContent) HandleAllTagged(text string)

func (*FileContent) HandleCommentSwaps

func (fc *FileContent) HandleCommentSwaps(name string)

Sometimes we remove a module line and would like to swap it for another.

func (*FileContent) HasIgnoreFile

func (fc *FileContent) HasIgnoreFile() bool

func (*FileContent) InPaths

func (fc *FileContent) InPaths(relPaths []string) bool

func (*FileContent) IsPath

func (fc *FileContent) IsPath(relPath string) bool

func (*FileContent) IsPathPrefixed

func (fc *FileContent) IsPathPrefixed(relPath string) bool

func (*FileContent) RemoveCosmWasm

func (fc *FileContent) RemoveCosmWasm(isWasmClientDisabled bool)

func (*FileContent) RemoveDisabledFeatures

func (fc *FileContent) RemoveDisabledFeatures(cfg *NewChainConfig)

Removes disabled features from the files specified NOTE: Ensure you call `SetProperFeaturePairs` before calling this function

func (*FileContent) RemoveDistribution

func (fc *FileContent) RemoveDistribution()

func (*FileContent) RemoveExplorer added in v0.50.5

func (fc *FileContent) RemoveExplorer()

func (*FileContent) RemoveGoModImport

func (fc *FileContent) RemoveGoModImport(importPath string)

given a go mod, remove line(s) with the importPath present.

func (*FileContent) RemoveGov

func (fc *FileContent) RemoveGov()

func (*FileContent) RemoveIBCRateLimit

func (fc *FileContent) RemoveIBCRateLimit()

func (*FileContent) RemoveInterchainSecurity

func (fc *FileContent) RemoveInterchainSecurity()

func (*FileContent) RemoveLineWithAnyMatch

func (fc *FileContent) RemoveLineWithAnyMatch(text string)

RemoveLineWithAnyMatch removes a line if it contains any text.

func (*FileContent) RemoveMint

func (fc *FileContent) RemoveMint()

func (*FileContent) RemoveModuleFromText

func (fc *FileContent) RemoveModuleFromText(removeText string, pathSuffix ...string)

RemoveGeneralModule removes any matching names from the fileContent. i.e. if moduleFind is "tokenfactory" any lines with "tokenfactory" will be removed including comments. If an import or other line depends on a solo module a user wishes to remove, add a comment to the line such as `// spawntag:tokenfactory` to also remove other lines within the simapp template

func (*FileContent) RemoveOptimisticExecution added in v0.50.3

func (fc *FileContent) RemoveOptimisticExecution()

func (*FileContent) RemovePOA

func (fc *FileContent) RemovePOA()

func (*FileContent) RemovePacketForward

func (fc *FileContent) RemovePacketForward()

func (*FileContent) RemoveStaking

func (fc *FileContent) RemoveStaking()

Remove staking module if using a custom impl like the ICS Consumer

func (*FileContent) RemoveStandardTestNodeScript added in v0.50.3

func (fc *FileContent) RemoveStandardTestNodeScript()

Remove this if using ICS, no need.

func (*FileContent) RemoveTaggedLines

func (fc *FileContent) RemoveTaggedLines(name string, deleteLine bool)

RemoveTaggedLines deletes tagged lines or just removes the comment if desired.

func (*FileContent) RemoveTokenFactory

func (fc *FileContent) RemoveTokenFactory()

func (*FileContent) RemoveWasmLightClient

func (fc *FileContent) RemoveWasmLightClient()

func (*FileContent) ReplaceAll

func (fc *FileContent) ReplaceAll(old, new string)

func (*FileContent) ReplaceApp

func (fc *FileContent) ReplaceApp(cfg *NewChainConfig)

func (*FileContent) ReplaceDockerFile

func (fc *FileContent) ReplaceDockerFile(cfg *NewChainConfig)

func (*FileContent) ReplaceEverywhere

func (fc *FileContent) ReplaceEverywhere(cfg *NewChainConfig)

ReplaceEverywhereReplaces any file content that matches anywhere in the file regardless of location.

func (*FileContent) ReplaceGithubActionWorkflows

func (fc *FileContent) ReplaceGithubActionWorkflows(cfg *NewChainConfig)

func (*FileContent) ReplaceMakeFile

func (fc *FileContent) ReplaceMakeFile(cfg *NewChainConfig)

func (*FileContent) ReplaceTestNodeScript

func (fc *FileContent) ReplaceTestNodeScript(cfg *NewChainConfig)

func (*FileContent) Save

func (fc *FileContent) Save() error

func (*FileContent) String

func (fc *FileContent) String() string

type FileType

type FileType string

FileType tells the application which type of proto file is it so we can sort Txs from Queries

const (
	Tx    FileType = "tx"
	Query FileType = "query"
	None  FileType = "none"
)

func FileTypeFromProtoContent

func FileTypeFromProtoContent(bz []byte) FileType

returns "tx" or "query" depending on the content of the file

func (FileType) String

func (ft FileType) String() string

get the str of FileType

type Links struct {
	Discord    string `json:"discord"`
	Email      string `json:"email"`
	Github     string `json:"github"`
	Telegram   string `json:"telegram"`
	Twitter    string `json:"twitter"`
	Website    string `json:"website"`
	Whitepaper string `json:"whitepaper"`
}

type MetadataFile added in v0.50.3

type MetadataFile struct {
	Display Display `json:"display"`
}

func (MetadataFile) SaveJSON added in v0.50.3

func (mf MetadataFile) SaveJSON(loc string) error

type ModuleMapping

type ModuleMapping map[string][]*ProtoRPC

ModuleMapping a map of the module name to a list of ProtoRPCs

func GetCurrentModuleRPCsFromProto

func GetCurrentModuleRPCsFromProto(logger *slog.Logger, absProtoPath string) ModuleMapping

Converts .proto files into a mapping depending on the type.

func GetMissingRPCMethodsFromModuleProto

func GetMissingRPCMethodsFromModuleProto(logger *slog.Logger, cwd string) (ModuleMapping, error)

func (ModuleMapping) Print

func (mm ModuleMapping) Print(logger *slog.Logger)

type NewChainConfig

type NewChainConfig struct {
	// ProjectName is the name of the new chain
	ProjectName string
	// Bech32Prefix is the new wallet prefix
	Bech32Prefix string
	// The home directory of the new chain (e.g. .simapp) within the binary
	// This should typically be prefixed with a period.
	HomeDir string
	// BinDaemon is the name of the binary. (e.g. appd)
	BinDaemon string
	// Denom is the token denomination (e.g. stake, uatom, etc.)
	Denom string
	// GithubOrg is the github organization name to use for the module
	GithubOrg string
	// IgnoreGitInit is a flag to ignore git init
	IgnoreGitInit   bool
	DisabledModules []string
	Logger          *slog.Logger
}

func (*NewChainConfig) AnnounceSuccessfulBuild

func (cfg *NewChainConfig) AnnounceSuccessfulBuild()

func (NewChainConfig) ChainRegistryAssetsFile added in v0.50.7

func (cfg NewChainConfig) ChainRegistryAssetsFile() types.ChainRegistryAssetsList

The ICS MetadataFile is similar to this.

func (NewChainConfig) ChainRegistryFile added in v0.50.7

func (cfg NewChainConfig) ChainRegistryFile() types.ChainRegistryFormat

func (*NewChainConfig) CreateNewChain added in v0.50.3

func (cfg *NewChainConfig) CreateNewChain() error

func (*NewChainConfig) GitInitNewProjectRepo

func (cfg *NewChainConfig) GitInitNewProjectRepo()

func (*NewChainConfig) GithubPath

func (cfg *NewChainConfig) GithubPath() string

func (*NewChainConfig) IsFeatureEnabled added in v0.50.7

func (cfg *NewChainConfig) IsFeatureEnabled(feat string) bool

func (*NewChainConfig) MakeModTidy

func (cfg *NewChainConfig) MakeModTidy()

func (*NewChainConfig) MetadataFile added in v0.50.3

func (cfg *NewChainConfig) MetadataFile() MetadataFile

func (NewChainConfig) NewChainExplorerConfig added in v0.50.5

func (cfg NewChainConfig) NewChainExplorerConfig() ChainExplorer

func (NewChainConfig) NewPingPubExplorer added in v0.50.5

func (cfg NewChainConfig) NewPingPubExplorer() error

func (NewChainConfig) NodeHome added in v0.50.7

func (cfg NewChainConfig) NodeHome() string

NodeHome returns the full path to the node home directory ex: $HOME/.simapp

func (*NewChainConfig) SetProperFeaturePairs

func (cfg *NewChainConfig) SetProperFeaturePairs()

SetProperFeaturePairs ensures modules that are meant to be disabled, are. ex: if ICS is enabled, disable staking if it is not already disabled Normalizes the names, removes any parent dependencies, and removes duplicates

func (*NewChainConfig) SetupInterchainTest

func (cfg *NewChainConfig) SetupInterchainTest() error

func (*NewChainConfig) SetupLocalInterchainJSON

func (cfg *NewChainConfig) SetupLocalInterchainJSON()

TODO: allow selecting for other chains to generate from (ethos, saga) SetupLocalInterchainJSON sets up the local-interchain testnets configuration files.

func (*NewChainConfig) SetupMainChainApp

func (cfg *NewChainConfig) SetupMainChainApp() error

func (*NewChainConfig) Validate

func (cfg *NewChainConfig) Validate() error

func (NewChainConfig) ValidateAndRun added in v0.50.3

func (cfg NewChainConfig) ValidateAndRun(doAnnounce bool) error

func (NewChainConfig) WithBech32Prefix added in v0.50.3

func (s NewChainConfig) WithBech32Prefix(bech string) NewChainConfig

func (NewChainConfig) WithBinDaemon added in v0.50.3

func (s NewChainConfig) WithBinDaemon(bin string) NewChainConfig

func (NewChainConfig) WithDenom added in v0.50.3

func (s NewChainConfig) WithDenom(denom string) NewChainConfig

func (NewChainConfig) WithHomeDir added in v0.50.3

func (s NewChainConfig) WithHomeDir(home string) NewChainConfig

func (NewChainConfig) WithOrg added in v0.50.3

func (s NewChainConfig) WithOrg(org string) NewChainConfig

func (NewChainConfig) WithProjectName added in v0.50.3

func (s NewChainConfig) WithProjectName(proj string) NewChainConfig

type ProtoRPC

type ProtoRPC struct {
	// The name of the proto RPC service (i.e. rpc Params would be Params for the name)
	Name string
	// The request object, such as QueryParamsRequest (queries) or MsgUpdateParams (txs)
	Req string
	// The response object, such as QueryParamsResponse (queries) or MsgUpdateParamsResponse (txs)
	Res string

	// The name of the cosmos extension (x/module)
	Module string
	// The type of file this proto service is (tx, query, none)
	FType FileType
	// Where there Query/Msg Server is located (querier.go, msgserver.gom, etc.)
	FileLoc string
}

A Proto server RPC method.

func ProtoServiceParser

func ProtoServiceParser(logger *slog.Logger, content []byte, ft FileType, fileLoc string) []*ProtoRPC

ProtoServiceParser parses out a proto file content and returns all the RPC services within it.

func (ProtoRPC) BuildProtoInterfaceStub

func (pr ProtoRPC) BuildProtoInterfaceStub() string

BuildProtoInterfaceStub returns the string to save to the file for the msgServer or Querier.

func (*ProtoRPC) String

func (pr *ProtoRPC) String() string

type Release added in v0.50.5

type Release struct {
	Id          int64   `json:"id"`
	Name        string  `json:"name"`
	TagName     string  `json:"tag_name"`
	PublishedAt string  `json:"published_at"`
	Assets      []Asset `json:"assets"`

	Prerelease bool `json:"prerelease"`
	Draft      bool `json:"draft"`
}

func GetLatestGithubReleases added in v0.50.5

func GetLatestGithubReleases(apiRepoURL string) ([]Release, error)

type Widget added in v0.50.9

type Widget struct {
	Title       string `json:"title,omitempty"`
	Description string `json:"description,omitempty"`
	ButtonText  string `json:"buttonText,omitempty"`
	ButtonURL   string `json:"buttonUrl,omitempty"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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