Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

deps(approval-controller): move to @metamask/rpc-errors #2

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
"@metamask/eslint-config-nodejs": "^12.0.0",
"@metamask/eslint-config-typescript": "^12.0.0",
"@metamask/eth-json-rpc-provider": "^1.0.0",
"@metamask/utils": "^6.2.0",
"@metamask/utils": "^8.1.0",
"@types/node": "^16.18.24",
"@typescript-eslint/eslint-plugin": "^5.30.7",
"@typescript-eslint/parser": "^5.30.7",
Expand Down
2 changes: 1 addition & 1 deletion packages/accounts-controller/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"@metamask/eth-snap-keyring": "^0.2.2",
"@metamask/keyring-api": "^0.2.5",
"@metamask/snaps-utils": "^1.0.1",
"@metamask/utils": "^6.2.0",
"@metamask/utils": "^8.1.0",
"deepmerge": "^4.2.2",
"eth-rpc-errors": "^4.0.2",
"ethereumjs-util": "^7.0.10",
Expand Down
2 changes: 1 addition & 1 deletion packages/address-book-controller/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"dependencies": {
"@metamask/base-controller": "^3.2.2",
"@metamask/controller-utils": "^5.0.1",
"@metamask/utils": "^6.2.0"
"@metamask/utils": "^8.1.0"
},
"devDependencies": {
"@metamask/auto-changelog": "^3.1.0",
Expand Down
4 changes: 2 additions & 2 deletions packages/approval-controller/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@
},
"dependencies": {
"@metamask/base-controller": "^3.2.2",
"@metamask/utils": "^6.2.0",
"eth-rpc-errors": "^4.0.2",
"@metamask/rpc-errors": "^6.0.0",
"@metamask/utils": "^8.1.0",
"immer": "^9.0.6",
"nanoid": "^3.1.31"
},
Expand Down
16 changes: 8 additions & 8 deletions packages/approval-controller/src/ApprovalController.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* eslint-disable jest/expect-expect */

import { ControllerMessenger } from '@metamask/base-controller';
import { errorCodes, EthereumRpcError } from 'eth-rpc-errors';
import { errorCodes, JsonRpcError } from '@metamask/rpc-errors';

