fix: changed aggregator contract logic, dioneStaking contract, filecoin client

This commit is contained in:
bahadylbekov 2020-11-14 14:25:14 +03:00
parent ffa03747d8
commit 3e68466665
19 changed files with 820 additions and 1638 deletions

View File

@ -27,7 +27,7 @@ var (
)
// AggregatorABI is the input ABI used to generate the binding from.
const AggregatorABI = "[{\"inputs\":[{\"internalType\":\"contractWhitelist\",\"name\":\"_whitelist\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"reqID\",\"type\":\"uint256\"},{\"internalType\":\"string\",\"name\":\"data\",\"type\":\"string\"},{\"internalType\":\"address\",\"name\":\"callbackAddress\",\"type\":\"address\"},{\"internalType\":\"bytes4\",\"name\":\"callbackMethodID\",\"type\":\"bytes4\"}],\"name\":\"collectData\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]"
const AggregatorABI = "[{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"previousOwner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"OwnershipTransferred\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"dioneStaking\",\"outputs\":[{\"internalType\":\"contractIDioneStaking\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"owner\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"renounceOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"transferOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contractIDioneStaking\",\"name\":\"_dioneStaking\",\"type\":\"address\"}],\"name\":\"setDioneStaking\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"reqID\",\"type\":\"uint256\"},{\"internalType\":\"string\",\"name\":\"data\",\"type\":\"string\"},{\"internalType\":\"address\",\"name\":\"callbackAddress\",\"type\":\"address\"},{\"internalType\":\"bytes4\",\"name\":\"callbackMethodID\",\"type\":\"bytes4\"}],\"name\":\"collectData\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]"
// Aggregator is an auto generated Go binding around an Ethereum contract.
type Aggregator struct {
@ -171,6 +171,58 @@ func (_Aggregator *AggregatorTransactorRaw) Transact(opts *bind.TransactOpts, me
return _Aggregator.Contract.contract.Transact(opts, method, params...)
}
// DioneStaking is a free data retrieval call binding the contract method 0xe7013ddd.
//
// Solidity: function dioneStaking() view returns(address)
func (_Aggregator *AggregatorCaller) DioneStaking(opts *bind.CallOpts) (common.Address, error) {
var (
ret0 = new(common.Address)
)
out := ret0
err := _Aggregator.contract.Call(opts, out, "dioneStaking")
return *ret0, err
}
// DioneStaking is a free data retrieval call binding the contract method 0xe7013ddd.
//
// Solidity: function dioneStaking() view returns(address)
func (_Aggregator *AggregatorSession) DioneStaking() (common.Address, error) {
return _Aggregator.Contract.DioneStaking(&_Aggregator.CallOpts)
}
// DioneStaking is a free data retrieval call binding the contract method 0xe7013ddd.
//
// Solidity: function dioneStaking() view returns(address)
func (_Aggregator *AggregatorCallerSession) DioneStaking() (common.Address, error) {
return _Aggregator.Contract.DioneStaking(&_Aggregator.CallOpts)
}
// Owner is a free data retrieval call binding the contract method 0x8da5cb5b.
//
// Solidity: function owner() view returns(address)
func (_Aggregator *AggregatorCaller) Owner(opts *bind.CallOpts) (common.Address, error) {
var (
ret0 = new(common.Address)
)
out := ret0
err := _Aggregator.contract.Call(opts, out, "owner")
return *ret0, err
}
// Owner is a free data retrieval call binding the contract method 0x8da5cb5b.
//
// Solidity: function owner() view returns(address)
func (_Aggregator *AggregatorSession) Owner() (common.Address, error) {
return _Aggregator.Contract.Owner(&_Aggregator.CallOpts)
}
// Owner is a free data retrieval call binding the contract method 0x8da5cb5b.
//
// Solidity: function owner() view returns(address)
func (_Aggregator *AggregatorCallerSession) Owner() (common.Address, error) {
return _Aggregator.Contract.Owner(&_Aggregator.CallOpts)
}
// CollectData is a paid mutator transaction binding the contract method 0x05187092.
//
// Solidity: function collectData(uint256 reqID, string data, address callbackAddress, bytes4 callbackMethodID) returns()
@ -191,3 +243,218 @@ func (_Aggregator *AggregatorSession) CollectData(reqID *big.Int, data string, c
func (_Aggregator *AggregatorTransactorSession) CollectData(reqID *big.Int, data string, callbackAddress common.Address, callbackMethodID [4]byte) (*types.Transaction, error) {
return _Aggregator.Contract.CollectData(&_Aggregator.TransactOpts, reqID, data, callbackAddress, callbackMethodID)
}
// RenounceOwnership is a paid mutator transaction binding the contract method 0x715018a6.
//
// Solidity: function renounceOwnership() returns()
func (_Aggregator *AggregatorTransactor) RenounceOwnership(opts *bind.TransactOpts) (*types.Transaction, error) {
return _Aggregator.contract.Transact(opts, "renounceOwnership")
}
// RenounceOwnership is a paid mutator transaction binding the contract method 0x715018a6.
//
// Solidity: function renounceOwnership() returns()
func (_Aggregator *AggregatorSession) RenounceOwnership() (*types.Transaction, error) {
return _Aggregator.Contract.RenounceOwnership(&_Aggregator.TransactOpts)
}
// RenounceOwnership is a paid mutator transaction binding the contract method 0x715018a6.
//
// Solidity: function renounceOwnership() returns()
func (_Aggregator *AggregatorTransactorSession) RenounceOwnership() (*types.Transaction, error) {
return _Aggregator.Contract.RenounceOwnership(&_Aggregator.TransactOpts)
}
// SetDioneStaking is a paid mutator transaction binding the contract method 0xc2cf98a4.
//
// Solidity: function setDioneStaking(address _dioneStaking) returns()
func (_Aggregator *AggregatorTransactor) SetDioneStaking(opts *bind.TransactOpts, _dioneStaking common.Address) (*types.Transaction, error) {
return _Aggregator.contract.Transact(opts, "setDioneStaking", _dioneStaking)
}
// SetDioneStaking is a paid mutator transaction binding the contract method 0xc2cf98a4.
//
// Solidity: function setDioneStaking(address _dioneStaking) returns()
func (_Aggregator *AggregatorSession) SetDioneStaking(_dioneStaking common.Address) (*types.Transaction, error) {
return _Aggregator.Contract.SetDioneStaking(&_Aggregator.TransactOpts, _dioneStaking)
}
// SetDioneStaking is a paid mutator transaction binding the contract method 0xc2cf98a4.
//
// Solidity: function setDioneStaking(address _dioneStaking) returns()
func (_Aggregator *AggregatorTransactorSession) SetDioneStaking(_dioneStaking common.Address) (*types.Transaction, error) {
return _Aggregator.Contract.SetDioneStaking(&_Aggregator.TransactOpts, _dioneStaking)
}
// TransferOwnership is a paid mutator transaction binding the contract method 0xf2fde38b.
//
// Solidity: function transferOwnership(address newOwner) returns()
func (_Aggregator *AggregatorTransactor) TransferOwnership(opts *bind.TransactOpts, newOwner common.Address) (*types.Transaction, error) {
return _Aggregator.contract.Transact(opts, "transferOwnership", newOwner)
}
// TransferOwnership is a paid mutator transaction binding the contract method 0xf2fde38b.
//
// Solidity: function transferOwnership(address newOwner) returns()
func (_Aggregator *AggregatorSession) TransferOwnership(newOwner common.Address) (*types.Transaction, error) {
return _Aggregator.Contract.TransferOwnership(&_Aggregator.TransactOpts, newOwner)
}
// TransferOwnership is a paid mutator transaction binding the contract method 0xf2fde38b.
//
// Solidity: function transferOwnership(address newOwner) returns()
func (_Aggregator *AggregatorTransactorSession) TransferOwnership(newOwner common.Address) (*types.Transaction, error) {
return _Aggregator.Contract.TransferOwnership(&_Aggregator.TransactOpts, newOwner)
}
// AggregatorOwnershipTransferredIterator is returned from FilterOwnershipTransferred and is used to iterate over the raw logs and unpacked data for OwnershipTransferred events raised by the Aggregator contract.
type AggregatorOwnershipTransferredIterator struct {
Event *AggregatorOwnershipTransferred // Event containing the contract specifics and raw log
contract *bind.BoundContract // Generic contract to use for unpacking event data
event string // Event name to use for unpacking event data
logs chan types.Log // Log channel receiving the found contract events
sub ethereum.Subscription // Subscription for errors, completion and termination
done bool // Whether the subscription completed delivering logs
fail error // Occurred error to stop iteration
}
// Next advances the iterator to the subsequent event, returning whether there
// are any more events found. In case of a retrieval or parsing error, false is
// returned and Error() can be queried for the exact failure.
func (it *AggregatorOwnershipTransferredIterator) Next() bool {
// If the iterator failed, stop iterating
if it.fail != nil {
return false
}
// If the iterator completed, deliver directly whatever's available
if it.done {
select {
case log := <-it.logs:
it.Event = new(AggregatorOwnershipTransferred)
if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil {
it.fail = err
return false
}
it.Event.Raw = log
return true
default:
return false
}
}
// Iterator still in progress, wait for either a data or an error event
select {
case log := <-it.logs:
it.Event = new(AggregatorOwnershipTransferred)
if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil {
it.fail = err
return false
}
it.Event.Raw = log
return true
case err := <-it.sub.Err():
it.done = true
it.fail = err
return it.Next()
}
}
// Error returns any retrieval or parsing error occurred during filtering.
func (it *AggregatorOwnershipTransferredIterator) Error() error {
return it.fail
}
// Close terminates the iteration process, releasing any pending underlying
// resources.
func (it *AggregatorOwnershipTransferredIterator) Close() error {
it.sub.Unsubscribe()
return nil
}
// AggregatorOwnershipTransferred represents a OwnershipTransferred event raised by the Aggregator contract.
type AggregatorOwnershipTransferred struct {
PreviousOwner common.Address
NewOwner common.Address
Raw types.Log // Blockchain specific contextual infos
}
// FilterOwnershipTransferred is a free log retrieval operation binding the contract event 0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0.
//
// Solidity: event OwnershipTransferred(address indexed previousOwner, address indexed newOwner)
func (_Aggregator *AggregatorFilterer) FilterOwnershipTransferred(opts *bind.FilterOpts, previousOwner []common.Address, newOwner []common.Address) (*AggregatorOwnershipTransferredIterator, error) {
var previousOwnerRule []interface{}
for _, previousOwnerItem := range previousOwner {
previousOwnerRule = append(previousOwnerRule, previousOwnerItem)
}
var newOwnerRule []interface{}
for _, newOwnerItem := range newOwner {
newOwnerRule = append(newOwnerRule, newOwnerItem)
}
logs, sub, err := _Aggregator.contract.FilterLogs(opts, "OwnershipTransferred", previousOwnerRule, newOwnerRule)
if err != nil {
return nil, err
}
return &AggregatorOwnershipTransferredIterator{contract: _Aggregator.contract, event: "OwnershipTransferred", logs: logs, sub: sub}, nil
}
// WatchOwnershipTransferred is a free log subscription operation binding the contract event 0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0.
//
// Solidity: event OwnershipTransferred(address indexed previousOwner, address indexed newOwner)
func (_Aggregator *AggregatorFilterer) WatchOwnershipTransferred(opts *bind.WatchOpts, sink chan<- *AggregatorOwnershipTransferred, previousOwner []common.Address, newOwner []common.Address) (event.Subscription, error) {
var previousOwnerRule []interface{}
for _, previousOwnerItem := range previousOwner {
previousOwnerRule = append(previousOwnerRule, previousOwnerItem)
}
var newOwnerRule []interface{}
for _, newOwnerItem := range newOwner {
newOwnerRule = append(newOwnerRule, newOwnerItem)
}
logs, sub, err := _Aggregator.contract.WatchLogs(opts, "OwnershipTransferred", previousOwnerRule, newOwnerRule)
if err != nil {
return nil, err
}
return event.NewSubscription(func(quit <-chan struct{}) error {
defer sub.Unsubscribe()
for {
select {
case log := <-logs:
// New log arrived, parse the event and forward to the user
event := new(AggregatorOwnershipTransferred)
if err := _Aggregator.contract.UnpackLog(event, "OwnershipTransferred", log); err != nil {
return err
}
event.Raw = log
select {
case sink <- event:
case err := <-sub.Err():
return err
case <-quit:
return nil
}
case err := <-sub.Err():
return err
case <-quit:
return nil
}
}
}), nil
}
// ParseOwnershipTransferred is a log parse operation binding the contract event 0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0.
//
// Solidity: event OwnershipTransferred(address indexed previousOwner, address indexed newOwner)
func (_Aggregator *AggregatorFilterer) ParseOwnershipTransferred(log types.Log) (*AggregatorOwnershipTransferred, error) {
event := new(AggregatorOwnershipTransferred)
if err := _Aggregator.contract.UnpackLog(event, "OwnershipTransferred", log); err != nil {
return nil, err
}
return event, nil
}

File diff suppressed because one or more lines are too long

View File

@ -1,573 +0,0 @@
// Code generated - DO NOT EDIT.
// This file is a generated binding and any manual changes will be lost.
package mediator
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
_ = bind.Bind
_ = common.Big1
_ = types.BloomLookup
_ = event.NewSubscription
)
// SmartcontractsABI is the input ABI used to generate the binding from.
const SmartcontractsABI = "[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_oracleEmitter\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"_aggregator\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"reqID\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"string\",\"name\":\"data\",\"type\":\"string\"}],\"name\":\"DataReceived\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"previousOwner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"OwnershipTransferred\",\"type\":\"event\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"reqID\",\"type\":\"uint256\"},{\"internalType\":\"string\",\"name\":\"data\",\"type\":\"string\"}],\"name\":\"_receiveDataCallback\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"isOwner\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"owner\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"string\",\"name\":\"requestType\",\"type\":\"string\"}],\"name\":\"request\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"transferOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]"
// Smartcontracts is an auto generated Go binding around an Ethereum contract.
type Smartcontracts struct {
SmartcontractsCaller // Read-only binding to the contract
SmartcontractsTransactor // Write-only binding to the contract
SmartcontractsFilterer // Log filterer for contract events
}
// SmartcontractsCaller is an auto generated read-only Go binding around an Ethereum contract.
type SmartcontractsCaller struct {
contract *bind.BoundContract // Generic contract wrapper for the low level calls
}
// SmartcontractsTransactor is an auto generated write-only Go binding around an Ethereum contract.
type SmartcontractsTransactor struct {
contract *bind.BoundContract // Generic contract wrapper for the low level calls
}
// SmartcontractsFilterer is an auto generated log filtering Go binding around an Ethereum contract events.
type SmartcontractsFilterer struct {
contract *bind.BoundContract // Generic contract wrapper for the low level calls
}
// SmartcontractsSession is an auto generated Go binding around an Ethereum contract,
// with pre-set call and transact options.
type SmartcontractsSession struct {
Contract *Smartcontracts // 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
}
// SmartcontractsCallerSession is an auto generated read-only Go binding around an Ethereum contract,
// with pre-set call options.
type SmartcontractsCallerSession struct {
Contract *SmartcontractsCaller // Generic contract caller binding to set the session for
CallOpts bind.CallOpts // Call options to use throughout this session
}
// SmartcontractsTransactorSession is an auto generated write-only Go binding around an Ethereum contract,
// with pre-set transact options.
type SmartcontractsTransactorSession struct {
Contract *SmartcontractsTransactor // Generic contract transactor binding to set the session for
TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session
}
// SmartcontractsRaw is an auto generated low-level Go binding around an Ethereum contract.
type SmartcontractsRaw struct {
Contract *Smartcontracts // Generic contract binding to access the raw methods on
}
// SmartcontractsCallerRaw is an auto generated low-level read-only Go binding around an Ethereum contract.
type SmartcontractsCallerRaw struct {
Contract *SmartcontractsCaller // Generic read-only contract binding to access the raw methods on
}
// SmartcontractsTransactorRaw is an auto generated low-level write-only Go binding around an Ethereum contract.
type SmartcontractsTransactorRaw struct {
Contract *SmartcontractsTransactor // Generic write-only contract binding to access the raw methods on
}
// NewSmartcontracts creates a new instance of Smartcontracts, bound to a specific deployed contract.
func NewSmartcontracts(address common.Address, backend bind.ContractBackend) (*Smartcontracts, error) {
contract, err := bindSmartcontracts(address, backend, backend, backend)
if err != nil {
return nil, err
}
return &Smartcontracts{SmartcontractsCaller: SmartcontractsCaller{contract: contract}, SmartcontractsTransactor: SmartcontractsTransactor{contract: contract}, SmartcontractsFilterer: SmartcontractsFilterer{contract: contract}}, nil
}
// NewSmartcontractsCaller creates a new read-only instance of Smartcontracts, bound to a specific deployed contract.
func NewSmartcontractsCaller(address common.Address, caller bind.ContractCaller) (*SmartcontractsCaller, error) {
contract, err := bindSmartcontracts(address, caller, nil, nil)
if err != nil {
return nil, err
}
return &SmartcontractsCaller{contract: contract}, nil
}
// NewSmartcontractsTransactor creates a new write-only instance of Smartcontracts, bound to a specific deployed contract.
func NewSmartcontractsTransactor(address common.Address, transactor bind.ContractTransactor) (*SmartcontractsTransactor, error) {
contract, err := bindSmartcontracts(address, nil, transactor, nil)
if err != nil {
return nil, err
}
return &SmartcontractsTransactor{contract: contract}, nil
}
// NewSmartcontractsFilterer creates a new log filterer instance of Smartcontracts, bound to a specific deployed contract.
func NewSmartcontractsFilterer(address common.Address, filterer bind.ContractFilterer) (*SmartcontractsFilterer, error) {
contract, err := bindSmartcontracts(address, nil, nil, filterer)
if err != nil {
return nil, err
}
return &SmartcontractsFilterer{contract: contract}, nil
}
// bindSmartcontracts binds a generic wrapper to an already deployed contract.
func bindSmartcontracts(address common.Address, caller bind.ContractCaller, transactor bind.ContractTransactor, filterer bind.ContractFilterer) (*bind.BoundContract, error) {
parsed, err := abi.JSON(strings.NewReader(SmartcontractsABI))
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 (_Smartcontracts *SmartcontractsRaw) Call(opts *bind.CallOpts, result interface{}, method string, params ...interface{}) error {
return _Smartcontracts.Contract.SmartcontractsCaller.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 (_Smartcontracts *SmartcontractsRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) {
return _Smartcontracts.Contract.SmartcontractsTransactor.contract.Transfer(opts)
}
// Transact invokes the (paid) contract method with params as input values.
func (_Smartcontracts *SmartcontractsRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) {
return _Smartcontracts.Contract.SmartcontractsTransactor.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 (_Smartcontracts *SmartcontractsCallerRaw) Call(opts *bind.CallOpts, result interface{}, method string, params ...interface{}) error {
return _Smartcontracts.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 (_Smartcontracts *SmartcontractsTransactorRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) {
return _Smartcontracts.Contract.contract.Transfer(opts)
}
// Transact invokes the (paid) contract method with params as input values.
func (_Smartcontracts *SmartcontractsTransactorRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) {
return _Smartcontracts.Contract.contract.Transact(opts, method, params...)
}
// IsOwner is a free data retrieval call binding the contract method 0x8f32d59b.
//
// Solidity: function isOwner() view returns(bool)
func (_Smartcontracts *SmartcontractsCaller) IsOwner(opts *bind.CallOpts) (bool, error) {
var (
ret0 = new(bool)
)
out := ret0
err := _Smartcontracts.contract.Call(opts, out, "isOwner")
return *ret0, err
}
// IsOwner is a free data retrieval call binding the contract method 0x8f32d59b.
//
// Solidity: function isOwner() view returns(bool)
func (_Smartcontracts *SmartcontractsSession) IsOwner() (bool, error) {
return _Smartcontracts.Contract.IsOwner(&_Smartcontracts.CallOpts)
}
// IsOwner is a free data retrieval call binding the contract method 0x8f32d59b.
//
// Solidity: function isOwner() view returns(bool)
func (_Smartcontracts *SmartcontractsCallerSession) IsOwner() (bool, error) {
return _Smartcontracts.Contract.IsOwner(&_Smartcontracts.CallOpts)
}
// Owner is a free data retrieval call binding the contract method 0x8da5cb5b.
//
// Solidity: function owner() view returns(address)
func (_Smartcontracts *SmartcontractsCaller) Owner(opts *bind.CallOpts) (common.Address, error) {
var (
ret0 = new(common.Address)
)
out := ret0
err := _Smartcontracts.contract.Call(opts, out, "owner")
return *ret0, err
}
// Owner is a free data retrieval call binding the contract method 0x8da5cb5b.
//
// Solidity: function owner() view returns(address)
func (_Smartcontracts *SmartcontractsSession) Owner() (common.Address, error) {
return _Smartcontracts.Contract.Owner(&_Smartcontracts.CallOpts)
}
// Owner is a free data retrieval call binding the contract method 0x8da5cb5b.
//
// Solidity: function owner() view returns(address)
func (_Smartcontracts *SmartcontractsCallerSession) Owner() (common.Address, error) {
return _Smartcontracts.Contract.Owner(&_Smartcontracts.CallOpts)
}
// ReceiveDataCallback is a paid mutator transaction binding the contract method 0xfd55592a.
//
// Solidity: function _receiveDataCallback(uint256 reqID, string data) returns()
func (_Smartcontracts *SmartcontractsTransactor) ReceiveDataCallback(opts *bind.TransactOpts, reqID *big.Int, data string) (*types.Transaction, error) {
return _Smartcontracts.contract.Transact(opts, "_receiveDataCallback", reqID, data)
}
// ReceiveDataCallback is a paid mutator transaction binding the contract method 0xfd55592a.
//
// Solidity: function _receiveDataCallback(uint256 reqID, string data) returns()
func (_Smartcontracts *SmartcontractsSession) ReceiveDataCallback(reqID *big.Int, data string) (*types.Transaction, error) {
return _Smartcontracts.Contract.ReceiveDataCallback(&_Smartcontracts.TransactOpts, reqID, data)
}
// ReceiveDataCallback is a paid mutator transaction binding the contract method 0xfd55592a.
//
// Solidity: function _receiveDataCallback(uint256 reqID, string data) returns()
func (_Smartcontracts *SmartcontractsTransactorSession) ReceiveDataCallback(reqID *big.Int, data string) (*types.Transaction, error) {
return _Smartcontracts.Contract.ReceiveDataCallback(&_Smartcontracts.TransactOpts, reqID, data)
}
// Request is a paid mutator transaction binding the contract method 0x2c199889.
//
// Solidity: function request(string requestType) returns(uint256)
func (_Smartcontracts *SmartcontractsTransactor) Request(opts *bind.TransactOpts, requestType string) (*types.Transaction, error) {
return _Smartcontracts.contract.Transact(opts, "request", requestType)
}
// Request is a paid mutator transaction binding the contract method 0x2c199889.
//
// Solidity: function request(string requestType) returns(uint256)
func (_Smartcontracts *SmartcontractsSession) Request(requestType string) (*types.Transaction, error) {
return _Smartcontracts.Contract.Request(&_Smartcontracts.TransactOpts, requestType)
}
// Request is a paid mutator transaction binding the contract method 0x2c199889.
//
// Solidity: function request(string requestType) returns(uint256)
func (_Smartcontracts *SmartcontractsTransactorSession) Request(requestType string) (*types.Transaction, error) {
return _Smartcontracts.Contract.Request(&_Smartcontracts.TransactOpts, requestType)
}
// TransferOwnership is a paid mutator transaction binding the contract method 0xf2fde38b.
//
// Solidity: function transferOwnership(address newOwner) returns()
func (_Smartcontracts *SmartcontractsTransactor) TransferOwnership(opts *bind.TransactOpts, newOwner common.Address) (*types.Transaction, error) {
return _Smartcontracts.contract.Transact(opts, "transferOwnership", newOwner)
}
// TransferOwnership is a paid mutator transaction binding the contract method 0xf2fde38b.
//
// Solidity: function transferOwnership(address newOwner) returns()
func (_Smartcontracts *SmartcontractsSession) TransferOwnership(newOwner common.Address) (*types.Transaction, error) {
return _Smartcontracts.Contract.TransferOwnership(&_Smartcontracts.TransactOpts, newOwner)
}
// TransferOwnership is a paid mutator transaction binding the contract method 0xf2fde38b.
//
// Solidity: function transferOwnership(address newOwner) returns()
func (_Smartcontracts *SmartcontractsTransactorSession) TransferOwnership(newOwner common.Address) (*types.Transaction, error) {
return _Smartcontracts.Contract.TransferOwnership(&_Smartcontracts.TransactOpts, newOwner)
}
// SmartcontractsDataReceivedIterator is returned from FilterDataReceived and is used to iterate over the raw logs and unpacked data for DataReceived events raised by the Smartcontracts contract.
type SmartcontractsDataReceivedIterator struct {
Event *SmartcontractsDataReceived // Event containing the contract specifics and raw log
contract *bind.BoundContract // Generic contract to use for unpacking event data
event string // Event name to use for unpacking event data
logs chan types.Log // Log channel receiving the found contract events
sub ethereum.Subscription // Subscription for errors, completion and termination
done bool // Whether the subscription completed delivering logs
fail error // Occurred error to stop iteration
}
// Next advances the iterator to the subsequent event, returning whether there
// are any more events found. In case of a retrieval or parsing error, false is
// returned and Error() can be queried for the exact failure.
func (it *SmartcontractsDataReceivedIterator) Next() bool {
// If the iterator failed, stop iterating
if it.fail != nil {
return false
}
// If the iterator completed, deliver directly whatever's available
if it.done {
select {
case log := <-it.logs:
it.Event = new(SmartcontractsDataReceived)
if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil {
it.fail = err
return false
}
it.Event.Raw = log
return true
default:
return false
}
}
// Iterator still in progress, wait for either a data or an error event
select {
case log := <-it.logs:
it.Event = new(SmartcontractsDataReceived)
if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil {
it.fail = err
return false
}
it.Event.Raw = log
return true
case err := <-it.sub.Err():
it.done = true
it.fail = err
return it.Next()
}
}
// Error returns any retrieval or parsing error occurred during filtering.
func (it *SmartcontractsDataReceivedIterator) Error() error {
return it.fail
}
// Close terminates the iteration process, releasing any pending underlying
// resources.
func (it *SmartcontractsDataReceivedIterator) Close() error {
it.sub.Unsubscribe()
return nil
}
// SmartcontractsDataReceived represents a DataReceived event raised by the Smartcontracts contract.
type SmartcontractsDataReceived struct {
ReqID *big.Int
Data string
Raw types.Log // Blockchain specific contextual infos
}
// FilterDataReceived is a free log retrieval operation binding the contract event 0x761d45cf346740607c4bed1616ffece636d5449d76d1213886d4a76b76318653.
//
// Solidity: event DataReceived(uint256 reqID, string data)
func (_Smartcontracts *SmartcontractsFilterer) FilterDataReceived(opts *bind.FilterOpts) (*SmartcontractsDataReceivedIterator, error) {
logs, sub, err := _Smartcontracts.contract.FilterLogs(opts, "DataReceived")
if err != nil {
return nil, err
}
return &SmartcontractsDataReceivedIterator{contract: _Smartcontracts.contract, event: "DataReceived", logs: logs, sub: sub}, nil
}
// WatchDataReceived is a free log subscription operation binding the contract event 0x761d45cf346740607c4bed1616ffece636d5449d76d1213886d4a76b76318653.
//
// Solidity: event DataReceived(uint256 reqID, string data)
func (_Smartcontracts *SmartcontractsFilterer) WatchDataReceived(opts *bind.WatchOpts, sink chan<- *SmartcontractsDataReceived) (event.Subscription, error) {
logs, sub, err := _Smartcontracts.contract.WatchLogs(opts, "DataReceived")
if err != nil {
return nil, err
}
return event.NewSubscription(func(quit <-chan struct{}) error {
defer sub.Unsubscribe()
for {
select {
case log := <-logs:
// New log arrived, parse the event and forward to the user
event := new(SmartcontractsDataReceived)
if err := _Smartcontracts.contract.UnpackLog(event, "DataReceived", log); err != nil {
return err
}
event.Raw = log
select {
case sink <- event:
case err := <-sub.Err():
return err
case <-quit:
return nil
}
case err := <-sub.Err():
return err
case <-quit:
return nil
}
}
}), nil
}
// ParseDataReceived is a log parse operation binding the contract event 0x761d45cf346740607c4bed1616ffece636d5449d76d1213886d4a76b76318653.
//
// Solidity: event DataReceived(uint256 reqID, string data)
func (_Smartcontracts *SmartcontractsFilterer) ParseDataReceived(log types.Log) (*SmartcontractsDataReceived, error) {
event := new(SmartcontractsDataReceived)
if err := _Smartcontracts.contract.UnpackLog(event, "DataReceived", log); err != nil {
return nil, err
}
return event, nil
}
// SmartcontractsOwnershipTransferredIterator is returned from FilterOwnershipTransferred and is used to iterate over the raw logs and unpacked data for OwnershipTransferred events raised by the Smartcontracts contract.
type SmartcontractsOwnershipTransferredIterator struct {
Event *SmartcontractsOwnershipTransferred // Event containing the contract specifics and raw log
contract *bind.BoundContract // Generic contract to use for unpacking event data
event string // Event name to use for unpacking event data
logs chan types.Log // Log channel receiving the found contract events
sub ethereum.Subscription // Subscription for errors, completion and termination
done bool // Whether the subscription completed delivering logs
fail error // Occurred error to stop iteration
}
// Next advances the iterator to the subsequent event, returning whether there
// are any more events found. In case of a retrieval or parsing error, false is
// returned and Error() can be queried for the exact failure.
func (it *SmartcontractsOwnershipTransferredIterator) Next() bool {
// If the iterator failed, stop iterating
if it.fail != nil {
return false
}
// If the iterator completed, deliver directly whatever's available
if it.done {
select {
case log := <-it.logs:
it.Event = new(SmartcontractsOwnershipTransferred)
if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil {
it.fail = err
return false
}
it.Event.Raw = log
return true
default:
return false
}
}
// Iterator still in progress, wait for either a data or an error event
select {
case log := <-it.logs:
it.Event = new(SmartcontractsOwnershipTransferred)
if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil {
it.fail = err
return false
}
it.Event.Raw = log
return true
case err := <-it.sub.Err():
it.done = true
it.fail = err
return it.Next()
}
}
// Error returns any retrieval or parsing error occurred during filtering.
func (it *SmartcontractsOwnershipTransferredIterator) Error() error {
return it.fail
}
// Close terminates the iteration process, releasing any pending underlying
// resources.
func (it *SmartcontractsOwnershipTransferredIterator) Close() error {
it.sub.Unsubscribe()
return nil
}
// SmartcontractsOwnershipTransferred represents a OwnershipTransferred event raised by the Smartcontracts contract.
type SmartcontractsOwnershipTransferred struct {
PreviousOwner common.Address
NewOwner common.Address
Raw types.Log // Blockchain specific contextual infos
}
// FilterOwnershipTransferred is a free log retrieval operation binding the contract event 0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0.
//
// Solidity: event OwnershipTransferred(address indexed previousOwner, address indexed newOwner)
func (_Smartcontracts *SmartcontractsFilterer) FilterOwnershipTransferred(opts *bind.FilterOpts, previousOwner []common.Address, newOwner []common.Address) (*SmartcontractsOwnershipTransferredIterator, error) {
var previousOwnerRule []interface{}
for _, previousOwnerItem := range previousOwner {
previousOwnerRule = append(previousOwnerRule, previousOwnerItem)
}
var newOwnerRule []interface{}
for _, newOwnerItem := range newOwner {
newOwnerRule = append(newOwnerRule, newOwnerItem)
}
logs, sub, err := _Smartcontracts.contract.FilterLogs(opts, "OwnershipTransferred", previousOwnerRule, newOwnerRule)
if err != nil {
return nil, err
}
return &SmartcontractsOwnershipTransferredIterator{contract: _Smartcontracts.contract, event: "OwnershipTransferred", logs: logs, sub: sub}, nil
}
// WatchOwnershipTransferred is a free log subscription operation binding the contract event 0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0.
//
// Solidity: event OwnershipTransferred(address indexed previousOwner, address indexed newOwner)
func (_Smartcontracts *SmartcontractsFilterer) WatchOwnershipTransferred(opts *bind.WatchOpts, sink chan<- *SmartcontractsOwnershipTransferred, previousOwner []common.Address, newOwner []common.Address) (event.Subscription, error) {
var previousOwnerRule []interface{}
for _, previousOwnerItem := range previousOwner {
previousOwnerRule = append(previousOwnerRule, previousOwnerItem)
}
var newOwnerRule []interface{}
for _, newOwnerItem := range newOwner {
newOwnerRule = append(newOwnerRule, newOwnerItem)
}
logs, sub, err := _Smartcontracts.contract.WatchLogs(opts, "OwnershipTransferred", previousOwnerRule, newOwnerRule)
if err != nil {
return nil, err
}
return event.NewSubscription(func(quit <-chan struct{}) error {
defer sub.Unsubscribe()
for {
select {
case log := <-logs:
// New log arrived, parse the event and forward to the user
event := new(SmartcontractsOwnershipTransferred)
if err := _Smartcontracts.contract.UnpackLog(event, "OwnershipTransferred", log); err != nil {
return err
}
event.Raw = log
select {
case sink <- event:
case err := <-sub.Err():
return err
case <-quit:
return nil
}
case err := <-sub.Err():
return err
case <-quit:
return nil
}
}
}), nil
}
// ParseOwnershipTransferred is a log parse operation binding the contract event 0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0.
//
// Solidity: event OwnershipTransferred(address indexed previousOwner, address indexed newOwner)
func (_Smartcontracts *SmartcontractsFilterer) ParseOwnershipTransferred(log types.Log) (*SmartcontractsOwnershipTransferred, error) {
event := new(SmartcontractsOwnershipTransferred)
if err := _Smartcontracts.contract.UnpackLog(event, "OwnershipTransferred", log); err != nil {
return nil, err
}
return event, nil
}

View File

@ -1,7 +1,7 @@
// Code generated - DO NOT EDIT.
// This file is a generated binding and any manual changes will be lost.
package oracleemitter
package oracleEmitter
import (
"math/big"
@ -27,7 +27,7 @@ var (
)
// OracleEmitterABI is the input ABI used to generate the binding from.
const OracleEmitterABI = "[{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"string\",\"name\":\"requestType\",\"type\":\"string\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"callbackAddress\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"bytes4\",\"name\":\"callbackMethodID\",\"type\":\"bytes4\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"requestID\",\"type\":\"uint256\"}],\"name\":\"NewOracleRequest\",\"type\":\"event\"},{\"inputs\":[{\"internalType\":\"string\",\"name\":\"requestType\",\"type\":\"string\"},{\"internalType\":\"address\",\"name\":\"callbackAddress\",\"type\":\"address\"},{\"internalType\":\"bytes4\",\"name\":\"callbackMethodID\",\"type\":\"bytes4\"}],\"name\":\"requestOracles\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]"
const OracleEmitterABI = "[{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"string\",\"name\":\"originChain\",\"type\":\"string\"},{\"indexed\":false,\"internalType\":\"string\",\"name\":\"requestType\",\"type\":\"string\"},{\"indexed\":false,\"internalType\":\"string\",\"name\":\"requestParams\",\"type\":\"string\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"callbackAddress\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"bytes4\",\"name\":\"callbackMethodID\",\"type\":\"bytes4\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"requestID\",\"type\":\"uint256\"}],\"name\":\"NewOracleRequest\",\"type\":\"event\"},{\"inputs\":[{\"internalType\":\"string\",\"name\":\"originChain\",\"type\":\"string\"},{\"internalType\":\"string\",\"name\":\"requestType\",\"type\":\"string\"},{\"internalType\":\"string\",\"name\":\"requestParams\",\"type\":\"string\"},{\"internalType\":\"address\",\"name\":\"callbackAddress\",\"type\":\"address\"},{\"internalType\":\"bytes4\",\"name\":\"callbackMethodID\",\"type\":\"bytes4\"}],\"name\":\"requestOracles\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]"
// OracleEmitter is an auto generated Go binding around an Ethereum contract.
type OracleEmitter struct {
@ -171,25 +171,25 @@ func (_OracleEmitter *OracleEmitterTransactorRaw) Transact(opts *bind.TransactOp
return _OracleEmitter.Contract.contract.Transact(opts, method, params...)
}
// RequestOracles is a paid mutator transaction binding the contract method 0xcae2f480.
// RequestOracles is a paid mutator transaction binding the contract method 0x8fe3d79f.
//
// Solidity: function requestOracles(string requestType, address callbackAddress, bytes4 callbackMethodID) returns(uint256)
func (_OracleEmitter *OracleEmitterTransactor) RequestOracles(opts *bind.TransactOpts, requestType string, callbackAddress common.Address, callbackMethodID [4]byte) (*types.Transaction, error) {
return _OracleEmitter.contract.Transact(opts, "requestOracles", requestType, callbackAddress, callbackMethodID)
// Solidity: function requestOracles(string originChain, string requestType, string requestParams, address callbackAddress, bytes4 callbackMethodID) returns(uint256)
func (_OracleEmitter *OracleEmitterTransactor) RequestOracles(opts *bind.TransactOpts, originChain string, requestType string, requestParams string, callbackAddress common.Address, callbackMethodID [4]byte) (*types.Transaction, error) {
return _OracleEmitter.contract.Transact(opts, "requestOracles", originChain, requestType, requestParams, callbackAddress, callbackMethodID)
}
// RequestOracles is a paid mutator transaction binding the contract method 0xcae2f480.
// RequestOracles is a paid mutator transaction binding the contract method 0x8fe3d79f.
//
// Solidity: function requestOracles(string requestType, address callbackAddress, bytes4 callbackMethodID) returns(uint256)
func (_OracleEmitter *OracleEmitterSession) RequestOracles(requestType string, callbackAddress common.Address, callbackMethodID [4]byte) (*types.Transaction, error) {
return _OracleEmitter.Contract.RequestOracles(&_OracleEmitter.TransactOpts, requestType, callbackAddress, callbackMethodID)
// Solidity: function requestOracles(string originChain, string requestType, string requestParams, address callbackAddress, bytes4 callbackMethodID) returns(uint256)
func (_OracleEmitter *OracleEmitterSession) RequestOracles(originChain string, requestType string, requestParams string, callbackAddress common.Address, callbackMethodID [4]byte) (*types.Transaction, error) {
return _OracleEmitter.Contract.RequestOracles(&_OracleEmitter.TransactOpts, originChain, requestType, requestParams, callbackAddress, callbackMethodID)
}
// RequestOracles is a paid mutator transaction binding the contract method 0xcae2f480.
// RequestOracles is a paid mutator transaction binding the contract method 0x8fe3d79f.
//
// Solidity: function requestOracles(string requestType, address callbackAddress, bytes4 callbackMethodID) returns(uint256)
func (_OracleEmitter *OracleEmitterTransactorSession) RequestOracles(requestType string, callbackAddress common.Address, callbackMethodID [4]byte) (*types.Transaction, error) {
return _OracleEmitter.Contract.RequestOracles(&_OracleEmitter.TransactOpts, requestType, callbackAddress, callbackMethodID)
// Solidity: function requestOracles(string originChain, string requestType, string requestParams, address callbackAddress, bytes4 callbackMethodID) returns(uint256)
func (_OracleEmitter *OracleEmitterTransactorSession) RequestOracles(originChain string, requestType string, requestParams string, callbackAddress common.Address, callbackMethodID [4]byte) (*types.Transaction, error) {
return _OracleEmitter.Contract.RequestOracles(&_OracleEmitter.TransactOpts, originChain, requestType, requestParams, callbackAddress, callbackMethodID)
}
// OracleEmitterNewOracleRequestIterator is returned from FilterNewOracleRequest and is used to iterate over the raw logs and unpacked data for NewOracleRequest events raised by the OracleEmitter contract.
@ -261,16 +261,18 @@ func (it *OracleEmitterNewOracleRequestIterator) Close() error {
// OracleEmitterNewOracleRequest represents a NewOracleRequest event raised by the OracleEmitter contract.
type OracleEmitterNewOracleRequest struct {
OriginChain string
RequestType string
RequestParams string
CallbackAddress common.Address
CallbackMethodID [4]byte
RequestID *big.Int
Raw types.Log // Blockchain specific contextual infos
}
// FilterNewOracleRequest is a free log retrieval operation binding the contract event 0xc1a7df69ed0404441720a3eb710f322985ecbbe4f31934587bee703efe04427a.
// FilterNewOracleRequest is a free log retrieval operation binding the contract event 0x4840d7d041230e7d05eaf9e64f0924379c740cd38ebe8ced4ca8b22afb8d3c94.
//
// Solidity: event NewOracleRequest(string requestType, address callbackAddress, bytes4 callbackMethodID, uint256 requestID)
// Solidity: event NewOracleRequest(string originChain, string requestType, string requestParams, address callbackAddress, bytes4 callbackMethodID, uint256 requestID)
func (_OracleEmitter *OracleEmitterFilterer) FilterNewOracleRequest(opts *bind.FilterOpts) (*OracleEmitterNewOracleRequestIterator, error) {
logs, sub, err := _OracleEmitter.contract.FilterLogs(opts, "NewOracleRequest")
@ -280,9 +282,9 @@ func (_OracleEmitter *OracleEmitterFilterer) FilterNewOracleRequest(opts *bind.F
return &OracleEmitterNewOracleRequestIterator{contract: _OracleEmitter.contract, event: "NewOracleRequest", logs: logs, sub: sub}, nil
}
// WatchNewOracleRequest is a free log subscription operation binding the contract event 0xc1a7df69ed0404441720a3eb710f322985ecbbe4f31934587bee703efe04427a.
// WatchNewOracleRequest is a free log subscription operation binding the contract event 0x4840d7d041230e7d05eaf9e64f0924379c740cd38ebe8ced4ca8b22afb8d3c94.
//
// Solidity: event NewOracleRequest(string requestType, address callbackAddress, bytes4 callbackMethodID, uint256 requestID)
// Solidity: event NewOracleRequest(string originChain, string requestType, string requestParams, address callbackAddress, bytes4 callbackMethodID, uint256 requestID)
func (_OracleEmitter *OracleEmitterFilterer) WatchNewOracleRequest(opts *bind.WatchOpts, sink chan<- *OracleEmitterNewOracleRequest) (event.Subscription, error) {
logs, sub, err := _OracleEmitter.contract.WatchLogs(opts, "NewOracleRequest")
@ -317,9 +319,9 @@ func (_OracleEmitter *OracleEmitterFilterer) WatchNewOracleRequest(opts *bind.Wa
}), nil
}
// ParseNewOracleRequest is a log parse operation binding the contract event 0xc1a7df69ed0404441720a3eb710f322985ecbbe4f31934587bee703efe04427a.
// ParseNewOracleRequest is a log parse operation binding the contract event 0x4840d7d041230e7d05eaf9e64f0924379c740cd38ebe8ced4ca8b22afb8d3c94.
//
// Solidity: event NewOracleRequest(string requestType, address callbackAddress, bytes4 callbackMethodID, uint256 requestID)
// Solidity: event NewOracleRequest(string originChain, string requestType, string requestParams, address callbackAddress, bytes4 callbackMethodID, uint256 requestID)
func (_OracleEmitter *OracleEmitterFilterer) ParseNewOracleRequest(log types.Log) (*OracleEmitterNewOracleRequest, error) {
event := new(OracleEmitterNewOracleRequest)
if err := _OracleEmitter.contract.UnpackLog(event, "NewOracleRequest", log); err != nil {

View File

@ -1,397 +0,0 @@
// Code generated - DO NOT EDIT.
// This file is a generated binding and any manual changes will be lost.
package ownable
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
_ = bind.Bind
_ = common.Big1
_ = types.BloomLookup
_ = event.NewSubscription
)
// SmartcontractsABI is the input ABI used to generate the binding from.
const SmartcontractsABI = "[{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"previousOwner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"OwnershipTransferred\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"isOwner\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"owner\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"transferOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]"
// Smartcontracts is an auto generated Go binding around an Ethereum contract.
type Smartcontracts struct {
SmartcontractsCaller // Read-only binding to the contract
SmartcontractsTransactor // Write-only binding to the contract
SmartcontractsFilterer // Log filterer for contract events
}
// SmartcontractsCaller is an auto generated read-only Go binding around an Ethereum contract.
type SmartcontractsCaller struct {
contract *bind.BoundContract // Generic contract wrapper for the low level calls
}
// SmartcontractsTransactor is an auto generated write-only Go binding around an Ethereum contract.
type SmartcontractsTransactor struct {
contract *bind.BoundContract // Generic contract wrapper for the low level calls
}
// SmartcontractsFilterer is an auto generated log filtering Go binding around an Ethereum contract events.
type SmartcontractsFilterer struct {
contract *bind.BoundContract // Generic contract wrapper for the low level calls
}
// SmartcontractsSession is an auto generated Go binding around an Ethereum contract,
// with pre-set call and transact options.
type SmartcontractsSession struct {
Contract *Smartcontracts // 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
}
// SmartcontractsCallerSession is an auto generated read-only Go binding around an Ethereum contract,
// with pre-set call options.
type SmartcontractsCallerSession struct {
Contract *SmartcontractsCaller // Generic contract caller binding to set the session for
CallOpts bind.CallOpts // Call options to use throughout this session
}
// SmartcontractsTransactorSession is an auto generated write-only Go binding around an Ethereum contract,
// with pre-set transact options.
type SmartcontractsTransactorSession struct {
Contract *SmartcontractsTransactor // Generic contract transactor binding to set the session for
TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session
}
// SmartcontractsRaw is an auto generated low-level Go binding around an Ethereum contract.
type SmartcontractsRaw struct {
Contract *Smartcontracts // Generic contract binding to access the raw methods on
}
// SmartcontractsCallerRaw is an auto generated low-level read-only Go binding around an Ethereum contract.
type SmartcontractsCallerRaw struct {
Contract *SmartcontractsCaller // Generic read-only contract binding to access the raw methods on
}
// SmartcontractsTransactorRaw is an auto generated low-level write-only Go binding around an Ethereum contract.
type SmartcontractsTransactorRaw struct {
Contract *SmartcontractsTransactor // Generic write-only contract binding to access the raw methods on
}
// NewSmartcontracts creates a new instance of Smartcontracts, bound to a specific deployed contract.
func NewSmartcontracts(address common.Address, backend bind.ContractBackend) (*Smartcontracts, error) {
contract, err := bindSmartcontracts(address, backend, backend, backend)
if err != nil {
return nil, err
}
return &Smartcontracts{SmartcontractsCaller: SmartcontractsCaller{contract: contract}, SmartcontractsTransactor: SmartcontractsTransactor{contract: contract}, SmartcontractsFilterer: SmartcontractsFilterer{contract: contract}}, nil
}
// NewSmartcontractsCaller creates a new read-only instance of Smartcontracts, bound to a specific deployed contract.
func NewSmartcontractsCaller(address common.Address, caller bind.ContractCaller) (*SmartcontractsCaller, error) {
contract, err := bindSmartcontracts(address, caller, nil, nil)
if err != nil {
return nil, err
}
return &SmartcontractsCaller{contract: contract}, nil
}
// NewSmartcontractsTransactor creates a new write-only instance of Smartcontracts, bound to a specific deployed contract.
func NewSmartcontractsTransactor(address common.Address, transactor bind.ContractTransactor) (*SmartcontractsTransactor, error) {
contract, err := bindSmartcontracts(address, nil, transactor, nil)
if err != nil {
return nil, err
}
return &SmartcontractsTransactor{contract: contract}, nil
}
// NewSmartcontractsFilterer creates a new log filterer instance of Smartcontracts, bound to a specific deployed contract.
func NewSmartcontractsFilterer(address common.Address, filterer bind.ContractFilterer) (*SmartcontractsFilterer, error) {
contract, err := bindSmartcontracts(address, nil, nil, filterer)
if err != nil {
return nil, err
}
return &SmartcontractsFilterer{contract: contract}, nil
}
// bindSmartcontracts binds a generic wrapper to an already deployed contract.
func bindSmartcontracts(address common.Address, caller bind.ContractCaller, transactor bind.ContractTransactor, filterer bind.ContractFilterer) (*bind.BoundContract, error) {
parsed, err := abi.JSON(strings.NewReader(SmartcontractsABI))
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 (_Smartcontracts *SmartcontractsRaw) Call(opts *bind.CallOpts, result interface{}, method string, params ...interface{}) error {
return _Smartcontracts.Contract.SmartcontractsCaller.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 (_Smartcontracts *SmartcontractsRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) {
return _Smartcontracts.Contract.SmartcontractsTransactor.contract.Transfer(opts)
}
// Transact invokes the (paid) contract method with params as input values.
func (_Smartcontracts *SmartcontractsRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) {
return _Smartcontracts.Contract.SmartcontractsTransactor.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 (_Smartcontracts *SmartcontractsCallerRaw) Call(opts *bind.CallOpts, result interface{}, method string, params ...interface{}) error {
return _Smartcontracts.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 (_Smartcontracts *SmartcontractsTransactorRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) {
return _Smartcontracts.Contract.contract.Transfer(opts)
}
// Transact invokes the (paid) contract method with params as input values.
func (_Smartcontracts *SmartcontractsTransactorRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) {
return _Smartcontracts.Contract.contract.Transact(opts, method, params...)
}
// IsOwner is a free data retrieval call binding the contract method 0x8f32d59b.
//
// Solidity: function isOwner() view returns(bool)
func (_Smartcontracts *SmartcontractsCaller) IsOwner(opts *bind.CallOpts) (bool, error) {
var (
ret0 = new(bool)
)
out := ret0
err := _Smartcontracts.contract.Call(opts, out, "isOwner")
return *ret0, err
}
// IsOwner is a free data retrieval call binding the contract method 0x8f32d59b.
//
// Solidity: function isOwner() view returns(bool)
func (_Smartcontracts *SmartcontractsSession) IsOwner() (bool, error) {
return _Smartcontracts.Contract.IsOwner(&_Smartcontracts.CallOpts)
}
// IsOwner is a free data retrieval call binding the contract method 0x8f32d59b.
//
// Solidity: function isOwner() view returns(bool)
func (_Smartcontracts *SmartcontractsCallerSession) IsOwner() (bool, error) {
return _Smartcontracts.Contract.IsOwner(&_Smartcontracts.CallOpts)
}
// Owner is a free data retrieval call binding the contract method 0x8da5cb5b.
//
// Solidity: function owner() view returns(address)
func (_Smartcontracts *SmartcontractsCaller) Owner(opts *bind.CallOpts) (common.Address, error) {
var (
ret0 = new(common.Address)
)
out := ret0
err := _Smartcontracts.contract.Call(opts, out, "owner")
return *ret0, err
}
// Owner is a free data retrieval call binding the contract method 0x8da5cb5b.
//
// Solidity: function owner() view returns(address)
func (_Smartcontracts *SmartcontractsSession) Owner() (common.Address, error) {
return _Smartcontracts.Contract.Owner(&_Smartcontracts.CallOpts)
}
// Owner is a free data retrieval call binding the contract method 0x8da5cb5b.
//
// Solidity: function owner() view returns(address)
func (_Smartcontracts *SmartcontractsCallerSession) Owner() (common.Address, error) {
return _Smartcontracts.Contract.Owner(&_Smartcontracts.CallOpts)
}
// TransferOwnership is a paid mutator transaction binding the contract method 0xf2fde38b.
//
// Solidity: function transferOwnership(address newOwner) returns()
func (_Smartcontracts *SmartcontractsTransactor) TransferOwnership(opts *bind.TransactOpts, newOwner common.Address) (*types.Transaction, error) {
return _Smartcontracts.contract.Transact(opts, "transferOwnership", newOwner)
}
// TransferOwnership is a paid mutator transaction binding the contract method 0xf2fde38b.
//
// Solidity: function transferOwnership(address newOwner) returns()
func (_Smartcontracts *SmartcontractsSession) TransferOwnership(newOwner common.Address) (*types.Transaction, error) {
return _Smartcontracts.Contract.TransferOwnership(&_Smartcontracts.TransactOpts, newOwner)
}
// TransferOwnership is a paid mutator transaction binding the contract method 0xf2fde38b.
//
// Solidity: function transferOwnership(address newOwner) returns()
func (_Smartcontracts *SmartcontractsTransactorSession) TransferOwnership(newOwner common.Address) (*types.Transaction, error) {
return _Smartcontracts.Contract.TransferOwnership(&_Smartcontracts.TransactOpts, newOwner)
}
// SmartcontractsOwnershipTransferredIterator is returned from FilterOwnershipTransferred and is used to iterate over the raw logs and unpacked data for OwnershipTransferred events raised by the Smartcontracts contract.
type SmartcontractsOwnershipTransferredIterator struct {
Event *SmartcontractsOwnershipTransferred // Event containing the contract specifics and raw log
contract *bind.BoundContract // Generic contract to use for unpacking event data
event string // Event name to use for unpacking event data
logs chan types.Log // Log channel receiving the found contract events
sub ethereum.Subscription // Subscription for errors, completion and termination
done bool // Whether the subscription completed delivering logs
fail error // Occurred error to stop iteration
}
// Next advances the iterator to the subsequent event, returning whether there
// are any more events found. In case of a retrieval or parsing error, false is
// returned and Error() can be queried for the exact failure.
func (it *SmartcontractsOwnershipTransferredIterator) Next() bool {
// If the iterator failed, stop iterating
if it.fail != nil {
return false
}
// If the iterator completed, deliver directly whatever's available
if it.done {
select {
case log := <-it.logs:
it.Event = new(SmartcontractsOwnershipTransferred)
if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil {
it.fail = err
return false
}
it.Event.Raw = log
return true
default:
return false
}
}
// Iterator still in progress, wait for either a data or an error event
select {
case log := <-it.logs:
it.Event = new(SmartcontractsOwnershipTransferred)
if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil {
it.fail = err
return false
}
it.Event.Raw = log
return true
case err := <-it.sub.Err():
it.done = true
it.fail = err
return it.Next()
}
}
// Error returns any retrieval or parsing error occurred during filtering.
func (it *SmartcontractsOwnershipTransferredIterator) Error() error {
return it.fail
}
// Close terminates the iteration process, releasing any pending underlying
// resources.
func (it *SmartcontractsOwnershipTransferredIterator) Close() error {
it.sub.Unsubscribe()
return nil
}
// SmartcontractsOwnershipTransferred represents a OwnershipTransferred event raised by the Smartcontracts contract.
type SmartcontractsOwnershipTransferred struct {
PreviousOwner common.Address
NewOwner common.Address
Raw types.Log // Blockchain specific contextual infos
}
// FilterOwnershipTransferred is a free log retrieval operation binding the contract event 0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0.
//
// Solidity: event OwnershipTransferred(address indexed previousOwner, address indexed newOwner)
func (_Smartcontracts *SmartcontractsFilterer) FilterOwnershipTransferred(opts *bind.FilterOpts, previousOwner []common.Address, newOwner []common.Address) (*SmartcontractsOwnershipTransferredIterator, error) {
var previousOwnerRule []interface{}
for _, previousOwnerItem := range previousOwner {
previousOwnerRule = append(previousOwnerRule, previousOwnerItem)
}
var newOwnerRule []interface{}
for _, newOwnerItem := range newOwner {
newOwnerRule = append(newOwnerRule, newOwnerItem)
}
logs, sub, err := _Smartcontracts.contract.FilterLogs(opts, "OwnershipTransferred", previousOwnerRule, newOwnerRule)
if err != nil {
return nil, err
}
return &SmartcontractsOwnershipTransferredIterator{contract: _Smartcontracts.contract, event: "OwnershipTransferred", logs: logs, sub: sub}, nil
}
// WatchOwnershipTransferred is a free log subscription operation binding the contract event 0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0.
//
// Solidity: event OwnershipTransferred(address indexed previousOwner, address indexed newOwner)
func (_Smartcontracts *SmartcontractsFilterer) WatchOwnershipTransferred(opts *bind.WatchOpts, sink chan<- *SmartcontractsOwnershipTransferred, previousOwner []common.Address, newOwner []common.Address) (event.Subscription, error) {
var previousOwnerRule []interface{}
for _, previousOwnerItem := range previousOwner {
previousOwnerRule = append(previousOwnerRule, previousOwnerItem)
}
var newOwnerRule []interface{}
for _, newOwnerItem := range newOwner {
newOwnerRule = append(newOwnerRule, newOwnerItem)
}
logs, sub, err := _Smartcontracts.contract.WatchLogs(opts, "OwnershipTransferred", previousOwnerRule, newOwnerRule)
if err != nil {
return nil, err
}
return event.NewSubscription(func(quit <-chan struct{}) error {
defer sub.Unsubscribe()
for {
select {
case log := <-logs:
// New log arrived, parse the event and forward to the user
event := new(SmartcontractsOwnershipTransferred)
if err := _Smartcontracts.contract.UnpackLog(event, "OwnershipTransferred", log); err != nil {
return err
}
event.Raw = log
select {
case sink <- event:
case err := <-sub.Err():
return err
case <-quit:
return nil
}
case err := <-sub.Err():
return err
case <-quit:
return nil
}
}
}), nil
}
// ParseOwnershipTransferred is a log parse operation binding the contract event 0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0.
//
// Solidity: event OwnershipTransferred(address indexed previousOwner, address indexed newOwner)
func (_Smartcontracts *SmartcontractsFilterer) ParseOwnershipTransferred(log types.Log) (*SmartcontractsOwnershipTransferred, error) {
event := new(SmartcontractsOwnershipTransferred)
if err := _Smartcontracts.contract.UnpackLog(event, "OwnershipTransferred", log); err != nil {
return nil, err
}
return event, nil
}

View File

@ -1,491 +0,0 @@
// Code generated - DO NOT EDIT.
// This file is a generated binding and any manual changes will be lost.
package whitelist
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
_ = bind.Bind
_ = common.Big1
_ = types.BloomLookup
_ = event.NewSubscription
)
// SmartcontractsABI is the input ABI used to generate the binding from.
const SmartcontractsABI = "[{\"inputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"previousOwner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"OwnershipTransferred\",\"type\":\"event\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"nodeAccount\",\"type\":\"address\"}],\"name\":\"addNode\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getNodes\",\"outputs\":[{\"internalType\":\"address[]\",\"name\":\"\",\"type\":\"address[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"isOwner\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"nodes\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"owner\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"nodeAccount\",\"type\":\"address\"}],\"name\":\"removeNode\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"transferOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]"
// Smartcontracts is an auto generated Go binding around an Ethereum contract.
type Smartcontracts struct {
SmartcontractsCaller // Read-only binding to the contract
SmartcontractsTransactor // Write-only binding to the contract
SmartcontractsFilterer // Log filterer for contract events
}
// SmartcontractsCaller is an auto generated read-only Go binding around an Ethereum contract.
type SmartcontractsCaller struct {
contract *bind.BoundContract // Generic contract wrapper for the low level calls
}
// SmartcontractsTransactor is an auto generated write-only Go binding around an Ethereum contract.
type SmartcontractsTransactor struct {
contract *bind.BoundContract // Generic contract wrapper for the low level calls
}
// SmartcontractsFilterer is an auto generated log filtering Go binding around an Ethereum contract events.
type SmartcontractsFilterer struct {
contract *bind.BoundContract // Generic contract wrapper for the low level calls
}
// SmartcontractsSession is an auto generated Go binding around an Ethereum contract,
// with pre-set call and transact options.
type SmartcontractsSession struct {
Contract *Smartcontracts // 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
}
// SmartcontractsCallerSession is an auto generated read-only Go binding around an Ethereum contract,
// with pre-set call options.
type SmartcontractsCallerSession struct {
Contract *SmartcontractsCaller // Generic contract caller binding to set the session for
CallOpts bind.CallOpts // Call options to use throughout this session
}
// SmartcontractsTransactorSession is an auto generated write-only Go binding around an Ethereum contract,
// with pre-set transact options.
type SmartcontractsTransactorSession struct {
Contract *SmartcontractsTransactor // Generic contract transactor binding to set the session for
TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session
}
// SmartcontractsRaw is an auto generated low-level Go binding around an Ethereum contract.
type SmartcontractsRaw struct {
Contract *Smartcontracts // Generic contract binding to access the raw methods on
}
// SmartcontractsCallerRaw is an auto generated low-level read-only Go binding around an Ethereum contract.
type SmartcontractsCallerRaw struct {
Contract *SmartcontractsCaller // Generic read-only contract binding to access the raw methods on
}
// SmartcontractsTransactorRaw is an auto generated low-level write-only Go binding around an Ethereum contract.
type SmartcontractsTransactorRaw struct {
Contract *SmartcontractsTransactor // Generic write-only contract binding to access the raw methods on
}
// NewSmartcontracts creates a new instance of Smartcontracts, bound to a specific deployed contract.
func NewSmartcontracts(address common.Address, backend bind.ContractBackend) (*Smartcontracts, error) {
contract, err := bindSmartcontracts(address, backend, backend, backend)
if err != nil {
return nil, err
}
return &Smartcontracts{SmartcontractsCaller: SmartcontractsCaller{contract: contract}, SmartcontractsTransactor: SmartcontractsTransactor{contract: contract}, SmartcontractsFilterer: SmartcontractsFilterer{contract: contract}}, nil
}
// NewSmartcontractsCaller creates a new read-only instance of Smartcontracts, bound to a specific deployed contract.
func NewSmartcontractsCaller(address common.Address, caller bind.ContractCaller) (*SmartcontractsCaller, error) {
contract, err := bindSmartcontracts(address, caller, nil, nil)
if err != nil {
return nil, err
}
return &SmartcontractsCaller{contract: contract}, nil
}
// NewSmartcontractsTransactor creates a new write-only instance of Smartcontracts, bound to a specific deployed contract.
func NewSmartcontractsTransactor(address common.Address, transactor bind.ContractTransactor) (*SmartcontractsTransactor, error) {
contract, err := bindSmartcontracts(address, nil, transactor, nil)
if err != nil {
return nil, err
}
return &SmartcontractsTransactor{contract: contract}, nil
}
// NewSmartcontractsFilterer creates a new log filterer instance of Smartcontracts, bound to a specific deployed contract.
func NewSmartcontractsFilterer(address common.Address, filterer bind.ContractFilterer) (*SmartcontractsFilterer, error) {
contract, err := bindSmartcontracts(address, nil, nil, filterer)
if err != nil {
return nil, err
}
return &SmartcontractsFilterer{contract: contract}, nil
}
// bindSmartcontracts binds a generic wrapper to an already deployed contract.
func bindSmartcontracts(address common.Address, caller bind.ContractCaller, transactor bind.ContractTransactor, filterer bind.ContractFilterer) (*bind.BoundContract, error) {
parsed, err := abi.JSON(strings.NewReader(SmartcontractsABI))
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 (_Smartcontracts *SmartcontractsRaw) Call(opts *bind.CallOpts, result interface{}, method string, params ...interface{}) error {
return _Smartcontracts.Contract.SmartcontractsCaller.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 (_Smartcontracts *SmartcontractsRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) {
return _Smartcontracts.Contract.SmartcontractsTransactor.contract.Transfer(opts)
}
// Transact invokes the (paid) contract method with params as input values.
func (_Smartcontracts *SmartcontractsRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) {
return _Smartcontracts.Contract.SmartcontractsTransactor.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 (_Smartcontracts *SmartcontractsCallerRaw) Call(opts *bind.CallOpts, result interface{}, method string, params ...interface{}) error {
return _Smartcontracts.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 (_Smartcontracts *SmartcontractsTransactorRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) {
return _Smartcontracts.Contract.contract.Transfer(opts)
}
// Transact invokes the (paid) contract method with params as input values.
func (_Smartcontracts *SmartcontractsTransactorRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) {
return _Smartcontracts.Contract.contract.Transact(opts, method, params...)
}
// GetNodes is a free data retrieval call binding the contract method 0xe29581aa.
//
// Solidity: function getNodes() view returns(address[])
func (_Smartcontracts *SmartcontractsCaller) GetNodes(opts *bind.CallOpts) ([]common.Address, error) {
var (
ret0 = new([]common.Address)
)
out := ret0
err := _Smartcontracts.contract.Call(opts, out, "getNodes")
return *ret0, err
}
// GetNodes is a free data retrieval call binding the contract method 0xe29581aa.
//
// Solidity: function getNodes() view returns(address[])
func (_Smartcontracts *SmartcontractsSession) GetNodes() ([]common.Address, error) {
return _Smartcontracts.Contract.GetNodes(&_Smartcontracts.CallOpts)
}
// GetNodes is a free data retrieval call binding the contract method 0xe29581aa.
//
// Solidity: function getNodes() view returns(address[])
func (_Smartcontracts *SmartcontractsCallerSession) GetNodes() ([]common.Address, error) {
return _Smartcontracts.Contract.GetNodes(&_Smartcontracts.CallOpts)
}
// IsOwner is a free data retrieval call binding the contract method 0x8f32d59b.
//
// Solidity: function isOwner() view returns(bool)
func (_Smartcontracts *SmartcontractsCaller) IsOwner(opts *bind.CallOpts) (bool, error) {
var (
ret0 = new(bool)
)
out := ret0
err := _Smartcontracts.contract.Call(opts, out, "isOwner")
return *ret0, err
}
// IsOwner is a free data retrieval call binding the contract method 0x8f32d59b.
//
// Solidity: function isOwner() view returns(bool)
func (_Smartcontracts *SmartcontractsSession) IsOwner() (bool, error) {
return _Smartcontracts.Contract.IsOwner(&_Smartcontracts.CallOpts)
}
// IsOwner is a free data retrieval call binding the contract method 0x8f32d59b.
//
// Solidity: function isOwner() view returns(bool)
func (_Smartcontracts *SmartcontractsCallerSession) IsOwner() (bool, error) {
return _Smartcontracts.Contract.IsOwner(&_Smartcontracts.CallOpts)
}
// Nodes is a free data retrieval call binding the contract method 0x1c53c280.
//
// Solidity: function nodes(uint256 ) view returns(address)
func (_Smartcontracts *SmartcontractsCaller) Nodes(opts *bind.CallOpts, arg0 *big.Int) (common.Address, error) {
var (
ret0 = new(common.Address)
)
out := ret0
err := _Smartcontracts.contract.Call(opts, out, "nodes", arg0)
return *ret0, err
}
// Nodes is a free data retrieval call binding the contract method 0x1c53c280.
//
// Solidity: function nodes(uint256 ) view returns(address)
func (_Smartcontracts *SmartcontractsSession) Nodes(arg0 *big.Int) (common.Address, error) {
return _Smartcontracts.Contract.Nodes(&_Smartcontracts.CallOpts, arg0)
}
// Nodes is a free data retrieval call binding the contract method 0x1c53c280.
//
// Solidity: function nodes(uint256 ) view returns(address)
func (_Smartcontracts *SmartcontractsCallerSession) Nodes(arg0 *big.Int) (common.Address, error) {
return _Smartcontracts.Contract.Nodes(&_Smartcontracts.CallOpts, arg0)
}
// Owner is a free data retrieval call binding the contract method 0x8da5cb5b.
//
// Solidity: function owner() view returns(address)
func (_Smartcontracts *SmartcontractsCaller) Owner(opts *bind.CallOpts) (common.Address, error) {
var (
ret0 = new(common.Address)
)
out := ret0
err := _Smartcontracts.contract.Call(opts, out, "owner")
return *ret0, err
}
// Owner is a free data retrieval call binding the contract method 0x8da5cb5b.
//
// Solidity: function owner() view returns(address)
func (_Smartcontracts *SmartcontractsSession) Owner() (common.Address, error) {
return _Smartcontracts.Contract.Owner(&_Smartcontracts.CallOpts)
}
// Owner is a free data retrieval call binding the contract method 0x8da5cb5b.
//
// Solidity: function owner() view returns(address)
func (_Smartcontracts *SmartcontractsCallerSession) Owner() (common.Address, error) {
return _Smartcontracts.Contract.Owner(&_Smartcontracts.CallOpts)
}
// AddNode is a paid mutator transaction binding the contract method 0x9d95f1cc.
//
// Solidity: function addNode(address nodeAccount) returns()
func (_Smartcontracts *SmartcontractsTransactor) AddNode(opts *bind.TransactOpts, nodeAccount common.Address) (*types.Transaction, error) {
return _Smartcontracts.contract.Transact(opts, "addNode", nodeAccount)
}
// AddNode is a paid mutator transaction binding the contract method 0x9d95f1cc.
//
// Solidity: function addNode(address nodeAccount) returns()
func (_Smartcontracts *SmartcontractsSession) AddNode(nodeAccount common.Address) (*types.Transaction, error) {
return _Smartcontracts.Contract.AddNode(&_Smartcontracts.TransactOpts, nodeAccount)
}
// AddNode is a paid mutator transaction binding the contract method 0x9d95f1cc.
//
// Solidity: function addNode(address nodeAccount) returns()
func (_Smartcontracts *SmartcontractsTransactorSession) AddNode(nodeAccount common.Address) (*types.Transaction, error) {
return _Smartcontracts.Contract.AddNode(&_Smartcontracts.TransactOpts, nodeAccount)
}
// RemoveNode is a paid mutator transaction binding the contract method 0xb2b99ec9.
//
// Solidity: function removeNode(address nodeAccount) returns()
func (_Smartcontracts *SmartcontractsTransactor) RemoveNode(opts *bind.TransactOpts, nodeAccount common.Address) (*types.Transaction, error) {
return _Smartcontracts.contract.Transact(opts, "removeNode", nodeAccount)
}
// RemoveNode is a paid mutator transaction binding the contract method 0xb2b99ec9.
//
// Solidity: function removeNode(address nodeAccount) returns()
func (_Smartcontracts *SmartcontractsSession) RemoveNode(nodeAccount common.Address) (*types.Transaction, error) {
return _Smartcontracts.Contract.RemoveNode(&_Smartcontracts.TransactOpts, nodeAccount)
}
// RemoveNode is a paid mutator transaction binding the contract method 0xb2b99ec9.
//
// Solidity: function removeNode(address nodeAccount) returns()
func (_Smartcontracts *SmartcontractsTransactorSession) RemoveNode(nodeAccount common.Address) (*types.Transaction, error) {
return _Smartcontracts.Contract.RemoveNode(&_Smartcontracts.TransactOpts, nodeAccount)
}
// TransferOwnership is a paid mutator transaction binding the contract method 0xf2fde38b.
//
// Solidity: function transferOwnership(address newOwner) returns()
func (_Smartcontracts *SmartcontractsTransactor) TransferOwnership(opts *bind.TransactOpts, newOwner common.Address) (*types.Transaction, error) {
return _Smartcontracts.contract.Transact(opts, "transferOwnership", newOwner)
}
// TransferOwnership is a paid mutator transaction binding the contract method 0xf2fde38b.
//
// Solidity: function transferOwnership(address newOwner) returns()
func (_Smartcontracts *SmartcontractsSession) TransferOwnership(newOwner common.Address) (*types.Transaction, error) {
return _Smartcontracts.Contract.TransferOwnership(&_Smartcontracts.TransactOpts, newOwner)
}
// TransferOwnership is a paid mutator transaction binding the contract method 0xf2fde38b.
//
// Solidity: function transferOwnership(address newOwner) returns()
func (_Smartcontracts *SmartcontractsTransactorSession) TransferOwnership(newOwner common.Address) (*types.Transaction, error) {
return _Smartcontracts.Contract.TransferOwnership(&_Smartcontracts.TransactOpts, newOwner)
}
// SmartcontractsOwnershipTransferredIterator is returned from FilterOwnershipTransferred and is used to iterate over the raw logs and unpacked data for OwnershipTransferred events raised by the Smartcontracts contract.
type SmartcontractsOwnershipTransferredIterator struct {
Event *SmartcontractsOwnershipTransferred // Event containing the contract specifics and raw log
contract *bind.BoundContract // Generic contract to use for unpacking event data
event string // Event name to use for unpacking event data
logs chan types.Log // Log channel receiving the found contract events
sub ethereum.Subscription // Subscription for errors, completion and termination
done bool // Whether the subscription completed delivering logs
fail error // Occurred error to stop iteration
}
// Next advances the iterator to the subsequent event, returning whether there
// are any more events found. In case of a retrieval or parsing error, false is
// returned and Error() can be queried for the exact failure.
func (it *SmartcontractsOwnershipTransferredIterator) Next() bool {
// If the iterator failed, stop iterating
if it.fail != nil {
return false
}
// If the iterator completed, deliver directly whatever's available
if it.done {
select {
case log := <-it.logs:
it.Event = new(SmartcontractsOwnershipTransferred)
if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil {
it.fail = err
return false
}
it.Event.Raw = log
return true
default:
return false
}
}
// Iterator still in progress, wait for either a data or an error event
select {
case log := <-it.logs:
it.Event = new(SmartcontractsOwnershipTransferred)
if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil {
it.fail = err
return false
}
it.Event.Raw = log
return true
case err := <-it.sub.Err():
it.done = true
it.fail = err
return it.Next()
}
}
// Error returns any retrieval or parsing error occurred during filtering.
func (it *SmartcontractsOwnershipTransferredIterator) Error() error {
return it.fail
}
// Close terminates the iteration process, releasing any pending underlying
// resources.
func (it *SmartcontractsOwnershipTransferredIterator) Close() error {
it.sub.Unsubscribe()
return nil
}
// SmartcontractsOwnershipTransferred represents a OwnershipTransferred event raised by the Smartcontracts contract.
type SmartcontractsOwnershipTransferred struct {
PreviousOwner common.Address
NewOwner common.Address
Raw types.Log // Blockchain specific contextual infos
}
// FilterOwnershipTransferred is a free log retrieval operation binding the contract event 0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0.
//
// Solidity: event OwnershipTransferred(address indexed previousOwner, address indexed newOwner)
func (_Smartcontracts *SmartcontractsFilterer) FilterOwnershipTransferred(opts *bind.FilterOpts, previousOwner []common.Address, newOwner []common.Address) (*SmartcontractsOwnershipTransferredIterator, error) {
var previousOwnerRule []interface{}
for _, previousOwnerItem := range previousOwner {
previousOwnerRule = append(previousOwnerRule, previousOwnerItem)
}
var newOwnerRule []interface{}
for _, newOwnerItem := range newOwner {
newOwnerRule = append(newOwnerRule, newOwnerItem)
}
logs, sub, err := _Smartcontracts.contract.FilterLogs(opts, "OwnershipTransferred", previousOwnerRule, newOwnerRule)
if err != nil {
return nil, err
}
return &SmartcontractsOwnershipTransferredIterator{contract: _Smartcontracts.contract, event: "OwnershipTransferred", logs: logs, sub: sub}, nil
}
// WatchOwnershipTransferred is a free log subscription operation binding the contract event 0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0.
//
// Solidity: event OwnershipTransferred(address indexed previousOwner, address indexed newOwner)
func (_Smartcontracts *SmartcontractsFilterer) WatchOwnershipTransferred(opts *bind.WatchOpts, sink chan<- *SmartcontractsOwnershipTransferred, previousOwner []common.Address, newOwner []common.Address) (event.Subscription, error) {
var previousOwnerRule []interface{}
for _, previousOwnerItem := range previousOwner {
previousOwnerRule = append(previousOwnerRule, previousOwnerItem)
}
var newOwnerRule []interface{}
for _, newOwnerItem := range newOwner {
newOwnerRule = append(newOwnerRule, newOwnerItem)
}
logs, sub, err := _Smartcontracts.contract.WatchLogs(opts, "OwnershipTransferred", previousOwnerRule, newOwnerRule)
if err != nil {
return nil, err
}
return event.NewSubscription(func(quit <-chan struct{}) error {
defer sub.Unsubscribe()
for {
select {
case log := <-logs:
// New log arrived, parse the event and forward to the user
event := new(SmartcontractsOwnershipTransferred)
if err := _Smartcontracts.contract.UnpackLog(event, "OwnershipTransferred", log); err != nil {
return err
}
event.Raw = log
select {
case sink <- event:
case err := <-sub.Err():
return err
case <-quit:
return nil
}
case err := <-sub.Err():
return err
case <-quit:
return nil
}
}
}), nil
}
// ParseOwnershipTransferred is a log parse operation binding the contract event 0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0.
//
// Solidity: event OwnershipTransferred(address indexed previousOwner, address indexed newOwner)
func (_Smartcontracts *SmartcontractsFilterer) ParseOwnershipTransferred(log types.Log) (*SmartcontractsOwnershipTransferred, error) {
event := new(SmartcontractsOwnershipTransferred)
if err := _Smartcontracts.contract.UnpackLog(event, "OwnershipTransferred", log); err != nil {
return nil, err
}
return event, nil
}

View File

@ -1,3 +1,3 @@
# P2P Oracle Smart Contracts
# Dione Smart Contracts
Smart contracts to work with Secured Finance P2P oracle network.
Smart contracts to work with Secured Finance Dione oracle network.

View File

@ -1,24 +1,25 @@
//SPDX-License-Identifier: MIT
pragma solidity >= 0.5.0 < 0.7.0;
import "./Whitelist.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/utils/ReentrancyGuard.sol";
contract Aggregator {
Whitelist whitelist;
interface IDioneStaking {
function mine(address _minerAddr) external;
function mineAndStake(address _minerAddr) external;
function isLegitMiner(address _minerAddr) external returns (bool);
}
constructor(Whitelist _whitelist) public {
whitelist = _whitelist;
contract Aggregator is Ownable, ReentrancyGuard {
IDioneStaking public dioneStaking;
// Set DioneStaking contract. Can only be called by the owner.
function setDioneStaking(IDioneStaking _dioneStaking) public onlyOwner {
dioneStaking = _dioneStaking;
}
function collectData(uint256 reqID, string memory data, address callbackAddress, bytes4 callbackMethodID) public {
address[] memory nodes = whitelist.getNodes();
bool nodeInTheList = false;
for (uint256 i = 0; i < nodes.length-1; i++) {
if (nodes[i] == msg.sender) {
nodeInTheList = true;
}
}
require(nodeInTheList);
function collectData(uint256 reqID, string memory data, address callbackAddress, bytes4 callbackMethodID) public nonReentrant {
require(dioneStaking.isLegitMiner(msg.sender));
(bool success,) = callbackAddress.call(abi.encode(callbackMethodID, reqID, data));
require(success);
}

View File

@ -117,9 +117,18 @@ contract DioneStaking is Ownable, ReentrancyGuard {
minerReward = _minerReward;
}
function isLegitMiner(address _minerAddr) external returns (bool) {
MinerInfo storage miner = minerInfo[_minerAddr];
if (miner.amount >= minimumStake) {
return true;
}
return false;
}
// Update minimum stake in DIONE tokens for miners, only can be executed by owner of the contract
function setMinimumStake(uint256 _minimumStake) public onlyOwner {
require(_minimumStake > 0, "!minerReward-0");
minimumStake = _minimumStake;
}
}

View File

@ -18,8 +18,8 @@ contract Mediator is Ownable {
aggregator = _aggregator;
}
function request(string memory requestType) public returns (uint256) {
return oracleEmitter.requestOracles(requestType, address(this), bytes4(keccak256("_receiveDataCallback(uint256, string)")));
function request(uint8 memory originChain, uint8 memory requestType, string memory requestParams) public returns (uint256) {
return oracleEmitter.requestOracles(originChain, requestType, requestParams, address(this), bytes4(keccak256("_receiveDataCallback(uint256, string)")));
}
function _receiveDataCallback(uint256 reqID, string memory data) public {

View File

@ -5,15 +5,17 @@ contract OracleEmitter {
uint256 requestCounter;
event NewOracleRequest(
string requestType,
uint8 originChain,
uint8 requestType,
string requestParams,
address callbackAddress,
bytes4 callbackMethodID,
uint256 requestID
);
function requestOracles(string memory requestType, address callbackAddress, bytes4 callbackMethodID) public returns (uint256) {
function requestOracles(uint8 memory originChain, uint8 memory requestType, string memory requestParams, address callbackAddress, bytes4 callbackMethodID) public returns (uint256) {
requestCounter++;
emit NewOracleRequest(requestType, callbackAddress, callbackMethodID, requestCounter);
emit NewOracleRequest(originChain, requestType, requestParams, callbackAddress, callbackMethodID, requestCounter);
return requestCounter;
}
}

View File

@ -1,34 +0,0 @@
//SPDX-License-Identifier: MIT
pragma solidity >= 0.5.0 < 0.7.0;
import "./vendor/Ownable.sol";
contract Whitelist is Ownable {
address[] public nodes;
constructor() public Ownable() {
}
function addNode(address nodeAccount) public onlyOwner {
nodes.push(nodeAccount);
}
function removeNode(address nodeAccount) public onlyOwner {
for (uint256 i = 0; i <= nodes.length-1; i++){
if (nodes[i] == nodeAccount) {
for (uint256 j = i; j < nodes.length-1; j++){
nodes[j] = nodes[j+1];
}
delete nodes[nodes.length-1];
if (nodes.length == 1) {
delete nodes;
}
break;
}
}
}
function getNodes() public view returns (address[] memory) {
return nodes;
}
}

View File

@ -1,5 +1,5 @@
{
"name": "p2p-oracle-smart-contracts",
"name": "dione-smart-contracts",
"version": "0.0.1",
"lockfileVersion": 1,
"requires": true,
@ -58,6 +58,16 @@
"to-fast-properties": "^2.0.0"
}
},
"@dabh/diagnostics": {
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/@dabh/diagnostics/-/diagnostics-2.0.2.tgz",
"integrity": "sha512-+A1YivoVDNNVCdfozHSR8v/jyuuLTMXwjWuxPFlFlUapXoGc+Gj9mDlTDDfrwl7rXCl2tNZ0kE8sIBO6YOn96Q==",
"requires": {
"colorspace": "1.1.x",
"enabled": "2.0.x",
"kuler": "^2.0.0"
}
},
"@ethersproject/abi": {
"version": "5.0.0-beta.153",
"resolved": "https://registry.npmjs.org/@ethersproject/abi/-/abi-5.0.0-beta.153.tgz",
@ -205,11 +215,114 @@
"integrity": "sha512-bUOmkSoPkjnUyMiKo6RYnb0VHBk5D9KKDAgNLzF41aqAM3TeE0yGdFF5dVRcV60pZdJLlyFT/jjXIZCWyyEzAQ==",
"dev": true
},
"@resolver-engine/core": {
"version": "0.2.1",
"resolved": "https://registry.npmjs.org/@resolver-engine/core/-/core-0.2.1.tgz",
"integrity": "sha512-nsLQHmPJ77QuifqsIvqjaF5B9aHnDzJjp73Q1z6apY3e9nqYrx4Dtowhpsf7Jwftg/XzVDEMQC+OzUBNTS+S1A==",
"requires": {
"debug": "^3.1.0",
"request": "^2.85.0"
},
"dependencies": {
"debug": {
"version": "3.2.6",
"resolved": "https://registry.npmjs.org/debug/-/debug-3.2.6.tgz",
"integrity": "sha512-mel+jf7nrtEl5Pn1Qx46zARXKDpBbvzezse7p7LqINmdoIk8PYP5SySaxEmYv6TZ0JyEKA1hsCId6DIhgITtWQ==",
"requires": {
"ms": "^2.1.1"
}
},
"ms": {
"version": "2.1.2",
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz",
"integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w=="
}
}
},
"@resolver-engine/fs": {
"version": "0.2.1",
"resolved": "https://registry.npmjs.org/@resolver-engine/fs/-/fs-0.2.1.tgz",
"integrity": "sha512-7kJInM1Qo2LJcKyDhuYzh9ZWd+mal/fynfL9BNjWOiTcOpX+jNfqb/UmGUqros5pceBITlWGqS4lU709yHFUbg==",
"requires": {
"@resolver-engine/core": "^0.2.1",
"debug": "^3.1.0"
},
"dependencies": {
"debug": {
"version": "3.2.6",
"resolved": "https://registry.npmjs.org/debug/-/debug-3.2.6.tgz",
"integrity": "sha512-mel+jf7nrtEl5Pn1Qx46zARXKDpBbvzezse7p7LqINmdoIk8PYP5SySaxEmYv6TZ0JyEKA1hsCId6DIhgITtWQ==",
"requires": {
"ms": "^2.1.1"
}
},
"ms": {
"version": "2.1.2",
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz",
"integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w=="
}
}
},
"@resolver-engine/imports": {
"version": "0.2.2",
"resolved": "https://registry.npmjs.org/@resolver-engine/imports/-/imports-0.2.2.tgz",
"integrity": "sha512-u5/HUkvo8q34AA+hnxxqqXGfby5swnH0Myw91o3Sm2TETJlNKXibFGSKBavAH+wvWdBi4Z5gS2Odu0PowgVOUg==",
"requires": {
"@resolver-engine/core": "^0.2.1",
"debug": "^3.1.0",
"hosted-git-info": "^2.6.0"
},
"dependencies": {
"debug": {
"version": "3.2.6",
"resolved": "https://registry.npmjs.org/debug/-/debug-3.2.6.tgz",
"integrity": "sha512-mel+jf7nrtEl5Pn1Qx46zARXKDpBbvzezse7p7LqINmdoIk8PYP5SySaxEmYv6TZ0JyEKA1hsCId6DIhgITtWQ==",
"requires": {
"ms": "^2.1.1"
}
},
"ms": {
"version": "2.1.2",
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz",
"integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w=="
}
}
},
"@resolver-engine/imports-fs": {
"version": "0.2.2",
"resolved": "https://registry.npmjs.org/@resolver-engine/imports-fs/-/imports-fs-0.2.2.tgz",
"integrity": "sha512-gFCgMvCwyppjwq0UzIjde/WI+yDs3oatJhozG9xdjJdewwtd7LiF0T5i9lrHAUtqrQbqoFE4E+ZMRVHWpWHpKQ==",
"requires": {
"@resolver-engine/fs": "^0.2.1",
"@resolver-engine/imports": "^0.2.2",
"debug": "^3.1.0"
},
"dependencies": {
"debug": {
"version": "3.2.6",
"resolved": "https://registry.npmjs.org/debug/-/debug-3.2.6.tgz",
"integrity": "sha512-mel+jf7nrtEl5Pn1Qx46zARXKDpBbvzezse7p7LqINmdoIk8PYP5SySaxEmYv6TZ0JyEKA1hsCId6DIhgITtWQ==",
"requires": {
"ms": "^2.1.1"
}
},
"ms": {
"version": "2.1.2",
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz",
"integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w=="
}
}
},
"@sindresorhus/is": {
"version": "0.14.0",
"resolved": "https://registry.npmjs.org/@sindresorhus/is/-/is-0.14.0.tgz",
"integrity": "sha512-9NET910DNaIPngYnLLPeg+Ogzqsi9uM4mSboU5y6p8S5DzMTVEsJZrawi+BoDNUVBa2DhJqQYUFvMDfgU062LQ=="
},
"@solidity-parser/parser": {
"version": "0.8.2",
"resolved": "https://registry.npmjs.org/@solidity-parser/parser/-/parser-0.8.2.tgz",
"integrity": "sha512-8LySx3qrNXPgB5JiULfG10O3V7QTxI/TLzSw5hFQhXWSkVxZBAv4rZQ0sYgLEbc8g3L2lmnujj1hKul38Eu5NQ=="
},
"@szmarczak/http-timer": {
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/@szmarczak/http-timer/-/http-timer-1.1.2.tgz",
@ -984,6 +1097,15 @@
"mimic-response": "^1.0.0"
}
},
"color": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/color/-/color-3.0.0.tgz",
"integrity": "sha512-jCpd5+s0s0t7p3pHQKpnJ0TpQKKdleP71LWcA0aqiljpiuAkOSUFN/dyH8ZwF0hRmFlrIuRhufds1QyEP9EB+w==",
"requires": {
"color-convert": "^1.9.1",
"color-string": "^1.5.2"
}
},
"color-convert": {
"version": "1.9.3",
"resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz",
@ -997,6 +1119,29 @@
"resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz",
"integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU="
},
"color-string": {
"version": "1.5.4",
"resolved": "https://registry.npmjs.org/color-string/-/color-string-1.5.4.tgz",
"integrity": "sha512-57yF5yt8Xa3czSEW1jfQDE79Idk0+AkN/4KWad6tbdxUmAs3MvjxlWSWD4deYytcRfoZ9nhKyFl1kj5tBvidbw==",
"requires": {
"color-name": "^1.0.0",
"simple-swizzle": "^0.2.2"
}
},
"colors": {
"version": "1.4.0",
"resolved": "https://registry.npmjs.org/colors/-/colors-1.4.0.tgz",
"integrity": "sha512-a+UqTh4kgZg/SlGvfbzDHpgRu7AAQOmmqRHJnxhRZICKFUT91brVhNNt58CMWU9PsBbv3PDCZUHbVxuDiH2mtA=="
},
"colorspace": {
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/colorspace/-/colorspace-1.1.2.tgz",
"integrity": "sha512-vt+OoIP2d76xLhjwbBaucYlNSpPsrJWPlBTtwCpQKIu6/CSMutyzX93O/Do0qzpH3YoHEes8YEFXyZ797rEhzQ==",
"requires": {
"color": "3.0.x",
"text-hex": "1.0.x"
}
},
"combined-stream": {
"version": "1.0.8",
"resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz",
@ -1295,6 +1440,11 @@
"resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-7.0.3.tgz",
"integrity": "sha512-CwBLREIQ7LvYFB0WyRvwhq5N5qPhc6PMjD6bYggFlI5YyDgl+0vxq5VHbMOFqLg7hfWzmu8T5Z1QofhmTIhItA=="
},
"enabled": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/enabled/-/enabled-2.0.0.tgz",
"integrity": "sha512-AKrN98kuwOzMIdAizXGI86UFBoo26CL21UM763y1h/GMSJ4/OHU9k2YlsmBpyScFo/wbLzWQJBMCW4+IO3/+OQ=="
},
"encodeurl": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-1.0.2.tgz",
@ -1999,6 +2149,11 @@
"resolved": "https://registry.npmjs.org/fast-safe-stringify/-/fast-safe-stringify-2.0.7.tgz",
"integrity": "sha512-Utm6CdzT+6xsDk2m8S6uL8VHxNwI6Jub+e9NYTcAms28T84pTa25GJQV9j0CY0N1rM8hK4x6grpF2BQf+2qwVA=="
},
"fecha": {
"version": "4.2.0",
"resolved": "https://registry.npmjs.org/fecha/-/fecha-4.2.0.tgz",
"integrity": "sha512-aN3pcx/DSmtyoovUudctc8+6Hl4T+hI9GBBHLjA76jdZl7+b1sgh5g4k+u/GL3dTy1/pnYzKp69FpJ0OicE3Wg=="
},
"fetch-ponyfill": {
"version": "4.1.0",
"resolved": "https://registry.npmjs.org/fetch-ponyfill/-/fetch-ponyfill-4.1.0.tgz",
@ -2051,6 +2206,11 @@
"is-buffer": "~2.0.3"
}
},
"fn.name": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/fn.name/-/fn.name-1.1.0.tgz",
"integrity": "sha512-GRnmB5gPyJpAhTQdSZTSp9uaPSvl09KoYcMQtsB9rQoOmzs9dH6ffeccH+Z+cv6P68Hu5bC6JjRh4Ah/mHSNRw=="
},
"forever-agent": {
"version": "0.6.1",
"resolved": "https://registry.npmjs.org/forever-agent/-/forever-agent-0.6.1.tgz",
@ -2285,6 +2445,11 @@
"minimalistic-crypto-utils": "^1.0.1"
}
},
"hosted-git-info": {
"version": "2.8.8",
"resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-2.8.8.tgz",
"integrity": "sha512-f/wzC2QaWBs7t9IYqB4T3sR1xviIViXJRJTWBlx2Gf3g0Xi5vI7Yy4koXQ1c9OYDGHN9sBy1DQ2AB8fqZBWhUg=="
},
"http-cache-semantics": {
"version": "4.1.0",
"resolved": "https://registry.npmjs.org/http-cache-semantics/-/http-cache-semantics-4.1.0.tgz",
@ -2381,6 +2546,11 @@
"resolved": "https://registry.npmjs.org/is-arguments/-/is-arguments-1.0.4.tgz",
"integrity": "sha512-xPh0Rmt8NE65sNzvyUmWgI1tz3mKq74lGA0mL8LYZcoIzKOzDh6HmrYm3d18k60nHerC8A9Km8kYu87zfSFnLA=="
},
"is-arrayish": {
"version": "0.3.2",
"resolved": "https://registry.npmjs.org/is-arrayish/-/is-arrayish-0.3.2.tgz",
"integrity": "sha512-eVRqCvVlZbuw3GrM63ovNSNAeA1K16kaR/LRY/92w0zxQ5/1YzwblUX652i4Xs9RwAGjW9d9y6X88t8OaAJfWQ=="
},
"is-binary-path": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/is-binary-path/-/is-binary-path-2.1.0.tgz",
@ -2638,6 +2808,11 @@
"json-buffer": "3.0.0"
}
},
"kuler": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/kuler/-/kuler-2.0.0.tgz",
"integrity": "sha512-Xq9nH7KlWZmXAtodXDDRE7vs6DU1gTU8zYDHDiWLSip45Egwq3plLHzPn27NgvzL2r1LMPC1vdqh98sQxtqj4A=="
},
"level-codec": {
"version": "7.0.1",
"resolved": "https://registry.npmjs.org/level-codec/-/level-codec-7.0.1.tgz",
@ -2755,6 +2930,25 @@
"chalk": "^2.4.2"
}
},
"logform": {
"version": "2.2.0",
"resolved": "https://registry.npmjs.org/logform/-/logform-2.2.0.tgz",
"integrity": "sha512-N0qPlqfypFx7UHNn4B3lzS/b0uLqt2hmuoa+PpuXNYgozdJYAyauF5Ky0BWVjrxDlMWiT3qN4zPq3vVAfZy7Yg==",
"requires": {
"colors": "^1.2.1",
"fast-safe-stringify": "^2.0.4",
"fecha": "^4.2.0",
"ms": "^2.1.1",
"triple-beam": "^1.3.0"
},
"dependencies": {
"ms": {
"version": "2.1.2",
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz",
"integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w=="
}
}
},
"lowercase-keys": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/lowercase-keys/-/lowercase-keys-1.0.1.tgz",
@ -3169,6 +3363,14 @@
"wrappy": "1"
}
},
"one-time": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/one-time/-/one-time-1.0.0.tgz",
"integrity": "sha512-5DXOiRKwuSEcQ/l0kGCF6Q3jcADFv5tSmRaJck/OqkVFcOzutB134KRSfF0xDrL39MNnqxbHBbUUcjZIhTgb2g==",
"requires": {
"fn.name": "1.x.x"
}
},
"original-require": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/original-require/-/original-require-1.0.1.tgz",
@ -3700,6 +3902,14 @@
"simple-concat": "^1.0.0"
}
},
"simple-swizzle": {
"version": "0.2.2",
"resolved": "https://registry.npmjs.org/simple-swizzle/-/simple-swizzle-0.2.2.tgz",
"integrity": "sha1-pNprY1/8zMoz9w0Xy5JZLeleVXo=",
"requires": {
"is-arrayish": "^0.3.1"
}
},
"source-map": {
"version": "0.6.1",
"resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz",
@ -3735,6 +3945,11 @@
"tweetnacl": "~0.14.0"
}
},
"stack-trace": {
"version": "0.0.10",
"resolved": "https://registry.npmjs.org/stack-trace/-/stack-trace-0.0.10.tgz",
"integrity": "sha1-VHxws0fo0ytOEI6hoqFZ5f3eGcA="
},
"statuses": {
"version": "1.5.0",
"resolved": "https://registry.npmjs.org/statuses/-/statuses-1.5.0.tgz",
@ -3904,6 +4119,11 @@
}
}
},
"text-hex": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/text-hex/-/text-hex-1.0.0.tgz",
"integrity": "sha512-uuVGNWzgJ4yhRaNSiubPY7OjISw4sw4E5Uv0wbjp+OzcbmVU/rsT8ujgcXJhn9ypzsgr5vlzpPqP+MBBKcGvbg=="
},
"timed-out": {
"version": "4.0.1",
"resolved": "https://registry.npmjs.org/timed-out/-/timed-out-4.0.1.tgz",
@ -3941,6 +4161,11 @@
"punycode": "^2.1.1"
}
},
"triple-beam": {
"version": "1.3.0",
"resolved": "https://registry.npmjs.org/triple-beam/-/triple-beam-1.3.0.tgz",
"integrity": "sha512-XrHUvV5HpdLmIj4uVMxHggLbFSZYIn7HEWsqePZcI50pco+MPqJ50wMGY794X7AOOhxOBAjbkqfAbEe/QMp2Lw=="
},
"truffle": {
"version": "5.1.37",
"resolved": "https://registry.npmjs.org/truffle/-/truffle-5.1.37.tgz",
@ -3951,6 +4176,78 @@
"original-require": "1.0.1"
}
},
"truffle-export-abi": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/truffle-export-abi/-/truffle-export-abi-1.0.1.tgz",
"integrity": "sha512-wt2mAQdTNB4SrZjWzyU+/f65zDwBhyfIhoDkqG8DCAeyYq8Rsu8xqBPhSFFKrvdqG5xh1fzfPtkCpyscIw49yg==",
"requires": {
"lodash": "^4.17.11",
"minimist": "^1.2.0",
"winston": "^3.1.0"
}
},
"truffle-flattener": {
"version": "1.5.0",
"resolved": "https://registry.npmjs.org/truffle-flattener/-/truffle-flattener-1.5.0.tgz",
"integrity": "sha512-vmzWG/L5OXoNruMV6u2l2IaheI091e+t+fFCOR9sl46EE3epkSRIwGCmIP/EYDtPsFBIG7e6exttC9/GlfmxEQ==",
"requires": {
"@resolver-engine/imports-fs": "^0.2.2",
"@solidity-parser/parser": "^0.8.0",
"find-up": "^2.1.0",
"mkdirp": "^1.0.4",
"tsort": "0.0.1"
},
"dependencies": {
"find-up": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/find-up/-/find-up-2.1.0.tgz",
"integrity": "sha1-RdG35QbHF93UgndaK3eSCjwMV6c=",
"requires": {
"locate-path": "^2.0.0"
}
},
"locate-path": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/locate-path/-/locate-path-2.0.0.tgz",
"integrity": "sha1-K1aLJl7slExtnA3pw9u7ygNUzY4=",
"requires": {
"p-locate": "^2.0.0",
"path-exists": "^3.0.0"
}
},
"p-limit": {
"version": "1.3.0",
"resolved": "https://registry.npmjs.org/p-limit/-/p-limit-1.3.0.tgz",
"integrity": "sha512-vvcXsLAJ9Dr5rQOPk7toZQZJApBl2K4J6dANSsEuh6QI41JYcsS/qhTGa9ErIUUgK3WNQoJYvylxvjqmiqEA9Q==",
"requires": {
"p-try": "^1.0.0"
}
},
"p-locate": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/p-locate/-/p-locate-2.0.0.tgz",
"integrity": "sha1-IKAQOyIqcMj9OcwuWAaA893l7EM=",
"requires": {
"p-limit": "^1.1.0"
}
},
"p-try": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/p-try/-/p-try-1.0.0.tgz",
"integrity": "sha1-y8ec26+P1CKOE/Yh8rGiN8GyB7M="
},
"path-exists": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/path-exists/-/path-exists-3.0.0.tgz",
"integrity": "sha1-zg6+ql94yxiSXqfYENe1mwEP1RU="
}
}
},
"tsort": {
"version": "0.0.1",
"resolved": "https://registry.npmjs.org/tsort/-/tsort-0.0.1.tgz",
"integrity": "sha1-4igPXoF/i/QnVlf9D5rr1E9aJ4Y="
},
"tunnel-agent": {
"version": "0.6.0",
"resolved": "https://registry.npmjs.org/tunnel-agent/-/tunnel-agent-0.6.0.tgz",
@ -4429,6 +4726,53 @@
"string-width": "^1.0.2 || 2"
}
},
"winston": {
"version": "3.3.3",
"resolved": "https://registry.npmjs.org/winston/-/winston-3.3.3.tgz",
"integrity": "sha512-oEXTISQnC8VlSAKf1KYSSd7J6IWuRPQqDdo8eoRNaYKLvwSb5+79Z3Yi1lrl6KDpU6/VWaxpakDAtb1oQ4n9aw==",
"requires": {
"@dabh/diagnostics": "^2.0.2",
"async": "^3.1.0",
"is-stream": "^2.0.0",
"logform": "^2.2.0",
"one-time": "^1.0.0",
"readable-stream": "^3.4.0",
"stack-trace": "0.0.x",
"triple-beam": "^1.3.0",
"winston-transport": "^4.4.0"
},
"dependencies": {
"async": {
"version": "3.2.0",
"resolved": "https://registry.npmjs.org/async/-/async-3.2.0.tgz",
"integrity": "sha512-TR2mEZFVOj2pLStYxLht7TyfuRzaydfpxr3k9RpHIzMgw7A64dzsdqCxH1WJyQdoe8T10nDXd9wnEigmiuHIZw=="
},
"is-stream": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/is-stream/-/is-stream-2.0.0.tgz",
"integrity": "sha512-XCoy+WlUr7d1+Z8GgSuXmpuUFC9fOhRXglJMx+dwLKTkL44Cjd4W1Z5P+BQZpr+cR93aGP4S/s7Ftw6Nd/kiEw=="
},
"readable-stream": {
"version": "3.6.0",
"resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.0.tgz",
"integrity": "sha512-BViHy7LKeTz4oNnkcLJ+lVSL6vpiFeX6/d3oSH8zCW7UxP2onchk+vTGB143xuFjHS3deTgkKoXXymXqymiIdA==",
"requires": {
"inherits": "^2.0.3",
"string_decoder": "^1.1.1",
"util-deprecate": "^1.0.1"
}
}
}
},
"winston-transport": {
"version": "4.4.0",
"resolved": "https://registry.npmjs.org/winston-transport/-/winston-transport-4.4.0.tgz",
"integrity": "sha512-Lc7/p3GtqtqPBYYtS6KCN3c77/2QCev51DvcJKbkFPQNoj1sinkGwLGFDxkXY9J6p9+EPnYs+D90uwbnaiURTw==",
"requires": {
"readable-stream": "^2.3.7",
"triple-beam": "^1.2.0"
}
},
"workerpool": {
"version": "6.0.0",
"resolved": "https://registry.npmjs.org/workerpool/-/workerpool-6.0.0.tgz",

View File

@ -7,14 +7,17 @@
"test": "test"
},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
"test": "echo \"Error: no test specified\" && exit 1",
"compile": "truffle compile"
},
"author": "",
"license": "MIT",
"dependencies": {
"@truffle/hdwallet-provider": "^1.0.40",
"dotenv": "^8.2.0",
"truffle": "^5.1.37"
"truffle": "^5.1.37",
"truffle-export-abi": "^1.0.1",
"truffle-flattener": "^1.5.0"
},
"devDependencies": {
"@openzeppelin/contracts": "^3.2.0"

View File

@ -6,7 +6,7 @@ import (
"github.com/Secured-Finance/dione/contracts/aggregator"
stakingContract "github.com/Secured-Finance/dione/contracts/dioneStaking"
"github.com/Secured-Finance/dione/contracts/oracleemitter"
oracleEmitter "github.com/Secured-Finance/dione/contracts/oracleemitter"
"github.com/ethereum/go-ethereum/accounts/abi/bind"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/crypto"
@ -19,7 +19,7 @@ type EthereumClient struct {
client *ethclient.Client
ethAddress *common.Address
authTransactor *bind.TransactOpts
oracleEmitter *oracleemitter.OracleEmitterSession
oracleEmitter *oracleEmitter.OracleEmitterSession
aggregator *aggregator.AggregatorSession
dioneStaking *stakingContract.DioneStakingSession
}
@ -58,7 +58,7 @@ func (c *EthereumClient) Initialize(ctx context.Context, url, privateKey, oracle
c.authTransactor = authTransactor
c.ethAddress = &c.authTransactor.From
oracleEmitter, err := oracleemitter.NewOracleEmitter(common.HexToAddress(oracleEmitterContractAddress), client)
emitter, err := oracleEmitter.NewOracleEmitter(common.HexToAddress(oracleEmitterContractAddress), client)
if err != nil {
return err
}
@ -66,8 +66,8 @@ func (c *EthereumClient) Initialize(ctx context.Context, url, privateKey, oracle
if err != nil {
return err
}
c.oracleEmitter = &oracleemitter.OracleEmitterSession{
Contract: oracleEmitter,
c.oracleEmitter = &oracleEmitter.OracleEmitterSession{
Contract: emitter,
CallOpts: bind.CallOpts{
Pending: true,
From: authTransactor.From,
@ -103,69 +103,8 @@ func (c *EthereumClient) GetEthAddress() *common.Address {
return c.ethAddress
}
// // Balance returns the balance of the given ethereum address.
// func (c *EthereumClient) Balance(ctx context.Context, address string) (*big.Int, error) {
// ethereumAddress := common.HexToAddress(address)
// value, err := c.HttpClient.BalanceAt(ctx, ethereumAddress, nil)
// if err != nil {
// return nil, err
// }
// return value, nil
// }
// func (c *EthereumClient) SendTransaction(ctx context.Context, private_key, to string, amount int64) string {
// privateKey, err := crypto.HexToECDSA(private_key)
// if err != nil {
// c.Logger.Fatal("Failed to parse private key", err)
// }
// publicKey := privateKey.Public()
// publicKeyECDSA, ok := publicKey.(*ecdsa.PublicKey)
// if !ok {
// c.Logger.Fatal("Cannot assert type: publicKey is not of type *ecdsa.PublicKey", err)
// }
// fromAddress := crypto.PubkeyToAddress(*publicKeyECDSA)
// nonce, err := c.HttpClient.PendingNonceAt(ctx, fromAddress)
// if err != nil {
// c.Logger.Fatal("Failed to generate wallet nonce value", err)
// }
// value := big.NewInt(amount)
// gasLimit := uint64(21000) // in units
// gasPrice, err := c.HttpClient.SuggestGasPrice(ctx)
// if err != nil {
// c.Logger.Fatal("Failed to suggest new gas price", err)
// }
// toAddress := common.HexToAddress(to)
// var data []byte
// tx := types.NewTransaction(nonce, toAddress, value, gasLimit, gasPrice, data)
// chainID, err := c.HttpClient.NetworkID(ctx)
// if err != nil {
// c.Logger.Fatal("Failed to get network ID", err)
// }
// signedTx, err := types.SignTx(tx, types.NewEIP155Signer(chainID), privateKey)
// if err != nil {
// c.Logger.Fatal("Failed to sign transaction", err)
// }
// err = c.HttpClient.SendTransaction(ctx, signedTx)
// if err != nil {
// c.Logger.Fatal("Failed to send signed transaction", err)
// }
// TxHash := signedTx.Hash().Hex()
// c.Logger.Info("Transaction sent: %s", TxHash)
// return TxHash
// }
func (c *EthereumClient) SubscribeOnOracleEvents() (chan *oracleemitter.OracleEmitterNewOracleRequest, event.Subscription, error) {
resChan := make(chan *oracleemitter.OracleEmitterNewOracleRequest)
func (c *EthereumClient) SubscribeOnOracleEvents() (chan *oracleEmitter.OracleEmitterNewOracleRequest, event.Subscription, error) {
resChan := make(chan *oracleEmitter.OracleEmitterNewOracleRequest)
requestsFilter := c.oracleEmitter.Contract.OracleEmitterFilterer
subscription, err := requestsFilter.WatchNewOracleRequest(&bind.WatchOpts{
Start: nil, //last block

73
ethclient/wallet.go Normal file
View File

@ -0,0 +1,73 @@
package ethclient
import (
"context"
"crypto/ecdsa"
"math/big"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/crypto"
"github.com/sirupsen/logrus"
)
// // Balance returns the balance of the given ethereum address.
func (c *EthereumClient) Balance(ctx context.Context, address string) (*big.Int, error) {
ethereumAddress := common.HexToAddress(address)
value, err := c.client.BalanceAt(ctx, ethereumAddress, nil)
if err != nil {
return nil, err
}
return value, nil
}
func (c *EthereumClient) SendTransaction(ctx context.Context, private_key, to string, amount int64) string {
privateKey, err := crypto.HexToECDSA(private_key)
if err != nil {
logrus.Fatal("Failed to parse private key", err)
}
publicKey := privateKey.Public()
publicKeyECDSA, ok := publicKey.(*ecdsa.PublicKey)
if !ok {
logrus.Fatal("Cannot assert type: publicKey is not of type *ecdsa.PublicKey", err)
}
fromAddress := crypto.PubkeyToAddress(*publicKeyECDSA)
nonce, err := c.client.PendingNonceAt(ctx, fromAddress)
if err != nil {
logrus.Fatal("Failed to generate wallet nonce value", err)
}
value := big.NewInt(amount)
gasLimit := uint64(21000) // in units
gasPrice, err := c.client.SuggestGasPrice(ctx)
if err != nil {
logrus.Fatal("Failed to suggest new gas price", err)
}
toAddress := common.HexToAddress(to)
var data []byte
tx := types.NewTransaction(nonce, toAddress, value, gasLimit, gasPrice, data)
chainID, err := c.client.NetworkID(ctx)
if err != nil {
logrus.Fatal("Failed to get network ID", err)
}
signedTx, err := types.SignTx(tx, types.NewEIP155Signer(chainID), privateKey)
if err != nil {
logrus.Fatal("Failed to sign transaction", err)
}
err = c.client.SendTransaction(ctx, signedTx)
if err != nil {
logrus.Fatal("Failed to send signed transaction", err)
}
TxHash := signedTx.Hash().Hex()
logrus.Info("Transaction sent: %s", TxHash)
return TxHash
}

8
lib/net.go Normal file
View File

@ -0,0 +1,8 @@
package lib
import "encoding/base64"
func BasicAuth(username, password string) string {
auth := username + ":" + password
return base64.StdEncoding.EncodeToString([]byte(auth))
}

View File

@ -7,6 +7,7 @@ import (
"fmt"
"time"
"github.com/Secured-Finance/dione/solana"
"github.com/Secured-Finance/dione/types"
"github.com/Secured-Finance/dione/wallet"
@ -42,6 +43,7 @@ type Node struct {
Config *config.Config
Lotus *rpc.LotusClient
Ethereum *ethclient.EthereumClient
Solana *solana.SolanaClient
ConsensusManager *consensus.PBFTConsensusManager
Miner *consensus.Miner
Beacon beacon.BeaconNetworks
@ -135,6 +137,11 @@ func (n *Node) setupFilecoinClient() {
n.Lotus = lotus
}
func (n *Node) setupSolanaClient() {
solana := solana.NewSolanaClient()
n.Solana = solana
}
func (n *Node) setupPubsub() {
n.PubSubRouter = pb.NewPubSubRouter(n.Host, n.OracleTopic)
// wait for setting up pubsub

View File

@ -1,51 +1,52 @@
package rpc
import (
"bytes"
"encoding/json"
"fmt"
"net/http"
"github.com/Secured-Finance/dione/lib"
"github.com/sirupsen/logrus"
"github.com/valyala/fasthttp"
)
var filecoinURL = "https://filecoin.infura.io/"
// client implements the `Client` interface.
type LotusClient struct {
host string
jwt string
host string
projectID string
projectSecret string
}
// NewClient returns a new client.
func NewLotusClient(host string, token string) *LotusClient {
func NewLotusClient(pID, secret string) *LotusClient {
return &LotusClient{
host: host,
jwt: token,
host: filecoinURL,
projectID: pID,
projectSecret: secret,
}
}
func (c *LotusClient) GetMessage(txHash string) (*http.Response, error) {
requestBody := NewRequestBody("Filecoin.GetMessage")
func (c *LotusClient) GetMessage(txHash string) (*fasthttp.Response, error) {
req := fasthttp.AcquireRequest()
req.SetRequestURI(c.host)
req.Header.SetMethod("POST")
req.Header.SetContentType("application/json")
req.Header.Set("Authorization", "Basic "+lib.BasicAuth(c.projectID, c.projectSecret))
requestBody := NewRequestBody("Filecoin.ChainGetMessage")
requestBody.Params = append(requestBody.Params, txHash)
body, err := json.Marshal(requestBody)
if err != nil {
return nil, fmt.Errorf("Failed to marshal request body %v", err)
}
client := http.Client{}
req, err := http.NewRequest("POST", c.host, bytes.NewBuffer(body))
req.Header.Set("Content-Type", "application/json")
req.Header.Set("Authentication", "Bearer "+c.jwt)
if err != nil {
return nil, fmt.Errorf("Failed to construct lotus node rpc request %v", err)
req.AppendBody(body)
resp := fasthttp.AcquireResponse()
client := &fasthttp.Client{}
if err = client.Do(req, resp); err != nil {
logrus.Warn("Failed to construct filecoin node rpc request", err)
return nil, err
}
return client.Do(req)
}
// HandleRequest implements the `Client` interface.
func (c *LotusClient) HandleRequest(r *http.Request, data []byte) (*http.Response, error) {
client := http.Client{}
req, err := http.NewRequest("POST", c.host, bytes.NewBuffer(data))
req.Header.Set("Content-Type", "application/json")
req.Header.Set("Authentication", "Bearer "+c.jwt)
if err != nil {
return nil, fmt.Errorf("Failed to construct lotus node rpc request %v", err)
}
return client.Do(req)
bodyBytes := resp.Body()
logrus.Info(string(bodyBytes))
return resp, nil
}