types

package
v0.0.0-...-77861b7 Latest Latest
Warning

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

Go to latest
Published: Jun 16, 2023 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Address_Length_20  = uint16(20)
	Address_Length_8   = uint16(8)
	Address_Max_Length = uint16(1 << 8)
	Address_Length_32  = uint16(32)
)

Variables

View Source
var (
	ErrInvalidLengthCommon        = fmt.Errorf("proto: negative length found during unmarshaling")
	ErrIntOverflowCommon          = fmt.Errorf("proto: integer overflow")
	ErrUnexpectedEndOfGroupCommon = fmt.Errorf("proto: unexpected end of group")
)
View Source
var AddressTypeLength = map[Address_Type]uint16{
	Address_Bytes20: Address_Length_20,
	Address_Bytes8:  Address_Length_8,
	Address_Hex:     Address_Max_Length,
	Address_String:  Address_Max_Length,
	Address_Bytes32: Address_Length_32,
}
View Source
var Address_Type_name = map[int32]string{
	0: "Hex",
	1: "String",
	2: "Bytes20",
	3: "Bytes8",
	4: "Bytes32",
}
View Source
var Address_Type_value = map[string]int32{
	"Hex":     0,
	"String":  1,
	"Bytes20": 2,
	"Bytes8":  3,
	"Bytes32": 4,
}
View Source
var NonEvmChainID_name = map[int32]string{
	0:        "UNDEFINED",
	12340001: "FLOW_MAINNET",
	12340002: "FLOW_TEST",
	12340003: "FLOW_EMULATOR",
	12350001: "SOLANA_MAINNET",
	12350002: "SOLANA_TEST",
	12350003: "SOLANA_EMULATOR",
	12360001: "APTOS_MAINNET",
	12360002: "APTOS_TEST",
	12360003: "APTOS_LOCAL",
}
View Source
var NonEvmChainID_value = map[string]int32{
	"UNDEFINED":       0,
	"FLOW_MAINNET":    12340001,
	"FLOW_TEST":       12340002,
	"FLOW_EMULATOR":   12340003,
	"SOLANA_MAINNET":  12350001,
	"SOLANA_TEST":     12350002,
	"SOLANA_EMULATOR": 12350003,
	"APTOS_MAINNET":   12360001,
	"APTOS_TEST":      12360002,
	"APTOS_LOCAL":     12360003,
}
View Source
var Supplement_Type_name = map[int32]string{
	0: "Address",
}
View Source
var Supplement_Type_value = map[string]int32{
	"Address": 0,
}

Functions

func CheckValidity

func CheckValidity(_bytes []byte, _type Address_Type) bool

func IsAptosChain

func IsAptosChain(chid uint64) bool

func IsFlowChain

func IsFlowChain(chid uint64) bool

func IsHexAddress

func IsHexAddress(s string) bool

IsHexAddress verifies whether a string can represent a valid hex-encoded address or not.

Types

type Address

type Address struct {
	// data defines the address data
	Data []byte `protobuf:"bytes,1,opt,name=data,proto3" json:"data,omitempty"`
	// type defines the address type
	Type Address_Type `protobuf:"varint,2,opt,name=type,proto3,enum=sgn.common.v1.Address_Type" json:"type,omitempty"`
}

Address describes a common type of address processed in sgn, and has no relation with sgn native address

func GetConfiscateAddrByChainId

func GetConfiscateAddrByChainId(chid uint64) *Address

func GetZeroAddrByChainId

func GetZeroAddrByChainId(chid uint64) *Address

func ZeroAddr

func ZeroAddr() *Address

func (*Address) Bytes

func (a *Address) Bytes() []byte

func (*Address) ConvertReceiver

func (a *Address) ConvertReceiver(chid uint64) *Address

func (*Address) ConvertSender

func (a *Address) ConvertSender(chid uint64) *Address

func (*Address) Copy

func (a *Address) Copy(expected *Address) *Address

func (*Address) Descriptor

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

func (*Address) Equal

func (this *Address) Equal(that interface{}) bool

func (*Address) GetData

func (m *Address) GetData() []byte

func (*Address) GetEthAddress

func (a *Address) GetEthAddress() eth.Addr

GetEthAddress would return the corresponding eth address of Address if its type is evm or (len=20)hexadecimal, else return the zero eth address.

func (*Address) GetFixedHexAddr

func (a *Address) GetFixedHexAddr() string

GetFixedHexAddr For some other server such as gateway, sentinel, im-scan, addr in db need it.

func (*Address) GetType

func (m *Address) GetType() Address_Type

func (*Address) Hex