import type {
ApprovalControllerActions,
Expand Down Expand Up @@ -652,7 +652,7 @@ describe('approval controller', () => {
approvalController.reject('2', new Error('foo'));
expect(approvalController.getTotalApprovalCount()).toBe(2);

approvalController.clear(new EthereumRpcError(1, 'clear'));
approvalController.clear(new JsonRpcError(1, 'clear'));
expect(approvalController.getTotalApprovalCount()).toBe(0);
});

Expand All @@ -677,7 +677,7 @@ describe('approval controller', () => {
approvalController.reject('2', new Error('foo'));
expect(approvalController.getTotalApprovalCount()).toBe(1);

approvalController.clear(new EthereumRpcError(1, 'clear'));
approvalController.clear(new JsonRpcError(1, 'clear'));
expect(approvalController.getTotalApprovalCount()).toBe(0);
});
});
Expand Down Expand Up @@ -1042,7 +1042,7 @@ describe('approval controller', () => {
describe('clear', () => {
it('does nothing if state is already empty', () => {
expect(() =>
approvalController.clear(new EthereumRpcError(1, 'clear')),
approvalController.clear(new JsonRpcError(1, 'clear')),
).not.toThrow();
});

Expand All @@ -1057,7 +1057,7 @@ describe('approval controller', () => {
.add({ id: 'foo3', origin: 'fizz.buzz', type: 'myType' })
.catch((_error) => undefined);

approvalController.clear(new EthereumRpcError(1, 'clear'));
approvalController.clear(new JsonRpcError(1, 'clear'));

expect(
approvalController.state[PENDING_APPROVALS_STORE_KEY],
Expand All @@ -1072,16 +1072,16 @@ describe('approval controller', () => {
type: 'myType',
});

approvalController.clear(new EthereumRpcError(1000, 'foo'));
approvalController.clear(new JsonRpcError(1000, 'foo'));
await expect(rejectPromise).rejects.toThrow(
new EthereumRpcError(1000, 'foo'),
new JsonRpcError(1000, 'foo'),
);
});

it('does not clear approval flows', async () => {
approvalController.startFlow();

approvalController.clear(new EthereumRpcError(1, 'clear'));
approvalController.clear(new JsonRpcError(1, 'clear'));

expect(approvalController.state[APPROVAL_FLOWS_STORE_KEY]).toHaveLength(
1,
Expand Down
14 changes: 7 additions & 7 deletions packages/approval-controller/src/ApprovalController.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import type { RestrictedControllerMessenger } from '@metamask/base-controller';
import { BaseControllerV2 } from '@metamask/base-controller';
import type { JsonRpcError, DataWithOptionalCause } from '@metamask/rpc-errors';
import { rpcErrors } from '@metamask/rpc-errors';
import type { Json, OptionalField } from '@metamask/utils';
import type { EthereumRpcError } from 'eth-rpc-errors';
import { ethErrors } from 'eth-rpc-errors';
import type { Patch } from 'immer';
import { nanoid } from 'nanoid';

Expand Down Expand Up @@ -256,7 +256,7 @@ export type GetApprovalsState = {

export type ClearApprovalRequests = {
type: `${typeof controllerName}:clearRequests`;
handler: (error: EthereumRpcError<unknown>) => void;
handler: (error: JsonRpcError<DataWithOptionalCause>) => void;
};

export type AddApprovalRequest = {
Expand Down Expand Up @@ -719,10 +719,10 @@ export class ApprovalController extends BaseControllerV2<
/**
* Rejects and deletes all approval requests.
*
* @param rejectionError - The EthereumRpcError to reject the approval
* @param rejectionError - The JsonRpcError to reject the approval
* requests with.
*/
clear(rejectionError: EthereumRpcError<unknown>): void {
clear(rejectionError: JsonRpcError<DataWithOptionalCause>): void {
for (const id of this.#approvals.keys()) {
this.reject(id, rejectionError);
}
Expand Down Expand Up @@ -878,7 +878,7 @@ export class ApprovalController extends BaseControllerV2<
!this.#typesExcludedFromRateLimiting.includes(type) &&
this.has({ origin, type })
) {
throw ethErrors.rpc.resourceUnavailable(
throw rpcErrors.resourceUnavailable(
getAlreadyPendingMessage(origin, type),
);
}
Expand Down Expand Up @@ -937,7 +937,7 @@ export class ApprovalController extends BaseControllerV2<
}

if (errorMessage) {
throw ethErrors.rpc.internal(errorMessage);
throw rpcErrors.internal(errorMessage);
}
}

Expand Down
2 changes: 1 addition & 1 deletion packages/assets-controllers/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
"@metamask/network-controller": "^13.0.1",
"@metamask/preferences-controller": "^4.4.2",
"@metamask/rpc-errors": "^6.0.0",
"@metamask/utils": "^6.2.0",
"@metamask/utils": "^8.1.0",
"@types/uuid": "^8.3.0",
"async-mutex": "^0.2.6",
"ethereumjs-util": "^7.0.10",
Expand Down
2 changes: 1 addition & 1 deletion packages/base-controller/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"test:watch": "jest --watch"
},
"dependencies": {
"@metamask/utils": "^6.2.0",
"@metamask/utils": "^8.1.0",
"immer": "^9.0.6"
},
"devDependencies": {
Expand Down
3 changes: 1 addition & 2 deletions packages/controller-utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,9 @@
},
"dependencies": {
"@metamask/eth-query": "^3.0.1",
"@metamask/utils": "^6.2.0",
"@metamask/utils": "^8.1.0",
"@spruceid/siwe-parser": "1.1.3",
"eth-ens-namehash": "^2.0.8",
"eth-rpc-errors": "^4.0.2",
"ethereumjs-util": "^7.0.10",
"ethjs-unit": "^0.1.6",
"fast-deep-equal": "^3.1.3"
Expand Down
2 changes: 1 addition & 1 deletion packages/ens-controller/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"@metamask/base-controller": "^3.2.2",
"@metamask/controller-utils": "^5.0.1",
"@metamask/network-controller": "^13.0.1",
"@metamask/utils": "^6.2.0",
"@metamask/utils": "^8.1.0",
"ethereum-ens-network-map": "^1.0.2",
"punycode": "^2.1.1"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/gas-fee-controller/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"@metamask/controller-utils": "^5.0.1",
"@metamask/eth-query": "^3.0.1",
"@metamask/network-controller": "^13.0.1",
"@metamask/utils": "^6.2.0",
"@metamask/utils": "^8.1.0",
"@types/uuid": "^8.3.0",
"ethereumjs-util": "^7.0.10",
"ethjs-unit": "^0.1.6",
Expand Down
2 changes: 1 addition & 1 deletion packages/keyring-controller/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"@metamask/eth-keyring-controller": "^13.0.1",
"@metamask/message-manager": "^7.3.4",
"@metamask/preferences-controller": "^4.4.2",
"@metamask/utils": "^6.2.0",
"@metamask/utils": "^8.1.0",
"async-mutex": "^0.2.6",
"ethereumjs-util": "^7.0.10",
"ethereumjs-wallet": "^1.0.1",
Expand Down
2 changes: 1 addition & 1 deletion packages/message-manager/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"@metamask/base-controller": "^3.2.2",
"@metamask/controller-utils": "^5.0.1",
"@metamask/eth-sig-util": "^7.0.0",
"@metamask/utils": "^6.2.0",
"@metamask/utils": "^8.1.0",
"@types/uuid": "^8.3.0",
"ethereumjs-util": "^7.0.10",
"jsonschema": "^1.2.4",
Expand Down
2 changes: 1 addition & 1 deletion packages/name-controller/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
},
"dependencies": {
"@metamask/base-controller": "^3.2.2",
"@metamask/utils": "^6.2.0",
"@metamask/utils": "^8.1.0",
"async-mutex": "^0.2.6",
"immer": "^9.0.6"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/network-controller/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"@metamask/eth-json-rpc-provider": "^1.0.0",
"@metamask/eth-query": "^3.0.1",
"@metamask/swappable-obj-proxy": "^2.1.0",
"@metamask/utils": "^6.2.0",
"@metamask/utils": "^8.1.0",
"async-mutex": "^0.2.6",
"eth-block-tracker": "^7.0.1",
"eth-rpc-errors": "^4.0.2",
Expand Down
2 changes: 1 addition & 1 deletion packages/notification-controller/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
},
"dependencies": {
"@metamask/base-controller": "^3.2.2",
"@metamask/utils": "^6.2.0",
"@metamask/utils": "^8.1.0",
"immer": "^9.0.6",
"nanoid": "^3.1.31"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/permission-controller/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"@metamask/approval-controller": "^3.5.2",
"@metamask/base-controller": "^3.2.2",
"@metamask/controller-utils": "^5.0.1",
"@metamask/utils": "^6.2.0",
"@metamask/utils": "^8.1.0",
"@types/deep-freeze-strict": "^1.1.0",
"deep-freeze-strict": "^1.1.1",
"eth-rpc-errors": "^4.0.2",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { MethodNames } from '../utils';

export const getPermissionsHandler: PermittedHandlerExport<
GetPermissionsHooks,
undefined,
[],
PermissionConstraint[]
> = {
methodNames: [MethodNames.getPermissions],
Expand Down
2 changes: 1 addition & 1 deletion packages/polling-controller/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"@metamask/base-controller": "^3.2.2",
"@metamask/controller-utils": "^5.0.1",
"@metamask/network-controller": "^13.0.1",
"@metamask/utils": "^6.2.0",
"@metamask/utils": "^8.1.0",
"@types/uuid": "^8.3.0",
"uuid": "^8.3.2"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/signature-controller/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"@metamask/controller-utils": "^5.0.1",
"@metamask/logging-controller": "^1.0.3",
"@metamask/message-manager": "^7.3.4",
"@metamask/utils": "^6.2.0",
"@metamask/utils": "^8.1.0",
"eth-rpc-errors": "^4.0.2",
"ethereumjs-util": "^7.0.10",
"immer": "^9.0.6",
Expand Down
2 changes: 1 addition & 1 deletion packages/transaction-controller/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
"@metamask/metamask-eth-abis": "^3.0.0",
"@metamask/network-controller": "^13.0.1",
"@metamask/rpc-errors": "^6.0.0",
"@metamask/utils": "^6.2.0",
"@metamask/utils": "^8.1.0",
"async-mutex": "^0.2.6",
"eth-method-registry": "1.1.0",
"ethereumjs-util": "^7.0.10",
Expand Down
Loading