ethereum

package
v0.0.0-...-cdae4ff Latest Latest
Warning

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

Go to latest
Published: Feb 23, 2024 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ChainEthereum = 2
	ChainMVM      = 4
	ChainPolygon  = 6

	TransactionConfirmations = 1

	ValuePrecision = 18
	ValueDust      = 100000000000000

	TimeLockMinimum = time.Hour * 1
	TimeLockMaximum = time.Hour * 24 * 365

	TypeETHTx       = 1
	TypeERC20Tx     = 2
	TypeMultiSendTx = 3

	EthereumEmptyAddress                        = "0x0000000000000000000000000000000000000000"
	EthereumSafeProxyFactoryAddress             = "0x4e1DCf7AD4e460CfD30791CCC4F9c8a4f820ec67"
	EthereumSafeL2Address                       = "0x29fcB43b46531BcA003ddC8FCB67FFE91900C762"
	EthereumCompatibilityFallbackHandlerAddress = "0xfd0732Dc9E303f09fCEf3a7388Ad10A83459Ec99"
	EthereumMultiSendAddress                    = "0x38869bf66a61cF6bDB996A6aE40D5853Fd43B526"
	EthereumSafeGuardAddress                    = "0x5cFE246E7F5d2473e34D0F2B33552076a682d68C"
)

Variables

This section is empty.

Functions

func AddSignature

func AddSignature(rpc, raw, public string, sig []byte) (string, error)

func BuildChainAssetId

func BuildChainAssetId(base, asset string) string

func CheckTransactionPartiallySignedBy

func CheckTransactionPartiallySignedBy(raw, public string) bool

func CheckTransactionSignature

func CheckTransactionSignature(raw, public string, signature []byte) (bool, error)

func GenerateAssetId

func GenerateAssetId(chain byte, assetKey string) string

func GetERC20TxData

func GetERC20TxData(receiver string, amount *big.Int) []byte

func GetEvmChainID

func GetEvmChainID(chain int64) int64

func GetMetaTxData

func GetMetaTxData(to common.Address, amount *big.Int, data []byte) []byte

func GetMixinChainID

func GetMixinChainID(chain int64) string

func GetMultiSendData

func GetMultiSendData(outputs []*Output) []byte

func GetOwners

func GetOwners(rpc, address string) ([]common.Address, error)

func GetSafeLastTxTime

func GetSafeLastTxTime(rpc, address string) (time.Time, error)

func HashMessageForSignature

func HashMessageForSignature(msg string) ([]byte, error)

func NormalizeAddress

func NormalizeAddress(addr string) string

func ParseAmount

func ParseAmount(amount string, decimals int32) *big.Int

func ParseEthereumCompressedPublicKey

func ParseEthereumCompressedPublicKey(public string) (*common.Address, error)

func ParseEthereumUncompressedPublicKey

func ParseEthereumUncompressedPublicKey(public string) (*common.Address, error)

func PrivToAddress

func PrivToAddress(priv string) (*common.Address, error)

func ProcessSignature

func ProcessSignature(signature []byte) []byte

func RPCGetAddressBalance

func RPCGetAddressBalance(rpc, txHash, address string) (*big.Int, error)

func RPCGetAddressBalanceAtBlock

func RPCGetAddressBalanceAtBlock(rpc, blockHash, address string) (*big.Int, error)

func RPCGetBlockHash

func RPCGetBlockHash(rpc string, height int64) (string, error)

func RPCGetBlockHeight

func RPCGetBlockHeight(rpc string) (int64, error)

func RPCGetGasPrice

func RPCGetGasPrice(rpc string) (*big.Int, error)

func SignTx

func SignTx(rawStr, privateStr string) (string, error)

func UnitAmount

func UnitAmount(amount *big.Int, decimals int32) string

func VerifyAssetKey

func VerifyAssetKey(assetKey string) error

func VerifyHashSignature

func VerifyHashSignature(public string, hash, sig []byte) error

func VerifyHolderKey

func VerifyHolderKey(public string) error

func VerifyMessageSignature

func VerifyMessageSignature(public string, msg, sig []byte) error

Types

type Asset

type Asset struct {
	Address  string
	Id       string
	Symbol   string
	Name     string
	Decimals uint32
	Chain    byte
}

func FetchAsset

func FetchAsset(chain byte, rpc, address string) (*Asset, error)

type Output

type Output struct {
	TokenAddress string
	Destination  string
	Amount       *big.Int
}

type RPCBlock

type RPCBlock struct {
	Hash      string   `json:"hash"`
	Number    string   `json:"number"`
	Tx        []string `json:"transactions"`
	Timestamp string   `json:"timestamp"`

	Height uint64
	Time   time.Time
}