func (a *Address) Hex() string

func (*Address) IsValid

func (a *Address) IsValid() bool

func (*Address) Length

func (a *Address) Length() uint16

func (*Address) Marshal

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

func (*Address) MarshalTo

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

func (*Address) MarshalToSizedBuffer

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

func (*Address) ProtoMessage

func (*Address) ProtoMessage()

func (*Address) Reset

func (m *Address) Reset()

func (Address) SetBytes

func (a Address) SetBytes(_bytes []byte) *Address

SetBytes return an Address defined by _bytes with auto length match. Address_String is not applicable. It is very dangerous to apply SetBytes with an unknown byte slice, especially when there are string-like addresses.

func (*Address) SetBytes20Address

func (a *Address) SetBytes20Address(addr eth.Addr) *Address

func (*Address) SetBytes32Address

func (a *Address) SetBytes32Address(aptosAddr [32]byte) *Address

func (*Address) SetBytes8Address

func (a *Address) SetBytes8Address(flowAddr [8]byte) *Address

func (*Address) SetBytesByChainId

func (a *Address) SetBytesByChainId(_bytes []byte, _chainId uint64) *Address

SetBytesByChainId return an Address defined by _bytes and _chainId. Some chain has hex type account address and string type token address. While only one type is matched by a chainId, we recommend only use SetBytesByChainId to new an account address.

func (*Address) SetBytesByType

func (a *Address) SetBytesByType(_bytes []byte, _type Address_Type) *Address

SetBytesByType return an Address defined by _bytes and _type.

func (*Address) SetDefaultAddress

func (a *Address) SetDefaultAddress(data []byte) *Address

SetDefaultAddress sets data to hexadecimal Address

func (*Address) SetStrAddress

func (a *Address) SetStrAddress(addrStr string) *Address

func (*Address) SetString

func (a *Address) SetString(addrStr string) *Address

func (*Address) SetStringByChainId

func (a *Address) SetStringByChainId(_addrStr string, _chainId uint64) *Address

SetStringByChainId is a helper func based on SetBytesByChainId.

func (*Address) Size

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

func (*Address) String

func (a *Address) String() string

func (*Address) Unmarshal

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

func (*Address) XXX_DiscardUnknown

func (m *Address) XXX_DiscardUnknown()

func (*Address) XXX_Marshal

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

func (*Address) XXX_Merge

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

func (*Address) XXX_Size

func (m *Address) XXX_Size() int

func (*Address) XXX_Unmarshal

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

type Address_Type

type Address_Type int32
const (
	Address_Hex     Address_Type = 0
	Address_String  Address_Type = 1
	Address_Bytes20 Address_Type = 2
	Address_Bytes8  Address_Type = 3
	Address_Bytes32 Address_Type = 4
)

func GetAddrTypeByChainId

func GetAddrTypeByChainId(chid uint64) Address_Type

func (Address_Type) EnumDescriptor

func (Address_Type) EnumDescriptor() ([]byte, []int)

func (Address_Type) String

func (x Address_Type) String() string

type ContractInfo

type ContractInfo struct {
	// chain_id defines the chain ID of the contract
	ChainId uint64 `protobuf:"varint,1,opt,name=chain_id,json=chainId,proto3" json:"chain_id,omitempty" yaml:"chain_id"`
	// address defines the address of the contract. Note for non-evm chains,
	// address format is different
	Address string `protobuf:"bytes,2,opt,name=address,proto3" json:"address,omitempty" yaml:"address"`
}

func (*ContractInfo) Descriptor

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

func (*ContractInfo) Equal

func (this *ContractInfo) Equal(that interface{}) bool

func (*ContractInfo) GetAddress

func (m *ContractInfo) GetAddress() string

func (*ContractInfo) GetChainId

func (m *ContractInfo) GetChainId() uint64

func (*ContractInfo) Marshal

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

func (*ContractInfo) MarshalTo

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

func (*ContractInfo) MarshalToSizedBuffer

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

func (*ContractInfo) ProtoMessage

func (*ContractInfo) ProtoMessage()

func (*ContractInfo) Reset

func (m *ContractInfo) Reset()

func (*ContractInfo) Size

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

func (*ContractInfo) String

func (m *ContractInfo) String() string

func (*ContractInfo) Unmarshal

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

func (*ContractInfo) XXX_DiscardUnknown

func (m *ContractInfo) XXX_DiscardUnknown()

func (*ContractInfo) XXX_Marshal

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

func (*ContractInfo) XXX_Merge

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

func (*ContractInfo) XXX_Size

func (m *ContractInfo) XXX_Size() int

