Skip to content
This repository has been archived by the owner on Jun 17, 2021. It is now read-only.

Published toChecksumAddress function deviates from docs and TypeScript source #218

Closed
rekmarks opened this issue Aug 29, 2019 · 1 comment

Comments

@rekmarks
Copy link

rekmarks commented Aug 29, 2019

Per the ethereumjs-util documentation and source code, the function signature of toChecksumAddress should be:

function(address: string, eip1191ChainId?: number): string

However, in the latest (6.1.0) NPM distribution, its signature is:

toChecksumAddress: (address: string) => string;

The distribution's implementation follows this:

exports.toChecksumAddress = function (address) {
    address = ethjsUtil.stripHexPrefix(address).toLowerCase();
    var hash = exports.keccak(address).toString('hex');
    var ret = '0x';
    for (var i = 0; i < address.length; i++) {
        if (parseInt(hash[i], 16) >= 8) {
            ret += address[i].toUpperCase();
        }
        else {
            ret += address[i];
        }
    }
    return ret;
};

Is the version with the optional eip1191ChainId parameter not supposed to be published yet?

@ryanio
Copy link
Contributor

ryanio commented Feb 5, 2020

It looks like this was fixed with #204 in 6.2.0 👍

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants