Skip to content

Commit ec7c012

Browse files
committed
move some code out of SFCLib to SFC
1 parent a617877 commit ec7c012

File tree

2 files changed

+41
-41
lines changed

2 files changed

+41
-41
lines changed

contracts/sfc/SFC.sol

+41
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,43 @@ contract SFC is SFCBase, Version {
3434
_delegate(libAddress);
3535
}
3636

37+
/*
38+
Getters
39+
*/
40+
41+
function getEpochValidatorIDs(uint256 epoch) public view returns (uint256[] memory) {
42+
return getEpochSnapshot[epoch].validatorIDs;
43+
}
44+
45+
function getEpochReceivedStake(uint256 epoch, uint256 validatorID) public view returns (uint256) {
46+
return getEpochSnapshot[epoch].receivedStake[validatorID];
47+
}
48+
49+
function getEpochAccumulatedRewardPerToken(uint256 epoch, uint256 validatorID) public view returns (uint256) {
50+
return getEpochSnapshot[epoch].accumulatedRewardPerToken[validatorID];
51+
}
52+
53+
function getEpochAccumulatedUptime(uint256 epoch, uint256 validatorID) public view returns (uint256) {
54+
return getEpochSnapshot[epoch].accumulatedUptime[validatorID];
55+
}
56+
57+
function getEpochAccumulatedOriginatedTxsFee(uint256 epoch, uint256 validatorID) public view returns (uint256) {
58+
return getEpochSnapshot[epoch].accumulatedOriginatedTxsFee[validatorID];
59+
}
60+
61+
function getEpochOfflineTime(uint256 epoch, uint256 validatorID) public view returns (uint256) {
62+
return getEpochSnapshot[epoch].offlineTime[validatorID];
63+
}
64+
65+
function getEpochOfflineBlocks(uint256 epoch, uint256 validatorID) public view returns (uint256) {
66+
return getEpochSnapshot[epoch].offlineBlocks[validatorID];
67+
}
68+
69+
function rewardsStash(address delegator, uint256 validatorID) public view returns (uint256) {
70+
Rewards memory stash = _rewardsStash[delegator][validatorID];
71+
return stash.lockupBaseReward.add(stash.lockupExtraReward).add(stash.unlockedReward);
72+
}
73+
3774
/*
3875
Constructor
3976
*/
@@ -73,6 +110,10 @@ contract SFC is SFCBase, Version {
73110
voteBookAddress = v;
74111
}
75112

113+
function updateSFTMFinalizer(address v) external onlyOwner {
114+
sftmFinalizer = v;
115+
}
116+
76117
function migrateValidatorPubkeyUniquenessFlag(uint256 start, uint256 end) external {
77118
for (uint256 vid = start; vid < end; vid++) {
78119
bytes memory pubkey = getValidatorPubkey[vid];

contracts/sfc/SFCLib.sol

-41
Original file line numberDiff line numberDiff line change
@@ -19,43 +19,6 @@ contract SFCLib is SFCBase {
1919
event UpdatedSlashingRefundRatio(uint256 indexed validatorID, uint256 refundRatio);
2020
event RefundedSlashedLegacyDelegation(address indexed delegator, uint256 indexed validatorID, uint256 amount);
2121

22-
/*
23-
Getters
24-
*/
25-
26-
function getEpochValidatorIDs(uint256 epoch) public view returns (uint256[] memory) {
27-
return getEpochSnapshot[epoch].validatorIDs;
28-
}
29-
30-
function getEpochReceivedStake(uint256 epoch, uint256 validatorID) public view returns (uint256) {
31-
return getEpochSnapshot[epoch].receivedStake[validatorID];
32-
}
33-
34-
function getEpochAccumulatedRewardPerToken(uint256 epoch, uint256 validatorID) public view returns (uint256) {
35-
return getEpochSnapshot[epoch].accumulatedRewardPerToken[validatorID];
36-
}
37-
38-
function getEpochAccumulatedUptime(uint256 epoch, uint256 validatorID) public view returns (uint256) {
39-
return getEpochSnapshot[epoch].accumulatedUptime[validatorID];
40-
}
41-
42-
function getEpochAccumulatedOriginatedTxsFee(uint256 epoch, uint256 validatorID) public view returns (uint256) {
43-
return getEpochSnapshot[epoch].accumulatedOriginatedTxsFee[validatorID];
44-
}
45-
46-
function getEpochOfflineTime(uint256 epoch, uint256 validatorID) public view returns (uint256) {
47-
return getEpochSnapshot[epoch].offlineTime[validatorID];
48-
}
49-
50-
function getEpochOfflineBlocks(uint256 epoch, uint256 validatorID) public view returns (uint256) {
51-
return getEpochSnapshot[epoch].offlineBlocks[validatorID];
52-
}
53-
54-
function rewardsStash(address delegator, uint256 validatorID) public view returns (uint256) {
55-
Rewards memory stash = _rewardsStash[delegator][validatorID];
56-
return stash.lockupBaseReward.add(stash.lockupExtraReward).add(stash.unlockedReward);
57-
}
58-
5922
/*
6023
Constructor
6124
*/
@@ -239,10 +202,6 @@ contract SFCLib is SFCBase {
239202
emit Withdrawn(delegator, toValidatorID, 0xffffffffff, amount);
240203
}
241204

242-
function updateSFTMFinalizer(address v) public onlyOwner {
243-
sftmFinalizer = v;
244-
}
245-
246205
function isSlashed(uint256 validatorID) view public returns (bool) {
247206
return getValidator[validatorID].status & CHEATER_MASK != 0;
248207
}

0 commit comments

Comments
 (0)