func (*ContractInfo) XXX_Unmarshal

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

type ERC20Token

type ERC20Token struct {
	// chain_id defines the chain ID
	ChainId uint64 `protobuf:"varint,1,opt,name=chain_id,json=chainId,proto3" json:"chain_id,omitempty" yaml:"chain_id"`
	// symbol defines the ERC20 token symbol
	Symbol string `protobuf:"bytes,2,opt,name=symbol,proto3" json:"symbol,omitempty" yaml:"symbol"`
	// address defines the token contract address
	Address string `protobuf:"bytes,3,opt,name=address,proto3" json:"address,omitempty" yaml:"address"`
	// decimals defines the token decimals
	Decimals uint32 `protobuf:"varint,4,opt,name=decimals,proto3" json:"decimals,omitempty" yaml:"decimals"`
}

ERC20Token describes an ERC20 token on a specific EVM-compatible chain Or a similar fungible token on non-evm chains.

func (*ERC20Token) Descriptor

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

func (*ERC20Token) Equal

func (this *ERC20Token) Equal(that interface{}) bool

func (*ERC20Token) GetAddress

func (m *ERC20Token) GetAddress() string

func (*ERC20Token) GetChainId

func (m *ERC20Token) GetChainId() uint64

func (*ERC20Token) GetDecimals

func (m *ERC20Token) GetDecimals() uint32

func (*ERC20Token) GetSymbol

func (m *ERC20Token) GetSymbol() string

func (*ERC20Token) Marshal

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

func (*ERC20Token) MarshalTo

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

func (*ERC20Token) MarshalToSizedBuffer

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

func (*ERC20Token) ProtoMessage

func (*ERC20Token) ProtoMessage()

func (*ERC20Token) Reset

func (m *ERC20Token) Reset()

func (*ERC20Token) Size

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

func (*ERC20Token) String

func (m *ERC20Token) String() string

func (*ERC20Token) Unmarshal

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

func (*ERC20Token) XXX_DiscardUnknown

func (m *ERC20Token) XXX_DiscardUnknown()

func (*ERC20Token) XXX_Marshal

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

func (*ERC20Token) XXX_Merge

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

func (*ERC20Token) XXX_Size

func (m *ERC20Token) XXX_Size() int

func (*ERC20Token) XXX_Unmarshal

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

type EventLog

type EventLog struct {
	Address     *Address `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"`
	TxHash      []byte   `protobuf:"bytes,2,opt,name=tx_hash,json=txHash,proto3" json:"tx_hash,omitempty"`
	BlockNumber uint64   `protobuf:"varint,3,opt,name=block_number,json=blockNumber,proto3" json:"block_number,omitempty"`
	Index       uint32   `protobuf:"varint,4,opt,name=index,proto3" json:"index,omitempty"`
	Event       []byte   `protobuf:"bytes,5,opt,name=event,proto3" json:"event,omitempty"`
	Spare       []byte   `protobuf:"bytes,6,opt,name=spare,proto3" json:"spare,omitempty"`
}

EventLog describes a generic event log for all kinds of chain.

func (*EventLog) Descriptor

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

func (*EventLog) Equal

func (this *EventLog) Equal(that interface{}) bool

func (*EventLog) GetAddress

func (m *EventLog) GetAddress() *Address

func (*EventLog) GetBlockNumber

func (m *EventLog) GetBlockNumber() uint64

func (*EventLog) GetEvent

func (m *EventLog) GetEvent() []byte

func (*EventLog) GetIndex

func (m *EventLog) GetIndex() uint32

func (*EventLog) GetSpare

func (m *EventLog) GetSpare() []byte

func (*EventLog) GetTxHash

func (m *EventLog) GetTxHash() []byte

func (*EventLog) Marshal

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

func (*EventLog) MarshalTo

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

func (*EventLog) MarshalToSizedBuffer

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

func (*EventLog) ProtoMessage

func (*EventLog) ProtoMessage()

func (*EventLog) Reset

func (m *EventLog) Reset()

func (*EventLog) Size

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

func (*EventLog) String

func (evl *EventLog) String() string

func (*EventLog) Unmarshal

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

func (*EventLog) XXX_DiscardUnknown

func (m *EventLog) XXX_DiscardUnknown()

func (*EventLog) XXX_Marshal

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

func (*EventLog) XXX_Merge

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

func (*EventLog) XXX_Size

func (m *EventLog) XXX_Size() int

func (*EventLog) XXX_Unmarshal

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

type NonEvmChainID

type NonEvmChainID int32

