types

package
v1.6.44 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	RouterKey         = "vm"
	TypeMsgEthereumTx = "MsgEthereumTx"
)

Variables

View Source
var (
	ErrInvalidLengthTx        = fmt.Errorf("proto: negative length found during unmarshaling")
	ErrIntOverflowTx          = fmt.Errorf("proto: integer overflow")
	ErrUnexpectedEndOfGroupTx = fmt.Errorf("proto: unexpected end of group")
)
View Source
var ModuleCdc = GetCodec()

Functions

func DefaultTxDecoder

func DefaultTxDecoder(cdc *codec.Codec) types2.TxDecoder

DefaultTxDecoder logic for standard transfer decoding

func ErrGenesisFile

func ErrGenesisFile(codespace sdk.CodespaceType, err error) error

func ErrInvalidParam

func ErrInvalidParam(desc string) error

func ErrNewDB

func ErrNewDB(codespace sdk.CodespaceType, err error) error

func ErrUnexpectedResponse

func ErrUnexpectedResponse(desc string) error

func GetCodec

func GetCodec() *codec.Codec

func IsValidPrivateKey

func IsValidPrivateKey(from types2.AccAddress, identity []byte) bool

func MarshalBigInt

func MarshalBigInt(i *big.Int) (string, error)

MarshalBigInt marshalls big int into text string for consistent encoding

func MarshalJSONIndent

func MarshalJSONIndent(cdc *amino.Codec, obj interface{}) ([]byte, error)

attempt to make some pretty json

func MustMarshalBigInt

func MustMarshalBigInt(i *big.Int) string

MustMarshalBigInt marshalls big int into text string for consistent encoding. It panics if an error is encountered.

func MustUnmarshalBigInt

func MustUnmarshalBigInt(s string) *big.Int

MustUnmarshalBigInt unmarshalls string from *big.Int. It panics if an error is encountered.

func PackPbMsgs

func PackPbMsgs(msgs []types2.PbMsg) []*codectypes.Any

func SignCommonTx

func SignCommonTx(from types2.AccAddress, nonce, gas uint64, msgs []types2.Msg, priv string, cdc *codec.Codec) ([]byte, error)

func SignPbTx

func SignPbTx(from types2.AccAddress, nonce, gas uint64, msgs []types2.PbMsg, priv string, cdc codec.BinaryMarshaler) ([]byte, error)

func UnmarshalBigInt

func UnmarshalBigInt(s string) (*big.Int, error)

UnmarshalBigInt unmarshalls string from *big.Int

Types

type CodeType

type CodeType = sdk.CodeType
const (
	DefaultCodespace sdk.CodespaceType = "app"
	CodeGenesisError CodeType          = 401
	CodeNewDBError   CodeType          = 402
	//CodeInitWithCfgError       	CodeType = 403
	//CodeTestNetError			CodeType = 404
	CodeInvalidParam       CodeType = 405
	CodeUnexpectedResponse CodeType = 406
)

type CommonTx

type CommonTx struct {
	From      types2.AccAddress `json:"from"`
	Nonce     uint64            `json:"nonce"`
	Gas       uint64            `json:"gas"`
	Msgs      []types2.Msg      `json:"msgs"`
	PubKey    []byte            `json:"pub_key"`
	Signature []byte            `json:"signature"`
}

func NewCommonTx

func NewCommonTx(from types2.AccAddress, nonce, gas uint64, msgs []types2.Msg) *CommonTx

func (*CommonTx) Bytes

func (msg *CommonTx) Bytes() []byte

func (*CommonTx) GetFromAddress

func (msg *CommonTx) GetFromAddress() types2.AccAddress

func (*CommonTx) GetGas

func (msg *CommonTx) GetGas() uint64

func (*CommonTx) GetMsgs

func (msg *CommonTx) GetMsgs() []types2.Msg

func (*CommonTx) GetNonce

func (msg *CommonTx) GetNonce() uint64

func (*CommonTx) GetSignBytes

func (msg *CommonTx) GetSignBytes() []byte

func (*CommonTx) GetSignature

func (tx *CommonTx) GetSignature() []byte

func (*CommonTx) SetPubKey

func (tx *CommonTx) SetPubKey(pub []byte)

func (*CommonTx) SetSignature

func (tx *CommonTx) SetSignature(sig []byte)

func (CommonTx) ValidateBasic

func (tx CommonTx) ValidateBasic() error

type ConfigFiles added in v1.6.8

type ConfigFiles struct {
	GenesisFile []byte `json:"genesis_file"`
	NodeID      string `json:"node_id"`
	ETHChainID  uint64 `json:"eth_chain_id"`
}

type EncodingConfig

type EncodingConfig struct {
	InterfaceRegistry types.InterfaceRegistry
	Marshaler         codec.Marshaler
	//TxConfig          client.TxConfig
	Amino *codec.Codec
}

func GetEncodingConfig

func GetEncodingConfig() *EncodingConfig

type MsgEthereumTx

