Skip to content
This repository has been archived by the owner on Mar 28, 2023. It is now read-only.

Commit

Permalink
Merge pull request #565 from keep-network/solid-ice
Browse files Browse the repository at this point in the history
Solid Ice: Freeze Solidity version for mainnet release
  • Loading branch information
NicholasDotSol authored Apr 7, 2020
2 parents e23d309 + 6f27fd5 commit 58f632e
Show file tree
Hide file tree
Showing 47 changed files with 372 additions and 178 deletions.
2 changes: 1 addition & 1 deletion solidity/contracts/DepositLog.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pragma solidity ^0.5.10;
pragma solidity 0.5.17;

import {TBTCDepositToken} from "./system/TBTCDepositToken.sol";

Expand Down
2 changes: 1 addition & 1 deletion solidity/contracts/Migrations.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pragma solidity >=0.4.21 <0.6.0;
pragma solidity 0.5.17;


contract Migrations {
Expand Down
2 changes: 1 addition & 1 deletion solidity/contracts/deposit/Deposit.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pragma solidity ^0.5.10;
pragma solidity 0.5.17;

import {DepositLiquidation} from "./DepositLiquidation.sol";
import {DepositUtils} from "./DepositUtils.sol";
Expand Down
4 changes: 2 additions & 2 deletions solidity/contracts/deposit/DepositFunding.sol
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
pragma solidity ^0.5.10;
pragma solidity 0.5.17;

import {SafeMath} from "@summa-tx/bitcoin-spv-sol/contracts/SafeMath.sol";
import {BytesLib} from "@summa-tx/bitcoin-spv-sol/contracts/BytesLib.sol";
import {BTCUtils} from "@summa-tx/bitcoin-spv-sol/contracts/BTCUtils.sol";
import {IBondedECDSAKeep} from "@keep-network/keep-ecdsa/contracts/api/IBondedECDSAKeep.sol";
import {SafeMath} from "openzeppelin-solidity/contracts/math/SafeMath.sol";
import {TBTCToken} from "../system/TBTCToken.sol";
import {DepositUtils} from "./DepositUtils.sol";
import {DepositLiquidation} from "./DepositLiquidation.sol";
Expand Down
6 changes: 3 additions & 3 deletions solidity/contracts/deposit/DepositLiquidation.sol
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
pragma solidity ^0.5.10;
pragma solidity 0.5.17;

import {SafeMath} from "@summa-tx/bitcoin-spv-sol/contracts/SafeMath.sol";
import {BTCUtils} from "@summa-tx/bitcoin-spv-sol/contracts/BTCUtils.sol";
import {BytesLib} from "@summa-tx/bitcoin-spv-sol/contracts/BytesLib.sol";
import {IBondedECDSAKeep} from "@keep-network/keep-ecdsa/contracts/api/IBondedECDSAKeep.sol";
import {SafeMath} from "openzeppelin-solidity/contracts/math/SafeMath.sol";
import {DepositStates} from "./DepositStates.sol";
import {DepositUtils} from "./DepositUtils.sol";
import {TBTCConstants} from "./TBTCConstants.sol";
import {IBondedECDSAKeep} from "@keep-network/keep-ecdsa/contracts/api/IBondedECDSAKeep.sol";
import {OutsourceDepositLogging} from "./OutsourceDepositLogging.sol";
import {TBTCToken} from "../system/TBTCToken.sol";
import {ITBTCSystem} from "../interfaces/ITBTCSystem.sol";
Expand Down
8 changes: 4 additions & 4 deletions solidity/contracts/deposit/DepositRedemption.sol
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
pragma solidity ^0.5.10;
pragma solidity 0.5.17;

import {SafeMath} from "@summa-tx/bitcoin-spv-sol/contracts/SafeMath.sol";
import {BTCUtils} from "@summa-tx/bitcoin-spv-sol/contracts/BTCUtils.sol";
import {BytesLib} from "@summa-tx/bitcoin-spv-sol/contracts/BytesLib.sol";
import {ValidateSPV} from "@summa-tx/bitcoin-spv-sol/contracts/ValidateSPV.sol";
import {CheckBitcoinSigs} from "@summa-tx/bitcoin-spv-sol/contracts/CheckBitcoinSigs.sol";
import {DepositUtils} from "./DepositUtils.sol";
import {IERC721} from "openzeppelin-solidity/contracts/token/ERC721/IERC721.sol";
import {SafeMath} from "openzeppelin-solidity/contracts/math/SafeMath.sol";
import {IBondedECDSAKeep} from "@keep-network/keep-ecdsa/contracts/api/IBondedECDSAKeep.sol";
import {DepositUtils} from "./DepositUtils.sol";
import {DepositStates} from "./DepositStates.sol";
import {OutsourceDepositLogging} from "./OutsourceDepositLogging.sol";
import {TBTCConstants} from "./TBTCConstants.sol";
import {TBTCToken} from "../system/TBTCToken.sol";
import {DepositLiquidation} from "./DepositLiquidation.sol";
import {IERC721} from "openzeppelin-solidity/contracts/token/ERC721/IERC721.sol";

library DepositRedemption {

Expand Down
2 changes: 1 addition & 1 deletion solidity/contracts/deposit/DepositStates.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pragma solidity ^0.5.10;
pragma solidity 0.5.17;

import {DepositUtils} from "./DepositUtils.sol";

Expand Down
8 changes: 4 additions & 4 deletions solidity/contracts/deposit/DepositUtils.sol
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
pragma solidity ^0.5.10;
pragma solidity 0.5.17;

import {ValidateSPV} from "@summa-tx/bitcoin-spv-sol/contracts/ValidateSPV.sol";
import {SafeMath} from "@summa-tx/bitcoin-spv-sol/contracts/SafeMath.sol";
import {BTCUtils} from "@summa-tx/bitcoin-spv-sol/contracts/BTCUtils.sol";
import {BytesLib} from "@summa-tx/bitcoin-spv-sol/contracts/BytesLib.sol";
import {IBondedECDSAKeep} from "@keep-network/keep-ecdsa/contracts/api/IBondedECDSAKeep.sol";
import {IERC721} from "openzeppelin-solidity/contracts/token/ERC721/IERC721.sol";
import {SafeMath} from "openzeppelin-solidity/contracts/math/SafeMath.sol";
import {DepositStates} from "./DepositStates.sol";
import {TBTCConstants} from "./TBTCConstants.sol";
import {ITBTCSystem} from "../interfaces/ITBTCSystem.sol";
import {IERC721} from "openzeppelin-solidity/contracts/token/ERC721/IERC721.sol";
import {IBondedECDSAKeep} from "@keep-network/keep-ecdsa/contracts/api/IBondedECDSAKeep.sol";
import {TBTCToken} from "../system/TBTCToken.sol";
import {FeeRebateToken} from "../system/FeeRebateToken.sol";

Expand Down
2 changes: 1 addition & 1 deletion solidity/contracts/deposit/OutsourceDepositLogging.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pragma solidity ^0.5.10;
pragma solidity 0.5.17;

import {DepositLog} from "../DepositLog.sol";
import {DepositUtils} from "./DepositUtils.sol";
Expand Down
2 changes: 1 addition & 1 deletion solidity/contracts/deposit/TBTCConstants.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pragma solidity ^0.5.10;
pragma solidity 0.5.17;

library TBTCConstants {

Expand Down
4 changes: 2 additions & 2 deletions solidity/contracts/external/IMedianizer.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pragma solidity ^0.5.10;
pragma solidity 0.5.17;

/// @notice A medianizer price feed.
/// @dev Based off the MakerDAO medianizer (https://github.com/makerdao/median)
Expand All @@ -7,4 +7,4 @@ interface IMedianizer {
/// @dev May revert if caller not whitelisted.
/// @return Price (USD) with 18 decimal places.
function read() external view returns (uint256);
}
}
2 changes: 1 addition & 1 deletion solidity/contracts/interfaces/IBTCETHPriceFeed.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pragma solidity ^0.5.10;
pragma solidity 0.5.17;

interface IBTCETHPriceFeed {
/// @notice Get the current price of bitcoin in ether.
Expand Down
2 changes: 1 addition & 1 deletion solidity/contracts/interfaces/ITBTCSystem.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pragma solidity ^0.5.10;
pragma solidity 0.5.17;

/**
* @title Keep interface
Expand Down
37 changes: 37 additions & 0 deletions solidity/contracts/interfaces/ITokenRecipient.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
pragma solidity 0.5.17;

/// @title Interface of recipient contract for `approveAndCall` pattern.
/// Implementors will be able to be used in an `approveAndCall`
/// interaction with a supporting contract, such that a token approval
/// can call the contract acting on that approval in a single
/// transaction.
///
/// See the `FundingScript` and `RedemptionScript` contracts as examples.
interface ITokenRecipient {
/// Typically called from a token contract's `approveAndCall` method, this
/// method will receive the original owner of the token (`_from`), the
/// transferred `_value` (in the case of an ERC721, the token id), the token
/// address (`_token`), and a blob of `_extraData` that is informally
/// specified by the implementor of this method as a way to communicate
/// additional parameters.
///
/// Token calls to `receiveApproval` should revert if `receiveApproval`
/// reverts, and reverts should remove the approval.
///
/// @param _from The original owner of the token approved for transfer.
/// @param _value For an ERC20, the amount approved for transfer; for an
/// ERC721, the id of the token approved for transfer.
/// @param _token The address of the contract for the token whose transfer
/// was approved.
/// @param _extraData An additional data blob forwarded unmodified through
/// `approveAndCall`, used to allow the token owner to pass
/// additional parameters and data to this method. The structure of
/// the extra data is informally specified by the implementor of
/// this interface.
function receiveApproval(
address _from,
uint256 _value,
address _token,
bytes calldata _extraData
) external;
}
6 changes: 3 additions & 3 deletions solidity/contracts/price-feed/BTCETHPriceFeed.sol
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
pragma solidity ^0.5.10;
pragma solidity 0.5.17;

import {SafeMath} from "@summa-tx/bitcoin-spv-sol/contracts/SafeMath.sol";
import {SafeMath} from "openzeppelin-solidity/contracts/math/SafeMath.sol";
import "openzeppelin-solidity/contracts/ownership/Ownable.sol";
import "../external/IMedianizer.sol";
import "../interfaces/IBTCETHPriceFeed.sol";
Expand Down Expand Up @@ -54,4 +54,4 @@ contract BTCETHPriceFeed is Ownable, IBTCETHPriceFeed {
// Due to order-of-ops, we can move the multiplication to get some more precision.
return btcUsd.mul(10**10).div(ethUsd);
}
}
}
2 changes: 1 addition & 1 deletion solidity/contracts/price-feed/MockMedianizer.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pragma solidity ^0.5.10;
pragma solidity 0.5.17;

import "openzeppelin-solidity/contracts/ownership/Ownable.sol";
import "../external/IMedianizer.sol";
Expand Down
2 changes: 1 addition & 1 deletion solidity/contracts/proxy/CloneFactory.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pragma solidity ^0.5.10;
pragma solidity 0.5.17;

/*
The MIT License (MIT)
Expand Down
2 changes: 1 addition & 1 deletion solidity/contracts/proxy/DepositFactory.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pragma solidity ^0.5.10;
pragma solidity 0.5.17;

import "./CloneFactory.sol";
import "../deposit/Deposit.sol";
Expand Down
2 changes: 1 addition & 1 deletion solidity/contracts/relay/MockRelay.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pragma solidity ^0.5.10;
pragma solidity 0.5.17;

contract MockRelay {
uint256 current = 1;
Expand Down
4 changes: 2 additions & 2 deletions solidity/contracts/scripts/FundingScript.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pragma solidity ^0.5.10;
pragma solidity 0.5.17;

import {TBTCDepositToken} from "../system/TBTCDepositToken.sol";
import {TBTCToken} from "../system/TBTCToken.sol";
Expand Down Expand Up @@ -59,4 +59,4 @@ contract FundingScript {
tbtcToken.transfer(_from, tbtcToken.balanceOf(address(this)));
feeRebateToken.transferFrom(address(this), _from, uint256(_tokenId));
}
}
}
4 changes: 2 additions & 2 deletions solidity/contracts/scripts/RedemptionScript.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pragma solidity ^0.5.10;
pragma solidity 0.5.17;

import {TBTCDepositToken} from "../system/TBTCDepositToken.sol";
import {TBTCToken} from "../system/TBTCToken.sol";
Expand Down Expand Up @@ -55,4 +55,4 @@ contract RedemptionScript {
// TODO: there's some noisy couple bytes at the beginning of the converted string, maybe the ABI-coded length?
require(success, string(returnData));
}
}
}
2 changes: 1 addition & 1 deletion solidity/contracts/system/DepositFactoryAuthority.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pragma solidity 0.5.10;
pragma solidity 0.5.17;

/// @title Deposit Factory Authority
/// @notice Contract to secure function calls to the Deposit Factory.
Expand Down
4 changes: 2 additions & 2 deletions solidity/contracts/system/FeeRebateToken.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pragma solidity ^0.5.10;
pragma solidity 0.5.17;

import "openzeppelin-solidity/contracts/token/ERC721/ERC721Metadata.sol";
import "./VendingMachineAuthority.sol";
Expand Down Expand Up @@ -36,4 +36,4 @@ contract FeeRebateToken is ERC721Metadata, VendingMachineAuthority {
function exists(uint256 _tokenId) public view returns (bool) {
return _exists(_tokenId);
}
}
}
36 changes: 12 additions & 24 deletions solidity/contracts/system/TBTCDepositToken.sol
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
pragma solidity ^0.5.10;

import "openzeppelin-solidity/contracts/token/ERC721/ERC721Metadata.sol";
import "./DepositFactoryAuthority.sol";
pragma solidity 0.5.17;

import {ERC721Metadata} from "openzeppelin-solidity/contracts/token/ERC721/ERC721Metadata.sol";
import {DepositFactoryAuthority} from "./DepositFactoryAuthority.sol";
import {ITokenRecipient} from "../interfaces/ITokenRecipient.sol";

/// @title tBTC Deposit Token for tracking deposit ownership
/// @notice The tBTC Deposit Token, commonly referenced as the TDT, is an
Expand All @@ -14,7 +14,7 @@ import "./DepositFactoryAuthority.sol";
/// TBTC tokens whose value is backed 1-to-1 by the corresponding
/// deposit's BTC.
/// @dev Currently, TDTs are minted using the uint256 casting of the
/// corresponding deposit contract's address. That is, the TDTs id is
/// corresponding deposit contract's address. That is, the TDT's id is
/// convertible to the deposit's address and vice versa. TDTs are minted
/// automatically by the factory during each deposit's initialization. See
/// DepositFactory.createNewDeposit() for more info on how the TDT is minted.
Expand Down Expand Up @@ -45,27 +45,15 @@ contract TBTCDepositToken is ERC721Metadata, DepositFactoryAuthority {
/// Set allowance for other address and notify.
/// Allows `_spender` to transfer the specified TDT
/// on your behalf and then ping the contract about it.
/// @dev The `_spender` should implement the `tokenRecipient` interface below
/// to receive approval notifications.
/// @param _spender Address of contract authorized to spend.
/// @dev The `_spender` should implement the `ITokenRecipient`
/// interface below to receive approval notifications.
/// @param _spender `ITokenRecipient`-conforming contract authorized to
/// operate on the approved token.
/// @param _tdtId The TDT they can spend.
/// @param _extraData Extra information to send to the approved contract.
function approveAndCall(address _spender, uint256 _tdtId, bytes memory _extraData) public returns (bool) {
tokenRecipient spender = tokenRecipient(_spender);
approve(_spender, _tdtId);
spender.receiveApproval(msg.sender, _tdtId, address(this), _extraData);
function approveAndCall(ITokenRecipient _spender, uint256 _tdtId, bytes memory _extraData) public returns (bool) {
approve(address(_spender), _tdtId);
_spender.receiveApproval(msg.sender, _tdtId, address(this), _extraData);
return true;
}
}

/// @title Interface of recipient contract for approveAndCall pattern.
/// See `FundingScript` contract for an example.
interface tokenRecipient {
function receiveApproval(
address _from,
uint256 _value,
address _token,
bytes calldata
_extraDat
) external;
}
2 changes: 1 addition & 1 deletion solidity/contracts/system/TBTCSystem.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* solium-disable function-order */
pragma solidity ^0.5.10;
pragma solidity 0.5.17;

import {IBondedECDSAKeepVendor} from "@keep-network/keep-ecdsa/contracts/api/IBondedECDSAKeepVendor.sol";
import {IBondedECDSAKeepFactory} from "@keep-network/keep-ecdsa/contracts/api/IBondedECDSAKeepFactory.sol";
Expand Down
4 changes: 2 additions & 2 deletions solidity/contracts/system/TBTCSystemAuthority.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pragma solidity 0.5.10;
pragma solidity 0.5.17;

/// @title TBTC System Authority.
/// @notice Contract to secure function calls to the TBTC System contract.
Expand All @@ -17,4 +17,4 @@ contract TBTCSystemAuthority {
require(msg.sender == tbtcSystemAddress, "Caller must be tbtcSystem contract");
_;
}
}
}
39 changes: 15 additions & 24 deletions solidity/contracts/system/TBTCToken.sol
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
pragma solidity ^0.5.10;
pragma solidity 0.5.17;

import "openzeppelin-solidity/contracts/token/ERC20/ERC20.sol";
import "openzeppelin-solidity/contracts/token/ERC20/ERC20Detailed.sol";
import "./VendingMachineAuthority.sol";
import {ERC20} from "openzeppelin-solidity/contracts/token/ERC20/ERC20.sol";
import {ERC20Detailed} from "openzeppelin-solidity/contracts/token/ERC20/ERC20Detailed.sol";
import {VendingMachineAuthority} from "./VendingMachineAuthority.sol";
import {ITokenRecipient} from "../interfaces/ITokenRecipient.sol";

/// @title TBTC Token.
/// @notice This is the TBTC ERC20 contract.
Expand Down Expand Up @@ -46,31 +47,21 @@ contract TBTCToken is ERC20Detailed, ERC20, VendingMachineAuthority {
}

/// @notice Set allowance for other address and notify.
/// Allows `_spender` to spend no more than `_value` tokens
/// on your behalf and then ping the contract about it.
/// @dev The `_spender` should implement the `tokenRecipient` interface above
/// to receive approval notifications.
/// Allows `_spender` to spend no more than `_value`
/// tokens on your behalf and then ping the contract about
/// it.
/// @dev The `_spender` should implement the `ITokenRecipient`
/// interface to receive approval notifications.
/// @param _spender Address of contract authorized to spend.
/// @param _value The max amount they can spend.
/// @param _extraData Extra information to send to the approved contract.
function approveAndCall(address _spender, uint256 _value, bytes memory _extraData) public returns (bool) {
tokenRecipient spender = tokenRecipient(_spender);
if (approve(_spender, _value)) {
spender.receiveApproval(msg.sender, _value, address(this), _extraData);
/// @return true if the `_spender` was successfully approved and acted on
/// the approval, false (or revert) otherwise.
function approveAndCall(ITokenRecipient _spender, uint256 _value, bytes memory _extraData) public returns (bool) {
if (approve(address(_spender), _value)) {
_spender.receiveApproval(msg.sender, _value, address(this), _extraData);
return true;
}
return false;
}
}

/// @title Interface of recipient contract for approveAndCall pattern.
/// See `RedemptionScript` for an example.
interface tokenRecipient {
function receiveApproval(
address _from,
uint256 _value,
address _token,
bytes calldata
_extraDat
) external;
}
4 changes: 2 additions & 2 deletions solidity/contracts/system/VendingMachine.sol
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
pragma solidity ^0.5.10;
pragma solidity 0.5.17;

import {SafeMath} from "@summa-tx/bitcoin-spv-sol/contracts/SafeMath.sol";
import {SafeMath} from "openzeppelin-solidity/contracts/math/SafeMath.sol";
import {TBTCDepositToken} from "./TBTCDepositToken.sol";
import {FeeRebateToken} from "./FeeRebateToken.sol";
import {TBTCToken} from "./TBTCToken.sol";
Expand Down
Loading

0 comments on commit 58f632e

Please sign in to comment.