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 basex_1.Base58.encode(bytes_1.concat([data, bytes_1.hexDataSlice(sha2_1.sha256(sha2_1.sha256(data)), 0, 4)]));
}
var _constructorGuard = {};
return [4 /*yield*/, resolver.contenthash(nodehash).then(function (hash) {
if (hash === "0x") {
return "";
}
if (hash.substring(0, 10) === "0xe3010170" && ethers_1.ethers.utils.isHexString(hash, 38)) {
return basex_1.Base58.encode(ethers_1.ethers.utils.hexDataSlice(hash, 4)) + " (IPFS)";
}
return hash + " (unknown format)";
}, function (error) { return (""); })];
case 15:
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
if (!(key === "hash")) return [3 /*break*/, 2];
bytes = basex_1.Base58.decode(value);
if (bytes.length !== 34 || bytes[0] !== 18 || bytes[1] !== 32) {
this.throwError("Unsupported IPFS hash");
}
multihash = ethers_1.ethers.utils.concat(["0xe3010170", bytes]);
return [4 /*yield*/, _super.prototype._setValue.call(this, "multihash", ethers_1.ethers.utils.hexlify(multihash))];
case 1:
_a.sent();
_a.label = 2;
case 2: return [4 /*yield*/, _super.prototype._setValue.call(this, key, value)];
case 3:
_a.sent();
return [2 /*return*/];
}
});
});