Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function base58check(data) {
return Base58.encode(concat([data, hexDataSlice(sha256(sha256(data)), 0, 4)]));
}
const _constructorGuard = {};
function base58check(data: Uint8Array): string {
return Base58.encode(concat([ data, hexDataSlice(sha256(sha256(data)), 0, 4) ]));
}
function getContractAddress(transaction) {
var from = null;
try {
from = getAddress(transaction.from);
}
catch (error) {
logger.throwArgumentError("missing from address", "transaction", transaction);
}
var nonce = bytes_1.stripZeros(bytes_1.arrayify(bignumber_1.BigNumber.from(transaction.nonce).toHexString()));
return getAddress(bytes_1.hexDataSlice(keccak256_1.keccak256(rlp_1.encode([from, nonce])), 12));
}
exports.getContractAddress = getContractAddress;
export function computeAddress(key) {
const publicKey = computePublicKey(key);
return getAddress(hexDataSlice(keccak256(hexDataSlice(publicKey, 1)), 12));
}
export function recoverAddress(digest, signature) {
_sighashify(functionFragment) {
return hexDataSlice(id(functionFragment.format()), 0, 4);
}
_topicify(eventFragment) {
function computeAddress(key) {
var publicKey = signing_key_1.computePublicKey(key);
return address_1.getAddress(bytes_1.hexDataSlice(keccak256_1.keccak256(bytes_1.hexDataSlice(publicKey, 1)), 12));
}
exports.computeAddress = computeAddress;
callAddress(value) {
if (!isHexString(value, 32)) {
return null;
}
let address = getAddress(hexDataSlice(value, 12));
return (address === AddressZero) ? null : address;
}
contractAddress(value) {
if (constructorGuard !== _constructorGuard) {
throw new Error("HDNode constructor cannot be called directly");
}
if (privateKey) {
const signingKey = new SigningKey(privateKey);
defineReadOnly(this, "privateKey", signingKey.privateKey);
defineReadOnly(this, "publicKey", signingKey.compressedPublicKey);
} else {
defineReadOnly(this, "privateKey", null);
defineReadOnly(this, "publicKey", hexlify(publicKey));
}
defineReadOnly(this, "parentFingerprint", parentFingerprint);
defineReadOnly(this, "fingerprint", hexDataSlice(ripemd160(sha256(this.publicKey)), 0, 4));
defineReadOnly(this, "address", computeAddress(this.publicKey));
defineReadOnly(this, "chainCode", chainCode);
defineReadOnly(this, "index", index);
defineReadOnly(this, "depth", depth);
defineReadOnly(this, "mnemonic", mnemonic);
defineReadOnly(this, "path", path);
}