From 82240fd1617783152c96825e39a4677e6594f006 Mon Sep 17 00:00:00 2001 From: Sergio Ceron Date: Wed, 2 Aug 2023 16:18:47 -0600 Subject: [PATCH] Fix ethers utils import --- lib/did.js | 4 ++-- lib/registry.js | 3 +-- package.json | 2 +- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/lib/did.js b/lib/did.js index b01c147..c56a9d5 100644 --- a/lib/did.js +++ b/lib/did.js @@ -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 { @@ -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; diff --git a/lib/registry.js b/lib/registry.js index 2c71f76..aee96ec 100644 --- a/lib/registry.js +++ b/lib/registry.js @@ -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 ); diff --git a/package.json b/package.json index c1b1f47..79474ba 100644 --- a/package.json +++ b/package.json @@ -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 ", "keywords": [