Documentation ¶
Index ¶
- Variables
- func CalcContractAddress(name string, version string, owner types.Address) types.Address
- func CalcMethodID(protoType string) int64
- func CheckOrgID(addr string) error
- func CheckVersions(firstContractPath string, res *Result) types.Error
- func CreatePrototype(item Method) string
- func ErrorTransfer(err0 error, err *types.Error)
- func ExpandMapFieldKey(f Field, index int) string
- func ExpandMapFieldKeyToKey(f Field, index int) string
- func ExpandMapFieldVal(f Field) string
- func ExpandMapFieldValNoStar(f Field) string
- func ExpandMethodPrototype(f Function) string
- func ExpandNames(t Field) string
- func ExpandStruct(s ast.GenDecl) string
- func ExpandType(t Field) string
- func ExpandTypeNoStar(t Field) string
- func FilterImports(importPath string) bool
- func FmtAndWrite(filename, content string) error
- func GetContractAddress(name string, version string) types.Address
- func GetGas(comment string) string
- func HaveUserDefinedStruct(method Method) bool
- func LowerFirst(word string) string
- func ParamsLen(item Method) int
- func UpperFirst(word string) string
- type CallNode
- type Callee
- type Field
- type Function
- type Import
- type ImportContract
- type Method
- type Report
- type Result
Constants ¶
This section is empty.
Variables ¶
var LiteralTypes = map[string]struct{}{
"int": {},
"int8": {},
"int16": {},
"int32": {},
"int64": {},
"uint": {},
"uint8": {},
"uint16": {},
"uint32": {},
"uint64": {},
"float32": {},
"float64": {},
"bool": {},
"string": {},
"byte": {},
"Address": {},
"Hash": {},
"HexBytes": {},
"PubKey": {},
}
LiteralTypes - primitive type
var NumberType = "Number"
var WhiteListPKG = map[string]struct{}{
"\"bytes\"": {},
"\"container/heap\"": {},
"\"container/list\"": {},
"\"container/ring\"": {},
"\"crypto\"": {},
"\"crypto/aes\"": {},
"\"crypto/cipher\"": {},
"\"crypto/des\"": {},
"\"crypto/dsa\"": {},
"\"crypto/ecdsa\"": {},
"\"crypto/elliptic\"": {},
"\"crypto/hmac\"": {},
"\"crypto/md5\"": {},
"\"crypto/rc4\"": {},
"\"crypto/rsa\"": {},
"\"crypto/sha1\"": {},
"\"crypto/sha256\"": {},
"\"crypto/sha512\"": {},
"\"encoding\"": {},
"\"encoding/ascii85\"": {},
"\"encoding/asn1\"": {},
"\"encoding/base32\"": {},
"\"encoding/base64\"": {},
"\"encoding/binary\"": {},
"\"encoding/csv\"": {},
"\"encoding/gob\"": {},
"\"encoding/hex\"": {},
"\"encoding/json\"": {},
"\"encoding/pem\"": {},
"\"encoding/xml\"": {},
"\"errors\"": {},
"\"fmt\"": {},
"\"hash\"": {},
"\"hash/adler32\"": {},
"\"hash/crc32\"": {},
"\"hash/crc64\"": {},
"\"hash/fnv\"": {},
"\"index/suffixarray\"": {},
"\"math\"": {},
"\"math/big\"": {},
"\"math/bits\"": {},
"\"math/cmplx\"": {},
"\"reflect\"": {},
"\"regexp\"": {},
"\"regexp/syntax\"": {},
"\"sort\"": {},
"\"strconv\"": {},
"\"strings\"": {},
"\"unicode\"": {},
"\"unicode/utf8\"": {},
"\"unicode/utf16\"": {},
}
WhiteListPKG - these packages can be imported
var WhiteListPkgPrefix = []string{
"\"blockchain/smcsdk/sdk",
"\"github.com/bcbchain/sdk/sdk",
}
WhiteListPkgPrefix - packages start with these paths are all allowed
Functions ¶
func CalcContractAddress ¶
nolint unhandled CalcContractAddress calculate contract address from name、version and owner
func CalcMethodID ¶
CalcMethodID - calculate method id with method prototype
func CheckOrgID ¶
nolint unhandled CheckAddress check address and return result
func CheckVersions ¶
Versions - 返回合约版本列表
func CreatePrototype ¶
CreatePrototype - create method prototype
func ErrorTransfer ¶
ErrorTransfer - transform common err to types.Error
func ExpandMapFieldKey ¶
ExpandMapFieldKey - write map field key type to string
func ExpandMapFieldKeyToKey ¶
ExpandMapFieldKeyToKey - write map field key make to string as access key
func ExpandMapFieldVal ¶
ExpandMapFieldVal - write map field val type to string
func ExpandMapFieldValNoStar ¶
ExpandMapFieldValNoStar - write map field val type to string but not star, ...
func ExpandNames ¶
ExpandNames - write field names to string nolint unhandled ..
func ExpandStruct ¶
ExpandStruct - actually expand GenDecl nolint unhandled ..
func ExpandType ¶
ExpandType - write field type to string nolint unhandled ..
func ExpandTypeNoStar ¶
ExpandTypeNoStar - write field type to string without star, ...
func FmtAndWrite ¶
FmtAndWrite - go fmt content and write to filename
func GetContractAddress ¶
GetContractAddress get contract address from name、version and owner
func HaveUserDefinedStruct ¶
Types ¶
type Field ¶
type Field struct { Names []string // names have 0 to n member(s) FieldType ast.Expr RelatedImport map[Import]struct{} // the field type imported package }
Field - describe the Field of go ast
func FieldsExpand ¶
FieldsExpand - expand a multi name field to multi single name field
type Function ¶
type Function struct { Method Comments string Receiver Field // go Function's receiver is an array, but I doubt how it works. MGas int64 IGas int64 TGas int64 GetTransferToMe bool // contains filtered or unexported fields }
Function - describe the function in go ast
type Result ¶
type Result struct { DirectionName string PackageName string Imports map[Import]struct{} // current file parsed, AllImports map[Import]struct{} // imports of all files, see function importsCollector ContractName string OrgID string Version string Versions []string Author string ContractStructure string Stores []Field StoreCaches []Field InitChain Function IsExistInitChain bool UpdateChain Function IsExistUpdateChain bool Mine Function IsExistMine bool Functions []Function // all function MFunctions []Function // methods IFunctions []Function // interfaces TFunctions []Function // ibcs Receipts []Method ImportContracts []ImportContract UserStruct map[string]ast.GenDecl ErrFlag bool ErrorDesc []string ErrorPos []token.Pos }
Result is the parse result