type MsgEthereumTx struct {
	Data TxData
	// contains filtered or unexported fields
}

MsgEthereumTx encapsulates an Ethereum transaction as an SDK message.

func NewMsgEthereumTx

func NewMsgEthereumTx(
	nonce uint64, to *ethcmn.Address, amount *big.Int,
	gasLimit uint64, gasPrice *big.Int, payload []byte,
) MsgEthereumTx

NewMsgEthereumTx returns a reference to a new Ethereum transaction message.

func NewMsgEthereumTxContract

func NewMsgEthereumTxContract(
	nonce uint64, amount *big.Int, gasLimit uint64, gasPrice *big.Int, payload []byte,
) MsgEthereumTx

NewMsgEthereumTxContract returns a reference to a new Ethereum transaction message designated for contract creation.

func (MsgEthereumTx) Bytes

func (msg MsgEthereumTx) Bytes() []byte

func (*MsgEthereumTx) ChainID

func (msg *MsgEthereumTx) ChainID() *big.Int

ChainID returns which chain id this transaction was signed for (if at all)

func (MsgEthereumTx) Cost

func (msg MsgEthereumTx) Cost() *big.Int

Cost returns amount + gasprice * gaslimit.

func (*MsgEthereumTx) DecodeRLP

func (msg *MsgEthereumTx) DecodeRLP(s *rlp.Stream) error

DecodeRLP implements the rlp.Decoder interface.

func (*MsgEthereumTx) EncodeRLP

func (msg *MsgEthereumTx) EncodeRLP(w io.Writer) error

EncodeRLP implements the rlp.Encoder interface.

func (MsgEthereumTx) Fee

func (msg MsgEthereumTx) Fee() *big.Int

Fee returns gasprice * gaslimit.

func (*MsgEthereumTx) From

func (msg *MsgEthereumTx) From() sdk.AccAddress

From loads the ethereum sender address from the sigcache and returns an sdk.AccAddress from its bytes

func (MsgEthereumTx) GetFromAddress

func (msg MsgEthereumTx) GetFromAddress() sdk.AccAddress

func (MsgEthereumTx) GetGas

func (msg MsgEthereumTx) GetGas() uint64

GetGas implements the GasTx interface. It returns the GasLimit of the transaction.

func (MsgEthereumTx) GetMsgs

func (msg MsgEthereumTx) GetMsgs() []sdk.Msg

GetMsgs returns a single MsgEthereumTx as an sdk.Msg.

func (MsgEthereumTx) GetNonce

func (msg MsgEthereumTx) GetNonce() uint64

func (MsgEthereumTx) GetSignBytes

func (msg MsgEthereumTx) GetSignBytes() []byte

GetSignBytes returns the Amino bytes of an Ethereum transaction message used for signing.

NOTE: This method cannot be used as a chain ID is needed to create valid bytes to sign over. Use 'RLPSignBytes' instead.

func (MsgEthereumTx) GetSignature

func (msg MsgEthereumTx) GetSignature() []byte

func (MsgEthereumTx) GetSigners

func (msg MsgEthereumTx) GetSigners() []sdk.AccAddress

GetSigners returns the expected signers for an Ethereum transaction message. For such a message, there should exist only a single 'signer'.

NOTE: This method panics if 'VerifySig' hasn't been called first.

func (MsgEthereumTx) MsgType

func (msg MsgEthereumTx) MsgType() string

Type returns the types value of an MsgEthereumTx.

func (MsgEthereumTx) RLPSignBytes

func (msg MsgEthereumTx) RLPSignBytes(chainID *big.Int) ethcmn.Hash

RLPSignBytes returns the RLP hash of an Ethereum transaction message with a given chainID used for signing.

func (MsgEthereumTx) RawSignatureValues

func (msg MsgEthereumTx) RawSignatureValues() (v, r, s *big.Int)

RawSignatureValues returns the V, R, S signature values of the transaction. The return values should not be modified by the caller.

func (MsgEthereumTx) Route

func (msg MsgEthereumTx) Route() string

Route returns the route value of an MsgEthereumTx.

func (MsgEthereumTx) SetPubKey

func (msg MsgEthereumTx) SetPubKey([]byte)

func (MsgEthereumTx) SetSignature

func (msg MsgEthereumTx) SetSignature([]byte)

func (*MsgEthereumTx) Sign

func (msg *MsgEthereumTx) Sign(chainID *big.Int, priv *ecdsa.PrivateKey) error

Sign calculates a secp256k1 ECDSA signature and signs the transaction. It takes a private key and chainID to sign an Ethereum transaction according to EIP155 standard. It mutates the transaction as it populates the V, R, S fields of the Transaction's Signature.

func (MsgEthereumTx) String

func (msg MsgEthereumTx) String() string

func (MsgEthereumTx) To

func (msg MsgEthereumTx) To() *ethcmn.Address

To returns the recipient address of the transaction. It returns nil if the transaction is a contract creation.

func (MsgEthereumTx) ValidateBasic

