-
Notifications
You must be signed in to change notification settings - Fork 13
Add supported-chains cmd & Improve Error Messages #330
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
ejacquier
wants to merge
21
commits into
main
Choose a base branch
from
error-improvement
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
4b63bc9
1. No project settings found (internal/context/project_context.go)
ejacquier ee13a4a
pk error fixes
ejacquier 2c249dd
Merge branch 'main' into error-improvement
ejacquier adaa987
updated supported-chains logic
ejacquier 8021f57
gendoc
ejacquier e4c1983
fix lint/tests
ejacquier d38e986
fixed tests
ejacquier f729c1e
Refactor: extract oauth from login (#325)
timothyF95 75a286a
AI Agent UX Improvements (#322)
ejacquier 5caa869
Secrets oauth browser (#326)
timothyF95 fd6d39d
Complete support for Oauth Vault permissions (#327)
timothyF95 6e9fd1d
Fix CI test failure (#329)
timothyF95 b6cc8c0
1. No project settings found (internal/context/project_context.go)
ejacquier d84a63d
pk error fixes
ejacquier 7533cf6
Merge branch 'main' into error-improvement
ejacquier 2e77049
updated supported-chains logic
ejacquier 0b21f42
gendoc
ejacquier ea93a2b
fix lint/tests
ejacquier 3494111
fixed tests
ejacquier ef86c70
Merge branch 'error-improvement' of github.com:smartcontractkit/cre-c…
ejacquier ec20783
fix invalid chain name error
ejacquier File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -207,14 +207,41 @@ func (h *handler) ResolveInputs(v *viper.Viper, creSettings *settings.Settings) | |
| } | ||
|
|
||
| if len(clients) == 0 { | ||
| return Inputs{}, fmt.Errorf("no RPC URLs found for supported or experimental chains") | ||
| target, _ := settings.GetTarget(v) | ||
| if target == "" { | ||
| target = "(none)" | ||
| } | ||
| return Inputs{}, fmt.Errorf( | ||
| "no RPC URLs found for target %q\n\n"+ | ||
| "To fix:\n"+ | ||
| " • Check that your workflow.yaml has an 'rpcs' section under the target %q\n"+ | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. project.yaml? |
||
| " • Ensure chain names are valid (run 'cre workflow supported-chains' to see all supported names)\n"+ | ||
| " • Verify the correct target is selected via --target or CRE_TARGET", | ||
| target, target, | ||
| ) | ||
| } | ||
|
|
||
| pk, err := crypto.HexToECDSA(creSettings.User.EthPrivateKey) | ||
| if err != nil { | ||
| // If the user explicitly set a key that looks like a hex string but is | ||
| // malformed (wrong length, invalid chars), always error with guidance. | ||
| // Skip placeholder values like "your-eth-private-key" from the default .env template. | ||
| if creSettings.User.EthPrivateKey != "" && isHexString(creSettings.User.EthPrivateKey) { | ||
| return Inputs{}, fmt.Errorf( | ||
| "invalid private key: expected 64 hex characters (256 bits), got %d characters.\n\n"+ | ||
| "The CLI reads CRE_ETH_PRIVATE_KEY from your .env file or system environment.\n"+ | ||
| "The 0x prefix is supported and stripped automatically.\n\n"+ | ||
| "Common issues:\n"+ | ||
| " • Pasted an Ethereum address (40 chars) instead of a private key (64 chars)\n"+ | ||
| " • Value has extra quotes — use CRE_ETH_PRIVATE_KEY=abc123... without wrapping quotes\n"+ | ||
| " • Key was truncated during copy-paste", | ||
| len(creSettings.User.EthPrivateKey)) | ||
| } | ||
| // Key not set or placeholder — require it for broadcast, otherwise use default for simulation | ||
| if v.GetBool("broadcast") { | ||
| return Inputs{}, fmt.Errorf( | ||
| "failed to parse private key, required to broadcast. Please check CRE_ETH_PRIVATE_KEY in your .env file or system environment: %w", err) | ||
| "a private key is required for --broadcast mode.\n" + | ||
| "Set CRE_ETH_PRIVATE_KEY in your .env file or system environment") | ||
| } | ||
| pk, err = crypto.HexToECDSA("0000000000000000000000000000000000000000000000000000000000000001") | ||
| if err != nil { | ||
|
|
@@ -1140,3 +1167,13 @@ func getEVMTriggerLogFromValues(ctx context.Context, ethClient *ethclient.Client | |
| } | ||
| return pbLog, nil | ||
| } | ||
|
|
||
| // isHexString returns true if s contains only hexadecimal characters (0-9, a-f, A-F). | ||
| func isHexString(s string) bool { | ||
| for _, c := range s { | ||
| if (c < '0' || c > '9') && (c < 'a' || c > 'f') && (c < 'A' || c > 'F') { | ||
| return false | ||
| } | ||
| } | ||
| return len(s) > 0 | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,8 @@ | ||
| package workflow | ||
|
|
||
| import ( | ||
| "fmt" | ||
|
|
||
| "github.com/spf13/cobra" | ||
|
|
||
| "github.com/smartcontractkit/cre-cli/cmd/workflow/activate" | ||
|
|
@@ -23,6 +25,21 @@ func New(runtimeContext *runtime.Context) *cobra.Command { | |
| Long: `The workflow command allows you to register and manage existing workflows.`, | ||
| } | ||
|
|
||
| supportedChainsCmd := &cobra.Command{ | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: Can we move this to it's own file to follow the pattern of other commands? |
||
| Use: "supported-chains", | ||
| Short: "List all supported chain names", | ||
| Args: cobra.NoArgs, | ||
| RunE: func(cmd *cobra.Command, args []string) error { | ||
| names := simulate.SupportedChainNames() | ||
| fmt.Println("Supported chain names:") | ||
| for _, name := range names { | ||
| fmt.Printf(" %s\n", name) | ||
| } | ||
| return nil | ||
| }, | ||
| } | ||
|
|
||
| workflowCmd.AddCommand(supportedChainsCmd) | ||
| workflowCmd.AddCommand(activate.New(runtimeContext)) | ||
| workflowCmd.AddCommand(build.New(runtimeContext)) | ||
| workflowCmd.AddCommand(convert.New(runtimeContext)) | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| ## cre workflow supported-chains | ||
|
|
||
| List all supported chain names | ||
|
|
||
| ``` | ||
| cre workflow supported-chains [optional flags] | ||
| ``` | ||
|
|
||
| ### Options | ||
|
|
||
| ``` | ||
| -h, --help help for supported-chains | ||
| ``` | ||
|
|
||
| ### Options inherited from parent commands | ||
|
|
||
| ``` | ||
| -e, --env string Path to .env file which contains sensitive info | ||
| -R, --project-root string Path to the project root | ||
| -E, --public-env string Path to .env.public file which contains shared, non-sensitive build config | ||
| -T, --target string Use target settings from YAML config | ||
| -v, --verbose Run command in VERBOSE mode | ||
| ``` | ||
|
|
||
| ### SEE ALSO | ||
|
|
||
| * [cre workflow](cre_workflow.md) - Manages workflows | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't we have a generalised rpc check in the root of the cmd package?