cmd

package
v3.0.0-...-9121f9c Latest Latest
Warning

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

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

Documentation

Overview

Package cmd includes relayer commands Copyright © 2020 Jack Zampolin jack.zampolin@gmail.com

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Package cmd includes relayer commands Copyright © 2020 Jack Zampolin jack.zampolin@gmail.com

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Package cmd includes relayer commands Copyright © 2020 Jack Zampolin jack.zampolin@gmail.com

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Package cmd includes relayer commands Copyright © 2020 Jack Zampolin <jack.zampolin@gmail.com>

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Index

Constants

View Source
const (
	REPOURL  = "https://github.com/defund-labs/relayer"
	PATHSURL = "https://github.com/defund-labs/relayer/tree/main/interchain"
)
View Source
const (
	MB = 1024 * 1024 // in bytes

)

Variables

View Source
var (
	// Version defines the application version (defined at compile time)
	Version = ""
)

Functions

func Execute

func Execute()

Execute adds all child commands to the root command and sets flags appropriately. This is called by main.main(). It only needs to happen once to the rootCmd.

func GetStartOptions

func GetStartOptions(cmd *cobra.Command) (uint64, uint64, error)

GetStartOptions sets strategy specific fields.

func NewRootCmd

func NewRootCmd(log *zap.Logger) *cobra.Command

NewRootCmd returns the root command for relayer. If log is nil, a new zap.Logger is set on the app state based on the command line flags regarding logging.

func OverwriteConfigFlag

func OverwriteConfigFlag(v *viper.Viper, cmd *cobra.Command) *cobra.Command

func UnmarshalJSONProviderConfig

func UnmarshalJSONProviderConfig(data []byte, customTypes map[string]reflect.Type) (any, error)

UnmarshalJSONProviderConfig contains the custom unmarshalling logic for ProviderConfig structs

func UpdateClientsFromChains

func UpdateClientsFromChains(ctx context.Context, src, dst *relayer.Chain, thresholdTime time.Duration) (time.Duration, error)

UpdateClientsFromChains takes src, dst chains, threshold time and update clients based on expiry time

Types

type Config

type Config struct {
	Global GlobalConfig   `yaml:"global" json:"global"`
	Chains relayer.Chains `yaml:"chains" json:"chains"`
	Paths  relayer.Paths  `yaml:"paths" json:"paths"`
}

Config represents the config file for the relayer

func (*Config) AddChain

func (c *Config) AddChain(chain *relayer.Chain) (err error)

AddChain adds an additional chain to the config

func (*Config) AddPath

func (c *Config) AddPath(name string, path *relayer.Path) (err error)

AddPath adds an additional path to the config

func (*Config) ChainsFromPath

func (c *Config) ChainsFromPath(path string) (map[string]*relayer.Chain, string, string, bool, error)

ChainsFromPath takes the path name and returns the properly configured chains

func (*Config) DeleteChain

func (c *Config) DeleteChain(chain string)

DeleteChain modifies c in-place to remove any chains that have the given name.

func (Config) MustYAML

func (c Config) MustYAML() []byte

MustYAML returns the yaml string representation of the Paths

func (*Config) ValidateClient

func (c *Config) ValidateClient(ctx context.Context, chain *relayer.Chain, height int64, pe *relayer.PathEnd) error

ValidateClient validates client id in provided pathend

func (*Config) ValidateConnection

func (c *Config) ValidateConnection(ctx context.Context, chain *relayer.Chain, height int64, pe *relayer.PathEnd) error

ValidateConnection validates connection id in provided pathend

func (*Config) ValidatePath

func (c *Config) ValidatePath(ctx context.Context, stderr io.Writer, p *relayer.Path) (err error)

ValidatePath checks that a path is valid

func (*Config) ValidatePathEnd

func (c *Config) ValidatePathEnd(ctx context.Context, stderr io.Writer, pe *relayer.PathEnd) error

ValidatePathEnd validates provided pathend and returns error for invalid identifiers

func (*Config) Wrapped

func (c *Config) Wrapped() *ConfigOutputWrapper

Wrapped converts the Config struct into a ConfigOutputWrapper struct

type ConfigInputWrapper

type ConfigInputWrapper struct {
	Global          GlobalConfig                          `yaml:"global"`
	ProviderConfigs map[string]*ProviderConfigYAMLWrapper `yaml:"chains"`
	Paths           relayer.Paths                         `yaml:"paths"`
}

ConfigInputWrapper is an intermediary type for parsing the config.yaml file

type ConfigOutputWrapper

type ConfigOutputWrapper struct {
	Global          GlobalConfig    `yaml:"global" json:"global"`
	ProviderConfigs ProviderConfigs `yaml:"chains" json:"chains"`
	Paths           relayer.Paths   `yaml:"paths" json:"paths"`
}

ConfigOutputWrapper is an intermediary type for writing the config to disk and stdout

type GlobalConfig

type GlobalConfig struct {
	APIListenPort  string `yaml:"api-listen-addr" json:"api-listen-addr"`
	Timeout        string `yaml:"timeout" json:"timeout"`
	Memo           string `yaml:"memo" json:"memo"`
	LightCacheSize int    `yaml:"light-cache-size" json:"light-cache-size"`
}

GlobalConfig describes any global relayer settings

type ProviderConfigWrapper

type ProviderConfigWrapper struct {
	Type  string                  `yaml:"type"  json:"type"`
	Value provider.ProviderConfig `yaml:"value" json:"value"`
}

ProviderConfigWrapper is an intermediary type for parsing arbitrary ProviderConfigs from json files and writing to json/yaml files

func (*ProviderConfigWrapper) UnmarshalJSON

func (pcw *ProviderConfigWrapper) UnmarshalJSON(data []byte) error

UnmarshalJSON adds support for unmarshalling data from an arbitrary ProviderConfig NOTE: Add new ProviderConfig types in the map here with the key set equal to the type of ChainProvider (e.g. cosmos, substrate, etc.)

type ProviderConfigYAMLWrapper

type ProviderConfigYAMLWrapper struct {
	Type  string `yaml:"type"`
	Value any    `yaml:"-"`
}

ProviderConfigYAMLWrapper is an intermediary type for parsing arbitrary ProviderConfigs from yaml files

func (*ProviderConfigYAMLWrapper) UnmarshalYAML

func (iw *ProviderConfigYAMLWrapper) UnmarshalYAML(n *yaml.Node) error

UnmarshalYAML adds support for unmarshalling data from arbitrary ProviderConfig entries found in the config file NOTE: Add logic for new ProviderConfig types in a switch case here

type ProviderConfigs

type ProviderConfigs map[string]*ProviderConfigWrapper

Jump to

Keyboard shortcuts

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