Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update/format code to conform to solidity guidelines. No changes in functionality. #59

Open
wants to merge 6 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5,074 changes: 5,073 additions & 1 deletion build/contracts/Avatar.json

Large diffs are not rendered by default.

2,103 changes: 2,102 additions & 1 deletion build/contracts/BasicToken.json

Large diffs are not rendered by default.

773 changes: 772 additions & 1 deletion build/contracts/Debug.json

Large diffs are not rendered by default.

1,238 changes: 1,237 additions & 1 deletion build/contracts/ERC20.json

Large diffs are not rendered by default.

807 changes: 806 additions & 1 deletion build/contracts/ERC20Basic.json

Large diffs are not rendered by default.

7,795 changes: 7,794 additions & 1 deletion build/contracts/Likes.json

Large diffs are not rendered by default.

1,381 changes: 1,380 additions & 1 deletion build/contracts/Migrations.json

Large diffs are not rendered by default.

1,460 changes: 1,459 additions & 1 deletion build/contracts/Ownable.json

Large diffs are not rendered by default.

6,757 changes: 6,756 additions & 1 deletion build/contracts/PTIDistributor.json

Large diffs are not rendered by default.

1,316 changes: 1,315 additions & 1 deletion build/contracts/ParatiiToken.json

Large diffs are not rendered by default.

5,797 changes: 5,796 additions & 1 deletion build/contracts/Registry.json

Large diffs are not rendered by default.

2,440 changes: 2,439 additions & 1 deletion build/contracts/SafeMath.json

Large diffs are not rendered by default.

4,881 changes: 4,880 additions & 1 deletion build/contracts/Sales.json

Large diffs are not rendered by default.

1,272 changes: 1,271 additions & 1 deletion build/contracts/SendEther.json

Large diffs are not rendered by default.

6,298 changes: 6,297 additions & 1 deletion build/contracts/StandardToken.json

Large diffs are not rendered by default.

4,545 changes: 4,544 additions & 1 deletion build/contracts/Store.json

Large diffs are not rendered by default.

9,941 changes: 9,940 additions & 1 deletion build/contracts/TcrPlaceholder.json

Large diffs are not rendered by default.

3,762 changes: 3,761 additions & 1 deletion build/contracts/Users.json

Large diffs are not rendered by default.

6,238 changes: 6,237 additions & 1 deletion build/contracts/Videos.json

Large diffs are not rendered by default.

4,664 changes: 4,663 additions & 1 deletion build/contracts/Views.json

Large diffs are not rendered by default.

5,791 changes: 5,790 additions & 1 deletion build/contracts/Vouchers.json

Large diffs are not rendered by default.