func RPCGetBlock

func RPCGetBlock(rpc, hash string) (*RPCBlock, error)

type RPCBlockCallTrace

type RPCBlockCallTrace struct {
	Result *RPCTransactionCallTrace `json:"result"`
}

func RPCDebugTraceBlockByHash

func RPCDebugTraceBlockByHash(rpc, hash string) ([]*RPCBlockCallTrace, error)

type RPCBlockWithTransactions

type RPCBlockWithTransactions struct {
	Hash   string            `json:"hash"`
	Number string            `json:"number"`
	Tx     []*RPCTransaction `json:"transactions"`

	Height uint64
}

func RPCGetBlockWithTransactions

func RPCGetBlockWithTransactions(rpc, hash string) (*RPCBlockWithTransactions, error)

type RPCTransaction

type RPCTransaction struct {
	BlockHash        string `json:"blockHash"`
	BlockNumber      string `json:"blockNumber"`
	ChainID          string `json:"chainId"`
	From             string `json:"from"`
	Gas              string `json:"gas"`
	GasPrice         string `json:"gasPrice"`
	Hash             string `json:"hash"`
	Input            string `json:"input"`
	Nonce            string `json:"Nonce"`
	To               string `json:"to"`
	TransactionIndex string `json:"transactionIndex"`
	Type             string `json:"type"`
	Value            string `json:"value"`

	BlockHeight uint64
}

func RPCGetTransactionByHash

func RPCGetTransactionByHash(rpc, hash string) (*RPCTransaction, error)

type RPCTransactionCallTrace

type RPCTransactionCallTrace struct {
	Calls   []*RPCTransactionCallTrace `json:"calls"`
	Error   string                     `json:"error"`
	From    string                     `json:"from"`
	Gas     string                     `json:"gas"`
	GasUsed string                     `json:"gasUsed"`
	Input   string                     `json:"input"`
	Output  string                     `json:"output"`
	To      string                     `json:"to"`
	Type    string                     `json:"type"`
	Value   string                     `json:"value"`
}

func RPCDebugTraceTransactionByHash

func RPCDebugTraceTransactionByHash(rpc, hash string) (*RPCTransactionCallTrace, error)

type SafeTransaction

type SafeTransaction struct {
	TxHash         string
	ChainID        int64
	SafeAddress    string
	Destination    common.Address
	Value          *big.Int
	Data           []byte
	Operation      uint8
	SafeTxGas      *big.Int
	BaseGas        *big.Int
	GasPrice       *big.Int
	GasToken       common.Address
	RefundReceiver common.Address
	Nonce          *big.Int
	Message        []byte
	Signatures     [][]byte
}

func CreateEnableGuardTransaction

func CreateEnableGuardTransaction(ctx context.Context, chainID int64, id, safeAddress, observerAddress string, timelock *big.Int) (*SafeTransaction, error)

func CreateMultiSendTransaction

func CreateMultiSendTransaction(ctx context.Context, chainID int64, id, safeAddress string, outputs []*Output, nonce *big.Int) (*SafeTransaction, error)

func CreateTransaction

func CreateTransaction(ctx context.Context, typ int, chainID int64, id, safeAddress, destination, tokenAddress, amount string, nonce *big.Int) (*SafeTransaction, error)

func CreateTransactionFromOutputs

func CreateTransactionFromOutputs(ctx context.Context, typ int, chainId int64, id, safeAddress string, outputs []*Output, nonce *big.Int) (*SafeTransaction, error)

func UnmarshalSafeTransaction

func UnmarshalSafeTransaction(b []byte) (*SafeTransaction, error)

func (*SafeTransaction) ExtractOutputs

func (tx *SafeTransaction) ExtractOutputs() []*Output

func (*SafeTransaction) GetEnableGuradData

func (tx *SafeTransaction) GetEnableGuradData(observer string, timelock *big.Int) []byte

func (*SafeTransaction) GetTransactionHash

func (tx *SafeTransaction) GetTransactionHash() []byte

func (*SafeTransaction) Hash

func (tx *SafeTransaction) Hash(id string) string

func (*SafeTransaction) Marshal

func (tx *SafeTransaction) Marshal() []byte

func (*SafeTransaction) ParseMultiSendData

func (tx *SafeTransaction) ParseMultiSendData() ([]*Output, error)

type Transfer

type Transfer struct {
	Hash         string
	Index        int64
	TokenAddress string
	AssetId      string
	Sender       string
	Receiver     string
	Value        *big.Int
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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