Skip to content

Commit

Permalink
Merge pull request #16 from OpenBazaar/rewards-audit-fixes
Browse files Browse the repository at this point in the history
Rewards audit fixes
  • Loading branch information
Austin-Williams authored Mar 12, 2019
2 parents 72ef7e9 + 9fba2fb commit e98108a
Show file tree
Hide file tree
Showing 54 changed files with 7,258 additions and 9,066 deletions.
Empty file modified .gitattributes
100644 → 100755
Empty file.
Empty file modified .gitignore
100644 → 100755
Empty file.
Empty file modified .solcover.js
100644 → 100755
Empty file.
Empty file modified .soliumignore
100644 → 100755
Empty file.
Empty file modified .soliumrc.json
100644 → 100755
Empty file.
Empty file modified .travis.yml
100644 → 100755
Empty file.
Empty file modified LICENSE
100644 → 100755
Empty file.
Empty file modified README.md
100644 → 100755
Empty file.
Empty file modified build/contracts/Address.json
100644 → 100755
Empty file.
Empty file modified build/contracts/BasicToken.json
100644 → 100755
Empty file.
Empty file modified build/contracts/ContractManager.json
100644 → 100755
Empty file.
Empty file modified build/contracts/ERC20.json
100644 → 100755
Empty file.
Empty file modified build/contracts/ERC20Basic.json
100644 → 100755
Empty file.
Empty file modified build/contracts/ERC20Burnable.json
100644 → 100755
Empty file.
Empty file modified build/contracts/EscrowWithoutToken.json
100644 → 100755
Empty file.
652 changes: 326 additions & 326 deletions build/contracts/Escrow_v1_0.json
100644 → 100755

Large diffs are not rendered by default.

Empty file modified build/contracts/IERC20.json
100644 → 100755
Empty file.
1,122 changes: 561 additions & 561 deletions build/contracts/IEscrow.json
100644 → 100755

Large diffs are not rendered by default.

506 changes: 253 additions & 253 deletions build/contracts/ITokenContract.json
100644 → 100755

Large diffs are not rendered by default.

Empty file modified build/contracts/Migrations.json
100644 → 100755
Empty file.
11,608 changes: 4,910 additions & 6,698 deletions build/contracts/OBRewards.json
100644 → 100755

Large diffs are not rendered by default.

Empty file modified build/contracts/OBToken.json
100644 → 100755
Empty file.
1,054 changes: 527 additions & 527 deletions build/contracts/Ownable.json
100644 → 100755

Large diffs are not rendered by default.

Empty file modified build/contracts/PowerUps.json
100644 → 100755
Empty file.
1,334 changes: 667 additions & 667 deletions build/contracts/SafeMath.json
100644 → 100755

Large diffs are not rendered by default.

