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

Commit

Permalink
Handle other compile errors like explicit conversions between uint an…
Browse files Browse the repository at this point in the history
…d byte, contract to address, and cleaning up DappHub code
  • Loading branch information
justinkchen committed Feb 23, 2019
1 parent 6454eb8 commit a2d4556
Show file tree
Hide file tree
Showing 24 changed files with 69 additions and 53 deletions.
4 changes: 2 additions & 2 deletions contracts/core/Vault.sol
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ contract Vault is
// Retrieve current balance of token for the vault
uint256 existingVaultBalance = ERC20Wrapper.balanceOf(
_token,
this
address(this)
);

// Call specified ERC20 token contract to transfer tokens from Vault to user
Expand All @@ -87,7 +87,7 @@ contract Vault is
// Verify transfer quantity is reflected in balance
uint256 newVaultBalance = ERC20Wrapper.balanceOf(
_token,
this
address(this)
);
// Check to make sure current balances are as expected
require(
Expand Down
4 changes: 2 additions & 2 deletions contracts/core/exchange-wrappers/KyberNetworkWrapper.sol
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ contract KyberNetworkWrapper {
address(this),
destinationQuantityToTradeFor,
trade.minimumConversionRate,
0
address(0)
);

// Ensure the destination token is allowed to be transferred by Set TransferProxy
Expand Down Expand Up @@ -265,7 +265,7 @@ contract KyberNetworkWrapper {
private
{
// Transfer any unused or remainder maker token back to the issuance order user
uint256 remainderMakerToken = ERC20.balanceOf(_makerToken, this);
uint256 remainderMakerToken = ERC20.balanceOf(_makerToken, address(this));
if (remainderMakerToken > 0) {
ERC20.transfer(
_makerToken,
Expand Down
6 changes: 3 additions & 3 deletions contracts/core/interfaces/IExchangeIssueModule.sol
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ import { ExchangeIssueLibrary } from "../lib/ExchangeIssueLibrary.sol";
*/
interface IExchangeIssueModule {
function exchangeIssue(
ExchangeIssueLibrary.ExchangeIssueParams memory _exchangeIssueData,
bytes memory _orderData
ExchangeIssueLibrary.ExchangeIssueParams calldata _exchangeIssueData,
bytes calldata _orderData
)
public;
external;
}
4 changes: 2 additions & 2 deletions contracts/core/interfaces/IRebalancingSetToken.sol
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ interface IRebalancingSetToken {
function balanceOf(
address owner
)
public
external
view
returns (uint256);

Expand Down Expand Up @@ -116,7 +116,7 @@ interface IRebalancingSetToken {
* @return A address representing the base Set Token
*/
function currentSet()
public
external
view
returns (address);

Expand Down
1 change: 1 addition & 0 deletions contracts/core/interfaces/IVault.sol
Original file line number Diff line number Diff line change
Expand Up @@ -160,5 +160,6 @@ interface IVault {
address _owner
)
external
view
returns (uint256);
}
2 changes: 2 additions & 0 deletions contracts/core/lib/RebalancingHelperLibrary.sol
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ library RebalancingHelperLibrary {
uint8 _rebalanceState
)
public
view
returns (uint256[] memory, uint256[] memory)
{
// Confirm in Rebalance State
Expand Down Expand Up @@ -136,6 +137,7 @@ library RebalancingHelperLibrary {
StandardStartRebalanceLibrary.BiddingParameters memory _biddingParameters
)
public
pure
returns (uint256[] memory, uint256[] memory)
{
// Declare unit arrays in memory
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ interface IAuctionPriceCurve {
* @param _auctionPriceParameters Struct containing relevant auction price parameters
*/
function validateAuctionPriceParameters(
RebalancingHelperLibrary.AuctionPriceParameters memory _auctionParameters
RebalancingHelperLibrary.AuctionPriceParameters calldata _auctionParameters
)
public
external
view;

/*
Expand All @@ -55,9 +55,9 @@ interface IAuctionPriceCurve {
* @return uint256 The auction price denominator
*/
function getCurrentPrice(
RebalancingHelperLibrary.AuctionPriceParameters memory _auctionParameters
RebalancingHelperLibrary.AuctionPriceParameters calldata _auctionParameters
)
public
external
view
returns (uint256, uint256);
}
1 change: 1 addition & 0 deletions contracts/core/modules/RebalancingTokenIssuanceModule.sol
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ contract RebalancingTokenIssuanceModule is
address _baseSetAddress
)
private
view
returns (uint256)
{
// Get Base Set Details from the rebalancing Set
Expand Down
24 changes: 13 additions & 11 deletions contracts/core/tokens/RebalancingSetTokenFactory.sol
Original file line number Diff line number Diff line change
Expand Up @@ -172,17 +172,19 @@ contract RebalancingSetTokenFactory {
);

// Create a new SetToken contract
return new RebalancingSetToken(
this,
parameters.manager,
startingSet,
_units[0],
_naturalUnit,
parameters.proposalPeriod,
parameters.rebalanceInterval,
rebalanceComponentWhitelist,
_name.bytes32ToString(),
_symbol.bytes32ToString()
return address(
new RebalancingSetToken(
address(this),
parameters.manager,
startingSet,
_units[0],
_naturalUnit,
parameters.proposalPeriod,
parameters.rebalanceInterval,
rebalanceComponentWhitelist,
_name.bytes32ToString(),
_symbol.bytes32ToString()
)
);
}

Expand Down
3 changes: 2 additions & 1 deletion contracts/core/tokens/SetToken.sol
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,8 @@ contract SetToken is

// Figure out which of the components has the minimum decimal value
/* solium-disable-next-line security/no-low-level-calls */
if (currentComponent.call(bytes4(keccak256("decimals()")))) {
(bool success, ) = currentComponent.call(abi.encodeWithSignature("decimals()"));
if (success) {
currentDecimals = ERC20Detailed(currentComponent).decimals();
minDecimals = currentDecimals < minDecimals ? currentDecimals : minDecimals;
} else {
Expand Down
16 changes: 9 additions & 7 deletions contracts/core/tokens/SetTokenFactory.sol
Original file line number Diff line number Diff line change
Expand Up @@ -84,13 +84,15 @@ contract SetTokenFactory
);

// Create a new SetToken contract
return new SetToken(
this,
_components,
_units,
_naturalUnit,
_name.bytes32ToString(),
_symbol.bytes32ToString()
return address(
new SetToken(
address(this),
_components,
_units,
_naturalUnit,
_name.bytes32ToString(),
_symbol.bytes32ToString()
)
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ library StandardPlaceBidLibrary {
uint8 _rebalanceState
)
public
view
returns (uint256[] memory, uint256[] memory)
{
// Make sure sender is a module
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ library StandardSettleRebalanceLibrary {
// Get amount of components in vault owned by rebalancingSetToken
uint256 componentAmount = vaultInstance.getOwnerBalance(
_setDetails.setComponents[i],
this
address(this)
);

// Calculate amount of Sets that can be issued from those components, if less than amount for other
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ library StandardStartRebalanceLibrary {
// Get remainingCurrentSets and make it divisible by currentSet natural unit
uint256 currentSetBalance = IVault(_vaultAddress).getOwnerBalance(
_currentSet,
this
address(this)
);

// Calculates the set's natural unit
Expand Down
4 changes: 2 additions & 2 deletions contracts/external/DappHub/auth.sol
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ contract DSAuth is DSAuthEvents {
auth
{
authority = authority_;
emit LogSetAuthority(authority);
emit LogSetAuthority(address(authority));
}

modifier auth {
Expand All @@ -62,7 +62,7 @@ contract DSAuth is DSAuthEvents {
} else if (authority == DSAuthority(0)) {
return false;
} else {
return authority.canCall(src, this, sig);
return authority.canCall(src, address(this), sig);
}
}
}
2 changes: 1 addition & 1 deletion contracts/external/DappHub/feed-factory.sol
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ contract FeedFactory {
PriceFeed feed = new PriceFeed();
emit Created(msg.sender, address(feed));
feed.setOwner(msg.sender);
isFeed[feed] = true;
isFeed[address(feed)] = true;
return feed;
}
}
4 changes: 2 additions & 2 deletions contracts/external/DappHub/interfaces/IMedian.sol
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ interface IMedian {
* @return Current price of asset represented in hex as bytes32
*/
function read()
public
external
view
returns (bytes32);

Expand All @@ -41,7 +41,7 @@ interface IMedian {
* @return Current price of asset represented in hex as bytes32, and whether value is non-zero
*/
function peek()
public
external
view
returns (bytes32, bool);
}
6 changes: 3 additions & 3 deletions contracts/external/DappHub/median.sol
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@ contract Median is DSAuth {

function read() public view returns (bytes32) {
require(val > 0, "Invalid price feed");
return bytes32(val);
return bytes32(uint256(val));
}

function peek() public view returns (bytes32,bool) {
return (bytes32(val), val > 0);
return (bytes32(uint256(val)), val > 0);
}

function recover(uint256 val_, uint256 age_, uint8 v, bytes32 r, bytes32 s, bytes32 wat_) internal pure returns (address) {
Expand Down Expand Up @@ -89,7 +89,7 @@ contract Median is DSAuth {
}

function lift(address a) public auth {
require(a != 0x0, "No oracle 0");
require(a != address(0x0), "No oracle 0");
orcl[a] = true;
}

Expand Down
7 changes: 6 additions & 1 deletion contracts/external/DappHub/note.sol
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,13 @@ contract DSNote {
bar := calldataload(36)
}

emit LogNote(msg.sig, msg.sender, foo, bar, msg.value, msg.data);
emit LogNote(msg.sig, msg.sender, foo, bar, getValue(), msg.data);

_;
}

function getValue() internal view returns (uint256)
{
return msg.value;
}
}
4 changes: 2 additions & 2 deletions contracts/external/DappHub/price-feed.sol
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@ contract PriceFeed is DSThing {

function peek() external view returns (bytes32,bool)
{
return (bytes32(val), now < zzz);
return (bytes32(uint256(val)), now < zzz);
}

function read() external view returns (bytes32)
{
require(now < zzz);
return bytes32(val);
return bytes32(uint256(val));
}

function poke(uint128 val_, uint32 zzz_) external note auth
Expand Down
2 changes: 1 addition & 1 deletion contracts/lib/Bytes32.sol
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ library Bytes32 {
returns (bytes memory)
{
uint256 i = 0;
while (i < 32 && uint256(data[i]) != 0) {
while (i < 32 && uint256(bytes32(data[i])) != 0) {
++i;
}
bytes memory result = new bytes(i);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,7 @@ contract BTCETHRebalancingManager {
uint256 _ethPrice
)
private
view
returns (uint256, uint256, uint256[] memory)
{
// Initialize set token parameters
Expand Down Expand Up @@ -461,7 +462,7 @@ contract BTCETHRebalancingManager {
uint256[] memory _units
)
private
view
pure
returns (uint256)
{
// Calculate btcDollarAmount of one Set Token (in cents)
Expand Down Expand Up @@ -500,7 +501,7 @@ contract BTCETHRebalancingManager {
uint256 _tokenDecimals
)
private
view
pure
returns (uint256)
{
// Calculate the amount of component base units are in one full set token
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@
},
"dependencies": {
"bn-chai": "^1.0.1",
"canonical-weth": "1.3.0",
"canonical-weth": "^1.3.1",
"dotenv": "^6.2.0",
"eth-gas-reporter": "^0.1.10",
"expect": "^24.1.0",
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1698,10 +1698,10 @@ caniuse-lite@^1.0.30000844:
resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30000890.tgz#86a18ffcc65d79ec6a437e985761b8bf1c4efeaf"
integrity sha512-4NI3s4Y6ROm+SgZN5sLUG4k7nVWQnedis3c/RWkynV5G6cHSY7+a8fwFyn2yoBDE3E6VswhTNNwR3PvzGqlTkg==

[email protected].0:
version "1.3.0"
resolved "https://registry.yarnpkg.com/canonical-weth/-/canonical-weth-1.3.0.tgz#4e863fe55d63f3e33595a80b335731435bd2474f"
integrity sha512-q1FoFo8SH7FNhemgvvkeuhO7YzztRbEcBoetTlT4Djf83ExdZKo1Wzh1rca+ncjhO6A2J0Ehl/tVG6xUkVIJcg==
canonical-weth@^1.3.1:
version "1.3.1"
resolved "https://registry.yarnpkg.com/canonical-weth/-/canonical-weth-1.3.1.tgz#8c12172ee2cd63247c5f6c75be44a6b173b97fd1"
integrity sha512-sDVYcU4ta2ixs9NNmOS15i5sdNJqbAPx/l86rctEK0XcAKI/PEs0IKZ2GjJ2hgTabzf4LfwopgNIznNcS3aLSQ==

caseless@~0.12.0:
version "0.12.0"
Expand Down

0 comments on commit a2d4556

Please sign in to comment.