Skip to content

Commit adcc9a0

Browse files
authored
docs: publish example controllers and service as @metamask/sample-controllers (#5363)
## Explanation Publish existing sample controllers as @metamask/sample-controllers so it can be used in sample code. ## References * Related to https://github.com/MetaMask/MetaMask-planning/issues/3850 <!-- Are there any issues that this pull request is tied to? Are there other links that reviewers should consult to understand these changes better? Are there client or consumer pull requests to adopt any breaking changes? For example: * Fixes #12345 * Related to #67890 --> ## Changelog <!-- If you're making any consumer-facing changes, list those changes here as if you were updating a changelog, using the template below as a guide. (CATEGORY is one of BREAKING, ADDED, CHANGED, DEPRECATED, REMOVED, or FIXED. For security-related issues, follow the Security Advisory process.) Please take care to name the exact pieces of the API you've added or changed (e.g. types, interfaces, functions, or methods). If there are any breaking changes, make sure to offer a solution for consumers to follow once they upgrade to the changes. Finally, if you're only making changes to development scripts or tests, you may replace the template below with "None". --> ### `@metamask/sample-controllers` - **ADDED**: Initial sample controllers and service – (GasPricesController, PetNamesController, GasPricesService) ## Checklist - [ ] I've updated the test suite for new or updated code as appropriate - [ ] I've updated documentation (JSDoc, Markdown, etc.) for new or updated code as appropriate - [ ] I've highlighted breaking changes using the "BREAKING" category above as appropriate - [ ] I've prepared draft pull requests for clients and consumer packages to resolve any breaking changes
1 parent 4de2849 commit adcc9a0

32 files changed

+284
-244
lines changed

.github/CODEOWNERS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
/packages/build-utils @MetaMask/wallet-framework-engineers
5555
/packages/composable-controller @MetaMask/wallet-framework-engineers
5656
/packages/controller-utils @MetaMask/wallet-framework-engineers
57-
/packages/example-controllers @MetaMask/wallet-framework-engineers
57+
/packages/sample-controllers @MetaMask/wallet-framework-engineers
5858
/packages/polling-controller @MetaMask/wallet-framework-engineers
5959
/packages/preferences-controller @MetaMask/wallet-framework-engineers
6060

README.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ Each package in this repository has its own README where you can find installati
5555
- [`@metamask/queued-request-controller`](packages/queued-request-controller)
5656
- [`@metamask/rate-limit-controller`](packages/rate-limit-controller)
5757
- [`@metamask/remote-feature-flag-controller`](packages/remote-feature-flag-controller)
58+
- [`@metamask/sample-controllers`](packages/sample-controllers)
5859
- [`@metamask/selected-network-controller`](packages/selected-network-controller)
5960
- [`@metamask/signature-controller`](packages/signature-controller)
6061
- [`@metamask/token-search-discovery-controller`](packages/token-search-discovery-controller)
@@ -104,6 +105,7 @@ linkStyle default opacity:0.5
104105
queued_request_controller(["@metamask/queued-request-controller"]);
105106
rate_limit_controller(["@metamask/rate-limit-controller"]);
106107
remote_feature_flag_controller(["@metamask/remote-feature-flag-controller"]);
108+
sample_controllers(["@metamask/sample-controllers"]);
107109
selected_network_controller(["@metamask/selected-network-controller"]);
108110
signature_controller(["@metamask/signature-controller"]);
109111
token_search_discovery_controller(["@metamask/token-search-discovery-controller"]);
@@ -129,15 +131,15 @@ linkStyle default opacity:0.5
129131
bridge_controller --> base_controller;
130132
bridge_controller --> controller_utils;
131133
bridge_controller --> polling_controller;
132-
bridge_controller --> transaction_controller;
133134
bridge_controller --> accounts_controller;
134135
bridge_controller --> eth_json_rpc_provider;
135136
bridge_controller --> network_controller;
137+
bridge_controller --> transaction_controller;
136138
bridge_status_controller --> base_controller;
139+
bridge_status_controller --> bridge_controller;
137140
bridge_status_controller --> controller_utils;
138141
bridge_status_controller --> polling_controller;
139142
bridge_status_controller --> accounts_controller;
140-
bridge_status_controller --> bridge_controller;
141143
bridge_status_controller --> network_controller;
142144
bridge_status_controller --> transaction_controller;
143145
composable_controller --> base_controller;
@@ -207,6 +209,9 @@ linkStyle default opacity:0.5
207209
rate_limit_controller --> base_controller;
208210
remote_feature_flag_controller --> base_controller;
209211
remote_feature_flag_controller --> controller_utils;
212+
sample_controllers --> base_controller;
213+
sample_controllers --> controller_utils;
214+
sample_controllers --> network_controller;
210215
selected_network_controller --> base_controller;
211216
selected_network_controller --> json_rpc_engine;
212217
selected_network_controller --> network_controller;

eslint-warning-thresholds.json

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,4 @@
11
{
2-
"examples/example-controllers/src/gas-prices-controller.test.ts": {
3-
"import-x/order": 1
4-
},
5-
"examples/example-controllers/src/gas-prices-controller.ts": {
6-
"@typescript-eslint/prefer-readonly": 1,
7-
"prettier/prettier": 1
8-
},
9-
"examples/example-controllers/src/gas-prices-service/gas-prices-service.ts": {
10-
"@typescript-eslint/prefer-readonly": 1,
11-
"jsdoc/require-returns": 1
12-
},
13-
"examples/example-controllers/src/pet-names-controller.test.ts": {
14-
"import-x/order": 2
15-
},
162
"packages/accounts-controller/src/AccountsController.test.ts": {
173
"import-x/namespace": 1
184
},

examples/example-controllers/src/gas-prices-service/abstract-gas-prices-service.ts

Lines changed: 0 additions & 8 deletions
This file was deleted.

examples/example-controllers/src/index.ts

Lines changed: 0 additions & 25 deletions
This file was deleted.

jest.config.packages.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ module.exports = {
2828
coverageDirectory: 'coverage',
2929

3030
// An array of regexp pattern strings used to skip coverage collection
31-
coveragePathIgnorePatterns: ['./src/index.ts'],
31+
coveragePathIgnorePatterns: ['.*/index\\.ts'],
3232

3333
// Indicates which provider should be used to instrument code for coverage
3434
coverageProvider: 'babel',

packages/assets-controllers/src/MultichainAssetsController/MultichainAssetsController.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ type RootEvent = ExtractAvailableEvent<MultichainAssetsControllerMessenger>;
227227
* Constructs the unrestricted messenger. This can be used to call actions and
228228
* publish events within the tests for this controller.
229229
*
230-
* @returns The unrestricted messenger suited for PetNamesController.
230+
* @returns The unrestricted messenger suited for MultichainAssetsController.
231231
*/
232232
function getRootMessenger(): Messenger<RootAction, RootEvent> {
233233
return new Messenger<RootAction, RootEvent>();

packages/assets-controllers/src/MultichainBalancesController/MultichainBalancesController.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ type RootEvent = ExtractAvailableEvent<MultichainBalancesControllerMessenger>;
114114
* Constructs the unrestricted messenger. This can be used to call actions and
115115
* publish events within the tests for this controller.
116116
*
117-
* @returns The unrestricted messenger suited for PetNamesController.
117+
* @returns The unrestricted messenger suited for MultichainBalancesController.
118118
*/
119119
function getRootMessenger(): Messenger<RootAction, RootEvent> {
120120
return new Messenger<RootAction, RootEvent>();
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2024 MetaMask
3+
Copyright (c) 2025 MetaMask
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

0 commit comments

Comments
 (0)