This repository has been archived by the owner on Jul 5, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
abi_example_test.go
270 lines (231 loc) · 12.2 KB
/
abi_example_test.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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
// Code generated - DO NOT EDIT.
// This file is a generated binding and any manual changes will be lost.
package rockside_test
import (
"math/big"
"strings"
ethereum "github.com/ethereum/go-ethereum"
"github.com/ethereum/go-ethereum/accounts/abi"
"github.com/ethereum/go-ethereum/accounts/abi/bind"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/event"
)
// Reference imports to suppress errors if they are not otherwise used.
var (
_ = big.NewInt
_ = strings.NewReader
_ = ethereum.NotFound
_ = abi.U256
_ = bind.Bind
_ = common.Big1
_ = types.BloomLookup
_ = event.NewSubscription
)
// ContractABI is the input ABI used to generate the binding from.
const ContractABI = "[{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"name\":\"data\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"s\",\"type\":\"bytes32\"}],\"name\":\"read\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"s\",\"type\":\"bytes32\"}],\"name\":\"write\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]"
// ContractFuncSigs maps the 4-byte function signature to its string representation.
var ContractFuncSigs = map[string]string{
"0147fb0c": "data(bytes32)",
"61da1439": "read(bytes32)",
"e020def2": "write(bytes32)",
}
// ContractBin is the compiled bytecode used for deploying new contracts.
var ContractBin = "0x608060405234801561001057600080fd5b50610110806100206000396000f3fe6080604052348015600f57600080fd5b5060043610603c5760003560e01c80630147fb0c14604157806361da143914606d578063e020def2146087575b600080fd5b605b60048036036020811015605557600080fd5b503560a3565b60408051918252519081900360200190f35b605b60048036036020811015608157600080fd5b503560b5565b60a160048036036020811015609b57600080fd5b503560c7565b005b60006020819052908152604090205481565b60009081526020819052604090205490565b600090815260208190526040902042905556fea2646970667358221220612007f316b38b7b85f971a85a31910ce6a3ef8a4cfdef7c0cfec3269077425c64736f6c63430006010033"
// DeployContract deploys a new Ethereum contract, binding an instance of Contract to it.
func DeployContract(auth *bind.TransactOpts, backend bind.ContractBackend) (common.Address, *types.Transaction, *Contract, error) {
parsed, err := abi.JSON(strings.NewReader(ContractABI))
if err != nil {
return common.Address{}, nil, nil, err
}
address, tx, contract, err := bind.DeployContract(auth, parsed, common.FromHex(ContractBin), backend)
if err != nil {
return common.Address{}, nil, nil, err
}
return address, tx, &Contract{ContractCaller: ContractCaller{contract: contract}, ContractTransactor: ContractTransactor{contract: contract}, ContractFilterer: ContractFilterer{contract: contract}}, nil
}
// Contract is an auto generated Go binding around an Ethereum contract.
type Contract struct {
ContractCaller // Read-only binding to the contract
ContractTransactor // Write-only binding to the contract
ContractFilterer // Log filterer for contract events
}
// ContractCaller is an auto generated read-only Go binding around an Ethereum contract.
type ContractCaller struct {
contract *bind.BoundContract // Generic contract wrapper for the low level calls
}
// ContractTransactor is an auto generated write-only Go binding around an Ethereum contract.
type ContractTransactor struct {
contract *bind.BoundContract // Generic contract wrapper for the low level calls
}
// ContractFilterer is an auto generated log filtering Go binding around an Ethereum contract events.
type ContractFilterer struct {
contract *bind.BoundContract // Generic contract wrapper for the low level calls
}
// ContractSession is an auto generated Go binding around an Ethereum contract,
// with pre-set call and transact options.
type ContractSession struct {
Contract *Contract // Generic contract binding to set the session for
CallOpts bind.CallOpts // Call options to use throughout this session
TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session
}
// ContractCallerSession is an auto generated read-only Go binding around an Ethereum contract,
// with pre-set call options.
type ContractCallerSession struct {
Contract *ContractCaller // Generic contract caller binding to set the session for
CallOpts bind.CallOpts // Call options to use throughout this session
}
// ContractTransactorSession is an auto generated write-only Go binding around an Ethereum contract,
// with pre-set transact options.
type ContractTransactorSession struct {
Contract *ContractTransactor // Generic contract transactor binding to set the session for
TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session
}
// ContractRaw is an auto generated low-level Go binding around an Ethereum contract.
type ContractRaw struct {
Contract *Contract // Generic contract binding to access the raw methods on
}
// ContractCallerRaw is an auto generated low-level read-only Go binding around an Ethereum contract.
type ContractCallerRaw struct {
Contract *ContractCaller // Generic read-only contract binding to access the raw methods on
}
// ContractTransactorRaw is an auto generated low-level write-only Go binding around an Ethereum contract.
type ContractTransactorRaw struct {
Contract *ContractTransactor // Generic write-only contract binding to access the raw methods on
}
// NewContract creates a new instance of Contract, bound to a specific deployed contract.
func NewContract(address common.Address, backend bind.ContractBackend) (*Contract, error) {
contract, err := bindContract(address, backend, backend, backend)
if err != nil {
return nil, err
}
return &Contract{ContractCaller: ContractCaller{contract: contract}, ContractTransactor: ContractTransactor{contract: contract}, ContractFilterer: ContractFilterer{contract: contract}}, nil
}
// NewContractCaller creates a new read-only instance of Contract, bound to a specific deployed contract.
func NewContractCaller(address common.Address, caller bind.ContractCaller) (*ContractCaller, error) {
contract, err := bindContract(address, caller, nil, nil)
if err != nil {
return nil, err
}
return &ContractCaller{contract: contract}, nil
}
// NewContractTransactor creates a new write-only instance of Contract, bound to a specific deployed contract.
func NewContractTransactor(address common.Address, transactor bind.ContractTransactor) (*ContractTransactor, error) {
contract, err := bindContract(address, nil, transactor, nil)
if err != nil {
return nil, err
}
return &ContractTransactor{contract: contract}, nil
}
// NewContractFilterer creates a new log filterer instance of Contract, bound to a specific deployed contract.
func NewContractFilterer(address common.Address, filterer bind.ContractFilterer) (*ContractFilterer, error) {
contract, err := bindContract(address, nil, nil, filterer)
if err != nil {
return nil, err
}
return &ContractFilterer{contract: contract}, nil
}
// bindContract binds a generic wrapper to an already deployed contract.
func bindContract(address common.Address, caller bind.ContractCaller, transactor bind.ContractTransactor, filterer bind.ContractFilterer) (*bind.BoundContract, error) {
parsed, err := abi.JSON(strings.NewReader(ContractABI))
if err != nil {
return nil, err
}
return bind.NewBoundContract(address, parsed, caller, transactor, filterer), nil
}
// Call invokes the (constant) contract method with params as input values and
// sets the output to result. The result type might be a single field for simple
// returns, a slice of interfaces for anonymous returns and a struct for named
// returns.
func (_Contract *ContractRaw) Call(opts *bind.CallOpts, result interface{}, method string, params ...interface{}) error {
return _Contract.Contract.ContractCaller.contract.Call(opts, result, method, params...)
}
// Transfer initiates a plain transaction to move funds to the contract, calling
// its default method if one is available.
func (_Contract *ContractRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) {
return _Contract.Contract.ContractTransactor.contract.Transfer(opts)
}
// Transact invokes the (paid) contract method with params as input values.
func (_Contract *ContractRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) {
return _Contract.Contract.ContractTransactor.contract.Transact(opts, method, params...)
}
// Call invokes the (constant) contract method with params as input values and
// sets the output to result. The result type might be a single field for simple
// returns, a slice of interfaces for anonymous returns and a struct for named
// returns.
func (_Contract *ContractCallerRaw) Call(opts *bind.CallOpts, result interface{}, method string, params ...interface{}) error {
return _Contract.Contract.contract.Call(opts, result, method, params...)
}
// Transfer initiates a plain transaction to move funds to the contract, calling
// its default method if one is available.
func (_Contract *ContractTransactorRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) {
return _Contract.Contract.contract.Transfer(opts)
}
// Transact invokes the (paid) contract method with params as input values.
func (_Contract *ContractTransactorRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) {
return _Contract.Contract.contract.Transact(opts, method, params...)
}
// Data is a free data retrieval call binding the contract method 0x0147fb0c.
//
// Solidity: function data(bytes32 ) constant returns(uint256)
func (_Contract *ContractCaller) Data(opts *bind.CallOpts, arg0 [32]byte) (*big.Int, error) {
var (
ret0 = new(*big.Int)
)
out := ret0
err := _Contract.contract.Call(opts, out, "data", arg0)
return *ret0, err
}
// Data is a free data retrieval call binding the contract method 0x0147fb0c.
//
// Solidity: function data(bytes32 ) constant returns(uint256)
func (_Contract *ContractSession) Data(arg0 [32]byte) (*big.Int, error) {
return _Contract.Contract.Data(&_Contract.CallOpts, arg0)
}
// Data is a free data retrieval call binding the contract method 0x0147fb0c.
//
// Solidity: function data(bytes32 ) constant returns(uint256)
func (_Contract *ContractCallerSession) Data(arg0 [32]byte) (*big.Int, error) {
return _Contract.Contract.Data(&_Contract.CallOpts, arg0)
}
// Read is a free data retrieval call binding the contract method 0x61da1439.
//
// Solidity: function read(bytes32 s) constant returns(uint256)
func (_Contract *ContractCaller) Read(opts *bind.CallOpts, s [32]byte) (*big.Int, error) {
var (
ret0 = new(*big.Int)
)
out := ret0
err := _Contract.contract.Call(opts, out, "read", s)
return *ret0, err
}
// Read is a free data retrieval call binding the contract method 0x61da1439.
//
// Solidity: function read(bytes32 s) constant returns(uint256)
func (_Contract *ContractSession) Read(s [32]byte) (*big.Int, error) {
return _Contract.Contract.Read(&_Contract.CallOpts, s)
}
// Read is a free data retrieval call binding the contract method 0x61da1439.
//
// Solidity: function read(bytes32 s) constant returns(uint256)
func (_Contract *ContractCallerSession) Read(s [32]byte) (*big.Int, error) {
return _Contract.Contract.Read(&_Contract.CallOpts, s)
}
// Write is a paid mutator transaction binding the contract method 0xe020def2.
//
// Solidity: function write(bytes32 s) returns()
func (_Contract *ContractTransactor) Write(opts *bind.TransactOpts, s [32]byte) (*types.Transaction, error) {
return _Contract.contract.Transact(opts, "write", s)
}
// Write is a paid mutator transaction binding the contract method 0xe020def2.
//
// Solidity: function write(bytes32 s) returns()
func (_Contract *ContractSession) Write(s [32]byte) (*types.Transaction, error) {
return _Contract.Contract.Write(&_Contract.TransactOpts, s)
}
// Write is a paid mutator transaction binding the contract method 0xe020def2.
//
// Solidity: function write(bytes32 s) returns()
func (_Contract *ContractTransactorSession) Write(s [32]byte) (*types.Transaction, error) {
return _Contract.Contract.Write(&_Contract.TransactOpts, s)
}