Documentation
¶
Index ¶
- Constants
- Variables
- func AddSkipConfirmation(cmd *cobra.Command)
- func AddTxnTypeFlags(cmd *cobra.Command)
- func BuildRPCsListYAML(networks []string, rpcURLs map[string]string) string
- func FindEnvFile(startDir, fileName string) (string, error)
- func FindOrCreateProjectSettings(startDir string, replacements map[string]string) error
- func GenerateFileFromTemplate(outputPath string, templateContent string, replacements map[string]string) error
- func GenerateGitIgnoreFile(workingDirectory string) (string, error)
- func GenerateProjectEnvFile(workingDirectory string) (string, error)
- func GenerateProjectSettingsFile(workingDirectory string) (string, bool, error)
- func GenerateWorkflowSettingsFile(workingDirectory string, workflowName string, workflowPath string) (string, error)
- func GetAvailableTargets() ([]string, error)
- func GetChainNameByChainSelector(chainSelector uint64) (string, error)
- func GetChainSelectorByChainName(name string) (uint64, error)
- func GetDefaultReplacements() map[string]string
- func GetEnvironmentVariable(filePath, key string) (string, error)
- func GetMCMSConfig(settings *Settings, chainSelector uint64) (*crecontracts.MCMSConfig, error)
- func GetReplacementsWithNetworks(networks []string, rpcURLs map[string]string) map[string]string
- func GetRpcUrlSettings(v *viper.Viper, chainName string) (string, error)
- func GetTarget(v *viper.Viper) (string, error)
- func GetWorkflowOwner(v *viper.Viper) (ownerAddress string, ownerType string, err error)
- func GetWorkflowPathFromFile(workflowYAMLPath string) (string, error)
- func IsValidChainName(name string) error
- func LoadEnv(logger *zerolog.Logger, v *viper.Viper, envPath string)
- func LoadPublicEnv(logger *zerolog.Logger, v *viper.Viper, envPath string)
- func LoadSettingsIntoViper(v *viper.Viper, cmd *cobra.Command) error
- func LoadedEnvFilePath() string
- func LoadedEnvVars() map[string]string
- func LoadedPublicEnvFilePath() string
- func LoadedPublicEnvVars() map[string]string
- func NormalizeHexKey(k string) string
- func PatchProjectRPCs(projectYAMLPath string, rpcURLs map[string]string) error
- func ResolveAndLoadBothEnvFiles(logger *zerolog.Logger, v *viper.Viper, envFlagName, envDefaultFile string, ...)
- func ResolveAndLoadEnv(logger *zerolog.Logger, v *viper.Viper, flagName, defaultFileName string)
- func ResolveAndLoadPublicEnv(logger *zerolog.Logger, v *viper.Viper, flagName, defaultFileName string)
- func ResolveEnvVars(s string) (string, error)
- func SetWorkflowPathInFile(workflowYAMLPath, newPath string) error
- func ShouldSkipGetOwner(cmd *cobra.Command) bool
- type CLDSettings
- type CREStorageSettings
- type Contract
- type ContractGroups
- type ExperimentalChain
- type Flag
- type ProjectEnv
- type RpcEndpoint
- type Settings
- type UserSettings
- type WorkflowSettings
- type WorkflowStorageSettings
Constants ¶
const ( EthPrivateKeyEnvVar = "CRE_ETH_PRIVATE_KEY" CreTargetEnvVar = "CRE_TARGET" )
sensitive information (not in configuration file)
const ( WorkflowOwnerSettingName = "account.workflow-owner-address" WorkflowNameSettingName = "user-workflow.workflow-name" WorkflowPathSettingName = "workflow-artifacts.workflow-path" ConfigPathSettingName = "workflow-artifacts.config-path" SecretsPathSettingName = "workflow-artifacts.secrets-path" SethConfigPathSettingName = "logging.seth-config-path" RegistriesSettingName = "contracts.registries" KeystoneSettingName = "contracts.keystone" RpcsSettingName = "rpcs" ExperimentalChainsSettingName = "experimental-chains" // used by simulator when present in target config )
Config names (YAML field paths)
Variables ¶
var Flags = flagNames{ Owner: Flag{"owner", "o"}, ProjectRoot: Flag{"project-root", "R"}, CliEnvFile: Flag{"env", "e"}, CliPublicEnvFile: Flag{"public-env", "E"}, Verbose: Flag{"verbose", "v"}, Target: Flag{"target", "T"}, OverridePreviousRoot: Flag{"override-previous-root", "O"}, RawTxFlag: Flag{"unsigned", ""}, Changeset: Flag{"changeset", ""}, Ledger: Flag{"ledger", ""}, LedgerDerivationPath: Flag{"ledger-derivation-path", ""}, NonInteractive: Flag{"non-interactive", ""}, SkipConfirmation: Flag{"yes", "y"}, ChangesetFile: Flag{"changeset-file", ""}, }
var ProjectEnvironmentTemplateContent string
var ProjectSettingsTemplateContent string
Functions ¶
func AddSkipConfirmation ¶
func AddTxnTypeFlags ¶
func BuildRPCsListYAML ¶ added in v1.2.0
BuildRPCsListYAML generates the indented rpcs YAML block for project.yaml. If networks is empty, falls back to the default (ethereum-testnet-sepolia).
func FindEnvFile ¶ added in v1.5.0
FindEnvFile walks up from startDir looking for a file named fileName.
func GenerateGitIgnoreFile ¶
func GenerateProjectEnvFile ¶
func GetAvailableTargets ¶ added in v1.3.0
GetAvailableTargets reads project.yaml and returns the top-level keys that represent target configurations, preserving the order from the file.
func GetDefaultReplacements ¶
func GetEnvironmentVariable ¶
func GetMCMSConfig ¶ added in v1.0.6
func GetMCMSConfig(settings *Settings, chainSelector uint64) (*crecontracts.MCMSConfig, error)
func GetReplacementsWithNetworks ¶ added in v1.2.0
GetReplacementsWithNetworks returns template replacements including a dynamic RPCs list.
func GetWorkflowOwner ¶
func GetWorkflowPathFromFile ¶ added in v1.1.0
GetWorkflowPathFromFile reads workflow-path from a workflow.yaml file (same value deploy/simulate get from Settings).
func IsValidChainName ¶
func LoadEnv ¶
LoadEnv loads environment variables from envPath into the process environment, then binds all loaded variables plus the sensitive defaults into Viper. AutomaticEnv is always activated so every OS env var is reachable via Viper regardless of whether a file was loaded. Errors are logged but do not halt execution — the CLI continues so that commands which don't need the env file can still run.
func LoadPublicEnv ¶ added in v1.5.0
LoadPublicEnv loads variables from envPath into the process environment and binds all loaded variables into Viper. It is intended for non-sensitive, shared build configuration (e.g. GOTOOLCHAIN).
func LoadSettingsIntoViper ¶
Loads the configuration file (if found) and sets the configuration values via Viper
func LoadedEnvFilePath ¶ added in v1.5.0
func LoadedEnvFilePath() string
LoadedEnvFilePath returns the .env path that was successfully loaded, or "".
func LoadedEnvVars ¶ added in v1.5.0
LoadedEnvVars returns the key-value pairs parsed from the loaded .env file. Returns nil if no file was loaded.
func LoadedPublicEnvFilePath ¶ added in v1.5.0
func LoadedPublicEnvFilePath() string
LoadedPublicEnvFilePath returns the .env.public path that was successfully loaded, or "".
func LoadedPublicEnvVars ¶ added in v1.5.0
LoadedPublicEnvVars returns the key-value pairs parsed from the loaded .env.public file. Returns nil if no file was loaded.
func NormalizeHexKey ¶
func PatchProjectRPCs ¶ added in v1.2.0
PatchProjectRPCs updates RPC URLs in an existing project.yaml file. It uses the yaml.Node API to preserve comments and formatting. Only entries whose chain-name matches a key in rpcURLs are updated.
func ResolveAndLoadBothEnvFiles ¶ added in v1.6.0
func ResolveAndLoadBothEnvFiles( logger *zerolog.Logger, v *viper.Viper, envFlagName, envDefaultFile string, publicEnvFlagName, publicEnvDefaultFile string, )
ResolveAndLoadBothEnvFiles resolves, loads, and binds variables from both the .env and .env.public files, applying the following rules:
- If a flag is not explicitly set, a debug message is emitted; if the default file is found it is loaded automatically.
- Variables are prioritized: public-env > env file > other OS vars. A warning is emitted for any key present in both files.
- All loaded variables from both files are bound into Viper.
func ResolveAndLoadEnv ¶ added in v1.5.0
ResolveAndLoadEnv resolves the .env file path from the given CLI flag (auto-detecting defaultFileName in parent dirs if the flag is empty), logs a debug message when the flag was not explicitly set, then loads the file and binds all variables into Viper.
func ResolveAndLoadPublicEnv ¶ added in v1.5.0
func ResolveAndLoadPublicEnv(logger *zerolog.Logger, v *viper.Viper, flagName, defaultFileName string)
ResolveAndLoadPublicEnv resolves the public env file path from the given CLI flag (auto-detecting defaultFileName in parent dirs if the flag is empty), logs a debug message when the flag was not explicitly set, then loads the file and binds all variables into Viper.
func ResolveEnvVars ¶ added in v1.5.0
ResolveEnvVars replaces all ${VAR_NAME} references in s with their corresponding environment variable values. It returns an error if any referenced variable is not set.
func SetWorkflowPathInFile ¶ added in v1.1.0
SetWorkflowPathInFile sets workflow-path in workflow.yaml (both staging-settings and production-settings) and writes the file.
func ShouldSkipGetOwner ¶
For commands that don't need the private key, we skip getting the owner address. ShouldSkipGetOwner returns true if the command is `simulate` and `--broadcast` is false or not set. `cre help` should skip as well.
Types ¶
type CLDSettings ¶ added in v1.0.6
type CLDSettings struct {
CLDPath string `mapstructure:"cld-path" yaml:"cld-path"`
Environment string `mapstructure:"environment" yaml:"environment"`
Domain string `mapstructure:"domain" yaml:"domain"`
MergeProposals bool `mapstructure:"merge-proposals" yaml:"merge-proposals"`
WorkflowRegistryQualifier string `mapstructure:"workflow-registry-qualifier" yaml:"workflow-registry-qualifier"`
ChangesetFile string `mapstructure:"changeset-file" yaml:"changeset-file"`
MCMSSettings struct {
MinDelay string `mapstructure:"min-delay" yaml:"min-delay"`
MCMSAction string `mapstructure:"mcms-action" yaml:"mcms-action"`
OverrideRoot bool `mapstructure:"override-root" yaml:"override-root"`
TimelockQualifier string `mapstructure:"timelock-qualifier" yaml:"timelock-qualifier"`
ValidDuration string `mapstructure:"valid-duration" yaml:"valid-duration"`
} `mapstructure:"mcms-settings" yaml:"mcms-settings"`
}
type CREStorageSettings ¶
type ContractGroups ¶
type ExperimentalChain ¶ added in v1.0.7
type ExperimentalChain struct {
ChainSelector uint64 `mapstructure:"chain-selector" yaml:"chain-selector"`
RPCURL string `mapstructure:"rpc-url" yaml:"rpc-url"`
Forwarder string `mapstructure:"forwarder" yaml:"forwarder"`
}
ExperimentalChain represents an EVM chain not in official chain-selectors. Automatically used by the simulator when present in the target's experimental-chains config. The ChainSelector is used as the selector key for EVM clients and forwarders.
func GetExperimentalChains ¶ added in v1.0.7
func GetExperimentalChains(v *viper.Viper) ([]ExperimentalChain, error)
GetExperimentalChains reads the experimental-chains list from the current target. Returns an empty slice if the key is not set or unmarshalling fails.
type ProjectEnv ¶
type RpcEndpoint ¶
type RpcEndpoint struct {
ChainName string `mapstructure:"chain-name" yaml:"chain-name"`
// TODO: in the future, we can have a distinction between "public URL" and "private URL", with only one of them present at the time
// "public URL" would be URL hidden behind the VPN or URL from ChainList, something that doesn't contain sensitive API tokens, e.g.
// url_public: https://rpcs.cldev.sh/ethereum/sepolia
// "private URL" can be feeded to the settings file by specifying the env var name where the real URL is kept, e.g.
// url_private: RPC_URL_ETH_SEPOLIA
Url string `mapstructure:"url" yaml:"url"`
}
type Settings ¶
type Settings struct {
Workflow WorkflowSettings
User UserSettings
StorageSettings WorkflowStorageSettings
CLDSettings CLDSettings
}
Settings holds user, project, and workflow configurations.
func New ¶
func New(logger *zerolog.Logger, v *viper.Viper, cmd *cobra.Command, registryChainName string) (*Settings, error)
New initializes and loads settings from YAML config files and the environment. Environment loading (.env + BindEnv) is handled earlier in PersistentPreRunE so that all commands see the variables consistently.
type UserSettings ¶
UserSettings stores user-specific configurations.
type WorkflowSettings ¶
type WorkflowSettings struct {
UserWorkflowSettings struct {
WorkflowOwnerAddress string `mapstructure:"workflow-owner-address" yaml:"workflow-owner-address"`
WorkflowOwnerType string `mapstructure:"workflow-owner-type" yaml:"workflow-owner-type"`
WorkflowName string `mapstructure:"workflow-name" yaml:"workflow-name"`
} `mapstructure:"user-workflow" yaml:"user-workflow"`
WorkflowArtifactSettings struct {
WorkflowPath string `mapstructure:"workflow-path" yaml:"workflow-path"`
ConfigPath string `mapstructure:"config-path" yaml:"config-path"`
SecretsPath string `mapstructure:"secrets-path" yaml:"secrets-path"`
} `mapstructure:"workflow-artifacts" yaml:"workflow-artifacts"`
LoggingSettings struct {
SethConfigPath string `mapstructure:"seth-config-path" yaml:"seth-config-path"`
} `mapstructure:"logging" yaml:"logging"`
RPCs []RpcEndpoint `mapstructure:"rpcs" yaml:"rpcs"`
}
type WorkflowStorageSettings ¶
type WorkflowStorageSettings struct {
CREStorage CREStorageSettings `mapstructure:"cre_storage"`
}
func LoadWorkflowStorageSettings ¶
func LoadWorkflowStorageSettings(logger *zerolog.Logger, v *viper.Viper) WorkflowStorageSettings