mukan-ignite/ignite/templates/module/create/options.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

97 lines
2.4 KiB
Go

package modulecreate
import (
"fmt"
"path/filepath"
"github.com/iancoleman/strcase"
"git.cw.tr/mukan-network/mukan-ignite/ignite/templates/field"
)
// ConfigsOptions represents the options to scaffold a Cosmos SDK module configs.
type ConfigsOptions struct {
ModuleName string
AppName string
ProtoDir string
ProtoVer string
Configs field.Fields
}
// ProtoFile returns the path to the proto folder.
func (opts *ConfigsOptions) ProtoFile(fname string) string {
return filepath.Join(opts.ProtoDir, opts.AppName, opts.ModuleName, opts.ProtoVer, fname)
}
// ParamsOptions represents the options to scaffold a Cosmos SDK module parameters.
type ParamsOptions struct {
ModuleName string
AppName string
ProtoDir string
ProtoVer string
Params field.Fields
}
// ProtoFile returns the path to the proto folder.
func (opts *ParamsOptions) ProtoFile(fname string) string {
return filepath.Join(opts.ProtoDir, opts.AppName, opts.ModuleName, opts.ProtoVer, fname)
}
// CreateOptions represents the options to scaffold a Cosmos SDK module.
type CreateOptions struct {
ModuleName string
ModulePath string
AppName string
AppPath string
ProtoDir string
ProtoVer string
Params field.Fields
Configs field.Fields
// True if the module should implement the IBC module interface
IsIBC bool
// Channel ordering of the IBC module: ordered, unordered or none
IBCOrdering string
// Dependencies of the module
Dependencies Dependencies
}
// ProtoFile returns the path to the proto folder.
func (opts *CreateOptions) ProtoFile(fname string) string {
return filepath.Join(opts.ProtoDir, opts.AppName, opts.ModuleName, opts.ProtoVer, fname)
}
// Dependency represents a module dependency of a module.
type Dependency struct {
Name string
}
// Dependencies represents a list of module dependency.
type Dependencies []Dependency
// NewDependency returns a new dependency.
func NewDependency(name string) Dependency {
return Dependency{Name: strcase.ToCamel(name)}
}
// Contains returns true if contains dependency name.
func (d Dependencies) Contains(name string) bool {
for _, dep := range d {
if dep.Name == name {
return true
}
}
return false
}
// Len returns the length of dependencies.
func (d Dependencies) Len() int {
return len(d)
}
// KeeperName returns the keeper's name for the dependency module.
func (d Dependency) KeeperName() string {
return fmt.Sprint(d.Name, "Keeper")
}