Skip to content

Commit

Permalink
Merge pull request #2425 from ethereum/issue/2424
Browse files Browse the repository at this point in the history
Dependency handling fixed in ens module
  • Loading branch information
nivida authored Feb 26, 2019
2 parents 95cc939 + 1a074b6 commit 7f5a390
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 3 deletions.
6 changes: 4 additions & 2 deletions packages/web3-eth-ens/src/Ens.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ import {AbstractWeb3Module} from 'web3-core';
import isFunction from 'lodash/isFunction';
import namehash from 'eth-ens-namehash';

// TODO: Maybe it would be better to extend from the CallContractMethod and SendContractMethod and to implement the
// TODO: ENS methods as method objects. This would clean up the entire module and remove the duplicated code.
// TODO: Remove the wrapped methods and create a proxy for handling a ENS method call.
export default class Ens extends AbstractWeb3Module {
/**
* @param {HttpProvider|WebsocketProvider|IpcProvider|EthereumProvider|String} provider
* @param {ProvidersModuleFactory} providersModuleFactory
* @param {MethodModuleFactory} methodModuleFactory
* @param {ContractModuleFactory} contractModuleFactory
* @param {Object} options
* @param {EnsModuleFactory} ensModuleFactory
* @param {PromiEvent} promiEvent
Expand All @@ -45,6 +45,7 @@ export default class Ens extends AbstractWeb3Module {
methodModuleFactory,
options,
ensModuleFactory,
contractModuleFactory,
promiEvent,
abiCoder,
utils,
Expand All @@ -55,6 +56,7 @@ export default class Ens extends AbstractWeb3Module {
super(provider, providersModuleFactory, methodModuleFactory, null, options);

this.ensModuleFactory = ensModuleFactory;
this.contractModuleFactory = contractModuleFactory;
this.promiEvent = promiEvent;
this.abiCoder = abiCoder;
this.utils = utils;
Expand Down
1 change: 1 addition & 0 deletions packages/web3-eth-ens/src/factories/EnsModuleFactory.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ export default class EnsModuleFactory {
methodModuleFactory,
ensModuleOptions,
this,
contractModuleFactory,
promiEvent,
abiCoder,
utils,
Expand Down
22 changes: 22 additions & 0 deletions packages/web3-eth-ens/tests/src/EnsTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {HttpProvider, ProvidersModuleFactory} from 'web3-providers';
import {MethodModuleFactory} from 'web3-core-method';
import {Network} from 'web3-net';
import {AbiCoder} from 'web3-eth-abi';
import {ContractModuleFactory} from 'web3-eth-contract';
import Registry from '../../src/contracts/Registry';
import namehash from 'eth-ens-namehash';
import Ens from '../../src/Ens';
Expand All @@ -21,6 +22,7 @@ jest.mock('AbiCoder');
jest.mock('Utils');
jest.mock('formatters');
jest.mock('namehash');
jest.mock('ContractModuleFactory');

/**
* Ens test
Expand All @@ -30,6 +32,7 @@ describe('EnsTest', () => {
providerMock,
providersModuleFactoryMock,
methodModuleFactoryMock,
constractModuleFactoryMock,
registryMock,
ensModuleFactoryMock,
abiCoderMock,
Expand All @@ -49,6 +52,9 @@ describe('EnsTest', () => {
registryMock = Registry.mock.instances[0];
registryMock.PromiEvent = PromiEvent;

new ContractModuleFactory();
constractModuleFactoryMock = ContractModuleFactory.mock.instances[0];

new EnsModuleFactory();
ensModuleFactoryMock = EnsModuleFactory.mock.instances[0];
ensModuleFactoryMock.createRegistry.mockReturnValue(registryMock);
Expand All @@ -72,6 +78,7 @@ describe('EnsTest', () => {
methodModuleFactoryMock,
{},
ensModuleFactoryMock,
constractModuleFactoryMock,
PromiEvent,
abiCoderMock,
Utils,
Expand All @@ -83,6 +90,7 @@ describe('EnsTest', () => {

it('constructor check', () => {
expect(ens.registry).toEqual(registryMock);

expect(ensModuleFactoryMock.createRegistry).toHaveBeenCalledWith(
ens.currentProvider,
ens.providersModuleFactory,
Expand All @@ -95,6 +103,20 @@ describe('EnsTest', () => {
ens.registryOptions,
ens.net
);

expect(ens.ensModuleFactory).toEqual(ensModuleFactoryMock);

expect(ens.contractModuleFactory).toEqual(constractModuleFactoryMock);

expect(ens.promiEvent).toEqual(PromiEvent);

expect(ens.abiCoder).toEqual(abiCoderMock);

expect(ens.utils).toEqual(Utils);

expect(ens.registryOptions).toEqual({});

expect(ens.net).toEqual(networkMock);
});

it('calls resolver and returns with a resolved promise', async () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/web3-providers/src/providers/HttpProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ export default class HttpProvider {

/**
* Checks if the error `net::ERR_NAME_NOT_RESOLVED` or `net::ERR_CONNECTION_REFUSED` will appear.
*
*
* @method isInvalidHttpEndpoint
*
* @param {Object} request
Expand Down

0 comments on commit 7f5a390

Please sign in to comment.