diff --git a/app/js/services/Meritocracy.js b/app/js/services/Meritocracy.js index f72a91d..185495a 100644 --- a/app/js/services/Meritocracy.js +++ b/app/js/services/Meritocracy.js @@ -14,7 +14,7 @@ export function addContributor(name, address) { const newHash = await saveContributorList(list); - const addContributor = Meritocracy.methods.addContributor(address, newHash); + const addContributor = Meritocracy.methods.addContributor(address, web3.utils.toHex(newHash)); let gas = await addContributor.estimateGas({from: mainAccount}); const receipt = await addContributor.send({from: mainAccount, gas: gas + 1000}); @@ -41,7 +41,7 @@ export function removeContributor(address) { const newHash = await saveContributorList(list); - const removeContributor = Meritocracy.methods.removeContributor(index, newHash); + const removeContributor = Meritocracy.methods.removeContributor(index, web3.utils.toHex(newHash)); let gas = await removeContributor.estimateGas({from: mainAccount}); const receipt = await removeContributor.send({from: mainAccount, gas: gas + 1000}); @@ -60,6 +60,7 @@ export function getContributorList(hash) { try { if (!hash) { hash = await Meritocracy.methods.contributorListIPFSHash().call(); + hash = web3.utils.hexToAscii(hash); } const content = await EmbarkJS.Storage.get(hash); diff --git a/config/contracts.js b/config/contracts.js index 0d103f7..709deb7 100644 --- a/config/contracts.js +++ b/config/contracts.js @@ -8,7 +8,7 @@ function getContributors () { return addresses; } -const OG_IPFS_HASH = 'QmREHBNWoJCx8KDz7PBAThv8mrxGRWimbzqZsL8aDzfLHW'; +const OG_IPFS_HASH = '0x516d524548424e576f4a4378384b447a37504241546876386d7278475257696d627a715a734c3861447a664c4857'; module.exports = { // default applies to all environments diff --git a/contracts/Meritocracy.sol b/contracts/Meritocracy.sol index d29c80d..ad26d39 100644 --- a/contracts/Meritocracy.sol +++ b/contracts/Meritocracy.sol @@ -49,7 +49,7 @@ contract Meritocracy { uint256 public maxContributors; // Dynamic finite limit on registry. mapping(address => bool) public admins; mapping(address => Contributor) public contributors; - string public contributorListIPFSHash; + bytes public contributorListIPFSHash; Meritocracy public previousMeritocracy; // Reference and read from previous contract @@ -191,7 +191,7 @@ contract Meritocracy { // Admin Functions ------------------------------------------------------------------------------------- // Add Contributor to Registry - function addContributor(address _contributor, string memory _contributorListIPFSHash) public onlyAdmin { + function addContributor(address _contributor, bytes memory _contributorListIPFSHash) public onlyAdmin { addContributorWithoutHash(_contributor); // Set new IPFS hash for the list @@ -210,7 +210,7 @@ contract Meritocracy { } // Add Multiple Contributors to the Registry in one tx - function addContributors(address[] calldata _newContributors, string calldata _contributorListIPFSHash) external onlyAdmin { + function addContributors(address[] calldata _newContributors, bytes calldata _contributorListIPFSHash) external onlyAdmin { // Locals uint256 newContributorLength = _newContributors.length; // Requirements @@ -226,7 +226,7 @@ contract Meritocracy { // Remove Contributor from Registry // Note: Should not be easy to remove multiple contributors in one tx // WARN: Changed to idx, client can do loop by enumerating registry - function removeContributor(uint256 idx, string calldata _contributorListIPFSHash) external onlyAdmin { // address _contributor + function removeContributor(uint256 idx, bytes calldata _contributorListIPFSHash) external onlyAdmin { // address _contributor // Locals uint256 registryLength = registry.length - 1; // Requirements @@ -340,7 +340,7 @@ contract Meritocracy { // } // Set Owner, Token address, initial maxContributors - constructor(address _token, uint256 _maxContributors, string memory _contributorListIPFSHash) public { + constructor(address _token, uint256 _maxContributors, bytes memory _contributorListIPFSHash) public { // Body owner = msg.sender; addAdmin(owner); diff --git a/test/Meritocracy_spec.js b/test/Meritocracy_spec.js index 4351d7b..9985cf2 100644 --- a/test/Meritocracy_spec.js +++ b/test/Meritocracy_spec.js @@ -8,7 +8,7 @@ let owner; let admins; let ownerInitTokens; -const IPFS_HASH = 'QmfWJJYFBJReu2rzTDzkBKXHazE52GVWrTcVNKdcupnxNH'; +const IPFS_HASH = web3.utils.toHex('QmREHBNWoJCx8KDz7PBAThv8mrxGRWimbzqZsL8aDzfLHW'); // For documentation please see https://embark.status.im/docs/contracts_testing.html config({