Skip to content

Commit baa177b

Browse files
committed
chore(review): renamed settlecommitment, updated docs and flatfile
1 parent ab42f18 commit baa177b

File tree

2 files changed

+67
-15
lines changed

2 files changed

+67
-15
lines changed

contracts/SinglePlayerCommit.sol

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ contract SinglePlayerCommit is ChainlinkClient, Ownable {
255255
require(commitment.endTime < block.timestamp, "SPC::processCommitment - commitment is still active");
256256
require(commitment.endTime < commitment.lastActivityUpdate, "SPC::processCommitment - update activity");
257257

258-
require(_commitmentSettlement(commitment), "SPC::processCommitmentUser - settlement failed");
258+
require(_settleCommitment(commitment), "SPC::processCommitmentUser - settlement failed");
259259

260260
emit CommitmentEnded(committer, commitment.met, commitment.stake);
261261
}
@@ -267,13 +267,13 @@ contract SinglePlayerCommit is ChainlinkClient, Ownable {
267267
require(commitments[msg.sender].exists, "SPC::processCommitmentUser - commitment does not exist");
268268
Commitment storage commitment = commitments[msg.sender];
269269

270-
require(_commitmentSettlement(commitment), "SPC::processCommitmentUser - settlement failed");
270+
require(_settleCommitment(commitment), "SPC::processCommitmentUser - settlement failed");
271271
emit CommitmentEnded(msg.sender, commitment.met, commitment.stake);
272272
}
273273

