-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathISmartContract.go
128 lines (125 loc) · 4.5 KB
/
ISmartContract.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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
/*
*
* This file is part of go-palletone.
* go-palletone is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* go-palletone 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 General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with go-palletone. If not, see <http://www.gnu.org/licenses/>.
* /
*
* * @author PalletOne core developer <[email protected]>
* * @date 2018-2019
*
*/
package adaptor
//ISmartContract 智能合约的相关操作接口
type ISmartContract interface {
IUtility
//创建一个安装合约的交易,未签名
CreateContractInstallTx(input *CreateContractInstallTxInput) (*CreateContractInstallTxOutput, error)
//查询合约安装的结果的交易
GetContractInstallTx(input *GetContractInstallTxInput) (*GetContractInstallTxOutput, error)
//初始化合约实例
CreateContractInitialTx(input *CreateContractInitialTxInput) (*CreateContractInitialTxOutput, error)
//查询初始化合约实例的交易
GetContractInitialTx(input *GetContractInitialTxInput) (*GetContractInitialTxOutput, error)
//调用合约方法
CreateContractInvokeTx(input *CreateContractInvokeTxInput) (*CreateContractInvokeTxOutput, error)
//查询调用合约方法的交易
GetContractInvokeTx(input *GetContractInvokeTxInput) (*GetContractInvokeTxOutput, error)
//调用合约的查询方法
QueryContract(input *QueryContractInput) (*QueryContractOutput, error)
//销毁合约
// CreateContractDestroyTx(input *CreateContractDestroyTx) (tx []byte, err error)
// GetContractDestroyTxByTxId(txId []byte) (*ContractDestroyTx, error)
}
type CreateContractInstallTxInput struct {
Address string `json:"address"`
Fee *AmountAsset `json:"fee"`
Contract []byte `json:"contract"`
Extra []byte `json:"extra"`
}
type CreateContractInstallTxOutput struct {
RawTransaction []byte `json:"raw_transaction"`
Extra []byte `json:"extra"`
}
type CreateContractInitialTxInput struct {
Address string `json:"address"`
Fee *AmountAsset `json:"fee"`
Contract []byte `json:"contract"`
Args [][]byte `json:"args"`
Extra []byte `json:"extra"`
}
type CreateContractInitialTxOutput struct {
RawTransaction []byte `json:"raw_transaction"`
Extra []byte `json:"extra"`
}
type CreateContractInvokeTxInput struct {
//合约调用的发起方地址
Address string `json:"address"`
//调用合约时转了多少Token给合约
Amount *AmountAsset `json:"amount"`
//调用合约时支付的手续费
Fee *AmountAsset `json:"fee"`
//被调用的合约地址
ContractAddress string `json:"contract_address"`
//调用合约的函数名
Function string `json:"function"`
//调用合约时传入的参数
Args [][]byte `json:"args"`
Extra []byte `json:"extra"`
}
type CreateContractInvokeTxOutput struct {
RawTransaction []byte `json:"raw_transaction"`
Extra []byte `json:"extra"`
}
type QueryContractInput struct {
//合约查询的发起方
Address string `json:"address"`
////查询合约支付的手续费
//Fee *AmountAsset `json:"fee"`
//查询的合约地址
ContractAddress string `json:"contract_address"`
//合约的查询函数
Function string `json:"function"`
//查询参数
Args [][]byte `json:"args"`
Extra []byte `json:"extra"`
}
type QueryContractOutput struct {
QueryResult []byte `json:"query_result"`
Extra []byte `json:"extra"`
}
type GetContractInstallTxInput struct {
TxID []byte `json:"tx_id"`
Extra []byte `json:"extra"`
}
type GetContractInstallTxOutput struct {
TxBasicInfo
TemplateID []byte `json:"template_id"`
}
type GetContractInitialTxInput struct {
TxID []byte `json:"tx_id"`
Extra []byte `json:"extra"`
}
type GetContractInitialTxOutput struct {
TxBasicInfo
ContractAddress string `json:"contract_address"`
Extra []byte `json:"extra"`
}
type GetContractInvokeTxInput struct {
TxID []byte `json:"tx_id"`
Extra []byte `json:"extra"`
}
type GetContractInvokeTxOutput struct {
TxBasicInfo
UpdateStateSuccess bool `json:"update_state_success"` //读写集一致,成功更新StateDB
InvokeResult []byte `json:"invoke_result"`
Extra []byte `json:"extra"`
}