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

Dependency handling fixed in ens module #2425

Merged
merged 3 commits into from
Feb 26, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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