60 changes: 30 additions & 30 deletions contracts/paratii/Avatar.sol
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
pragma solidity ^0.4.18;
import './Registry.sol';
import './ParatiiToken.sol';
import "./Registry.sol";
import "./ParatiiToken.sol";
import "zeppelin-solidity/contracts/ownership/Ownable.sol";
/*
* @dev A contract that holds PTI for the paratii DAO
Expand All @@ -17,48 +17,48 @@ contract Avatar is Ownable {
_;
}

function Avatar(Registry _registry) public {
constructor(Registry _registry) public {
registry = _registry;
owner = msg.sender;
}

function addToWhitelist(address _address) public onlyOwner {
// check if the address is already known, and if there is a free space in the whitelist
uint freeSpace = whitelist.length;
for (uint i=0; i < whitelist.length; i++) {
if (whitelist[i] == _address) {
return;
}
if (whitelist[i] == address(0)) {
freeSpace = i;
}
}
if (freeSpace == whitelist.length){
whitelist.push(_address);
} else {
whitelist[freeSpace] = _address;
}
// check if the address is already known, and if there is a free space in the whitelist
uint freeSpace = whitelist.length;
for (uint i = 0; i < whitelist.length; i++) {
if (whitelist[i] == _address) {
return;
}
if (whitelist[i] == address(0)) {
freeSpace = i;
}
}
if (freeSpace == whitelist.length){
whitelist.push(_address);
} else {
whitelist[freeSpace] = _address;
}
}

function removeFromWhitelist(address _address) public onlyOwner {
for (uint i=0; i < whitelist.length; i++) {
if (whitelist[i] == _address) {
delete whitelist[i];
}
}
for (uint i = 0; i < whitelist.length; i++) {
if (whitelist[i] == _address) {
delete whitelist[i];
}
}
}

function isOnWhiteList(address _address) public constant returns(bool) {
for (uint i=0; i < whitelist.length; i++) {
if (whitelist[i] == _address) {
return true;
}
}
return false;
for (uint i = 0; i < whitelist.length; i++) {
if (whitelist[i] == _address) {
return true;
}
}
return false;
}

function transferFrom(address _from, address _to, uint256 _value) public onlyWhitelist returns (bool) {
ParatiiToken token = ParatiiToken(registry.getContract('ParatiiToken'));
ParatiiToken token = ParatiiToken(registry.getContract("ParatiiToken"));
return token.transferFrom(_from, _to, _value);
}
}
108 changes: 54 additions & 54 deletions contracts/paratii/Likes.sol
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
pragma solidity ^0.4.18;

import "zeppelin-solidity/contracts/ownership/Ownable.sol";
import 'zeppelin-solidity/contracts/math/SafeMath.sol';
import './Registry.sol';
import "zeppelin-solidity/contracts/math/SafeMath.sol";
import "./Registry.sol";

contract Likes is Ownable {

Expand All @@ -19,83 +19,83 @@ contract Likes is Ownable {

event LogLikeVideo(address _address, string _videoId, bool _liked);

function Likes(Registry _paratiiRegistry) public {
constructor(Registry _paratiiRegistry) public {
owner = msg.sender;
paratiiRegistry = _paratiiRegistry;
}

function likeVideo(string _videoId, bool _liked) public {
address _address = msg.sender ;
bytes32 _videoHash = keccak256(_videoId);
bool _userLikesVideo = userLikesVideo(_address, _videoId);
bool _userDislikesVideo = userDislikesVideo(_address, _videoId);

if (_liked && _userLikesVideo) {
// this user already liked the video before
return;
}

if (!_liked && _userDislikesVideo) {
// this user already disliked the video before
return;
}

if (_liked) {
// msg.sender likes his video and did not do so before
_likes[_address][_videoHash] = true;
_userLikes[_address] += 1;
_vidLikes[_videoHash] += 1;

if (_userDislikesVideo) {
_dislikes[_address][_videoHash] = false;
_userDislikes[_address] -= 1;
_vidDislikes[_videoHash] -= 1;
}

LogLikeVideo(_address, _videoId, _liked);
function likeVideo(string _videoId, bool _liked) public {
address _address = msg.sender;
bytes32 _videoHash = keccak256(_videoId);
bool _userLikesVideo = userLikesVideo(_address, _videoId);
bool _userDislikesVideo = userDislikesVideo(_address, _videoId);

if (_liked && _userLikesVideo) {
// this user already liked the video before
return;
}

if (!_liked && _userDislikesVideo) {
// this user already disliked the video before
return;
}

if (_liked) {
// msg.sender likes his video and did not do so before
_likes[_address][_videoHash] = true;
_userLikes[_address] += 1;
_vidLikes[_videoHash] += 1;

if (_userDislikesVideo) {
_dislikes[_address][_videoHash] = false;
_userDislikes[_address] -= 1;
_vidDislikes[_videoHash] -= 1;
}

emit LogLikeVideo(_address, _videoId, _liked);
}

if (!_liked) {
// msg.sender likes his video and did not do so before
_dislikes[_address][_videoHash] = true;
_userDislikes[_address] += 1;
_vidDislikes[_videoHash] += 1;

if (_userLikesVideo) {
_likes[_address][_videoHash] = false;
_userLikes[_address] -= 1;
_vidLikes[_videoHash] -= 1;
}
LogLikeVideo(_address, _videoId, _liked);
LogLikeVideo(_address, 'this passed here', _liked);
// msg.sender likes his video and did not do so before
_dislikes[_address][_videoHash] = true;
_userDislikes[_address] += 1;
_vidDislikes[_videoHash] += 1;

if (_userLikesVideo) {
_likes[_address][_videoHash] = false;
_userLikes[_address] -= 1;
_vidLikes[_videoHash] -= 1;
}
emit LogLikeVideo(_address, _videoId, _liked);
emit LogLikeVideo(_address, "this passed here", _liked);
}
}

function userLikes(address _address) public constant returns(uint) {
return _userLikes[_address];
function userLikes(address _address) public view returns(uint) {
return _userLikes[_address];
}

/**
* @dev returns total of dislikes registered by this user
* @param _address Address of the user
*/
function userDislikes(address _address) public constant returns(uint) {
return _userDislikes[_address];
function userDislikes(address _address) public view returns(uint) {
return _userDislikes[_address];
}

function vidLikes(string _videoId) public constant returns(uint) {
return _vidLikes[keccak256(_videoId)];
function vidLikes(string _videoId) public view returns(uint) {
return _vidLikes[keccak256(_videoId)];
}

function vidDislikes(string _videoId) public constant returns(uint) {
return _vidDislikes[keccak256(_videoId)];
function vidDislikes(string _videoId) public view returns(uint) {
return _vidDislikes[keccak256(_videoId)];
}

function userLikesVideo(address _address, string _videoId) public constant returns(bool) {
function userLikesVideo(address _address, string _videoId) public view returns(bool) {
return _likes[_address][keccak256(_videoId)];
}

function userDislikesVideo(address _address, string _videoId) public constant returns(bool) {
function userDislikesVideo(address _address, string _videoId) public view returns(bool) {
return _dislikes[_address][keccak256(_videoId)];
}
}
48 changes: 24 additions & 24 deletions contracts/paratii/PTIDistributor.sol
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
pragma solidity ^0.4.18;

import "zeppelin-solidity/contracts/ownership/Ownable.sol";
import './ParatiiToken.sol';
import './Registry.sol';
import "./ParatiiToken.sol";
import "./Registry.sol";

contract PTIDistributor is Ownable {

Expand All @@ -15,37 +15,37 @@ contract PTIDistributor is Ownable {

mapping(bytes32 => bool) public isUsed;

function PTIDistributor(Registry _registry) public {
constructor(Registry _registry) public {
owner = msg.sender;
registry = _registry;
}


function distribute(address _toAddress, uint256 _amount, bytes32 _salt, string _reason, uint8 _v, bytes32 _r, bytes32 _s) {
bytes32 message = keccak256(_toAddress, _amount, _salt, _reason);
bytes memory prefix = "\x19Ethereum Signed Message:\n32";
bytes32 prefixedHash = keccak256(prefix, message);
require(!isUsed[_salt] && ecrecover(prefixedHash, _v, _r, _s) == owner);
isUsed[_salt] = true;
ParatiiToken token = ParatiiToken(registry.getContract('ParatiiToken'));
require(token.transfer(_toAddress, _amount));
LogDistribute(_toAddress, _amount, _reason);
function distribute(address _toAddress, uint256 _amount, bytes32 _salt, string _reason, uint8 _v, bytes32 _r, bytes32 _s) public {
bytes32 message = keccak256(_toAddress, _amount, _salt, _reason);
bytes memory prefix = "\x19Ethereum Signed Message:\n32";
bytes32 prefixedHash = keccak256(prefix, message);
require(!isUsed[_salt] && ecrecover(prefixedHash, _v, _r, _s) == owner);
isUsed[_salt] = true;
ParatiiToken token = ParatiiToken(registry.getContract("ParatiiToken"));
require(token.transfer(_toAddress, _amount));
emit LogDistribute(_toAddress, _amount, _reason);
}

function checkOwnerPacked(address _toAddress, uint256 _amount, bytes32 _salt, string _reason, uint8 _v, bytes32 _r, bytes32 _s) {
bytes32 message = keccak256(_toAddress, _amount, _salt, _reason);
bytes memory prefix = "\x19Ethereum Signed Message:\n32";
bytes32 prefixedHash = keccak256(prefix, message);
LogDebugOwner( ecrecover(prefixedHash, _v, _r, _s) );
function checkOwnerPacked(address _toAddress, uint256 _amount, bytes32 _salt, string _reason, uint8 _v, bytes32 _r, bytes32 _s) public {
bytes32 message = keccak256(_toAddress, _amount, _salt, _reason);
bytes memory prefix = "\x19Ethereum Signed Message:\n32";
bytes32 prefixedHash = keccak256(prefix, message);
emit LogDebugOwner(ecrecover(prefixedHash, _v, _r, _s));
}
function checkOwner(bytes32 _hash, uint8 _v, bytes32 _r, bytes32 _s) constant returns (address) {
bytes memory prefix = "\x19Ethereum Signed Message:\n32";
bytes32 prefixedHash = keccak256(prefix, _hash);
return ecrecover(prefixedHash, _v, _r, _s);
function checkOwner(bytes32 _hash, uint8 _v, bytes32 _r, bytes32 _s) public view returns (address) {
bytes memory prefix = "\x19Ethereum Signed Message:\n32";
bytes32 prefixedHash = keccak256(prefix, _hash);
return ecrecover(prefixedHash, _v, _r, _s);
}

function checkHashing(address _toAddress, uint256 _amount, bytes32 _salt, string _reason) {
bytes32 hashing = keccak256(_toAddress, _amount, _salt, _reason);
LogDebug( hashing );
function checkHashing(address _toAddress, uint256 _amount, bytes32 _salt, string _reason) public {
bytes32 hashing = keccak256(_toAddress, _amount, _salt, _reason);
emit LogDebug(hashing);
}
}
2 changes: 1 addition & 1 deletion contracts/paratii/ParatiiToken.sol
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ contract ParatiiToken is StandardToken {
uint public decimals = 18;
uint public INITIAL_SUPPLY = 21000000 * (10**decimals);

function ParatiiToken() public {
constructor() public {
totalSupply = INITIAL_SUPPLY;
balances[msg.sender] = INITIAL_SUPPLY;
}
Expand Down
Loading