-
Notifications
You must be signed in to change notification settings - Fork 4
/
native_abi.go
76 lines (67 loc) · 2.35 KB
/
native_abi.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
/*
* Copyright (C) 2018 The ZeepinChain Authors
* This file is part of The ZeepinChain library.
*
* The ZeepinChain 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 ZeepinChain 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 ZeepinChain. If not, see <http://www.gnu.org/licenses/>.
*/
package abi
import "strings"
const (
NATIVE_PARAM_TYPE_BOOL = "bool"
NATIVE_PARAM_TYPE_BYTE = "byte"
NATIVE_PARAM_TYPE_INTEGER = "int"
NATIVE_PARAM_TYPE_STRING = "string"
NATIVE_PARAM_TYPE_BYTEARRAY = "bytearray"
NATIVE_PARAM_TYPE_ARRAY = "array"
NATIVE_PARAM_TYPE_ADDRESS = "address"
NATIVE_PARAM_TYPE_UINT256 = "uint256"
NATIVE_PARAM_TYPE_STRUCT = "struct"
)
type NativeContractAbi struct {
Address string `json:"hash"`
Functions []*NativeContractFunctionAbi `json:"functions"`
Events []*NativeContractEventAbi `json:"events"`
}
type NativeContractFunctionAbi struct {
Name string `json:"name"`
Parameters []*NativeContractParamAbi `json:"parameters"`
ReturnType string `json:"returnType"`
}
type NativeContractParamAbi struct {
Name string `json:"name"`
Type string `json:"type"`
SubType []*NativeContractParamAbi `json:"subType"`
}
type NativeContractEventAbi struct {
Name string `json:"name"`
Parameters []*NativeContractParamAbi `json:"parameters"`
}
func (this *NativeContractAbi) GetFunc(name string) *NativeContractFunctionAbi {
name = strings.ToLower(name)
for _, funcAbi := range this.Functions {
if strings.ToLower(funcAbi.Name) == name {
return funcAbi
}
}
return nil
}
func (this *NativeContractAbi) GetEvent(name string) *NativeContractEventAbi {
name = strings.ToLower(name)
for _, evtAbi := range this.Events {
if strings.ToLower(evtAbi.Name) == name {
return evtAbi
}
}
return nil
}