uport-project / ethr-did

Create ethr DIDs
Apache License 2.0
259 stars 53 forks source link

error when using addDelegate() function call as explained in the "Getting Started" documentation #58

Closed yogh333 closed 3 years ago

yogh333 commented 3 years ago

Describe the bug I follow the "Getting Started" guide here: https://github.com/uport-project/ethr-did/blob/master/docs/guides/index.md, and try adding a Delegate Signer.

I am using Ganache for my own test private blockchain and deployed ERC1056 on it.

Here is my node.js code:

const EthrDID = require('ethr-did');              
const Web3 = require('web3');              
const Registry = require('./build/contracts/Registry.json');

const init = async () => {
    const current_provider = new Web3.providers.HttpProvider('http://localhost:8545');
    const web3 = new Web3(current_provider);
    const id = await web3.eth.net.getId();

    const deployedNetwork = Registry.networks[id];
    const contract = new web3.eth.Contract(
        Registry.abi,
        deployedNetwork.address
    );
    const addresses = await web3.eth.getAccounts();

    const ethrDid = new EthrDID({
        address: addresses[0], 
        registry: deployedNetwork.address, 
        privateKey: '0x2f93aa4f85edafb71f472bbd1be5046270aed1c6f6fcdd8fa0705c5ccb59ab12',
        rpcUrl: 'http://localhost:8545'
    });

    console.log("DiD = " + ethrDid.did);
    const owner = await ethrDid.lookupOwner();
    console.log("Owner = " + owner);

    console.log("Set Delegate = " + addresses[1]);
    await ethrDid.addDelegate(addresses[1]);
}

init();

Call to ethrDid.addDelegate() throws the following error:

_(node:54879) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'delegateType' of undefined at e.o.addDelegate (/Users/jcaporossi/Documents/ethr-did-test/node_modules/ethr-did/lib/index.js:1:1849) at init (/Users/jcaporossi/Documents/ethr-did-test/index.js:36:16) at processTicksAndRejections (internal/process/task_queues.js:93:5) (Use node --trace-warnings ... to show where the warning was created) (node:54879) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag --unhandled-rejections=strict (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1) (node:54879) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code._

Any help would be welcome ;) Thx, Kind regards, Jerome

uport-automation-bot commented 3 years ago

:tada: This issue has been resolved in version 2.0.0 :tada:

The release is available on:

Your semantic-release bot :package::rocket: