convert hash to bytes in contract
This commit is contained in:
parent
8963427f64
commit
8837315c30
|
@ -14,7 +14,7 @@ export function addContributor(name, address) {
|
||||||
|
|
||||||
const newHash = await saveContributorList(list);
|
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});
|
let gas = await addContributor.estimateGas({from: mainAccount});
|
||||||
const receipt = await addContributor.send({from: mainAccount, gas: gas + 1000});
|
const receipt = await addContributor.send({from: mainAccount, gas: gas + 1000});
|
||||||
|
|
||||||
|
@ -41,7 +41,7 @@ export function removeContributor(address) {
|
||||||
|
|
||||||
const newHash = await saveContributorList(list);
|
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});
|
let gas = await removeContributor.estimateGas({from: mainAccount});
|
||||||
const receipt = await removeContributor.send({from: mainAccount, gas: gas + 1000});
|
const receipt = await removeContributor.send({from: mainAccount, gas: gas + 1000});
|
||||||
|
|
||||||
|
@ -60,6 +60,7 @@ export function getContributorList(hash) {
|
||||||
try {
|
try {
|
||||||
if (!hash) {
|
if (!hash) {
|
||||||
hash = await Meritocracy.methods.contributorListIPFSHash().call();
|
hash = await Meritocracy.methods.contributorListIPFSHash().call();
|
||||||
|
hash = web3.utils.hexToAscii(hash);
|
||||||
}
|
}
|
||||||
|
|
||||||
const content = await EmbarkJS.Storage.get(hash);
|
const content = await EmbarkJS.Storage.get(hash);
|
||||||
|
|
|
@ -8,7 +8,7 @@ function getContributors () {
|
||||||
return addresses;
|
return addresses;
|
||||||
}
|
}
|
||||||
|
|
||||||
const OG_IPFS_HASH = 'QmREHBNWoJCx8KDz7PBAThv8mrxGRWimbzqZsL8aDzfLHW';
|
const OG_IPFS_HASH = '0x516d524548424e576f4a4378384b447a37504241546876386d7278475257696d627a715a734c3861447a664c4857';
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
// default applies to all environments
|
// default applies to all environments
|
||||||
|
|
|
@ -49,7 +49,7 @@ contract Meritocracy {
|
||||||
uint256 public maxContributors; // Dynamic finite limit on registry.
|
uint256 public maxContributors; // Dynamic finite limit on registry.
|
||||||
mapping(address => bool) public admins;
|
mapping(address => bool) public admins;
|
||||||
mapping(address => Contributor) public contributors;
|
mapping(address => Contributor) public contributors;
|
||||||
string public contributorListIPFSHash;
|
bytes public contributorListIPFSHash;
|
||||||
|
|
||||||
Meritocracy public previousMeritocracy; // Reference and read from previous contract
|
Meritocracy public previousMeritocracy; // Reference and read from previous contract
|
||||||
|
|
||||||
|
@ -191,7 +191,7 @@ contract Meritocracy {
|
||||||
// Admin Functions -------------------------------------------------------------------------------------
|
// Admin Functions -------------------------------------------------------------------------------------
|
||||||
|
|
||||||
// Add Contributor to Registry
|
// Add Contributor to Registry
|
||||||
function addContributor(address _contributor, string memory _contributorListIPFSHash) public onlyAdmin {
|
function addContributor(address _contributor, bytes memory _contributorListIPFSHash) public onlyAdmin {
|
||||||
addContributorWithoutHash(_contributor);
|
addContributorWithoutHash(_contributor);
|
||||||
|
|
||||||
// Set new IPFS hash for the list
|
// Set new IPFS hash for the list
|
||||||
|
@ -210,7 +210,7 @@ contract Meritocracy {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add Multiple Contributors to the Registry in one tx
|
// 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
|
// Locals
|
||||||
uint256 newContributorLength = _newContributors.length;
|
uint256 newContributorLength = _newContributors.length;
|
||||||
// Requirements
|
// Requirements
|
||||||
|
@ -226,7 +226,7 @@ contract Meritocracy {
|
||||||
// Remove Contributor from Registry
|
// Remove Contributor from Registry
|
||||||
// Note: Should not be easy to remove multiple contributors in one tx
|
// Note: Should not be easy to remove multiple contributors in one tx
|
||||||
// WARN: Changed to idx, client can do loop by enumerating registry
|
// 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
|
// Locals
|
||||||
uint256 registryLength = registry.length - 1;
|
uint256 registryLength = registry.length - 1;
|
||||||
// Requirements
|
// Requirements
|
||||||
|
@ -340,7 +340,7 @@ contract Meritocracy {
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// Set Owner, Token address, initial maxContributors
|
// 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
|
// Body
|
||||||
owner = msg.sender;
|
owner = msg.sender;
|
||||||
addAdmin(owner);
|
addAdmin(owner);
|
||||||
|
|
|
@ -8,7 +8,7 @@ let owner;
|
||||||
let admins;
|
let admins;
|
||||||
let ownerInitTokens;
|
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
|
// For documentation please see https://embark.status.im/docs/contracts_testing.html
|
||||||
config({
|
config({
|
||||||
|
|
Loading…
Reference in New Issue