Skip to content

Commit

Permalink
Use controllers monorepo packages (#955)
Browse files Browse the repository at this point in the history
* Use controllers monorepo packages

* Fix imports and lint

* Fix import

* Fix import

* Update manifest

* Fix import after rebase

* Fix issue after rebase
  • Loading branch information
FrederikBolding authored Nov 23, 2022
1 parent 3804d68 commit 24ed068
Show file tree
Hide file tree
Showing 43 changed files with 142 additions and 1,633 deletions.
2 changes: 1 addition & 1 deletion packages/examples/examples/ethers-js/snap.manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"url": "https://github.com/MetaMask/snaps-monorepo.git"
},
"source": {
"shasum": "ZKh05KNz06P5GlNCYOuSUe3QQX6OuhSbMjH7RyCQmHo=",
"shasum": "qcHDNajXeVlbmh2ryeq6QezaEBKqbu4MTk6mOXY5oYw=",
"location": {
"npm": {
"filePath": "dist/bundle.js",
Expand Down
2 changes: 1 addition & 1 deletion packages/rpc-methods/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
"publish:package": "../../scripts/publish-package.sh"
},
"dependencies": {
"@metamask/controllers": "^32.0.2",
"@metamask/key-tree": "^6.0.0",
"@metamask/permission-controller": "^1.0.0",
"@metamask/snaps-utils": "^0.24.1",
"@metamask/types": "^1.1.0",
"@metamask/utils": "^3.3.1",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { RequestedPermissions } from '@metamask/controllers';
import { RequestedPermissions } from '@metamask/permission-controller';
import { InstallSnapsResult } from '@metamask/snaps-utils';
import { isObject } from '@metamask/utils';
import { ethErrors } from 'eth-rpc-errors';
Expand Down
2 changes: 1 addition & 1 deletion packages/rpc-methods/src/permitted/requestSnaps.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { RequestedPermissions } from '@metamask/controllers';
import { RequestedPermissions } from '@metamask/permission-controller';
import {
getSnapPermissionName,
InstallSnapsResult,
Expand Down
2 changes: 1 addition & 1 deletion packages/rpc-methods/src/permitted/requestSnaps.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {
PermissionConstraint,
RequestedPermissions,
} from '@metamask/controllers';
} from '@metamask/permission-controller';
import { getSnapPermissionName } from '@metamask/snaps-utils';
import {
PermittedHandlerExport,
Expand Down
2 changes: 1 addition & 1 deletion packages/rpc-methods/src/restricted/confirm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {
PermissionType,
RestrictedMethodOptions,
ValidPermissionSpecification,
} from '@metamask/controllers';
} from '@metamask/permission-controller';
import { isObject, NonEmptyArray } from '@metamask/utils';
import { ethErrors } from 'eth-rpc-errors';

Expand Down
2 changes: 1 addition & 1 deletion packages/rpc-methods/src/restricted/dialog.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { PermissionType } from '@metamask/controllers';
import { PermissionType } from '@metamask/permission-controller';

import {
dialogBuilder,
Expand Down
2 changes: 1 addition & 1 deletion packages/rpc-methods/src/restricted/dialog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {
PermissionType,
RestrictedMethodOptions,
ValidPermissionSpecification,
} from '@metamask/controllers';
} from '@metamask/permission-controller';
import { NonEmptyArray } from '@metamask/utils';
import { ethErrors } from 'eth-rpc-errors';
import {
Expand Down
4 changes: 2 additions & 2 deletions packages/rpc-methods/src/restricted/getBip32Entropy.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { BIP32Node, JsonSLIP10Node, SLIP10Node } from '@metamask/key-tree';
import {
Caveat,
PermissionConstraint,
Expand All @@ -7,8 +8,7 @@ import {
RestrictedMethodCaveatSpecificationConstraint,
RestrictedMethodOptions,
ValidPermissionSpecification,
} from '@metamask/controllers';
import { BIP32Node, JsonSLIP10Node, SLIP10Node } from '@metamask/key-tree';
} from '@metamask/permission-controller';
import {
Bip32Entropy,
Bip32EntropyStruct,
Expand Down
4 changes: 2 additions & 2 deletions packages/rpc-methods/src/restricted/getBip32PublicKey.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { BIP32Node, SLIP10Node } from '@metamask/key-tree';
import {
Caveat,
PermissionSpecificationBuilder,
PermissionType,
PermissionValidatorConstraint,
RestrictedMethodOptions,
ValidPermissionSpecification,
} from '@metamask/controllers';
import { BIP32Node, SLIP10Node } from '@metamask/key-tree';
} from '@metamask/permission-controller';
import {
Bip32Entropy,
bip32entropy,
Expand Down
4 changes: 2 additions & 2 deletions packages/rpc-methods/src/restricted/getBip44Entropy.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { BIP44CoinTypeNode, JsonBIP44CoinTypeNode } from '@metamask/key-tree';
import {
Caveat,
PermissionSpecificationBuilder,
Expand All @@ -7,8 +8,7 @@ import {
ValidPermissionSpecification,
PermissionConstraint,
RestrictedMethodCaveatSpecificationConstraint,
} from '@metamask/controllers';
import { BIP44CoinTypeNode, JsonBIP44CoinTypeNode } from '@metamask/key-tree';
} from '@metamask/permission-controller';
import { SnapCaveatType } from '@metamask/snaps-utils';
import {
hasProperty,
Expand Down
2 changes: 1 addition & 1 deletion packages/rpc-methods/src/restricted/getEntropy.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { PermissionType } from '@metamask/controllers';
import { PermissionType } from '@metamask/permission-controller';
import { MOCK_SNAP_ID } from '@metamask/snaps-utils/test-utils';

import { ENTROPY_VECTORS } from './__fixtures__';
Expand Down
4 changes: 2 additions & 2 deletions packages/rpc-methods/src/restricted/getEntropy.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { HardenedBIP32Node, SLIP10Node } from '@metamask/key-tree';
import {
PermissionSpecificationBuilder,
PermissionType,
RestrictedMethodOptions,
ValidPermissionSpecification,
} from '@metamask/controllers';
import { HardenedBIP32Node, SLIP10Node } from '@metamask/key-tree';
} from '@metamask/permission-controller';
import { SIP_6_MAGIC_VALUE } from '@metamask/snaps-utils';
import {
add0x,
Expand Down
2 changes: 1 addition & 1 deletion packages/rpc-methods/src/restricted/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { PermissionConstraint } from '@metamask/controllers';
import { PermissionConstraint } from '@metamask/permission-controller';
import { Json } from '@metamask/utils';

import { confirmBuilder, ConfirmMethodHooks } from './confirm';
Expand Down
2 changes: 1 addition & 1 deletion packages/rpc-methods/src/restricted/invokeSnap.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { PermissionType } from '@metamask/controllers';
import { PermissionType } from '@metamask/permission-controller';
import {
MOCK_SNAP_ID,
MOCK_ORIGIN,
Expand Down
2 changes: 1 addition & 1 deletion packages/rpc-methods/src/restricted/invokeSnap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {
RestrictedMethodOptions,
ValidPermissionSpecification,
PermissionType,
} from '@metamask/controllers';
} from '@metamask/permission-controller';
import {
Snap,
SNAP_PREFIX,
Expand Down
2 changes: 1 addition & 1 deletion packages/rpc-methods/src/restricted/manageState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {
PermissionType,
RestrictedMethodOptions,
ValidPermissionSpecification,
} from '@metamask/controllers';
} from '@metamask/permission-controller';
import {
Json,
NonEmptyArray,
Expand Down
2 changes: 1 addition & 1 deletion packages/rpc-methods/src/restricted/notify.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {
PermissionType,
RestrictedMethodOptions,
ValidPermissionSpecification,
} from '@metamask/controllers';
} from '@metamask/permission-controller';
import { NonEmptyArray, isObject } from '@metamask/utils';
import { ethErrors } from 'eth-rpc-errors';

Expand Down
4 changes: 3 additions & 1 deletion packages/snaps-controllers/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,11 @@
"publish:package": "../../scripts/publish-package.sh"
},
"dependencies": {
"@metamask/approval-controller": "^1.0.0",
"@metamask/base-controller": "^1.0.0",
"@metamask/browser-passworder": "^4.0.2",
"@metamask/controllers": "^32.0.2",
"@metamask/object-multiplex": "^1.1.0",
"@metamask/permission-controller": "^1.0.0",
"@metamask/post-message-stream": "^6.0.0",
"@metamask/rpc-methods": "^0.24.1",
"@metamask/snaps-execution-environments": "^0.24.1",
Expand Down
4 changes: 2 additions & 2 deletions packages/snaps-controllers/src/cronjob/CronjobController.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import {
BaseControllerV2 as BaseController,
RestrictedControllerMessenger,
GetPermissions,
} from '@metamask/controllers';
} from '@metamask/base-controller';
import { GetPermissions } from '@metamask/permission-controller';
import {
HandlerType,
SnapId,
Expand Down
2 changes: 1 addition & 1 deletion packages/snaps-controllers/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export type { Json } from '@metamask/controllers';
export type { Json } from '@metamask/utils';
export * from './services';
export * from './snaps';
export * from './utils';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import { AddApprovalRequest } from '@metamask/approval-controller';
import {
AddApprovalRequest,
BaseControllerV2 as BaseController,
RestrictedControllerMessenger,
} from '@metamask/base-controller';
import {
GetPermissions,
GrantPermissions,
HasPermission,
PermissionConstraint,
RestrictedControllerMessenger,
} from '@metamask/controllers';
} from '@metamask/permission-controller';
import { SnapKeyring } from '@metamask/snaps-types';
import {
parseAccountId,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { RestrictedControllerMessenger } from '@metamask/controllers';
import { RestrictedControllerMessenger } from '@metamask/base-controller';
import { SnapId, SnapRpcHookArgs } from '@metamask/snaps-utils';
import { Json } from '@metamask/types';

Expand Down
4 changes: 2 additions & 2 deletions packages/snaps-controllers/src/snaps/SnapController.test.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { getPersistentState } from '@metamask/base-controller';
import { encrypt } from '@metamask/browser-passworder';
import {
Caveat,
getPersistentState,
SubjectPermissions,
ValidPermission,
} from '@metamask/controllers';
} from '@metamask/permission-controller';
import {
DEFAULT_ENDOWMENTS,
getSnapSourceShasum,
Expand Down
10 changes: 6 additions & 4 deletions packages/snaps-controllers/src/snaps/SnapController.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import { encrypt, decrypt } from '@metamask/browser-passworder';
import { AddApprovalRequest } from '@metamask/approval-controller';
import {
AddApprovalRequest,
BaseControllerV2 as BaseController,
RestrictedControllerMessenger,
} from '@metamask/base-controller';
import { encrypt, decrypt } from '@metamask/browser-passworder';
import {
Caveat,
GetEndowments,
GetPermissions,
Expand All @@ -10,13 +13,12 @@ import {
HasPermissions,
PermissionConstraint,
PermissionsRequest,
RestrictedControllerMessenger,
RevokeAllPermissions,
RevokePermissionForAllSubjects,
RevokePermissions,
SubjectPermissions,
ValidPermission,
} from '@metamask/controllers';
} from '@metamask/permission-controller';
import { caveatMappers } from '@metamask/rpc-methods';
import {
assertIsSnapManifest,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Caveat, PermissionType } from '@metamask/controllers';
import { Caveat, PermissionType } from '@metamask/permission-controller';
import { SnapCaveatType } from '@metamask/snaps-utils';

import { SnapEndowments } from '.';
Expand Down
2 changes: 1 addition & 1 deletion packages/snaps-controllers/src/snaps/endowments/cronjob.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
PermissionConstraint,
Caveat,
CaveatSpecificationConstraint,
} from '@metamask/controllers';
} from '@metamask/permission-controller';
import {
SnapCaveatType,
CronjobSpecification,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { PermissionType } from '@metamask/controllers';
import { PermissionType } from '@metamask/permission-controller';

import { SnapEndowments } from './enum';
import { ethereumProviderEndowmentBuilder } from './ethereum-provider';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {
PermissionSpecificationBuilder,
PermissionType,
ValidPermissionSpecification,
} from '@metamask/controllers';
} from '@metamask/permission-controller';

import { SnapEndowments } from './enum';

Expand Down
2 changes: 1 addition & 1 deletion packages/snaps-controllers/src/snaps/endowments/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { PermissionConstraint } from '@metamask/controllers';
import { PermissionConstraint } from '@metamask/permission-controller';
import { Json } from '@metamask/utils';

import {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import { PermissionConstraint, PermissionType } from '@metamask/controllers';
import {
PermissionConstraint,
PermissionType,
} from '@metamask/permission-controller';
import { SnapCaveatType } from '@metamask/snaps-utils';
import { getNamespace } from '@metamask/snaps-utils/test-utils';

Expand Down
2 changes: 1 addition & 1 deletion packages/snaps-controllers/src/snaps/endowments/keyring.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
PermissionType,
PermissionValidatorConstraint,
ValidPermissionSpecification,
} from '@metamask/controllers';
} from '@metamask/permission-controller';
import {
assertIsNamespacesObject,
Namespaces,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { PermissionType } from '@metamask/controllers';
import { PermissionType } from '@metamask/permission-controller';

import { SnapEndowments } from '.';
import { longRunningEndowmentBuilder } from './long-running';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {
PermissionType,
EndowmentGetterParams,
ValidPermissionSpecification,
} from '@metamask/controllers';
} from '@metamask/permission-controller';

import { SnapEndowments } from './enum';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { PermissionType } from '@metamask/controllers';
import { PermissionType } from '@metamask/permission-controller';

import { SnapEndowments } from './enum';
import { networkAccessEndowmentBuilder } from './network-access';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {
PermissionSpecificationBuilder,
PermissionType,
ValidPermissionSpecification,
} from '@metamask/controllers';
} from '@metamask/permission-controller';

import { SnapEndowments } from './enum';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import { PermissionConstraint, PermissionType } from '@metamask/controllers';
import {
PermissionConstraint,
PermissionType,
} from '@metamask/permission-controller';
import { SnapCaveatType } from '@metamask/snaps-utils';

import { SnapEndowments } from '.';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
PermissionConstraint,
CaveatSpecificationConstraint,
Caveat,
} from '@metamask/controllers';
} from '@metamask/permission-controller';
import { SnapCaveatType } from '@metamask/snaps-utils';
import {
assert,
Expand Down
2 changes: 1 addition & 1 deletion packages/snaps-controllers/src/test-utils/controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {
ActionConstraint,
ControllerMessenger,
EventConstraint,
} from '@metamask/controllers';
} from '@metamask/base-controller';
import {
getPersistedSnapObject,
getTruncatedSnap,
Expand Down
2 changes: 1 addition & 1 deletion packages/snaps-controllers/src/test-utils/cronjob.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { PermissionConstraint } from '@metamask/controllers';
import { PermissionConstraint } from '@metamask/permission-controller';
import { SnapCaveatType } from '@metamask/snaps-utils';
import { MOCK_ORIGIN } from '@metamask/snaps-utils/test-utils';

Expand Down
2 changes: 1 addition & 1 deletion packages/snaps-controllers/src/test-utils/multichain.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {
PermissionConstraint,
SubjectPermissions,
} from '@metamask/controllers';
} from '@metamask/permission-controller';
import { fromEntries, getSnapSourceShasum } from '@metamask/snaps-utils';
import {
MOCK_ORIGIN,
Expand Down
2 changes: 1 addition & 1 deletion packages/snaps-controllers/src/test-utils/service.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ControllerMessenger } from '@metamask/controllers';
import { ControllerMessenger } from '@metamask/base-controller';
import { JsonRpcEngine } from 'json-rpc-engine';
import { createEngineStream } from 'json-rpc-middleware-stream';
import pump from 'pump';
Expand Down
Loading

0 comments on commit 24ed068

Please sign in to comment.