Skip to content

Overloaded function createAlastriaIdentity(...) causes ambiguity in ethers.js v6 #18

@Cainuriel

Description

@Cainuriel

The contract AlastriaIdentityManager defines two functions with the same name but different signatures:

function createAlastriaIdentity(bytes memory data) public
function createAlastriaIdentity(bytes32 hash) public

Why this is problematic:

Client libraries like ethers.js or web3.js fail to infer the correct ABI signature unless manually specified:

const hash = ethers.utils.keccak256(ethers.utils.toUtf8Bytes(subject)); 
const tx = await this.contract["createAlastriaIdentity(bytes32)"](hash);

This leads to a poor developer experience and if it is not done unexpected runtime errors like this:

"TypeError: ambiguous function description (i.e. matches "createAlastriaIdentity(bytes32)", "createAlastriaIdentity(bytes)")"

Overloaded function names reduce readability in public APIs.

Suggestion:

Rename the functions to distinct, semantically clear names, for example:

function createAlastriaIdentityWithHash(bytes32 hash) public
function createAlastriaIdentityWithData(bytes memory data) public

This will prevent ambiguity and improve usability for developers integrating with the Alastria ID stack.

Thanks for your work.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions