Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
.map(methodSignature => soliditySha3(methodSignature)) // keccak256
.map(h =>
const REWARD = WAD.muln(0); // No reward currently
const INITIAL_FUNDING = WAD.muln(360);
const MANAGER_PAYOUT = WAD.muln(100);
const EVALUATOR_PAYOUT = WAD.muln(50);
const WORKER_PAYOUT = WAD.muln(200);
const MAX_PAYOUT = UINT128_MAX;
const MANAGER_RATING = 2;
const WORKER_RATING = 2;
const RATING_MULTIPLIER = { 1: -1, 2: 1, 3: 1.5 };
const RATING_1_SALT = soliditySha3(shortid.generate());
const RATING_2_SALT = soliditySha3(shortid.generate());
const RATING_1_SECRET = soliditySha3(RATING_1_SALT, MANAGER_RATING);
const RATING_2_SECRET = soliditySha3(RATING_2_SALT, WORKER_RATING);
const ACTIVE_TASK_STATE = 0;
const CANCELLED_TASK_STATE = 1;
const FINALIZED_TASK_STATE = 2;
const SECONDS_PER_DAY = 86400;
const MINING_CYCLE_DURATION = 60 * 60 * 24; // 24 hours
const DECAY_RATE = {
NUMERATOR: new BN("992327946262944"), // eslint-disable-line prettier/prettier
DENOMINATOR: new BN("1000000000000000")
};
const GLOBAL_SKILL_ID = new BN("3"); // Not a root global skill ID or anything, just the first global skill's ID
module.exports = {
});
Object.keys(deployedImplementations).map(name => parseImplementation(name, functionsToResolve, deployedImplementations));
// Iterate over the ABI again to make sure we get overloads - the functionToResolve is only indexed by name, not signature.
for (let i = 0; i < iAbi.length; i += 1) {
// We do it like this rather than a nice await Promise.all on a mapped array of promises because of
// https://github.com/paritytech/parity-ethereum/issues/9155
const fName = iAbi[i].name;
if (functionsToResolve[fName]) {
const sig = `${fName}(${iAbi[i].inputs.map(parameter => parameter.type).join(",")})`;
const address = functionsToResolve[fName].definedIn;
try {
await resolver.register(sig, address);
} catch (err) {
throw new Error(`${sig} could not be registered. Is it defined?`);
}
const sigHash = soliditySha3(sig).substr(0, 10);
const destination = await resolver.lookup(sigHash);
assert.equal(destination, address, `${sig} has not been registered correctly. Is it defined?`);
}
}
}
sortedHashes.push(soliditySha3(key))
sortedHashes.sort()
keyPosition = sortedHashes.indexOf(soliditySha3(key));
}
let adjacentKeyPosition;
if (keyPosition === 0){
adjacentKeyPosition = keyPosition + 1;
} else if (keyPosition === sortedHashes.length - 1){
adjacentKeyPosition = keyPosition - 1;
} else {
const possibleAdjacentKeyHash1 = new BN(sortedHashes[keyPosition - 1].slice(2), 16);
const possibleAdjacentKeyHash2 = new BN(sortedHashes[keyPosition + 1].slice(2), 16);
// Which is most similar, bitwise?
// Pick the key that has the most similarity to the reputation being questioned.
const keyHash = new BN(soliditySha3(key).slice(2), 16);
if (possibleAdjacentKeyHash1.xor(keyHash).lt(possibleAdjacentKeyHash2.xor(keyHash))) {
// Note that these xor'd numbers can never be equal
adjacentKeyPosition = keyPosition - 1;
} else {
adjacentKeyPosition = keyPosition + 1;
}
}
return this.reverseReputationHashLookup[sortedHashes[adjacentKeyPosition]];
}
let domain1;
let domain2;
let domain3;
let metaColony;
let colonyNetwork;
let voting;
let votingFactory;
let reputationTree;
const USER0 = accounts[0];
const USER1 = accounts[1];
const MINER = accounts[5];
const SALT = soliditySha3(shortid.generate());
const FAKE = soliditySha3(shortid.generate());
const WAD2 = WAD.muln(2);
before(async () => {
colonyNetwork = await setupColonyNetwork();
({ metaColony } = await setupMetaColonyWithLockedCLNYToken(colonyNetwork));
await giveUserCLNYTokensAndStake(colonyNetwork, MINER, DEFAULT_STAKE);
await colonyNetwork.initialiseReputationMining();
await colonyNetwork.startNextCycle();
votingFactory = await VotingReputationFactory.new();
});
beforeEach(async () => {
({ colony } = await setupRandomColony(colonyNetwork));
export function attestationMessageToSign(phoneHash: string, account: string) {
const messageHash: string = Web3Utils.soliditySha3(
{ type: 'bytes32', value: phoneHash },
{ type: 'address', value: account }
)
return messageHash
}
export function attestationMessageToSign(phoneHash: string, account: string) {
const messageHash: string = Web3Utils.soliditySha3(
{ type: 'bytes32', value: phoneHash },
{ type: 'address', value: account }
)
return messageHash
}
let k = PatriciaTreeBase.makeLabel(key, 256);
const valueHash = PatriciaTreeBase.sha3(value);
const e = {};
e.nodeHash = valueHash;
const edgeHashes = [];
for (let i = 0; i < siblings.length; i += 1) {
const bitSet = branchMask.zeroBits();
branchMask = branchMask.and(new BN(1).shln(bitSet).notn(256));
[k, e.label] = PatriciaTreeBase.splitAt(k, 255 - bitSet);
const [bit, newLabel] = PatriciaTreeBase.chopFirstBit(e.label);
e.label = newLabel;
edgeHashes[bit] = PatriciaTreeBase.edgeEncodingHash(e);
edgeHashes[1 - bit] = PatriciaTreeBase.sha2bn(siblings[siblings.length - i - 1]);
e.nodeHash = PatriciaTreeBase.sha2bn(
soliditySha3(PatriciaTreeBase.bn2hex64(edgeHashes[0]), PatriciaTreeBase.bn2hex64(edgeHashes[1]))
);
}
if (branchMask.zeroBits().toString() === "0") {
e.label = k;
} else {
const bitSet = branchMask.zeroBits();
[k, e.label] = PatriciaTreeBase.splitAt(k, 255 - bitSet);
const [, newLabel] = PatriciaTreeBase.chopFirstBit(e.label);
e.label = newLabel;
}
return PatriciaTreeBase.bn2hex64(PatriciaTreeBase.edgeEncodingHash(e));
}
function hashForSetState(hash: string, round: number, channelAddress: string) {
return Web3Util.soliditySha3(
{
t: "bytes32",
v: hash
},
{
t: "uint",
v: round
},
{
t: "address",
v: channelAddress
}
);
}
function getPhoneHash(phoneNumber: string): string {
if (!phoneNumber || !isE164Number(phoneNumber)) {
throw Error('Attempting to hash a non-e164 number: ' + phoneNumber)
}
return Web3Utils.soliditySha3({ type: 'string', value: phoneNumber })
}