Skip to content

Commit

Permalink
refactor: setting modules as dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
DChan0319 committed Oct 3, 2023
1 parent f3fdeb9 commit 0ca5d23
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 23 deletions.
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@
},
"homepage": "https://github.com/unstoppabledomains/resolution.git#readme",
"devDependencies": {
"@ensdomains/address-encoder": "0.2.18",
"@ethersproject/providers": "^5.4.5",
"@types/bn.js": "^4.11.6",
"@types/crypto-js": "^4.1.1",
Expand All @@ -73,8 +72,6 @@
"@unstoppabledomains/sizecheck": "^4.0.4",
"@zilliqa-js/core": "^3.3.4",
"audit-ci": "^3.1.1",
"bip44-constants": "^8.0.103",
"content-hash": "^2.5.2",
"dotenv": "^8.2.0",
"eslint": "^7.7.0",
"eslint-config-prettier": "^8.3.0",
Expand All @@ -99,8 +96,11 @@
"access": "public"
},
"dependencies": {
"@ensdomains/address-encoder": "^0.2.22",
"@ethersproject/abi": "^5.0.1",
"bip44-constants": "^8.0.103",
"bn.js": "^4.4.0",
"content-hash": "^2.5.2",
"cross-fetch": "4.0.0",
"crypto-js": "^4.1.1",
"elliptic": "^6.5.4",
Expand Down
25 changes: 5 additions & 20 deletions src/Ens.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
import * as contentHash from 'content-hash';
import bip44Constants from 'bip44-constants';
import {formatsByCoinType} from '@ensdomains/address-encoder';
import EnsNetworkMap from 'ethereum-ens-network-map';
import {default as ensInterface} from './contracts/ens/ens';
import {default as resolverInterface} from './contracts/ens/resolver';
import {default as nameWrapperInterface} from './contracts/ens/nameWrapper';
Expand All @@ -6,7 +10,6 @@ import {default as reverseRegistrarInterface} from './contracts/ens/reverseRegis
import {EnsSupportedNetwork, EthCoinIndex, hasProvider} from './types';
import {ResolutionError, ResolutionErrorCode} from './errors/resolutionError';
import EthereumContract from './contracts/EthereumContract';
import EnsNetworkMap from 'ethereum-ens-network-map';
import {
EnsSource,
Locations,
Expand All @@ -25,7 +28,6 @@ import ConfigurationError, {
ConfigurationErrorCode,
} from './errors/configurationError';
import {EthereumNetworks} from './utils';
import {requireOrFail} from './utils/requireOrFail';
import ensConfig from './config/ens-config.json';
import Networking from './utils/Networking';

Expand Down Expand Up @@ -390,17 +392,7 @@ export default class Ens extends NamingService {
}

protected getCoinType(currencyTicker: string): string {
const bip44constants = requireOrFail(
'bip44-constants',
'bip44-constants',
'^8.0.5',
);
const formatsByCoinType = requireOrFail(
'@ensdomains/address-encoder',
'@ensdomains/address-encoder',
'>= 0.1.x <= 0.2.x',
).formatsByCoinType;
const coin = bip44constants.findIndex(
const coin = bip44Constants.findIndex(
(item) =>
item[1] === currencyTicker.toUpperCase() ||
item[2] === currencyTicker.toUpperCase(),
Expand Down Expand Up @@ -447,12 +439,6 @@ export default class Ens extends NamingService {
domain: string,
coinType: string,
): Promise<string | undefined> {
const formatsByCoinType = requireOrFail(
'@ensdomains/address-encoder',
'@ensdomains/address-encoder',
'>= 0.1.x <= 0.2.x',
).formatsByCoinType;

const resolverContract = new EthereumContract(
resolverInterface(resolver, coinType),
resolver,
Expand Down Expand Up @@ -490,7 +476,6 @@ export default class Ens extends NamingService {

// @see https://docs.ens.domains/ens-improvement-proposals/ensip-7-contenthash-field
private async getContentHash(domain: string): Promise<string | undefined> {
const contentHash = requireOrFail('content-hash', 'content-hash', '^2.5.2');
const nodeHash = this.namehash(domain);
const resolverContract = await this.getResolverContract(domain);
const contentHashEncoded = await this.callMethod(
Expand Down

0 comments on commit 0ca5d23

Please sign in to comment.