common

package
v1.14.4 Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2022 License: LGPL-3.0 Imports: 25 Imported by: 51

Documentation

Overview

Package common privides functions for http handler call

  • Copyright (C) 2018 The ontology Authors
  • This file is part of The ontology library. *
  • The ontology is free software: you can redistribute it and/or modify
  • it under the terms of the GNU Lesser General Public License as published by
  • the Free Software Foundation, either version 3 of the License, or
  • (at your option) any later version. *
  • The ontology is distributed in the hope that it will be useful,
  • but WITHOUT ANY WARRANTY; without even the implied warranty of
  • MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  • GNU Lesser General Public License for more details. *
  • You should have received a copy of the GNU Lesser General Public License
  • along with The ontology. If not, see <http://www.gnu.org/licenses/>.

Index

Constants

View Source
const MAX_REQUEST_BODY_SIZE = 1 << 20
View Source
const MAX_SEARCH_HEIGHT uint32 = 100

Variables

This section is empty.

Functions

func BuildNeoVMInvokeCode

func BuildNeoVMInvokeCode(smartContractAddress common.Address, params []interface{}) ([]byte, error)

BuildNeoVMInvokeCode build NeoVM Invoke code for params

func GetAddress added in v1.0.3

func GetAddress(str string) (common.Address, error)

func GetAllowance

func GetAllowance(asset string, from, to common.Address) (string, error)

func GetAllowanceV2 added in v1.14.1

func GetAllowanceV2(asset string, from, to common.Address) (string, error)

func GetBlockTransactions

func GetBlockTransactions(block *types.Block) interface{}

func GetContractAllowance

func GetContractAllowance(cVersion byte, contractAddr, fromAddr, toAddr common.Address) (uint64, error)

func GetContractAllowanceV2 added in v1.14.1

func GetContractAllowanceV2(cVersion byte, contractAddr, fromAddr, toAddr common.Address) (string, error)

func GetGasPrice

func GetGasPrice() (gasPrice uint64, height uint32, err error)

func GetGrantOng added in v1.0.3

func GetGrantOng(addr common.Address) (string, error)

func GetNativeTokenBalance added in v1.14.1

func GetNativeTokenBalance(cVersion byte, contractAddres []common.Address, accAddr common.Address, atomic bool) (
	[]states.NativeTokenBalance, uint32, error)

func GetOep4ContractBalance added in v1.14.1

func GetOep4ContractBalance(contractAddr common.Address, accAddr []common.Address, atomic bool) ([]string, uint32, error)

func NewNativeInvokeTransaction

func NewNativeInvokeTransaction(gasPirce, gasLimit uint64, contractAddress common.Address, version byte,
	method string, params []interface{}) (*types.MutableTransaction, error)

NewNativeInvokeTransaction return native contract invoke transaction

func NewNeovmInvokeTransaction

func NewNeovmInvokeTransaction(gasPrice, gasLimit uint64, contractAddress common.Address, params []interface{}) (*types.MutableTransaction, error)

func NewSmartContractTransaction

func NewSmartContractTransaction(gasPrice, gasLimit uint64, invokeCode []byte) (*types.MutableTransaction, error)

func SendTxToPool added in v1.0.1

func SendTxToPool(txn *types.Transaction) (ontErrors.ErrCode, string)

func TransferCrossChainMsg added in v1.9.0

func TransferCrossChainMsg(msg *types.CrossChainMsg, pks []keypair.PublicKey) string

Types

type AmountMap

type AmountMap struct {
	Key   common.Uint256
	Value common.Fixed64
}

type BalanceOfRsp

type BalanceOfRsp struct {
	Ont    string `json:"ont"`
	Ong    string `json:"ong"`
	Height string `json:"height"`
}

func GetBalance

func GetBalance(address common.Address) (*BalanceOfRsp, error)

func GetBalanceV2 added in v1.14.1

func GetBalanceV2(address common.Address) (*BalanceOfRsp, error)

type BlockHead

type BlockHead struct {
	Version          uint32
	PrevBlockHash    string
	TransactionsRoot string
	BlockRoot        string
	Timestamp        uint32
	Height           uint32
	ConsensusData    uint64
	ConsensusPayload string
	NextBookkeeper   string

	Bookkeepers []string
	SigData     []string

	Hash string
}

type BlockInfo

type BlockInfo struct {
	Hash         string
	Size         int
	Header       *BlockHead
	Transactions []*Transactions
}

func GetBlockInfo

func GetBlockInfo(block *types.Block) BlockInfo

