Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it('get access by address', () => {
const m = metadata(metadataStr);
expect(m.getAccess(addressBytes[0])).toEqual({
address: utils.toChecksumAddress(addressBytes[0]),
viewingKey: viewingKeyBytes[0],
});
expect(m.getAccess(addressBytes[1])).toEqual({
address: utils.toChecksumAddress(addressBytes[1]),
viewingKey: viewingKeyBytes[1],
});
});
it('allow empty metadataStr', () => {
const newMetadata = addAccess('', [
{
address: addressBytes[0],
viewingKey: viewingKeyBytes[0],
},
]);
const addressStr = padValues(
utils.toChecksumAddress(addresses[0]).slice(2).padStart(MIN_BYTES_VAR_LENGTH, '0'),
MIN_BYTES_VAR_LENGTH,
);
const viewingKeyStr = padValues(
viewingKeys[0].padStart(MIN_BYTES_VAR_LENGTH, '0'),
VIEWING_KEY_LENGTH,
);
const expectedStr = [
'0x',
''.padStart(METADATA_AZTEC_DATA_LENGTH, '0'),
padOffset(fixedOffset),
padOffset(fixedOffset + addressStr.length),
padOffset(fixedOffset + addressStr.length + viewingKeyStr.length),
addressStr,
viewingKeyStr,
padValues('', 0),
].join('');
.map(a => utils.toChecksumAddress(a).slice(2))
.map(a => a.padStart(MIN_BYTES_VAR_LENGTH, '0'))
function messageEqualsEvent(parsedMsg, event) {
return (
web3Utils.toChecksumAddress(parsedMsg.sender) === event.sender &&
web3Utils.toChecksumAddress(parsedMsg.executor) === event.executor &&
parsedMsg.txHash === event.transactionHash
)
}
export default function address(str) {
const bytes = (str || '').replace(/^0x/, '').toLowerCase();
if (!bytes.match(addressPattern)) {
return '';
}
return utils.toChecksumAddress(`0x${bytes}`);
}
function messageEqualsEvent(parsedMsg, event) {
return (
web3Utils.toChecksumAddress(parsedMsg.sender) === event.sender &&
web3Utils.toChecksumAddress(parsedMsg.executor) === event.executor &&
parsedMsg.txHash === event.transactionHash
)
}
segLen = length !== undefined
? Math.max(length, MIN_BYTES_VAR_LENGTH)
: metadataStr.length - start;
}
let val = metadataStr
.substr(
start,
segLen,
);
if (isLenVar) {
val = parseInt(val, 16);
} else if (length) {
val = val.slice(segLen - (length || 0));
}
if (name === 'addresses') {
arr.push(utils.toChecksumAddress(val));
} else {
arr.push(val ? `0x${val}` : '');
}
start += segLen;
}
const isArrayValue = isDynamic && (length !== undefined);
metadata[name] = isArrayValue
? arr
: (arr[0] || '');
});
const matchedImage = images.find(img => {
return img.includes(`${utils.toChecksumAddress(item.address).toLowerCase()}`)
})
mainArr.push({