Empty file modified build/contracts/StandardToken.json
100644 → 100755
Empty file.
Empty file modified build/contracts/TestToken.json
100644 → 100755
Empty file.
Empty file modified contracts/Migrations.sol
100644 → 100755
Empty file.
Empty file modified contracts/escrow/EscrowSpec.md
100644 → 100755
Empty file.
Empty file modified contracts/escrow/Escrow_v1_0.sol
100644 → 100755
Empty file.
Empty file modified contracts/escrow/IEscrow.sol
100644 → 100755
Empty file.
Empty file modified contracts/powerUps/PowerUps.sol
100644 → 100755
Empty file.
Empty file modified contracts/powerUps/PowerUpsSpec.md
100644 → 100755
Empty file.
Empty file modified contracts/registry/ContractManager.sol
100644 → 100755
Empty file.
Empty file modified contracts/registry/ContractManagerSpec.md
100644 → 100755
Empty file.
28 changes: 2 additions & 26 deletions contracts/rewards/OBRewards.sol
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -94,32 +94,24 @@ contract OBRewards is Ownable {

/**
* @dev Add details to rewards contract at the time of deployment
* @param _promotedSellers List of promoted sellers
* @param _maxRewardPerSeller Maximum reward to be distributed from
* each seller
* @param _timeWindow A time window, in seconds, where purchases
* will be rewarded with tokens
* @param _escrowContractAddress Escrow address to be considered for
* rewards distribution.
* @param obTokenAddress Address of the reward token
* @param _endDate end date of the promotion
*/
constructor(
address[] _promotedSellers,
uint256 _maxRewardPerSeller,
uint256 _timeWindow,
address _escrowContractAddress, // this should be a trusted contract
address obTokenAddress,
uint256 _endDate
address obTokenAddress
)
public
nonZeroAddress(_escrowContractAddress)
nonZeroAddress(obTokenAddress)
{
require(
_promotedSellers.length > 0,
"Please provide atleast 1 promoted seller"
);

require(
_maxRewardPerSeller > 0,
Expand All @@ -135,26 +127,10 @@ contract OBRewards is Ownable {
timeWindow = _timeWindow;
escrowContract = IEscrow(_escrowContractAddress);
obToken = ITokenContract(obTokenAddress);
endDate = _endDate;
maxRewardToBuyerPerSeller = uint256(50).mul(
10 ** uint256(obToken.decimals())
);

for (uint256 i = 0; i < _promotedSellers.length; i++) {
require(
_promotedSellers[i] != address(0),
"Please provide valid address for promoted seller"
);

require(
!promotedSellers[_promotedSellers[i]],
"Same promoted seller provided twice"
);

promotedSellers[_promotedSellers[i]] = true;
}

emit PromotedSellersAdded(_promotedSellers);
}

/**
Expand Down Expand Up @@ -261,7 +237,7 @@ contract OBRewards is Ownable {
}

/**
* @dev Method to allow the onwer to adjust the maximum reward per seller
* @dev Method to allow the owner to adjust the maximum reward per seller
* @param _maxRewardPerSeller Max reward to be distributed for each seller
*/
function changeMaxRewardPerSeller(
Expand Down
Empty file modified contracts/rewards/RewardsSpec.md
100644 → 100755
Empty file.
Empty file modified contracts/test/EscrowWithoutToken.sol
100644 → 100755
Empty file.
Empty file modified contracts/test/TestToken.sol
100644 → 100755
Empty file.
Empty file modified contracts/token/ITokenContract.sol
100644 → 100755
Empty file.
Empty file modified contracts/token/OBToken.sol
100644 → 100755
Empty file.
Empty file modified migrations/1_initial_migration.js
100644 → 100755
Empty file.
Empty file modified migrations/escrow/2_Escrow_v1_0_migration.js
100644 → 100755
Empty file.
Empty file modified migrations/registry/3_contract_manager_migration.js
100644 → 100755
Empty file.
13 changes: 9 additions & 4 deletions package-lock.json
100644 → 100755

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Empty file modified package.json
100644 → 100755
Empty file.
Empty file modified scripts/signing.js
100644 → 100755
Empty file.
Empty file modified scripts/usage.txt
100644 → 100755
Empty file.
Empty file modified test/escrow/1_Escrow_v1_0_test.js
100644 → 100755
Empty file.
Empty file modified test/helper.js
100644 → 100755
Empty file.
Empty file modified test/powerUps/3_PowerUps_tests.js
100644 → 100755
Empty file.
Empty file modified test/registry/2_contract_manager_test.js
100644 → 100755
Empty file.
7 changes: 3 additions & 4 deletions test/rewards/6_OB_Rewards_Test.js
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -105,11 +105,10 @@ contract("OB Rewards Contract", function() {
this.escrow = await Escrow_v1_0.new({from:acct[0]});

this.OBT = await OBToken.new("Open Bazaar", "OBT", 18, 100000000, {from:acct[0]});

var endDate = 0;

this.rewards = await OBRewards.new(promotedSellers, 500000000000000000000, 432000, this.escrow.address, this.OBT.address, endDate, {from:acct[0]});

this.rewards = await OBRewards.new(500000000000000000000, 432000, this.escrow.address, this.OBT.address, {from:acct[0]});
await this.rewards.addPromotedSellers(promotedSellers, {from:acct[0]});

await this.OBT.transfer(this.rewards.address, 570000000000000000000, {from:acct[0]});

});
Expand Down
Empty file modified truffle.js
100644 → 100755
Empty file.

0 comments on commit e98108a

Please sign in to comment.