utils

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2023 License: Apache-2.0 Imports: 27 Imported by: 8

Documentation

Index

Constants

View Source
const Percentage = 100

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 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" mapstructure:"plainPrivateKey"`
	KmsConfig       *kms.KmsConfig `json:"kmsConfig,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, gasLimitBumpRatio uint64, fn func(opts *bind.TransactOpts) (*types.Transaction, error)) (*types.Transaction, error)
	SignTypedData(typedData core.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
}

func NewUtils

func NewUtils() Utils

Jump to

Keyboard shortcuts

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