Skip to content

Commit

Permalink
Merge branch 'main' into reset-plugins-running-on-boot-not-runningn
Browse files Browse the repository at this point in the history
  • Loading branch information
shanejonas authored Aug 31, 2021
2 parents 37a85e1 + 3c461ef commit 44fec51
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 3 deletions.
3 changes: 2 additions & 1 deletion packages/controllers/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,14 @@
"prepublishOnly": "yarn lint && yarn build"
},
"dependencies": {
"@metamask/controllers": "^14.2.0",
"@metamask/controllers": "^15.0.0",
"@metamask/object-multiplex": "^1.1.0",
"@metamask/obs-store": "^6.0.2",
"@metamask/post-message-stream": "4.0.0",
"@metamask/safe-event-emitter": "^2.0.0",
"@mm-snap/workers": "^0.0.6",
"eth-rpc-errors": "^4.0.2",
"immer": "^8.0.4",
"json-rpc-engine": "^6.1.0",
"json-rpc-middleware-stream": "^3.0.0",
"nanoid": "^3.1.20",
Expand Down
27 changes: 25 additions & 2 deletions packages/controllers/src/plugins/PluginController.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { ethErrors, serializeError } from 'eth-rpc-errors';
import type { Patch } from 'immer';
import { IOcapLdCapability } from 'rpc-cap/dist/src/@types/ocap-ld';
import {
BaseControllerV2 as BaseController,
Expand All @@ -14,6 +15,8 @@ import {
} from '../services/ExecutionEnvironmentService';
import { INLINE_PLUGINS } from './inlinePlugins';

export const controllerName = 'PluginController';

export const PLUGIN_PREFIX = 'wallet_plugin_';
export const PLUGIN_PREFIX_REGEX = new RegExp(`^${PLUGIN_PREFIX}`, 'u');
const SERIALIZABLE_PLUGIN_PROPERTIES = new Set([
Expand Down Expand Up @@ -68,8 +71,27 @@ export type PluginControllerState = {
};
};

export type PluginStateChange = {
type: `${typeof controllerName}:stateChange`;
payload: [PluginControllerState, Patch[]];
};

// TODO: Create actions
export type PluginControllerActions = never;

export type PluginControllerEvents = PluginStateChange;

// TODO: Use ControllerMessenger events
type PluginControllerMessenger = RestrictedControllerMessenger<
typeof controllerName,
PluginControllerActions,
PluginControllerEvents,
never,
never
>;

interface PluginControllerArgs {
messenger: RestrictedControllerMessenger<string, any, any, string, string>;
messenger: PluginControllerMessenger;
state?: PluginControllerState;
removeAllPermissionsFor: RemoveAllPermissionsFunction;
closeAllConnections: CloseAllConnectionsFunction;
Expand Down Expand Up @@ -120,7 +142,8 @@ const name = 'PluginController';

export class PluginController extends BaseController<
string,
PluginControllerState
PluginControllerState,
PluginControllerMessenger
> {
private _removeAllPermissionsFor: RemoveAllPermissionsFunction;

Expand Down
41 changes: 41 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2304,6 +2304,11 @@
resolved "https://registry.yarnpkg.com/@metamask/contract-metadata/-/contract-metadata-1.28.0.tgz#76796f5010aa4aa6d28bf6fe36392017cea687cb"
integrity sha512-QZj6Y1nmSs9BHufBS1GSuPX5TVFa5gbtMhEo/KRuSdKyY43OdlbBKuyT36/l5p30krlzfMX8bN0MAWqw3g0Bog==

"@metamask/contract-metadata@^1.29.0":
version "1.29.0"
resolved "https://registry.yarnpkg.com/@metamask/contract-metadata/-/contract-metadata-1.29.0.tgz#4ca86a2f03d4dad4350d09216a7fe92f9dd21c8e"
integrity sha512-wxsC0ZCyhPKqThvmsL8+2zVWGWPqofSo8HNtOuOnQM9oGbXX9294imJ3T+A/Lov8fkX4jAWZOeNV0uR80zkNtA==

"@metamask/controllers@^14.2.0":
version "14.2.0"
resolved "https://registry.yarnpkg.com/@metamask/controllers/-/controllers-14.2.0.tgz#bed161ac3523fd525be79b0e557b132e2e2526e4"
Expand Down Expand Up @@ -2340,6 +2345,42 @@
web3 "^0.20.7"
web3-provider-engine "^16.0.3"

"@metamask/controllers@^15.0.0":
version "15.0.0"
resolved "https://registry.yarnpkg.com/@metamask/controllers/-/controllers-15.0.0.tgz#b7e816e12e02debaf32f7bab5f8d612cbd7a5170"
integrity sha512-vYVwDVctxdmBRBYDzPfpab3GoVtePykaMKfOdgD+OT8Cz8tlDrEIRc5+DZhr6HembWg8LkNfw9Gh5lKfAFSGLg==
dependencies:
"@ethereumjs/common" "^2.3.1"
"@ethereumjs/tx" "^3.2.1"
"@metamask/contract-metadata" "^1.29.0"
"@types/uuid" "^8.3.0"
async-mutex "^0.2.6"
babel-runtime "^6.26.0"
eth-ens-namehash "^2.0.8"
eth-json-rpc-infura "^5.1.0"
eth-keyring-controller "^6.2.1"
eth-method-registry "1.1.0"
eth-phishing-detect "^1.1.14"
eth-query "^2.1.2"
eth-rpc-errors "^4.0.0"
eth-sig-util "^3.0.0"
ethereumjs-util "^7.0.10"
ethereumjs-wallet "^1.0.1"
ethers "^5.4.1"
ethjs-unit "^0.1.6"
ethjs-util "^0.1.6"
human-standard-collectible-abi "^1.0.2"
human-standard-token-abi "^2.0.0"
immer "^8.0.1"
isomorphic-fetch "^3.0.0"
jsonschema "^1.2.4"
nanoid "^3.1.12"
punycode "^2.1.1"
single-call-balance-checker-abi "^1.0.0"
uuid "^8.3.2"
web3 "^0.20.7"
web3-provider-engine "^16.0.3"

"@metamask/controllers@^5.0.0":
version "5.1.0"
resolved "https://registry.yarnpkg.com/@metamask/controllers/-/controllers-5.1.0.tgz#02c1957295bcb6db1655a716d165665d170e7f34"
Expand Down

0 comments on commit 44fec51

Please sign in to comment.