type BookkeeperInfo

type BookkeeperInfo struct {
	PubKey     string
	Action     string
	Issuer     string
	Controller string
}

type ConsensusInfo

type ConsensusInfo struct {
}

type CrossStatesLeafHashes added in v1.14.4

type CrossStatesLeafHashes struct {
	Height uint32
	Hashes []string
}

type CrossStatesProof added in v1.9.0

type CrossStatesProof struct {
	Type      string
	AuditPath string
}

type DeployCodeInfo

type DeployCodeInfo struct {
	Code        string
	VmType      byte
	Name        string
	CodeVersion string
	Author      string
	Email       string
	Description string
}

type ExecuteNotify

type ExecuteNotify struct {
	TxHash      string
	State       byte
	GasConsumed uint64
	Notify      []NotifyEventInfo

	GasStepUsed     uint64
	TxIndex         uint32
	CreatedContract string
}

func GetExecuteNotify

func GetExecuteNotify(obj *event.ExecuteNotify) (map[string]bool, ExecuteNotify)

type Fee

type Fee struct {
	Amount common.Fixed64
	Payer  string
}

type InvokeCodeInfo

type InvokeCodeInfo struct {
	Code string
}

type LogEventArgs

type LogEventArgs struct {
	TxHash          string
	ContractAddress string
	Message         string
}

func GetLogEvent

func GetLogEvent(obj *event.LogEventArgs) (map[string]bool, LogEventArgs)

type MerkleProof

type MerkleProof struct {
	Type             string
	TransactionsRoot string
	BlockHeight      uint32
	CurBlockRoot     string
	CurBlockHeight   uint32
	TargetHashes     []string
}

type NodeInfo

type NodeInfo struct {
	NodePort    uint16         // The nodes's port
	ID          common2.PeerId // The nodes's id
	NodeTime    int64
	NodeVersion uint32   // The network protocol the node used
	NodeType    uint64   // The services the node supplied
	Relay       bool     // The relay capability of the node (merge into capbility flag)
	Height      uint32   // The node latest block height
	TxnCnt      []uint32 // The transactions in pool

}

type NotifyEventInfo

type NotifyEventInfo struct {
	ContractAddress string
	States          interface{}
	IsEvm           bool
}

type Oep4Balance added in v1.14.1

type Oep4Balance struct {
	Addr    string `json:"addr"`
	Balance string `json:"balance"`
}

type Oep4BalanceOfRsp added in v1.14.1

type Oep4BalanceOfRsp struct {
	Oep4   []Oep4Balance `json:"oep4"`
	Height string        `json:"height"`
}

func GetOep4Balance added in v1.14.1

func GetOep4Balance(contractAddress common.Address, addrs []common.Address) (*Oep4BalanceOfRsp, error)

type PayloadInfo

type PayloadInfo interface{}

func TransPayloadToHex

func TransPayloadToHex(p types.Payload) PayloadInfo

get tranasction payload data

type PreExecuteResult added in v1.6.0

type PreExecuteResult struct {
	State  byte
	Gas    uint64
	Result interface{}
	Notify []NotifyEventInfo
}

func ConvertPreExecuteResult added in v1.6.0

func ConvertPreExecuteResult(obj *cstate.PreExecResult) PreExecuteResult

type Sig

type Sig struct {
	PubKeys []string
	M       uint16
	SigData []string
}

type SyncStatus added in v1.8.1

type SyncStatus struct {
	CurrentBlockHeight uint32
	ConnectCount       uint32
	MaxPeerBlockHeight uint64
}

func GetSyncStatus added in v1.8.1

func GetSyncStatus() (SyncStatus, error)

type TXNAttrInfo

type TXNAttrInfo struct {
	Height  uint32
	Type    int
	ErrCode int
}

type TXNEntryInfo

type TXNEntryInfo struct {
	State []TXNAttrInfo // the result from each validator
}

type Transactions

type Transactions struct {
	Version    byte
	Nonce      uint32
	GasPrice   uint64
	GasLimit   uint64
	Payer      string
	TxType     types.TransactionType
	Payload    PayloadInfo
	Attributes []TxAttributeInfo
	Sigs       []Sig
	Hash       string
	Height     uint32
}

func TransArryByteToHexString

func TransArryByteToHexString(ptx *types.Transaction) *Transactions

type TxAttributeInfo

type TxAttributeInfo struct {
	Usage types.TransactionAttributeUsage
	Data  string
}

Jump to

Keyboard shortcuts

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