func (msg MsgEthereumTx) ValidateBasic() error

ValidateBasic implements the sdk.Msg interface. It performs basic validation checks of a Transaction. If returns an error if validation fails.

func (*MsgEthereumTx) VerifySig

func (msg *MsgEthereumTx) VerifySig(chainID *big.Int) (ethcmn.Address, error)

VerifySig attempts to verify a Transaction's signature for a given chainID. A derived address is returned upon success or an error if recovery fails.

type PbTx

type PbTx struct {
	From      []byte            `protobuf:"bytes,1,opt,name=from,proto3" json:"from,omitempty"`
	Nonce     uint64            `protobuf:"varint,2,opt,name=nonce,proto3" json:"nonce,omitempty"`
	Gas       uint64            `protobuf:"varint,3,opt,name=gas,proto3" json:"gas,omitempty"`
	Msgs      []*codectypes.Any `protobuf:"bytes,4,rep,name=msgs,proto3" json:"msgs,omitempty"`
	PubKey    []byte            `protobuf:"bytes,5,opt,name=pub_key,json=pubKey,proto3" json:"pub_key,omitempty"`
	Signature []byte            `protobuf:"bytes,6,opt,name=signature,proto3" json:"signature,omitempty"`
}

func NewPbTx

func NewPbTx(from types2.AccAddress, nonce, gas uint64, msgs []types2.PbMsg) *PbTx

func (*PbTx) Bytes

func (msg *PbTx) Bytes() []byte

func (*PbTx) Descriptor

func (*PbTx) Descriptor() ([]byte, []int)

func (*PbTx) GetFrom

func (m *PbTx) GetFrom() []byte

func (*PbTx) GetFromAddress

func (msg *PbTx) GetFromAddress() types2.AccAddress

func (*PbTx) GetGas

func (m *PbTx) GetGas() uint64

func (*PbTx) GetMsgs

func (m *PbTx) GetMsgs() []types2.Msg

func (*PbTx) GetNonce

func (m *PbTx) GetNonce() uint64

func (*PbTx) GetPubKey

func (m *PbTx) GetPubKey() []byte

func (*PbTx) GetSignBytes

func (msg *PbTx) GetSignBytes() []byte

func (*PbTx) GetSignature

func (m *PbTx) GetSignature() []byte

func (*PbTx) Marshal

func (m *PbTx) Marshal() (dAtA []byte, err error)

func (*PbTx) MarshalTo

func (m *PbTx) MarshalTo(dAtA []byte) (int, error)

func (*PbTx) MarshalToSizedBuffer

func (m *PbTx) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*PbTx) ProtoMessage

func (*PbTx) ProtoMessage()

func (*PbTx) Reset

func (m *PbTx) Reset()

func (*PbTx) SetPubKey

func (tx *PbTx) SetPubKey(pub []byte)

func (*PbTx) SetSignature

func (tx *PbTx) SetSignature(sig []byte)

func (*PbTx) Size

func (m *PbTx) Size() (n int)

func (*PbTx) String

func (m *PbTx) String() string

func (*PbTx) Unmarshal

func (m *PbTx) Unmarshal(dAtA []byte) error

func (*PbTx) UnpackInterfaces

func (tx *PbTx) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error

func (PbTx) ValidateBasic

func (tx PbTx) ValidateBasic() error

func (*PbTx) XXX_DiscardUnknown

func (m *PbTx) XXX_DiscardUnknown()

func (*PbTx) XXX_Marshal

func (m *PbTx) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*PbTx) XXX_Merge

func (m *PbTx) XXX_Merge(src proto.Message)

func (*PbTx) XXX_Size

func (m *PbTx) XXX_Size() int

func (*PbTx) XXX_Unmarshal

func (m *PbTx) XXX_Unmarshal(b []byte) error

type TxData

type TxData struct {
	AccountNonce uint64          `json:"nonce"`
	Price        *big.Int        `json:"gasPrice"`
	GasLimit     uint64          `json:"gas"`
	Recipient    *ethcmn.Address `json:"to" rlp:"nil"` // nil means contract creation
	Amount       *big.Int        `json:"value"`
	Payload      []byte          `json:"input"`

	// signature values
	V *big.Int `json:"v"`
	R *big.Int `json:"r"`
	S *big.Int `json:"s"`

	// hash is only used when marshaling to JSON
	Hash *ethcmn.Hash `json:"hash" rlp:"-"`
}

TxData implements the Ethereum transaction data structure. It is used solely as intended in Ethereum abiding by the protocol.

func (TxData) MarshalAmino

func (td TxData) MarshalAmino() ([]byte, error)

MarshalAmino defines custom encoding scheme for TxData

func (TxData) String

func (td TxData) String() string

func (*TxData) UnmarshalAmino

func (td *TxData) UnmarshalAmino(data []byte) error

UnmarshalAmino defines custom decoding scheme for TxData

Directories

Path Synopsis
Package service is a reverse proxy.
Package service is a reverse proxy.

Jump to

Keyboard shortcuts

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