Skip to content

Commit

Permalink
feat(opinit): also save keyfile after init step
Browse files Browse the repository at this point in the history
  • Loading branch information
traviolus committed Feb 13, 2025
1 parent 824dcac commit 3c2790f
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions models/opinit_bots/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -1099,6 +1099,31 @@ func WaitStartingInitBot(ctx context.Context) tea.Cmd {
}
}

keyFilePath, err := weavecontext.GetOPInitKeyFileJson(ctx)
if err != nil {
return ui.NonRetryableErrorLoading{Err: fmt.Errorf("failed to get key file path for OPinit: %w", err)}
}

keyFile := io.NewKeyFile()
err = keyFile.Load(keyFilePath)
if err != nil {
return ui.NonRetryableErrorLoading{Err: fmt.Errorf("failed to load key file for OPinit: %w", err)}
}

for _, botName := range BotNames {
if res, ok := state.SetupOpinitResponses[botName]; ok {
keyInfo := strings.Split(res, "\n")
address := strings.Split(keyInfo[0], ": ")
mnemonic := keyInfo[1]
keyFile.AddKey(string(BotNameToKeyName[botName]), io.NewKey(address[1], mnemonic))
}
}

err = keyFile.Write(keyFilePath)
if err != nil {
return ui.NonRetryableErrorLoading{Err: fmt.Errorf("failed to write key file: %w", err)}
}

if state.InitExecutorBot {
srv, err := service.NewService(service.OPinitExecutor)
if err != nil {
Expand Down

0 comments on commit 3c2790f

Please sign in to comment.