Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function hashFile(file) {
var body = fs.readFileSync(file);
console.log("##############################");
console.log(body);
console.log("##############################");
console.log(body.toString('base64'));
console.log("##############################");
return keccak256(body.toString());
}
signHash() {
return Buffer.from(keccak256(this.encode()), 'hex')
}
import register from 'module-alias/register'
import Repository from '@components/repository'
import RemoteBranchFactory from '@factories/remote-branch-factory'
import CID from 'cids'
import { hash } from 'eth-ens-namehash'
import ethereumRegex from 'ethereum-regex'
import IPFS from 'ipfs-api'
import isIPFS from 'is-ipfs'
import { keccak256, sha3_256 } from 'js-sha3'
import util from 'util'
import web3Utils from 'web3-utils'
export default class Remote {
public static APP_NAMESPACE = '0x' + keccak256('app')
public static APP_BASE_NAMESPACE = '0x' + keccak256('base')
public static TREE_BASE_APP_ID = hash('tree.pando.aragonpm.test')
public static TREE_APP_ID = web3Utils.sha3(
Remote.APP_BASE_NAMESPACE + Remote.TREE_BASE_APP_ID.substring(2),
{ encoding: 'hex' }
)
public static PROXY_APP_ID = web3Utils.sha3(
Remote.APP_NAMESPACE + Remote.TREE_BASE_APP_ID.substring(2),
{ encoding: 'hex' }
)
public static async at(
repository: Repository,
kernelAddress: string
): Promise {
const kernel = await repository.pando.contracts.kernel.at(kernelAddress)
static publicKeyToAddress(pubKey) {
const publicKey = (pubKey.length === 65) ? pubKey.slice(1) : pubKey
const hash = keccak256(publicKey).toString()
return ByteArray.fromHexString(address)
}
setId () {
let key = ''
if (this.checkSet()) {
const keyString = this.rights.basis +
this.rights.status +
this.rights.countryCode +
this.rights.determinationDate +
this.rights.act + this.rights.restriction
key = keccak256(keyString)
}
this.rights.id = key
}
function libraryHashPlaceholder (input) {
return '$' + keccak256(input).slice(0, 34) + '$';
}
case 2:
PUSH = _b.sent();
return [4 /*yield*/, this.acl.grantPermission(who, this.tree.address, PUSH, {
from: this.repository.config.author.account
})];
case 3:
receipt = _b.sent();
return [3 /*break*/, 5];
case 4: throw new TypeError("'" + what + "' is not a valid role");
case 5: return [2 /*return*/, receipt];
}
});
});
};
Remote.APP_NAMESPACE = '0x' + js_sha3_1.keccak256('app');
Remote.APP_BASE_NAMESPACE = '0x' + js_sha3_1.keccak256('base');
Remote.TREE_BASE_APP_ID = eth_ens_namehash_1.hash('tree.pando.aragonpm.test');
Remote.TREE_APP_ID = web3_utils_1.default.sha3(Remote.APP_BASE_NAMESPACE + Remote.TREE_BASE_APP_ID.substring(2), { encoding: 'hex' });
Remote.PROXY_APP_ID = web3_utils_1.default.sha3(Remote.APP_NAMESPACE + Remote.TREE_BASE_APP_ID.substring(2), { encoding: 'hex' });
return Remote;
}());
exports.default = Remote;
Commitment.prototype.hash = function() {
const buf = keccak256(abi.rawEncode(
['bytes32', 'bytes32', 'address', 'uint256', 'uint256', 'address', 'address', 'address[]', 'uint256[]'],
[SCHEMA_HASH, this.bidId, this.tokenAddr, this.tokenAmount, this.validUntil, this.advertiser, this.publisher, this.validators, this.validatorRewards]
))
return '0x'+buf.toString(16)
}
function pubToAddrStr(pub) {
return keccak256(pub).slice(-40);
}