to make sure no chain id conflict within sgn system there is no way to guarantee the chain id we choose here will NEVER be used by another real evm chain in the future. we just do our best choosing an unlikely range. also value should be smaller than max int32 corresponding value also needs to be coded in non-evm chain smart contracts

const (
	NonEvmChainID_UNDEFINED       NonEvmChainID = 0
	NonEvmChainID_FLOW_MAINNET    NonEvmChainID = 12340001
	NonEvmChainID_FLOW_TEST       NonEvmChainID = 12340002
	NonEvmChainID_FLOW_EMULATOR   NonEvmChainID = 12340003
	NonEvmChainID_SOLANA_MAINNET  NonEvmChainID = 12350001
	NonEvmChainID_SOLANA_TEST     NonEvmChainID = 12350002
	NonEvmChainID_SOLANA_EMULATOR NonEvmChainID = 12350003
	NonEvmChainID_APTOS_MAINNET   NonEvmChainID = 12360001
	NonEvmChainID_APTOS_TEST      NonEvmChainID = 12360002
	NonEvmChainID_APTOS_LOCAL     NonEvmChainID = 12360003
)

func (NonEvmChainID) EnumDescriptor

func (NonEvmChainID) EnumDescriptor() ([]byte, []int)

func (NonEvmChainID) String

func (x NonEvmChainID) String() string

type Signature

type Signature struct {
	// signer defines the Ethereum address of the signer.
	Signer string `protobuf:"bytes,1,opt,name=signer,proto3" json:"signer,omitempty" yaml:"signer"`
	// sig_bytes defines the signature bytes.
	SigBytes []byte `protobuf:"bytes,2,opt,name=sig_bytes,json=sigBytes,proto3" json:"sig_bytes,omitempty" yaml:"sig_bytes"`
}

Signature is the structure representing an Ethereum ECDSA signature.

func (*Signature) Descriptor

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

func (*Signature) Equal

func (this *Signature) Equal(that interface{}) bool

func (*Signature) GetSigBytes

func (m *Signature) GetSigBytes() []byte

func (*Signature) GetSigner

func (m *Signature) GetSigner() string

func (*Signature) Marshal

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

func (*Signature) MarshalTo

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

func (*Signature) MarshalToSizedBuffer

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

func (*Signature) ProtoMessage

func (*Signature) ProtoMessage()

func (*Signature) Reset

func (m *Signature) Reset()

func (*Signature) Size

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

func (*Signature) String

func (m *Signature) String() string

func (*Signature) Unmarshal

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

func (*Signature) XXX_DiscardUnknown

func (m *Signature) XXX_DiscardUnknown()

func (*Signature) XXX_Marshal

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

func (*Signature) XXX_Merge

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

func (*Signature) XXX_Size

func (m *Signature) XXX_Size() int

func (*Signature) XXX_Unmarshal

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

type Supplement

type Supplement struct {
	Type Supplement_Type `protobuf:"varint,1,opt,name=type,proto3,enum=sgn.common.v1.Supplement_Type" json:"type,omitempty"`
	Data []byte          `protobuf:"bytes,2,opt,name=data,proto3" json:"data,omitempty"`
}

Supplement describes a piece of supplementary data, which gonna be used to store arbitrary data.

func (*Supplement) Descriptor

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

func (*Supplement) Equal

func (this *Supplement) Equal(that interface{}) bool

func (*Supplement) GetData

func (m *Supplement) GetData() []byte

func (*Supplement) GetType

func (m *Supplement) GetType() Supplement_Type

func (*Supplement) Marshal

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

func (*Supplement) MarshalTo

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

func (*Supplement) MarshalToSizedBuffer

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

func (*Supplement) ProtoMessage

func (*Supplement) ProtoMessage()

func (*Supplement) Reset

func (m *Supplement) Reset()

func (*Supplement) Size

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

func (*Supplement) String

func (m *Supplement) String() string

func (*Supplement) Unmarshal

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

func (*Supplement) XXX_DiscardUnknown

func (m *Supplement) XXX_DiscardUnknown()

func (*Supplement) XXX_Marshal

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

func (*Supplement) XXX_Merge

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

func (*Supplement) XXX_Size

func (m *Supplement) XXX_Size() int

func (*Supplement) XXX_Unmarshal

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

type Supplement_Type

type Supplement_Type int32
const (
	Supplement_Address Supplement_Type = 0
)

func (Supplement_Type) EnumDescriptor

func (Supplement_Type) EnumDescriptor() ([]byte, []int)

func (Supplement_Type) String

func (x Supplement_Type) String() string

Jump to

Keyboard shortcuts

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