Rename Contributors function parameter to be more consitent
This commit is contained in:
parent
ef3b3dd6bb
commit
163a57af98
@ -20,8 +20,8 @@ contract Contributors is Upgradeable {
|
|||||||
uint256 public contributorsCount;
|
uint256 public contributorsCount;
|
||||||
|
|
||||||
event ContributorProfileUpdated(uint id, bytes32 oldIpfsHash, bytes32 newIpfsHash);
|
event ContributorProfileUpdated(uint id, bytes32 oldIpfsHash, bytes32 newIpfsHash);
|
||||||
event ContributorAddressUpdated(uint id, address oldAddress, address newAddress);
|
event ContributorAccountUpdated(uint id, address oldAccount, address newAccount);
|
||||||
event ContributorAdded(uint id, address _address);
|
event ContributorAdded(uint id, address account);
|
||||||
|
|
||||||
modifier onlyCoreOrOperator() {
|
modifier onlyCoreOrOperator() {
|
||||||
require(msg.sender == registry.getProxyFor('Operator') || addressIsCore(msg.sender));
|
require(msg.sender == registry.getProxyFor('Operator') || addressIsCore(msg.sender));
|
||||||
@ -49,71 +49,72 @@ contract Contributors is Upgradeable {
|
|||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateContributorAddress(uint _id, address _oldAddress, address _newAddress) public onlyCoreOrOperator {
|
function updateContributorAddress(uint id, address oldAccount, address newAccount) public onlyCoreOrOperator {
|
||||||
contributorIds[_oldAddress] = 0;
|
contributorIds[oldAccount] = 0;
|
||||||
contributorIds[_newAddress] = _id;
|
contributorIds[newAccount] = id;
|
||||||
contributors[_id].account = _newAddress;
|
contributors[id].account = newAccount;
|
||||||
ContributorAddressUpdated(_id, _oldAddress, _newAddress);
|
ContributorAccountUpdated(id, oldAccount, newAccount);
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateContributorIpfsHash(uint _id, bytes32 _ipfsHash, uint8 _hashFunction, uint8 _hashSize) public onlyCoreOrOperator {
|
function updateContributorIpfsHash(uint id, bytes32 ipfsHash, uint8 hashFunction, uint8 hashSize) public onlyCoreOrOperator {
|
||||||
Contributor storage c = contributors[_id];
|
Contributor storage c = contributors[id];
|
||||||
bytes32 _oldIpfsHash = c.ipfsHash;
|
bytes32 oldIpfsHash = c.ipfsHash;
|
||||||
c.ipfsHash = _ipfsHash;
|
c.ipfsHash = ipfsHash;
|
||||||
c.hashFunction = _hashFunction;
|
c.hashFunction = hashFunction;
|
||||||
c.hashSize = _hashSize;
|
c.hashSize = hashSize;
|
||||||
|
|
||||||
ContributorProfileUpdated(_id, _oldIpfsHash, c.ipfsHash);
|
ContributorProfileUpdated(id, oldIpfsHash, c.ipfsHash);
|
||||||
}
|
}
|
||||||
|
|
||||||
function addContributor(address _address, bytes32 _ipfsHash, uint8 _hashFunction, uint8 _hashSize, bool _isCore) public onlyCoreOrOperator {
|
function addContributor(address account, bytes32 ipfsHash, uint8 hashFunction, uint8 hashSize, bool isCore) public onlyCoreOrOperator {
|
||||||
require(!addressExists(_address));
|
require(!addressExists(account));
|
||||||
uint _id = contributorsCount + 1;
|
uint _id = contributorsCount + 1;
|
||||||
assert(!contributors[_id].exists); // this can not be acually
|
assert(!contributors[_id].exists); // this can not be acually
|
||||||
Contributor storage c = contributors[_id];
|
Contributor storage c = contributors[_id];
|
||||||
c.exists = true;
|
c.exists = true;
|
||||||
c.isCore = _isCore;
|
c.isCore = isCore;
|
||||||
c.hashFunction = _hashFunction;
|
c.ipfsHash = ipfsHash;
|
||||||
c.hashSize = _hashSize;
|
c.hashFunction = hashFunction;
|
||||||
c.ipfsHash = _ipfsHash;
|
c.hashSize = hashSize;
|
||||||
c.account = _address;
|
c.account = account;
|
||||||
contributorIds[_address] = _id;
|
contributorIds[account] = _id;
|
||||||
|
|
||||||
contributorsCount += 1;
|
contributorsCount += 1;
|
||||||
ContributorAdded(_id, _address);
|
ContributorAdded(_id, account);
|
||||||
}
|
}
|
||||||
|
|
||||||
function isCore(uint _id) view public returns (bool) {
|
function isCore(uint id) view public returns (bool) {
|
||||||
return contributors[_id].isCore;
|
return contributors[id].isCore;
|
||||||
}
|
}
|
||||||
|
|
||||||
function exists(uint _id) view public returns (bool) {
|
function exists(uint id) view public returns (bool) {
|
||||||
return contributors[_id].exists;
|
return contributors[id].exists;
|
||||||
}
|
}
|
||||||
|
|
||||||
function addressIsCore(address _address) view public returns (bool) {
|
function addressIsCore(address account) view public returns (bool) {
|
||||||
return getContributorByAddress(_address).isCore;
|
return getContributorByAddress(account).isCore;
|
||||||
}
|
}
|
||||||
|
|
||||||
function addressExists(address _address) view public returns (bool) {
|
function addressExists(address account) view public returns (bool) {
|
||||||
return getContributorByAddress(_address).exists;
|
return getContributorByAddress(account).exists;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getContributorIdByAddress(address _address) view public returns (uint) {
|
function getContributorIdByAddress(address account) view public returns (uint) {
|
||||||
return contributorIds[_address];
|
return contributorIds[account];
|
||||||
}
|
}
|
||||||
|
|
||||||
function getContributorAddressById(uint _id) view public returns (address) {
|
function getContributorAddressById(uint id) view public returns (address) {
|
||||||
return contributors[_id].account;
|
return contributors[id].account;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getContributorByAddress(address _address) internal view returns (Contributor) {
|
function getContributorByAddress(address account) internal view returns (Contributor) {
|
||||||
uint id = contributorIds[_address];
|
uint id = contributorIds[account];
|
||||||
return contributors[id];
|
return contributors[id];
|
||||||
}
|
}
|
||||||
|
|
||||||
function getContributorById(uint _id) view returns (address account, bytes32 ipfsHash, uint8 hashFunction, uint8 hashSize, bool isCore, uint balance, bool exists ) {
|
function getContributorById(uint _id) public view returns (uint id, address account, bytes32 ipfsHash, uint8 hashFunction, uint8 hashSize, bool isCore, uint balance, bool exists ) {
|
||||||
Contributor c = contributors[_id];
|
id = _id;
|
||||||
|
Contributor storage c = contributors[_id];
|
||||||
account = c.account;
|
account = c.account;
|
||||||
ipfsHash = c.ipfsHash;
|
ipfsHash = c.ipfsHash;
|
||||||
hashFunction = c.hashFunction;
|
hashFunction = c.hashFunction;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user