lib

package
v1.1.3 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (

	/**
	 * [0x80]
	 * If a string is 0-55 bytes long, the RLP encoding consists of a single
	 * byte with value 0x80 plus the length of the string followed by the
	 * string. The range of the first byte is thus [0x80, 0xb7].
	 */
	OFFSET_SHORT_STRING = 0x80

	/**
	 * [0xb7]
	 * If a string is more than 55 bytes long, the RLP encoding consists of a
	 * single byte with value 0xb7 plus the length of the length of the string
	 * in binary form, followed by the length of the string, followed by the
	 * string. For example, a length-1024 string would be encoded as
	 * \xb9\x04\x00 followed by the string. The range of the first byte is thus
	 * [0xb8, 0xbf].
	 */
	OFFSET_LONG_STRING = 0xb7

	/**
	 * [0xc0]
	 * If the total payload of a list (i.e. the combined length of all its
	 * items) is 0-55 bytes long, the RLP encoding consists of a single byte
	 * with value 0xc0 plus the length of the list followed by the concatenation
	 * of the RLP encodings of the items. The range of the first byte is thus
	 * [0xc0, 0xf7].
	 */
	OFFSET_SHORT_LIST = 0xc0

	/**
	 * [0xf7]
	 * If the total payload of a list is more than 55 bytes long, the RLP
	 * encoding consists of a single byte with value 0xf7 plus the length of the
	 * length of the list in binary form, followed by the length of the list,
	 * followed by the concatenation of the RLP encodings of the items. The
	 * range of the first byte is thus [0xf8, 0xff].
	 */
	OFFSET_LONG_LIST = 0xf7
)
View Source
const (
	BASE_DEFAULT_GAS_LIMIT  = uint64(21000)
	BASE_NON_ZERO_GAS_LIMIT = uint64(68)
	BASE_ZERO_GAS_LIMIT     = uint64(4)
)
View Source
const MainFanAccount = "0xf35894c6b663e1E0934812c81CF4984898D5d8d2"
View Source
const PrivateKey = "f77192cea69effdf050308a18f16dc0213d061d553363adbbb3219381186e5a9"

Variables

View Source
var (
	DefaultMainNetConfig = Config{core.RpcUrl, big.NewInt(configs.ChainId)}
	DposMainNetParams    = &DposNetworkParameters{
		DefaultMainNetConfig,
		vm.StakingContractAddr.String(),
	}
)
View Source
var KeyCredentials, _ = NewCredential(PrivateKey)

Functions

func EncodeBytes

func EncodeBytes(bs []byte, offset byte) []byte

func GetGasLimit

func GetGasLimit(f *Function) uint64

func IsLocalSupportFunction

func IsLocalSupportFunction(ftype FunctionType) bool

func MinimalByteArray

func MinimalByteArray(value int) []byte

func ToByteArray

func ToByteArray(value int) []byte

Types

type BytesSlice

type BytesSlice []byte

func EncodeBytesSlice

func EncodeBytesSlice(list []BytesSlice) BytesSlice

type CallResponse

type CallResponse struct {
	Code uint64          `json:"Code"`
	Ret  json.RawMessage `json:"Ret"`
}

type Config

type Config struct {
	Url     string
	ChainId *big.Int
}

type Credentials

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

func NewCredential

func NewCredential(hexPrivateKeyStr string) (*Credentials, error)

func (*Credentials) Address

func (c *Credentials) Address() common.Address

func (*Credentials) MustStringToAddress

func (c *Credentials) MustStringToAddress(addr string) common.Address

func (*Credentials) PrivateKey

func (c *Credentials) PrivateKey() *ecdsa.PrivateKey

func (*Credentials) SignTx

func (c *Credentials) SignTx(tx *types.Transaction, chainID *big.Int) (*types.Transaction, error)

type DposNetworkParameters

type DposNetworkParameters struct {
	Config
	StakingContract string
}

type Function

type Function struct {
	Type        FunctionType
	InputParams []interface{}
}

func NewFunction

func NewFunction(typ FunctionType, params []interface{}) *Function

