Skip to content

Sim auth#26

Merged
ivpusic merged 2 commits intomainfrom
sim/auth
Mar 12, 2026
Merged

Sim auth#26
ivpusic merged 2 commits intomainfrom
sim/auth

Conversation

@ivpusic
Copy link
Member

@ivpusic ivpusic commented Mar 11, 2026

Add dune sim auth command for persisting a Sim API key via --api-key flag, DUNE_SIM_API_KEY env var, or interactive prompt. Wires up the sim command tree with SimClient, evm/svm parent commands, and registers sim in the root CLI.

…, root registration

- Extend authconfig.Config with SimAPIKey field for sim_api_key in config.yaml
- Add SimClient HTTP wrapper (cmd/sim/client.go) with X-Sim-Api-Key auth header
  and structured HTTP error handling (400/401/404/429/500)
- Add SetSimClient/SimClientFromCmd to cmdutil for context-based client injection
- Create sim parent command with PersistentPreRunE that resolves sim API key
  (--sim-api-key flag > DUNE_SIM_API_KEY env > config file)
- Create stub evm/svm parent commands for future subcommands
- Register sim command in cli/root.go init()
- All commands annotated with skipAuth to bypass Dune API key requirement
@cursor
Copy link

cursor bot commented Mar 12, 2026

PR Summary

Medium Risk
Adds a new authentication path and persists an additional API key in the shared CLI config, which could impact config compatibility and key-handling behavior. Also introduces a new HTTP client and command wiring, so failures would primarily affect the new sim command tree.

Overview
Adds a new top-level dune sim command group, registered in cli/root.go, with evm and svm placeholder subcommands and a PersistentPreRunE that resolves a Sim API key and injects a SimClient into the command context.

Introduces dune sim auth to persist sim_api_key into ~/.config/dune/config.yaml (from --api-key, DUNE_SIM_API_KEY, or an interactive prompt), extends authconfig.Config to store SimAPIKey, and adds cmdutil helpers (SetSimClient/SimClientFromCmd) plus tests covering key sources and preserving existing config fields.

Written by Cursor Bugbot for commit 3ec8d83. Configure here.

@ivpusic ivpusic requested a review from va3093 March 12, 2026 09:09
Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Bugbot Autofix prepared a fix for the issue found in the latest run.

  • ✅ Fixed: Sim's PersistentPreRunE overrides root's, breaking telemetry tracking
    • Added cmdutil.SetStartTime call at the beginning of simPreRun to ensure start time is tracked for all sim subcommands.

Create PR

Or push these changes by commenting:

@cursor push 6d2c3c3b2c
Preview (6d2c3c3b2c)
diff --git a/cmd/sim/sim.go b/cmd/sim/sim.go
--- a/cmd/sim/sim.go
+++ b/cmd/sim/sim.go
@@ -4,6 +4,7 @@
 	"fmt"
 	"os"
 	"strings"
+	"time"
 
 	"github.com/spf13/cobra"
 
@@ -43,6 +44,8 @@
 // simPreRun resolves the Sim API key and stores a SimClient in the command context.
 // Commands annotated with "skipSimAuth": "true" bypass this step.
 func simPreRun(cmd *cobra.Command, _ []string) error {
+	cmdutil.SetStartTime(cmd, time.Now())
+
 	// Allow commands like `sim auth` to skip sim client creation.
 	if cmd.Annotations["skipSimAuth"] == "true" {
 		return nil

Comment @cursor review or bugbot run to trigger another review on this PR

@ivpusic ivpusic merged commit 225485f into main Mar 12, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants