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

Commit

Permalink
Contract type for Function parameters
Browse files Browse the repository at this point in the history
When a contract has use beyon it's address,
Pass the contract type isntead of the address.
  • Loading branch information
NicholasDotSol committed Mar 25, 2020
1 parent ef8c467 commit 41104d0
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 50 deletions.
6 changes: 3 additions & 3 deletions solidity/contracts/DepositLog.sol
Original file line number Diff line number Diff line change
Expand Up @@ -118,13 +118,13 @@ contract DepositLog {
/// @notice Sets the tbtcDepositToken contract.
/// @dev The contract is used by `approvedToLog` to check if the
/// caller is a Deposit contract. This should only be called once.
/// @param _tbtcDepositTokenAddress The address of the tbtcDepositToken.
function setTbtcDepositToken(address _tbtcDepositTokenAddress) public {
/// @param _tbtcDepositToken tbtcDepositToken contract.
function setTbtcDepositToken(TBTCDepositToken _tbtcDepositToken) public {
require(
address(tbtcDepositToken) == address(0),
"tbtcDepositToken is already set"
);
tbtcDepositToken = TBTCDepositToken(_tbtcDepositTokenAddress);
tbtcDepositToken = _tbtcDepositToken;
}

//
Expand Down
16 changes: 8 additions & 8 deletions solidity/contracts/deposit/Deposit.sol
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,10 @@ contract Deposit is DepositFactoryAuthority {
// THIS IS THE INIT FUNCTION
/// @notice The Deposit Factory can spin up a new deposit.
/// @dev Only the Deposit factory can call this.
/// @param _TBTCSystem `TBTCSystem` address. More info in `VendingMachine`.
/// @param _TBTCToken `TBTCToken` address. More info in TBTCToken`.
/// @param _TBTCDepositToken `TBTCDepositToken` (TDT) address. More info in `TBTCDepositToken`.
/// @param _FeeRebateToken `FeeRebateToken` (FRT) address. More info in `FeeRebateToken`.
/// @param _TBTCSystem `TBTCSystem` contract. More info in `VendingMachine`.
/// @param _TBTCToken `TBTCToken` contract. More info in TBTCToken`.
/// @param _TBTCDepositToken `TBTCDepositToken` (TDT) contract. More info in `TBTCDepositToken`.
/// @param _FeeRebateToken `FeeRebateToken` (FRT) contract. More info in `FeeRebateToken`.
/// @param _VendingMachine `VendingMachine` address. More info in `VendingMachine`.
/// @param _m Signing group honesty threshold.
/// @param _n Signing group size.
Expand All @@ -118,10 +118,10 @@ contract Deposit is DepositFactoryAuthority {
uint256 _n,
uint256 _lotSizeSatoshis
) public onlyFactory payable returns (bool) {
self.tbtcSystem = (_TBTCSystem);
self.tbtcToken = (_TBTCToken);
self.tbtcDepositToken = (_TBTCDepositToken);
self.feeRebateToken = (_FeeRebateToken);
self.tbtcSystem = _TBTCSystem;
self.tbtcToken = _TBTCToken;
self.tbtcDepositToken = _TBTCDepositToken;
self.feeRebateToken = _FeeRebateToken;
self.VendingMachine = _VendingMachine;
self.createNewDeposit(_m, _n, _lotSizeSatoshis);
return true;
Expand Down
24 changes: 12 additions & 12 deletions solidity/contracts/proxy/DepositFactory.sol
Original file line number Diff line number Diff line change
Expand Up @@ -34,28 +34,28 @@ contract DepositFactory is CloneFactory, TBTCSystemAuthority{

/// @dev Set the required external variables.
/// @param _masterDepositAddress The address of the master deposit contract.
/// @param _tbtcSystem Address of system contract.
/// @param _tbtcToken Address of TBTC token contract.
/// @param _tbtcDepositToken Address of the TBTC Deposit Token contract.
/// @param _feeRebateToken Address of the Fee Rebate Token contract.
/// @param _tbtcSystem Tbtc system contract.
/// @param _tbtcToken TBTC token contract.
/// @param _tbtcDepositToken TBTC Deposit Token contract.
/// @param _feeRebateToken AFee Rebate Token contract.
/// @param _vendingMachine Address of the Vending Machine contract.
/// @param _keepThreshold Minimum number of honest keep members.
/// @param _keepSize Number of all members in a keep.
function setExternalDependencies(
address payable _masterDepositAddress,
address _tbtcSystem,
address _tbtcToken,
address _tbtcDepositToken,
address _feeRebateToken,
TBTCSystem _tbtcSystem,
TBTCToken _tbtcToken,
TBTCDepositToken _tbtcDepositToken,
FeeRebateToken _feeRebateToken,
address _vendingMachine,
uint256 _keepThreshold,
uint256 _keepSize
) public onlyTbtcSystem {
masterDepositAddress = _masterDepositAddress;
tbtcDepositToken = TBTCDepositToken(_tbtcDepositToken);
tbtcSystem = TBTCSystem(_tbtcSystem);
tbtcToken = TBTCToken(_tbtcToken);
feeRebateToken = FeeRebateToken(_feeRebateToken);
tbtcDepositToken = _tbtcDepositToken;
tbtcSystem = _tbtcSystem;
tbtcToken = _tbtcToken;
feeRebateToken = _feeRebateToken;
vendingMachine = _vendingMachine;
keepThreshold = _keepThreshold;
keepSize = _keepSize;
Expand Down
38 changes: 20 additions & 18 deletions solidity/contracts/system/TBTCSystem.sol
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ import {IBTCETHPriceFeed} from "../interfaces/IBTCETHPriceFeed.sol";
import {DepositLog} from "../DepositLog.sol";

import {TBTCDepositToken} from "./TBTCDepositToken.sol";
import "./TBTCToken.sol";
import "./FeeRebateToken.sol";
import "openzeppelin-solidity/contracts/ownership/Ownable.sol";
import "openzeppelin-solidity/contracts/math/SafeMath.sol";

Expand Down Expand Up @@ -79,41 +81,41 @@ contract TBTCSystem is Ownable, ITBTCSystem, DepositLog {

/// @notice Initialize contracts
/// @dev Only the Deposit factory should call this, and only once.
/// @param _keepVendor ECDSA keep vendor address.
/// @param _depositFactory Deposit Factory address. More info in `DepositFactory`.
/// @param _keepVendor ECDSA keep vendor.
/// @param _depositFactory Deposit Factory. More info in `DepositFactory`.
/// @param _masterDepositAddress Master Deposit address. More info in `Deposit`.
/// @param _tbtcToken TBTCToken address. More info in `TBTCToken`.
/// @param _tbtcDepositToken TBTCDepositToken (TDT) address. More info in `TBTCDepositToken`.
/// @param _feeRebateToken FeeRebateToken (FRT) address. More info in `FeeRebateToken`.
/// @param _vendingMachine Vending Machine address. More info in `VendingMachine`.
/// @param _tbtcToken TBTCToken. More info in `TBTCToken`.
/// @param _tbtcDepositToken TBTCDepositToken (TDT). More info in `TBTCDepositToken`.
/// @param _feeRebateToken FeeRebateToken (FRT). More info in `FeeRebateToken`.
/// @param _vendingMachine Vending Machine. More info in `VendingMachine`.
/// @param _keepThreshold Signing group honesty threshold.
/// @param _keepSize Signing group size.
function initialize(
address _keepVendor,
address _depositFactory,
IBondedECDSAKeepVendor _keepVendor,
DepositFactory _depositFactory,
address payable _masterDepositAddress,
address _tbtcToken,
address _tbtcDepositToken,
address _feeRebateToken,
address _vendingMachine,
TBTCToken _tbtcToken,
TBTCDepositToken _tbtcDepositToken,
FeeRebateToken _feeRebateToken,
VendingMachine _vendingMachine,
uint256 _keepThreshold,
uint256 _keepSize
) external onlyOwner {
require(!_initialized, "already initialized");
tbtcDepositToken = TBTCDepositToken(_tbtcDepositToken);
keepVendor = IBondedECDSAKeepVendor(_keepVendor);
VendingMachine(_vendingMachine).setExternalAddresses(
tbtcDepositToken = _tbtcDepositToken;
keepVendor = _keepVendor;
_vendingMachine.setExternalAddresses(
_tbtcToken,
_tbtcDepositToken,
_feeRebateToken
);
DepositFactory(_depositFactory).setExternalDependencies(
_depositFactory.setExternalDependencies(
_masterDepositAddress,
address(this),
TBTCSystem(address(this)),
_tbtcToken,
_tbtcDepositToken,
_feeRebateToken,
_vendingMachine,
address(_vendingMachine),
_keepThreshold,
_keepSize
);
Expand Down
18 changes: 9 additions & 9 deletions solidity/contracts/system/VendingMachine.sol
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,17 @@ contract VendingMachine is TBTCSystemAuthority{

/// @notice Set external contracts needed by the Vending Machine.
/// @dev Addresses are used to update the local contract instance.
/// @param _tbtcToken TBTCToken address. More info in `TBTCToken`.
/// @param _tbtcDepositToken TBTCDepositToken (TDT) address. More info in `TBTCDepositToken`.
/// @param _feeRebateToken FeeRebateToken (FRT) address. More info in `FeeRebateToken`.
/// @param _tbtcToken TBTCToken contract. More info in `TBTCToken`.
/// @param _tbtcDepositToken TBTCDepositToken (TDT) contract. More info in `TBTCDepositToken`.
/// @param _feeRebateToken FeeRebateToken (FRT) contract. More info in `FeeRebateToken`.
function setExternalAddresses(
address _tbtcToken,
address _tbtcDepositToken,
address _feeRebateToken
TBTCToken _tbtcToken,
TBTCDepositToken _tbtcDepositToken,
FeeRebateToken _feeRebateToken
) public onlyTbtcSystem {
tbtcToken = TBTCToken(_tbtcToken);
tbtcDepositToken = TBTCDepositToken(_tbtcDepositToken);
feeRebateToken = FeeRebateToken(_feeRebateToken);
tbtcToken = _tbtcToken;
tbtcDepositToken = _tbtcDepositToken;
feeRebateToken = _feeRebateToken;
}

/// @notice Determines whether a deposit is qualified for minting TBTC.
Expand Down

0 comments on commit 41104d0

Please sign in to comment.