Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Address not added to de DID object when providing controllerPrivateKey and address #2

Open
ghost opened this issue Aug 26, 2021 · 2 comments

Comments

@ghost
Copy link

ghost commented Aug 26, 2021

Just a quick bug we have found using this. When you create a new DID with private key and address, the config.address is not stored like it does in the two other cases. Just add "this.address = config.address;" this line:

constructor( config ) {
		this.config = config;
		if( config.controllerPrivateKey && !config.address ) {
			throw new Error( "If you set the controller private key you must also provide the DID address" );
		} else if( !config.controllerPrivateKey && config.address ) {
			this.address = config.address;
			this.readOnly = true;
		} else if( !config.controllerPrivateKey && !config.address ) {
			const keyPair = createKeyPair();
			this.address = keyPair.address;
			config.controllerPrivateKey = keyPair.privateKey;
		}
		this.address = config.address; // <=========== this one
		this.registry = new DIDRegistry( config );
		this.resolver = getResolver( {
			...config,
			networks: [{
				name: 'main',
				registry: config.registry,
				rpcUrl: config.rpcUrl
			}]
		} );
	}
@ghost
Copy link
Author

ghost commented Aug 26, 2021

I have tried to make a pull request with the fix but I don't have permissions

@bdesiderio
Copy link

I come here for the same problem. I can't instantiate the DID class when I already have a private key because the address is not set in the constructor

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

Successfully merging a pull request may close this issue.

1 participant