contract

package
v1.6.3 Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2023 License: GPL-3.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TableName = "contract"
	KeyPrefix = TableName + "-"
)
View Source
const (
	MethodChain33Version = "Chain33.Version"
	MethodChain33Query   = "Chain33.Query"
	Default20Abi         = "" /* 3775-byte string literal not displayed */
	Default721Abi        = "" /* 4654-byte string literal not displayed */
	Default1155Abi       = "" /* 4411-byte string literal not displayed */
	ERC20                = "ERC20"
	ERC721               = "ERC721"
	ERC1155              = "ERC1155"
	ExecEVM              = "evm"
	FuncNameEstimateGas  = "EstimateGas"
	FuncNameQuery        = "Query"
)
View Source
const Mapping = `` /* 970-byte string literal not displayed */

Mapping 合约验证表

Variables

View Source
var DefaultABIs map[string]*pabi.ABI

Functions

func AddKeyPrefix

func AddKeyPrefix(hash string) string

AddKeyPrefix 添加索引前缀

func GetDefaultValue

func GetDefaultValue(method pabi.Method, t *pabi.Type, defaultAddr string) interface{}

func InitDetector

func InitDetector(cfg *proto.ConfigNew)

func InitESDB

func InitESDB(cli db.DBCreator) error

InitESDB 创建db (插件满足接口 db.ExecConvert)

Types

type Contract

type Contract struct {
	Address           string                         `json:"contract_address"`
	Creator           string                         `json:"creator"`
	DeployBlockHash   string                         `json:"deploy_block_hash"`
	DeployBlockTime   int64                          `json:"deploy_block_time"`
	DeployHeight      int64                          `json:"deploy_height"`
	DeployHeightIndex int64                          `json:"deploy_height_index"`
	DeployTxHash      string                         `json:"deploy_tx_hash"`    // 部署的交易hash
	ContractBinHash   string                         `json:"contract_bin_hash"` // bin文件直接sha256处理
	ContractBin       string                         `json:"contract_bin"`
	ContractAbi       string                         `json:"contract_abi"`
	ContractType      string                         `json:"contract_type"`
	TxCount           int64                          `json:"tx_count"`
	PublishCount      int64                          `json:"publish_count"`
	ParsedAbi         *pabi.ABI                      `json:"-"`
	ParsedAbiErr      error                          `json:"-"`
	ContractVerify    *contractverify.ContractVerify `json:"-"`
	Name              string                         `json:"name"`
	Symbol            string                         `json:"symbol"`
	URI               string                         `json:"uri"`
}

func NewContractByMap

func NewContractByMap(data map[string]interface{}) *Contract

func (*Contract) GetContractBinHash

func (c *Contract) GetContractBinHash() string

func (*Contract) Key

func (c *Contract) Key() string

func (*Contract) SetContractBinHash

func (c *Contract) SetContractBinHash(bin string)

type DB

type DB interface {
	Get(hash string) (*Contract, error)
	Set(r *Record) error
	GetABI(addr string) (*pabi.ABI, error)
	GetContract(addr string) (*Contract, error)
	UpdateCache(contract *Contract)
}

DB operate FilePart

func NewEsDB

func NewEsDB(client db.WrapDB) DB

NewEsDB new es DB

type DetectClient

type DetectClient struct {
	// contains filtered or unexported fields
}
var Detector *DetectClient

func NewDetectClient

func NewDetectClient(host, paraName string) *DetectClient

func (*DetectClient) ContractCall

func (c *DetectClient) ContractCall(contract *Contract, contractABI *pabi.ABI, method string, args ...interface{}) (map[string]interface{}, error)

func (*DetectClient) CreateCallTx

func (c *DetectClient) CreateCallTx(contractAddr string, data []byte) string

func (*DetectClient) Detect

func (c *DetectClient) Detect(contract *Contract)

func (*DetectClient) GetChainID

func (c *DetectClient) GetChainID() int32

func (*DetectClient) GetContractName

func (c *DetectClient) GetContractName(contractABI *pabi.ABI, contract *Contract)

func (*DetectClient) GetContractSymbol

func (c *DetectClient) GetContractSymbol(contractABI *pabi.ABI, contract *Contract)

func (*DetectClient) GetContractURI

func (c *DetectClient) GetContractURI(contractABI *pabi.ABI, contract *Contract)

type EstimateGasReq

type EstimateGasReq struct {
	Tx   string `json:"tx"`   // 部署合约交易或者调用合约交易的序列化后的字符串
	From string `json:"from"` // 合约交易调用者地址
}

EstimateGasReq 估算部署交易或者调用交易需要的 gas 请求

type EstimateGasResp

type EstimateGasResp struct {
	Gas string `json:"gas"` // 估算需要的 gas 数值
}

EstimateGasResp 估算部署交易或者调用交易需要的 gas 响应

type Record

type Record struct {
	*db.IKey
	*db.Op
	// contains filtered or unexported fields
}

Record es record

func NewRecord

func NewRecord(op int, value *Contract) *Record

NewRecord new RecordFilePart

func (*Record) Source

func (r *Record) Source() interface{}

func (*Record) Value

func (r *Record) Value() []byte

Value value

Jump to

Keyboard shortcuts

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