diff --git a/precompiles/distribution/IDistribution.abi b/precompiles/distribution/IDistribution.abi index b092e5aa..3986b34b 100644 --- a/precompiles/distribution/IDistribution.abi +++ b/precompiles/distribution/IDistribution.abi @@ -1,29 +1,4 @@ [ - { - "inputs": [], - "name": "CommunityPool", - "outputs": [ - { - "components": [ - { - "internalType": "string", - "name": "denom", - "type": "string" - }, - { - "internalType": "uint256", - "name": "amount", - "type": "uint256" - } - ], - "internalType": "struct DecCoin[]", - "name": "pool", - "type": "tuple[]" - } - ], - "stateMutability": "view", - "type": "function" - }, { "inputs": [ { @@ -158,30 +133,6 @@ "stateMutability": "view", "type": "function" }, - { - "inputs": [ - { - "internalType": "address", - "name": "depositor", - "type": "address" - }, - { - "internalType": "uint256", - "name": "amount", - "type": "uint256" - } - ], - "name": "fundCommunityPool", - "outputs": [ - { - "internalType": "bool", - "name": "success", - "type": "bool" - } - ], - "stateMutability": "nonpayable", - "type": "function" - }, { "inputs": [], "name": "params", @@ -219,11 +170,6 @@ }, { "inputs": [ - { - "internalType": "address", - "name": "delegatorAddress", - "type": "address" - }, { "internalType": "address", "name": "withdrawerAddress", @@ -455,11 +401,6 @@ }, { "inputs": [ - { - "internalType": "address", - "name": "delegatorAddress", - "type": "address" - }, { "internalType": "string", "name": "validatorAddress", @@ -490,13 +431,7 @@ "type": "function" }, { - "inputs": [ - { - "internalType": "address", - "name": "validatorAddress", - "type": "address" - } - ], + "inputs": [], "name": "withdrawValidatorCommission", "outputs": [ { diff --git a/precompiles/distribution/contract.go b/precompiles/distribution/contract.go index 3d7b54ae..68a30d98 100644 --- a/precompiles/distribution/contract.go +++ b/precompiles/distribution/contract.go @@ -30,7 +30,7 @@ var ( // DistributionMetaData contains all meta data concerning the Distribution contract. var DistributionMetaData = &bind.MetaData{ - ABI: "[{\"inputs\":[],\"name\":\"CommunityPool\",\"outputs\":[{\"components\":[{\"internalType\":\"string\",\"name\":\"denom\",\"type\":\"string\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"internalType\":\"structDecCoin[]\",\"name\":\"pool\",\"type\":\"tuple[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"delegatorAddress\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"validatorAddress\",\"type\":\"address\"}],\"name\":\"delegationRewards\",\"outputs\":[{\"components\":[{\"internalType\":\"string\",\"name\":\"denom\",\"type\":\"string\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"internalType\":\"structDecCoin[]\",\"name\":\"rewards\",\"type\":\"tuple[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"delegatorAddress\",\"type\":\"address\"}],\"name\":\"delegationTotalRewards\",\"outputs\":[{\"components\":[{\"internalType\":\"address\",\"name\":\"validatorAddress\",\"type\":\"address\"},{\"components\":[{\"internalType\":\"string\",\"name\":\"denom\",\"type\":\"string\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"internalType\":\"structDecCoin[]\",\"name\":\"reward\",\"type\":\"tuple[]\"}],\"internalType\":\"structDelegationDelegatorReward[]\",\"name\":\"rewards\",\"type\":\"tuple[]\"},{\"components\":[{\"internalType\":\"string\",\"name\":\"denom\",\"type\":\"string\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"internalType\":\"structDecCoin[]\",\"name\":\"total\",\"type\":\"tuple[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"delegatorAddress\",\"type\":\"address\"}],\"name\":\"delegatorValidators\",\"outputs\":[{\"internalType\":\"address[]\",\"name\":\"validators\",\"type\":\"address[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"delegatorAddress\",\"type\":\"address\"}],\"name\":\"delegatorWithdrawAddress\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"withdrawAddress\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"depositor\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"fundCommunityPool\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"success\",\"type\":\"bool\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"params\",\"outputs\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"communityTax\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"baseProposerReward\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"bonusProposerReward\",\"type\":\"uint256\"},{\"internalType\":\"bool\",\"name\":\"withdrawAddrEnabled\",\"type\":\"bool\"}],\"internalType\":\"structParams\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"delegatorAddress\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"withdrawerAddress\",\"type\":\"address\"}],\"name\":\"setWithdrawAddress\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"success\",\"type\":\"bool\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"string\",\"name\":\"validatorAddress\",\"type\":\"string\"}],\"name\":\"validatorCommission\",\"outputs\":[{\"components\":[{\"internalType\":\"string\",\"name\":\"denom\",\"type\":\"string\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"internalType\":\"structDecCoin[]\",\"name\":\"commission\",\"type\":\"tuple[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"validatorAddress\",\"type\":\"address\"}],\"name\":\"validatorDistributionInfo\",\"outputs\":[{\"components\":[{\"internalType\":\"address\",\"name\":\"operatorAddress\",\"type\":\"address\"},{\"components\":[{\"internalType\":\"string\",\"name\":\"denom\",\"type\":\"string\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"internalType\":\"structDecCoin[]\",\"name\":\"selfBondRewards\",\"type\":\"tuple[]\"},{\"components\":[{\"internalType\":\"string\",\"name\":\"denom\",\"type\":\"string\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"internalType\":\"structDecCoin[]\",\"name\":\"commission\",\"type\":\"tuple[]\"}],\"internalType\":\"structValidatorDistributionInfoResponse\",\"name\":\"distributionInfo\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"validatorAddress\",\"type\":\"address\"}],\"name\":\"validatorOutstandingRewards\",\"outputs\":[{\"components\":[{\"internalType\":\"string\",\"name\":\"denom\",\"type\":\"string\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"internalType\":\"structDecCoin[]\",\"name\":\"rewards\",\"type\":\"tuple[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"validatorAddress\",\"type\":\"address\"},{\"internalType\":\"uint64\",\"name\":\"startingHeight\",\"type\":\"uint64\"},{\"internalType\":\"uint64\",\"name\":\"endingHeight\",\"type\":\"uint64\"},{\"components\":[{\"internalType\":\"bytes\",\"name\":\"key\",\"type\":\"bytes\"},{\"internalType\":\"uint64\",\"name\":\"offset\",\"type\":\"uint64\"},{\"internalType\":\"uint64\",\"name\":\"limit\",\"type\":\"uint64\"},{\"internalType\":\"bool\",\"name\":\"countTotal\",\"type\":\"bool\"},{\"internalType\":\"bool\",\"name\":\"reverse\",\"type\":\"bool\"}],\"internalType\":\"structPageRequest\",\"name\":\"pageRequest\",\"type\":\"tuple\"}],\"name\":\"validatorSlashes\",\"outputs\":[{\"components\":[{\"internalType\":\"uint64\",\"name\":\"validatorPeriod\",\"type\":\"uint64\"},{\"internalType\":\"uint256\",\"name\":\"fraction\",\"type\":\"uint256\"}],\"internalType\":\"structValidatorSlashEvent[]\",\"name\":\"slashes\",\"type\":\"tuple[]\"},{\"components\":[{\"internalType\":\"bytes\",\"name\":\"nextKey\",\"type\":\"bytes\"},{\"internalType\":\"uint64\",\"name\":\"total\",\"type\":\"uint64\"}],\"internalType\":\"structPageResponse\",\"name\":\"pageResponse\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"delegatorAddress\",\"type\":\"address\"},{\"internalType\":\"string\",\"name\":\"validatorAddress\",\"type\":\"string\"}],\"name\":\"withdrawDelegatorRewards\",\"outputs\":[{\"components\":[{\"internalType\":\"string\",\"name\":\"denom\",\"type\":\"string\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"internalType\":\"structCoin[]\",\"name\":\"amount\",\"type\":\"tuple[]\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"validatorAddress\",\"type\":\"address\"}],\"name\":\"withdrawValidatorCommission\",\"outputs\":[{\"components\":[{\"internalType\":\"string\",\"name\":\"denom\",\"type\":\"string\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"internalType\":\"structCoin[]\",\"name\":\"amount\",\"type\":\"tuple[]\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]", + ABI: "[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"delegatorAddress\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"validatorAddress\",\"type\":\"address\"}],\"name\":\"delegationRewards\",\"outputs\":[{\"components\":[{\"internalType\":\"string\",\"name\":\"denom\",\"type\":\"string\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"internalType\":\"structDecCoin[]\",\"name\":\"rewards\",\"type\":\"tuple[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"delegatorAddress\",\"type\":\"address\"}],\"name\":\"delegationTotalRewards\",\"outputs\":[{\"components\":[{\"internalType\":\"address\",\"name\":\"validatorAddress\",\"type\":\"address\"},{\"components\":[{\"internalType\":\"string\",\"name\":\"denom\",\"type\":\"string\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"internalType\":\"structDecCoin[]\",\"name\":\"reward\",\"type\":\"tuple[]\"}],\"internalType\":\"structDelegationDelegatorReward[]\",\"name\":\"rewards\",\"type\":\"tuple[]\"},{\"components\":[{\"internalType\":\"string\",\"name\":\"denom\",\"type\":\"string\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"internalType\":\"structDecCoin[]\",\"name\":\"total\",\"type\":\"tuple[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"delegatorAddress\",\"type\":\"address\"}],\"name\":\"delegatorValidators\",\"outputs\":[{\"internalType\":\"address[]\",\"name\":\"validators\",\"type\":\"address[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"delegatorAddress\",\"type\":\"address\"}],\"name\":\"delegatorWithdrawAddress\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"withdrawAddress\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"params\",\"outputs\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"communityTax\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"baseProposerReward\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"bonusProposerReward\",\"type\":\"uint256\"},{\"internalType\":\"bool\",\"name\":\"withdrawAddrEnabled\",\"type\":\"bool\"}],\"internalType\":\"structParams\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"withdrawerAddress\",\"type\":\"address\"}],\"name\":\"setWithdrawAddress\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"success\",\"type\":\"bool\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"string\",\"name\":\"validatorAddress\",\"type\":\"string\"}],\"name\":\"validatorCommission\",\"outputs\":[{\"components\":[{\"internalType\":\"string\",\"name\":\"denom\",\"type\":\"string\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"internalType\":\"structDecCoin[]\",\"name\":\"commission\",\"type\":\"tuple[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"validatorAddress\",\"type\":\"address\"}],\"name\":\"validatorDistributionInfo\",\"outputs\":[{\"components\":[{\"internalType\":\"address\",\"name\":\"operatorAddress\",\"type\":\"address\"},{\"components\":[{\"internalType\":\"string\",\"name\":\"denom\",\"type\":\"string\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"internalType\":\"structDecCoin[]\",\"name\":\"selfBondRewards\",\"type\":\"tuple[]\"},{\"components\":[{\"internalType\":\"string\",\"name\":\"denom\",\"type\":\"string\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"internalType\":\"structDecCoin[]\",\"name\":\"commission\",\"type\":\"tuple[]\"}],\"internalType\":\"structValidatorDistributionInfoResponse\",\"name\":\"distributionInfo\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"validatorAddress\",\"type\":\"address\"}],\"name\":\"validatorOutstandingRewards\",\"outputs\":[{\"components\":[{\"internalType\":\"string\",\"name\":\"denom\",\"type\":\"string\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"internalType\":\"structDecCoin[]\",\"name\":\"rewards\",\"type\":\"tuple[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"validatorAddress\",\"type\":\"address\"},{\"internalType\":\"uint64\",\"name\":\"startingHeight\",\"type\":\"uint64\"},{\"internalType\":\"uint64\",\"name\":\"endingHeight\",\"type\":\"uint64\"},{\"components\":[{\"internalType\":\"bytes\",\"name\":\"key\",\"type\":\"bytes\"},{\"internalType\":\"uint64\",\"name\":\"offset\",\"type\":\"uint64\"},{\"internalType\":\"uint64\",\"name\":\"limit\",\"type\":\"uint64\"},{\"internalType\":\"bool\",\"name\":\"countTotal\",\"type\":\"bool\"},{\"internalType\":\"bool\",\"name\":\"reverse\",\"type\":\"bool\"}],\"internalType\":\"structPageRequest\",\"name\":\"pageRequest\",\"type\":\"tuple\"}],\"name\":\"validatorSlashes\",\"outputs\":[{\"components\":[{\"internalType\":\"uint64\",\"name\":\"validatorPeriod\",\"type\":\"uint64\"},{\"internalType\":\"uint256\",\"name\":\"fraction\",\"type\":\"uint256\"}],\"internalType\":\"structValidatorSlashEvent[]\",\"name\":\"slashes\",\"type\":\"tuple[]\"},{\"components\":[{\"internalType\":\"bytes\",\"name\":\"nextKey\",\"type\":\"bytes\"},{\"internalType\":\"uint64\",\"name\":\"total\",\"type\":\"uint64\"}],\"internalType\":\"structPageResponse\",\"name\":\"pageResponse\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"string\",\"name\":\"validatorAddress\",\"type\":\"string\"}],\"name\":\"withdrawDelegatorRewards\",\"outputs\":[{\"components\":[{\"internalType\":\"string\",\"name\":\"denom\",\"type\":\"string\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"internalType\":\"structCoin[]\",\"name\":\"amount\",\"type\":\"tuple[]\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"withdrawValidatorCommission\",\"outputs\":[{\"components\":[{\"internalType\":\"string\",\"name\":\"denom\",\"type\":\"string\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"internalType\":\"structCoin[]\",\"name\":\"amount\",\"type\":\"tuple[]\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]", } // DistributionABI is the input ABI used to generate the binding from. @@ -179,37 +179,6 @@ func (_Distribution *DistributionTransactorRaw) Transact(opts *bind.TransactOpts return _Distribution.Contract.contract.Transact(opts, method, params...) } -// CommunityPool is a free data retrieval call binding the contract method 0x5637d7c9. -// -// Solidity: function CommunityPool() view returns((string,uint256)[] pool) -func (_Distribution *DistributionCaller) CommunityPool(opts *bind.CallOpts) ([]DecCoin, error) { - var out []interface{} - err := _Distribution.contract.Call(opts, &out, "CommunityPool") - - if err != nil { - return *new([]DecCoin), err - } - - out0 := *abi.ConvertType(out[0], new([]DecCoin)).(*[]DecCoin) - - return out0, err - -} - -// CommunityPool is a free data retrieval call binding the contract method 0x5637d7c9. -// -// Solidity: function CommunityPool() view returns((string,uint256)[] pool) -func (_Distribution *DistributionSession) CommunityPool() ([]DecCoin, error) { - return _Distribution.Contract.CommunityPool(&_Distribution.CallOpts) -} - -// CommunityPool is a free data retrieval call binding the contract method 0x5637d7c9. -// -// Solidity: function CommunityPool() view returns((string,uint256)[] pool) -func (_Distribution *DistributionCallerSession) CommunityPool() ([]DecCoin, error) { - return _Distribution.Contract.CommunityPool(&_Distribution.CallOpts) -} - // DelegationRewards is a free data retrieval call binding the contract method 0xc9a21b7b. // // Solidity: function delegationRewards(address delegatorAddress, address validatorAddress) view returns((string,uint256)[] rewards) @@ -517,86 +486,65 @@ func (_Distribution *DistributionCallerSession) ValidatorSlashes(validatorAddres return _Distribution.Contract.ValidatorSlashes(&_Distribution.CallOpts, validatorAddress, startingHeight, endingHeight, pageRequest) } -// FundCommunityPool is a paid mutator transaction binding the contract method 0xed41d0b6. +// SetWithdrawAddress is a paid mutator transaction binding the contract method 0x3ab1a494. // -// Solidity: function fundCommunityPool(address depositor, uint256 amount) returns(bool success) -func (_Distribution *DistributionTransactor) FundCommunityPool(opts *bind.TransactOpts, depositor common.Address, amount *big.Int) (*types.Transaction, error) { - return _Distribution.contract.Transact(opts, "fundCommunityPool", depositor, amount) +// Solidity: function setWithdrawAddress(address withdrawerAddress) returns(bool success) +func (_Distribution *DistributionTransactor) SetWithdrawAddress(opts *bind.TransactOpts, withdrawerAddress common.Address) (*types.Transaction, error) { + return _Distribution.contract.Transact(opts, "setWithdrawAddress", withdrawerAddress) } -// FundCommunityPool is a paid mutator transaction binding the contract method 0xed41d0b6. +// SetWithdrawAddress is a paid mutator transaction binding the contract method 0x3ab1a494. // -// Solidity: function fundCommunityPool(address depositor, uint256 amount) returns(bool success) -func (_Distribution *DistributionSession) FundCommunityPool(depositor common.Address, amount *big.Int) (*types.Transaction, error) { - return _Distribution.Contract.FundCommunityPool(&_Distribution.TransactOpts, depositor, amount) +// Solidity: function setWithdrawAddress(address withdrawerAddress) returns(bool success) +func (_Distribution *DistributionSession) SetWithdrawAddress(withdrawerAddress common.Address) (*types.Transaction, error) { + return _Distribution.Contract.SetWithdrawAddress(&_Distribution.TransactOpts, withdrawerAddress) } -// FundCommunityPool is a paid mutator transaction binding the contract method 0xed41d0b6. +// SetWithdrawAddress is a paid mutator transaction binding the contract method 0x3ab1a494. // -// Solidity: function fundCommunityPool(address depositor, uint256 amount) returns(bool success) -func (_Distribution *DistributionTransactorSession) FundCommunityPool(depositor common.Address, amount *big.Int) (*types.Transaction, error) { - return _Distribution.Contract.FundCommunityPool(&_Distribution.TransactOpts, depositor, amount) +// Solidity: function setWithdrawAddress(address withdrawerAddress) returns(bool success) +func (_Distribution *DistributionTransactorSession) SetWithdrawAddress(withdrawerAddress common.Address) (*types.Transaction, error) { + return _Distribution.Contract.SetWithdrawAddress(&_Distribution.TransactOpts, withdrawerAddress) } -// SetWithdrawAddress is a paid mutator transaction binding the contract method 0xe59a2f99. +// WithdrawDelegatorRewards is a paid mutator transaction binding the contract method 0x6636125e. // -// Solidity: function setWithdrawAddress(address delegatorAddress, address withdrawerAddress) returns(bool success) -func (_Distribution *DistributionTransactor) SetWithdrawAddress(opts *bind.TransactOpts, delegatorAddress common.Address, withdrawerAddress common.Address) (*types.Transaction, error) { - return _Distribution.contract.Transact(opts, "setWithdrawAddress", delegatorAddress, withdrawerAddress) +// Solidity: function withdrawDelegatorRewards(string validatorAddress) returns((string,uint256)[] amount) +func (_Distribution *DistributionTransactor) WithdrawDelegatorRewards(opts *bind.TransactOpts, validatorAddress string) (*types.Transaction, error) { + return _Distribution.contract.Transact(opts, "withdrawDelegatorRewards", validatorAddress) } -// SetWithdrawAddress is a paid mutator transaction binding the contract method 0xe59a2f99. +// WithdrawDelegatorRewards is a paid mutator transaction binding the contract method 0x6636125e. // -// Solidity: function setWithdrawAddress(address delegatorAddress, address withdrawerAddress) returns(bool success) -func (_Distribution *DistributionSession) SetWithdrawAddress(delegatorAddress common.Address, withdrawerAddress common.Address) (*types.Transaction, error) { - return _Distribution.Contract.SetWithdrawAddress(&_Distribution.TransactOpts, delegatorAddress, withdrawerAddress) +// Solidity: function withdrawDelegatorRewards(string validatorAddress) returns((string,uint256)[] amount) +func (_Distribution *DistributionSession) WithdrawDelegatorRewards(validatorAddress string) (*types.Transaction, error) { + return _Distribution.Contract.WithdrawDelegatorRewards(&_Distribution.TransactOpts, validatorAddress) } -// SetWithdrawAddress is a paid mutator transaction binding the contract method 0xe59a2f99. +// WithdrawDelegatorRewards is a paid mutator transaction binding the contract method 0x6636125e. // -// Solidity: function setWithdrawAddress(address delegatorAddress, address withdrawerAddress) returns(bool success) -func (_Distribution *DistributionTransactorSession) SetWithdrawAddress(delegatorAddress common.Address, withdrawerAddress common.Address) (*types.Transaction, error) { - return _Distribution.Contract.SetWithdrawAddress(&_Distribution.TransactOpts, delegatorAddress, withdrawerAddress) +// Solidity: function withdrawDelegatorRewards(string validatorAddress) returns((string,uint256)[] amount) +func (_Distribution *DistributionTransactorSession) WithdrawDelegatorRewards(validatorAddress string) (*types.Transaction, error) { + return _Distribution.Contract.WithdrawDelegatorRewards(&_Distribution.TransactOpts, validatorAddress) } -// WithdrawDelegatorRewards is a paid mutator transaction binding the contract method 0xb46a8d61. +// WithdrawValidatorCommission is a paid mutator transaction binding the contract method 0x0bde076d. // -// Solidity: function withdrawDelegatorRewards(address delegatorAddress, string validatorAddress) returns((string,uint256)[] amount) -func (_Distribution *DistributionTransactor) WithdrawDelegatorRewards(opts *bind.TransactOpts, delegatorAddress common.Address, validatorAddress string) (*types.Transaction, error) { - return _Distribution.contract.Transact(opts, "withdrawDelegatorRewards", delegatorAddress, validatorAddress) +// Solidity: function withdrawValidatorCommission() returns((string,uint256)[] amount) +func (_Distribution *DistributionTransactor) WithdrawValidatorCommission(opts *bind.TransactOpts) (*types.Transaction, error) { + return _Distribution.contract.Transact(opts, "withdrawValidatorCommission") } -// WithdrawDelegatorRewards is a paid mutator transaction binding the contract method 0xb46a8d61. +// WithdrawValidatorCommission is a paid mutator transaction binding the contract method 0x0bde076d. // -// Solidity: function withdrawDelegatorRewards(address delegatorAddress, string validatorAddress) returns((string,uint256)[] amount) -func (_Distribution *DistributionSession) WithdrawDelegatorRewards(delegatorAddress common.Address, validatorAddress string) (*types.Transaction, error) { - return _Distribution.Contract.WithdrawDelegatorRewards(&_Distribution.TransactOpts, delegatorAddress, validatorAddress) +// Solidity: function withdrawValidatorCommission() returns((string,uint256)[] amount) +func (_Distribution *DistributionSession) WithdrawValidatorCommission() (*types.Transaction, error) { + return _Distribution.Contract.WithdrawValidatorCommission(&_Distribution.TransactOpts) } -// WithdrawDelegatorRewards is a paid mutator transaction binding the contract method 0xb46a8d61. +// WithdrawValidatorCommission is a paid mutator transaction binding the contract method 0x0bde076d. // -// Solidity: function withdrawDelegatorRewards(address delegatorAddress, string validatorAddress) returns((string,uint256)[] amount) -func (_Distribution *DistributionTransactorSession) WithdrawDelegatorRewards(delegatorAddress common.Address, validatorAddress string) (*types.Transaction, error) { - return _Distribution.Contract.WithdrawDelegatorRewards(&_Distribution.TransactOpts, delegatorAddress, validatorAddress) -} - -// WithdrawValidatorCommission is a paid mutator transaction binding the contract method 0x11fc0bfe. -// -// Solidity: function withdrawValidatorCommission(address validatorAddress) returns((string,uint256)[] amount) -func (_Distribution *DistributionTransactor) WithdrawValidatorCommission(opts *bind.TransactOpts, validatorAddress common.Address) (*types.Transaction, error) { - return _Distribution.contract.Transact(opts, "withdrawValidatorCommission", validatorAddress) -} - -// WithdrawValidatorCommission is a paid mutator transaction binding the contract method 0x11fc0bfe. -// -// Solidity: function withdrawValidatorCommission(address validatorAddress) returns((string,uint256)[] amount) -func (_Distribution *DistributionSession) WithdrawValidatorCommission(validatorAddress common.Address) (*types.Transaction, error) { - return _Distribution.Contract.WithdrawValidatorCommission(&_Distribution.TransactOpts, validatorAddress) -} - -// WithdrawValidatorCommission is a paid mutator transaction binding the contract method 0x11fc0bfe. -// -// Solidity: function withdrawValidatorCommission(address validatorAddress) returns((string,uint256)[] amount) -func (_Distribution *DistributionTransactorSession) WithdrawValidatorCommission(validatorAddress common.Address) (*types.Transaction, error) { - return _Distribution.Contract.WithdrawValidatorCommission(&_Distribution.TransactOpts, validatorAddress) +// Solidity: function withdrawValidatorCommission() returns((string,uint256)[] amount) +func (_Distribution *DistributionTransactorSession) WithdrawValidatorCommission() (*types.Transaction, error) { + return _Distribution.Contract.WithdrawValidatorCommission(&_Distribution.TransactOpts) } diff --git a/precompiles/distribution/distribution.go b/precompiles/distribution/distribution.go index e60ffa7f..155df56c 100644 --- a/precompiles/distribution/distribution.go +++ b/precompiles/distribution/distribution.go @@ -18,7 +18,6 @@ const ( DistributionFunctionSetWithdrawAddress = "setWithdrawAddress" DistributionFunctionWithdrawDelegatorRewards = "withdrawDelegatorRewards" DistributionFunctionWithdrawValidatorCommission = "withdrawValidatorCommission" - DistributionFunctionFundCommunityPool = "fundCommunityPool" // query DistributionFunctionParams = "params" DistributionFunctionValidatorDistributionInfo = "validatorDistributionInfo" @@ -29,7 +28,6 @@ const ( DistributionFunctionDelegationTotalRewards = "delegationTotalRewards" DistributionFunctionDelegatorValidators = "delegatorValidators" DistributionFunctionDelegatorWithdrawAddress = "delegatorWithdrawAddress" - DistributionFunctionCommunityPool = "CommunityPool" ) var _ vm.PrecompiledContract = &DistributionPrecompile{} @@ -69,8 +67,7 @@ func (d *DistributionPrecompile) IsTx(method string) bool { switch method { case DistributionFunctionSetWithdrawAddress, DistributionFunctionWithdrawDelegatorRewards, - DistributionFunctionWithdrawValidatorCommission, - DistributionFunctionFundCommunityPool: + DistributionFunctionWithdrawValidatorCommission: return true default: return false @@ -109,17 +106,13 @@ func (d *DistributionPrecompile) Run(evm *vm.EVM, contract *vm.Contract, readonl bz, err = d.DelegatorValidators(ctx, evm, method, args) case DistributionFunctionDelegatorWithdrawAddress: bz, err = d.DelegatorWithdrawAddress(ctx, evm, method, args) - case DistributionFunctionCommunityPool: - bz, err = d.CommunityPool(ctx, evm, method, args) // txs case DistributionFunctionSetWithdrawAddress: - bz, err = d.CreateValidator(ctx, evm, stateDB, contract, method, args) + bz, err = d.SetWithdrawAddress(ctx, evm, stateDB, contract, method, args) case DistributionFunctionWithdrawDelegatorRewards: - bz, err = d.EditValidator(ctx, evm, stateDB, contract, method, args) + bz, err = d.WithdrawDelegatorReward(ctx, evm, stateDB, contract, method, args) case DistributionFunctionWithdrawValidatorCommission: - bz, err = d.Delegate(ctx, evm, stateDB, contract, method, args) - case DistributionFunctionFundCommunityPool: - bz, err = d.BeginRedelegate(ctx, evm, stateDB, contract, method, args) + bz, err = d.WithdrawValidatorCommission(ctx, evm, stateDB, contract, method, args) } if err != nil { diff --git a/precompiles/distribution/query.go b/precompiles/distribution/query.go index 78e93ab7..70259912 100644 --- a/precompiles/distribution/query.go +++ b/precompiles/distribution/query.go @@ -156,17 +156,3 @@ func (d *DistributionPrecompile) DelegatorWithdrawAddress(ctx sdk.Context, _ *vm return method.Outputs.Pack(withdrawAddress) } - -func (d *DistributionPrecompile) CommunityPool(ctx sdk.Context, _ *vm.EVM, method *abi.Method, args []interface{}) ([]byte, error) { - req, err := NewQueryCommunityPoolRequest(args) - if err != nil { - return nil, err - } - - response, err := distributionkeeper.Querier{Keeper: d.distributionKeeper}.CommunityPool(ctx, req) - if err != nil { - return nil, err - } - - return method.Outputs.Pack(convertCommunityPoolResponse(response)) -} diff --git a/precompiles/distribution/tx.go b/precompiles/distribution/tx.go new file mode 100644 index 00000000..83deb366 --- /dev/null +++ b/precompiles/distribution/tx.go @@ -0,0 +1,76 @@ +package distribution + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + + distributionkeeper "github.com/cosmos/cosmos-sdk/x/distribution/keeper" + "github.com/ethereum/go-ethereum/accounts/abi" + "github.com/ethereum/go-ethereum/core/vm" + "github.com/evmos/ethermint/x/evm/statedb" +) + +func (d *DistributionPrecompile) SetWithdrawAddress( + ctx sdk.Context, + evm *vm.EVM, + stateDB *statedb.StateDB, + contract *vm.Contract, + method *abi.Method, + args []interface{}, +) ([]byte, error) { + msg, err := NewMsgSetWithdrawAddress(args, contract.CallerAddress) + if err != nil { + return nil, err + } + // validation + // execute + _, err = distributionkeeper.NewMsgServerImpl(d.distributionKeeper).SetWithdrawAddress(ctx, msg) + if err != nil { + return nil, err + } + // emit events + return method.Outputs.Pack() +} + +func (d *DistributionPrecompile) WithdrawDelegatorReward( + ctx sdk.Context, + evm *vm.EVM, + stateDB *statedb.StateDB, + contract *vm.Contract, + method *abi.Method, + args []interface{}, +) ([]byte, error) { + msg, err := NewMsgWithdrawDelegatorReward(args, contract.CallerAddress) + if err != nil { + return nil, err + } + // validation + // execute + _, err = distributionkeeper.NewMsgServerImpl(d.distributionKeeper).WithdrawDelegatorReward(ctx, msg) + if err != nil { + return nil, err + } + // emit events + return method.Outputs.Pack() +} + +func (d *DistributionPrecompile) WithdrawValidatorCommission( + ctx sdk.Context, + evm *vm.EVM, + stateDB *statedb.StateDB, + contract *vm.Contract, + method *abi.Method, + args []interface{}, +) ([]byte, error) { + msg, err := NewMsgWithdrawValidatorCommission(args, contract.CallerAddress) + if err != nil { + return nil, err + } + // validation + // execute + _, err = distributionkeeper.NewMsgServerImpl(d.distributionKeeper).WithdrawValidatorCommission(ctx, msg) + if err != nil { + return nil, err + } + // emit events + return method.Outputs.Pack() +} diff --git a/precompiles/distribution/types.go b/precompiles/distribution/types.go index 811bfeeb..410ed984 100644 --- a/precompiles/distribution/types.go +++ b/precompiles/distribution/types.go @@ -303,3 +303,42 @@ func NewQueryCommunityPoolRequest(args []interface{}) (*distributiontypes.QueryC func convertCommunityPoolResponse(response *distributiontypes.QueryCommunityPoolResponse) []DecCoin { return convertDecCoins(response.Pool) } + +func NewMsgSetWithdrawAddress(args []interface{}, sender common.Address) (*distributiontypes.MsgSetWithdrawAddress, error) { + if len(args) != 1 { + return nil, fmt.Errorf(precompiles_common.ErrInvalidNumberOfArgs, 1, len(args)) + } + + withdrawAddress := args[0].(common.Address) + + msg := &distributiontypes.MsgSetWithdrawAddress{ + DelegatorAddress: sdk.AccAddress(sender.Bytes()).String(), + WithdrawAddress: sdk.AccAddress(withdrawAddress.Bytes()).String(), + } + return msg, msg.ValidateBasic() +} + +func NewMsgWithdrawDelegatorReward(args []interface{}, sender common.Address) (*distributiontypes.MsgWithdrawDelegatorReward, error) { + if len(args) != 1 { + return nil, fmt.Errorf(precompiles_common.ErrInvalidNumberOfArgs, 1, len(args)) + } + + validatorAddress := args[0].(common.Address) + + msg := &distributiontypes.MsgWithdrawDelegatorReward{ + DelegatorAddress: sdk.AccAddress(sender.Bytes()).String(), + ValidatorAddress: sdk.AccAddress(validatorAddress.Bytes()).String(), + } + return msg, msg.ValidateBasic() +} + +func NewMsgWithdrawValidatorCommission(args []interface{}, sender common.Address) (*distributiontypes.MsgWithdrawValidatorCommission, error) { + if len(args) != 0 { + return nil, fmt.Errorf(precompiles_common.ErrInvalidNumberOfArgs, 0, len(args)) + } + + msg := &distributiontypes.MsgWithdrawValidatorCommission{ + ValidatorAddress: sdk.AccAddress(sender.Bytes()).String(), + } + return msg, msg.ValidateBasic() +} diff --git a/precompiles/interfaces/contracts/IDistribution.sol b/precompiles/interfaces/contracts/IDistribution.sol index 99453089..6bf64621 100644 --- a/precompiles/interfaces/contracts/IDistribution.sol +++ b/precompiles/interfaces/contracts/IDistribution.sol @@ -33,38 +33,31 @@ interface IDistribution { /** * @dev SetWithdrawAddress defines a method to change the withdraw address for a delegator (or validator self-delegation). + * delegator address is msg.sener. + * * cosmos grpc: rpc SetWithdrawAddress(MsgSetWithdrawAddress) returns (MsgSetWithdrawAddressResponse); */ function setWithdrawAddress( - address delegatorAddress, address withdrawerAddress ) external returns (bool success); /** * @dev WithdrawDelegatorReward defines a method to withdraw rewards of delegator from a single validator. + * delegator address is msg.sender. + * * cosmos grpc: rpc WithdrawDelegatorReward(MsgWithdrawDelegatorReward) returns (MsgWithdrawDelegatorRewardResponse); */ function withdrawDelegatorRewards( - address delegatorAddress, string memory validatorAddress ) external returns (Coin[] calldata amount); /** * @dev WithdrawValidatorCommission defines a method to withdraw the full commission to the validator address. + * validator address is msg.sender. + * * cosmos grpc: rpc WithdrawValidatorCommission(MsgWithdrawValidatorCommission) returns (MsgWithdrawValidatorCommissionResponse); */ - function withdrawValidatorCommission( - address validatorAddress - ) external returns (Coin[] calldata amount); - - /** - * @dev FundCommunityPool defines a method to allow an account to directly fund the community pool. - * cosmos grpc: rpc FundCommunityPool(MsgFundCommunityPool) returns (MsgFundCommunityPoolResponse); - */ - function fundCommunityPool( - address depositor, - uint256 amount - ) external returns (bool success); + function withdrawValidatorCommission() external returns (Coin[] calldata amount); /*=== cosmos query ===*/ @@ -156,10 +149,4 @@ interface IDistribution { function delegatorWithdrawAddress( address delegatorAddress ) external view returns (address withdrawAddress); - - /** - * @dev CommunityPool queries the community pool coins. - * cosmos grpc: rpc CommunityPool(QueryCommunityPoolRequest) returns (QueryCommunityPoolResponse); - */ - function CommunityPool() external view returns (DecCoin[] memory pool); }