add: integrate DioneStaking contract into ethereum client and node store
This commit is contained in:
parent
9b8c4eb012
commit
9219e483a1
@ -26,107 +26,107 @@ var (
|
||||
_ = event.NewSubscription
|
||||
)
|
||||
|
||||
// SmartcontractsABI is the input ABI used to generate the binding from.
|
||||
const SmartcontractsABI = "[{\"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\"}]"
|
||||
// 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\"}]"
|
||||
|
||||
// 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
|
||||
// Aggregator is an auto generated Go binding around an Ethereum contract.
|
||||
type Aggregator struct {
|
||||
AggregatorCaller // Read-only binding to the contract
|
||||
AggregatorTransactor // Write-only binding to the contract
|
||||
AggregatorFilterer // Log filterer for contract events
|
||||
}
|
||||
|
||||
// SmartcontractsCaller is an auto generated read-only Go binding around an Ethereum contract.
|
||||
type SmartcontractsCaller struct {
|
||||
// AggregatorCaller is an auto generated read-only Go binding around an Ethereum contract.
|
||||
type AggregatorCaller 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 {
|
||||
// AggregatorTransactor is an auto generated write-only Go binding around an Ethereum contract.
|
||||
type AggregatorTransactor 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 {
|
||||
// AggregatorFilterer is an auto generated log filtering Go binding around an Ethereum contract events.
|
||||
type AggregatorFilterer struct {
|
||||
contract *bind.BoundContract // Generic contract wrapper for the low level calls
|
||||
}
|
||||
|
||||
// SmartcontractsSession is an auto generated Go binding around an Ethereum contract,
|
||||
// AggregatorSession 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
|
||||
type AggregatorSession struct {
|
||||
Contract *Aggregator // 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,
|
||||
// AggregatorCallerSession 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
|
||||
type AggregatorCallerSession struct {
|
||||
Contract *AggregatorCaller // 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,
|
||||
// AggregatorTransactorSession 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
|
||||
type AggregatorTransactorSession struct {
|
||||
Contract *AggregatorTransactor // 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
|
||||
// AggregatorRaw is an auto generated low-level Go binding around an Ethereum contract.
|
||||
type AggregatorRaw struct {
|
||||
Contract *Aggregator // 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
|
||||
// AggregatorCallerRaw is an auto generated low-level read-only Go binding around an Ethereum contract.
|
||||
type AggregatorCallerRaw struct {
|
||||
Contract *AggregatorCaller // 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
|
||||
// AggregatorTransactorRaw is an auto generated low-level write-only Go binding around an Ethereum contract.
|
||||
type AggregatorTransactorRaw struct {
|
||||
Contract *AggregatorTransactor // 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)
|
||||
// NewAggregator creates a new instance of Aggregator, bound to a specific deployed contract.
|
||||
func NewAggregator(address common.Address, backend bind.ContractBackend) (*Aggregator, error) {
|
||||
contract, err := bindAggregator(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
|
||||
return &Aggregator{AggregatorCaller: AggregatorCaller{contract: contract}, AggregatorTransactor: AggregatorTransactor{contract: contract}, AggregatorFilterer: AggregatorFilterer{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)
|
||||
// NewAggregatorCaller creates a new read-only instance of Aggregator, bound to a specific deployed contract.
|
||||
func NewAggregatorCaller(address common.Address, caller bind.ContractCaller) (*AggregatorCaller, error) {
|
||||
contract, err := bindAggregator(address, caller, nil, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &SmartcontractsCaller{contract: contract}, nil
|
||||
return &AggregatorCaller{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)
|
||||
// NewAggregatorTransactor creates a new write-only instance of Aggregator, bound to a specific deployed contract.
|
||||
func NewAggregatorTransactor(address common.Address, transactor bind.ContractTransactor) (*AggregatorTransactor, error) {
|
||||
contract, err := bindAggregator(address, nil, transactor, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &SmartcontractsTransactor{contract: contract}, nil
|
||||
return &AggregatorTransactor{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)
|
||||
// NewAggregatorFilterer creates a new log filterer instance of Aggregator, bound to a specific deployed contract.
|
||||
func NewAggregatorFilterer(address common.Address, filterer bind.ContractFilterer) (*AggregatorFilterer, error) {
|
||||
contract, err := bindAggregator(address, nil, nil, filterer)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &SmartcontractsFilterer{contract: contract}, nil
|
||||
return &AggregatorFilterer{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))
|
||||
// bindAggregator binds a generic wrapper to an already deployed contract.
|
||||
func bindAggregator(address common.Address, caller bind.ContractCaller, transactor bind.ContractTransactor, filterer bind.ContractFilterer) (*bind.BoundContract, error) {
|
||||
parsed, err := abi.JSON(strings.NewReader(AggregatorABI))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -137,57 +137,57 @@ func bindSmartcontracts(address common.Address, caller bind.ContractCaller, tran
|
||||
// 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...)
|
||||
func (_Aggregator *AggregatorRaw) Call(opts *bind.CallOpts, result interface{}, method string, params ...interface{}) error {
|
||||
return _Aggregator.Contract.AggregatorCaller.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)
|
||||
func (_Aggregator *AggregatorRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) {
|
||||
return _Aggregator.Contract.AggregatorTransactor.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...)
|
||||
func (_Aggregator *AggregatorRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) {
|
||||
return _Aggregator.Contract.AggregatorTransactor.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...)
|
||||
func (_Aggregator *AggregatorCallerRaw) Call(opts *bind.CallOpts, result interface{}, method string, params ...interface{}) error {
|
||||
return _Aggregator.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)
|
||||
func (_Aggregator *AggregatorTransactorRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) {
|
||||
return _Aggregator.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...)
|
||||
func (_Aggregator *AggregatorTransactorRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) {
|
||||
return _Aggregator.Contract.contract.Transact(opts, method, params...)
|
||||
}
|
||||
|
||||
// CollectData is a paid mutator transaction binding the contract method 0x05187092.
|
||||
//
|
||||
// Solidity: function collectData(uint256 reqID, string data, address callbackAddress, bytes4 callbackMethodID) returns()
|
||||
func (_Smartcontracts *SmartcontractsTransactor) CollectData(opts *bind.TransactOpts, reqID *big.Int, data string, callbackAddress common.Address, callbackMethodID [4]byte) (*types.Transaction, error) {
|
||||
return _Smartcontracts.contract.Transact(opts, "collectData", reqID, data, callbackAddress, callbackMethodID)
|
||||
func (_Aggregator *AggregatorTransactor) CollectData(opts *bind.TransactOpts, reqID *big.Int, data string, callbackAddress common.Address, callbackMethodID [4]byte) (*types.Transaction, error) {
|
||||
return _Aggregator.contract.Transact(opts, "collectData", reqID, data, callbackAddress, callbackMethodID)
|
||||
}
|
||||
|
||||
// CollectData is a paid mutator transaction binding the contract method 0x05187092.
|
||||
//
|
||||
// Solidity: function collectData(uint256 reqID, string data, address callbackAddress, bytes4 callbackMethodID) returns()
|
||||
func (_Smartcontracts *SmartcontractsSession) CollectData(reqID *big.Int, data string, callbackAddress common.Address, callbackMethodID [4]byte) (*types.Transaction, error) {
|
||||
return _Smartcontracts.Contract.CollectData(&_Smartcontracts.TransactOpts, reqID, data, callbackAddress, callbackMethodID)
|
||||
func (_Aggregator *AggregatorSession) 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)
|
||||
}
|
||||
|
||||
// CollectData is a paid mutator transaction binding the contract method 0x05187092.
|
||||
//
|
||||
// Solidity: function collectData(uint256 reqID, string data, address callbackAddress, bytes4 callbackMethodID) returns()
|
||||
func (_Smartcontracts *SmartcontractsTransactorSession) CollectData(reqID *big.Int, data string, callbackAddress common.Address, callbackMethodID [4]byte) (*types.Transaction, error) {
|
||||
return _Smartcontracts.Contract.CollectData(&_Smartcontracts.TransactOpts, reqID, data, callbackAddress, callbackMethodID)
|
||||
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)
|
||||
}
|
||||
|
1172
contracts/dioneStaking/DioneStaking.go
Normal file
1172
contracts/dioneStaking/DioneStaking.go
Normal file
File diff suppressed because it is too large
Load Diff
@ -26,107 +26,107 @@ var (
|
||||
_ = event.NewSubscription
|
||||
)
|
||||
|
||||
// SmartcontractsABI is the input ABI used to generate the binding from.
|
||||
const SmartcontractsABI = "[{\"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\"}]"
|
||||
// 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\"}]"
|
||||
|
||||
// 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
|
||||
// OracleEmitter is an auto generated Go binding around an Ethereum contract.
|
||||
type OracleEmitter struct {
|
||||
OracleEmitterCaller // Read-only binding to the contract
|
||||
OracleEmitterTransactor // Write-only binding to the contract
|
||||
OracleEmitterFilterer // Log filterer for contract events
|
||||
}
|
||||
|
||||
// SmartcontractsCaller is an auto generated read-only Go binding around an Ethereum contract.
|
||||
type SmartcontractsCaller struct {
|
||||
// OracleEmitterCaller is an auto generated read-only Go binding around an Ethereum contract.
|
||||
type OracleEmitterCaller 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 {
|
||||
// OracleEmitterTransactor is an auto generated write-only Go binding around an Ethereum contract.
|
||||
type OracleEmitterTransactor 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 {
|
||||
// OracleEmitterFilterer is an auto generated log filtering Go binding around an Ethereum contract events.
|
||||
type OracleEmitterFilterer struct {
|
||||
contract *bind.BoundContract // Generic contract wrapper for the low level calls
|
||||
}
|
||||
|
||||
// SmartcontractsSession is an auto generated Go binding around an Ethereum contract,
|
||||
// OracleEmitterSession 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
|
||||
type OracleEmitterSession struct {
|
||||
Contract *OracleEmitter // 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,
|
||||
// OracleEmitterCallerSession 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
|
||||
type OracleEmitterCallerSession struct {
|
||||
Contract *OracleEmitterCaller // 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,
|
||||
// OracleEmitterTransactorSession 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
|
||||
type OracleEmitterTransactorSession struct {
|
||||
Contract *OracleEmitterTransactor // 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
|
||||
// OracleEmitterRaw is an auto generated low-level Go binding around an Ethereum contract.
|
||||
type OracleEmitterRaw struct {
|
||||
Contract *OracleEmitter // 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
|
||||
// OracleEmitterCallerRaw is an auto generated low-level read-only Go binding around an Ethereum contract.
|
||||
type OracleEmitterCallerRaw struct {
|
||||
Contract *OracleEmitterCaller // 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
|
||||
// OracleEmitterTransactorRaw is an auto generated low-level write-only Go binding around an Ethereum contract.
|
||||
type OracleEmitterTransactorRaw struct {
|
||||
Contract *OracleEmitterTransactor // 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)
|
||||
// NewOracleEmitter creates a new instance of OracleEmitter, bound to a specific deployed contract.
|
||||
func NewOracleEmitter(address common.Address, backend bind.ContractBackend) (*OracleEmitter, error) {
|
||||
contract, err := bindOracleEmitter(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
|
||||
return &OracleEmitter{OracleEmitterCaller: OracleEmitterCaller{contract: contract}, OracleEmitterTransactor: OracleEmitterTransactor{contract: contract}, OracleEmitterFilterer: OracleEmitterFilterer{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)
|
||||
// NewOracleEmitterCaller creates a new read-only instance of OracleEmitter, bound to a specific deployed contract.
|
||||
func NewOracleEmitterCaller(address common.Address, caller bind.ContractCaller) (*OracleEmitterCaller, error) {
|
||||
contract, err := bindOracleEmitter(address, caller, nil, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &SmartcontractsCaller{contract: contract}, nil
|
||||
return &OracleEmitterCaller{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)
|
||||
// NewOracleEmitterTransactor creates a new write-only instance of OracleEmitter, bound to a specific deployed contract.
|
||||
func NewOracleEmitterTransactor(address common.Address, transactor bind.ContractTransactor) (*OracleEmitterTransactor, error) {
|
||||
contract, err := bindOracleEmitter(address, nil, transactor, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &SmartcontractsTransactor{contract: contract}, nil
|
||||
return &OracleEmitterTransactor{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)
|
||||
// NewOracleEmitterFilterer creates a new log filterer instance of OracleEmitter, bound to a specific deployed contract.
|
||||
func NewOracleEmitterFilterer(address common.Address, filterer bind.ContractFilterer) (*OracleEmitterFilterer, error) {
|
||||
contract, err := bindOracleEmitter(address, nil, nil, filterer)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &SmartcontractsFilterer{contract: contract}, nil
|
||||
return &OracleEmitterFilterer{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))
|
||||
// bindOracleEmitter binds a generic wrapper to an already deployed contract.
|
||||
func bindOracleEmitter(address common.Address, caller bind.ContractCaller, transactor bind.ContractTransactor, filterer bind.ContractFilterer) (*bind.BoundContract, error) {
|
||||
parsed, err := abi.JSON(strings.NewReader(OracleEmitterABI))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -137,64 +137,64 @@ func bindSmartcontracts(address common.Address, caller bind.ContractCaller, tran
|
||||
// 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...)
|
||||
func (_OracleEmitter *OracleEmitterRaw) Call(opts *bind.CallOpts, result interface{}, method string, params ...interface{}) error {
|
||||
return _OracleEmitter.Contract.OracleEmitterCaller.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)
|
||||
func (_OracleEmitter *OracleEmitterRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) {
|
||||
return _OracleEmitter.Contract.OracleEmitterTransactor.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...)
|
||||
func (_OracleEmitter *OracleEmitterRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) {
|
||||
return _OracleEmitter.Contract.OracleEmitterTransactor.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...)
|
||||
func (_OracleEmitter *OracleEmitterCallerRaw) Call(opts *bind.CallOpts, result interface{}, method string, params ...interface{}) error {
|
||||
return _OracleEmitter.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)
|
||||
func (_OracleEmitter *OracleEmitterTransactorRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) {
|
||||
return _OracleEmitter.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...)
|
||||
func (_OracleEmitter *OracleEmitterTransactorRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) {
|
||||
return _OracleEmitter.Contract.contract.Transact(opts, method, params...)
|
||||
}
|
||||
|
||||
// RequestOracles is a paid mutator transaction binding the contract method 0xcae2f480.
|
||||
//
|
||||
// Solidity: function requestOracles(string requestType, address callbackAddress, bytes4 callbackMethodID) returns(uint256)
|
||||
func (_Smartcontracts *SmartcontractsTransactor) RequestOracles(opts *bind.TransactOpts, requestType string, callbackAddress common.Address, callbackMethodID [4]byte) (*types.Transaction, error) {
|
||||
return _Smartcontracts.contract.Transact(opts, "requestOracles", requestType, callbackAddress, callbackMethodID)
|
||||
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)
|
||||
}
|
||||
|
||||
// RequestOracles is a paid mutator transaction binding the contract method 0xcae2f480.
|
||||
//
|
||||
// Solidity: function requestOracles(string requestType, address callbackAddress, bytes4 callbackMethodID) returns(uint256)
|
||||
func (_Smartcontracts *SmartcontractsSession) RequestOracles(requestType string, callbackAddress common.Address, callbackMethodID [4]byte) (*types.Transaction, error) {
|
||||
return _Smartcontracts.Contract.RequestOracles(&_Smartcontracts.TransactOpts, requestType, callbackAddress, callbackMethodID)
|
||||
func (_OracleEmitter *OracleEmitterSession) RequestOracles(requestType string, callbackAddress common.Address, callbackMethodID [4]byte) (*types.Transaction, error) {
|
||||
return _OracleEmitter.Contract.RequestOracles(&_OracleEmitter.TransactOpts, requestType, callbackAddress, callbackMethodID)
|
||||
}
|
||||
|
||||
// RequestOracles is a paid mutator transaction binding the contract method 0xcae2f480.
|
||||
//
|
||||
// Solidity: function requestOracles(string requestType, address callbackAddress, bytes4 callbackMethodID) returns(uint256)
|
||||
func (_Smartcontracts *SmartcontractsTransactorSession) RequestOracles(requestType string, callbackAddress common.Address, callbackMethodID [4]byte) (*types.Transaction, error) {
|
||||
return _Smartcontracts.Contract.RequestOracles(&_Smartcontracts.TransactOpts, requestType, callbackAddress, callbackMethodID)
|
||||
func (_OracleEmitter *OracleEmitterTransactorSession) RequestOracles(requestType string, callbackAddress common.Address, callbackMethodID [4]byte) (*types.Transaction, error) {
|
||||
return _OracleEmitter.Contract.RequestOracles(&_OracleEmitter.TransactOpts, requestType, callbackAddress, callbackMethodID)
|
||||
}
|
||||
|
||||
// SmartcontractsNewOracleRequestIterator is returned from FilterNewOracleRequest and is used to iterate over the raw logs and unpacked data for NewOracleRequest events raised by the Smartcontracts contract.
|
||||
type SmartcontractsNewOracleRequestIterator struct {
|
||||
Event *SmartcontractsNewOracleRequest // Event containing the contract specifics and raw log
|
||||
// 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.
|
||||
type OracleEmitterNewOracleRequestIterator struct {
|
||||
Event *OracleEmitterNewOracleRequest // 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
|
||||
@ -208,7 +208,7 @@ type SmartcontractsNewOracleRequestIterator struct {
|
||||
// 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 *SmartcontractsNewOracleRequestIterator) Next() bool {
|
||||
func (it *OracleEmitterNewOracleRequestIterator) Next() bool {
|
||||
// If the iterator failed, stop iterating
|
||||
if it.fail != nil {
|
||||
return false
|
||||
@ -217,7 +217,7 @@ func (it *SmartcontractsNewOracleRequestIterator) Next() bool {
|
||||
if it.done {
|
||||
select {
|
||||
case log := <-it.logs:
|
||||
it.Event = new(SmartcontractsNewOracleRequest)
|
||||
it.Event = new(OracleEmitterNewOracleRequest)
|
||||
if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil {
|
||||
it.fail = err
|
||||
return false
|
||||
@ -232,7 +232,7 @@ func (it *SmartcontractsNewOracleRequestIterator) Next() bool {
|
||||
// Iterator still in progress, wait for either a data or an error event
|
||||
select {
|
||||
case log := <-it.logs:
|
||||
it.Event = new(SmartcontractsNewOracleRequest)
|
||||
it.Event = new(OracleEmitterNewOracleRequest)
|
||||
if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil {
|
||||
it.fail = err
|
||||
return false
|
||||
@ -248,19 +248,19 @@ func (it *SmartcontractsNewOracleRequestIterator) Next() bool {
|
||||
}
|
||||
|
||||
// Error returns any retrieval or parsing error occurred during filtering.
|
||||
func (it *SmartcontractsNewOracleRequestIterator) Error() error {
|
||||
func (it *OracleEmitterNewOracleRequestIterator) Error() error {
|
||||
return it.fail
|
||||
}
|
||||
|
||||
// Close terminates the iteration process, releasing any pending underlying
|
||||
// resources.
|
||||
func (it *SmartcontractsNewOracleRequestIterator) Close() error {
|
||||
func (it *OracleEmitterNewOracleRequestIterator) Close() error {
|
||||
it.sub.Unsubscribe()
|
||||
return nil
|
||||
}
|
||||
|
||||
// SmartcontractsNewOracleRequest represents a NewOracleRequest event raised by the Smartcontracts contract.
|
||||
type SmartcontractsNewOracleRequest struct {
|
||||
// OracleEmitterNewOracleRequest represents a NewOracleRequest event raised by the OracleEmitter contract.
|
||||
type OracleEmitterNewOracleRequest struct {
|
||||
RequestType string
|
||||
CallbackAddress common.Address
|
||||
CallbackMethodID [4]byte
|
||||
@ -271,21 +271,21 @@ type SmartcontractsNewOracleRequest struct {
|
||||
// FilterNewOracleRequest is a free log retrieval operation binding the contract event 0xc1a7df69ed0404441720a3eb710f322985ecbbe4f31934587bee703efe04427a.
|
||||
//
|
||||
// Solidity: event NewOracleRequest(string requestType, address callbackAddress, bytes4 callbackMethodID, uint256 requestID)
|
||||
func (_Smartcontracts *SmartcontractsFilterer) FilterNewOracleRequest(opts *bind.FilterOpts) (*SmartcontractsNewOracleRequestIterator, error) {
|
||||
func (_OracleEmitter *OracleEmitterFilterer) FilterNewOracleRequest(opts *bind.FilterOpts) (*OracleEmitterNewOracleRequestIterator, error) {
|
||||
|
||||
logs, sub, err := _Smartcontracts.contract.FilterLogs(opts, "NewOracleRequest")
|
||||
logs, sub, err := _OracleEmitter.contract.FilterLogs(opts, "NewOracleRequest")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &SmartcontractsNewOracleRequestIterator{contract: _Smartcontracts.contract, event: "NewOracleRequest", logs: logs, sub: sub}, nil
|
||||
return &OracleEmitterNewOracleRequestIterator{contract: _OracleEmitter.contract, event: "NewOracleRequest", logs: logs, sub: sub}, nil
|
||||
}
|
||||
|
||||
// WatchNewOracleRequest is a free log subscription operation binding the contract event 0xc1a7df69ed0404441720a3eb710f322985ecbbe4f31934587bee703efe04427a.
|
||||
//
|
||||
// Solidity: event NewOracleRequest(string requestType, address callbackAddress, bytes4 callbackMethodID, uint256 requestID)
|
||||
func (_Smartcontracts *SmartcontractsFilterer) WatchNewOracleRequest(opts *bind.WatchOpts, sink chan<- *SmartcontractsNewOracleRequest) (event.Subscription, error) {
|
||||
func (_OracleEmitter *OracleEmitterFilterer) WatchNewOracleRequest(opts *bind.WatchOpts, sink chan<- *OracleEmitterNewOracleRequest) (event.Subscription, error) {
|
||||
|
||||
logs, sub, err := _Smartcontracts.contract.WatchLogs(opts, "NewOracleRequest")
|
||||
logs, sub, err := _OracleEmitter.contract.WatchLogs(opts, "NewOracleRequest")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -295,8 +295,8 @@ func (_Smartcontracts *SmartcontractsFilterer) WatchNewOracleRequest(opts *bind.
|
||||
select {
|
||||
case log := <-logs:
|
||||
// New log arrived, parse the event and forward to the user
|
||||
event := new(SmartcontractsNewOracleRequest)
|
||||
if err := _Smartcontracts.contract.UnpackLog(event, "NewOracleRequest", log); err != nil {
|
||||
event := new(OracleEmitterNewOracleRequest)
|
||||
if err := _OracleEmitter.contract.UnpackLog(event, "NewOracleRequest", log); err != nil {
|
||||
return err
|
||||
}
|
||||
event.Raw = log
|
||||
@ -320,9 +320,9 @@ func (_Smartcontracts *SmartcontractsFilterer) WatchNewOracleRequest(opts *bind.
|
||||
// ParseNewOracleRequest is a log parse operation binding the contract event 0xc1a7df69ed0404441720a3eb710f322985ecbbe4f31934587bee703efe04427a.
|
||||
//
|
||||
// Solidity: event NewOracleRequest(string requestType, address callbackAddress, bytes4 callbackMethodID, uint256 requestID)
|
||||
func (_Smartcontracts *SmartcontractsFilterer) ParseNewOracleRequest(log types.Log) (*SmartcontractsNewOracleRequest, error) {
|
||||
event := new(SmartcontractsNewOracleRequest)
|
||||
if err := _Smartcontracts.contract.UnpackLog(event, "NewOracleRequest", log); err != nil {
|
||||
func (_OracleEmitter *OracleEmitterFilterer) ParseNewOracleRequest(log types.Log) (*OracleEmitterNewOracleRequest, error) {
|
||||
event := new(OracleEmitterNewOracleRequest)
|
||||
if err := _OracleEmitter.contract.UnpackLog(event, "NewOracleRequest", log); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return event, nil
|
||||
|
@ -1,7 +1,6 @@
|
||||
pragma solidity 0.6.12;
|
||||
|
||||
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
|
||||
import "@openzeppelin/contracts/token/ERC20/SafeERC20.sol";
|
||||
import "@openzeppelin/contracts/math/SafeMath.sol";
|
||||
import "@openzeppelin/contracts/access/Ownable.sol";
|
||||
import "@openzeppelin/contracts/utils/ReentrancyGuard.sol";
|
||||
@ -13,7 +12,6 @@ import "./DioneToken.sol";
|
||||
// The ownership of the contract would be transfered to 24 hours Timelock
|
||||
contract DioneStaking is Ownable, ReentrancyGuard {
|
||||
using SafeMath for uint256;
|
||||
using SafeERC20 for IERC20;
|
||||
|
||||
// MinerInfo contains total DIONEs staked by miner, how much tasks been already computed
|
||||
// and timestamp of first deposit
|
||||
@ -47,7 +45,7 @@ contract DioneStaking is Ownable, ReentrancyGuard {
|
||||
address _aggregatorAddr,
|
||||
uint256 _minerReward,
|
||||
uint256 _startBlock,
|
||||
uint256 _minimumStake;
|
||||
uint256 _minimumStake
|
||||
) public {
|
||||
dione = _dione;
|
||||
aggregatorAddr = _aggregatorAddr;
|
||||
@ -60,31 +58,31 @@ contract DioneStaking is Ownable, ReentrancyGuard {
|
||||
function mine(address _minerAddr) public nonReentrant {
|
||||
require(msg.sender == aggregatorAddr, "not aggregator contract");
|
||||
MinerInfo storage miner = minerInfo[_minerAddr];
|
||||
require(miner.amount >= minimumStake)
|
||||
require(miner.amount >= minimumStake);
|
||||
dione.mint(_minerAddr, minerReward);
|
||||
miner.lastRewardBlock = block.number;
|
||||
emit Mine(_minerAddr, block.number)
|
||||
emit Mine(_minerAddr, block.number);
|
||||
}
|
||||
|
||||
// Mine new dione oracle task and stake miner reward, only can be executed by aggregator contract
|
||||
function mineAndStake(address _minerAddr) public nonReentrant {
|
||||
require(msg.sender == aggregatorAddr, "not aggregator contract");
|
||||
MinerInfo storage miner = minerInfo[_minerAddr];
|
||||
require(miner.amount >= minimumStake)
|
||||
require(miner.amount >= minimumStake);
|
||||
dione.mint(address(this), minerReward);
|
||||
_totalStake = _totalStake.add(minerReward);
|
||||
miner.amount = miner.amount.add(minerReward);
|
||||
miner.lastRewardBlock = block.number;
|
||||
emit Mine(_minerAddr, block.number)
|
||||
emit Mine(_minerAddr, block.number);
|
||||
}
|
||||
|
||||
// Deposit DIONE tokens to mine on dione network
|
||||
function stake(uint256 _amount) public nonReentrant {
|
||||
require(_amount > 0, "Cannot stake 0");
|
||||
MinerInfo storage miner = minerInfo[msg.sender];
|
||||
_totalStake = _totalStake.add(amount);
|
||||
_totalStake = _totalStake.add(_amount);
|
||||
miner.amount = miner.amount.add(_amount);
|
||||
dione.safeTransferFrom(address(msg.sender), address(this), _amount);
|
||||
dione.transferFrom(address(msg.sender), address(this), _amount);
|
||||
if (miner.firstStakeBlock == 0 && miner.amount >= minimumStake) {
|
||||
miner.firstStakeBlock = block.number > startBlock ? block.number : startBlock;
|
||||
}
|
||||
@ -96,9 +94,9 @@ contract DioneStaking is Ownable, ReentrancyGuard {
|
||||
MinerInfo storage miner = minerInfo[msg.sender];
|
||||
require(miner.amount >= _amount, "withdraw: not enough tokens");
|
||||
if(_amount > 0) {
|
||||
_totalStake = _totalStake.sub(amount);
|
||||
_totalStake = _totalStake.sub(_amount);
|
||||
miner.amount = miner.amount.sub(_amount);
|
||||
dione.safeTransfer(address(msg.sender), _amount);
|
||||
dione.transfer(address(msg.sender), _amount);
|
||||
}
|
||||
emit Withdraw(msg.sender, _amount);
|
||||
}
|
||||
@ -110,7 +108,7 @@ contract DioneStaking is Ownable, ReentrancyGuard {
|
||||
|
||||
function minerStake(address _minerAddr) external view returns (uint256) {
|
||||
MinerInfo storage miner = minerInfo[_minerAddr];
|
||||
return miner.amount
|
||||
return miner.amount;
|
||||
}
|
||||
|
||||
// Update miner reward in DIONE tokens, only can be executed by owner of the contract
|
||||
|
1761
eth-contracts/package-lock.json
generated
1761
eth-contracts/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -15,5 +15,8 @@
|
||||
"@truffle/hdwallet-provider": "^1.0.40",
|
||||
"dotenv": "^8.2.0",
|
||||
"truffle": "^5.1.37"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@openzeppelin/contracts": "^3.2.0"
|
||||
}
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import (
|
||||
"context"
|
||||
"math/big"
|
||||
|
||||
stakingContract "github.com/Secured-Finance/dione/contracts/DioneStaking"
|
||||
"github.com/Secured-Finance/dione/contracts/aggregator"
|
||||
"github.com/Secured-Finance/dione/contracts/oracleemitter"
|
||||
"github.com/ethereum/go-ethereum/accounts/abi/bind"
|
||||
@ -13,11 +14,13 @@ import (
|
||||
"github.com/ethereum/go-ethereum/event"
|
||||
)
|
||||
|
||||
// TODO: change artifacts for other contracts
|
||||
type EthereumClient struct {
|
||||
client *ethclient.Client
|
||||
authTransactor *bind.TransactOpts
|
||||
oracleEmitter *oracleemitter.SmartcontractsSession
|
||||
aggregator *aggregator.SmartcontractsSession
|
||||
oracleEmitter *oracleemitter.OracleEmitterSession
|
||||
aggregator *aggregator.AggregatorSession
|
||||
dioneStaking *stakingContract.DioneStakingSession
|
||||
}
|
||||
|
||||
type OracleEvent struct {
|
||||
@ -53,15 +56,15 @@ func (c *EthereumClient) Initialize(ctx context.Context, url, privateKey, oracle
|
||||
authTransactor := bind.NewKeyedTransactor(ecdsaKey)
|
||||
c.authTransactor = authTransactor
|
||||
|
||||
oracleEmitter, err := oracleemitter.NewSmartcontracts(common.HexToAddress(oracleEmitterContractAddress), client)
|
||||
oracleEmitter, err := oracleemitter.NewOracleEmitter(common.HexToAddress(oracleEmitterContractAddress), client)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
aggregatorPlainSC, err := aggregator.NewSmartcontracts(common.HexToAddress(aggregatorContractAddress), client)
|
||||
aggregatorPlainSC, err := aggregator.NewAggregator(common.HexToAddress(aggregatorContractAddress), client)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
c.oracleEmitter = &oracleemitter.SmartcontractsSession{
|
||||
c.oracleEmitter = &oracleemitter.OracleEmitterSession{
|
||||
Contract: oracleEmitter,
|
||||
CallOpts: bind.CallOpts{
|
||||
Pending: true,
|
||||
@ -76,7 +79,7 @@ func (c *EthereumClient) Initialize(ctx context.Context, url, privateKey, oracle
|
||||
Context: context.Background(),
|
||||
},
|
||||
}
|
||||
c.aggregator = &aggregator.SmartcontractsSession{
|
||||
c.aggregator = &aggregator.AggregatorSession{
|
||||
Contract: aggregatorPlainSC,
|
||||
CallOpts: bind.CallOpts{
|
||||
Pending: true,
|
||||
@ -175,8 +178,8 @@ func (c *EthereumClient) Initialize(ctx context.Context, url, privateKey, oracle
|
||||
// return address
|
||||
// }
|
||||
|
||||
func (c *EthereumClient) SubscribeOnOracleEvents(incomingEventsChan chan *oracleemitter.SmartcontractsNewOracleRequest) (event.Subscription, error) {
|
||||
requestsFilter := c.oracleEmitter.Contract.SmartcontractsFilterer
|
||||
func (c *EthereumClient) SubscribeOnOracleEvents(incomingEventsChan chan *oracleemitter.OracleEmitterNewOracleRequest) (event.Subscription, error) {
|
||||
requestsFilter := c.oracleEmitter.Contract.OracleEmitterFilterer
|
||||
subscription, err := requestsFilter.WatchNewOracleRequest(&bind.WatchOpts{
|
||||
Start: nil, //last block
|
||||
Context: nil,
|
||||
@ -220,3 +223,19 @@ func (c *EthereumClient) SubmitRequestAnswer(reqID *big.Int, data string, callba
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *EthereumClient) GetTotalStake() (*big.Int, error) {
|
||||
totalStake, err := c.dioneStaking.TotalStake()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return totalStake, nil
|
||||
}
|
||||
|
||||
func (c *EthereumClient) GetMinerStake(minerAddress common.Address) (*big.Int, error) {
|
||||
minerStake, err := c.dioneStaking.MinerStake(minerAddress)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return minerStake, nil
|
||||
}
|
||||
|
@ -1,9 +1,45 @@
|
||||
package store
|
||||
|
||||
import "math/big"
|
||||
import (
|
||||
"math/big"
|
||||
|
||||
"github.com/Secured-Finance/dione/rpcclient"
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
)
|
||||
|
||||
// TODO: specify store for staking mechanism
|
||||
type StakeTokenInfo struct {
|
||||
TotalTokensStaked *big.Int
|
||||
NodeTokensStaked *big.Int
|
||||
type DioneStakeInfo struct {
|
||||
MinerStake *big.Int
|
||||
TotalStake *big.Int
|
||||
Ethereum *rpcclient.EthereumClient
|
||||
}
|
||||
|
||||
func NewDioneStakeInfo(minerStake, totalStake *big.Int, ethereumClient *rpcclient.EthereumClient) *DioneStakeInfo {
|
||||
return &DioneStakeInfo{
|
||||
MinerStake: minerStake,
|
||||
TotalStake: totalStake,
|
||||
Ethereum: ethereumClient,
|
||||
}
|
||||
}
|
||||
|
||||
func (d *DioneStakeInfo) UpdateMinerStake(minerAddress common.Address) error {
|
||||
minerStake, err := d.Ethereum.GetMinerStake(minerAddress)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
d.MinerStake = minerStake
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (d *DioneStakeInfo) UpdateTotalStake(minerAddress common.Address) error {
|
||||
totalStake, err := d.Ethereum.GetTotalStake()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
d.TotalStake = totalStake
|
||||
|
||||
return nil
|
||||
}
|
||||
|
@ -20,3 +20,5 @@ func NewStore(db *sql.DB, node *node.Node, genesisTs uint64) *Store {
|
||||
genesisTs: genesisTs,
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: connect data base; specify the table for stake storage; queries for stake storage
|
||||
|
Loading…
Reference in New Issue
Block a user