Skip to content
Merged
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
4 changes: 3 additions & 1 deletion .soliumrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@
"extends": "solium:recommended",
"plugins": ["security"],
"rules": {
"no-experimental": ["off"],
"quotes": ["error", "double"],
"indentation": ["error", 4],
"linebreak-style": ["error", "unix"],
"security/no-inline-assembly": ["off"]
"security/no-inline-assembly": ["off"],
"security/no-low-level-calls": ["off"]
}
}
58 changes: 12 additions & 46 deletions contracts/GNS.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ pragma experimental ABIEncoderV2;

import "./Governed.sol";


contract GNS is Governed {
/*
* @title Graph Name Service (GNS) contract
Expand Down Expand Up @@ -41,34 +42,18 @@ contract GNS is Governed {
*/

/* Events */
event DomainAdded(
bytes32 indexed topLevelDomainHash,
address indexed owner,
string domainName
);
event DomainTransferred(
bytes32 indexed domainHash,
address indexed newOwner
);
event DomainAdded(bytes32 indexed topLevelDomainHash, address indexed owner, string domainName);
event DomainTransferred(bytes32 indexed domainHash, address indexed newOwner);
event SubgraphCreated(
bytes32 indexed topLevelDomainHash,
bytes32 indexed registeredHash,
string subdomainName,
address indexed owner
);
event SubgraphIDUpdated(
bytes32 indexed domainHash,
bytes32 indexed subgraphID
);
event SubgraphIDUpdated(bytes32 indexed domainHash, bytes32 indexed subgraphID);
event DomainDeleted(bytes32 indexed domainHash);
event AccountMetadataChanged(
address indexed account,
bytes32 indexed ipfsHash
);
event SubgraphMetadataChanged(
bytes32 indexed domainHash,
bytes32 indexed ipfsHash
);
event AccountMetadataChanged(address indexed account, bytes32 indexed ipfsHash);
event SubgraphMetadataChanged(bytes32 indexed domainHash, bytes32 indexed ipfsHash);

/* TYPES */
struct Domain {
Expand All @@ -87,10 +72,7 @@ contract GNS is Governed {
/* Graph Protocol Functions */

modifier onlyDomainOwner(bytes32 _domainHash) {
require(
msg.sender == domains[_domainHash].owner,
"Only domain owner can call."
);
require(msg.sender == domains[_domainHash].owner, "Only domain owner can call.");
_;
}

Expand All @@ -101,10 +83,7 @@ contract GNS is Governed {
function registerDomain(string calldata _domainName) external {
bytes32 hashedName = keccak256(abi.encodePacked(_domainName));
// Require that this domain is not yet owned by anyone.
require(
domains[hashedName].owner == address(0),
"Domain is already owned."
);
require(domains[hashedName].owner == address(0), "Domain is already owned.");
domains[hashedName].owner = msg.sender;
emit DomainAdded(hashedName, msg.sender, _domainName);
}
Expand Down Expand Up @@ -134,9 +113,7 @@ contract GNS is Governed {
domainHash = _topLevelDomainHash;
} else {
// The domain hash becomes the subdomain concatenated with the top level domain hash.
domainHash = keccak256(
abi.encodePacked(subdomainHash, _topLevelDomainHash)
);
domainHash = keccak256(abi.encodePacked(subdomainHash, _topLevelDomainHash));
require(
domains[domainHash].owner == address(0),
"Someone already owns this subdomain."
Expand All @@ -147,12 +124,7 @@ contract GNS is Governed {
// Note - subdomain name and IPFS hash are only emitted through the events.
// Note - if the subdomain is blank, the domain hash ends up being the top level
// domain hash, not the hash of a blank string.
emit SubgraphCreated(
_topLevelDomainHash,
domainHash,
_subdomainName,
msg.sender
);
emit SubgraphCreated(_topLevelDomainHash, domainHash, _subdomainName, msg.sender);
emit SubgraphMetadataChanged(domainHash, _ipfsHash);
}

Expand Down Expand Up @@ -181,10 +153,7 @@ contract GNS is Governed {
*
* @param _domainHash <bytes32> - Hash of the domain name.
*/
function deleteSubdomain(bytes32 _domainHash)
external
onlyDomainOwner(_domainHash)
{
function deleteSubdomain(bytes32 _domainHash) external onlyDomainOwner(_domainHash) {
delete domains[_domainHash];
emit DomainDeleted(_domainHash);
}
Expand All @@ -200,10 +169,7 @@ contract GNS is Governed {
external
onlyDomainOwner(_domainHash)
{
require(
_newOwner != address(0),
"If you want to reset the owner, call deleteSubdomain."
);
require(_newOwner != address(0), "If you want to reset the owner, call deleteSubdomain.");
domains[_domainHash].owner = _newOwner;
emit DomainTransferred(_domainHash, _newOwner);
}
Expand Down
29 changes: 9 additions & 20 deletions contracts/GraphToken.sol
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,11 @@ import "@openzeppelin/contracts/token/ERC20/ERC20Burnable.sol";
import "@openzeppelin/contracts/token/ERC20/ERC20Detailed.sol";


// @imp 08 target _to of transfer(_to, _amount, _data) in Token must implement this interface
// NOTE: This is based off of ERC777TokensRecipient interface, but does not fully implement it
interface TokenReceiver {
function tokensReceived(
address _from,
uint256 _amount,
bytes calldata _data
) external returns (bool);
function tokensReceived(address _from, uint256 _amount, bytes calldata _data)
external
returns (bool);
}


Expand All @@ -30,10 +27,7 @@ contract GraphToken is Governed, ERC20Detailed, ERC20Burnable {
event MinterRemoved(address indexed account);

modifier onlyMinter() {
require(
isMinter(msg.sender) || msg.sender == governor,
"Only minter can call"
);
require(isMinter(msg.sender) || msg.sender == governor, "Only minter can call");
_;
}

Expand Down Expand Up @@ -70,11 +64,7 @@ contract GraphToken is Governed, ERC20Detailed, ERC20Burnable {
_removeMinter(msg.sender);
}

function mint(address _account, uint256 _amount)
external
onlyMinter
returns (bool)
{
function mint(address _account, uint256 _amount) external onlyMinter returns (bool) {
_mint(_account, _amount);
return true;
}
Expand All @@ -84,11 +74,10 @@ contract GraphToken is Governed, ERC20Detailed, ERC20Burnable {
* @notice Interacts with Staking contract
* @notice Overriding `transfer` was not working with web3.js so we renamed to `transferToTokenReceiver`
*/
function transferToTokenReceiver(
address _to,
uint256 _amount,
bytes memory _data
) public returns (bool success) {
function transferToTokenReceiver(address _to, uint256 _amount, bytes memory _data)
public
returns (bool success)
{
assert(super.transfer(_to, _amount)); // Handle basic transfer functionality
// @imp 08 Have staking contract receive the token and handle the data
assert(TokenReceiver(_to).tokensReceived(msg.sender, _amount, _data));
Expand Down
1 change: 1 addition & 0 deletions contracts/Migrations.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
pragma solidity ^0.6.4;


contract Migrations {
address public owner;
uint256 public last_completed_migration;
Expand Down
67 changes: 23 additions & 44 deletions contracts/MultiSigWallet.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
pragma solidity ^0.6.4;


// upgraded from solidity ^0.4.15 (Gnosis MultiSigWallet v1.3.7)

/// @title Multisignature wallet - Allows multiple parties to agree on transactions before execution.
Expand Down Expand Up @@ -183,11 +184,10 @@ contract MultiSigWallet {
/// @param value Transaction ether value.
/// @param data Transaction data payload.
/// @return transactionId Returns transaction ID.
function submitTransaction(
address destination,
uint256 value,
bytes memory data
) public returns (uint256 transactionId) {
function submitTransaction(address destination, uint256 value, bytes memory data)
public
returns (uint256 transactionId)
{
transactionId = addTransaction(destination, value, data);
confirmTransaction(transactionId);
}
Expand Down Expand Up @@ -228,14 +228,8 @@ contract MultiSigWallet {
if (isConfirmed(transactionId)) {
Transaction storage txn = transactions[transactionId];
txn.executed = true;
if (
external_call(
txn.destination,
txn.value,
txn.data.length,
txn.data
)
) emit Execution(transactionId);
if (external_call(txn.destination, txn.value, txn.data.length, txn.data))
emit Execution(transactionId);
else {
emit ExecutionFailure(transactionId);
txn.executed = false;
Expand Down Expand Up @@ -289,11 +283,11 @@ contract MultiSigWallet {
/// @param value Transaction ether value.
/// @param data Transaction data payload.
/// @return transactionId Returns transaction ID.
function addTransaction(
address destination,
uint256 value,
bytes memory data
) internal notNull(destination) returns (uint256 transactionId) {
function addTransaction(address destination, uint256 value, bytes memory data)
internal
notNull(destination)
returns (uint256 transactionId)
{
transactionId = transactionCount;
transactions[transactionId] = Transaction({
destination: destination,
Expand All @@ -311,11 +305,7 @@ contract MultiSigWallet {
/// @dev Returns number of confirmations of a transaction.
/// @param transactionId Transaction ID.
/// @return count Number of confirmations.
function getConfirmationCount(uint256 transactionId)
public
view
returns (uint256 count)
{
function getConfirmationCount(uint256 transactionId) public view returns (uint256 count) {
for (uint256 i = 0; i < owners.length; i++)
if (confirmations[transactionId][owners[i]]) count += 1;
}
Expand All @@ -324,16 +314,10 @@ contract MultiSigWallet {
/// @param pending Include pending transactions.
/// @param executed Include executed transactions.
/// @return count Total number of transactions after filters are applied.
function getTransactionCount(bool pending, bool executed)
public
view
returns (uint256 count)
{
function getTransactionCount(bool pending, bool executed) public view returns (uint256 count) {
for (uint256 i = 0; i < transactionCount; i++)
if (
(pending && !transactions[i].executed) ||
(executed && transactions[i].executed)
) count += 1;
if ((pending && !transactions[i].executed) || (executed && transactions[i].executed))
count += 1;
}

/// @dev Returns list of owners.
Expand Down Expand Up @@ -368,25 +352,20 @@ contract MultiSigWallet {
/// @param pending Include pending transactions.
/// @param executed Include executed transactions.
/// @return _transactionIds Returns array of transaction IDs.
function getTransactionIds(
uint256 from,
uint256 to,
bool pending,
bool executed
) public view returns (uint256[] memory _transactionIds) {
function getTransactionIds(uint256 from, uint256 to, bool pending, bool executed)
public
view
returns (uint256[] memory _transactionIds)
{
uint256[] memory transactionIdsTemp = new uint256[](transactionCount);
uint256 count = 0;
uint256 i;
for (i = 0; i < transactionCount; i++)
if (
(pending && !transactions[i].executed) ||
(executed && transactions[i].executed)
) {
if ((pending && !transactions[i].executed) || (executed && transactions[i].executed)) {
transactionIdsTemp[count] = i;
count += 1;
}
_transactionIds = new uint256[](to - from);
for (i = from; i < to; i++)
_transactionIds[i - from] = transactionIdsTemp[i];
for (i = from; i < to; i++) _transactionIds[i - from] = transactionIdsTemp[i];
}
}
5 changes: 1 addition & 4 deletions contracts/ServiceRegistry.sol
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,7 @@ contract ServiceRegistry is Governed {
* @param _indexer <address> - Address of the indexer
* @param _url <string> - URL of the service provider
*/
function setBootstrapIndexerURL(address _indexer, string calldata _url)
external
onlyGovernor
{
function setBootstrapIndexerURL(address _indexer, string calldata _url) external onlyGovernor {
bytes memory url = bytes(_url);
bootstrapIndexerURLs[_indexer] = url;
emit ServiceUrlSet(_indexer, _url);
Expand Down
33 changes: 0 additions & 33 deletions contracts/channel/funding/proxies/Proxy.sol

This file was deleted.

Loading