Skip to content

Commit

Permalink
Update prettier and related packages (#783)
Browse files Browse the repository at this point in the history
Prettier has been updated, along with all related packages. The update
includes various formatting changes, all of which were applied with
`yarn lint:fix`.

This update was required to support later versions of TypeScript.
  • Loading branch information
Gudahtt authored and MajorLift committed Oct 11, 2023
1 parent 6c41914 commit 22f4382
Show file tree
Hide file tree
Showing 37 changed files with 464 additions and 487 deletions.
26 changes: 13 additions & 13 deletions package.json
Expand Up @@ -21,18 +21,18 @@
"dist/"
],
"scripts": {
"setup": "yarn install && yarn allow-scripts",
"prepublishOnly": "yarn build",
"lint:eslint": "eslint . --cache --ext js,ts",
"lint:misc": "prettier '**/*.json' '**/*.md' '!CHANGELOG.md' '**/*.yml' --ignore-path .gitignore",
"build": "rimraf dist && tsc --project tsconfig.build.json",
"build:link": "yarn build && cd dist && yarn link && rm -rf node_modules && cd ..",
"build:watch": "yarn build --watch",
"doc": "typedoc && touch docs/.nojekyll",
"lint": "yarn lint:eslint && yarn lint:misc --check",
"lint:eslint": "eslint . --cache --ext js,ts",
"lint:fix": "yarn lint:eslint --fix && yarn lint:misc --write",
"lint:misc": "prettier '**/*.json' '**/*.md' '!CHANGELOG.md' '**/*.yml' --ignore-path .gitignore",
"prepublishOnly": "yarn build",
"setup": "yarn install && yarn allow-scripts",
"test": "jest",
"test:watch": "jest --watch",
"build": "rimraf dist && tsc --project tsconfig.build.json",
"build:watch": "yarn build --watch",
"build:link": "yarn build && cd dist && yarn link && rm -rf node_modules && cd ..",
"doc": "typedoc && touch docs/.nojekyll"
"test:watch": "jest --watch"
},
"dependencies": {
"@ethereumjs/common": "^2.3.1",
Expand Down Expand Up @@ -89,20 +89,20 @@
"@typescript-eslint/eslint-plugin": "^4.22.0",
"@typescript-eslint/parser": "^4.22.0",
"eslint": "^7.24.0",
"eslint-config-prettier": "^8.1.0",
"eslint-config-prettier": "^8.5.0",
"eslint-import-resolver-typescript": "^2.4.0",
"eslint-plugin-import": "^2.22.1",
"eslint-plugin-jest": "^24.1.5",
"eslint-plugin-jsdoc": "^36.1.0",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-prettier": "^3.3.1",
"eslint-plugin-prettier": "^3.4.1",
"ethjs-provider-http": "^0.1.6",
"jest": "^26.4.2",
"jest-environment-jsdom": "^25.0.0",
"jest-when": "^3.4.2",
"nock": "^13.0.7",
"prettier": "^2.2.1",
"prettier-plugin-packagejson": "^2.2.11",
"prettier": "^2.6.2",
"prettier-plugin-packagejson": "^2.2.17",
"rimraf": "^3.0.2",
"sinon": "^9.2.4",
"ts-jest": "^26.5.2",
Expand Down
7 changes: 3 additions & 4 deletions src/BaseControllerV2.test.ts
Expand Up @@ -779,13 +779,12 @@ describe('getPersistentState', () => {
const visitorController = new VisitorController(
visitorControllerMessenger,
);
const visitorOverflowControllerMessenger = controllerMessenger.getRestricted(
{
const visitorOverflowControllerMessenger =
controllerMessenger.getRestricted({
name: visitorOverflowName,
allowedActions: ['VisitorController:clear'],
allowedEvents: ['VisitorController:stateChange'],
},
);
});
const visitorOverflowController = new VisitorOverflowController(
visitorOverflowControllerMessenger,
);
Expand Down
12 changes: 7 additions & 5 deletions src/BaseControllerV2.ts
Expand Up @@ -75,7 +75,7 @@ export type Json =
export class BaseController<
N extends string,
S extends Record<string, Json>,
messenger extends RestrictedControllerMessenger<N, any, any, string, string>
messenger extends RestrictedControllerMessenger<N, any, any, string, string>,
> {
private internalState: S;

Expand Down Expand Up @@ -158,10 +158,12 @@ export class BaseController<
// We run into ts2589, "infinite type depth", if we don't cast
// produceWithPatches here.
// The final, omitted member of the returned tuple are the inverse patches.
const [nextState, patches] = ((produceWithPatches as unknown) as (
state: S,
cb: typeof callback,
) => [S, Patch[], Patch[]])(this.internalState, callback);
const [nextState, patches] = (
produceWithPatches as unknown as (
state: S,
cb: typeof callback,
) => [S, Patch[], Patch[]]
)(this.internalState, callback);

this.internalState = nextState;
this.messagingSystem.publish(
Expand Down
14 changes: 6 additions & 8 deletions src/ControllerMessenger.test.ts
Expand Up @@ -956,11 +956,10 @@ describe('RestrictedControllerMessenger', () => {
handler: (increment: number) => void;
};
const controllerMessenger = new ControllerMessenger<CountAction, never>();
const externalRestrictedControllerMessenger = controllerMessenger.getRestricted(
{
const externalRestrictedControllerMessenger =
controllerMessenger.getRestricted({
name: 'CountController',
},
);
});
const restrictedControllerMessenger = controllerMessenger.getRestricted({
name: 'OtherController',
allowedActions: ['CountController:count'],
Expand All @@ -984,11 +983,10 @@ describe('RestrictedControllerMessenger', () => {
payload: [string];
};
const controllerMessenger = new ControllerMessenger<never, MessageEvent>();
const externalRestrictedControllerMessenger = controllerMessenger.getRestricted(
{
const externalRestrictedControllerMessenger =
controllerMessenger.getRestricted({
name: 'MessageController',
},
);
});
const restrictedControllerMessenger = controllerMessenger.getRestricted({
name: 'OtherController',
allowedEvents: ['MessageController:message'],
Expand Down
6 changes: 3 additions & 3 deletions src/ControllerMessenger.ts
Expand Up @@ -87,7 +87,7 @@ export class RestrictedControllerMessenger<
Action extends ActionConstraint,
Event extends EventConstraint,
AllowedAction extends string,
AllowedEvent extends string
AllowedEvent extends string,
> {
private controllerMessenger: ControllerMessenger<
ActionConstraint,
Expand Down Expand Up @@ -352,7 +352,7 @@ export class RestrictedControllerMessenger<
*/
export class ControllerMessenger<
Action extends ActionConstraint,
Event extends EventConstraint
Event extends EventConstraint,
> {
private actions = new Map<Action['type'], unknown>();

Expand Down Expand Up @@ -595,7 +595,7 @@ export class ControllerMessenger<
getRestricted<
N extends string,
AllowedAction extends string,
AllowedEvent extends string
AllowedEvent extends string,
>({
name,
allowedActions,
Expand Down
6 changes: 3 additions & 3 deletions src/approval/ApprovalController.test.ts
Expand Up @@ -97,9 +97,9 @@ describe('approval controller', () => {
expect(approvalController.has({ id: 'foo' })).toStrictEqual(true);
expect(approvalController.has({ origin: 'bar.baz' })).toStrictEqual(true);
expect(approvalController.has({ type: 'myType' })).toStrictEqual(true);
expect(
approvalController.state[STORE_KEY].foo.requestData,
).toStrictEqual({ foo: 'bar' });
expect(approvalController.state[STORE_KEY].foo.requestData).toStrictEqual(
{ foo: 'bar' },
);
});

it('adds multiple entries for same origin with different types and ids', () => {
Expand Down
14 changes: 6 additions & 8 deletions src/assets/AccountTrackerController.ts
Expand Up @@ -166,14 +166,12 @@ export class AccountTrackerController extends BaseController<
addresses: string[],
): Promise<Record<string, { balance: string }>> {
return await Promise.all(
addresses.map(
(address): Promise<[string, string] | undefined> => {
return safelyExecuteWithTimeout(async () => {
const balance = await query(this.ethQuery, 'getBalance', [address]);
return [address, balance];
});
},
),
addresses.map((address): Promise<[string, string] | undefined> => {
return safelyExecuteWithTimeout(async () => {
const balance = await query(this.ethQuery, 'getBalance', [address]);
return [address, balance];
});
}),
).then((value) => {
return value.reduce((obj, item) => {
if (!item) {
Expand Down
51 changes: 24 additions & 27 deletions src/assets/CollectibleDetectionController.test.ts
Expand Up @@ -30,20 +30,16 @@ describe('CollectibleDetectionController', () => {
collectiblesController = new CollectiblesController({
onPreferencesStateChange: (listener) => preferences.subscribe(listener),
onNetworkStateChange: (listener) => network.subscribe(listener),
getERC721AssetName: assetsContract.getERC721AssetName.bind(
assetsContract,
),
getERC721AssetSymbol: assetsContract.getERC721AssetSymbol.bind(
assetsContract,
),
getERC721AssetName:
assetsContract.getERC721AssetName.bind(assetsContract),
getERC721AssetSymbol:
assetsContract.getERC721AssetSymbol.bind(assetsContract),
getERC721TokenURI: assetsContract.getERC721TokenURI.bind(assetsContract),
getERC721OwnerOf: assetsContract.getERC721OwnerOf.bind(assetsContract),
getERC1155BalanceOf: assetsContract.getERC1155BalanceOf.bind(
assetsContract,
),
getERC1155TokenURI: assetsContract.getERC1155TokenURI.bind(
assetsContract,
),
getERC1155BalanceOf:
assetsContract.getERC1155BalanceOf.bind(assetsContract),
getERC1155TokenURI:
assetsContract.getERC1155TokenURI.bind(assetsContract),
});

collectibleDetection = new CollectibleDetectionController({
Expand Down Expand Up @@ -222,21 +218,22 @@ describe('CollectibleDetectionController', () => {
CollectibleDetectionController.prototype,
'detectCollectibles',
);
const collectiblesDetectionController = new CollectibleDetectionController(
{
onCollectiblesStateChange: (listener) =>
collectiblesController.subscribe(listener),
onPreferencesStateChange: (listener) =>
preferences.subscribe(listener),
onNetworkStateChange: (listener) => network.subscribe(listener),
getOpenSeaApiKey: () => collectiblesController.openSeaApiKey,
addCollectible: collectiblesController.addCollectible.bind(
collectiblesController,
),
getCollectiblesState: () => collectiblesController.state,
},
{ interval: 10 },
);
const collectiblesDetectionController =
new CollectibleDetectionController(
{
onCollectiblesStateChange: (listener) =>
collectiblesController.subscribe(listener),
onPreferencesStateChange: (listener) =>
preferences.subscribe(listener),
onNetworkStateChange: (listener) => network.subscribe(listener),
getOpenSeaApiKey: () => collectiblesController.openSeaApiKey,
addCollectible: collectiblesController.addCollectible.bind(
collectiblesController,
),
getCollectiblesState: () => collectiblesController.state,
},
{ interval: 10 },
);
collectiblesDetectionController.configure({ disabled: false });
collectiblesDetectionController.start();
expect(mockCollectibles.calledOnce).toBe(true);
Expand Down
6 changes: 2 additions & 4 deletions src/assets/CollectibleDetectionController.ts
Expand Up @@ -222,10 +222,8 @@ export class CollectibleDetectionController extends BaseController<
this.initialize();
this.getCollectiblesState = getCollectiblesState;
onPreferencesStateChange(({ selectedAddress, useCollectibleDetection }) => {
const {
selectedAddress: previouslySelectedAddress,
disabled,
} = this.config;
const { selectedAddress: previouslySelectedAddress, disabled } =
this.config;

if (
selectedAddress !== previouslySelectedAddress ||
Expand Down
29 changes: 13 additions & 16 deletions src/assets/CollectiblesController.test.ts
Expand Up @@ -58,20 +58,16 @@ describe('CollectiblesController', () => {
collectiblesController = new CollectiblesController({
onPreferencesStateChange: (listener) => preferences.subscribe(listener),
onNetworkStateChange: (listener) => network.subscribe(listener),
getERC721AssetName: assetsContract.getERC721AssetName.bind(
assetsContract,
),
getERC721AssetSymbol: assetsContract.getERC721AssetSymbol.bind(
assetsContract,
),
getERC721AssetName:
assetsContract.getERC721AssetName.bind(assetsContract),
getERC721AssetSymbol:
assetsContract.getERC721AssetSymbol.bind(assetsContract),
getERC721TokenURI: assetsContract.getERC721TokenURI.bind(assetsContract),
getERC721OwnerOf: assetsContract.getERC721OwnerOf.bind(assetsContract),
getERC1155BalanceOf: assetsContract.getERC1155BalanceOf.bind(
assetsContract,
),
getERC1155TokenURI: assetsContract.getERC1155TokenURI.bind(
assetsContract,
),
getERC1155BalanceOf:
assetsContract.getERC1155BalanceOf.bind(assetsContract),
getERC1155TokenURI:
assetsContract.getERC1155TokenURI.bind(assetsContract),
});

preferences.update({
Expand Down Expand Up @@ -1294,10 +1290,11 @@ describe('CollectiblesController', () => {
.stub(collectiblesController, 'isCollectibleOwner' as any)
.returns(false);

const updatedCollectible = await collectiblesController.checkAndUpdateSingleCollectibleOwnershipStatus(
collectible,
true,
);
const updatedCollectible =
await collectiblesController.checkAndUpdateSingleCollectibleOwnershipStatus(
collectible,
true,
);

expect(
collectiblesController.state.allCollectibles[selectedAddress][
Expand Down
Expand Up @@ -32,8 +32,7 @@ describe('ERC1155Standard', () => {
params: [
{
to: '0xfaaFDc07907ff5120a76b34b731b278c38d6043C',
data:
'0x01ffc9a70e89341c00000000000000000000000000000000000000000000000000000000',
data: '0x01ffc9a70e89341c00000000000000000000000000000000000000000000000000000000',
},
'latest',
],
Expand All @@ -44,9 +43,10 @@ describe('ERC1155Standard', () => {
result:
'0x0000000000000000000000000000000000000000000000000000000000000001',
});
const contractSupportsUri = await erc1155Standard.contractSupportsURIMetadataInterface(
ERC1155_ADDRESS,
);
const contractSupportsUri =
await erc1155Standard.contractSupportsURIMetadataInterface(
ERC1155_ADDRESS,
);
expect(contractSupportsUri).toBe(true);
});
});

0 comments on commit 22f4382

Please sign in to comment.