From ec7c0125865ab102e549f5c50b64d83a9b623dc4 Mon Sep 17 00:00:00 2001 From: Egor Lysenko Date: Fri, 23 Feb 2024 23:54:05 +0400 Subject: [PATCH] move some code out of SFCLib to SFC --- contracts/sfc/SFC.sol | 41 ++++++++++++++++++++++++++++++++++++++++ contracts/sfc/SFCLib.sol | 41 ---------------------------------------- 2 files changed, 41 insertions(+), 41 deletions(-) diff --git a/contracts/sfc/SFC.sol b/contracts/sfc/SFC.sol index 7c57812..64d53ff 100644 --- a/contracts/sfc/SFC.sol +++ b/contracts/sfc/SFC.sol @@ -34,6 +34,43 @@ contract SFC is SFCBase, Version { _delegate(libAddress); } + /* + Getters + */ + + function getEpochValidatorIDs(uint256 epoch) public view returns (uint256[] memory) { + return getEpochSnapshot[epoch].validatorIDs; + } + + function getEpochReceivedStake(uint256 epoch, uint256 validatorID) public view returns (uint256) { + return getEpochSnapshot[epoch].receivedStake[validatorID]; + } + + function getEpochAccumulatedRewardPerToken(uint256 epoch, uint256 validatorID) public view returns (uint256) { + return getEpochSnapshot[epoch].accumulatedRewardPerToken[validatorID]; + } + + function getEpochAccumulatedUptime(uint256 epoch, uint256 validatorID) public view returns (uint256) { + return getEpochSnapshot[epoch].accumulatedUptime[validatorID]; + } + + function getEpochAccumulatedOriginatedTxsFee(uint256 epoch, uint256 validatorID) public view returns (uint256) { + return getEpochSnapshot[epoch].accumulatedOriginatedTxsFee[validatorID]; + } + + function getEpochOfflineTime(uint256 epoch, uint256 validatorID) public view returns (uint256) { + return getEpochSnapshot[epoch].offlineTime[validatorID]; + } + + function getEpochOfflineBlocks(uint256 epoch, uint256 validatorID) public view returns (uint256) { + return getEpochSnapshot[epoch].offlineBlocks[validatorID]; + } + + function rewardsStash(address delegator, uint256 validatorID) public view returns (uint256) { + Rewards memory stash = _rewardsStash[delegator][validatorID]; + return stash.lockupBaseReward.add(stash.lockupExtraReward).add(stash.unlockedReward); + } + /* Constructor */ @@ -73,6 +110,10 @@ contract SFC is SFCBase, Version { voteBookAddress = v; } + function updateSFTMFinalizer(address v) external onlyOwner { + sftmFinalizer = v; + } + function migrateValidatorPubkeyUniquenessFlag(uint256 start, uint256 end) external { for (uint256 vid = start; vid < end; vid++) { bytes memory pubkey = getValidatorPubkey[vid]; diff --git a/contracts/sfc/SFCLib.sol b/contracts/sfc/SFCLib.sol index 5dbce0d..e401249 100644 --- a/contracts/sfc/SFCLib.sol +++ b/contracts/sfc/SFCLib.sol @@ -19,43 +19,6 @@ contract SFCLib is SFCBase { event UpdatedSlashingRefundRatio(uint256 indexed validatorID, uint256 refundRatio); event RefundedSlashedLegacyDelegation(address indexed delegator, uint256 indexed validatorID, uint256 amount); - /* - Getters - */ - - function getEpochValidatorIDs(uint256 epoch) public view returns (uint256[] memory) { - return getEpochSnapshot[epoch].validatorIDs; - } - - function getEpochReceivedStake(uint256 epoch, uint256 validatorID) public view returns (uint256) { - return getEpochSnapshot[epoch].receivedStake[validatorID]; - } - - function getEpochAccumulatedRewardPerToken(uint256 epoch, uint256 validatorID) public view returns (uint256) { - return getEpochSnapshot[epoch].accumulatedRewardPerToken[validatorID]; - } - - function getEpochAccumulatedUptime(uint256 epoch, uint256 validatorID) public view returns (uint256) { - return getEpochSnapshot[epoch].accumulatedUptime[validatorID]; - } - - function getEpochAccumulatedOriginatedTxsFee(uint256 epoch, uint256 validatorID) public view returns (uint256) { - return getEpochSnapshot[epoch].accumulatedOriginatedTxsFee[validatorID]; - } - - function getEpochOfflineTime(uint256 epoch, uint256 validatorID) public view returns (uint256) { - return getEpochSnapshot[epoch].offlineTime[validatorID]; - } - - function getEpochOfflineBlocks(uint256 epoch, uint256 validatorID) public view returns (uint256) { - return getEpochSnapshot[epoch].offlineBlocks[validatorID]; - } - - function rewardsStash(address delegator, uint256 validatorID) public view returns (uint256) { - Rewards memory stash = _rewardsStash[delegator][validatorID]; - return stash.lockupBaseReward.add(stash.lockupExtraReward).add(stash.unlockedReward); - } - /* Constructor */ @@ -239,10 +202,6 @@ contract SFCLib is SFCBase { emit Withdrawn(delegator, toValidatorID, 0xffffffffff, amount); } - function updateSFTMFinalizer(address v) public onlyOwner { - sftmFinalizer = v; - } - function isSlashed(uint256 validatorID) view public returns (bool) { return getValidator[validatorID].status & CHEATER_MASK != 0; }