Skip to content

Commit

Permalink
Added PR feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
BelfordZ committed Apr 7, 2023
1 parent 3737bc1 commit 5f9e7e2
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 21 deletions.
6 changes: 3 additions & 3 deletions packages/controller-utils/src/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
import { fromWei, toWei } from 'ethjs-unit';
import ensNamehash from 'eth-ens-namehash';
import deepEqual from 'fast-deep-equal';
import { Hex } from '@metamask/utils';
import { Hex, isStrictHexString } from '@metamask/utils';
import type { Json } from './types';
import { MAX_SAFE_CHAIN_ID } from './constants';

Expand Down Expand Up @@ -176,8 +176,8 @@ export function fromHex(value: string | BN): BN {
* @returns The integer encoded as a hex string.
*/
export function toHex(value: number | string | BN): Hex {
if (typeof value === 'string' && isHexString(value)) {
return value as Hex;
if (typeof value === 'string' && isStrictHexString(value)) {
return value;
}
const hexString = BN.isBN(value)
? value.toString(16)
Expand Down
32 changes: 16 additions & 16 deletions packages/network-controller/src/create-network-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ type InfuraNetworkConfiguration = {
* Create a JSON RPC network client for a specific network.
*
* @param networkConfig - The network configuration.
* @returns the network client
* @returns The network client.
*/
export function createNetworkClient(
networkConfig: CustomNetworkConfiguration | InfuraNetworkConfiguration,
Expand Down Expand Up @@ -106,12 +106,12 @@ export function createNetworkClient(
/**
* Create middleware for infura.
*
* @param options0 - options for infura middleware
* @param options0.blockTracker - block tracker to use
* @param options0.network - network to use
* @param options0.rpcProvider - rpcProvider to use
* @param options0.rpcApiMiddleware - additional rpcApiMiddleware
* @returns the middleware
* @param args - The arguments.
* @param args.blockTracker - The block tracker to use.
* @param args.network - The Infura network to use.
* @param args.rpcProvider - The RPC provider to use.
* @param args.rpcApiMiddleware - Additional middleware.
* @returns The collection of middleware that makes up the Infura client.
*/
function createInfuraNetworkMiddleware({
blockTracker,
Expand All @@ -138,9 +138,9 @@ function createInfuraNetworkMiddleware({
/**
* Creates static method middleware.
*
* @param options0 - options
* @param options0.network - the network to use
* @returns the middleware
* @param args - The Arguments.
* @param args.network - The Infura network to use.
* @returns The middleware that implements eth_chainId & net_version methods.
*/
function createNetworkAndChainIdMiddleware({
network,
Expand Down Expand Up @@ -170,11 +170,11 @@ const createChainIdMiddleware = (
/**
* Creates custom middleware.
*
* @param options0 - options for middleware
* @param options0.blockTracker - the block tracker to use
* @param options0.chainId - the chain id to use
* @param options0.rpcApiMiddleware - additional middleware
* @returns the middleware
* @param args - The arguments.
* @param args.blockTracker - The block tracker to use.
* @param args.chainId - The chain id to use.
* @param args.rpcApiMiddleware - Additional middleware.
* @returns The collection of middleware that makes up the Infura client.
*/
function createCustomNetworkMiddleware({
blockTracker,
Expand Down Expand Up @@ -205,7 +205,7 @@ function createCustomNetworkMiddleware({
* For use in tests only.
* Adds a delay to `eth_estimateGas` calls.
*
* @returns the middleware
* @returns The middleware for delaying gas estimation calls by 2 seconds when in test.
*/
function createEstimateGasDelayTestMiddleware() {
return createAsyncMiddleware(async (req, _, next) => {
Expand Down
6 changes: 4 additions & 2 deletions packages/network-controller/tests/NetworkController.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5640,9 +5640,11 @@ class FakeBlockTracker extends PollingBlockTracker {
* @param provider - provider to use if you dont want the defaults
* @returns The object.
*/
function buildFakeClient(provider?: SafeEventEmitterProvider) {
function buildFakeClient(
provider: SafeEventEmitterProvider = buildFakeProvider(),
) {
return {
provider: provider || buildFakeProvider(),
provider,
blockTracker: new FakeBlockTracker() as PollingBlockTracker,
};
}
Expand Down

0 comments on commit 5f9e7e2

Please sign in to comment.