The controllers and services in sample-controllers are not as useful as examples as they could be. They do not follow the best practices that we want others to follow, so we cannot ask teams to copy them, and they do not follow patterns that are standard in the product.
Here is a more exhaustive list of issues we need to fix:
- The
SampleGasPricesService does not make use of the messenger system. - The
AbstractSampleGasPricesService is no longer needed if SampleGasPricesService uses the messenger system. SampleGasPricesService does not follow the patterns described in the data services pattern. Specifically, it does not use createServicePolicy internally.- The tests for
SampleGasPricesController and SamplePetnamesController do not use the withController pattern. - The tests for
SampleGasPricesController and SamplePetnamesController set up a "root" messenger. We don't use this terminology anywhere else (we either use "global" messenger or "unrestricted" messenger). @metamask/network-controller types are copied instead of being used directly.fetchGasPrices in SampleGasPricesController does not follow the standard multichain pattern and operates against the globally selected network, so contributors learning how to implement a feature might find this strange.getDefaultGasPricesControllerState and getDefaultPetnamesControllerState are placed in the wrong section in their respective files.getDefaultPetnamesControllerState is not exported.
The controllers and services in
sample-controllersare not as useful as examples as they could be. They do not follow the best practices that we want others to follow, so we cannot ask teams to copy them, and they do not follow patterns that are standard in the product.Here is a more exhaustive list of issues we need to fix:
SampleGasPricesServicedoes not make use of the messenger system.AbstractSampleGasPricesServiceis no longer needed ifSampleGasPricesServiceuses the messenger system.SampleGasPricesServicedoes not follow the patterns described in the data services pattern. Specifically, it does not usecreateServicePolicyinternally.SampleGasPricesControllerandSamplePetnamesControllerdo not use thewithControllerpattern.SampleGasPricesControllerandSamplePetnamesControllerset up a "root" messenger. We don't use this terminology anywhere else (we either use "global" messenger or "unrestricted" messenger).@metamask/network-controllertypes are copied instead of being used directly.fetchGasPricesinSampleGasPricesControllerdoes not follow the standard multichain pattern and operates against the globally selected network, so contributors learning how to implement a feature might find this strange.getDefaultGasPricesControllerStateandgetDefaultPetnamesControllerStateare placed in the wrong section in their respective files.getDefaultPetnamesControllerStateis not exported.