Skip to content

Commit

Permalink
Script for fetching node keys (#12609)
Browse files Browse the repository at this point in the history
  • Loading branch information
bolekk authored Mar 28, 2024
1 parent fb99cdb commit b2def74
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 0 deletions.
1 change: 1 addition & 0 deletions core/scripts/functions/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ func main() {
src.NewGenerateJobSpecsCommand(),
src.NewDeployJobSpecsCommand(),
src.NewDeleteJobsCommand(),
src.NewFetchKeysCommand(),
}

commandsList := func(commands []command) string {
Expand Down
44 changes: 44 additions & 0 deletions core/scripts/functions/src/fetch_keys.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package src

import (
"encoding/json"
"flag"
"fmt"
"os"
)

type fetchKeys struct {
}

func NewFetchKeysCommand() *fetchKeys {
return &fetchKeys{}
}

func (g *fetchKeys) Name() string {
return "fetch-keys"
}

func (g *fetchKeys) Run(args []string) {
fs := flag.NewFlagSet(g.Name(), flag.ContinueOnError)
nodesFile := fs.String("nodes", "", "a file containing nodes urls, logins and passwords")
chainID := fs.Int64("chainid", 80001, "chain id")
if err := fs.Parse(args); err != nil || *nodesFile == "" || *chainID == 0 {
fs.Usage()
os.Exit(1)
}

nodes := mustReadNodesList(*nodesFile)
nca := mustFetchNodesKeys(*chainID, nodes)

nodePublicKeys, err := json.MarshalIndent(nca, "", " ")
if err != nil {
panic(err)
}
filepath := "PublicKeys.json"
err = os.WriteFile(filepath, nodePublicKeys, 0600)
if err != nil {
panic(err)
}
fmt.Println("Functions OCR2 public keys have been saved to:", filepath)

}

0 comments on commit b2def74

Please sign in to comment.