Merge pull request #2079 from vzotova/spdx-license

SPDX license identifier in contracts
pull/2085/head
K Prasch 2020-06-08 15:07:43 -07:00 committed by GitHub
commit 9fb5caee5f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
47 changed files with 223 additions and 36 deletions

View File

@ -15,4 +15,4 @@ You should have received a copy of the GNU Affero General Public License
along with nucypher. If not, see <https://www.gnu.org/licenses/>.
"""
SOLIDITY_COMPILER_VERSION = 'v0.6.7'
SOLIDITY_COMPILER_VERSION = 'v0.6.9'

View File

@ -1,5 +1,8 @@
// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity ^0.6.5;
// Minimum interface to interact with Aragon's Aggregator
interface IERC900History {
function totalStakedForAt(address addr, uint256 blockNumber) external view returns (uint256);

View File

@ -1,3 +1,5 @@
// SPDX-License-Identifier: AGPL-3.0-or-later
pragma solidity ^0.6.5;
import "contracts/lib/ReEncryptionValidator.sol";

View File

@ -1,3 +1,5 @@
// SPDX-License-Identifier: AGPL-3.0-or-later
pragma solidity ^0.6.5;

View File

@ -1,3 +1,5 @@
// SPDX-License-Identifier: AGPL-3.0-or-later
pragma solidity ^0.6.1;
@ -30,9 +32,7 @@ contract MultiSig {
_;
}
// TODO #1809
// receive() external payable {}
fallback() external payable {}
receive() external payable {}
/**
* @param _required Number of required signings

View File

@ -1,3 +1,5 @@
// SPDX-License-Identifier: AGPL-3.0-or-later
pragma solidity ^0.6.1;

View File

@ -1,3 +1,5 @@
// SPDX-License-Identifier: AGPL-3.0-or-later
pragma solidity ^0.6.5;

View File

@ -1,5 +1,8 @@
// SPDX-License-Identifier: AGPL-3.0-or-later
pragma solidity ^0.6.5;
import "aragon/interfaces/IERC900History.sol";
import "contracts/Issuer.sol";
import "contracts/lib/Bits.sol";

View File

@ -1,3 +1,5 @@
// SPDX-License-Identifier: AGPL-3.0-or-later
pragma solidity ^0.6.5;

View File

@ -1,3 +1,5 @@
// SPDX-License-Identifier: AGPL-3.0-or-later
pragma solidity ^0.6.1;

View File

@ -1,3 +1,5 @@
// SPDX-License-Identifier: AGPL-3.0-or-later
pragma solidity ^0.6.1;
/**

View File

@ -1,3 +1,5 @@
// SPDX-License-Identifier: AGPL-3.0-or-later
pragma solidity ^0.6.1;
import "contracts/lib/UmbralDeserializer.sol";
@ -11,9 +13,9 @@ library ReEncryptionValidator {
using UmbralDeserializer for bytes;
//////////////////////////////////
//------------------------------//
// Umbral-specific constants //
//////////////////////////////////
//------------------------------//
// See parameter `u` of `UmbralParameters` class in pyUmbral
// https://github.com/nucypher/pyUmbral/blob/master/umbral/params.py
@ -22,9 +24,9 @@ library ReEncryptionValidator {
uint256 public constant UMBRAL_PARAMETER_U_YCOORD = 0x7880ed56962d7c0ae44d6f14bb53b5fe64b31ea44a41d0316f3a598778f0f936;
//////////////////////////////////
//------------------------------//
// SECP256K1-specific constants //
//////////////////////////////////
//------------------------------//
// Base field order
uint256 constant FIELD_ORDER = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFC2F;

View File

@ -1,3 +1,5 @@
// SPDX-License-Identifier: AGPL-3.0-or-later
pragma solidity ^0.6.1;

View File

@ -1,5 +1,8 @@
// SPDX-License-Identifier: AGPL-3.0-or-later
pragma solidity ^0.6.5;
/**
* @title Snapshot
* @notice Manages snapshots of size 128 bits (32 bits for timestamp, 96 bits for value)

View File

@ -1,3 +1,5 @@
// SPDX-License-Identifier: AGPL-3.0-or-later
pragma solidity ^0.6.1;

View File

@ -1,3 +1,5 @@
// SPDX-License-Identifier: AGPL-3.0-or-later
pragma solidity ^0.6.1;
@ -131,7 +133,19 @@ contract Dispatcher is Upgradeable, ERCProxy {
function finishUpgrade(address) public override {}
/**
* @dev Fallback function send all requests to the target contract
* @dev Receive function sends empty request to the target contract
*/
receive() external payable {
assert(target.isContract());
// execute receive function from target contract using storage of the dispatcher
(bool callSuccess,) = target.delegatecall("");
if (!callSuccess) {
revert();
}
}
/**
* @dev Fallback function sends all requests to the target contract
*/
fallback() external payable {
assert(target.isContract());

View File

@ -1,3 +1,5 @@
// SPDX-License-Identifier: AGPL-3.0-or-later
pragma solidity ^0.6.1;
@ -37,7 +39,9 @@ abstract contract Upgradeable is Ownable {
*/
uint256 stubSlot;
/** Constants for `isUpgrade` field **/
/**
* @dev Constants for `isUpgrade` field
*/
uint8 constant UPGRADE_FALSE = 1;
uint8 constant UPGRADE_TRUE = 2;

View File

@ -1,3 +1,5 @@
// SPDX-License-Identifier: AGPL-3.0-or-later
pragma solidity ^0.6.5;
@ -71,15 +73,12 @@ abstract contract AbstractStakingContract {
*/
function withdrawETH() public virtual;
receive() external payable {}
/**
* @dev Function sends all requests to the target contract
*/
// TODO #1809
fallback() external payable {
if (msg.data.length == 0) {
return;
}
require(isFallbackAllowed());
address target = address(router.target());
require(target.isContract());

View File

@ -1,3 +1,5 @@
// SPDX-License-Identifier: AGPL-3.0-or-later
pragma solidity ^0.6.5;

View File

@ -1,3 +1,5 @@
// SPDX-License-Identifier: AGPL-3.0-or-later
pragma solidity ^0.6.5;

View File

@ -1,3 +1,5 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.6.1;

View File

@ -1,3 +1,5 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.6.1;

View File

@ -1,3 +1,5 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.6.1;

View File

@ -1,3 +1,5 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.6.1;

View File

@ -1,3 +1,5 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.6.1;

View File

@ -1,3 +1,5 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.6.1;

View File

@ -1,3 +1,5 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.6.1;

View File

@ -1,3 +1,5 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.6.1;
/**

View File

@ -1,3 +1,5 @@
// SPDX-License-Identifier: AGPL-3.0-or-later
pragma solidity ^0.6.1;

View File

@ -1,3 +1,5 @@
// SPDX-License-Identifier: AGPL-3.0-or-later
pragma solidity ^0.6.1;

View File

@ -561,3 +561,56 @@ def test_selfdestruct(testerchain, deploy_contract):
testerchain.wait_for_receipt(tx)
assert 26 == contract_instance.functions.constructorValue().call()
assert 34 == contract_instance.functions.functionValue().call()
@pytest.mark.slow
def test_receive_fallback(testerchain, deploy_contract):
# Deploy first contract
no_fallback_lib, _ = deploy_contract('NoFallback')
dispatcher, _ = deploy_contract('Dispatcher', no_fallback_lib.address)
contract_instance = testerchain.client.get_contract(
abi=no_fallback_lib.abi,
address=dispatcher.address,
ContractFactoryClass=Contract)
# Can't transfer ETH to this version of contract
value = 10000
with pytest.raises((TransactionFailed, ValueError)):
tx = testerchain.client.send_transaction(
{'from': testerchain.client.coinbase, 'to': contract_instance.address, 'value': value})
testerchain.wait_for_receipt(tx)
assert testerchain.client.get_balance(contract_instance.address) == 0
# Upgrade to other contract
receive_lib, _ = deploy_contract('OnlyReceive')
tx = dispatcher.functions.upgrade(receive_lib.address).transact()
testerchain.wait_for_receipt(tx)
contract_instance = testerchain.client.get_contract(
abi=receive_lib.abi,
address=dispatcher.address,
ContractFactoryClass=Contract)
# Transfer ETH and check which function was executed
tx = testerchain.client.send_transaction(
{'from': testerchain.client.coinbase, 'to': contract_instance.address, 'value': value})
testerchain.wait_for_receipt(tx)
assert contract_instance.functions.value().call() == value
assert contract_instance.functions.receiveRequests().call() == 1
assert testerchain.client.get_balance(contract_instance.address) == value
# Upgrade to other contract and transfer ETH again
receive_fallback_lib, _ = deploy_contract('ReceiveFallback')
tx = dispatcher.functions.upgrade(receive_fallback_lib.address).transact()
testerchain.wait_for_receipt(tx)
contract_instance = testerchain.client.get_contract(
abi=receive_fallback_lib.abi,
address=dispatcher.address,
ContractFactoryClass=Contract)
tx = testerchain.client.send_transaction(
{'from': testerchain.client.coinbase, 'to': contract_instance.address, 'value': value})
testerchain.wait_for_receipt(tx)
assert contract_instance.functions.receiveRequests().call() == 2
assert contract_instance.functions.value().call() == 2 * value
assert contract_instance.functions.fallbackRequests().call() == 0
assert testerchain.client.get_balance(contract_instance.address) == 2 * value

View File

@ -1,3 +1,5 @@
// SPDX-License-Identifier: AGPL-3.0-or-later
pragma solidity ^0.6.5;

View File

@ -1,3 +1,5 @@
// SPDX-License-Identifier: AGPL-3.0-or-later
pragma solidity ^0.6.5;

View File

@ -1,3 +1,5 @@
// SPDX-License-Identifier: AGPL-3.0-or-later
pragma solidity ^0.6.1;

View File

@ -1,3 +1,5 @@
// SPDX-License-Identifier: AGPL-3.0-or-later
pragma solidity ^0.6.5;

View File

@ -1,3 +1,5 @@
// SPDX-License-Identifier: AGPL-3.0-or-later
pragma solidity ^0.6.1;

View File

@ -1,3 +1,5 @@
// SPDX-License-Identifier: AGPL-3.0-or-later
pragma solidity ^0.6.1;
@ -19,9 +21,7 @@ contract ReentrancyTest {
data = _data;
}
// TODO #1809
// receive() external payable {
fallback() external payable {
receive() external payable {
// call no more than maxDepth times
if (lockCounter >= maxDepth) {
return;

View File

@ -1,3 +1,5 @@
// SPDX-License-Identifier: AGPL-3.0-or-later
pragma solidity ^0.6.5;
@ -112,9 +114,7 @@ contract PolicyManagerForStakingContractMock {
minFeeRate = _minFeeRate;
}
// TODO #1809
// receive() external payable {}
fallback() external payable {}
receive() external payable {}
}
@ -193,12 +193,7 @@ contract StakingInterfaceMockV2 {
address public immutable token = address(1);
address public immutable escrow = address(1);
// TODO #1809
// receive() external payable {}
fallback() external payable {
// can only use with ETH
require(msg.value > 0);
}
receive() external payable {}
function firstMethod(uint256) public pure {}

View File

@ -1,3 +1,5 @@
// SPDX-License-Identifier: AGPL-3.0-or-later
pragma solidity ^0.6.5;

View File

@ -1,3 +1,5 @@
// SPDX-License-Identifier: AGPL-3.0-or-later
pragma solidity ^0.6.5;

View File

@ -1,3 +1,5 @@
// SPDX-License-Identifier: AGPL-3.0-or-later
pragma solidity ^0.6.1;

View File

@ -1,3 +1,5 @@
// SPDX-License-Identifier: AGPL-3.0-or-later
pragma solidity ^0.6.1;

View File

@ -1,3 +1,5 @@
// SPDX-License-Identifier: AGPL-3.0-or-later
pragma solidity ^0.6.1;

View File

@ -1,3 +1,5 @@
// SPDX-License-Identifier: AGPL-3.0-or-later
pragma solidity ^0.6.1;

View File

@ -1,3 +1,5 @@
// SPDX-License-Identifier: AGPL-3.0-or-later
pragma solidity ^0.6.1;
@ -14,22 +16,22 @@ import "contracts/proxy/Upgradeable.sol";
contract ContractV4 is Upgradeable {
// slot allocation costs nothing
/// uint256 public storageValue;
// uint256 public storageValue;
uint256 reservedSlot4;
/// string public dynamicallySizedValue;
// string public dynamicallySizedValue;
uint256 reservedSlot5;
/// uint256[] public arrayValues;
// uint256[] public arrayValues;
uint256 reservedSlot6;
/// mapping (uint256 => uint256) public mappingValues;
// mapping (uint256 => uint256) public mappingValues;
uint256 reservedSlot7;
/// uint256[] public mappingIndices;
// uint256[] public mappingIndices;
uint256 reservedSlot8;
struct Structure1 {
uint256 value;
uint256[] arrayValues;
}
/// Structure1[] public arrayStructures;
// Structure1[] public arrayStructures;
uint256 reservedSlot9;
struct Structure2 {
@ -37,12 +39,12 @@ contract ContractV4 is Upgradeable {
uint256[] arrayValues;
uint256 valueToCheck;
}
/// mapping (uint256 => Structure2) public mappingStructures;
// mapping (uint256 => Structure2) public mappingStructures;
uint256 reservedSlot10;
/// uint256 public mappingStructuresLength;
// uint256 public mappingStructuresLength;
uint256 reservedSlot11;
/// uint256 public storageValueToCheck;
// uint256 public storageValueToCheck;
uint256 reservedSlot12;
uint256 public anotherStorageValue;

View File

@ -1,3 +1,5 @@
// SPDX-License-Identifier: AGPL-3.0-or-later
pragma solidity ^0.6.1;

View File

@ -0,0 +1,43 @@
// SPDX-License-Identifier: AGPL-3.0-or-later
pragma solidity ^0.6.1;
import "contracts/proxy/Upgradeable.sol";
/**
* @dev Contract can't handle 'receive' and 'fallback' requests
*/
contract NoFallback is Upgradeable {}
/**
* @dev Contract can handle only 'receive' requests
*/
contract OnlyReceive is NoFallback {
uint256 public receiveRequests;
uint256 public value;
receive() external payable {
receiveRequests += 1;
value += msg.value;
}
}
/**
* @dev Contract can handle 'receive' and 'fallback' requests
*/
contract ReceiveFallback is OnlyReceive {
uint256 public fallbackRequests;
fallback() external payable {
fallbackRequests += 1;
value += msg.value;
}
}