mirror of
https://github.com/OffchainLabs/prysm.git
synced 2026-01-09 13:28:01 -05:00
* wip passing e2e * reverting temp comment * remove unneeded comments * fixing merge errors * fixing more bugs from merge * fixing test * WIP moving code around and fixing tests * unused linting * gaz * temp removing these tests as we need placeholder/wrapper APIs for them with the removal of the gateway * attempting to remove dependencies to gRPC gateway , 1 mroe left in deps.bzl * renaming flags and other gateway services to http * goimport * fixing deepsource * git mv * Update validator/package/validator.yaml Co-authored-by: Radosław Kapka <rkapka@wp.pl> * Update validator/package/validator.yaml Co-authored-by: Radosław Kapka <rkapka@wp.pl> * Update cmd/beacon-chain/flags/base.go Co-authored-by: Radosław Kapka <rkapka@wp.pl> * Update cmd/beacon-chain/flags/base.go Co-authored-by: Radosław Kapka <rkapka@wp.pl> * Update cmd/beacon-chain/flags/base.go Co-authored-by: Radosław Kapka <rkapka@wp.pl> * addressing feedback * missed lint * renaming import * reversal based on feedback * fixing web ui registration * don't require mux handler * gaz * removing gRPC service from validator completely, merged with http service, renames are a work in progress * updating go.sum * linting * trailing white space * realized there was more cleanup i could do with code reuse * adding wrapper for routes * reverting version * fixing dependencies from merging develop * gaz * fixing unit test * fixing dependencies * reverting unit test * fixing conflict * updating change log * Update log.go Co-authored-by: Preston Van Loon <pvanloon@offchainlabs.com> * gaz * Update api/server/httprest/server.go Co-authored-by: Preston Van Loon <pvanloon@offchainlabs.com> * addressing some feedback * forgot to remove deprecated flag in usage * gofmt * fixing test * fixing deepsource issue * moving deprecated flag and adding timeout handler * missed removal of a flag * fixing test: * Update CHANGELOG.md Co-authored-by: Radosław Kapka <rkapka@wp.pl> * addressing feedback * updating comments based on feedback * removing unused field for now, we can add it back in if we need to use the option * removing unused struct * changing api-timeout flag based on feedback --------- Co-authored-by: Radosław Kapka <rkapka@wp.pl> Co-authored-by: Preston Van Loon <pvanloon@offchainlabs.com>
62 lines
1.9 KiB
Go
62 lines
1.9 KiB
Go
package web
|
|
|
|
import (
|
|
"fmt"
|
|
"path/filepath"
|
|
|
|
"github.com/prysmaticlabs/prysm/v5/api"
|
|
"github.com/prysmaticlabs/prysm/v5/cmd"
|
|
"github.com/prysmaticlabs/prysm/v5/cmd/validator/flags"
|
|
"github.com/prysmaticlabs/prysm/v5/config/features"
|
|
"github.com/prysmaticlabs/prysm/v5/runtime/tos"
|
|
"github.com/prysmaticlabs/prysm/v5/validator/rpc"
|
|
"github.com/urfave/cli/v2"
|
|
)
|
|
|
|
// Commands for managing Prysm validator accounts.
|
|
var Commands = &cli.Command{
|
|
Name: "web",
|
|
Category: "web",
|
|
Usage: "Defines commands for interacting with the Prysm web interface.",
|
|
Subcommands: []*cli.Command{
|
|
{
|
|
Name: "generate-auth-token",
|
|
Description: `Generate an authentication token for the Prysm web interface`,
|
|
Flags: cmd.WrapFlags([]cli.Flag{
|
|
flags.WalletDirFlag,
|
|
flags.HTTPServerHost,
|
|
flags.HTTPServerPort,
|
|
flags.AuthTokenPathFlag,
|
|
cmd.AcceptTosFlag,
|
|
}),
|
|
Before: func(cliCtx *cli.Context) error {
|
|
if err := cmd.LoadFlagsFromConfig(cliCtx, cliCtx.Command.Flags); err != nil {
|
|
return err
|
|
}
|
|
return tos.VerifyTosAcceptedOrPrompt(cliCtx)
|
|
},
|
|
Action: func(cliCtx *cli.Context) error {
|
|
if err := features.ConfigureValidator(cliCtx); err != nil {
|
|
return err
|
|
}
|
|
walletDirPath := cliCtx.String(flags.WalletDirFlag.Name)
|
|
if walletDirPath == "" {
|
|
log.Fatal("--wallet-dir not specified")
|
|
}
|
|
host := cliCtx.String(flags.HTTPServerHost.Name)
|
|
port := cliCtx.Int(flags.HTTPServerPort.Name)
|
|
validatorWebAddr := fmt.Sprintf("%s:%d", host, port)
|
|
authTokenPath := filepath.Join(walletDirPath, api.AuthTokenFileName)
|
|
tempAuthTokenPath := cliCtx.String(flags.AuthTokenPathFlag.Name)
|
|
if tempAuthTokenPath != "" {
|
|
authTokenPath = tempAuthTokenPath
|
|
}
|
|
if err := rpc.CreateAuthToken(authTokenPath, validatorWebAddr); err != nil {
|
|
log.WithError(err).Fatal("Could not create web auth token")
|
|
}
|
|
return nil
|
|
},
|
|
},
|
|
},
|
|
}
|