From e4df325e22578859fa8cf205f572f1f43e5df7b5 Mon Sep 17 00:00:00 2001 From: Richard Moore Date: Mon, 16 Jul 2018 00:48:41 -0400 Subject: [PATCH] Moved getNetwork to utils. --- src.ts/index.ts | 3 --- src.ts/providers/infura-provider.ts | 3 ++- src.ts/providers/json-rpc-provider.ts | 5 +++-- src.ts/providers/provider.ts | 3 +-- src.ts/providers/web3-provider.ts | 11 ++--------- src.ts/utils/index.ts | 2 ++ src.ts/{providers => utils}/networks.ts | 0 7 files changed, 10 insertions(+), 17 deletions(-) rename src.ts/{providers => utils}/networks.ts (100%) diff --git a/src.ts/index.ts b/src.ts/index.ts index e617d4a47..4cb2b8a80 100644 --- a/src.ts/index.ts +++ b/src.ts/index.ts @@ -6,7 +6,6 @@ import {} from './utils/shims'; import { Contract, Interface } from './contracts'; import * as providers from './providers'; -import { getNetwork } from './providers/networks'; import * as utils from './utils'; import { HDNode, SigningKey, Wallet } from './wallet'; import * as wordlists from './wordlists'; @@ -28,7 +27,6 @@ export { Contract, Interface, - getNetwork, providers, types, @@ -51,7 +49,6 @@ export const ethers = { Contract, Interface, - getNetwork, providers, types, diff --git a/src.ts/providers/infura-provider.ts b/src.ts/providers/infura-provider.ts index 545e786c1..716f96051 100644 --- a/src.ts/providers/infura-provider.ts +++ b/src.ts/providers/infura-provider.ts @@ -1,9 +1,10 @@ 'use strict'; import { JsonRpcProvider, JsonRpcSigner } from './json-rpc-provider'; -import { getNetwork } from './networks'; +import { getNetwork } from '../utils/networks'; import { defineReadOnly } from '../utils/properties'; + import { Networkish } from '../utils/types'; import * as errors from '../utils/errors'; diff --git a/src.ts/providers/json-rpc-provider.ts b/src.ts/providers/json-rpc-provider.ts index 9e77d2aec..f4ea5262e 100644 --- a/src.ts/providers/json-rpc-provider.ts +++ b/src.ts/providers/json-rpc-provider.ts @@ -2,17 +2,18 @@ // See: https://github.com/ethereum/wiki/wiki/JSON-RPC -import { getNetwork } from './networks'; import { Provider } from './provider'; import { getAddress } from '../utils/address'; import { BigNumber } from '../utils/bignumber'; import { Arrayish, hexlify, hexStripZeros } from '../utils/bytes'; +import { getNetwork } from '../utils/networks'; import { defineReadOnly, resolveProperties, shallowCopy } from '../utils/properties'; -import { BlockTag, Network, Networkish, Signer, TransactionRequest, TransactionResponse } from '../utils/types'; import { toUtf8Bytes } from '../utils/utf8'; import { ConnectionInfo, fetchJson, poll } from '../utils/web'; +import { BlockTag, Network, Networkish, Signer, TransactionRequest, TransactionResponse } from '../utils/types'; + import * as errors from '../utils/errors'; function timer(timeout: number): Promise { diff --git a/src.ts/providers/provider.ts b/src.ts/providers/provider.ts index 719529cfc..e0ab69d34 100644 --- a/src.ts/providers/provider.ts +++ b/src.ts/providers/provider.ts @@ -1,11 +1,10 @@ 'use strict'; -import { getNetwork, Network, Networkish } from './networks'; - import { getAddress, getContractAddress } from '../utils/address'; import { BigNumber, bigNumberify, BigNumberish } from '../utils/bignumber'; import { hexDataLength, hexDataSlice, hexlify, hexStripZeros, isHexString, stripZeros } from '../utils/bytes'; import { namehash } from '../utils/hash'; +import { getNetwork, Network, Networkish } from '../utils/networks'; import { defineReadOnly, resolveProperties, shallowCopy } from '../utils/properties'; import { encode as rlpEncode } from '../utils/rlp'; import { parse as parseTransaction, Transaction } from '../utils/transaction'; diff --git a/src.ts/providers/web3-provider.ts b/src.ts/providers/web3-provider.ts index 3b2c75fc1..8263102ef 100644 --- a/src.ts/providers/web3-provider.ts +++ b/src.ts/providers/web3-provider.ts @@ -1,11 +1,11 @@ 'use strict'; -import { Networkish } from './networks'; import { JsonRpcProvider } from './json-rpc-provider'; import { defineReadOnly } from '../utils/properties'; -import { AsyncProvider } from '../utils/types'; +import { AsyncProvider, Networkish } from '../utils/types'; + import * as errors from '../utils/errors'; /* @@ -14,13 +14,6 @@ utils.defineProperty(Web3Signer, 'onchange', { }); -export type AsyncProvider = { - isMetaMask: boolean; - host?: string; - path?: string; - sendAsync: (request: any, callback: (error: any, response: any) => void) => void -} - */ export class Web3Provider extends JsonRpcProvider { diff --git a/src.ts/utils/index.ts b/src.ts/utils/index.ts index d7f73ca22..f4f85f2d6 100644 --- a/src.ts/utils/index.ts +++ b/src.ts/utils/index.ts @@ -13,6 +13,7 @@ import { keccak256 } from './keccak256'; import { sha256 } from './sha2'; import { keccak256 as solidityKeccak256, pack as solidityPack, sha256 as soliditySha256 } from './solidity'; import { randomBytes } from './random-bytes'; +import { getNetwork } from './networks'; import { defineFrozen, defineReadOnly, resolveProperties, shallowCopy } from './properties'; import * as RLP from './rlp'; import { parse as parseTransaction, serialize as serializeTransaction } from './transaction'; @@ -51,6 +52,7 @@ export { RLP, fetchJson, + getNetwork, defineReadOnly, defineFrozen, diff --git a/src.ts/providers/networks.ts b/src.ts/utils/networks.ts similarity index 100% rename from src.ts/providers/networks.ts rename to src.ts/utils/networks.ts