Skip to content

Commit

Permalink
Merge pull request #632 from oceanprotocol/feature/fix_false_reentran…
Browse files Browse the repository at this point in the history
…cy_positives

fix some false positives
  • Loading branch information
alexcos20 authored May 9, 2022
2 parents d396efc + 42e76d6 commit 22b0ef7
Show file tree
Hide file tree
Showing 12 changed files with 47 additions and 46 deletions.
28 changes: 14 additions & 14 deletions artifacts/contracts/ERC721Factory.sol/ERC721Factory.json

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions artifacts/contracts/pools/balancer/BPool.sol/BPool.json

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions contracts/ERC721Factory.sol
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,8 @@ contract ERC721Factory is Deployer, Ownable, ReentrancyGuard, IFactory {
);

erc721List[token] = token;

emit NFTCreated(token, tokenTemplate.templateAddress, name, owner, symbol, tokenURI, transferable, msg.sender);
currentNFTCount += 1;
IERC721Template tokenInstance = IERC721Template(token);
require(
tokenInstance.initialize(
Expand All @@ -178,8 +179,7 @@ contract ERC721Factory is Deployer, Ownable, ReentrancyGuard, IFactory {
"ERC721DTFactory: Unable to initialize token instance"
);

emit NFTCreated(token, tokenTemplate.templateAddress, name, owner, symbol, tokenURI, transferable, msg.sender);
currentNFTCount += 1;

}

/**
Expand Down
4 changes: 2 additions & 2 deletions contracts/pools/balancer/BPool.sol
Original file line number Diff line number Diff line change
Expand Up @@ -335,8 +335,8 @@ contract BPool is BMath, BToken, IPool {
for (uint256 i = 0; i < tokens.length; i++) {
uint256 amount = communityFees[tokens[i]];
communityFees[tokens[i]] = 0;
IERC20(tokens[i]).safeTransfer(_opcCollector, amount);
emit OPCFee(msg.sender, _opcCollector, tokens[i], amount);
IERC20(tokens[i]).safeTransfer(_opcCollector, amount);
}
}

Expand Down Expand Up @@ -392,13 +392,13 @@ contract BPool is BMath, BToken, IPool {
for (uint256 i = 0; i < tokens.length; i++) {
uint256 amount = publishMarketFees[tokens[i]];
publishMarketFees[tokens[i]] = 0;
IERC20(tokens[i]).safeTransfer(_publishMarketCollector, amount);
emit PublishMarketFee(
msg.sender,
_publishMarketCollector,
tokens[i],
amount
);
IERC20(tokens[i]).safeTransfer(_publishMarketCollector, amount);
}
}

Expand Down
4 changes: 2 additions & 2 deletions contracts/pools/dispenser/Dispenser.sol
Original file line number Diff line number Diff line change
Expand Up @@ -241,8 +241,8 @@ contract Dispenser is ReentrancyGuard, IDispenser{
ourBalance>=amount,
'Not enough reserves'
);
IERC20(datatoken).safeTransfer(destination,amount);
emit TokensDispensed(datatoken, destination, amount);
IERC20(datatoken).safeTransfer(destination,amount);
}

/**
Expand All @@ -263,8 +263,8 @@ contract Dispenser is ReentrancyGuard, IDispenser{
address destination = tokenInstance.getPaymentCollector();
uint256 ourBalance = tokenInstance.balanceOf(address(this));
if(ourBalance>0){
IERC20(datatoken).safeTransfer(destination,ourBalance);
emit OwnerWithdrawed(datatoken, destination, ourBalance);
IERC20(datatoken).safeTransfer(destination,ourBalance);
}
}
}
9 changes: 5 additions & 4 deletions contracts/pools/fixedRate/FixedRateExchange.sol
Original file line number Diff line number Diff line change
Expand Up @@ -653,15 +653,16 @@ contract FixedRateExchange is ReentrancyGuard, IFixedRateExchange {
function _collectMarketFee(bytes32 exchangeId) internal {
uint256 amount = exchanges[exchangeId].marketFeeAvailable;
exchanges[exchangeId].marketFeeAvailable = 0;
IERC20(exchanges[exchangeId].baseToken).safeTransfer(
exchanges[exchangeId].marketFeeCollector,
amount
);
emit MarketFeeCollected(
exchangeId,
exchanges[exchangeId].baseToken,
amount
);
IERC20(exchanges[exchangeId].baseToken).safeTransfer(
exchanges[exchangeId].marketFeeCollector,
amount
);

}

/**
Expand Down
12 changes: 6 additions & 6 deletions contracts/templates/ERC20Template.sol
Original file line number Diff line number Diff line change
Expand Up @@ -390,13 +390,13 @@ contract ERC20Template is
address[] memory addresses,
uint256[] memory uints
) external onlyERC20Deployer nonReentrant returns (bytes32 exchangeId) {
// add FixedPriced contract as minter if withMint == true
if (uints[4] > 0) _addMinter(fixedPriceAddress);
exchangeId = IFactoryRouter(router).deployFixedRate(
fixedPriceAddress,
addresses,
uints
);
// add FixedPriced contract as minter if withMint == true
if (uints[4] > 0) _addMinter(fixedPriceAddress);
emit NewFixedRate(exchangeId, addresses[1], fixedPriceAddress, addresses[0]);
fixedRateExchanges.push(fixedRate(fixedPriceAddress,exchangeId));

Expand All @@ -418,6 +418,10 @@ contract ERC20Template is
bool withMint,
address allowedSwapper
) external onlyERC20Deployer nonReentrant {
// add FixedPriced contract as minter if withMint == true
if (withMint) _addMinter(_dispenser);
dispensers.push(_dispenser);
emit NewDispenser(_dispenser);
IFactoryRouter(router).deployDispenser(
_dispenser,
address(this),
Expand All @@ -426,10 +430,6 @@ contract ERC20Template is
msg.sender,
allowedSwapper
);
// add FixedPriced contract as minter if withMint == true
if (withMint) _addMinter(_dispenser);
dispensers.push(_dispenser);
emit NewDispenser(_dispenser);
}

/**
Expand Down
10 changes: 5 additions & 5 deletions contracts/templates/ERC20TemplateEnterprise.sol
Original file line number Diff line number Diff line change
Expand Up @@ -334,12 +334,12 @@ contract ERC20TemplateEnterprise is
) external onlyERC20Deployer nonReentrant returns (bytes32 exchangeId) {
//force FRE allowedSwapper to this contract address. no one else can swap
addresses[3] = address(this);
if (uints[4] > 0) _addMinter(fixedPriceAddress);
exchangeId = IFactoryRouter(router).deployFixedRate(
fixedPriceAddress,
addresses,
uints
);
if (uints[4] > 0) _addMinter(fixedPriceAddress);
emit NewFixedRate(exchangeId, addresses[1], fixedPriceAddress, addresses[0]);
fixedRateExchanges.push(fixedRate(fixedPriceAddress,exchangeId));
}
Expand All @@ -360,6 +360,10 @@ contract ERC20TemplateEnterprise is
bool withMint,
address
) external onlyERC20Deployer nonReentrant {
// add dispenser contract as minter if withMint == true
if (withMint) _addMinter(_dispenser);
dispensers.push(_dispenser);
emit NewDispenser(_dispenser);
IFactoryRouter(router).deployDispenser(
_dispenser,
address(this),
Expand All @@ -368,10 +372,6 @@ contract ERC20TemplateEnterprise is
msg.sender,
address(this)
);
// add FixedPriced contract as minter if withMint == true
if (withMint) _addMinter(_dispenser);
dispensers.push(_dispenser);
emit NewDispenser(_dispenser);
}

/**
Expand Down

0 comments on commit 22b0ef7

Please sign in to comment.