chain

package
v0.0.0-...-d298eb8 Latest Latest
Warning

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

Go to latest
Published: Feb 15, 2023 License: Apache-2.0 Imports: 12 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (

	// ConfigFilenames is a list of recognized names as Spellshape's chain config file.
	ConfigFilenames = []string{"config.yml", "config.yaml"}

	// DefaultTSClientPath defines the default relative path to use when generating the TS client.
	// The path is relative to the app's directory.
	DefaultTSClientPath = "ts-client"

	// DefaultVuePath defines the default relative path to use when scaffolding a Vue app.
	// The path is relative to the app's directory.
	DefaultVuePath = "vue"

	// DefaultReactPath defines the default relative path to use when scaffolding a React app.
	// The path is relative to the app's directory.
	DefaultReactPath = "react"

	// DefaultVuexPath defines the default relative path to use when generating Vuex stores for a Vue app.
	// The path is relative to the app's directory.
	DefaultVuexPath = "vue/src/store"

	// DefaultComposablesPath defines the default relative path to use when generating useQuery composables for a Vue app.
	// The path is relative to the app's directory.
	DefaultComposablesPath = "vue/src/composables"

	// DefaultHooksPath defines the default relative path to use when generating useQuery hooks for a React app.
	// The path is relative to the app's directory.
	DefaultHooksPath = "react/src/hooks"

	// DefaultOpenAPIPath defines the default relative path to use when generating an OpenAPI schema.
	// The path is relative to the app's directory.
	DefaultOpenAPIPath = "docs/static/openapi.yml"

	// LatestVersion defines the latest version of the config.
	LatestVersion version.Version = 1

	// Versions holds config types for the supported versions.
	Versions = map[version.Version]version.Converter{
		0: &v0.Config{},
		1: &v1.Config{},
	}
)
View Source
var ErrConfigNotFound = errors.New("could not locate a config.yml in your chain")

ErrConfigNotFound indicates that the config.yml can't be found.

Functions

func CheckVersion

func CheckVersion(configFile io.Reader) error

CheckVersion checks that the config version is the latest and if not a VersionError is returned.

func ComposablesPath

func ComposablesPath(conf *Config) string

ComposablesPath returns the relative path to the Vue useQuery composables directory. Path is relative to the app's directory.

func FaucetHost

func FaucetHost(cfg *Config) string

FaucetHost returns the faucet host to use.

func HooksPath

func HooksPath(conf *Config) string

HooksPath returns the relative path to the React useQuery hooks directory. Path is relative to the app's directory.

func LocateDefault

func LocateDefault(root string) (path string, err error)

LocateDefault locates the default path for the config file. Returns ErrConfigNotFound when no config file found.

func MigrateLatest

func MigrateLatest(current io.Reader, latest io.Writer) error

MigrateLatest migrates a config file to the latest version.

func ReadConfigVersion

func ReadConfigVersion(configFile io.Reader) (version.Version, error)

ReadConfigVersion reads the config version.

func Save

func Save(c Config, path string) error

Save saves a config to a YAML file.

func TSClientPath

func TSClientPath(conf Config) string

TSClientPath returns the relative path to the Typescript client directory. Path is relative to the app's directory.

func VuexPath

func VuexPath(conf *Config) string

VuexPath returns the relative path to the Vuex stores directory. Path is relative to the app's directory.

Types

type Config

type Config = v1.Config

Config defines the latest chain config.

func ConvertLatest

func ConvertLatest(c version.Converter) (_ *Config, err error)

ConvertLatest converts a config to the latest version.

func DefaultChainConfig

func DefaultChainConfig() *Config

DefaultChainConfig returns a config for the latest version initialized with default values.

func Parse

func Parse(configFile io.Reader) (*Config, error)

Parse reads a config file. When the version of the file being read is not the latest it is automatically migrated to the latest version.

func ParseFile

func ParseFile(path string) (*Config, error)

ParseFile parses a config from a file path.

func ParseNetwork

func ParseNetwork(configFile io.Reader) (*Config, error)

ParseNetwork reads a config file for Spellshape Network genesis. When the version of the file being read is not the latest it is automatically migrated to the latest version.

func ParseNetworkFile

func ParseNetworkFile(path string) (*Config, error)

ParseNetworkFile parses a config for Spellshape Network genesis from a file path.

type UnsupportedVersionError

type UnsupportedVersionError struct {
	Version version.Version
}

UnsupportedVersionError is returned when the version of the config is not supported.

func (UnsupportedVersionError) Error

func (e UnsupportedVersionError) Error() string

type ValidationError

type ValidationError struct {
	Message string
}

ValidationError is returned when a configuration is invalid.

func (ValidationError) Error

func (e ValidationError) Error() string

type Validator

type Validator = v1.Validator

Validator defines the latest validator settings.

func FirstValidator

func FirstValidator(conf *Config) (Validator, error)

FirstValidator returns the first validator from the validators list. An error is returned when there are no validators defined in the config.

type VersionError

type VersionError struct {
	Version version.Version
}

VersionError is returned when config version doesn't match with the version CLI supports.

func (VersionError) Error

func (e VersionError) Error() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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