Skip to content

Commit

Permalink
Merge 1a52348 into 9d9ecb7
Browse files Browse the repository at this point in the history
  • Loading branch information
nivida committed Nov 5, 2019
2 parents 9d9ecb7 + 1a52348 commit 08c833f
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 26 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,8 @@ sudo apt-get install npm
- ``build:all`` - Creates CJS and ESM bundles for all packages
- ``build:all:cjs`` - Creates CJS bundles for all packages
- ``build:all:esm`` - Creates ESM bundles for all packages
- ``build:all:minified`` - Creates minified UMD bundles with the cjs bundles as the source for all packages
- ``build:all:release`` - Creates CJS, ESM, and minified UMD bundles for all packages.
- ``build:web3`` - Creates just the CJS and ESM bundle of the web3 umbrella package
- ``build:web3:minified`` - Creates all CJS and ESM bundles of all packages and creates a web3.min after
Expand Down
7 changes: 1 addition & 6 deletions packages/web3-eth-ens/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,7 @@
"@babel/runtime": "^7.6.3",
"eth-ens-namehash": "^2.0.8",
"underscore": "^1.9.1",
"web3-core": "1.2.2",
"web3-core-helpers": "1.2.2",
"web3-core-promievent": "1.2.2",
"web3-eth-abi": "1.2.2",
"web3-eth-contract": "1.2.2",
"web3-utils": "1.2.2"
"web3-core-promievent": "1.2.2"
},
"devDependencies": {
"definitelytyped-header-parser": "^1.0.1",
Expand Down
2 changes: 0 additions & 2 deletions packages/web3-eth-ens/rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ export default rollupConfig(
'web3-core': 'Web3Core',
'web3-core-helpers': 'Web3CoreHelpers',
'web3-core-promievent': 'Web3CorePromiEvent',
'web3-eth-abi': 'Web3EthAbi',
'web3-eth-contract': 'Web3EthContract',
'web3-utils': 'Web3Utils',
'underscore': '_',
'eth-ens-namehash': 'namehash'
Expand Down
29 changes: 11 additions & 18 deletions packages/web3-eth-ens/src/contracts/Registry.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,9 @@
* @date 2018
*/

"use strict";
'use strict';

var _ = require('underscore');
var Contract = require('web3-eth-contract');
var namehash = require('eth-ens-namehash');
var PromiEvent = require('web3-core-promievent');
var REGISTRY_ABI = require('../ressources/ABI/Registry');
Expand All @@ -36,13 +35,9 @@ var RESOLVER_ABI = require('../ressources/ABI/Resolver');
* @constructor
*/
function Registry(ens) {
var self = this;
this.ens = ens;
this.contract = ens.checkNetwork().then(function (address) {
var contract = new Contract(REGISTRY_ABI, address);
contract.setProvider(self.ens.eth.currentProvider);

return contract;
this.contract = ens.checkNetwork().then(function(address) {
return new ens.eth.Contract(REGISTRY_ABI, address);
});
}

Expand All @@ -54,19 +49,19 @@ function Registry(ens) {
* @param {function} callback
* @return {Promise<any>}
*/
Registry.prototype.owner = function (name, callback) {
Registry.prototype.owner = function(name, callback) {
var promiEvent = new PromiEvent(true);

this.contract.then(function (contract) {
this.contract.then(function(contract) {
contract.methods.owner(namehash.hash(name)).call()
.then(function (receipt) {
.then(function(receipt) {
promiEvent.resolve(receipt);

if (_.isFunction(callback)) {
callback(receipt);
}
})
.catch(function (error) {
.catch(function(error) {
promiEvent.reject(error);

if (_.isFunction(callback)) {
Expand All @@ -85,15 +80,13 @@ Registry.prototype.owner = function (name, callback) {
* @param {string} name
* @return {Promise<Contract>}
*/
Registry.prototype.resolver = function (name) {
Registry.prototype.resolver = function(name) {
var self = this;

return this.contract.then(function (contract) {
return this.contract.then(function(contract) {
return contract.methods.resolver(namehash.hash(name)).call();
}).then(function (address) {
var contract = new Contract(RESOLVER_ABI, address);
contract.setProvider(self.ens.eth.currentProvider);
return contract;
}).then(function(address) {
return new self.ens.eth.Contract(RESOLVER_ABI, address);
});
};

Expand Down

0 comments on commit 08c833f

Please sign in to comment.