util

package
v0.0.0-...-50fcca9 Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2021 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// Logger instance for quick declarative logging levels
	Logger    = logging.MustGetLogger("deputy")
	SdkLogger = &sdkLogger{}
)

Functions

func GetSecret

func GetSecret(secretName, region string) (string, error)

func InitLogger

func InitLogger(config LogConfig)

InitLogger initialises the logger.

func InitTgAlerter

func InitTgAlerter(cfg AlertConfig)

func SendTelegramMessage

func SendTelegramMessage(msg string)

Types

type AdminConfig

type AdminConfig struct {
	ListenAddr string `json:"listen_addr"`
}

type AlertConfig

type AlertConfig struct {
	TelegramBotId  string `json:"telegram_bot_id"`
	TelegramChatId string `json:"telegram_chat_id"`

	BlockUpdateTimeout int64 `json:"block_update_timeout"`
}

func (AlertConfig) Validate

func (cfg AlertConfig) Validate()

type ChainConfig

type ChainConfig struct {
	BalanceMonitorInterval int64 `json:"balance_monitor_interval"`

	BSCObserverFetchInterval    int64  `json:"bsc_observer_fetch_interval"`
	BSCStartHeight              int64  `json:"bsc_start_height"`
	BSCProvider                 string `json:"bsc_provider"`
	BSCConfirmNum               int64  `json:"bsc_confirm_num"`
	BSCSwapAgentAddr            string `json:"bsc_swap_agent_addr"`
	BSCExplorerUrl              string `json:"bsc_explorer_url"`
	BSCMaxTrackRetry            int64  `json:"bsc_max_track_retry"`
	BSCAlertThreshold           string `json:"bsc_alert_threshold"`
	BSCWaitMilliSecBetweenSwaps int64  `json:"bsc_wait_milli_sec_between_swaps"`

	ETHObserverFetchInterval    int64  `json:"eth_observer_fetch_interval"`
	ETHStartHeight              int64  `json:"eth_start_height"`
	ETHProvider                 string `json:"eth_provider"`
	ETHConfirmNum               int64  `json:"eth_confirm_num"`
	ETHSwapAgentAddr            string `json:"eth_swap_agent_addr"`
	ETHExplorerUrl              string `json:"eth_explorer_url"`
	ETHMaxTrackRetry            int64  `json:"eth_max_track_retry"`
	ETHAlertThreshold           string `json:"eth_alert_threshold"`
	ETHWaitMilliSecBetweenSwaps int64  `json:"eth_wait_milli_sec_between_swaps"`
}

func (ChainConfig) Validate

func (cfg ChainConfig) Validate()

type Config

type Config struct {
	KeyManagerConfig KeyManagerConfig `json:"key_manager_config"`
	DBConfig         DBConfig         `json:"db_config"`
	ChainConfig      ChainConfig      `json:"chain_config"`
	LogConfig        LogConfig        `json:"log_config"`
	AlertConfig      AlertConfig      `json:"alert_config"`
	AdminConfig      AdminConfig      `json:"admin_config"`
}

func ParseConfigFromFile

func ParseConfigFromFile(filePath string) *Config

func ParseConfigFromJson

func ParseConfigFromJson(content string) *Config

func (*Config) Validate

func (cfg *Config) Validate()

type DBConfig

type DBConfig struct {
	Dialect string `json:"dialect"`
	DBPath  string `json:"db_path"`
}

func (DBConfig) Validate

func (cfg DBConfig) Validate()

type HmacSigner

type HmacSigner struct {
	ApiKey    string
	SecretKey []byte
}

hmacSigner uses HMAC SHA256 for signing payloads.

func NewHmacSigner

func NewHmacSigner(apiKey string, secretKey string) *HmacSigner

func NewHmacSignerFromConfig

func NewHmacSignerFromConfig(config *Config) (*HmacSigner, error)

func (*HmacSigner) Sign

func (hs *HmacSigner) Sign(payload []byte) string

Sign signs provided payload and returns encoded string sum.

func (*HmacSigner) Verify

func (hs *HmacSigner) Verify(payload []byte, hash string) bool

type KeyConfig

type KeyConfig struct {
	HMACKey        string `json:"hmac_key"`
	BSCPrivateKey  string `json:"bsc_private_key"`
	ETHPrivateKey  string `json:"eth_private_key"`
	AdminApiKey    string `json:"admin_api_key"`
	AdminSecretKey string `json:"admin_secret_key"`
}

type KeyManagerConfig

type KeyManagerConfig struct {
	KeyType       string `json:"key_type"`
	AWSRegion     string `json:"aws_region"`
	AWSSecretName string `json:"aws_secret_name"`

	// local keys
	LocalHMACKey        string `json:"local_hmac_key"`
	LocalBSCPrivateKey  string `json:"local_bsc_private_key"`
	LocalETHPrivateKey  string `json:"local_eth_private_key"`
	LocalAdminApiKey    string `json:"local_admin_api_key"`
	LocalAdminSecretKey string `json:"local_admin_secret_key"`
}

func (KeyManagerConfig) Validate

func (cfg KeyManagerConfig) Validate()

type LogConfig

type LogConfig struct {
	Level                        string `json:"level"`
	Filename                     string `json:"filename"`
	MaxFileSizeInMB              int    `json:"max_file_size_in_mb"`
	MaxBackupsOfLogFiles         int    `json:"max_backups_of_log_files"`
	MaxAgeToRetainLogFilesInDays int    `json:"max_age_to_retain_log_files_in_days"`
	UseConsoleLogger             bool   `json:"use_console_logger"`
	UseFileLogger                bool   `json:"use_file_logger"`
	Compress                     bool   `json:"compress"`
}

func (LogConfig) Validate

func (cfg LogConfig) Validate()

type Signer

type Signer interface {
	// Sign signs provided payload and returns encoded string sum.
	Sign(payload []byte) string

	Verify(payload []byte, hash string) bool
}

Signer signs provided payloads.

type TgAlerter

type TgAlerter struct {
	BotId  string
	ChatId string
}

type TokenSecretKey

type TokenSecretKey struct {
	Symbol        string `json:"symbol"`
	BSCPrivateKey string `json:"bsc_private_key"`
	ETHPrivateKey string `json:"eth_private_key"`
}

Jump to

Keyboard shortcuts

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