Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function getTokenIdFromRaw(rawTokenId) {
var err = checkParams({ rawTokenId: rawTokenId }, ['rawTokenId'], [{
name: 'rawTokenId',
func: function (_t) { return /^[0-9a-fA-F]+$/.test(_t) && _t.length === 20; }
}]);
if (err) {
console.error(new Error(err.message));
return null;
}
var checkSum = blake.blake2bHex(Buffer.from(rawTokenId, 'hex'), null, 2);
return "tti_" + rawTokenId + checkSum;
}
exports.getTokenIdFromRaw = getTokenIdFromRaw;
function getTokenIdFromRaw(rawTokenId) {
var err = checkParams({ rawTokenId: rawTokenId }, ['rawTokenId'], [{
name: 'rawTokenId',
func: function (_t) { return /^[0-9a-fA-F]+$/.test(_t) && _t.length === 20; }
}]);
if (err) {
throw new Error(err.message);
}
var checkSum = blake.blake2bHex(Buffer.from(rawTokenId, 'hex'), null, 2);
return "tti_" + rawTokenId + checkSum;
}
exports.getTokenIdFromRaw = getTokenIdFromRaw;
function getTokenIdCheckSum(originalTokenId: Hex): Hex {
return blake.blake2bHex(Buffer.from(originalTokenId, 'hex'), null, 2);
}
async getNonce(): Promise {
const err = checkParams({
difficulty: this.difficulty,
previousHash: this.previousHash
}, [ 'difficulty', 'previousHash' ]);
if (err) {
throw err;
}
const getNonceHashBuffer = Buffer.from(this.originalAddress + this.previousHash, 'hex');
const getNonceHash = blake.blake2bHex(getNonceHashBuffer, null, 32);
const nonce: Base64 = this.provider.request('util_getPoWNonce', this.difficulty, getNonceHash);
return nonce;
}
export function getDataHex(data: Base64): Hex {
return data ? blake.blake2bHex(Buffer.from(data, 'base64'), null, 32) : '';
}
function getAddrCheckSum(addr) {
var res = blake.blake2bHex(addr, null, ADDR_CHECK_SUM_SIZE);
return res;
}