utils

package
v0.0.0-...-c40edbd Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2023 License: Apache-2.0 Imports: 31 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type EthClient

type EthClient interface {
	ethereum.ChainReader
	ethereum.TransactionReader
	ethereum.ChainStateReader
	ethereum.ContractCaller
	ethereum.LogFilterer

	BlockNumber(ctx context.Context) (uint64, error)
	ChainID(ctx context.Context) (*big.Int, error)
	Close()
}

type ISign

type ISign interface {
	// sign function receives raw message, not hash of message
	Sign(message []byte, dataType string) ([]byte, error)
	GetAddress() common.Address
}

func NewSignMethod

func NewSignMethod(config *SignMethodConfig) (ISign, error)

type KeystoreConfig

type KeystoreConfig struct {
	KeystorePath string `json:"keystorePath,omitempty"`
	Password     string `json:"password,omitempty"`
}

type KeystoreSign

type KeystoreSign struct {
	// contains filtered or unexported fields
}

func NewKeystoreSign

func NewKeystoreSign(KeystoreConfig *KeystoreConfig) (*KeystoreSign, error)

func (*KeystoreSign) GetAddress

func (KeystoreSign *KeystoreSign) GetAddress() common.Address

func (*KeystoreSign) Sign

func (KeystoreSign *KeystoreSign) Sign(message []byte, dataType string) ([]byte, error)

Sign function receives raw message, not hash of message

type KmsSign

type KmsSign struct {
	*kms.KmsSign
}

func NewKmsSign

func NewKmsSign(kmsConfig *kms.KmsConfig) (*KmsSign, error)

func (*KmsSign) GetAddress

func (kmsSign *KmsSign) GetAddress() common.Address

func (*KmsSign) Sign

func (kmsSign *KmsSign) Sign(message []byte, dataType string) ([]byte, error)

type PrivateKeyConfig

type PrivateKeyConfig struct {
	PrivateKey string `json:"privateKey"`
}

type PrivateKeySign

type PrivateKeySign struct {
	// contains filtered or unexported fields
}

func NewPrivateKeySign

func NewPrivateKeySign(plainPrivateKey string) (*PrivateKeySign, error)

func (*PrivateKeySign) GetAddress

func (privateKeySign *PrivateKeySign) GetAddress() common.Address

func (*PrivateKeySign) Sign

func (privateKeySign *PrivateKeySign) Sign(message []byte, dataType string) ([]byte, error)

type SignMethodConfig

type SignMethodConfig struct {
	PlainPrivateKey string          `json:"plainPrivateKey,omitempty"`
	KmsConfig       *kms.KmsConfig  `json:"kmsConfig,omitempty"`
	KeystoreConfig  *KeystoreConfig `json:"keystoreConfig,omitempty"`
}

type Utils

type Utils interface {
	Invoke(any interface{}, name string, args ...interface{}) (reflect.Value, error)
	LoadAbi(path string) (*abi.ABI, error)
	GetArguments(a abi.ABI, name string, data []byte, isInput bool) (abi.Arguments, error)
	UnpackToInterface(a abi.ABI, name string, data []byte, isInput bool, v interface{}) error
	Title(text string) string
	NewEthClient(url string) (EthClient, error)
	SendContractTransaction(signMethod ISign, chainId *big.Int, fn func(opts *bind.TransactOpts) (*types.Transaction, error)) (*types.Transaction, error)
	SignTypedData(typedData apitypes.TypedData, signMethod ISign) (hexutil.Bytes, error)
	FilterLogs(client EthClient, opts *bind.FilterOpts, contractAddresses []common.Address, filteredMethods map[*abi.ABI]map[string]struct{}) ([]types.Log, error)
	RlpHash(x interface{}) (h common.Hash)
	UnpackLog(smcAbi abi.ABI, out interface{}, event string, data []byte) error
	ToDecimal(ivalue interface{}, decimals uint64) decimal.Decimal
}

func NewUtils

func NewUtils() Utils

Jump to

Keyboard shortcuts

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