mukan-ignite/ignite/pkg/chaincmd/in-place-testnet.go
Mukan Erkin Törük c32551b6f7
Some checks failed
Docs Deploy / build_and_deploy (push) Has been cancelled
Generate Docs / cli (push) Has been cancelled
Generate Config Doc / cli (push) Has been cancelled
Go formatting / go-formatting (push) Has been cancelled
Check links / markdown-link-check (push) Has been cancelled
Integration / pre-test (push) Has been cancelled
Integration / test on (push) Has been cancelled
Integration / status (push) Has been cancelled
Lint / Lint Go code (push) Has been cancelled
Test / test (ubuntu-latest) (push) Has been cancelled
refactor: replace all github.com upstream refs with git.cw.tr/mukan-network
2026-05-11 03:36:24 +03:00

128 lines
3.3 KiB
Go

package chaincmd
import (
"git.cw.tr/mukan-network/mukan-ignite/ignite/pkg/cmdrunner/step"
)
type InPlaceOption func([]string) []string
func InPlaceWithPrvKey(prvKey string) InPlaceOption {
return func(s []string) []string {
if len(prvKey) > 0 {
return append(s, optionValidatorPrivateKey, prvKey)
}
return s
}
}
func InPlaceWithAccountToFund(accounts string) InPlaceOption {
return func(s []string) []string {
if len(accounts) > 0 {
return append(s, optionAccountToFund, accounts)
}
return s
}
}
func InPlaceWithSkipConfirmation() InPlaceOption {
return func(s []string) []string {
return append(s, optionSkipConfirmation)
}
}
// TestnetInPlaceCommand return command to start testnet in-place.
func (c ChainCmd) TestnetInPlaceCommand(newChainID, newOperatorAddress string, options ...InPlaceOption) step.Option {
command := []string{
commandTestnetInPlace,
newChainID,
newOperatorAddress,
}
// Apply the options provided by the user
for _, apply := range options {
command = apply(command)
}
return c.daemonCommand(command)
}
// Options for testnet multi node.
type MultiNodeOption func([]string) []string
// MultiNodeWithChainID returns a MultiNodeOption that appends the chainID option
// to the provided slice of strings.
func MultiNodeWithChainID(chainID string) MultiNodeOption {
return func(s []string) []string {
if len(chainID) > 0 {
return append(s, optionChainID, chainID)
}
return s
}
}
// MultiNodeWithDirOutput returns a MultiNodeOption that appends the output directory option
// to the provided slice of strings.
func MultiNodeWithDirOutput(dirOutput string) MultiNodeOption {
return func(s []string) []string {
if len(dirOutput) > 0 {
return append(s, optionOutPutDir, dirOutput)
}
return s
}
}
// MultiNodeWithNumValidator returns a MultiNodeOption that appends the number of validators option
// to the provided slice of strings.
func MultiNodeWithNumValidator(numVal string) MultiNodeOption {
return func(s []string) []string {
if len(numVal) > 0 {
return append(s, optionNumValidator, numVal)
}
return s
}
}
// MultiNodeWithValidatorsStakeAmount returns a MultiNodeOption that appends the stake amounts option
// to the provided slice of strings.
func MultiNodeWithValidatorsStakeAmount(satkeAmounts string) MultiNodeOption {
return func(s []string) []string {
if len(satkeAmounts) > 0 {
return append(s, optionAmountStakes, satkeAmounts)
}
return s
}
}
// MultiNodeDirPrefix returns a MultiNodeOption that appends the node directory prefix option
// to the provided slice of strings.
func MultiNodeDirPrefix(nodeDirPrefix string) MultiNodeOption {
return func(s []string) []string {
if len(nodeDirPrefix) > 0 {
return append(s, optionNodeDirPrefix, nodeDirPrefix)
}
return s
}
}
func MultiNodePorts(ports string) MultiNodeOption {
return func(s []string) []string {
if len(ports) > 0 {
return append(s, optionPorts, ports)
}
return s
}
}
// TestnetMultiNodeCommand return command to start testnet multinode.
func (c ChainCmd) TestnetMultiNodeCommand(options ...MultiNodeOption) step.Option {
command := []string{
commandTestnetMultiNode,
}
// Apply the options provided by the user
for _, apply := range options {
command = apply(command)
}
return c.daemonCommand(command)
}