Skip to content

Commit

Permalink
move some code out of SFCLib to SFC
Browse files Browse the repository at this point in the history
  • Loading branch information
uprendis committed Feb 23, 2024
1 parent a617877 commit ec7c012
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 41 deletions.
41 changes: 41 additions & 0 deletions contracts/sfc/SFC.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down Expand Up @@ -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];
Expand Down
41 changes: 0 additions & 41 deletions contracts/sfc/SFCLib.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit ec7c012

Please sign in to comment.