Skip to content

Commit

Permalink
lint fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
adonesky1 committed Jul 15, 2021
1 parent 31af1d8 commit b382fc2
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 31 deletions.
5 changes: 3 additions & 2 deletions src/assets/AssetsDetectionController.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -671,8 +671,9 @@ describe('AssetsDetectionController', () => {
});

it('should subscribe to new sibling detecting assets when account changes', async () => {
stub(tokensController, '_instantiateNewEthersProvider')
.callsFake(() => {});
stub(tokensController, '_instantiateNewEthersProvider').callsFake(
() => null,
);
const firstNetworkType = 'rinkeby';
const secondNetworkType = 'mainnet';
const firstAddress = '0x123';
Expand Down
22 changes: 13 additions & 9 deletions src/assets/TokensController.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ describe('TokensController', () => {
);
sinon
.stub(tokensController, '_instantiateNewEthersProvider')
.callsFake(() => {});
.callsFake(() => null);
});

afterEach(() => {
Expand Down Expand Up @@ -426,16 +426,20 @@ describe('TokensController', () => {
});

it('should handle ERC20 type and add to suggestedAssets', async function () {
sinon.stub(tokensController, '_generateRandomId').callsFake(() => '12345')
sinon
.stub(tokensController, '_generateRandomId')
.callsFake(() => '12345');
type = 'ERC20';
tokensController.watchAsset(asset, type);
await expect(tokensController.state.suggestedAssets).toEqual([{
id: '12345',
status: 'pending',
time: 1,
type: 'ERC20',
asset: asset,
}]);
await expect(tokensController.state.suggestedAssets).toStrictEqual([
{
id: '12345',
status: 'pending',
time: 1,
type: 'ERC20',
asset,
},
]);
});
});
});
40 changes: 20 additions & 20 deletions src/assets/TokensController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ export class TokensController extends BaseController<
TokensState
> {
private mutex = new Mutex();

private ethersProvider: any;

private failSuggestedAsset(
Expand Down Expand Up @@ -137,23 +138,21 @@ export class TokensController extends BaseController<
* @param config - Initial options used to configure this controller
* @param state - Initial state to set on this controller
*/
constructor(
{
onPreferencesStateChange,
onNetworkStateChange,
config,
state,
}: {
onPreferencesStateChange: (
listener: (preferencesState: PreferencesState) => void,
) => void;
onNetworkStateChange: (
listener: (networkState: NetworkState) => void,
) => void;
config?: Partial<TokensConfig>,
state?: Partial<TokensState>,
},
) {
constructor({
onPreferencesStateChange,
onNetworkStateChange,
config,
state,
}: {
onPreferencesStateChange: (
listener: (preferencesState: PreferencesState) => void,
) => void;
onNetworkStateChange: (
listener: (networkState: NetworkState) => void,
) => void;
config?: Partial<TokensConfig>;
state?: Partial<TokensState>;
}) {
super(config, state);

this.defaultConfig = {
Expand Down Expand Up @@ -187,7 +186,7 @@ export class TokensController extends BaseController<
const { selectedAddress } = this.config;
const { chainId } = provider;
this.configure({ chainId });
this.ethersProvider = this._instantiateNewEthersProvider()
this.ethersProvider = this._instantiateNewEthersProvider();
this.update({
tokens: allTokens[selectedAddress]?.[chainId] || [],
});
Expand Down Expand Up @@ -354,9 +353,10 @@ export class TokensController extends BaseController<
return tokenContract;
}

_generateRandomId(): string{
return random()
_generateRandomId(): string {
return random();
}

/**
* Adds a new suggestedAsset to state. Parameters will be validated according to
* asset type being watched. A `<suggestedAssetMeta.id>:pending` hub event will be emitted once added.
Expand Down

0 comments on commit b382fc2

Please sign in to comment.