Skip to content

Commit

Permalink
Fix ethers utils import
Browse files Browse the repository at this point in the history
  • Loading branch information
sergioceron committed Aug 2, 2023
1 parent 1136195 commit 82240fd
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 5 deletions.
4 changes: 2 additions & 2 deletions lib/did.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as ethers from 'ethers';
import DIDRegistry from "./registry.js";
import { createKeyPair } from "./utils.js";
import { getResolver } from "./resolver.js";
import { isAddress } from "ethers/lib/utils.js";

export default class DID {

Expand All @@ -10,7 +10,7 @@ export default class DID {
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 ) {
if(!isAddress(config.address)) {
if(!ethers.utils.isAddress(config.address)) {
throw new Error( "Invalid 'address' attribute" );
};
this.address = config.address;
Expand Down
3 changes: 1 addition & 2 deletions lib/registry.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,13 @@ import DIDRegistryContract from './DIDRegistry.json';
import DIDRegistryContractOld from './DIDRegistry_old.json';
import { Buffer } from 'buffer'
import { attributeToHex, signData, stringToBytes, stripHexPrefix } from "./utils.js";
import { isAddress } from 'ethers/lib/utils.js';

export default class DIDRegistry {

constructor( conf = {} ) {
this.conf = conf;
this.provider = this.configureProvider( conf );
if (!isAddress(conf.registry)) {
if (!ethers.utils.isAddress(conf.registry)) {
throw new Error( "Invalid 'registry' attribute" );
}
this.registry = new ethers.Contract( conf.registry, conf.nodeAddress ? DIDRegistryContract.abi : DIDRegistryContractOld.abi, this.provider );
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@lacchain/did",
"version": "1.6.1",
"version": "1.6.2",
"description": "The LACChain DID Method NodeJS Implementation",
"author": "Sergio Ceron Figueroa <[email protected]>",
"keywords": [
Expand Down

0 comments on commit 82240fd

Please sign in to comment.