How to use the web3.utils.toChecksumAddress function in web3

To help you get started, we’ve selected a few web3 examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github AztecProtocol / AZTEC / packages / extension / src / utils / __tests__ / metadata.spec.js View on Github external
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],
        });
    });
github AztecProtocol / AZTEC / packages / extension / src / utils / __tests__ / metadata.spec.js View on Github external
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('');
github AztecProtocol / AZTEC / packages / extension / src / utils / __tests__ / metadata.spec.js View on Github external
    .map(a => utils.toChecksumAddress(a).slice(2))
    .map(a => a.padStart(MIN_BYTES_VAR_LENGTH, '0'))
github poanetwork / tokenbridge / monitor / utils / message.js View on Github external
function messageEqualsEvent(parsedMsg, event) {
  return (
    web3Utils.toChecksumAddress(parsedMsg.sender) === event.sender &&
    web3Utils.toChecksumAddress(parsedMsg.executor) === event.executor &&
    parsedMsg.txHash === event.transactionHash
  )
}
github AztecProtocol / AZTEC / packages / extension / src / utils / address / index.js View on Github external
export default function address(str) {
    const bytes = (str || '').replace(/^0x/, '').toLowerCase();

    if (!bytes.match(addressPattern)) {
        return '';
    }

    return utils.toChecksumAddress(`0x${bytes}`);
}
github poanetwork / tokenbridge / monitor / utils / message.js View on Github external
function messageEqualsEvent(parsedMsg, event) {
  return (
    web3Utils.toChecksumAddress(parsedMsg.sender) === event.sender &&
    web3Utils.toChecksumAddress(parsedMsg.executor) === event.executor &&
    parsedMsg.txHash === event.transactionHash
  )
}
github AztecProtocol / AZTEC / packages / extension / src / utils / metadata / constructor.js View on Github external
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] || '');
    });
github MyEtherWallet / ethereum-lists / generateMasterFile.js View on Github external
const matchedImage = images.find(img => {
          return img.includes(`${utils.toChecksumAddress(item.address).toLowerCase()}`)
        })
        mainArr.push({