spawn

package
v0.50.2 Latest Latest
Warning

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

Go to latest
Published: May 30, 2024 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

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 (
	IgnoredFiles = []string{"embed.go", "heighliner/"}

	CosmosHubProvider = localictypes.
						ChainCosmosHub("localcosmos-1").
						SetDockerImage(ibc.NewDockerImage("", "v15.1.0", "1025:1025")).
						SetDefaultSDKv47Genesis(2)
)
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
	GlobalFee          = "globalfee"
	CosmWasm           = "cosmwasm"
	WasmLC             = "wasmlc"
	PacketForward      = "packetforward"
	IBCRateLimit       = "ibc-ratelimit"
	Ignite             = "ignite"
	InterchainSecurity = "ics"
)

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 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 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 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 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.

Types

type CLIInfo

type CLIInfo struct {
	Description string
	Cmds        map[string]string
}

func ParseCobraCLICmd

func ParseCobraCLICmd(binAbsPath string) (CLIInfo, error)

Parses the CLI commands from a cobra binary to showcase values within the `plugins` subcommand.

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) 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) RemoveGlobalFee

func (fc *FileContent) RemoveGlobalFee()

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) RemoveIgniteCLI

func (fc *FileContent) RemoveIgniteCLI()

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) 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) 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 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
	// contains filtered or unexported fields
}

func (*NewChainConfig) AnnounceSuccessfulBuild

func (cfg *NewChainConfig) AnnounceSuccessfulBuild()

func (*NewChainConfig) GitInitNewProjectRepo

func (cfg *NewChainConfig) GitInitNewProjectRepo()

func (*NewChainConfig) GithubPath

func (cfg *NewChainConfig) GithubPath() string

func (*NewChainConfig) IsFeatureDisabled

func (cfg *NewChainConfig) IsFeatureDisabled(featName string) bool

func (*NewChainConfig) MakeModTidy

func (cfg *NewChainConfig) MakeModTidy()

func (*NewChainConfig) NewChain

func (cfg *NewChainConfig) NewChain()

func (NewChainConfig) Run

func (cfg NewChainConfig) Run(doAnnounce bool)

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

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

Jump to

Keyboard shortcuts

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