Help us shape the future of Go! Take the 2026 Go Developer Survey

initialize

package
v0.13.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 19, 2021 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Cmd = &cobra.Command{
	Use:   "init",
	Short: "Initialize a new account profile",
	Run: func(cmd *cobra.Command, args []string) {
		if !cli.ConfigExists() || conf.Reset {
			var pconf *cli.Config
			serviceKeySigAlgo := crypto.StringToSignatureAlgorithm(conf.ServiceKeySigAlgo)
			serviceKeyHashAlgo := crypto.StringToHashAlgorithm(conf.ServiceKeyHashAlgo)
			if len(conf.ServicePrivateKey) > 0 {
				serviceKey := cli.MustDecodePrivateKeyHex(serviceKeySigAlgo, conf.ServicePrivateKey)
				pconf = InitProjectWithServiceKey(serviceKey, serviceKeyHashAlgo)
			} else {
				pconf = InitProject(serviceKeySigAlgo, serviceKeyHashAlgo)
			}
			serviceAcct := pconf.ServiceAccount()

			fmt.Printf("⚙️   Flow client initialized with service account:\n\n")
			fmt.Printf("👤  Address: 0x%x\n", serviceAcct.Address.Bytes())
			fmt.Printf("ℹ️   Start the emulator with this service account by running: flow emulator start\n")
		} else {
			fmt.Printf("⚠️   Flow configuration file already exists! Begin by running: flow emulator start\n")
		}
	},
}

Functions

func InitProject

func InitProject(sigAlgo crypto.SignatureAlgorithm, hashAlgo crypto.HashAlgorithm) *cli.Config

InitProject generates a new service key and saves project config.

func InitProjectWithServiceKey

func InitProjectWithServiceKey(privateKey crypto.PrivateKey, hashAlgo crypto.HashAlgorithm) *cli.Config

InitProjectWithServiceKey creates and saves a new project config using the specified service key.

Types

type Config

type Config struct {
	ServicePrivateKey  string `flag:"service-priv-key" info:"Service account private key"`
	ServiceKeySigAlgo  string `default:"ECDSA_P256" flag:"service-sig-algo" info:"Service account key signature algorithm"`
	ServiceKeyHashAlgo string `default:"SHA3_256" flag:"service-hash-algo" info:"Service account key hash algorithm"`
	Reset              bool   `default:"false" flag:"reset" info:"Reset flow.json config file"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL