util

package
v0.0.0-...-ef390af Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2021 License: MIT Imports: 32 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 BigIntSliceToStrSlice

func BigIntSliceToStrSlice(vv []*big.Int) []string

func BuildKeys

func BuildKeys(privateKeyStr string) (*ecdsa.PrivateKey, *ecdsa.PublicKey, error)

func BuildSignedTransaction

func BuildSignedTransaction(
	contract common.Address,
	ethClient *ethclient.Client,
	chainID *big.Int,
	txInput []byte,
	privateKey *ecdsa.PrivateKey,
) (*types.Transaction, error)

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 PackERC721AgentInput

func PackERC721AgentInput(method string, params ...interface{}) ([]byte, error)

func SendTelegramMessage

func SendTelegramMessage(msg string)

func StrSliceToBigIntSlice

func StrSliceToBigIntSlice(ss []string) []*big.Int

func StrToBigInt

func StrToBigInt(val string) *big.Int

func TxOpts

func TxOpts(ctx context.Context, ethClient client.ETHClient, privateKey string, chainID *big.Int) (*bind.TransactOpts, error)

func ULID

func ULID() 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 {
	BalanceAlertThreshold  string `json:"balance_alert_threshold"`
	BalanceMonitorInterval int64  `json:"balance_monitor_interval"`
	ID                     string `json:"id"`
	Name                   string `json:"name"`
	ObserverFetchInterval  int64  `json:"observer_fetch_interval"`
	StartHeight            int64  `json:"start_height"`
	PrivateKey             string `json:"private_key"`
	Provider               string `json:"provider"`
	ConfirmNum             int64  `json:"confirm_num"`
	ERC721SwapAgentAddr    string `json:"erc_721_swap_agent_addr"`
	ERC1155SwapAgentAddr   string `json:"erc_1155_swap_agent_addr"`
	ExplorerUrl            string `json:"explorer_url"`
	MaxTrackRetry          int64  `json:"max_track_retry"`
	WaitMilliSecBetweenTx  int64  `json:"wait_milli_sec_between_tx"`
}

func (ChainConfig) Validate

func (cfg ChainConfig) Validate()

type Config

type Config struct {
	KeyManagerConfig KeyManagerConfig `json:"key_manager_config"`
	DBConfig         DBConfig         `json:"db_config"`
	ChainConfigs     []ChainConfig    `json:"chain_configs"`
	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 {
	LogLevel string `json:"log_level"`
	DSN      string `json:"dsn"`
}

func (DBConfig) Validate

func (cfg DBConfig) Validate()

type HmacSigner

type HmacSigner struct {
	ApiKey    string
	SecretKey []byte
}

hmacSigner uses HMAC SHA256 for signing payloads.

type KeyConfig

type KeyConfig struct {
	HMACKey            string `json:"hmac_key"`
	PrivateKey         string `json:"private_key"`
	ETHChainPrivateKey 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"`
	HMACKey       string `json:"hmac_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"`
	PrivateKey         string `json:"private_key"`
	ETHChainPrivateKey string `json:"destination_private_key"`
}

Jump to

Keyboard shortcuts

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