274274
/// @notice Internal function for evaluating commitment and slashing funds if needed
275275
/// @dev Receive call with commitment object from storage
276-
function _commitmentSettlement(Commitment storage commitment) internal returns (bool success) {
276+
function _settleCommitment(Commitment storage commitment) internal returns (bool success) {
277277
commitment.met = commitment.reportedValue > commitment.goalValue;
278278

279279
if (!commitment.met) {
@@ -287,7 +287,7 @@ contract SinglePlayerCommit is ChainlinkClient, Ownable {
287287
/// @notice Contract owner can withdraw funds not owned by committers. E.g. slashed from failed commitments
288288
/// @param amount Amount of <token> to withdraw
289289
/// @dev Check amount against slashedBalance, transfer amount and update slashedBalance
290-
function ownerWithdraw(uint256 amount) public onlyOwner returns (bool) {
290+
function ownerWithdraw(uint256 amount) public onlyOwner returns (bool success) {
291291
console.log("Received call for owner withdrawal for amount %s", amount);
292292

293293
require(amount <= slashedBalance, "SPC::ownerWithdraw - not enough available balance");
@@ -481,7 +481,7 @@ contract SinglePlayerCommit is ChainlinkClient, Ownable {
481481

482482
/// @notice Get address for ChainLink token contract
483483
/// @dev ChainLink contract method
484-
function getChainlinkToken() public view returns (address) {
484+
function getChainlinkToken() public view returns (address chainlinkTokenAddress) {
485485
return chainlinkTokenAddress();
486486
}
487487

out/SinglePlayerCommit_flat.sol

Lines changed: 62 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
/* SPDX-License-Identifier: MIT */
2-
pragma solidity 0.6.10;
3-
pragma experimental ABIEncoderV2;
1+
42
// File: https://github.com/smartcontractkit/chainlink/blob/master/evm-contracts/src/v0.6/vendor/SafeMathChainlink.sol
53

4+
pragma solidity ^0.6.0;
65

76
/**
87
* @dev Wrappers over Solidity's arithmetic operations with added overflow
@@ -112,18 +111,24 @@ library SafeMathChainlink {
112111

113112
// File: https://github.com/smartcontractkit/chainlink/blob/master/evm-contracts/src/v0.6/vendor/ENSResolver.sol
114113

114+
pragma solidity ^0.6.0;
115+
115116
abstract contract ENSResolver {
116117
function addr(bytes32 node) public view virtual returns (address);
117118
}
118119

119120
// File: https://github.com/smartcontractkit/chainlink/blob/master/evm-contracts/src/v0.6/interfaces/PointerInterface.sol
120121

122+
pragma solidity ^0.6.0;
123+
121124
interface PointerInterface {
122125
function getAddress() external view returns (address);
123126
}
124127

125128
// File: https://github.com/smartcontractkit/chainlink/blob/master/evm-contracts/src/v0.6/interfaces/ChainlinkRequestInterface.sol
126129

130+
pragma solidity ^0.6.0;
131+
127132
interface ChainlinkRequestInterface {
128133
function oracleRequest(
129134
address sender,
@@ -146,6 +151,8 @@ interface ChainlinkRequestInterface {
146151

147152
// File: https://github.com/smartcontractkit/chainlink/blob/master/evm-contracts/src/v0.6/interfaces/LinkTokenInterface.sol
148153

154+
pragma solidity ^0.6.0;
155+
149156
interface LinkTokenInterface {
150157
function allowance(address owner, address spender) external view returns (uint256 remaining);
151158
function approve(address spender, uint256 value) external returns (bool success);
@@ -163,6 +170,8 @@ interface LinkTokenInterface {
163170

164171
// File: https://github.com/smartcontractkit/chainlink/blob/master/evm-contracts/src/v0.6/interfaces/ENSInterface.sol
165172

173+
pragma solidity ^0.6.0;
174+
166175
interface ENSInterface {
167176

168177
// Logged when the owner of a node assigns a new owner to a subnode.
@@ -190,6 +199,8 @@ interface ENSInterface {
190199

191200
// File: https://github.com/smartcontractkit/chainlink/blob/master/evm-contracts/src/v0.6/vendor/BufferChainlink.sol
192201

202+
pragma solidity ^0.6.0;
203+
193204
/**
194205
* @dev A library for working with mutable byte buffers in Solidity.
195206
*
@@ -492,6 +503,8 @@ library BufferChainlink {
492503

493504
// File: https://github.com/smartcontractkit/chainlink/blob/master/evm-contracts/src/v0.6/vendor/CBORChainlink.sol
494505

506+
pragma solidity ^0.6.0;
507+
495508

496509
library CBORChainlink {
497510
using BufferChainlink for BufferChainlink.buffer;
@@ -563,6 +576,10 @@ library CBORChainlink {
563576

564577
// File: https://github.com/smartcontractkit/chainlink/blob/master/evm-contracts/src/v0.6/Chainlink.sol
565578

579+
pragma solidity ^0.6.0;
580+
581+
582+
566583
/**
567584
* @title Library for common Chainlink functions
568585
* @dev Uses imported CBOR library for encoding to buffer
@@ -687,6 +704,15 @@ library Chainlink {
687704

688705
// File: https://github.com/smartcontractkit/chainlink/blob/master/evm-contracts/src/v0.6/ChainlinkClient.sol
689706

707+
pragma solidity ^0.6.0;
708+
709+
710+
711+
712+
713+
714+
715+
690716
/**
691717
* @title The ChainlinkClient contract
692718
* @notice Contract writers can inherit this contract in order to create requests for the
@@ -866,7 +892,7 @@ contract ChainlinkClient {
866892
ens = ENSInterface(_ens);
867893
ensNode = _node;
868894
bytes32 linkSubnode = keccak256(abi.encodePacked(ensNode, ENS_TOKEN_SUBNAME));
869-
ENSResolver resolver = ENSResolver(ens.resolver(linkSubnode));
895+
ENSResolver_Chainlink resolver = ENSResolver_Chainlink(ens.resolver(linkSubnode));
870896
setChainlinkToken(resolver.addr(linkSubnode));
871897
updateChainlinkOracleWithENS();
872898
}
@@ -879,7 +905,7 @@ contract ChainlinkClient {
879905
internal
880906
{
881907
bytes32 oracleSubnode = keccak256(abi.encodePacked(ensNode, ENS_ORACLE_SUBNAME));
882-
ENSResolver resolver = ENSResolver(ens.resolver(oracleSubnode));
908+
ENSResolver_Chainlink resolver = ENSResolver_Chainlink(ens.resolver(oracleSubnode));
883909
setChainlinkOracle(resolver.addr(oracleSubnode));
884910
}
885911

@@ -943,6 +969,10 @@ contract ChainlinkClient {
943969

944970
// File: https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v3.1.0/contracts/token/ERC20/IERC20.sol
945971

972+
// SPDX-License-Identifier: MIT
973+
974+
pragma solidity ^0.6.0;
975+
946976
/**
947977
* @dev Interface of the ERC20 standard as defined in the EIP.
948978
*/
@@ -1019,6 +1049,10 @@ interface IERC20 {
10191049

10201050
// File: https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v3.1.0/contracts/GSN/Context.sol
10211051

1052+
// SPDX-License-Identifier: MIT
1053+
1054+
pragma solidity ^0.6.0;
1055+
10221056
/*
10231057
* @dev Provides information about the current execution context, including the
10241058
* sender of the transaction and its data. While these are generally available
@@ -1042,6 +1076,10 @@ abstract contract Context {
10421076

10431077
// File: https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v3.1.0/contracts/access/Ownable.sol
10441078

1079+
// SPDX-License-Identifier: MIT
1080+
1081+
pragma solidity ^0.6.0;
1082+
10451083
/**
10461084
* @dev Contract module which provides a basic access control mechanism, where
10471085
* there is an account (an owner) that can be granted exclusive access to
@@ -1108,6 +1146,9 @@ contract Ownable is Context {
11081146

11091147
// File: https://github.com/nomiclabs/hardhat/blob/master/packages/hardhat-core/console.sol
11101148

1149+
// SPDX-License-Identifier: MIT
1150+
pragma solidity >= 0.4.22 <0.8.0;
1151+
11111152
library console {
11121153
address constant CONSOLE_ADDRESS = address(0x000000000000000000636F6e736F6c652e6c6f67);
11131154

@@ -2643,6 +2684,17 @@ library console {
26432684
}
26442685

26452686
// File: browser/SinglePlayerCommit.sol
2687+
2688+
/* SPDX-License-Identifier: MIT */
2689+
pragma solidity 0.6.10;
2690+
pragma experimental ABIEncoderV2;
2691+
2692+
2693+
2694+
2695+
//https://github.com/smartcontractkit/chainlink/issues/3153#issuecomment-655241638
2696+
2697+
26462698
/// @title CommitPool single-player mode contract
26472699
/// @notice Enables staking and validating performance. No social/pool functionality.
26482700
contract SinglePlayerCommit is ChainlinkClient, Ownable {
@@ -2888,7 +2940,7 @@ contract SinglePlayerCommit is ChainlinkClient, Ownable {
28882940
require(commitment.endTime < block.timestamp, "SPC::processCommitment - commitment is still active");
28892941
require(commitment.endTime < commitment.lastActivityUpdate, "SPC::processCommitment - update activity");
28902942

2891-
require(_commitmentSettlement(commitment), "SPC::processCommitmentUser - settlement failed");
2943+
require(_settleCommitment(commitment), "SPC::processCommitmentUser - settlement failed");
28922944

28932945
emit CommitmentEnded(committer, commitment.met, commitment.stake);
28942946
}
@@ -2900,13 +2952,13 @@ contract SinglePlayerCommit is ChainlinkClient, Ownable {
29002952
require(commitments[msg.sender].exists, "SPC::processCommitmentUser - commitment does not exist");
29012953
Commitment storage commitment = commitments[msg.sender];
29022954

2903-
require(_commitmentSettlement(commitment), "SPC::processCommitmentUser - settlement failed");
2955+
require(_settleCommitment(commitment), "SPC::processCommitmentUser - settlement failed");
29042956
emit CommitmentEnded(msg.sender, commitment.met, commitment.stake);
29052957
}
29062958

29072959
/// @notice Internal function for evaluating commitment and slashing funds if needed
29082960
/// @dev Receive call with commitment object from storage
2909-
function _commitmentSettlement(Commitment storage commitment) internal returns (bool success) {
2961+
function _settleCommitment(Commitment storage commitment) internal returns (bool success) {
29102962
commitment.met = commitment.reportedValue > commitment.goalValue;
29112963

29122964
if (!commitment.met) {
@@ -2920,7 +2972,7 @@ contract SinglePlayerCommit is ChainlinkClient, Ownable {
29202972
/// @notice Contract owner can withdraw funds not owned by committers. E.g. slashed from failed commitments
29212973
/// @param amount Amount of <token> to withdraw
29222974
/// @dev Check amount against slashedBalance, transfer amount and update slashedBalance
2923-
function ownerWithdraw(uint256 amount) public onlyOwner returns (bool) {
2975+
function ownerWithdraw(uint256 amount) public onlyOwner returns (bool success) {
29242976
console.log("Received call for owner withdrawal for amount %s", amount);
29252977

29262978
require(amount <= slashedBalance, "SPC::ownerWithdraw - not enough available balance");
@@ -3114,7 +3166,7 @@ contract SinglePlayerCommit is ChainlinkClient, Ownable {
31143166

31153167
/// @notice Get address for ChainLink token contract
31163168
/// @dev ChainLink contract method
3117-
function getChainlinkToken() public view returns (address) {
3169+
function getChainlinkToken() public view returns (address tokenAddress) {
31183170
return chainlinkTokenAddress();
31193171
}
31203172

0 commit comments

Comments
 (0)