func (*Function) ToBytes

func (f *Function) ToBytes() []byte

type FunctionExecutor

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

func (*FunctionExecutor) SendWithRaw

func (fe *FunctionExecutor) SendWithRaw(f *Function) (string, error)

func (*FunctionExecutor) SendWithResult

func (fe *FunctionExecutor) SendWithResult(f *Function, result *string) error

type FunctionType

type FunctionType int
const (
	STAKING_FUNC_TYPE             FunctionType = 1000
	UPDATE_STAKING_INFO_FUNC_TYPE FunctionType = 1001
	ADD_STAKING_FUNC_TYPE         FunctionType = 1002
	WITHDREW_STAKING_FUNC_TYPE    FunctionType = 1003
)

func (FunctionType) GetType

func (ft FunctionType) GetType() int

type HexStringParam

type HexStringParam struct {
	HexStringValue string
}

func (HexStringParam) GetEncodeData

func (hsp HexStringParam) GetEncodeData() BytesSlice

type NodeId

type NodeId struct {
	HexStringId string
}

func (NodeId) GetEncodeData

func (ni NodeId) GetEncodeData() BytesSlice

type ParamEncoder

type ParamEncoder interface {
	GetEncodeData() BytesSlice
}

type ProgramVersion

type ProgramVersion struct {
	Version *big.Int `json:"Version"`
	Sign    string   `json:"Sign"`
}

type RlpEncoder

type RlpEncoder struct{}

func (RlpEncoder) Encode

func (re RlpEncoder) Encode(intf interface{}) []byte

type RlpList

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

func (*RlpList) Append

func (rl *RlpList) Append(args ...interface{})

func (*RlpList) GetValues

func (rl *RlpList) GetValues() []interface{}

type RlpString

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

func RlpStringFromBig

func RlpStringFromBig(v *big.Int) RlpString

func (*RlpString) FromBig

func (rs *RlpString) FromBig(v *big.Int)

func (*RlpString) GetBytes

func (rs *RlpString) GetBytes() []byte

type StakingAmountType

type StakingAmountType uint16
const (
	FREE_AMOUNT_TYPE        StakingAmountType = 0
	RESTRICTING_AMOUNT_TYPE StakingAmountType = 1
)

func (StakingAmountType) GetValue

func (sat StakingAmountType) GetValue() uint16

type StakingContract

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

func NewStakingContract

func NewStakingContract(dposConfig *DposNetworkParameters, credentials *Credentials) *StakingContract

func (*StakingContract) Staking

func (sc *StakingContract) Staking(stakingParam StakingParam) (string, error)

type StakingParam

type StakingParam struct {
	NodeId            string
	Amount            *big.Int
	StakingAmountType StakingAmountType
	BenefitAddress    string
	ExternalId        string
	NodeName          string
	WebSite           string
	Details           string
	ProcessVersion    ProgramVersion
	BlsPubKey         string
	BlsProof          string
	RewardPer         *big.Int
}

func (StakingParam) SubmitInputParameters

func (sp StakingParam) SubmitInputParameters() []interface{}

type TransactionHash

type TransactionHash string

type TransactionReceipt

type TransactionReceipt types.Receipt

type UInt16

type UInt16 struct {
	ValueInner uint16
}

func (UInt16) GetEncodeData

func (u16 UInt16) GetEncodeData() BytesSlice

type UInt256

type UInt256 struct {
	ValueInner *big.Int
}

func (UInt256) GetEncodeData

func (u256 UInt256) GetEncodeData() BytesSlice

type UInt32

type UInt32 struct {
	ValueInner *big.Int
}

func (UInt32) GetEncodeData

func (u32 UInt32) GetEncodeData() BytesSlice

type UInt64

type UInt64 struct {
	ValueInner *big.Int
}

func (UInt64) GetEncodeData

func (u64 UInt64) GetEncodeData() BytesSlice

type Utf8String

type Utf8String struct {
	ValueInner string
}

func (Utf8String) GetEncodeData

func (u8str Utf8String) GetEncodeData() BytesSlice

Jump to

Keyboard shortcuts

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