@metamask-previews/sample-controllers 5.0.3-preview-ec4680201 → 5.0.3-preview-40d5fb1e2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (30) hide show
  1. package/dist/index.cjs +8 -8
  2. package/dist/index.cjs.map +1 -1
  3. package/dist/index.d.cts.map +1 -1
  4. package/dist/index.d.mts.map +1 -1
  5. package/dist/index.mjs.map +1 -1
  6. package/dist/sample-gas-prices-controller-method-action-types.cjs.map +1 -1
  7. package/dist/sample-gas-prices-controller-method-action-types.d.cts.map +1 -1
  8. package/dist/sample-gas-prices-controller-method-action-types.d.mts.map +1 -1
  9. package/dist/sample-gas-prices-controller-method-action-types.mjs.map +1 -1
  10. package/dist/sample-gas-prices-controller.cjs.map +1 -1
  11. package/dist/sample-gas-prices-controller.d.cts.map +1 -1
  12. package/dist/sample-gas-prices-controller.d.mts.map +1 -1
  13. package/dist/sample-gas-prices-controller.mjs.map +1 -1
  14. package/dist/sample-gas-prices-service/sample-gas-prices-service-method-action-types.cjs.map +1 -1
  15. package/dist/sample-gas-prices-service/sample-gas-prices-service-method-action-types.d.cts.map +1 -1
  16. package/dist/sample-gas-prices-service/sample-gas-prices-service-method-action-types.d.mts.map +1 -1
  17. package/dist/sample-gas-prices-service/sample-gas-prices-service-method-action-types.mjs.map +1 -1
  18. package/dist/sample-gas-prices-service/sample-gas-prices-service.cjs.map +1 -1
  19. package/dist/sample-gas-prices-service/sample-gas-prices-service.d.cts.map +1 -1
  20. package/dist/sample-gas-prices-service/sample-gas-prices-service.d.mts.map +1 -1
  21. package/dist/sample-gas-prices-service/sample-gas-prices-service.mjs.map +1 -1
  22. package/dist/sample-petnames-controller-method-action-types.cjs.map +1 -1
  23. package/dist/sample-petnames-controller-method-action-types.d.cts.map +1 -1
  24. package/dist/sample-petnames-controller-method-action-types.d.mts.map +1 -1
  25. package/dist/sample-petnames-controller-method-action-types.mjs.map +1 -1
  26. package/dist/sample-petnames-controller.cjs.map +1 -1
  27. package/dist/sample-petnames-controller.d.cts.map +1 -1
  28. package/dist/sample-petnames-controller.d.mts.map +1 -1
  29. package/dist/sample-petnames-controller.mjs.map +1 -1
  30. package/package.json +6 -6
package/dist/index.cjs CHANGED
@@ -1,12 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getDefaultPetnamesControllerState = exports.SamplePetnamesController = exports.getDefaultSampleGasPricesControllerState = exports.SampleGasPricesController = exports.SampleGasPricesService = void 0;
4
- var sample_gas_prices_service_js_1 = require("./sample-gas-prices-service/sample-gas-prices-service.cjs");
5
- Object.defineProperty(exports, "SampleGasPricesService", { enumerable: true, get: function () { return sample_gas_prices_service_js_1.SampleGasPricesService; } });
6
- var sample_gas_prices_controller_js_1 = require("./sample-gas-prices-controller.cjs");
7
- Object.defineProperty(exports, "SampleGasPricesController", { enumerable: true, get: function () { return sample_gas_prices_controller_js_1.SampleGasPricesController; } });
8
- Object.defineProperty(exports, "getDefaultSampleGasPricesControllerState", { enumerable: true, get: function () { return sample_gas_prices_controller_js_1.getDefaultSampleGasPricesControllerState; } });
9
- var sample_petnames_controller_js_1 = require("./sample-petnames-controller.cjs");
10
- Object.defineProperty(exports, "SamplePetnamesController", { enumerable: true, get: function () { return sample_petnames_controller_js_1.SamplePetnamesController; } });
11
- Object.defineProperty(exports, "getDefaultPetnamesControllerState", { enumerable: true, get: function () { return sample_petnames_controller_js_1.getDefaultPetnamesControllerState; } });
4
+ var sample_gas_prices_service_1 = require("./sample-gas-prices-service/sample-gas-prices-service.cjs");
5
+ Object.defineProperty(exports, "SampleGasPricesService", { enumerable: true, get: function () { return sample_gas_prices_service_1.SampleGasPricesService; } });
6
+ var sample_gas_prices_controller_1 = require("./sample-gas-prices-controller.cjs");
7
+ Object.defineProperty(exports, "SampleGasPricesController", { enumerable: true, get: function () { return sample_gas_prices_controller_1.SampleGasPricesController; } });
8
+ Object.defineProperty(exports, "getDefaultSampleGasPricesControllerState", { enumerable: true, get: function () { return sample_gas_prices_controller_1.getDefaultSampleGasPricesControllerState; } });
9
+ var sample_petnames_controller_1 = require("./sample-petnames-controller.cjs");
10
+ Object.defineProperty(exports, "SamplePetnamesController", { enumerable: true, get: function () { return sample_petnames_controller_1.SamplePetnamesController; } });
11
+ Object.defineProperty(exports, "getDefaultPetnamesControllerState", { enumerable: true, get: function () { return sample_petnames_controller_1.getDefaultPetnamesControllerState; } });
12
12
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AASA,0GAAkG;AAAzF,sIAAA,sBAAsB,OAAA;AAS/B,sFAG2C;AAFzC,4IAAA,yBAAyB,OAAA;AACzB,2JAAA,wCAAwC,OAAA;AAW1C,kFAGyC;AAFvC,yIAAA,wBAAwB,OAAA;AACxB,kJAAA,iCAAiC,OAAA","sourcesContent":["export type {\n SampleGasPricesServiceInvalidateQueriesAction,\n SampleGasPricesServiceActions,\n SampleGasPricesServiceCacheUpdatedEvent,\n SampleGasPricesServiceGranularCacheUpdatedEvent,\n SampleGasPricesServiceEvents,\n SampleGasPricesServiceMessenger,\n} from './sample-gas-prices-service/sample-gas-prices-service.js';\nexport type { SampleGasPricesServiceFetchGasPricesAction } from './sample-gas-prices-service/sample-gas-prices-service-method-action-types.js';\nexport { SampleGasPricesService } from './sample-gas-prices-service/sample-gas-prices-service.js';\nexport type {\n SampleGasPricesControllerActions,\n SampleGasPricesControllerEvents,\n SampleGasPricesControllerGetStateAction,\n SampleGasPricesControllerMessenger,\n SampleGasPricesControllerState,\n SampleGasPricesControllerStateChangeEvent,\n} from './sample-gas-prices-controller.js';\nexport {\n SampleGasPricesController,\n getDefaultSampleGasPricesControllerState,\n} from './sample-gas-prices-controller.js';\nexport type { SampleGasPricesControllerUpdateGasPricesAction } from './sample-gas-prices-controller-method-action-types.js';\nexport type {\n SamplePetnamesControllerActions,\n SamplePetnamesControllerEvents,\n SamplePetnamesControllerGetStateAction,\n SamplePetnamesControllerMessenger,\n SamplePetnamesControllerState,\n SamplePetnamesControllerStateChangeEvent,\n} from './sample-petnames-controller.js';\nexport {\n SamplePetnamesController,\n getDefaultPetnamesControllerState,\n} from './sample-petnames-controller.js';\nexport type { SamplePetnamesControllerAssignPetnameAction } from './sample-petnames-controller-method-action-types.js';\n"]}
1
+ {"version":3,"file":"index.cjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AASA,uGAA+F;AAAtF,mIAAA,sBAAsB,OAAA;AAS/B,mFAGwC;AAFtC,yIAAA,yBAAyB,OAAA;AACzB,wJAAA,wCAAwC,OAAA;AAW1C,+EAGsC;AAFpC,sIAAA,wBAAwB,OAAA;AACxB,+IAAA,iCAAiC,OAAA","sourcesContent":["export type {\n SampleGasPricesServiceInvalidateQueriesAction,\n SampleGasPricesServiceActions,\n SampleGasPricesServiceCacheUpdatedEvent,\n SampleGasPricesServiceGranularCacheUpdatedEvent,\n SampleGasPricesServiceEvents,\n SampleGasPricesServiceMessenger,\n} from './sample-gas-prices-service/sample-gas-prices-service';\nexport type { SampleGasPricesServiceFetchGasPricesAction } from './sample-gas-prices-service/sample-gas-prices-service-method-action-types';\nexport { SampleGasPricesService } from './sample-gas-prices-service/sample-gas-prices-service';\nexport type {\n SampleGasPricesControllerActions,\n SampleGasPricesControllerEvents,\n SampleGasPricesControllerGetStateAction,\n SampleGasPricesControllerMessenger,\n SampleGasPricesControllerState,\n SampleGasPricesControllerStateChangeEvent,\n} from './sample-gas-prices-controller';\nexport {\n SampleGasPricesController,\n getDefaultSampleGasPricesControllerState,\n} from './sample-gas-prices-controller';\nexport type { SampleGasPricesControllerUpdateGasPricesAction } from './sample-gas-prices-controller-method-action-types';\nexport type {\n SamplePetnamesControllerActions,\n SamplePetnamesControllerEvents,\n SamplePetnamesControllerGetStateAction,\n SamplePetnamesControllerMessenger,\n SamplePetnamesControllerState,\n SamplePetnamesControllerStateChangeEvent,\n} from './sample-petnames-controller';\nexport {\n SamplePetnamesController,\n getDefaultPetnamesControllerState,\n} from './sample-petnames-controller';\nexport type { SamplePetnamesControllerAssignPetnameAction } from './sample-petnames-controller-method-action-types';\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.cts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,6CAA6C,EAC7C,6BAA6B,EAC7B,uCAAuC,EACvC,+CAA+C,EAC/C,4BAA4B,EAC5B,+BAA+B,GAChC,kEAAiE;AAClE,YAAY,EAAE,0CAA0C,EAAE,sFAAqF;AAC/I,OAAO,EAAE,sBAAsB,EAAE,kEAAiE;AAClG,YAAY,EACV,gCAAgC,EAChC,+BAA+B,EAC/B,uCAAuC,EACvC,kCAAkC,EAClC,8BAA8B,EAC9B,yCAAyC,GAC1C,2CAA0C;AAC3C,OAAO,EACL,yBAAyB,EACzB,wCAAwC,GACzC,2CAA0C;AAC3C,YAAY,EAAE,8CAA8C,EAAE,+DAA8D;AAC5H,YAAY,EACV,+BAA+B,EAC/B,8BAA8B,EAC9B,sCAAsC,EACtC,iCAAiC,EACjC,6BAA6B,EAC7B,wCAAwC,GACzC,yCAAwC;AACzC,OAAO,EACL,wBAAwB,EACxB,iCAAiC,GAClC,yCAAwC;AACzC,YAAY,EAAE,2CAA2C,EAAE,6DAA4D"}
1
+ {"version":3,"file":"index.d.cts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,6CAA6C,EAC7C,6BAA6B,EAC7B,uCAAuC,EACvC,+CAA+C,EAC/C,4BAA4B,EAC5B,+BAA+B,GAChC,kEAA8D;AAC/D,YAAY,EAAE,0CAA0C,EAAE,sFAAkF;AAC5I,OAAO,EAAE,sBAAsB,EAAE,kEAA8D;AAC/F,YAAY,EACV,gCAAgC,EAChC,+BAA+B,EAC/B,uCAAuC,EACvC,kCAAkC,EAClC,8BAA8B,EAC9B,yCAAyC,GAC1C,2CAAuC;AACxC,OAAO,EACL,yBAAyB,EACzB,wCAAwC,GACzC,2CAAuC;AACxC,YAAY,EAAE,8CAA8C,EAAE,+DAA2D;AACzH,YAAY,EACV,+BAA+B,EAC/B,8BAA8B,EAC9B,sCAAsC,EACtC,iCAAiC,EACjC,6BAA6B,EAC7B,wCAAwC,GACzC,yCAAqC;AACtC,OAAO,EACL,wBAAwB,EACxB,iCAAiC,GAClC,yCAAqC;AACtC,YAAY,EAAE,2CAA2C,EAAE,6DAAyD"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,6CAA6C,EAC7C,6BAA6B,EAC7B,uCAAuC,EACvC,+CAA+C,EAC/C,4BAA4B,EAC5B,+BAA+B,GAChC,kEAAiE;AAClE,YAAY,EAAE,0CAA0C,EAAE,sFAAqF;AAC/I,OAAO,EAAE,sBAAsB,EAAE,kEAAiE;AAClG,YAAY,EACV,gCAAgC,EAChC,+BAA+B,EAC/B,uCAAuC,EACvC,kCAAkC,EAClC,8BAA8B,EAC9B,yCAAyC,GAC1C,2CAA0C;AAC3C,OAAO,EACL,yBAAyB,EACzB,wCAAwC,GACzC,2CAA0C;AAC3C,YAAY,EAAE,8CAA8C,EAAE,+DAA8D;AAC5H,YAAY,EACV,+BAA+B,EAC/B,8BAA8B,EAC9B,sCAAsC,EACtC,iCAAiC,EACjC,6BAA6B,EAC7B,wCAAwC,GACzC,yCAAwC;AACzC,OAAO,EACL,wBAAwB,EACxB,iCAAiC,GAClC,yCAAwC;AACzC,YAAY,EAAE,2CAA2C,EAAE,6DAA4D"}
1
+ {"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,6CAA6C,EAC7C,6BAA6B,EAC7B,uCAAuC,EACvC,+CAA+C,EAC/C,4BAA4B,EAC5B,+BAA+B,GAChC,kEAA8D;AAC/D,YAAY,EAAE,0CAA0C,EAAE,sFAAkF;AAC5I,OAAO,EAAE,sBAAsB,EAAE,kEAA8D;AAC/F,YAAY,EACV,gCAAgC,EAChC,+BAA+B,EAC/B,uCAAuC,EACvC,kCAAkC,EAClC,8BAA8B,EAC9B,yCAAyC,GAC1C,2CAAuC;AACxC,OAAO,EACL,yBAAyB,EACzB,wCAAwC,GACzC,2CAAuC;AACxC,YAAY,EAAE,8CAA8C,EAAE,+DAA2D;AACzH,YAAY,EACV,+BAA+B,EAC/B,8BAA8B,EAC9B,sCAAsC,EACtC,iCAAiC,EACjC,6BAA6B,EAC7B,wCAAwC,GACzC,yCAAqC;AACtC,OAAO,EACL,wBAAwB,EACxB,iCAAiC,GAClC,yCAAqC;AACtC,YAAY,EAAE,2CAA2C,EAAE,6DAAyD"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,sBAAsB,EAAE,kEAAiE;AASlG,OAAO,EACL,yBAAyB,EACzB,wCAAwC,EACzC,2CAA0C;AAU3C,OAAO,EACL,wBAAwB,EACxB,iCAAiC,EAClC,yCAAwC","sourcesContent":["export type {\n SampleGasPricesServiceInvalidateQueriesAction,\n SampleGasPricesServiceActions,\n SampleGasPricesServiceCacheUpdatedEvent,\n SampleGasPricesServiceGranularCacheUpdatedEvent,\n SampleGasPricesServiceEvents,\n SampleGasPricesServiceMessenger,\n} from './sample-gas-prices-service/sample-gas-prices-service.js';\nexport type { SampleGasPricesServiceFetchGasPricesAction } from './sample-gas-prices-service/sample-gas-prices-service-method-action-types.js';\nexport { SampleGasPricesService } from './sample-gas-prices-service/sample-gas-prices-service.js';\nexport type {\n SampleGasPricesControllerActions,\n SampleGasPricesControllerEvents,\n SampleGasPricesControllerGetStateAction,\n SampleGasPricesControllerMessenger,\n SampleGasPricesControllerState,\n SampleGasPricesControllerStateChangeEvent,\n} from './sample-gas-prices-controller.js';\nexport {\n SampleGasPricesController,\n getDefaultSampleGasPricesControllerState,\n} from './sample-gas-prices-controller.js';\nexport type { SampleGasPricesControllerUpdateGasPricesAction } from './sample-gas-prices-controller-method-action-types.js';\nexport type {\n SamplePetnamesControllerActions,\n SamplePetnamesControllerEvents,\n SamplePetnamesControllerGetStateAction,\n SamplePetnamesControllerMessenger,\n SamplePetnamesControllerState,\n SamplePetnamesControllerStateChangeEvent,\n} from './sample-petnames-controller.js';\nexport {\n SamplePetnamesController,\n getDefaultPetnamesControllerState,\n} from './sample-petnames-controller.js';\nexport type { SamplePetnamesControllerAssignPetnameAction } from './sample-petnames-controller-method-action-types.js';\n"]}
1
+ {"version":3,"file":"index.mjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,sBAAsB,EAAE,kEAA8D;AAS/F,OAAO,EACL,yBAAyB,EACzB,wCAAwC,EACzC,2CAAuC;AAUxC,OAAO,EACL,wBAAwB,EACxB,iCAAiC,EAClC,yCAAqC","sourcesContent":["export type {\n SampleGasPricesServiceInvalidateQueriesAction,\n SampleGasPricesServiceActions,\n SampleGasPricesServiceCacheUpdatedEvent,\n SampleGasPricesServiceGranularCacheUpdatedEvent,\n SampleGasPricesServiceEvents,\n SampleGasPricesServiceMessenger,\n} from './sample-gas-prices-service/sample-gas-prices-service';\nexport type { SampleGasPricesServiceFetchGasPricesAction } from './sample-gas-prices-service/sample-gas-prices-service-method-action-types';\nexport { SampleGasPricesService } from './sample-gas-prices-service/sample-gas-prices-service';\nexport type {\n SampleGasPricesControllerActions,\n SampleGasPricesControllerEvents,\n SampleGasPricesControllerGetStateAction,\n SampleGasPricesControllerMessenger,\n SampleGasPricesControllerState,\n SampleGasPricesControllerStateChangeEvent,\n} from './sample-gas-prices-controller';\nexport {\n SampleGasPricesController,\n getDefaultSampleGasPricesControllerState,\n} from './sample-gas-prices-controller';\nexport type { SampleGasPricesControllerUpdateGasPricesAction } from './sample-gas-prices-controller-method-action-types';\nexport type {\n SamplePetnamesControllerActions,\n SamplePetnamesControllerEvents,\n SamplePetnamesControllerGetStateAction,\n SamplePetnamesControllerMessenger,\n SamplePetnamesControllerState,\n SamplePetnamesControllerStateChangeEvent,\n} from './sample-petnames-controller';\nexport {\n SamplePetnamesController,\n getDefaultPetnamesControllerState,\n} from './sample-petnames-controller';\nexport type { SamplePetnamesControllerAssignPetnameAction } from './sample-petnames-controller-method-action-types';\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"sample-gas-prices-controller-method-action-types.cjs","sourceRoot":"","sources":["../src/sample-gas-prices-controller-method-action-types.ts"],"names":[],"mappings":";AAAA;;;GAGG","sourcesContent":["/**\n * This file is auto generated.\n * Do not edit manually.\n */\n\nimport type { SampleGasPricesController } from './sample-gas-prices-controller.js';\n\n/**\n * Fetches the latest gas prices for the given chain and persists them to\n * state.\n *\n * @param args - The arguments to the function.\n * @param args.chainId - The chain ID for which to fetch gas prices.\n */\nexport type SampleGasPricesControllerUpdateGasPricesAction = {\n type: `SampleGasPricesController:updateGasPrices`;\n handler: SampleGasPricesController['updateGasPrices'];\n};\n\n/**\n * Union of all SampleGasPricesController action types.\n */\nexport type SampleGasPricesControllerMethodActions =\n SampleGasPricesControllerUpdateGasPricesAction;\n"]}
1
+ {"version":3,"file":"sample-gas-prices-controller-method-action-types.cjs","sourceRoot":"","sources":["../src/sample-gas-prices-controller-method-action-types.ts"],"names":[],"mappings":";AAAA;;;GAGG","sourcesContent":["/**\n * This file is auto generated.\n * Do not edit manually.\n */\n\nimport type { SampleGasPricesController } from './sample-gas-prices-controller';\n\n/**\n * Fetches the latest gas prices for the given chain and persists them to\n * state.\n *\n * @param args - The arguments to the function.\n * @param args.chainId - The chain ID for which to fetch gas prices.\n */\nexport type SampleGasPricesControllerUpdateGasPricesAction = {\n type: `SampleGasPricesController:updateGasPrices`;\n handler: SampleGasPricesController['updateGasPrices'];\n};\n\n/**\n * Union of all SampleGasPricesController action types.\n */\nexport type SampleGasPricesControllerMethodActions =\n SampleGasPricesControllerUpdateGasPricesAction;\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"sample-gas-prices-controller-method-action-types.d.cts","sourceRoot":"","sources":["../src/sample-gas-prices-controller-method-action-types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,yBAAyB,EAAE,2CAA0C;AAEnF;;;;;;GAMG;AACH,MAAM,MAAM,8CAA8C,GAAG;IAC3D,IAAI,EAAE,2CAA2C,CAAC;IAClD,OAAO,EAAE,yBAAyB,CAAC,iBAAiB,CAAC,CAAC;CACvD,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,sCAAsC,GAChD,8CAA8C,CAAC"}
1
+ {"version":3,"file":"sample-gas-prices-controller-method-action-types.d.cts","sourceRoot":"","sources":["../src/sample-gas-prices-controller-method-action-types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,yBAAyB,EAAE,2CAAuC;AAEhF;;;;;;GAMG;AACH,MAAM,MAAM,8CAA8C,GAAG;IAC3D,IAAI,EAAE,2CAA2C,CAAC;IAClD,OAAO,EAAE,yBAAyB,CAAC,iBAAiB,CAAC,CAAC;CACvD,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,sCAAsC,GAChD,8CAA8C,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"sample-gas-prices-controller-method-action-types.d.mts","sourceRoot":"","sources":["../src/sample-gas-prices-controller-method-action-types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,yBAAyB,EAAE,2CAA0C;AAEnF;;;;;;GAMG;AACH,MAAM,MAAM,8CAA8C,GAAG;IAC3D,IAAI,EAAE,2CAA2C,CAAC;IAClD,OAAO,EAAE,yBAAyB,CAAC,iBAAiB,CAAC,CAAC;CACvD,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,sCAAsC,GAChD,8CAA8C,CAAC"}
1
+ {"version":3,"file":"sample-gas-prices-controller-method-action-types.d.mts","sourceRoot":"","sources":["../src/sample-gas-prices-controller-method-action-types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,yBAAyB,EAAE,2CAAuC;AAEhF;;;;;;GAMG;AACH,MAAM,MAAM,8CAA8C,GAAG;IAC3D,IAAI,EAAE,2CAA2C,CAAC;IAClD,OAAO,EAAE,yBAAyB,CAAC,iBAAiB,CAAC,CAAC;CACvD,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,sCAAsC,GAChD,8CAA8C,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"sample-gas-prices-controller-method-action-types.mjs","sourceRoot":"","sources":["../src/sample-gas-prices-controller-method-action-types.ts"],"names":[],"mappings":"AAAA;;;GAGG","sourcesContent":["/**\n * This file is auto generated.\n * Do not edit manually.\n */\n\nimport type { SampleGasPricesController } from './sample-gas-prices-controller.js';\n\n/**\n * Fetches the latest gas prices for the given chain and persists them to\n * state.\n *\n * @param args - The arguments to the function.\n * @param args.chainId - The chain ID for which to fetch gas prices.\n */\nexport type SampleGasPricesControllerUpdateGasPricesAction = {\n type: `SampleGasPricesController:updateGasPrices`;\n handler: SampleGasPricesController['updateGasPrices'];\n};\n\n/**\n * Union of all SampleGasPricesController action types.\n */\nexport type SampleGasPricesControllerMethodActions =\n SampleGasPricesControllerUpdateGasPricesAction;\n"]}
1
+ {"version":3,"file":"sample-gas-prices-controller-method-action-types.mjs","sourceRoot":"","sources":["../src/sample-gas-prices-controller-method-action-types.ts"],"names":[],"mappings":"AAAA;;;GAGG","sourcesContent":["/**\n * This file is auto generated.\n * Do not edit manually.\n */\n\nimport type { SampleGasPricesController } from './sample-gas-prices-controller';\n\n/**\n * Fetches the latest gas prices for the given chain and persists them to\n * state.\n *\n * @param args - The arguments to the function.\n * @param args.chainId - The chain ID for which to fetch gas prices.\n */\nexport type SampleGasPricesControllerUpdateGasPricesAction = {\n type: `SampleGasPricesController:updateGasPrices`;\n handler: SampleGasPricesController['updateGasPrices'];\n};\n\n/**\n * Union of all SampleGasPricesController action types.\n */\nexport type SampleGasPricesControllerMethodActions =\n SampleGasPricesControllerUpdateGasPricesAction;\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"sample-gas-prices-controller.cjs","sourceRoot":"","sources":["../src/sample-gas-prices-controller.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAKA,+DAA2D;AAY3D,kBAAkB;AAElB;;;;GAIG;AACH,MAAM,eAAe,GAAG,2BAA2B,CAAC;AAsCpD;;GAEG;AACH,MAAM,2BAA2B,GAAG;IAClC,kBAAkB,EAAE;QAClB,sBAAsB,EAAE,KAAK;QAC7B,kBAAkB,EAAE,IAAI;QACxB,OAAO,EAAE,IAAI;QACb,QAAQ,EAAE,IAAI;KACf;CACsD,CAAC;AAE1D;;;;;;;GAOG;AACH,SAAgB,wCAAwC;IACtD,OAAO;QACL,kBAAkB,EAAE,EAAE;KACvB,CAAC;AACJ,CAAC;AAJD,4FAIC;AAED,oBAAoB;AAEpB,MAAM,yBAAyB,GAAG,CAAC,iBAAiB,CAAU,CAAC;AAuD/D,gCAAgC;AAEhC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwEG;AACH,MAAa,yBAA0B,SAAQ,gCAI9C;IAMC;;;;;;;OAOG;IACH,YAAY,EACV,SAAS,EACT,KAAK,GAIN;QACC,KAAK,CAAC;YACJ,SAAS;YACT,QAAQ,EAAE,2BAA2B;YACrC,IAAI,EAAE,eAAe;YACrB,KAAK,EAAE;gBACL,GAAG,wCAAwC,EAAE;gBAC7C,GAAG,KAAK;aACT;SACF,CAAC,CAAC;;QA5BL;;WAEG;QACH,6DAAkC;QA2BhC,IAAI,CAAC,SAAS,CAAC,4BAA4B,CACzC,IAAI,EACJ,yBAAyB,CAC1B,CAAC;QAEF,IAAI,CAAC,SAAS,CAAC,SAAS,CACtB,+BAA+B,EAC/B,uBAAA,IAAI,wGAAiC,CAAC,IAAI,CAAC,IAAI,CAAC,EAChD,CAAC,sBAAsB,EAAE,EAAE,CACzB,sBAAsB,CAAC,uBAAuB,CACjD,CAAC;IACJ,CAAC;IAED;;;;;;OAMG;IACH,KAAK,CAAC,eAAe,CAAC,EAAE,OAAO,EAAoB;QACjD,MAAM,iBAAiB,GAAG,MAAM,IAAI,CAAC,SAAS,CAAC,IAAI,CACjD,uCAAuC,EACvC,OAAO,CACR,CAAC;QAEF,IAAI,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE;YACpB,KAAK,CAAC,kBAAkB,CAAC,OAAO,CAAC,GAAG;gBAClC,GAAG,iBAAiB;gBACpB,WAAW,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;aACtC,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC;CAyBF;AA5FD,8DA4FC;mPAhBG,uBAAwC;IAExC,MAAM,EACJ,aAAa,EAAE,EAAE,OAAO,EAAE,GAC3B,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,CACrB,wCAAwC,EACxC,uBAAuB,CACxB,CAAC;IAEF,IAAI,OAAO,KAAK,uBAAA,IAAI,kDAAiB,EAAE,CAAC;QACtC,uBAAA,IAAI,8CAAoB,OAAO,MAAA,CAAC;QAChC,IAAI,CAAC,eAAe,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;YAChD,IAAI,CAAC,SAAS,CAAC,gBAAgB,EAAE,CAAC,KAAK,CAAC,CAAC;QAC3C,CAAC,CAAC,CAAC;IACL,CAAC;AACH,CAAC","sourcesContent":["import type {\n ControllerGetStateAction,\n ControllerStateChangeEvent,\n StateMetadata,\n} from '@metamask/base-controller';\nimport { BaseController } from '@metamask/base-controller';\nimport type { Messenger } from '@metamask/messenger';\nimport type {\n NetworkClientId,\n NetworkControllerGetNetworkClientByIdAction,\n NetworkControllerStateChangeEvent,\n} from '@metamask/network-controller';\nimport type { Hex } from '@metamask/utils';\n\nimport type { SampleGasPricesControllerMethodActions } from './sample-gas-prices-controller-method-action-types.js';\nimport type { SampleGasPricesServiceFetchGasPricesAction } from './sample-gas-prices-service/sample-gas-prices-service-method-action-types.js';\n\n// === GENERAL ===\n\n/**\n * The name of the {@link SampleGasPricesController}, used to namespace the\n * controller's actions and events and to namespace the controller's state data\n * when composed with other controllers.\n */\nconst CONTROLLER_NAME = 'SampleGasPricesController';\n\n// === STATE ===\n\n/**\n * The collection of gas price data fetched periodically.\n */\ntype GasPrices = {\n /**\n * The total estimated gas in the \"low\" bucket.\n */\n low: number;\n /**\n * The total estimated gas in the \"average\" bucket.\n */\n average: number;\n /**\n * The total estimated gas in the \"high\" bucket.\n */\n high: number;\n /**\n * The date/time (in ISO-8601 format) when prices were fetched.\n */\n fetchedDate: string;\n};\n\n/**\n * Describes the shape of the state object for {@link SampleGasPricesController}.\n */\nexport type SampleGasPricesControllerState = {\n /**\n * Fetched gas prices categorized by chain ID.\n */\n gasPricesByChainId: {\n [chainId: Hex]: GasPrices;\n };\n};\n\n/**\n * The metadata for each property in {@link SampleGasPricesControllerState}.\n */\nconst gasPricesControllerMetadata = {\n gasPricesByChainId: {\n includeInDebugSnapshot: false,\n includeInStateLogs: true,\n persist: true,\n usedInUi: true,\n },\n} satisfies StateMetadata<SampleGasPricesControllerState>;\n\n/**\n * Constructs the default {@link SampleGasPricesController} state. This allows\n * consumers to provide a partial state object when initializing the controller\n * and also helps in constructing complete state objects for this controller in\n * tests.\n *\n * @returns The default {@link SampleGasPricesController} state.\n */\nexport function getDefaultSampleGasPricesControllerState(): SampleGasPricesControllerState {\n return {\n gasPricesByChainId: {},\n };\n}\n\n// === MESSENGER ===\n\nconst MESSENGER_EXPOSED_METHODS = ['updateGasPrices'] as const;\n\n/**\n * Retrieves the state of the {@link SampleGasPricesController}.\n */\nexport type SampleGasPricesControllerGetStateAction = ControllerGetStateAction<\n typeof CONTROLLER_NAME,\n SampleGasPricesControllerState\n>;\n\n/**\n * Actions that {@link SampleGasPricesMessenger} exposes to other consumers.\n */\nexport type SampleGasPricesControllerActions =\n | SampleGasPricesControllerGetStateAction\n | SampleGasPricesControllerMethodActions;\n\n/**\n * Actions from other messengers that {@link SampleGasPricesMessenger} calls.\n */\ntype AllowedActions =\n | NetworkControllerGetNetworkClientByIdAction\n | SampleGasPricesServiceFetchGasPricesAction;\n\n/**\n * Published when the state of {@link SampleGasPricesController} changes.\n */\nexport type SampleGasPricesControllerStateChangeEvent =\n ControllerStateChangeEvent<\n typeof CONTROLLER_NAME,\n SampleGasPricesControllerState\n >;\n\n/**\n * Events that {@link SampleGasPricesMessenger} exposes to other consumers.\n */\nexport type SampleGasPricesControllerEvents =\n SampleGasPricesControllerStateChangeEvent;\n\n/**\n * Events from other messengers that {@link SampleGasPricesMessenger} subscribes\n * to.\n */\ntype AllowedEvents = NetworkControllerStateChangeEvent;\n\n/**\n * The messenger restricted to actions and events accessed by\n * {@link SampleGasPricesController}.\n */\nexport type SampleGasPricesControllerMessenger = Messenger<\n typeof CONTROLLER_NAME,\n SampleGasPricesControllerActions | AllowedActions,\n SampleGasPricesControllerEvents | AllowedEvents\n>;\n\n// === CONTROLLER DEFINITION ===\n\n/**\n * `SampleGasPricesController` fetches and persists gas prices for various chains.\n *\n * @example\n *\n * ``` ts\n * import { Messenger } from '@metamask/messenger';\n * import type {\n * NetworkControllerActions,\n * NetworkControllerEvents,\n * } from '@metamask/network-controller';\n * import type {\n * SampleGasPricesControllerActions,\n * SampleGasPricesControllerEvents,\n * SampleGasPricesServiceActions,\n * SampleGasPricesServiceEvents,\n * } from '@metamask/sample-controllers';\n * import {\n * SampleGasPricesController,\n * SampleGasPricesService,\n * selectGasPrices,\n * } from '@metamask/sample-controllers';\n *\n * const rootMessenger = new Messenger<\n * 'Root',\n * SampleGasPricesServiceActions\n * | SampleGasPricesControllerActions\n * | NetworkControllerActions,\n * SampleGasPricesServiceEvents\n * | SampleGasPricesControllerEvents\n * | NetworkControllerEvents\n * >({ namespace: 'Root' });\n * const gasPricesServiceMessenger = new Messenger<\n * 'SampleGasPricesService',\n * SampleGasPricesServiceActions,\n * SampleGasPricesServiceEvents,\n * typeof rootMessenger,\n * >({\n * namespace: 'SampleGasPricesService',\n * parent: rootMessenger,\n * });\n * // Instantiate the service to register its actions on the messenger\n * new SampleGasPricesService({\n * messenger: gasPricesServiceMessenger,\n * // We assume you're using this in the browser.\n * fetch,\n * });\n * const gasPricesControllerMessenger = new Messenger<\n * 'SampleGasPricesController',\n * SampleGasPricesControllerActions | NetworkControllerGetNetworkClientByIdAction,\n * SampleGasPricesControllerEvents | NetworkControllerStateChangeEvent,\n * typeof rootMessenger,\n * >({\n * namespace: 'SampleGasPricesController',\n * parent: rootMessenger,\n * });\n * // Instantiate the controller to register its actions on the messenger\n * new SampleGasPricesController({\n * messenger: gasPricesControllerMessenger,\n * });\n *\n * // Later...\n * await rootMessenger.call(\n * 'SampleGasPricesController:updateGasPrices',\n * { chainId: '0x42' },\n * );\n * const gasPricesControllerState = await rootMessenger.call(\n * 'SampleGasPricesController:getState',\n * );\n * gasPricesControllerState.gasPricesByChainId\n * // => { '0x42': { low: 5, average: 10, high: 15, fetchedDate: '2024-01-02T00:00:00.000Z' } }\n * ```\n */\nexport class SampleGasPricesController extends BaseController<\n typeof CONTROLLER_NAME,\n SampleGasPricesControllerState,\n SampleGasPricesControllerMessenger\n> {\n /**\n * The globally selected chain ID.\n */\n #selectedChainId: Hex | undefined;\n\n /**\n * Constructs a new {@link SampleGasPricesController}.\n *\n * @param args - The constructor arguments.\n * @param args.messenger - The messenger suited for this controller.\n * @param args.state - The desired state with which to initialize this\n * controller. Missing properties will be filled in with defaults.\n */\n constructor({\n messenger,\n state,\n }: {\n messenger: SampleGasPricesControllerMessenger;\n state?: Partial<SampleGasPricesControllerState>;\n }) {\n super({\n messenger,\n metadata: gasPricesControllerMetadata,\n name: CONTROLLER_NAME,\n state: {\n ...getDefaultSampleGasPricesControllerState(),\n ...state,\n },\n });\n\n this.messenger.registerMethodActionHandlers(\n this,\n MESSENGER_EXPOSED_METHODS,\n );\n\n this.messenger.subscribe(\n 'NetworkController:stateChange',\n this.#onSelectedNetworkClientIdChange.bind(this),\n (networkControllerState) =>\n networkControllerState.selectedNetworkClientId,\n );\n }\n\n /**\n * Fetches the latest gas prices for the given chain and persists them to\n * state.\n *\n * @param args - The arguments to the function.\n * @param args.chainId - The chain ID for which to fetch gas prices.\n */\n async updateGasPrices({ chainId }: { chainId: Hex }): Promise<void> {\n const gasPricesResponse = await this.messenger.call(\n 'SampleGasPricesService:fetchGasPrices',\n chainId,\n );\n\n this.update((state) => {\n state.gasPricesByChainId[chainId] = {\n ...gasPricesResponse,\n fetchedDate: new Date().toISOString(),\n };\n });\n }\n\n /**\n * Callback to call when the globally selected network client ID changes,\n * ensuring that gas prices get updated.\n *\n * @param selectedNetworkClientId - The globally selected network client ID.\n */\n #onSelectedNetworkClientIdChange(\n selectedNetworkClientId: NetworkClientId,\n ): void {\n const {\n configuration: { chainId },\n } = this.messenger.call(\n 'NetworkController:getNetworkClientById',\n selectedNetworkClientId,\n );\n\n if (chainId !== this.#selectedChainId) {\n this.#selectedChainId = chainId;\n this.updateGasPrices({ chainId }).catch((error) => {\n this.messenger.captureException?.(error);\n });\n }\n }\n}\n"]}
1
+ {"version":3,"file":"sample-gas-prices-controller.cjs","sourceRoot":"","sources":["../src/sample-gas-prices-controller.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAKA,+DAA2D;AAY3D,kBAAkB;AAElB;;;;GAIG;AACH,MAAM,eAAe,GAAG,2BAA2B,CAAC;AAsCpD;;GAEG;AACH,MAAM,2BAA2B,GAAG;IAClC,kBAAkB,EAAE;QAClB,sBAAsB,EAAE,KAAK;QAC7B,kBAAkB,EAAE,IAAI;QACxB,OAAO,EAAE,IAAI;QACb,QAAQ,EAAE,IAAI;KACf;CACsD,CAAC;AAE1D;;;;;;;GAOG;AACH,SAAgB,wCAAwC;IACtD,OAAO;QACL,kBAAkB,EAAE,EAAE;KACvB,CAAC;AACJ,CAAC;AAJD,4FAIC;AAED,oBAAoB;AAEpB,MAAM,y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CAAC,IAAI,CACrB,wCAAwC,EACxC,uBAAuB,CACxB,CAAC;IAEF,IAAI,OAAO,KAAK,uBAAA,IAAI,kDAAiB,EAAE,CAAC;QACtC,uBAAA,IAAI,8CAAoB,OAAO,MAAA,CAAC;QAChC,IAAI,CAAC,eAAe,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;YAChD,IAAI,CAAC,SAAS,CAAC,gBAAgB,EAAE,CAAC,KAAK,CAAC,CAAC;QAC3C,CAAC,CAAC,CAAC;IACL,CAAC;AACH,CAAC","sourcesContent":["import type {\n ControllerGetStateAction,\n ControllerStateChangeEvent,\n StateMetadata,\n} from '@metamask/base-controller';\nimport { BaseController } from '@metamask/base-controller';\nimport type { Messenger } from '@metamask/messenger';\nimport type {\n NetworkClientId,\n NetworkControllerGetNetworkClientByIdAction,\n NetworkControllerStateChangeEvent,\n} from '@metamask/network-controller';\nimport type { Hex } from '@metamask/utils';\n\nimport type { SampleGasPricesControllerMethodActions } from './sample-gas-prices-controller-method-action-types';\nimport type { SampleGasPricesServiceFetchGasPricesAction } from './sample-gas-prices-service/sample-gas-prices-service-method-action-types';\n\n// === GENERAL ===\n\n/**\n * The name of the {@link SampleGasPricesController}, used to namespace the\n * controller's actions and events and to namespace the controller's state data\n * when composed with other controllers.\n */\nconst CONTROLLER_NAME = 'SampleGasPricesController';\n\n// === STATE ===\n\n/**\n * The collection of gas price data fetched periodically.\n */\ntype GasPrices = {\n /**\n * The total estimated gas in the \"low\" bucket.\n */\n low: number;\n /**\n * The total estimated gas in the \"average\" bucket.\n */\n average: number;\n /**\n * The total estimated gas in the \"high\" bucket.\n */\n high: number;\n /**\n * The date/time (in ISO-8601 format) when prices were fetched.\n */\n fetchedDate: string;\n};\n\n/**\n * Describes the shape of the state object for {@link SampleGasPricesController}.\n */\nexport type SampleGasPricesControllerState = {\n /**\n * Fetched gas prices categorized by chain ID.\n */\n gasPricesByChainId: {\n [chainId: Hex]: GasPrices;\n };\n};\n\n/**\n * The metadata for each property in {@link SampleGasPricesControllerState}.\n */\nconst gasPricesControllerMetadata = {\n gasPricesByChainId: {\n includeInDebugSnapshot: false,\n includeInStateLogs: true,\n persist: true,\n usedInUi: true,\n },\n} satisfies StateMetadata<SampleGasPricesControllerState>;\n\n/**\n * Constructs the default {@link SampleGasPricesController} state. This allows\n * consumers to provide a partial state object when initializing the controller\n * and also helps in constructing complete state objects for this controller in\n * tests.\n *\n * @returns The default {@link SampleGasPricesController} state.\n */\nexport function getDefaultSampleGasPricesControllerState(): SampleGasPricesControllerState {\n return {\n gasPricesByChainId: {},\n };\n}\n\n// === MESSENGER ===\n\nconst MESSENGER_EXPOSED_METHODS = ['updateGasPrices'] as const;\n\n/**\n * Retrieves the state of the {@link SampleGasPricesController}.\n */\nexport type SampleGasPricesControllerGetStateAction = ControllerGetStateAction<\n typeof CONTROLLER_NAME,\n SampleGasPricesControllerState\n>;\n\n/**\n * Actions that {@link SampleGasPricesMessenger} exposes to other consumers.\n */\nexport type SampleGasPricesControllerActions =\n | SampleGasPricesControllerGetStateAction\n | SampleGasPricesControllerMethodActions;\n\n/**\n * Actions from other messengers that {@link SampleGasPricesMessenger} calls.\n */\ntype AllowedActions =\n | NetworkControllerGetNetworkClientByIdAction\n | SampleGasPricesServiceFetchGasPricesAction;\n\n/**\n * Published when the state of {@link SampleGasPricesController} changes.\n */\nexport type SampleGasPricesControllerStateChangeEvent =\n ControllerStateChangeEvent<\n typeof CONTROLLER_NAME,\n SampleGasPricesControllerState\n >;\n\n/**\n * Events that {@link SampleGasPricesMessenger} exposes to other consumers.\n */\nexport type SampleGasPricesControllerEvents =\n SampleGasPricesControllerStateChangeEvent;\n\n/**\n * Events from other messengers that {@link SampleGasPricesMessenger} subscribes\n * to.\n */\ntype AllowedEvents = NetworkControllerStateChangeEvent;\n\n/**\n * The messenger restricted to actions and events accessed by\n * {@link SampleGasPricesController}.\n */\nexport type SampleGasPricesControllerMessenger = Messenger<\n typeof CONTROLLER_NAME,\n SampleGasPricesControllerActions | AllowedActions,\n SampleGasPricesControllerEvents | AllowedEvents\n>;\n\n// === CONTROLLER DEFINITION ===\n\n/**\n * `SampleGasPricesController` fetches and persists gas prices for various chains.\n *\n * @example\n *\n * ``` ts\n * import { Messenger } from '@metamask/messenger';\n * import type {\n * NetworkControllerActions,\n * NetworkControllerEvents,\n * } from '@metamask/network-controller';\n * import type {\n * SampleGasPricesControllerActions,\n * SampleGasPricesControllerEvents,\n * SampleGasPricesServiceActions,\n * SampleGasPricesServiceEvents,\n * } from '@metamask/sample-controllers';\n * import {\n * SampleGasPricesController,\n * SampleGasPricesService,\n * selectGasPrices,\n * } from '@metamask/sample-controllers';\n *\n * const rootMessenger = new Messenger<\n * 'Root',\n * SampleGasPricesServiceActions\n * | SampleGasPricesControllerActions\n * | NetworkControllerActions,\n * SampleGasPricesServiceEvents\n * | SampleGasPricesControllerEvents\n * | NetworkControllerEvents\n * >({ namespace: 'Root' });\n * const gasPricesServiceMessenger = new Messenger<\n * 'SampleGasPricesService',\n * SampleGasPricesServiceActions,\n * SampleGasPricesServiceEvents,\n * typeof rootMessenger,\n * >({\n * namespace: 'SampleGasPricesService',\n * parent: rootMessenger,\n * });\n * // Instantiate the service to register its actions on the messenger\n * new SampleGasPricesService({\n * messenger: gasPricesServiceMessenger,\n * // We assume you're using this in the browser.\n * fetch,\n * });\n * const gasPricesControllerMessenger = new Messenger<\n * 'SampleGasPricesController',\n * SampleGasPricesControllerActions | NetworkControllerGetNetworkClientByIdAction,\n * SampleGasPricesControllerEvents | NetworkControllerStateChangeEvent,\n * typeof rootMessenger,\n * >({\n * namespace: 'SampleGasPricesController',\n * parent: rootMessenger,\n * });\n * // Instantiate the controller to register its actions on the messenger\n * new SampleGasPricesController({\n * messenger: gasPricesControllerMessenger,\n * });\n *\n * // Later...\n * await rootMessenger.call(\n * 'SampleGasPricesController:updateGasPrices',\n * { chainId: '0x42' },\n * );\n * const gasPricesControllerState = await rootMessenger.call(\n * 'SampleGasPricesController:getState',\n * );\n * gasPricesControllerState.gasPricesByChainId\n * // => { '0x42': { low: 5, average: 10, high: 15, fetchedDate: '2024-01-02T00:00:00.000Z' } }\n * ```\n */\nexport class SampleGasPricesController extends BaseController<\n typeof CONTROLLER_NAME,\n SampleGasPricesControllerState,\n SampleGasPricesControllerMessenger\n> {\n /**\n * The globally selected chain ID.\n */\n #selectedChainId: Hex | undefined;\n\n /**\n * Constructs a new {@link SampleGasPricesController}.\n *\n * @param args - The constructor arguments.\n * @param args.messenger - The messenger suited for this controller.\n * @param args.state - The desired state with which to initialize this\n * controller. Missing properties will be filled in with defaults.\n */\n constructor({\n messenger,\n state,\n }: {\n messenger: SampleGasPricesControllerMessenger;\n state?: Partial<SampleGasPricesControllerState>;\n }) {\n super({\n messenger,\n metadata: gasPricesControllerMetadata,\n name: CONTROLLER_NAME,\n state: {\n ...getDefaultSampleGasPricesControllerState(),\n ...state,\n },\n });\n\n this.messenger.registerMethodActionHandlers(\n this,\n MESSENGER_EXPOSED_METHODS,\n );\n\n this.messenger.subscribe(\n 'NetworkController:stateChange',\n this.#onSelectedNetworkClientIdChange.bind(this),\n (networkControllerState) =>\n networkControllerState.selectedNetworkClientId,\n );\n }\n\n /**\n * Fetches the latest gas prices for the given chain and persists them to\n * state.\n *\n * @param args - The arguments to the function.\n * @param args.chainId - The chain ID for which to fetch gas prices.\n */\n async updateGasPrices({ chainId }: { chainId: Hex }): Promise<void> {\n const gasPricesResponse = await this.messenger.call(\n 'SampleGasPricesService:fetchGasPrices',\n chainId,\n );\n\n this.update((state) => {\n state.gasPricesByChainId[chainId] = {\n ...gasPricesResponse,\n fetchedDate: new Date().toISOString(),\n };\n });\n }\n\n /**\n * Callback to call when the globally selected network client ID changes,\n * ensuring that gas prices get updated.\n *\n * @param selectedNetworkClientId - The globally selected network client ID.\n */\n #onSelectedNetworkClientIdChange(\n selectedNetworkClientId: NetworkClientId,\n ): void {\n const {\n configuration: { chainId },\n } = this.messenger.call(\n 'NetworkController:getNetworkClientById',\n selectedNetworkClientId,\n );\n\n if (chainId !== this.#selectedChainId) {\n this.#selectedChainId = chainId;\n this.updateGasPrices({ chainId }).catch((error) => {\n this.messenger.captureException?.(error);\n });\n }\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"sample-gas-prices-controller.d.cts","sourceRoot":"","sources":["../src/sample-gas-prices-controller.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,wBAAwB,EACxB,0BAA0B,EAE3B,kCAAkC;AACnC,OAAO,EAAE,cAAc,EAAE,kCAAkC;AAC3D,OAAO,KAAK,EAAE,SAAS,EAAE,4BAA4B;AACrD,OAAO,KAAK,EAEV,2CAA2C,EAC3C,iCAAiC,EAClC,qCAAqC;AACtC,OAAO,KAAK,EAAE,GAAG,EAAE,wBAAwB;AAE3C,OAAO,KAAK,EAAE,sCAAsC,EAAE,+DAA8D;AACpH,OAAO,KAAK,EAAE,0CAA0C,EAAE,sFAAqF;AAI/I;;;;GAIG;AACH,QAAA,MAAM,eAAe,8BAA8B,CAAC;AAIpD;;GAEG;AACH,KAAK,SAAS,GAAG;IACf;;OAEG;IACH,GAAG,EAAE,MAAM,CAAC;IACZ;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC;IAChB;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IACb;;OAEG;IACH,WAAW,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,8BAA8B,GAAG;IAC3C;;OAEG;IACH,kBAAkB,EAAE;QAClB,CAAC,OAAO,EAAE,GAAG,GAAG,SAAS,CAAC;KAC3B,CAAC;CACH,CAAC;AAcF;;;;;;;GAOG;AACH,wBAAgB,wCAAwC,IAAI,8BAA8B,CAIzF;AAMD;;GAEG;AACH,MAAM,MAAM,uCAAuC,GAAG,wBAAwB,CAC5E,OAAO,eAAe,EACtB,8BAA8B,CAC/B,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,gCAAgC,GACxC,uCAAuC,GACvC,sCAAsC,CAAC;AAE3C;;GAEG;AACH,KAAK,cAAc,GACf,2CAA2C,GAC3C,0CAA0C,CAAC;AAE/C;;GAEG;AACH,MAAM,MAAM,yCAAyC,GACnD,0BAA0B,CACxB,OAAO,eAAe,EACtB,8BAA8B,CAC/B,CAAC;AAEJ;;GAEG;AACH,MAAM,MAAM,+BAA+B,GACzC,yCAAyC,CAAC;AAE5C;;;GAGG;AACH,KAAK,aAAa,GAAG,iCAAiC,CAAC;AAEvD;;;GAGG;AACH,MAAM,MAAM,kCAAkC,GAAG,SAAS,CACxD,OAAO,eAAe,EACtB,gCAAgC,GAAG,cAAc,EACjD,+BAA+B,GAAG,aAAa,CAChD,CAAC;AAIF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwEG;AACH,qBAAa,yBAA0B,SAAQ,cAAc,CAC3D,OAAO,eAAe,EACtB,8BAA8B,EAC9B,kCAAkC,CACnC;;IAMC;;;;;;;OAOG;gBACS,EACV,SAAS,EACT,KAAK,GACN,EAAE;QACD,SAAS,EAAE,kCAAkC,CAAC;QAC9C,KAAK,CAAC,EAAE,OAAO,CAAC,8BAA8B,CAAC,CAAC;KACjD;IAwBD;;;;;;OAMG;IACG,eAAe,CAAC,EAAE,OAAO,EAAE,EAAE;QAAE,OAAO,EAAE,GAAG,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC;CAqCpE"}
1
+ {"version":3,"file":"sample-gas-prices-controller.d.cts","sourceRoot":"","sources":["../src/sample-gas-prices-controller.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,wBAAwB,EACxB,0BAA0B,EAE3B,kCAAkC;AACnC,OAAO,EAAE,cAAc,EAAE,kCAAkC;AAC3D,OAAO,KAAK,EAAE,SAAS,EAAE,4BAA4B;AACrD,OAAO,KAAK,EAEV,2CAA2C,EAC3C,iCAAiC,EAClC,qCAAqC;AACtC,OAAO,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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwEG;AACH,qBAAa,yBAA0B,SAAQ,cAAc,CAC3D,OAAO,eAAe,EACtB,8BAA8B,EAC9B,kCAAkC,CACnC;;IAMC;;;;;;;OAOG;gBACS,EACV,SAAS,EACT,KAAK,GACN,EAAE;QACD,SAAS,EAAE,kCAAkC,CAAC;QAC9C,KAAK,CAAC,EAAE,OAAO,CAAC,8BAA8B,CAAC,CAAC;KACjD;IAwBD;;;;;;OAMG;IACG,eAAe,CAAC,EAAE,OAAO,EAAE,EAAE;QAAE,OAAO,EAAE,GAAG,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC;CAqCpE"}
@@ -1 +1 @@
1
- {"version":3,"file":"sample-gas-prices-controller.d.mts","sourceRoot":"","sources":["../src/sample-gas-prices-controller.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,wBAAwB,EACxB,0BAA0B,EAE3B,kCAAkC;AACnC,OAAO,EAAE,cAAc,EAAE,kCAAkC;AAC3D,OAAO,KAAK,EAAE,SAAS,EAAE,4BAA4B;AACrD,OAAO,KAAK,EAEV,2CAA2C,EAC3C,iCAAiC,EAClC,qCAAqC;AACtC,OAAO,KAAK,EAAE,GAAG,EAAE,wBAAwB;AAE3C,OAAO,KAAK,EAAE,sCAAsC,EAAE,+DAA8D;AACpH,OAAO,KAAK,EAAE,0CAA0C,EAAE,sFAAqF;AAI/I;;;;GAIG;AACH,QAAA,MAAM,eAAe,8BAA8B,CAAC;AAIpD;;GAEG;AACH,KAAK,SAAS,GAAG;IACf;;OAEG;IACH,GAAG,EAAE,MAAM,CAAC;IACZ;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC;IAChB;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IACb;;OAEG;IACH,WAAW,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,8BAA8B,GAAG;IAC3C;;OAEG;IACH,kBA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,CAAC;AAEJ;;GAEG;AACH,MAAM,MAAM,+BAA+B,GACzC,yCAAyC,CAAC;AAE5C;;;GAGG;AACH,KAAK,aAAa,GAAG,iCAAiC,CAAC;AAEvD;;;GAGG;AACH,MAAM,MAAM,kCAAkC,GAAG,SAAS,CACxD,OAAO,eAAe,EACtB,gCAAgC,GAAG,cAAc,EACjD,+BAA+B,GAAG,aAAa,CAChD,CAAC;AAIF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwEG;AACH,qBAAa,yBAA0B,SAAQ,cAAc,CAC3D,OAAO,eAAe,EACtB,8BAA8B,EAC9B,kCAAkC,CACnC;;IAMC;;;;;;;OAOG;gBACS,EACV,SAAS,EACT,KAAK,GACN,EAAE;QACD,SAAS,EAAE,kCAAkC,CAAC;QAC9C,KAAK,CAAC,EAAE,OAAO,CAAC,8BAA8B,CAAC,CAAC;KACjD;IAwBD;;;;;;OAMG;IACG,eAAe,CAAC,EAAE,OAAO,EAAE,EAAE;QAAE,OAAO,EAAE,GAAG,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC;CAqCpE"}
@@ -1 +1 @@
1
- {"version":3,"file":"sample-gas-prices-controller.mjs","sourceRoot":"","sources":["../src/sample-gas-prices-controller.ts"],"names":[],"mappings":";;;;;;;;;;;;AAKA,OAAO,EAAE,cAAc,EAAE,kCAAkC;AAY3D,kBAAkB;AAElB;;;;GAIG;AACH,MAAM,eAAe,GAAG,2BAA2B,CAAC;AAsCpD;;GAEG;AACH,MAAM,2BAA2B,GAAG;IAClC,kBAAkB,EAAE;QAClB,sBAAsB,EAAE,KAAK;QAC7B,kBAAkB,EAAE,IAAI;QACxB,OAAO,EAAE,IAAI;QACb,QAAQ,EAAE,IAAI;KACf;CACsD,CAAC;AAE1D;;;;;;;GAOG;AACH,MAAM,UAAU,wCAAwC;IACtD,OAAO;QACL,kBAAkB,EAAE,EAAE;KACvB,CAAC;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C3B,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,CACrB,wCAAwC,EACxC,uBAAuB,CACxB,CAAC;IAEF,IAAI,OAAO,KAAK,uBAAA,IAAI,kDAAiB,EAAE,CAAC;QACtC,uBAAA,IAAI,8CAAoB,OAAO,MAAA,CAAC;QAChC,IAAI,CAAC,eAAe,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;YAChD,IAAI,CAAC,SAAS,CAAC,gBAAgB,EAAE,CAAC,KAAK,CAAC,CAAC;QAC3C,CAAC,CAAC,CAAC;IACL,CAAC;AACH,CAAC","sourcesContent":["import type {\n ControllerGetStateAction,\n ControllerStateChangeEvent,\n StateMetadata,\n} from '@metamask/base-controller';\nimport { BaseController } from '@metamask/base-controller';\nimport type { Messenger } from '@metamask/messenger';\nimport type {\n NetworkClientId,\n NetworkControllerGetNetworkClientByIdAction,\n NetworkControllerStateChangeEvent,\n} from '@metamask/network-controller';\nimport type { Hex } from '@metamask/utils';\n\nimport type { SampleGasPricesControllerMethodActions } from './sample-gas-prices-controller-method-action-types.js';\nimport type { SampleGasPricesServiceFetchGasPricesAction } from './sample-gas-prices-service/sample-gas-prices-service-method-action-types.js';\n\n// === GENERAL ===\n\n/**\n * The name of the {@link SampleGasPricesController}, used to namespace the\n * controller's actions and events and to namespace the controller's state data\n * when composed with other controllers.\n */\nconst CONTROLLER_NAME = 'SampleGasPricesController';\n\n// === STATE ===\n\n/**\n * The collection of gas price data fetched periodically.\n */\ntype GasPrices = {\n /**\n * The total estimated gas in the \"low\" bucket.\n */\n low: number;\n /**\n * The total estimated gas in the \"average\" bucket.\n */\n average: number;\n /**\n * The total estimated gas in the \"high\" bucket.\n */\n high: number;\n /**\n * The date/time (in ISO-8601 format) when prices were fetched.\n */\n fetchedDate: string;\n};\n\n/**\n * Describes the shape of the state object for {@link SampleGasPricesController}.\n */\nexport type SampleGasPricesControllerState = {\n /**\n * Fetched gas prices categorized by chain ID.\n */\n gasPricesByChainId: {\n [chainId: Hex]: GasPrices;\n };\n};\n\n/**\n * The metadata for each property in {@link SampleGasPricesControllerState}.\n */\nconst gasPricesControllerMetadata = {\n gasPricesByChainId: {\n includeInDebugSnapshot: false,\n includeInStateLogs: true,\n persist: true,\n usedInUi: true,\n },\n} satisfies StateMetadata<SampleGasPricesControllerState>;\n\n/**\n * Constructs the default {@link SampleGasPricesController} state. This allows\n * consumers to provide a partial state object when initializing the controller\n * and also helps in constructing complete state objects for this controller in\n * tests.\n *\n * @returns The default {@link SampleGasPricesController} state.\n */\nexport function getDefaultSampleGasPricesControllerState(): SampleGasPricesControllerState {\n return {\n gasPricesByChainId: {},\n };\n}\n\n// === MESSENGER ===\n\nconst MESSENGER_EXPOSED_METHODS = ['updateGasPrices'] as const;\n\n/**\n * Retrieves the state of the {@link SampleGasPricesController}.\n */\nexport type SampleGasPricesControllerGetStateAction = ControllerGetStateAction<\n typeof CONTROLLER_NAME,\n SampleGasPricesControllerState\n>;\n\n/**\n * Actions that {@link SampleGasPricesMessenger} exposes to other consumers.\n */\nexport type SampleGasPricesControllerActions =\n | SampleGasPricesControllerGetStateAction\n | SampleGasPricesControllerMethodActions;\n\n/**\n * Actions from other messengers that {@link SampleGasPricesMessenger} calls.\n */\ntype AllowedActions =\n | NetworkControllerGetNetworkClientByIdAction\n | SampleGasPricesServiceFetchGasPricesAction;\n\n/**\n * Published when the state of {@link SampleGasPricesController} changes.\n */\nexport type SampleGasPricesControllerStateChangeEvent =\n ControllerStateChangeEvent<\n typeof CONTROLLER_NAME,\n SampleGasPricesControllerState\n >;\n\n/**\n * Events that {@link SampleGasPricesMessenger} exposes to other consumers.\n */\nexport type SampleGasPricesControllerEvents =\n SampleGasPricesControllerStateChangeEvent;\n\n/**\n * Events from other messengers that {@link SampleGasPricesMessenger} subscribes\n * to.\n */\ntype AllowedEvents = NetworkControllerStateChangeEvent;\n\n/**\n * The messenger restricted to actions and events accessed by\n * {@link SampleGasPricesController}.\n */\nexport type SampleGasPricesControllerMessenger = Messenger<\n typeof CONTROLLER_NAME,\n SampleGasPricesControllerActions | AllowedActions,\n SampleGasPricesControllerEvents | AllowedEvents\n>;\n\n// === CONTROLLER DEFINITION ===\n\n/**\n * `SampleGasPricesController` fetches and persists gas prices for various chains.\n *\n * @example\n *\n * ``` ts\n * import { Messenger } from '@metamask/messenger';\n * import type {\n * NetworkControllerActions,\n * NetworkControllerEvents,\n * } from '@metamask/network-controller';\n * import type {\n * SampleGasPricesControllerActions,\n * SampleGasPricesControllerEvents,\n * SampleGasPricesServiceActions,\n * SampleGasPricesServiceEvents,\n * } from '@metamask/sample-controllers';\n * import {\n * SampleGasPricesController,\n * SampleGasPricesService,\n * selectGasPrices,\n * } from '@metamask/sample-controllers';\n *\n * const rootMessenger = new Messenger<\n * 'Root',\n * SampleGasPricesServiceActions\n * | SampleGasPricesControllerActions\n * | NetworkControllerActions,\n * SampleGasPricesServiceEvents\n * | SampleGasPricesControllerEvents\n * | NetworkControllerEvents\n * >({ namespace: 'Root' });\n * const gasPricesServiceMessenger = new Messenger<\n * 'SampleGasPricesService',\n * SampleGasPricesServiceActions,\n * SampleGasPricesServiceEvents,\n * typeof rootMessenger,\n * >({\n * namespace: 'SampleGasPricesService',\n * parent: rootMessenger,\n * });\n * // Instantiate the service to register its actions on the messenger\n * new SampleGasPricesService({\n * messenger: gasPricesServiceMessenger,\n * // We assume you're using this in the browser.\n * fetch,\n * });\n * const gasPricesControllerMessenger = new Messenger<\n * 'SampleGasPricesController',\n * SampleGasPricesControllerActions | NetworkControllerGetNetworkClientByIdAction,\n * SampleGasPricesControllerEvents | NetworkControllerStateChangeEvent,\n * typeof rootMessenger,\n * >({\n * namespace: 'SampleGasPricesController',\n * parent: rootMessenger,\n * });\n * // Instantiate the controller to register its actions on the messenger\n * new SampleGasPricesController({\n * messenger: gasPricesControllerMessenger,\n * });\n *\n * // Later...\n * await rootMessenger.call(\n * 'SampleGasPricesController:updateGasPrices',\n * { chainId: '0x42' },\n * );\n * const gasPricesControllerState = await rootMessenger.call(\n * 'SampleGasPricesController:getState',\n * );\n * gasPricesControllerState.gasPricesByChainId\n * // => { '0x42': { low: 5, average: 10, high: 15, fetchedDate: '2024-01-02T00:00:00.000Z' } }\n * ```\n */\nexport class SampleGasPricesController extends BaseController<\n typeof CONTROLLER_NAME,\n SampleGasPricesControllerState,\n SampleGasPricesControllerMessenger\n> {\n /**\n * The globally selected chain ID.\n */\n #selectedChainId: Hex | undefined;\n\n /**\n * Constructs a new {@link SampleGasPricesController}.\n *\n * @param args - The constructor arguments.\n * @param args.messenger - The messenger suited for this controller.\n * @param args.state - The desired state with which to initialize this\n * controller. Missing properties will be filled in with defaults.\n */\n constructor({\n messenger,\n state,\n }: {\n messenger: SampleGasPricesControllerMessenger;\n state?: Partial<SampleGasPricesControllerState>;\n }) {\n super({\n messenger,\n metadata: gasPricesControllerMetadata,\n name: CONTROLLER_NAME,\n state: {\n ...getDefaultSampleGasPricesControllerState(),\n ...state,\n },\n });\n\n this.messenger.registerMethodActionHandlers(\n this,\n MESSENGER_EXPOSED_METHODS,\n );\n\n this.messenger.subscribe(\n 'NetworkController:stateChange',\n this.#onSelectedNetworkClientIdChange.bind(this),\n (networkControllerState) =>\n networkControllerState.selectedNetworkClientId,\n );\n }\n\n /**\n * Fetches the latest gas prices for the given chain and persists them to\n * state.\n *\n * @param args - The arguments to the function.\n * @param args.chainId - The chain ID for which to fetch gas prices.\n */\n async updateGasPrices({ chainId }: { chainId: Hex }): Promise<void> {\n const gasPricesResponse = await this.messenger.call(\n 'SampleGasPricesService:fetchGasPrices',\n chainId,\n );\n\n this.update((state) => {\n state.gasPricesByChainId[chainId] = {\n ...gasPricesResponse,\n fetchedDate: new Date().toISOString(),\n };\n });\n }\n\n /**\n * Callback to call when the globally selected network client ID changes,\n * ensuring that gas prices get updated.\n *\n * @param selectedNetworkClientId - The globally selected network client ID.\n */\n #onSelectedNetworkClientIdChange(\n selectedNetworkClientId: NetworkClientId,\n ): void {\n const {\n configuration: { chainId },\n } = this.messenger.call(\n 'NetworkController:getNetworkClientById',\n selectedNetworkClientId,\n );\n\n if (chainId !== this.#selectedChainId) {\n this.#selectedChainId = chainId;\n this.updateGasPrices({ chainId }).catch((error) => {\n this.messenger.captureException?.(error);\n });\n }\n }\n}\n"]}
1
+ {"version":3,"file":"sample-gas-prices-controller.mjs","sourceRoot":"","sources":["../src/sample-gas-prices-controller.ts"],"names":[],"mappings":";;;;;;;;;;;;AAKA,OAAO,EAAE,cAAc,EAAE,kCAAkC;AAY3D,kBAAkB;AAElB;;;;GAIG;AACH,MAAM,eAAe,GAAG,2BAA2B,CAAC;AAsCpD;;GAEG;AACH,MAAM,2BAA2B,GAAG;IAClC,kBAAkB,EAAE;QAClB,sBAAsB,EAAE,KAAK;QAC7B,kBAAkB,EAAE,IAAI;QACxB,OAAO,EAAE,IAAI;QACb,QAAQ,EAAE,IAAI;KACf;CACsD,CAAC;AAE1D;;;;;;;GAOG;AACH,MAAM,UAAU,wCAAwC;IACtD,OAAO;QACL,kBAAkB,EAAE,EAAE;KACvB,CAAC;AACJ,CAAC;AAED,oBAAoB;AAEpB,MAAM,yBAAyB,GAAG,CAAC,iBAAiB,CAAU,CAAC;AAuD/D,gCAAgC;AAEhC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwEG;AACH,MAAM,OAAO,yBAA0B,SAAQ,cAI9C;IAMC;;;;;;;OAOG;IACH,YAAY,EACV,SAAS,EACT,KAAK,GAIN;QACC,KAAK,CAAC;YACJ,SAAS;YACT,QAAQ,EAAE,2BAA2B;YACrC,IAAI,EAAE,eAAe;YACrB,KAAK,EAAE;gBACL,GAAG,wCAAwC,EAAE;gBAC7C,GAAG,KAAK;aACT;SACF,CAAC,CAAC;;QA5BL;;WAEG;QACH,6DAAkC;QA2BhC,IAAI,CAAC,SAAS,CAAC,4BAA4B,CACzC,IAAI,EACJ,yBAAyB,CAC1B,CAAC;QAEF,IAAI,CAAC,SAAS,CAAC,SAAS,CACtB,+BAA+B,EAC/B,uBAAA,IAAI,wGAAiC,CAAC,IAAI,CAAC,IAAI,CAAC,EAChD,CAAC,sBAAsB,EAAE,EAAE,CACzB,sBAAsB,CAAC,uBAAuB,CACjD,CAAC;IACJ,CAAC;IAED;;;;;;OAMG;IACH,KAAK,CAAC,eAAe,CAAC,EAAE,OAAO,EAAoB;QACjD,MAAM,iBAAiB,GAAG,MAAM,IAAI,CAAC,SAAS,CAAC,IAAI,CACjD,uCAAuC,EACvC,OAAO,CACR,CAAC;QAEF,IAAI,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE;YACpB,KAAK,CAAC,kBAAkB,CAAC,OAAO,CAAC,GAAG;gBAClC,GAAG,iBAAiB;gBACpB,WAAW,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;aACtC,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC;CAyBF;mPAhBG,uBAAwC;IAExC,MAAM,EACJ,aAAa,EAAE,EAAE,OAAO,EAAE,GAC3B,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,CACrB,wCAAwC,EACxC,uBAAuB,CACxB,CAAC;IAEF,IAAI,OAAO,KAAK,uBAAA,IAAI,kDAAiB,EAAE,CAAC;QACtC,uBAAA,IAAI,8CAAoB,OAAO,MAAA,CAAC;QAChC,IAAI,CAAC,eAAe,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;YAChD,IAAI,CAAC,SAAS,CAAC,gBAAgB,EAAE,CAAC,KAAK,CAAC,CAAC;QAC3C,CAAC,CAAC,CAAC;IACL,CAAC;AACH,CAAC","sourcesContent":["import type {\n ControllerGetStateAction,\n ControllerStateChangeEvent,\n StateMetadata,\n} from '@metamask/base-controller';\nimport { BaseController } from '@metamask/base-controller';\nimport type { Messenger } from '@metamask/messenger';\nimport type {\n NetworkClientId,\n NetworkControllerGetNetworkClientByIdAction,\n NetworkControllerStateChangeEvent,\n} from '@metamask/network-controller';\nimport type { Hex } from '@metamask/utils';\n\nimport type { SampleGasPricesControllerMethodActions } from './sample-gas-prices-controller-method-action-types';\nimport type { SampleGasPricesServiceFetchGasPricesAction } from './sample-gas-prices-service/sample-gas-prices-service-method-action-types';\n\n// === GENERAL ===\n\n/**\n * The name of the {@link SampleGasPricesController}, used to namespace the\n * controller's actions and events and to namespace the controller's state data\n * when composed with other controllers.\n */\nconst CONTROLLER_NAME = 'SampleGasPricesController';\n\n// === STATE ===\n\n/**\n * The collection of gas price data fetched periodically.\n */\ntype GasPrices = {\n /**\n * The total estimated gas in the \"low\" bucket.\n */\n low: number;\n /**\n * The total estimated gas in the \"average\" bucket.\n */\n average: number;\n /**\n * The total estimated gas in the \"high\" bucket.\n */\n high: number;\n /**\n * The date/time (in ISO-8601 format) when prices were fetched.\n */\n fetchedDate: string;\n};\n\n/**\n * Describes the shape of the state object for {@link SampleGasPricesController}.\n */\nexport type SampleGasPricesControllerState = {\n /**\n * Fetched gas prices categorized by chain ID.\n */\n gasPricesByChainId: {\n [chainId: Hex]: GasPrices;\n };\n};\n\n/**\n * The metadata for each property in {@link SampleGasPricesControllerState}.\n */\nconst gasPricesControllerMetadata = {\n gasPricesByChainId: {\n includeInDebugSnapshot: false,\n includeInStateLogs: true,\n persist: true,\n usedInUi: true,\n },\n} satisfies StateMetadata<SampleGasPricesControllerState>;\n\n/**\n * Constructs the default {@link SampleGasPricesController} state. This allows\n * consumers to provide a partial state object when initializing the controller\n * and also helps in constructing complete state objects for this controller in\n * tests.\n *\n * @returns The default {@link SampleGasPricesController} state.\n */\nexport function getDefaultSampleGasPricesControllerState(): SampleGasPricesControllerState {\n return {\n gasPricesByChainId: {},\n };\n}\n\n// === MESSENGER ===\n\nconst MESSENGER_EXPOSED_METHODS = ['updateGasPrices'] as const;\n\n/**\n * Retrieves the state of the {@link SampleGasPricesController}.\n */\nexport type SampleGasPricesControllerGetStateAction = ControllerGetStateAction<\n typeof CONTROLLER_NAME,\n SampleGasPricesControllerState\n>;\n\n/**\n * Actions that {@link SampleGasPricesMessenger} exposes to other consumers.\n */\nexport type SampleGasPricesControllerActions =\n | SampleGasPricesControllerGetStateAction\n | SampleGasPricesControllerMethodActions;\n\n/**\n * Actions from other messengers that {@link SampleGasPricesMessenger} calls.\n */\ntype AllowedActions =\n | NetworkControllerGetNetworkClientByIdAction\n | SampleGasPricesServiceFetchGasPricesAction;\n\n/**\n * Published when the state of {@link SampleGasPricesController} changes.\n */\nexport type SampleGasPricesControllerStateChangeEvent =\n ControllerStateChangeEvent<\n typeof CONTROLLER_NAME,\n SampleGasPricesControllerState\n >;\n\n/**\n * Events that {@link SampleGasPricesMessenger} exposes to other consumers.\n */\nexport type SampleGasPricesControllerEvents =\n SampleGasPricesControllerStateChangeEvent;\n\n/**\n * Events from other messengers that {@link SampleGasPricesMessenger} subscribes\n * to.\n */\ntype AllowedEvents = NetworkControllerStateChangeEvent;\n\n/**\n * The messenger restricted to actions and events accessed by\n * {@link SampleGasPricesController}.\n */\nexport type SampleGasPricesControllerMessenger = Messenger<\n typeof CONTROLLER_NAME,\n SampleGasPricesControllerActions | AllowedActions,\n SampleGasPricesControllerEvents | AllowedEvents\n>;\n\n// === CONTROLLER DEFINITION ===\n\n/**\n * `SampleGasPricesController` fetches and persists gas prices for various chains.\n *\n * @example\n *\n * ``` ts\n * import { Messenger } from '@metamask/messenger';\n * import type {\n * NetworkControllerActions,\n * NetworkControllerEvents,\n * } from '@metamask/network-controller';\n * import type {\n * SampleGasPricesControllerActions,\n * SampleGasPricesControllerEvents,\n * SampleGasPricesServiceActions,\n * SampleGasPricesServiceEvents,\n * } from '@metamask/sample-controllers';\n * import {\n * SampleGasPricesController,\n * SampleGasPricesService,\n * selectGasPrices,\n * } from '@metamask/sample-controllers';\n *\n * const rootMessenger = new Messenger<\n * 'Root',\n * SampleGasPricesServiceActions\n * | SampleGasPricesControllerActions\n * | NetworkControllerActions,\n * SampleGasPricesServiceEvents\n * | SampleGasPricesControllerEvents\n * | NetworkControllerEvents\n * >({ namespace: 'Root' });\n * const gasPricesServiceMessenger = new Messenger<\n * 'SampleGasPricesService',\n * SampleGasPricesServiceActions,\n * SampleGasPricesServiceEvents,\n * typeof rootMessenger,\n * >({\n * namespace: 'SampleGasPricesService',\n * parent: rootMessenger,\n * });\n * // Instantiate the service to register its actions on the messenger\n * new SampleGasPricesService({\n * messenger: gasPricesServiceMessenger,\n * // We assume you're using this in the browser.\n * fetch,\n * });\n * const gasPricesControllerMessenger = new Messenger<\n * 'SampleGasPricesController',\n * SampleGasPricesControllerActions | NetworkControllerGetNetworkClientByIdAction,\n * SampleGasPricesControllerEvents | NetworkControllerStateChangeEvent,\n * typeof rootMessenger,\n * >({\n * namespace: 'SampleGasPricesController',\n * parent: rootMessenger,\n * });\n * // Instantiate the controller to register its actions on the messenger\n * new SampleGasPricesController({\n * messenger: gasPricesControllerMessenger,\n * });\n *\n * // Later...\n * await rootMessenger.call(\n * 'SampleGasPricesController:updateGasPrices',\n * { chainId: '0x42' },\n * );\n * const gasPricesControllerState = await rootMessenger.call(\n * 'SampleGasPricesController:getState',\n * );\n * gasPricesControllerState.gasPricesByChainId\n * // => { '0x42': { low: 5, average: 10, high: 15, fetchedDate: '2024-01-02T00:00:00.000Z' } }\n * ```\n */\nexport class SampleGasPricesController extends BaseController<\n typeof CONTROLLER_NAME,\n SampleGasPricesControllerState,\n SampleGasPricesControllerMessenger\n> {\n /**\n * The globally selected chain ID.\n */\n #selectedChainId: Hex | undefined;\n\n /**\n * Constructs a new {@link SampleGasPricesController}.\n *\n * @param args - The constructor arguments.\n * @param args.messenger - The messenger suited for this controller.\n * @param args.state - The desired state with which to initialize this\n * controller. Missing properties will be filled in with defaults.\n */\n constructor({\n messenger,\n state,\n }: {\n messenger: SampleGasPricesControllerMessenger;\n state?: Partial<SampleGasPricesControllerState>;\n }) {\n super({\n messenger,\n metadata: gasPricesControllerMetadata,\n name: CONTROLLER_NAME,\n state: {\n ...getDefaultSampleGasPricesControllerState(),\n ...state,\n },\n });\n\n this.messenger.registerMethodActionHandlers(\n this,\n MESSENGER_EXPOSED_METHODS,\n );\n\n this.messenger.subscribe(\n 'NetworkController:stateChange',\n this.#onSelectedNetworkClientIdChange.bind(this),\n (networkControllerState) =>\n networkControllerState.selectedNetworkClientId,\n );\n }\n\n /**\n * Fetches the latest gas prices for the given chain and persists them to\n * state.\n *\n * @param args - The arguments to the function.\n * @param args.chainId - The chain ID for which to fetch gas prices.\n */\n async updateGasPrices({ chainId }: { chainId: Hex }): Promise<void> {\n const gasPricesResponse = await this.messenger.call(\n 'SampleGasPricesService:fetchGasPrices',\n chainId,\n );\n\n this.update((state) => {\n state.gasPricesByChainId[chainId] = {\n ...gasPricesResponse,\n fetchedDate: new Date().toISOString(),\n };\n });\n }\n\n /**\n * Callback to call when the globally selected network client ID changes,\n * ensuring that gas prices get updated.\n *\n * @param selectedNetworkClientId - The globally selected network client ID.\n */\n #onSelectedNetworkClientIdChange(\n selectedNetworkClientId: NetworkClientId,\n ): void {\n const {\n configuration: { chainId },\n } = this.messenger.call(\n 'NetworkController:getNetworkClientById',\n selectedNetworkClientId,\n );\n\n if (chainId !== this.#selectedChainId) {\n this.#selectedChainId = chainId;\n this.updateGasPrices({ chainId }).catch((error) => {\n this.messenger.captureException?.(error);\n });\n }\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"sample-gas-prices-service-method-action-types.cjs","sourceRoot":"","sources":["../../src/sample-gas-prices-service/sample-gas-prices-service-method-action-types.ts"],"names":[],"mappings":";AAAA;;;GAGG","sourcesContent":["/**\n * This file is auto generated.\n * Do not edit manually.\n */\n\nimport type { SampleGasPricesService } from './sample-gas-prices-service.js';\n\n/**\n * Makes a request to the API in order to retrieve gas prices for a particular\n * chain.\n *\n * @param chainId - The chain ID for which you want to fetch gas prices.\n * @returns The gas prices for the given chain.\n */\nexport type SampleGasPricesServiceFetchGasPricesAction = {\n type: `SampleGasPricesService:fetchGasPrices`;\n handler: SampleGasPricesService['fetchGasPrices'];\n};\n\n/**\n * Union of all SampleGasPricesService action types.\n */\nexport type SampleGasPricesServiceMethodActions =\n SampleGasPricesServiceFetchGasPricesAction;\n"]}
1
+ {"version":3,"file":"sample-gas-prices-service-method-action-types.cjs","sourceRoot":"","sources":["../../src/sample-gas-prices-service/sample-gas-prices-service-method-action-types.ts"],"names":[],"mappings":";AAAA;;;GAGG","sourcesContent":["/**\n * This file is auto generated.\n * Do not edit manually.\n */\n\nimport type { SampleGasPricesService } from './sample-gas-prices-service';\n\n/**\n * Makes a request to the API in order to retrieve gas prices for a particular\n * chain.\n *\n * @param chainId - The chain ID for which you want to fetch gas prices.\n * @returns The gas prices for the given chain.\n */\nexport type SampleGasPricesServiceFetchGasPricesAction = {\n type: `SampleGasPricesService:fetchGasPrices`;\n handler: SampleGasPricesService['fetchGasPrices'];\n};\n\n/**\n * Union of all SampleGasPricesService action types.\n */\nexport type SampleGasPricesServiceMethodActions =\n SampleGasPricesServiceFetchGasPricesAction;\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"sample-gas-prices-service-method-action-types.d.cts","sourceRoot":"","sources":["../../src/sample-gas-prices-service/sample-gas-prices-service-method-action-types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,sBAAsB,EAAE,wCAAuC;AAE7E;;;;;;GAMG;AACH,MAAM,MAAM,0CAA0C,GAAG;IACvD,IAAI,EAAE,uCAAuC,CAAC;IAC9C,OAAO,EAAE,sBAAsB,CAAC,gBAAgB,CAAC,CAAC;CACnD,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,mCAAmC,GAC7C,0CAA0C,CAAC"}
1
+ {"version":3,"file":"sample-gas-prices-service-method-action-types.d.cts","sourceRoot":"","sources":["../../src/sample-gas-prices-service/sample-gas-prices-service-method-action-types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,sBAAsB,EAAE,wCAAoC;AAE1E;;;;;;GAMG;AACH,MAAM,MAAM,0CAA0C,GAAG;IACvD,IAAI,EAAE,uCAAuC,CAAC;IAC9C,OAAO,EAAE,sBAAsB,CAAC,gBAAgB,CAAC,CAAC;CACnD,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,mCAAmC,GAC7C,0CAA0C,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"sample-gas-prices-service-method-action-types.d.mts","sourceRoot":"","sources":["../../src/sample-gas-prices-service/sample-gas-prices-service-method-action-types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,sBAAsB,EAAE,wCAAuC;AAE7E;;;;;;GAMG;AACH,MAAM,MAAM,0CAA0C,GAAG;IACvD,IAAI,EAAE,uCAAuC,CAAC;IAC9C,OAAO,EAAE,sBAAsB,CAAC,gBAAgB,CAAC,CAAC;CACnD,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,mCAAmC,GAC7C,0CAA0C,CAAC"}
1
+ {"version":3,"file":"sample-gas-prices-service-method-action-types.d.mts","sourceRoot":"","sources":["../../src/sample-gas-prices-service/sample-gas-prices-service-method-action-types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,sBAAsB,EAAE,wCAAoC;AAE1E;;;;;;GAMG;AACH,MAAM,MAAM,0CAA0C,GAAG;IACvD,IAAI,EAAE,uCAAuC,CAAC;IAC9C,OAAO,EAAE,sBAAsB,CAAC,gBAAgB,CAAC,CAAC;CACnD,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,mCAAmC,GAC7C,0CAA0C,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"sample-gas-prices-service-method-action-types.mjs","sourceRoot":"","sources":["../../src/sample-gas-prices-service/sample-gas-prices-service-method-action-types.ts"],"names":[],"mappings":"AAAA;;;GAGG","sourcesContent":["/**\n * This file is auto generated.\n * Do not edit manually.\n */\n\nimport type { SampleGasPricesService } from './sample-gas-prices-service.js';\n\n/**\n * Makes a request to the API in order to retrieve gas prices for a particular\n * chain.\n *\n * @param chainId - The chain ID for which you want to fetch gas prices.\n * @returns The gas prices for the given chain.\n */\nexport type SampleGasPricesServiceFetchGasPricesAction = {\n type: `SampleGasPricesService:fetchGasPrices`;\n handler: SampleGasPricesService['fetchGasPrices'];\n};\n\n/**\n * Union of all SampleGasPricesService action types.\n */\nexport type SampleGasPricesServiceMethodActions =\n SampleGasPricesServiceFetchGasPricesAction;\n"]}
1
+ {"version":3,"file":"sample-gas-prices-service-method-action-types.mjs","sourceRoot":"","sources":["../../src/sample-gas-prices-service/sample-gas-prices-service-method-action-types.ts"],"names":[],"mappings":"AAAA;;;GAGG","sourcesContent":["/**\n * This file is auto generated.\n * Do not edit manually.\n */\n\nimport type { SampleGasPricesService } from './sample-gas-prices-service';\n\n/**\n * Makes a request to the API in order to retrieve gas prices for a particular\n * chain.\n *\n * @param chainId - The chain ID for which you want to fetch gas prices.\n * @returns The gas prices for the given chain.\n */\nexport type SampleGasPricesServiceFetchGasPricesAction = {\n type: `SampleGasPricesService:fetchGasPrices`;\n handler: SampleGasPricesService['fetchGasPrices'];\n};\n\n/**\n * Union of all SampleGasPricesService action types.\n */\nexport type SampleGasPricesServiceMethodActions =\n SampleGasPricesServiceFetchGasPricesAction;\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"sample-gas-prices-service.cjs","sourceRoot":"","sources":["../../src/sample-gas-prices-service/sample-gas-prices-service.ts"],"names":[],"mappings":";;;AAAA,mEAA8D;AAO9D,iEAAgE;AAGhE,uDAAyD;AAMzD,kBAAkB;AAElB;;;GAGG;AACU,QAAA,WAAW,GAAG,wBAAwB,CAAC;AAEpD,oBAAoB;AAEpB;;;GAGG;AACH,MAAM,yBAAyB,GAAG,CAAC,gBAAgB,CAAU,CAAC;AAwD9D,6BAA6B;AAE7B;;GAEG;AACH,MAAM,uBAAuB,GAAG,IAAA,kBAAI,EAAC;IACnC,IAAI,EAAE,IAAA,kBAAI,EAAC;QACT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Q,CAAC,IAAI,EAAE,CAAC;YACzB,CAAC;SACF,CAAC,CAAC;QAEH,IAAI,CAAC,IAAA,gBAAE,EAAC,YAAY,EAAE,uBAAuB,CAAC,EAAE,CAAC;YAC/C,MAAM,IAAI,KAAK,CAAC,iDAAiD,CAAC,CAAC;QACrE,CAAC;QAED,OAAO,YAAY,CAAC,IAAI,CAAC;IAC3B,CAAC;CACF;AArED,wDAqEC","sourcesContent":["import { BaseDataService } from '@metamask/base-data-service';\nimport type {\n DataServiceCacheUpdatedEvent,\n DataServiceGranularCacheUpdatedEvent,\n DataServiceInvalidateQueriesAction,\n} from '@metamask/base-data-service';\nimport type { CreateServicePolicyOptions } from '@metamask/controller-utils';\nimport { HttpError, fromHex } from '@metamask/controller-utils';\nimport type { Messenger } from '@metamask/messenger';\nimport type { Infer } from '@metamask/superstruct';\nimport { is, number, type } from '@metamask/superstruct';\nimport type { Hex } from '@metamask/utils';\nimport type { QueryClientConfig } from '@tanstack/query-core';\n\nimport type { SampleGasPricesServiceMethodActions } from './sample-gas-prices-service-method-action-types.js';\n\n// === GENERAL ===\n\n/**\n * The name of the {@link SampleGasPricesService}, used to namespace the\n * service's actions and events.\n */\nexport const serviceName = 'SampleGasPricesService';\n\n// === MESSENGER ===\n\n/**\n * All of the methods within {@link SampleGasPricesService} that are exposed via\n * the messenger.\n */\nconst MESSENGER_EXPOSED_METHODS = ['fetchGasPrices'] as const;\n\n/**\n * Invalidates cached queries for {@link SampleGasPricesService}.\n */\nexport type SampleGasPricesServiceInvalidateQueriesAction =\n DataServiceInvalidateQueriesAction<typeof serviceName>;\n\n/**\n * Actions that {@link SampleGasPricesService} exposes to other consumers.\n */\nexport type SampleGasPricesServiceActions =\n | SampleGasPricesServiceMethodActions\n | SampleGasPricesServiceInvalidateQueriesAction;\n\n/**\n * Actions from other messengers that {@link SampleGasPricesService} calls.\n */\ntype AllowedActions = never;\n\n/**\n * Published when {@link SampleGasPricesService}'s cache is updated.\n */\nexport type SampleGasPricesServiceCacheUpdatedEvent =\n DataServiceCacheUpdatedEvent<typeof serviceName>;\n\n/**\n * Published when a key within {@link SampleGasPricesService}'s cache is\n * updated.\n */\nexport type SampleGasPricesServiceGranularCacheUpdatedEvent =\n DataServiceGranularCacheUpdatedEvent<typeof serviceName>;\n\n/**\n * Events that {@link SampleGasPricesService} exposes to other consumers.\n */\nexport type SampleGasPricesServiceEvents =\n | SampleGasPricesServiceCacheUpdatedEvent\n | SampleGasPricesServiceGranularCacheUpdatedEvent;\n\n/**\n * Events from other messengers that {@link SampleGasPricesService} subscribes\n * to.\n */\ntype AllowedEvents = never;\n\n/**\n * The messenger which is restricted to actions and events accessed by\n * {@link SampleGasPricesService}.\n */\nexport type SampleGasPricesServiceMessenger = Messenger<\n typeof serviceName,\n SampleGasPricesServiceActions | AllowedActions,\n SampleGasPricesServiceEvents | AllowedEvents\n>;\n\n// === SERVICE DEFINITION ===\n\n/**\n * Struct to validate what the API endpoint returns.\n */\nconst GasPricesResponseStruct = type({\n data: type({\n low: number(),\n average: number(),\n high: number(),\n }),\n});\n\n/**\n * What the API endpoint returns.\n */\ntype GasPricesResponse = Infer<typeof GasPricesResponseStruct>;\n\n/**\n * The base URL of the API that the service represents.\n */\nconst BASE_URL = 'https://api.example.com';\n\n/**\n * This service object is responsible for fetching gas prices via an API.\n *\n * @example\n *\n * ``` ts\n * import type { MessengerActions, MessengerEvents } from '@metamask/messenger';\n * import { Messenger } from '@metamask/messenger';\n * import type {\n * SampleGasPricesServiceMessenger,\n * } from '@metamask/sample-controllers';\n *\n * const rootMessenger = new Messenger<\n * 'Root',\n * SampleGasPricesServiceActions\n * SampleGasPricesServiceEvents\n * >({ namespace: 'Root' });\n * const gasPricesServiceMessenger = new Messenger<\n * 'SampleGasPricesService',\n * MessengerActions<SampleGasPricesServiceMessenger>,\n * MessengerEvents<SampleGasPricesServiceMessenger>,\n * typeof rootMessenger,\n * >({\n * namespace: 'SampleGasPricesService',\n * parent: rootMessenger,\n * });\n * // Instantiate the service to register its actions on the messenger\n * new SampleGasPricesService({\n * messenger: gasPricesServiceMessenger,\n * });\n *\n * // Later...\n * // Fetch gas prices for Mainnet\n * const gasPrices = await rootMessenger.call(\n * 'SampleGasPricesService:fetchGasPrices',\n * '0x1',\n * );\n * // ... Do something with the gas prices ...\n * ```\n */\nexport class SampleGasPricesService extends BaseDataService<\n typeof serviceName,\n SampleGasPricesServiceMessenger\n> {\n /**\n * Constructs a new SampleGasPricesService object.\n *\n * @param args - The constructor arguments.\n * @param args.messenger - The messenger suited for this service.\n * @param args.queryClientConfig - Configuration for the underlying TanStack\n * Query client.\n * @param args.policyOptions - Options to pass to `createServicePolicy`, which\n * is used to wrap each request. See {@link CreateServicePolicyOptions}.\n */\n constructor({\n messenger,\n queryClientConfig = {},\n policyOptions = {},\n }: {\n messenger: SampleGasPricesServiceMessenger;\n queryClientConfig?: QueryClientConfig;\n policyOptions?: CreateServicePolicyOptions;\n }) {\n super({\n name: serviceName,\n messenger,\n queryClientConfig,\n policyOptions,\n });\n\n this.messenger.registerMethodActionHandlers(\n this,\n MESSENGER_EXPOSED_METHODS,\n );\n }\n\n /**\n * Makes a request to the API in order to retrieve gas prices for a particular\n * chain.\n *\n * @param chainId - The chain ID for which you want to fetch gas prices.\n * @returns The gas prices for the given chain.\n */\n async fetchGasPrices(chainId: Hex): Promise<GasPricesResponse['data']> {\n const url = new URL('/gas-prices', BASE_URL);\n url.searchParams.append('chainId', `eip155:${fromHex(chainId).toString()}`);\n\n const jsonResponse = await this.fetchQuery({\n queryKey: [`${this.name}:fetchGasPrices`, chainId],\n queryFn: async () => {\n const response = await fetch(url);\n\n if (!response.ok) {\n throw new HttpError(\n response.status,\n `Gas prices API failed with status '${response.status}'`,\n );\n }\n\n return response.json();\n },\n });\n\n if (!is(jsonResponse, GasPricesResponseStruct)) {\n throw new Error('Malformed response received from gas prices API');\n }\n\n return jsonResponse.data;\n }\n}\n"]}
1
+ {"version":3,"file":"sample-gas-prices-service.cjs","sourceRoot":"","sources":["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U,CAAC;YACzC,QAAQ,EAAE,CAAC,GAAG,IAAI,CAAC,IAAI,iBAAiB,EAAE,OAAO,CAAC;YAClD,OAAO,EAAE,KAAK,IAAI,EAAE;gBAClB,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,GAAG,CAAC,CAAC;gBAElC,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;oBACjB,MAAM,IAAI,4BAAS,CACjB,QAAQ,CAAC,MAAM,EACf,sCAAsC,QAAQ,CAAC,MAAM,GAAG,CACzD,CAAC;gBACJ,CAAC;gBAED,OAAO,QAAQ,CAAC,IAAI,EAAE,CAAC;YACzB,CAAC;SACF,CAAC,CAAC;QAEH,IAAI,CAAC,IAAA,gBAAE,EAAC,YAAY,EAAE,uBAAuB,CAAC,EAAE,CAAC;YAC/C,MAAM,IAAI,KAAK,CAAC,iDAAiD,CAAC,CAAC;QACrE,CAAC;QAED,OAAO,YAAY,CAAC,IAAI,CAAC;IAC3B,CAAC;CACF;AArED,wDAqEC","sourcesContent":["import { BaseDataService } from '@metamask/base-data-service';\nimport type {\n DataServiceCacheUpdatedEvent,\n DataServiceGranularCacheUpdatedEvent,\n DataServiceInvalidateQueriesAction,\n} from '@metamask/base-data-service';\nimport type { CreateServicePolicyOptions } from '@metamask/controller-utils';\nimport { HttpError, fromHex } from '@metamask/controller-utils';\nimport type { Messenger } from '@metamask/messenger';\nimport type { Infer } from '@metamask/superstruct';\nimport { is, number, type } from '@metamask/superstruct';\nimport type { Hex } from '@metamask/utils';\nimport type { QueryClientConfig } from '@tanstack/query-core';\n\nimport type { SampleGasPricesServiceMethodActions } from './sample-gas-prices-service-method-action-types';\n\n// === GENERAL ===\n\n/**\n * The name of the {@link SampleGasPricesService}, used to namespace the\n * service's actions and events.\n */\nexport const serviceName = 'SampleGasPricesService';\n\n// === MESSENGER ===\n\n/**\n * All of the methods within {@link SampleGasPricesService} that are exposed via\n * the messenger.\n */\nconst MESSENGER_EXPOSED_METHODS = ['fetchGasPrices'] as const;\n\n/**\n * Invalidates cached queries for {@link SampleGasPricesService}.\n */\nexport type SampleGasPricesServiceInvalidateQueriesAction =\n DataServiceInvalidateQueriesAction<typeof serviceName>;\n\n/**\n * Actions that {@link SampleGasPricesService} exposes to other consumers.\n */\nexport type SampleGasPricesServiceActions =\n | SampleGasPricesServiceMethodActions\n | SampleGasPricesServiceInvalidateQueriesAction;\n\n/**\n * Actions from other messengers that {@link SampleGasPricesService} calls.\n */\ntype AllowedActions = never;\n\n/**\n * Published when {@link SampleGasPricesService}'s cache is updated.\n */\nexport type SampleGasPricesServiceCacheUpdatedEvent =\n DataServiceCacheUpdatedEvent<typeof serviceName>;\n\n/**\n * Published when a key within {@link SampleGasPricesService}'s cache is\n * updated.\n */\nexport type SampleGasPricesServiceGranularCacheUpdatedEvent =\n DataServiceGranularCacheUpdatedEvent<typeof serviceName>;\n\n/**\n * Events that {@link SampleGasPricesService} exposes to other consumers.\n */\nexport type SampleGasPricesServiceEvents =\n | SampleGasPricesServiceCacheUpdatedEvent\n | SampleGasPricesServiceGranularCacheUpdatedEvent;\n\n/**\n * Events from other messengers that {@link SampleGasPricesService} subscribes\n * to.\n */\ntype AllowedEvents = never;\n\n/**\n * The messenger which is restricted to actions and events accessed by\n * {@link SampleGasPricesService}.\n */\nexport type SampleGasPricesServiceMessenger = Messenger<\n typeof serviceName,\n SampleGasPricesServiceActions | AllowedActions,\n SampleGasPricesServiceEvents | AllowedEvents\n>;\n\n// === SERVICE DEFINITION ===\n\n/**\n * Struct to validate what the API endpoint returns.\n */\nconst GasPricesResponseStruct = type({\n data: type({\n low: number(),\n average: number(),\n high: number(),\n }),\n});\n\n/**\n * What the API endpoint returns.\n */\ntype GasPricesResponse = Infer<typeof GasPricesResponseStruct>;\n\n/**\n * The base URL of the API that the service represents.\n */\nconst BASE_URL = 'https://api.example.com';\n\n/**\n * This service object is responsible for fetching gas prices via an API.\n *\n * @example\n *\n * ``` ts\n * import type { MessengerActions, MessengerEvents } from '@metamask/messenger';\n * import { Messenger } from '@metamask/messenger';\n * import type {\n * SampleGasPricesServiceMessenger,\n * } from '@metamask/sample-controllers';\n *\n * const rootMessenger = new Messenger<\n * 'Root',\n * SampleGasPricesServiceActions\n * SampleGasPricesServiceEvents\n * >({ namespace: 'Root' });\n * const gasPricesServiceMessenger = new Messenger<\n * 'SampleGasPricesService',\n * MessengerActions<SampleGasPricesServiceMessenger>,\n * MessengerEvents<SampleGasPricesServiceMessenger>,\n * typeof rootMessenger,\n * >({\n * namespace: 'SampleGasPricesService',\n * parent: rootMessenger,\n * });\n * // Instantiate the service to register its actions on the messenger\n * new SampleGasPricesService({\n * messenger: gasPricesServiceMessenger,\n * });\n *\n * // Later...\n * // Fetch gas prices for Mainnet\n * const gasPrices = await rootMessenger.call(\n * 'SampleGasPricesService:fetchGasPrices',\n * '0x1',\n * );\n * // ... Do something with the gas prices ...\n * ```\n */\nexport class SampleGasPricesService extends BaseDataService<\n typeof serviceName,\n SampleGasPricesServiceMessenger\n> {\n /**\n * Constructs a new SampleGasPricesService object.\n *\n * @param args - The constructor arguments.\n * @param args.messenger - The messenger suited for this service.\n * @param args.queryClientConfig - Configuration for the underlying TanStack\n * Query client.\n * @param args.policyOptions - Options to pass to `createServicePolicy`, which\n * is used to wrap each request. See {@link CreateServicePolicyOptions}.\n */\n constructor({\n messenger,\n queryClientConfig = {},\n policyOptions = {},\n }: {\n messenger: SampleGasPricesServiceMessenger;\n queryClientConfig?: QueryClientConfig;\n policyOptions?: CreateServicePolicyOptions;\n }) {\n super({\n name: serviceName,\n messenger,\n queryClientConfig,\n policyOptions,\n });\n\n this.messenger.registerMethodActionHandlers(\n this,\n MESSENGER_EXPOSED_METHODS,\n );\n }\n\n /**\n * Makes a request to the API in order to retrieve gas prices for a particular\n * chain.\n *\n * @param chainId - The chain ID for which you want to fetch gas prices.\n * @returns The gas prices for the given chain.\n */\n async fetchGasPrices(chainId: Hex): Promise<GasPricesResponse['data']> {\n const url = new URL('/gas-prices', BASE_URL);\n url.searchParams.append('chainId', `eip155:${fromHex(chainId).toString()}`);\n\n const jsonResponse = await this.fetchQuery({\n queryKey: [`${this.name}:fetchGasPrices`, chainId],\n queryFn: async () => {\n const response = await fetch(url);\n\n if (!response.ok) {\n throw new HttpError(\n response.status,\n `Gas prices API failed with status '${response.status}'`,\n );\n }\n\n return response.json();\n },\n });\n\n if (!is(jsonResponse, GasPricesResponseStruct)) {\n throw new Error('Malformed response received from gas prices API');\n }\n\n return jsonResponse.data;\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"sample-gas-prices-service.d.cts","sourceRoot":"","sources":["../../src/sample-gas-prices-service/sample-gas-prices-service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,oCAAoC;AAC9D,OAAO,KAAK,EACV,4BAA4B,EAC5B,oCAAoC,EACpC,kCAAkC,EACnC,oCAAoC;AACrC,OAAO,KAAK,EAAE,0BAA0B,EAAE,mCAAmC;AAE7E,OAAO,KAAK,EAAE,SAAS,EAAE,4BAA4B;AACrD,OAAO,KAAK,EAAE,KAAK,EAAE,8BAA8B;AAEnD,OAAO,KAAK,EAAE,GAAG,EAAE,wBAAwB;AAC3C,OAAO,KAAK,EAAE,iBAAiB,EAAE,6BAA6B;AAE9D,OAAO,KAAK,EAAE,mCAAmC,EAAE,4DAA2D;AAI9G;;;GAGG;AACH,eAAO,MAAM,WAAW,2BAA2B,CAAC;AAUpD;;GAEG;AACH,MAAM,MAAM,6CAA6C,GACvD,kCAAkC,CAAC,OAAO,WAAW,CAAC,CAAC;AAEzD;;GAEG;AACH,MAAM,MAAM,6BAA6B,GACrC,mCAAmC,GACnC,6CAA6C,CAAC;AAElD;;GAEG;AACH,KAAK,cAAc,GAAG,KAAK,CAAC;AAE5B;;GAEG;AACH,MAAM,MAAM,uCAAuC,GACjD,4BAA4B,CAAC,OAAO,WAAW,CAAC,CAAC;AAEnD;;;GAGG;AACH,MAAM,MAAM,+CAA+C,GACzD,oCAAoC,CAAC,OAAO,WAAW,CAAC,CAAC;AAE3D;;GAEG;AACH,MAAM,MAAM,4BAA4B,GACpC,uCAAuC,GACvC,+CAA+C,CAAC;AAEpD;;;GAGG;AACH,KAAK,aAAa,GAAG,KAAK,CAAC;AAE3B;;;GAGG;AACH,MAAM,MAAM,+BAA+B,GAAG,SAAS,CACrD,OAAO,WAAW,EAClB,6BAA6B,GAAG,cAAc,EAC9C,4BAA4B,GAAG,aAAa,CAC7C,CAAC;AAIF;;GAEG;AACH,QAAA,MAAM,uBAAuB;;;;;;;;;;;;;;;;EAM3B,CAAC;AAEH;;GAEG;AACH,KAAK,iBAAiB,GAAG,KAAK,CAAC,OAAO,uBAAuB,CAAC,CAAC;AAO/D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AACH,qBAAa,sBAAuB,SAAQ,eAAe,CACzD,OAAO,WAAW,EAClB,+BAA+B,CAChC;IACC;;;;;;;;;OASG;gBACS,EACV,SAAS,EACT,iBAAsB,EACtB,aAAkB,GACnB,EAAE;QACD,SAAS,EAAE,+BAA+B,CAAC;QAC3C,iBAAiB,CAAC,EAAE,iBAAiB,CAAC;QACtC,aAAa,CAAC,EAAE,0BAA0B,CAAC;KAC5C;IAcD;;;;;;OAMG;IACG,cAAc,CAAC,OAAO,EAAE,GAAG,GAAG,OAAO,CAAC,iBAAiB,CAAC,MAAM,CAAC,CAAC;CA0BvE"}
1
+ {"version":3,"file":"sample-gas-prices-service.d.cts","sourceRoot":"","sources":["../../src/sample-gas-prices-service/sample-gas-prices-service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,oCAAoC;AAC9D,OAAO,KAAK,EACV,4BAA4B,EAC5B,oCAAoC,EACpC,kCAAkC,EACnC,oCAAoC;AACrC,OAAO,KAAK,EAAE,0BAA0B,EAAE,mCAAmC;AAE7E,OAAO,KAAK,EAAE,SAAS,EAAE,4BAA4B;AACrD,OAAO,KAAK,EAAE,KAAK,EAAE,8BAA8B;AAEnD,OA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EAAE,iBAAiB,CAAC;QACtC,aAAa,CAAC,EAAE,0BAA0B,CAAC;KAC5C;IAcD;;;;;;OAMG;IACG,cAAc,CAAC,OAAO,EAAE,GAAG,GAAG,OAAO,CAAC,iBAAiB,CAAC,MAAM,CAAC,CAAC;CA0BvE"}
@@ -1 +1 @@
1
- {"version":3,"file":"sample-gas-prices-service.d.mts","sourceRoot":"","sources":["../../src/sample-gas-prices-service/sample-gas-prices-service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,oCAAoC;AAC9D,OAAO,KAAK,EACV,4BAA4B,EAC5B,oCAAoC,EACpC,kCAAkC,EACnC,oCAAoC;AACrC,OAAO,KAAK,EAAE,0BAA0B,EAAE,mCAAmC;AAE7E,OAAO,KAAK,EAAE,SAAS,EAAE,4BAA4B;AACrD,OAAO,KAAK,EAAE,KAAK,EAAE,8BAA8B;AAEnD,OAAO,KAAK,EAAE,GAAG,EAAE,wBAAwB;AAC3C,OAAO,KAAK,EAAE,iBAAiB,EAAE,6BAA6B;AAE9D,OAAO,KAAK,EAAE,mCAAmC,EAAE,4DAA2D;AAI9G;;;GAGG;AACH,eAAO,MAAM,WAAW,2BAA2B,CAAC;AAUpD;;GAEG;AACH,MAAM,MAAM,6CAA6C,GACvD,kCAAkC,CAAC,OAAO,WAAW,CAAC,CAAC;AAEzD;;GAEG;AACH,MAAM,MAAM,6BAA6B,GACrC,mCAAmC,GACnC,6CAA6C,CAAC;AAElD;;GAEG;AACH,KAAK,cAAc,GAAG,KAAK,CAAC;AAE5B;;GAEG;AACH,MAAM,MAAM,uCAAuC,GACjD,4BAA4B,CAAC,OAAO,WAAW,CAAC,CAAC;AAEnD;;;GAGG;AACH,MAAM,MAAM,+CAA+C,GACzD,oCAAoC,CAAC,OAAO,WAAW,CAAC,CAAC;AAE3D;;GAEG;AACH,MAAM,MAAM,4BAA4B,GACpC,uCAAuC,GACvC,+CAA+C,CAAC;AAEpD;;;GAGG;AACH,KAAK,aAAa,GAAG,KAAK,CAAC;AAE3B;;;GAGG;AACH,MAAM,MAAM,+BAA+B,GAAG,SAAS,CACrD,OAAO,WAAW,EAClB,6BAA6B,GAAG,cAAc,EAC9C,4BAA4B,GAAG,aAAa,CAC7C,CAAC;AAIF;;GAEG;AACH,QAAA,MAAM,uBAAuB;;;;;;;;;;;;;;;;EAM3B,CAAC;AAEH;;GAEG;AACH,KAAK,iBAAiB,GAAG,KAAK,CAAC,OAAO,uBAAuB,CAAC,CAAC;AAO/D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AACH,qBAAa,sBAAuB,SAAQ,eAAe,CACzD,OAAO,WAAW,EAClB,+BAA+B,CAChC;IACC;;;;;;;;;OASG;gBACS,EACV,SAAS,EACT,iBAAsB,EACtB,aAAkB,GACnB,EAAE;QACD,SAAS,EAAE,+BAA+B,CAAC;QAC3C,iBAAiB,CAAC,EAAE,iBAAiB,CAAC;QACtC,aAAa,CAAC,EAAE,0BAA0B,CAAC;KAC5C;IAcD;;;;;;OAMG;IACG,cAAc,CAAC,OAAO,EAAE,GAAG,GAAG,OAAO,CAAC,iBAAiB,CAAC,MAAM,CAAC,CAAC;CA0BvE"}
1
+ {"version":3,"file":"sample-gas-prices-service.d.mts","sourceRoot":"","sources":["../../src/sample-gas-prices-service/sample-gas-prices-service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,oCAAoC;AAC9D,OAAO,KAAK,EACV,4BAA4B,EAC5B,oCAAoC,EACpC,kCAAkC,EACnC,oCAAoC;AACrC,OAAO,KAAK,EAAE,0BAA0B,EAAE,mCAAmC;AAE7E,OAAO,KAAK,EAAE,SAAS,EAAE,4BAA4B;AACrD,OAAO,KAAK,EAAE,KAAK,EAAE,8BAA8B;AAEnD,OAAO,KAAK,EAAE,GAAG,EAAE,wBAAwB;AAC3C,OAAO,KAAK,EAAE,iBAAiB,EAAE,6BAA6B;AAE9D,OAAO,KAAK,EAAE,mCAAmC,EAAE,4DAAwD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CAAC,iBAAiB,CAAC,MAAM,CAAC,CAAC;CA0BvE"}
@@ -1 +1 @@
1
- {"version":3,"file":"sample-gas-prices-service.mjs","sourceRoot":"","sources":["../../src/sample-gas-prices-service/sample-gas-prices-service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,oCAAoC;AAO9D,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,mCAAmC;AAGhE,OAAO,EAAE,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,8BAA8B;AAMzD,kBAAkB;AAElB;;;GAGG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,wBAAwB,CAAC;AAEpD,oBAAoB;AAEpB;;;GAGG;AACH,MAAM,yBAAyB,GAAG,CAAC,gBAAgB,CAAU,CAAC;AAwD9D,6BAA6B;AAE7B;;GAEG;AACH,MAAM,uBAAuB,GAAG,IAAI,CAAC;IACnC,IAAI,EAAE,IAAI,CAAC;QACT,GAAG,EAAE,MAAM,EAAE;QACb,OAAO,EAAE,MAAM,EAAE;QACjB,IAAI,EAAE,MAAM,EAAE;KACf,CAAC;CACH,CAAC,CAAC;AAOH;;GAEG;AACH,MAAM,QAAQ,GAAG,yBAAyB,CAAC;AAE3C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AACH,MAAM,OAAO,sBAAuB,SAAQ,eAG3C;IACC;;;;;;;;;OASG;IACH,YAAY,EACV,SAAS,EACT,iBAAiB,GAAG,EAAE,EACtB,aAAa,GAAG,EAAE,GAKnB;QACC,KAAK,CAAC;YACJ,IAAI,EAAE,WAAW;YACjB,SAAS;YACT,iBAAiB;YACjB,aAAa;SACd,CAAC,CAAC;QAEH,IAAI,CAAC,SAAS,CAAC,4BAA4B,CACzC,IAAI,EACJ,yBAAyB,CAC1B,CAAC;IACJ,CAAC;IAED;;;;;;OAMG;IACH,KAAK,CAAC,cAAc,CAAC,OAAY;QAC/B,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,aAAa,EAAE,QAAQ,CAAC,CAAC;QAC7C,GAAG,CAAC,YAAY,CAAC,MAAM,CAAC,SAAS,EAAE,UAAU,OAAO,CAAC,OAAO,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC;QAE5E,MAAM,YAAY,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC;YACzC,QAAQ,EAAE,CAAC,GAAG,IAAI,CAAC,IAAI,iBAAiB,EAAE,OAAO,CAAC;YAClD,OAAO,EAAE,KAAK,IAAI,EAAE;gBAClB,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,GAAG,CAAC,CAAC;gBAElC,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;oBACjB,MAAM,IAAI,SAAS,CACjB,QAAQ,CAAC,MAAM,EACf,sCAAsC,QAAQ,CAAC,MAAM,GAAG,CACzD,CAAC;gBACJ,CAAC;gBAED,OAAO,QAAQ,CAAC,IAAI,EAAE,CAAC;YACzB,CAAC;SACF,CAAC,CAAC;QAEH,IAAI,CAAC,EAAE,CAAC,YAAY,EAAE,uBAAuB,CAAC,EAAE,CAAC;YAC/C,MAAM,IAAI,KAAK,CAAC,iDAAiD,CAAC,CAAC;QACrE,CAAC;QAED,OAAO,YAAY,CAAC,IAAI,CAAC;IAC3B,CAAC;CACF","sourcesContent":["import { BaseDataService } from '@metamask/base-data-service';\nimport type {\n DataServiceCacheUpdatedEvent,\n DataServiceGranularCacheUpdatedEvent,\n DataServiceInvalidateQueriesAction,\n} from '@metamask/base-data-service';\nimport type { CreateServicePolicyOptions } from '@metamask/controller-utils';\nimport { HttpError, fromHex } from '@metamask/controller-utils';\nimport type { Messenger } from '@metamask/messenger';\nimport type { Infer } from '@metamask/superstruct';\nimport { is, number, type } from '@metamask/superstruct';\nimport type { Hex } from '@metamask/utils';\nimport type { QueryClientConfig } from '@tanstack/query-core';\n\nimport type { SampleGasPricesServiceMethodActions } from './sample-gas-prices-service-method-action-types.js';\n\n// === GENERAL ===\n\n/**\n * The name of the {@link SampleGasPricesService}, used to namespace the\n * service's actions and events.\n */\nexport const serviceName = 'SampleGasPricesService';\n\n// === MESSENGER ===\n\n/**\n * All of the methods within {@link SampleGasPricesService} that are exposed via\n * the messenger.\n */\nconst MESSENGER_EXPOSED_METHODS = ['fetchGasPrices'] as const;\n\n/**\n * Invalidates cached queries for {@link SampleGasPricesService}.\n */\nexport type SampleGasPricesServiceInvalidateQueriesAction =\n DataServiceInvalidateQueriesAction<typeof serviceName>;\n\n/**\n * Actions that {@link SampleGasPricesService} exposes to other consumers.\n */\nexport type SampleGasPricesServiceActions =\n | SampleGasPricesServiceMethodActions\n | SampleGasPricesServiceInvalidateQueriesAction;\n\n/**\n * Actions from other messengers that {@link SampleGasPricesService} calls.\n */\ntype AllowedActions = never;\n\n/**\n * Published when {@link SampleGasPricesService}'s cache is updated.\n */\nexport type SampleGasPricesServiceCacheUpdatedEvent =\n DataServiceCacheUpdatedEvent<typeof serviceName>;\n\n/**\n * Published when a key within {@link SampleGasPricesService}'s cache is\n * updated.\n */\nexport type SampleGasPricesServiceGranularCacheUpdatedEvent =\n DataServiceGranularCacheUpdatedEvent<typeof serviceName>;\n\n/**\n * Events that {@link SampleGasPricesService} exposes to other consumers.\n */\nexport type SampleGasPricesServiceEvents =\n | SampleGasPricesServiceCacheUpdatedEvent\n | SampleGasPricesServiceGranularCacheUpdatedEvent;\n\n/**\n * Events from other messengers that {@link SampleGasPricesService} subscribes\n * to.\n */\ntype AllowedEvents = never;\n\n/**\n * The messenger which is restricted to actions and events accessed by\n * {@link SampleGasPricesService}.\n */\nexport type SampleGasPricesServiceMessenger = Messenger<\n typeof serviceName,\n SampleGasPricesServiceActions | AllowedActions,\n SampleGasPricesServiceEvents | AllowedEvents\n>;\n\n// === SERVICE DEFINITION ===\n\n/**\n * Struct to validate what the API endpoint returns.\n */\nconst GasPricesResponseStruct = type({\n data: type({\n low: number(),\n average: number(),\n high: number(),\n }),\n});\n\n/**\n * What the API endpoint returns.\n */\ntype GasPricesResponse = Infer<typeof GasPricesResponseStruct>;\n\n/**\n * The base URL of the API that the service represents.\n */\nconst BASE_URL = 'https://api.example.com';\n\n/**\n * This service object is responsible for fetching gas prices via an API.\n *\n * @example\n *\n * ``` ts\n * import type { MessengerActions, MessengerEvents } from '@metamask/messenger';\n * import { Messenger } from '@metamask/messenger';\n * import type {\n * SampleGasPricesServiceMessenger,\n * } from '@metamask/sample-controllers';\n *\n * const rootMessenger = new Messenger<\n * 'Root',\n * SampleGasPricesServiceActions\n * SampleGasPricesServiceEvents\n * >({ namespace: 'Root' });\n * const gasPricesServiceMessenger = new Messenger<\n * 'SampleGasPricesService',\n * MessengerActions<SampleGasPricesServiceMessenger>,\n * MessengerEvents<SampleGasPricesServiceMessenger>,\n * typeof rootMessenger,\n * >({\n * namespace: 'SampleGasPricesService',\n * parent: rootMessenger,\n * });\n * // Instantiate the service to register its actions on the messenger\n * new SampleGasPricesService({\n * messenger: gasPricesServiceMessenger,\n * });\n *\n * // Later...\n * // Fetch gas prices for Mainnet\n * const gasPrices = await rootMessenger.call(\n * 'SampleGasPricesService:fetchGasPrices',\n * '0x1',\n * );\n * // ... Do something with the gas prices ...\n * ```\n */\nexport class SampleGasPricesService extends BaseDataService<\n typeof serviceName,\n SampleGasPricesServiceMessenger\n> {\n /**\n * Constructs a new SampleGasPricesService object.\n *\n * @param args - The constructor arguments.\n * @param args.messenger - The messenger suited for this service.\n * @param args.queryClientConfig - Configuration for the underlying TanStack\n * Query client.\n * @param args.policyOptions - Options to pass to `createServicePolicy`, which\n * is used to wrap each request. See {@link CreateServicePolicyOptions}.\n */\n constructor({\n messenger,\n queryClientConfig = {},\n policyOptions = {},\n }: {\n messenger: SampleGasPricesServiceMessenger;\n queryClientConfig?: QueryClientConfig;\n policyOptions?: CreateServicePolicyOptions;\n }) {\n super({\n name: serviceName,\n messenger,\n queryClientConfig,\n policyOptions,\n });\n\n this.messenger.registerMethodActionHandlers(\n this,\n MESSENGER_EXPOSED_METHODS,\n );\n }\n\n /**\n * Makes a request to the API in order to retrieve gas prices for a particular\n * chain.\n *\n * @param chainId - The chain ID for which you want to fetch gas prices.\n * @returns The gas prices for the given chain.\n */\n async fetchGasPrices(chainId: Hex): Promise<GasPricesResponse['data']> {\n const url = new URL('/gas-prices', BASE_URL);\n url.searchParams.append('chainId', `eip155:${fromHex(chainId).toString()}`);\n\n const jsonResponse = await this.fetchQuery({\n queryKey: [`${this.name}:fetchGasPrices`, chainId],\n queryFn: async () => {\n const response = await fetch(url);\n\n if (!response.ok) {\n throw new HttpError(\n response.status,\n `Gas prices API failed with status '${response.status}'`,\n );\n }\n\n return response.json();\n },\n });\n\n if (!is(jsonResponse, GasPricesResponseStruct)) {\n throw new Error('Malformed response received from gas prices API');\n }\n\n return jsonResponse.data;\n }\n}\n"]}
1
+ {"version":3,"file":"sample-gas-prices-service.mjs","sourceRoot":"","sources":["../../src/sample-gas-prices-service/sample-gas-prices-service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,oCAAoC;AAO9D,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,mCAAmC;AAGhE,OAAO,EAAE,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,8BAA8B;AAMzD,kBAAkB;AAElB;;;GAGG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,wBAAwB,CAAC;AAEpD,oBAAoB;AAEpB;;;GAGG;AACH,MAAM,yBAAyB,GAAG,CAAC,gBAAgB,CAAU,CAAC;AAwD9D,6BAA6B;AAE7B;;GAEG;AACH,MAAM,uBAAuB,GAAG,IAAI,CAAC;IACnC,IAAI,EAAE,IAAI,CAAC;QACT,GAAG,EAAE,MAAM,EAAE;QACb,OAAO,EAAE,MAAM,EAAE;QACjB,IAAI,EAAE,MAAM,EAAE;KACf,CAAC;CACH,CAAC,CAAC;AAOH;;GAEG;AACH,MAAM,QAAQ,GAAG,yBAAyB,CAAC;AAE3C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AACH,M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seDataService } from '@metamask/base-data-service';\nimport type {\n DataServiceCacheUpdatedEvent,\n DataServiceGranularCacheUpdatedEvent,\n DataServiceInvalidateQueriesAction,\n} from '@metamask/base-data-service';\nimport type { CreateServicePolicyOptions } from '@metamask/controller-utils';\nimport { HttpError, fromHex } from '@metamask/controller-utils';\nimport type { Messenger } from '@metamask/messenger';\nimport type { Infer } from '@metamask/superstruct';\nimport { is, number, type } from '@metamask/superstruct';\nimport type { Hex } from '@metamask/utils';\nimport type { QueryClientConfig } from '@tanstack/query-core';\n\nimport type { SampleGasPricesServiceMethodActions } from './sample-gas-prices-service-method-action-types';\n\n// === GENERAL ===\n\n/**\n * The name of the {@link SampleGasPricesService}, used to namespace the\n * service's actions and events.\n */\nexport const serviceName = 'SampleGasPricesService';\n\n// === MESSENGER ===\n\n/**\n * All of the methods within {@link SampleGasPricesService} that are exposed via\n * the messenger.\n */\nconst MESSENGER_EXPOSED_METHODS = ['fetchGasPrices'] as const;\n\n/**\n * Invalidates cached queries for {@link SampleGasPricesService}.\n */\nexport type SampleGasPricesServiceInvalidateQueriesAction =\n DataServiceInvalidateQueriesAction<typeof serviceName>;\n\n/**\n * Actions that {@link SampleGasPricesService} exposes to other consumers.\n */\nexport type SampleGasPricesServiceActions =\n | SampleGasPricesServiceMethodActions\n | SampleGasPricesServiceInvalidateQueriesAction;\n\n/**\n * Actions from other messengers that {@link SampleGasPricesService} calls.\n */\ntype AllowedActions = never;\n\n/**\n * Published when {@link SampleGasPricesService}'s cache is updated.\n */\nexport type SampleGasPricesServiceCacheUpdatedEvent =\n DataServiceCacheUpdatedEvent<typeof serviceName>;\n\n/**\n * Published when a key within {@link SampleGasPricesService}'s cache is\n * updated.\n */\nexport type SampleGasPricesServiceGranularCacheUpdatedEvent =\n DataServiceGranularCacheUpdatedEvent<typeof serviceName>;\n\n/**\n * Events that {@link SampleGasPricesService} exposes to other consumers.\n */\nexport type SampleGasPricesServiceEvents =\n | SampleGasPricesServiceCacheUpdatedEvent\n | SampleGasPricesServiceGranularCacheUpdatedEvent;\n\n/**\n * Events from other messengers that {@link SampleGasPricesService} subscribes\n * to.\n */\ntype AllowedEvents = never;\n\n/**\n * The messenger which is restricted to actions and events accessed by\n * {@link SampleGasPricesService}.\n */\nexport type SampleGasPricesServiceMessenger = Messenger<\n typeof serviceName,\n SampleGasPricesServiceActions | AllowedActions,\n SampleGasPricesServiceEvents | AllowedEvents\n>;\n\n// === SERVICE DEFINITION ===\n\n/**\n * Struct to validate what the API endpoint returns.\n */\nconst GasPricesResponseStruct = type({\n data: type({\n low: number(),\n average: number(),\n high: number(),\n }),\n});\n\n/**\n * What the API endpoint returns.\n */\ntype GasPricesResponse = Infer<typeof GasPricesResponseStruct>;\n\n/**\n * The base URL of the API that the service represents.\n */\nconst BASE_URL = 'https://api.example.com';\n\n/**\n * This service object is responsible for fetching gas prices via an API.\n *\n * @example\n *\n * ``` ts\n * import type { MessengerActions, MessengerEvents } from '@metamask/messenger';\n * import { Messenger } from '@metamask/messenger';\n * import type {\n * SampleGasPricesServiceMessenger,\n * } from '@metamask/sample-controllers';\n *\n * const rootMessenger = new Messenger<\n * 'Root',\n * SampleGasPricesServiceActions\n * SampleGasPricesServiceEvents\n * >({ namespace: 'Root' });\n * const gasPricesServiceMessenger = new Messenger<\n * 'SampleGasPricesService',\n * MessengerActions<SampleGasPricesServiceMessenger>,\n * MessengerEvents<SampleGasPricesServiceMessenger>,\n * typeof rootMessenger,\n * >({\n * namespace: 'SampleGasPricesService',\n * parent: rootMessenger,\n * });\n * // Instantiate the service to register its actions on the messenger\n * new SampleGasPricesService({\n * messenger: gasPricesServiceMessenger,\n * });\n *\n * // Later...\n * // Fetch gas prices for Mainnet\n * const gasPrices = await rootMessenger.call(\n * 'SampleGasPricesService:fetchGasPrices',\n * '0x1',\n * );\n * // ... Do something with the gas prices ...\n * ```\n */\nexport class SampleGasPricesService extends BaseDataService<\n typeof serviceName,\n SampleGasPricesServiceMessenger\n> {\n /**\n * Constructs a new SampleGasPricesService object.\n *\n * @param args - The constructor arguments.\n * @param args.messenger - The messenger suited for this service.\n * @param args.queryClientConfig - Configuration for the underlying TanStack\n * Query client.\n * @param args.policyOptions - Options to pass to `createServicePolicy`, which\n * is used to wrap each request. See {@link CreateServicePolicyOptions}.\n */\n constructor({\n messenger,\n queryClientConfig = {},\n policyOptions = {},\n }: {\n messenger: SampleGasPricesServiceMessenger;\n queryClientConfig?: QueryClientConfig;\n policyOptions?: CreateServicePolicyOptions;\n }) {\n super({\n name: serviceName,\n messenger,\n queryClientConfig,\n policyOptions,\n });\n\n this.messenger.registerMethodActionHandlers(\n this,\n MESSENGER_EXPOSED_METHODS,\n );\n }\n\n /**\n * Makes a request to the API in order to retrieve gas prices for a particular\n * chain.\n *\n * @param chainId - The chain ID for which you want to fetch gas prices.\n * @returns The gas prices for the given chain.\n */\n async fetchGasPrices(chainId: Hex): Promise<GasPricesResponse['data']> {\n const url = new URL('/gas-prices', BASE_URL);\n url.searchParams.append('chainId', `eip155:${fromHex(chainId).toString()}`);\n\n const jsonResponse = await this.fetchQuery({\n queryKey: [`${this.name}:fetchGasPrices`, chainId],\n queryFn: async () => {\n const response = await fetch(url);\n\n if (!response.ok) {\n throw new HttpError(\n response.status,\n `Gas prices API failed with status '${response.status}'`,\n );\n }\n\n return response.json();\n },\n });\n\n if (!is(jsonResponse, GasPricesResponseStruct)) {\n throw new Error('Malformed response received from gas prices API');\n }\n\n return jsonResponse.data;\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"sample-petnames-controller-method-action-types.cjs","sourceRoot":"","sources":["../src/sample-petnames-controller-method-action-types.ts"],"names":[],"mappings":";AAAA;;;GAGG","sourcesContent":["/**\n * This file is auto generated.\n * Do not edit manually.\n */\n\nimport type { SamplePetnamesController } from './sample-petnames-controller.js';\n\n/**\n * Registers the given name with the given address (relative to the given\n * chain).\n *\n * @param chainId - The chain ID that the address belongs to.\n * @param address - The account address to name.\n * @param name - The name to assign to the address.\n */\nexport type SamplePetnamesControllerAssignPetnameAction = {\n type: `SamplePetnamesController:assignPetname`;\n handler: SamplePetnamesController['assignPetname'];\n};\n\n/**\n * Union of all SamplePetnamesController action types.\n */\nexport type SamplePetnamesControllerMethodActions =\n SamplePetnamesControllerAssignPetnameAction;\n"]}
1
+ {"version":3,"file":"sample-petnames-controller-method-action-types.cjs","sourceRoot":"","sources":["../src/sample-petnames-controller-method-action-types.ts"],"names":[],"mappings":";AAAA;;;GAGG","sourcesContent":["/**\n * This file is auto generated.\n * Do not edit manually.\n */\n\nimport type { SamplePetnamesController } from './sample-petnames-controller';\n\n/**\n * Registers the given name with the given address (relative to the given\n * chain).\n *\n * @param chainId - The chain ID that the address belongs to.\n * @param address - The account address to name.\n * @param name - The name to assign to the address.\n */\nexport type SamplePetnamesControllerAssignPetnameAction = {\n type: `SamplePetnamesController:assignPetname`;\n handler: SamplePetnamesController['assignPetname'];\n};\n\n/**\n * Union of all SamplePetnamesController action types.\n */\nexport type SamplePetnamesControllerMethodActions =\n SamplePetnamesControllerAssignPetnameAction;\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"sample-petnames-controller-method-action-types.d.cts","sourceRoot":"","sources":["../src/sample-petnames-controller-method-action-types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,wBAAwB,EAAE,yCAAwC;AAEhF;;;;;;;GAOG;AACH,MAAM,MAAM,2CAA2C,GAAG;IACxD,IAAI,EAAE,wCAAwC,CAAC;IAC/C,OAAO,EAAE,wBAAwB,CAAC,eAAe,CAAC,CAAC;CACpD,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,qCAAqC,GAC/C,2CAA2C,CAAC"}
1
+ {"version":3,"file":"sample-petnames-controller-method-action-types.d.cts","sourceRoot":"","sources":["../src/sample-petnames-controller-method-action-types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,wBAAwB,EAAE,yCAAqC;AAE7E;;;;;;;GAOG;AACH,MAAM,MAAM,2CAA2C,GAAG;IACxD,IAAI,EAAE,wCAAwC,CAAC;IAC/C,OAAO,EAAE,wBAAwB,CAAC,eAAe,CAAC,CAAC;CACpD,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,qCAAqC,GAC/C,2CAA2C,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"sample-petnames-controller-method-action-types.d.mts","sourceRoot":"","sources":["../src/sample-petnames-controller-method-action-types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,wBAAwB,EAAE,yCAAwC;AAEhF;;;;;;;GAOG;AACH,MAAM,MAAM,2CAA2C,GAAG;IACxD,IAAI,EAAE,wCAAwC,CAAC;IAC/C,OAAO,EAAE,wBAAwB,CAAC,eAAe,CAAC,CAAC;CACpD,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,qCAAqC,GAC/C,2CAA2C,CAAC"}
1
+ {"version":3,"file":"sample-petnames-controller-method-action-types.d.mts","sourceRoot":"","sources":["../src/sample-petnames-controller-method-action-types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,wBAAwB,EAAE,yCAAqC;AAE7E;;;;;;;GAOG;AACH,MAAM,MAAM,2CAA2C,GAAG;IACxD,IAAI,EAAE,wCAAwC,CAAC;IAC/C,OAAO,EAAE,wBAAwB,CAAC,eAAe,CAAC,CAAC;CACpD,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,qCAAqC,GAC/C,2CAA2C,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"sample-petnames-controller-method-action-types.mjs","sourceRoot":"","sources":["../src/sample-petnames-controller-method-action-types.ts"],"names":[],"mappings":"AAAA;;;GAGG","sourcesContent":["/**\n * This file is auto generated.\n * Do not edit manually.\n */\n\nimport type { SamplePetnamesController } from './sample-petnames-controller.js';\n\n/**\n * Registers the given name with the given address (relative to the given\n * chain).\n *\n * @param chainId - The chain ID that the address belongs to.\n * @param address - The account address to name.\n * @param name - The name to assign to the address.\n */\nexport type SamplePetnamesControllerAssignPetnameAction = {\n type: `SamplePetnamesController:assignPetname`;\n handler: SamplePetnamesController['assignPetname'];\n};\n\n/**\n * Union of all SamplePetnamesController action types.\n */\nexport type SamplePetnamesControllerMethodActions =\n SamplePetnamesControllerAssignPetnameAction;\n"]}
1
+ {"version":3,"file":"sample-petnames-controller-method-action-types.mjs","sourceRoot":"","sources":["../src/sample-petnames-controller-method-action-types.ts"],"names":[],"mappings":"AAAA;;;GAGG","sourcesContent":["/**\n * This file is auto generated.\n * Do not edit manually.\n */\n\nimport type { SamplePetnamesController } from './sample-petnames-controller';\n\n/**\n * Registers the given name with the given address (relative to the given\n * chain).\n *\n * @param chainId - The chain ID that the address belongs to.\n * @param address - The account address to name.\n * @param name - The name to assign to the address.\n */\nexport type SamplePetnamesControllerAssignPetnameAction = {\n type: `SamplePetnamesController:assignPetname`;\n handler: SamplePetnamesController['assignPetname'];\n};\n\n/**\n * Union of all SamplePetnamesController action types.\n */\nexport type SamplePetnamesControllerMethodActions =\n SamplePetnamesControllerAssignPetnameAction;\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"sample-petnames-controller.cjs","sourceRoot":"","sources":["../src/sample-petnames-controller.ts"],"names":[],"mappings":";;;AAKA,+DAA2D;AAC3D,iEAA8D;AAM9D,kBAAkB;AAElB;;;;GAIG;AACH,MAAM,eAAe,GAAG,0BAA0B,CAAC;AAmBnD;;GAEG;AACH,MAAM,gCAAgC,GAAG;IACvC,wBAAwB,EAAE;QACxB,sBAAsB,EAAE,KAAK;QAC7B,kBAAkB,EAAE,IAAI;QACxB,OAAO,EAAE,IAAI;QACb,QAAQ,EAAE,IAAI;KACf;CACqD,CAAC;AAEzD;;;;;;;GAOG;AACH,SAAgB,iCAAiC;IAC/C,OAAO;QACL,wBAAwB,EAAE,EAAE;KAC7B,CAAC;AACJ,CAAC;AAJD,8EAIC;AAED,oBAAoB;AAEpB,MAAM,yBAAyB,GAAG,CAAC,eAAe,CAAU,CAAC;AAqD7D,gCAAgC;AAEhC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8CG;AACH,MAAa,wBAAyB,SAAQ,gCAI7C;IACC;;;;;;;OAOG;IACH,YAAY,EACV,SAAS,EACT,KAAK,GAIN;QACC,KAAK,CAAC;YACJ,SAAS;YACT,QAAQ,EAAE,gCAAgC;YAC1C,IAAI,EAAE,eAAe;YACrB,KAAK,EAAE;gBACL,GAAG,iCAAiC,EAAE;gBACtC,GAAG,KAAK;aACT;SACF,CAAC,CAAC;QAEH,IAAI,CAAC,SAAS,CAAC,4BAA4B,CACzC,IAAI,EACJ,yBAAyB,CAC1B,CAAC;IACJ,CAAC;IAED;;;;;;;OAOG;IACH,aAAa,CAAC,OAAY,EAAE,OAAY,EAAE,IAAY;QACpD,IAAI,CAAC,IAAA,mCAAgB,EAAC,OAAO,CAAC,EAAE,CAAC;YAC/B,MAAM,IAAI,KAAK,CAAC,kBAAkB,CAAC,CAAC;QACtC,CAAC;QAED,MAAM,iBAAiB,GAAG,OAAO,CAAC,WAAW,EAAS,CAAC;QAEvD,IAAI,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE;;YACpB,MAAA,KAAK,CAAC,wBAAwB,EAAC,OAAO,SAAP,OAAO,IAAM,EAAE,EAAC;YAC/C,KAAK,CAAC,wBAAwB,CAAC,OAAO,CAAC,CAAC,iBAAiB,CAAC,GAAG,IAAI,CAAC;QACpE,CAAC,CAAC,CAAC;IACL,CAAC;CACF;AAxDD,4DAwDC","sourcesContent":["import type {\n ControllerGetStateAction,\n ControllerStateChangeEvent,\n StateMetadata,\n} from '@metamask/base-controller';\nimport { BaseController } from '@metamask/base-controller';\nimport { isSafeDynamicKey } from '@metamask/controller-utils';\nimport type { Messenger } from '@metamask/messenger';\nimport type { Hex } from '@metamask/utils';\n\nimport type { SamplePetnamesControllerMethodActions } from './sample-petnames-controller-method-action-types.js';\n\n// === GENERAL ===\n\n/**\n * The name of the {@link SamplePetnamesController}, used to namespace the\n * controller's actions and events and to namespace the controller's state data\n * when composed with other controllers.\n */\nconst CONTROLLER_NAME = 'SamplePetnamesController';\n\n// === STATE ===\n\n/**\n * Describes the shape of the state object for {@link SamplePetnamesController}.\n */\nexport type SamplePetnamesControllerState = {\n /**\n * The registry of pet names, categorized by chain ID first and address\n * second.\n */\n namesByChainIdAndAddress: {\n [chainId: Hex]: {\n [address: Hex]: string;\n };\n };\n};\n\n/**\n * The metadata for each property in {@link SamplePetnamesControllerState}.\n */\nconst samplePetnamesControllerMetadata = {\n namesByChainIdAndAddress: {\n includeInDebugSnapshot: false,\n includeInStateLogs: true,\n persist: true,\n usedInUi: true,\n },\n} satisfies StateMetadata<SamplePetnamesControllerState>;\n\n/**\n * Constructs the default {@link SamplePetnamesController} state. This allows\n * consumers to provide a partial state object when initializing the controller\n * and also helps in constructing complete state objects for this controller in\n * tests.\n *\n * @returns The default {@link SamplePetnamesController} state.\n */\nexport function getDefaultPetnamesControllerState(): SamplePetnamesControllerState {\n return {\n namesByChainIdAndAddress: {},\n };\n}\n\n// === MESSENGER ===\n\nconst MESSENGER_EXPOSED_METHODS = ['assignPetname'] as const;\n\n/**\n * Retrieves the state of the {@link SamplePetnamesController}.\n */\nexport type SamplePetnamesControllerGetStateAction = ControllerGetStateAction<\n typeof CONTROLLER_NAME,\n SamplePetnamesControllerState\n>;\n\n/**\n * Actions that {@link SampleGasPricesMessenger} exposes to other consumers.\n */\nexport type SamplePetnamesControllerActions =\n | SamplePetnamesControllerGetStateAction\n | SamplePetnamesControllerMethodActions;\n\n/**\n * Actions from other messengers that {@link SampleGasPricesMessenger} calls.\n */\ntype AllowedActions = never;\n\n/**\n * Published when the state of {@link SamplePetnamesController} changes.\n */\nexport type SamplePetnamesControllerStateChangeEvent =\n ControllerStateChangeEvent<\n typeof CONTROLLER_NAME,\n SamplePetnamesControllerState\n >;\n\n/**\n * Events that {@link SampleGasPricesMessenger} exposes to other consumers.\n */\nexport type SamplePetnamesControllerEvents =\n SamplePetnamesControllerStateChangeEvent;\n\n/**\n * Events from other messengers that {@link SampleGasPricesMessenger} subscribes\n * to.\n */\ntype AllowedEvents = never;\n\n/**\n * The messenger restricted to actions and events accessed by\n * {@link SamplePetnamesController}.\n */\nexport type SamplePetnamesControllerMessenger = Messenger<\n typeof CONTROLLER_NAME,\n SamplePetnamesControllerActions | AllowedActions,\n SamplePetnamesControllerEvents | AllowedEvents\n>;\n\n// === CONTROLLER DEFINITION ===\n\n/**\n * `SamplePetnamesController` records user-provided nicknames for various\n * addresses on various chains.\n *\n * @example\n *\n * ``` ts\n * import { Messenger } from '@metamask/messenger';\n * import type {\n * SamplePetnamesControllerActions,\n * SamplePetnamesControllerEvents,\n * } from '@metamask/sample-controllers';\n *\n * const rootMessenger = new Messenger<\n * 'Root',\n * SamplePetnamesControllerActions,\n * SamplePetnamesControllerEvents\n * >({ namespace: 'Root' });\n * const samplePetnamesMessenger = new Messenger<\n * 'SamplePetnamesController',\n * SamplePetnamesControllerActions,\n * SamplePetnamesControllerEvents,\n * typeof rootMessenger,\n * >({\n * namespace: 'SamplePetnamesController',\n * parent: rootMessenger,\n * });\n * // Instantiate the controller to register its actions on the messenger\n * new SamplePetnamesController({\n * messenger: samplePetnamesMessenger,\n * });\n *\n * rootMessenger.call(\n * 'SamplePetnamesController:assignPetname',\n * [\n * '0x1',\n * '0xF57F855e17483B1f09bFec62783C9d3b6c8b3A99',\n * 'Primary Account',\n * ],\n * );\n * const samplePetnamesControllerState = await rootMessenger.call(\n * 'SamplePetnamesController:getState',\n * );\n * samplePetnamesControllerState.namesByChainIdAndAddress\n * // => { '0x1': { '0xF57F855e17483B1f09bFec62783C9d3b6c8b3A99': 'Primary Account' } }\n * ```\n */\nexport class SamplePetnamesController extends BaseController<\n typeof CONTROLLER_NAME,\n SamplePetnamesControllerState,\n SamplePetnamesControllerMessenger\n> {\n /**\n * Constructs a new {@link SamplePetnamesController}.\n *\n * @param args - The arguments to this controller.\n * @param args.messenger - The messenger suited for this controller.\n * @param args.state - The desired state with which to initialize this\n * controller. Missing properties will be filled in with defaults.\n */\n constructor({\n messenger,\n state,\n }: {\n messenger: SamplePetnamesControllerMessenger;\n state?: Partial<SamplePetnamesControllerState>;\n }) {\n super({\n messenger,\n metadata: samplePetnamesControllerMetadata,\n name: CONTROLLER_NAME,\n state: {\n ...getDefaultPetnamesControllerState(),\n ...state,\n },\n });\n\n this.messenger.registerMethodActionHandlers(\n this,\n MESSENGER_EXPOSED_METHODS,\n );\n }\n\n /**\n * Registers the given name with the given address (relative to the given\n * chain).\n *\n * @param chainId - The chain ID that the address belongs to.\n * @param address - The account address to name.\n * @param name - The name to assign to the address.\n */\n assignPetname(chainId: Hex, address: Hex, name: string): void {\n if (!isSafeDynamicKey(chainId)) {\n throw new Error('Invalid chain ID');\n }\n\n const normalizedAddress = address.toLowerCase() as Hex;\n\n this.update((state) => {\n state.namesByChainIdAndAddress[chainId] ??= {};\n state.namesByChainIdAndAddress[chainId][normalizedAddress] = name;\n });\n }\n}\n"]}
1
+ {"version":3,"file":"sample-petnames-controller.cjs","sourceRoot":"","sources":["../src/sample-petnames-controller.ts"],"names":[],"mappings":";;;AAKA,+DAA2D;AAC3D,iEAA8D;AAM9D,kBAAkB;AAElB;;;;GAIG;AACH,MAAM,eAAe,GAAG,0BAA0B,CAAC;AAmBnD;;GAEG;AACH,MAAM,gCAAgC,GAAG;IACvC,wBAAwB,EAAE;QACxB,sBAAsB,EAAE,KAAK;QAC7B,kBAAkB,EAAE,IAAI;QACxB,OAAO,EAAE,IAAI;QACb,QAAQ,EAAE,IAAI;KACf;CACqD,CAAC;AAEzD;;;;;;;GAOG;AACH,SAAgB,iCAAiC;IAC/C,OAAO;QACL,wBAAwB,EAAE,EAAE;KAC7B,CAAC;AACJ,CAAC;AAJD,8EAIC;AAED,oBAAoB;AAEpB,MAAM,yBAAyB,GAAG,CAAC,eAAe,CAAU,CAAC;AAqD7D,gCAAgC;AAEhC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8CG;AACH,MAAa,wBAAyB,SAAQ,gCAI7C;IACC;;;;;;;OAOG;IACH,YAAY,EACV,SAAS,EACT,KAAK,GAIN;QACC,KAAK,CAAC;YACJ,SAAS;YACT,QAAQ,EAAE,gCAAgC;YAC1C,IAAI,EAAE,eAAe;YACrB,KAAK,EAAE;gBACL,GAAG,iCAAiC,EAAE;gBACtC,GAAG,KAAK;aACT;SACF,CAAC,CAAC;QAEH,IAAI,CAAC,SAAS,CAAC,4BAA4B,CACzC,IAAI,EACJ,yBAAyB,CAC1B,CAAC;IACJ,CAAC;IAED;;;;;;;OAOG;IACH,aAAa,CAAC,OAAY,EAAE,OAAY,EAAE,IAAY;QACpD,IAAI,CAAC,IAAA,mCAAgB,EAAC,OAAO,CAAC,EAAE,CAAC;YAC/B,MAAM,IAAI,KAAK,CAAC,kBAAkB,CAAC,CAAC;QACtC,CAAC;QAED,MAAM,iBAAiB,GAAG,OAAO,CAAC,WAAW,EAAS,CAAC;QAEvD,IAAI,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE;;YACpB,MAAA,KAAK,CAAC,wBAAwB,EAAC,OAAO,SAAP,OAAO,IAAM,EAAE,EAAC;YAC/C,KAAK,CAAC,wBAAwB,CAAC,OAAO,CAAC,CAAC,iBAAiB,CAAC,GAAG,IAAI,CAAC;QACpE,CAAC,CAAC,CAAC;IACL,CAAC;CACF;AAxDD,4DAwDC","sourcesContent":["import type {\n ControllerGetStateAction,\n ControllerStateChangeEvent,\n StateMetadata,\n} from '@metamask/base-controller';\nimport { BaseController } from '@metamask/base-controller';\nimport { isSafeDynamicKey } from '@metamask/controller-utils';\nimport type { Messenger } from '@metamask/messenger';\nimport type { Hex } from '@metamask/utils';\n\nimport type { SamplePetnamesControllerMethodActions } from './sample-petnames-controller-method-action-types';\n\n// === GENERAL ===\n\n/**\n * The name of the {@link SamplePetnamesController}, used to namespace the\n * controller's actions and events and to namespace the controller's state data\n * when composed with other controllers.\n */\nconst CONTROLLER_NAME = 'SamplePetnamesController';\n\n// === STATE ===\n\n/**\n * Describes the shape of the state object for {@link SamplePetnamesController}.\n */\nexport type SamplePetnamesControllerState = {\n /**\n * The registry of pet names, categorized by chain ID first and address\n * second.\n */\n namesByChainIdAndAddress: {\n [chainId: Hex]: {\n [address: Hex]: string;\n };\n };\n};\n\n/**\n * The metadata for each property in {@link SamplePetnamesControllerState}.\n */\nconst samplePetnamesControllerMetadata = {\n namesByChainIdAndAddress: {\n includeInDebugSnapshot: false,\n includeInStateLogs: true,\n persist: true,\n usedInUi: true,\n },\n} satisfies StateMetadata<SamplePetnamesControllerState>;\n\n/**\n * Constructs the default {@link SamplePetnamesController} state. This allows\n * consumers to provide a partial state object when initializing the controller\n * and also helps in constructing complete state objects for this controller in\n * tests.\n *\n * @returns The default {@link SamplePetnamesController} state.\n */\nexport function getDefaultPetnamesControllerState(): SamplePetnamesControllerState {\n return {\n namesByChainIdAndAddress: {},\n };\n}\n\n// === MESSENGER ===\n\nconst MESSENGER_EXPOSED_METHODS = ['assignPetname'] as const;\n\n/**\n * Retrieves the state of the {@link SamplePetnamesController}.\n */\nexport type SamplePetnamesControllerGetStateAction = ControllerGetStateAction<\n typeof CONTROLLER_NAME,\n SamplePetnamesControllerState\n>;\n\n/**\n * Actions that {@link SampleGasPricesMessenger} exposes to other consumers.\n */\nexport type SamplePetnamesControllerActions =\n | SamplePetnamesControllerGetStateAction\n | SamplePetnamesControllerMethodActions;\n\n/**\n * Actions from other messengers that {@link SampleGasPricesMessenger} calls.\n */\ntype AllowedActions = never;\n\n/**\n * Published when the state of {@link SamplePetnamesController} changes.\n */\nexport type SamplePetnamesControllerStateChangeEvent =\n ControllerStateChangeEvent<\n typeof CONTROLLER_NAME,\n SamplePetnamesControllerState\n >;\n\n/**\n * Events that {@link SampleGasPricesMessenger} exposes to other consumers.\n */\nexport type SamplePetnamesControllerEvents =\n SamplePetnamesControllerStateChangeEvent;\n\n/**\n * Events from other messengers that {@link SampleGasPricesMessenger} subscribes\n * to.\n */\ntype AllowedEvents = never;\n\n/**\n * The messenger restricted to actions and events accessed by\n * {@link SamplePetnamesController}.\n */\nexport type SamplePetnamesControllerMessenger = Messenger<\n typeof CONTROLLER_NAME,\n SamplePetnamesControllerActions | AllowedActions,\n SamplePetnamesControllerEvents | AllowedEvents\n>;\n\n// === CONTROLLER DEFINITION ===\n\n/**\n * `SamplePetnamesController` records user-provided nicknames for various\n * addresses on various chains.\n *\n * @example\n *\n * ``` ts\n * import { Messenger } from '@metamask/messenger';\n * import type {\n * SamplePetnamesControllerActions,\n * SamplePetnamesControllerEvents,\n * } from '@metamask/sample-controllers';\n *\n * const rootMessenger = new Messenger<\n * 'Root',\n * SamplePetnamesControllerActions,\n * SamplePetnamesControllerEvents\n * >({ namespace: 'Root' });\n * const samplePetnamesMessenger = new Messenger<\n * 'SamplePetnamesController',\n * SamplePetnamesControllerActions,\n * SamplePetnamesControllerEvents,\n * typeof rootMessenger,\n * >({\n * namespace: 'SamplePetnamesController',\n * parent: rootMessenger,\n * });\n * // Instantiate the controller to register its actions on the messenger\n * new SamplePetnamesController({\n * messenger: samplePetnamesMessenger,\n * });\n *\n * rootMessenger.call(\n * 'SamplePetnamesController:assignPetname',\n * [\n * '0x1',\n * '0xF57F855e17483B1f09bFec62783C9d3b6c8b3A99',\n * 'Primary Account',\n * ],\n * );\n * const samplePetnamesControllerState = await rootMessenger.call(\n * 'SamplePetnamesController:getState',\n * );\n * samplePetnamesControllerState.namesByChainIdAndAddress\n * // => { '0x1': { '0xF57F855e17483B1f09bFec62783C9d3b6c8b3A99': 'Primary Account' } }\n * ```\n */\nexport class SamplePetnamesController extends BaseController<\n typeof CONTROLLER_NAME,\n SamplePetnamesControllerState,\n SamplePetnamesControllerMessenger\n> {\n /**\n * Constructs a new {@link SamplePetnamesController}.\n *\n * @param args - The arguments to this controller.\n * @param args.messenger - The messenger suited for this controller.\n * @param args.state - The desired state with which to initialize this\n * controller. Missing properties will be filled in with defaults.\n */\n constructor({\n messenger,\n state,\n }: {\n messenger: SamplePetnamesControllerMessenger;\n state?: Partial<SamplePetnamesControllerState>;\n }) {\n super({\n messenger,\n metadata: samplePetnamesControllerMetadata,\n name: CONTROLLER_NAME,\n state: {\n ...getDefaultPetnamesControllerState(),\n ...state,\n },\n });\n\n this.messenger.registerMethodActionHandlers(\n this,\n MESSENGER_EXPOSED_METHODS,\n );\n }\n\n /**\n * Registers the given name with the given address (relative to the given\n * chain).\n *\n * @param chainId - The chain ID that the address belongs to.\n * @param address - The account address to name.\n * @param name - The name to assign to the address.\n */\n assignPetname(chainId: Hex, address: Hex, name: string): void {\n if (!isSafeDynamicKey(chainId)) {\n throw new Error('Invalid chain ID');\n }\n\n const normalizedAddress = address.toLowerCase() as Hex;\n\n this.update((state) => {\n state.namesByChainIdAndAddress[chainId] ??= {};\n state.namesByChainIdAndAddress[chainId][normalizedAddress] = name;\n });\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"sample-petnames-controller.d.cts","sourceRoot":"","sources":["../src/sample-petnames-controller.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,wBAAwB,EACxB,0BAA0B,EAE3B,kCAAkC;AACnC,OAAO,EAAE,cAAc,EAAE,kCAAkC;AAE3D,OAAO,KAAK,EAAE,SAAS,EAAE,4BAA4B;AACrD,OAAO,KAAK,EAAE,GAAG,EAAE,wBAAwB;AAE3C,OAAO,KAAK,EAAE,qCAAqC,EAAE,6DAA4D;AAIjH;;;;GAIG;AACH,QAAA,MAAM,eAAe,6BAA6B,CAAC;AAInD;;GAEG;AACH,MAAM,MAAM,6BAA6B,GAAG;IAC1C;;;OAGG;IACH,wBAAwB,EAAE;QACxB,CAAC,OAAO,EAAE,GAAG,GAAG;YACd,CAAC,OAAO,EAAE,GAAG,GAAG,MAAM,CAAC;SACxB,CAAC;KACH,CAAC;CACH,CAAC;AAcF;;;;;;;GAOG;AACH,wBAAgB,iCAAiC,IAAI,6BAA6B,CAIjF;AAMD;;GAEG;AACH,MAAM,MAAM,sCAAsC,GAAG,wBAAwB,CAC3E,OAAO,eAAe,EACtB,6BAA6B,CAC9B,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,+BAA+B,GACvC,sCAAsC,GACtC,qCAAqC,CAAC;AAE1C;;GAEG;AACH,KAAK,cAAc,GAAG,KAAK,CAAC;AAE5B;;GAEG;AACH,MAAM,MAAM,wCAAwC,GAClD,0BAA0B,CACxB,OAAO,eAAe,EACtB,6BAA6B,CAC9B,CAAC;AAEJ;;GAEG;AACH,MAAM,MAAM,8BAA8B,GACxC,wCAAwC,CAAC;AAE3C;;;GAGG;AACH,KAAK,aAAa,GAAG,KAAK,CAAC;AAE3B;;;GAGG;AACH,MAAM,MAAM,iCAAiC,GAAG,SAAS,CACvD,OAAO,eAAe,EACtB,+BAA+B,GAAG,cAAc,EAChD,8BAA8B,GAAG,aAAa,CAC/C,CAAC;AAIF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8CG;AACH,qBAAa,wBAAyB,SAAQ,cAAc,CAC1D,OAAO,eAAe,EACtB,6BAA6B,EAC7B,iCAAiC,CAClC;IACC;;;;;;;OAOG;gBACS,EACV,SAAS,EACT,KAAK,GACN,EAAE;QACD,SAAS,EAAE,iCAAiC,CAAC;QAC7C,KAAK,CAAC,EAAE,OAAO,CAAC,6BAA6B,CAAC,CAAC;KAChD;IAiBD;;;;;;;OAOG;IACH,aAAa,CAAC,OAAO,EAAE,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI;CAY9D"}
1
+ {"version":3,"file":"sample-petnames-controller.d.cts","sourceRoot":"","sources":["../src/sample-petnames-controller.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,wBAAwB,EACxB,0BAA0B,EAE3B,kCAAkC;AACnC,OAAO,EAAE,cAAc,EAAE,kCAAkC;AAE3D,OAAO,KAAK,EAAE,SAAS,EAAE,4BAA4B;AACrD,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,EAAE,OAAO,CAAC,6BAA6B,CAAC,CAAC;KAChD;IAiBD;;;;;;;OAOG;IACH,aAAa,CAAC,OAAO,EAAE,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI;CAY9D"}
@@ -1 +1 @@
1
- {"version":3,"file":"sample-petnames-controller.d.mts","sourceRoot":"","sources":["../src/sample-petnames-controller.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,wBAAwB,EACxB,0BAA0B,EAE3B,kCAAkC;AACnC,OAAO,EAAE,cAAc,EAAE,kCAAkC;AAE3D,OAAO,KAAK,EAAE,SAAS,EAAE,4BAA4B;AACrD,OAAO,KAAK,EAAE,GAAG,EAAE,wBAAwB;AAE3C,OAAO,KAAK,EAAE,qCAAqC,EAAE,6DAA4D;AAIjH;;;;GAIG;AACH,QAAA,MAAM,eAAe,6BAA6B,CAAC;AAInD;;GAEG;AACH,MAAM,MAAM,6BAA6B,GAAG;IAC1C;;;OAGG;IACH,wBAAwB,EAAE;QACxB,CAAC,OAAO,EAAE,GAAG,GAAG;YACd,CAAC,OAAO,EAAE,GAAG,GAAG,MAAM,CAAC;SACxB,CAAC;KACH,CAAC;CACH,CAAC;AAcF;;;;;;;GAOG;AACH,wBAAgB,iCAAiC,IAAI,6BAA6B,CAIjF;AAMD;;GAEG;AACH,MAAM,MAAM,sCAAsC,GAAG,wBAAwB,CAC3E,OAAO,eAAe,EACtB,6BAA6B,CAC9B,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,+BAA+B,GACvC,sCAAsC,GACtC,qCAAqC,CAAC;AAE1C;;GAEG;AACH,KAAK,cAAc,GAAG,KAAK,CAAC;AAE5B;;GAEG;AACH,MAAM,MAAM,wCAAwC,GAClD,0BAA0B,CACxB,OAAO,eAAe,EACtB,6BAA6B,CAC9B,CAAC;AAEJ;;GAEG;AACH,MAAM,MAAM,8BAA8B,GACxC,wCAAwC,CAAC;AAE3C;;;GAGG;AACH,KAAK,aAAa,GAAG,KAAK,CAAC;AAE3B;;;GAGG;AACH,MAAM,MAAM,iCAAiC,GAAG,SAAS,CACvD,OAAO,eAAe,EACtB,+BAA+B,GAAG,cAAc,EAChD,8BAA8B,GAAG,aAAa,CAC/C,CAAC;AAIF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8CG;AACH,qBAAa,wBAAyB,SAAQ,cAAc,CAC1D,OAAO,eAAe,EACtB,6BAA6B,EAC7B,iCAAiC,CAClC;IACC;;;;;;;OAOG;gBACS,EACV,SAAS,EACT,KAAK,GACN,EAAE;QACD,SAAS,EAAE,iCAAiC,CAAC;QAC7C,KAAK,CAAC,EAAE,OAAO,CAAC,6BAA6B,CAAC,CAAC;KAChD;IAiBD;;;;;;;OAOG;IACH,aAAa,CAAC,OAAO,EAAE,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI;CAY9D"}
1
+ {"version":3,"file":"sample-petnames-controller.d.mts","sourceRoot":"","sources":["../src/sample-petnames-controller.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,wBAAwB,EACxB,0BAA0B,EAE3B,kCAAkC;AACnC,OAAO,EAAE,cAAc,EAAE,kCAAkC;AAE3D,OAAO,KAAK,EAAE,SAAS,EAAE,4BAA4B;AACrD,OAAO,KAAK,EAAE,GAAG,EAAE,wBAAwB;AAE3C,OAAO,KAAK,EAAE,qCAAqC,EAAE,6DAAyD;AAI9G;;;;GAIG;AACH,QAAA,MAAM,eAAe,6BAA6B,CAAC;AAInD;;GAEG;AACH,MAAM,MAAM,6BAA6B,GAAG;IAC1C;;;OAGG;IACH,wBAAwB,EAAE;QACxB,CAAC,OAAO,EAAE,GAAG,GAAG;YACd,CAAC,OAAO,EAAE,GAAG,GAAG,MAAM,CAAC;SACxB,CAAC;KACH,CAAC;CACH,CAAC;AAcF;;;;;;;GAOG;AACH,wBAAgB,iCAAiC,IAAI,6BAA6B,CAIjF;AAMD;;GAEG;AACH,MAAM,MAAM,sCAAsC,GAAG,wBAAwB,CAC3E,OAAO,eAAe,EACtB,6BAA6B,CAC9B,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,+BAA+B,GACvC,sCAAsC,GACtC,qCAAqC,CAAC;AAE1C;;GAEG;AACH,KAAK,cAAc,GAAG,KAAK,CAAC;AAE5B;;GAEG;AACH,MAAM,MAAM,wCAAwC,GAClD,0BAA0B,CACxB,OAAO,eAAe,EACtB,6BAA6B,CAC9B,CAAC;AAEJ;;GAEG;AACH,MAAM,MAAM,8BAA8B,GACxC,wCAAwC,CAAC;AAE3C;;;GAGG;AACH,KAAK,aAAa,GAAG,KAAK,CAAC;AAE3B;;;GAGG;AACH,MAAM,MAAM,iCAAiC,GAAG,SAAS,CACvD,OAAO,eAAe,EACtB,+BAA+B,GAAG,cAAc,EAChD,8BAA8B,GAAG,aAAa,CAC/C,CAAC;AAIF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8CG;AACH,qBAAa,wBAAyB,SAAQ,cAAc,CAC1D,OAAO,eAAe,EACtB,6BAA6B,EAC7B,iCAAiC,CAClC;IACC;;;;;;;OAOG;gBACS,EACV,SAAS,EACT,KAAK,GACN,EAAE;QACD,SAAS,EAAE,iCAAiC,CAAC;QAC7C,KAAK,CAAC,EAAE,OAAO,CAAC,6BAA6B,CAAC,CAAC;KAChD;IAiBD;;;;;;;OAOG;IACH,aAAa,CAAC,OAAO,EAAE,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI;CAY9D"}
@@ -1 +1 @@
1
- {"version":3,"file":"sample-petnames-controller.mjs","sourceRoot":"","sources":["../src/sample-petnames-controller.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,cAAc,EAAE,kCAAkC;AAC3D,OAAO,EAAE,gBAAgB,EAAE,mCAAmC;AAM9D,kBAAkB;AAElB;;;;GAIG;AACH,MAAM,eAAe,GAAG,0BA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iB,CAAC,GAAG,IAAI,CAAC;QACpE,CAAC,CAAC,CAAC;IACL,CAAC;CACF","sourcesContent":["import type {\n ControllerGetStateAction,\n ControllerStateChangeEvent,\n StateMetadata,\n} from '@metamask/base-controller';\nimport { BaseController } from '@metamask/base-controller';\nimport { isSafeDynamicKey } from '@metamask/controller-utils';\nimport type { Messenger } from '@metamask/messenger';\nimport type { Hex } from '@metamask/utils';\n\nimport type { SamplePetnamesControllerMethodActions } from './sample-petnames-controller-method-action-types.js';\n\n// === GENERAL ===\n\n/**\n * The name of the {@link SamplePetnamesController}, used to namespace the\n * controller's actions and events and to namespace the controller's state data\n * when composed with other controllers.\n */\nconst CONTROLLER_NAME = 'SamplePetnamesController';\n\n// === STATE ===\n\n/**\n * Describes the shape of the state object for {@link SamplePetnamesController}.\n */\nexport type SamplePetnamesControllerState = {\n /**\n * The registry of pet names, categorized by chain ID first and address\n * second.\n */\n namesByChainIdAndAddress: {\n [chainId: Hex]: {\n [address: Hex]: string;\n };\n };\n};\n\n/**\n * The metadata for each property in {@link SamplePetnamesControllerState}.\n */\nconst samplePetnamesControllerMetadata = {\n namesByChainIdAndAddress: {\n includeInDebugSnapshot: false,\n includeInStateLogs: true,\n persist: true,\n usedInUi: true,\n },\n} satisfies StateMetadata<SamplePetnamesControllerState>;\n\n/**\n * Constructs the default {@link SamplePetnamesController} state. This allows\n * consumers to provide a partial state object when initializing the controller\n * and also helps in constructing complete state objects for this controller in\n * tests.\n *\n * @returns The default {@link SamplePetnamesController} state.\n */\nexport function getDefaultPetnamesControllerState(): SamplePetnamesControllerState {\n return {\n namesByChainIdAndAddress: {},\n };\n}\n\n// === MESSENGER ===\n\nconst MESSENGER_EXPOSED_METHODS = ['assignPetname'] as const;\n\n/**\n * Retrieves the state of the {@link SamplePetnamesController}.\n */\nexport type SamplePetnamesControllerGetStateAction = ControllerGetStateAction<\n typeof CONTROLLER_NAME,\n SamplePetnamesControllerState\n>;\n\n/**\n * Actions that {@link SampleGasPricesMessenger} exposes to other consumers.\n */\nexport type SamplePetnamesControllerActions =\n | SamplePetnamesControllerGetStateAction\n | SamplePetnamesControllerMethodActions;\n\n/**\n * Actions from other messengers that {@link SampleGasPricesMessenger} calls.\n */\ntype AllowedActions = never;\n\n/**\n * Published when the state of {@link SamplePetnamesController} changes.\n */\nexport type SamplePetnamesControllerStateChangeEvent =\n ControllerStateChangeEvent<\n typeof CONTROLLER_NAME,\n SamplePetnamesControllerState\n >;\n\n/**\n * Events that {@link SampleGasPricesMessenger} exposes to other consumers.\n */\nexport type SamplePetnamesControllerEvents =\n SamplePetnamesControllerStateChangeEvent;\n\n/**\n * Events from other messengers that {@link SampleGasPricesMessenger} subscribes\n * to.\n */\ntype AllowedEvents = never;\n\n/**\n * The messenger restricted to actions and events accessed by\n * {@link SamplePetnamesController}.\n */\nexport type SamplePetnamesControllerMessenger = Messenger<\n typeof CONTROLLER_NAME,\n SamplePetnamesControllerActions | AllowedActions,\n SamplePetnamesControllerEvents | AllowedEvents\n>;\n\n// === CONTROLLER DEFINITION ===\n\n/**\n * `SamplePetnamesController` records user-provided nicknames for various\n * addresses on various chains.\n *\n * @example\n *\n * ``` ts\n * import { Messenger } from '@metamask/messenger';\n * import type {\n * SamplePetnamesControllerActions,\n * SamplePetnamesControllerEvents,\n * } from '@metamask/sample-controllers';\n *\n * const rootMessenger = new Messenger<\n * 'Root',\n * SamplePetnamesControllerActions,\n * SamplePetnamesControllerEvents\n * >({ namespace: 'Root' });\n * const samplePetnamesMessenger = new Messenger<\n * 'SamplePetnamesController',\n * SamplePetnamesControllerActions,\n * SamplePetnamesControllerEvents,\n * typeof rootMessenger,\n * >({\n * namespace: 'SamplePetnamesController',\n * parent: rootMessenger,\n * });\n * // Instantiate the controller to register its actions on the messenger\n * new SamplePetnamesController({\n * messenger: samplePetnamesMessenger,\n * });\n *\n * rootMessenger.call(\n * 'SamplePetnamesController:assignPetname',\n * [\n * '0x1',\n * '0xF57F855e17483B1f09bFec62783C9d3b6c8b3A99',\n * 'Primary Account',\n * ],\n * );\n * const samplePetnamesControllerState = await rootMessenger.call(\n * 'SamplePetnamesController:getState',\n * );\n * samplePetnamesControllerState.namesByChainIdAndAddress\n * // => { '0x1': { '0xF57F855e17483B1f09bFec62783C9d3b6c8b3A99': 'Primary Account' } }\n * ```\n */\nexport class SamplePetnamesController extends BaseController<\n typeof CONTROLLER_NAME,\n SamplePetnamesControllerState,\n SamplePetnamesControllerMessenger\n> {\n /**\n * Constructs a new {@link SamplePetnamesController}.\n *\n * @param args - The arguments to this controller.\n * @param args.messenger - The messenger suited for this controller.\n * @param args.state - The desired state with which to initialize this\n * controller. Missing properties will be filled in with defaults.\n */\n constructor({\n messenger,\n state,\n }: {\n messenger: SamplePetnamesControllerMessenger;\n state?: Partial<SamplePetnamesControllerState>;\n }) {\n super({\n messenger,\n metadata: samplePetnamesControllerMetadata,\n name: CONTROLLER_NAME,\n state: {\n ...getDefaultPetnamesControllerState(),\n ...state,\n },\n });\n\n this.messenger.registerMethodActionHandlers(\n this,\n MESSENGER_EXPOSED_METHODS,\n );\n }\n\n /**\n * Registers the given name with the given address (relative to the given\n * chain).\n *\n * @param chainId - The chain ID that the address belongs to.\n * @param address - The account address to name.\n * @param name - The name to assign to the address.\n */\n assignPetname(chainId: Hex, address: Hex, name: string): void {\n if (!isSafeDynamicKey(chainId)) {\n throw new Error('Invalid chain ID');\n }\n\n const normalizedAddress = address.toLowerCase() as Hex;\n\n this.update((state) => {\n state.namesByChainIdAndAddress[chainId] ??= {};\n state.namesByChainIdAndAddress[chainId][normalizedAddress] = name;\n });\n }\n}\n"]}
1
+ {"version":3,"file":"sample-petnames-controller.mjs","sourceRoot":"","sources":["../src/sample-petnames-controller.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,cAAc,EAAE,kCAAkC;AAC3D,OAAO,EAAE,gBAAgB,EAAE,mCAAmC;AAM9D,kBAAkB;AAElB;;;;GAIG;AACH,MAAM,eAAe,GAAG,0BAA0B,CAAC;AAmBnD;;GAEG;A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QACpE,CAAC,CAAC,CAAC;IACL,CAAC;CACF","sourcesContent":["import type {\n ControllerGetStateAction,\n ControllerStateChangeEvent,\n StateMetadata,\n} from '@metamask/base-controller';\nimport { BaseController } from '@metamask/base-controller';\nimport { isSafeDynamicKey } from '@metamask/controller-utils';\nimport type { Messenger } from '@metamask/messenger';\nimport type { Hex } from '@metamask/utils';\n\nimport type { SamplePetnamesControllerMethodActions } from './sample-petnames-controller-method-action-types';\n\n// === GENERAL ===\n\n/**\n * The name of the {@link SamplePetnamesController}, used to namespace the\n * controller's actions and events and to namespace the controller's state data\n * when composed with other controllers.\n */\nconst CONTROLLER_NAME = 'SamplePetnamesController';\n\n// === STATE ===\n\n/**\n * Describes the shape of the state object for {@link SamplePetnamesController}.\n */\nexport type SamplePetnamesControllerState = {\n /**\n * The registry of pet names, categorized by chain ID first and address\n * second.\n */\n namesByChainIdAndAddress: {\n [chainId: Hex]: {\n [address: Hex]: string;\n };\n };\n};\n\n/**\n * The metadata for each property in {@link SamplePetnamesControllerState}.\n */\nconst samplePetnamesControllerMetadata = {\n namesByChainIdAndAddress: {\n includeInDebugSnapshot: false,\n includeInStateLogs: true,\n persist: true,\n usedInUi: true,\n },\n} satisfies StateMetadata<SamplePetnamesControllerState>;\n\n/**\n * Constructs the default {@link SamplePetnamesController} state. This allows\n * consumers to provide a partial state object when initializing the controller\n * and also helps in constructing complete state objects for this controller in\n * tests.\n *\n * @returns The default {@link SamplePetnamesController} state.\n */\nexport function getDefaultPetnamesControllerState(): SamplePetnamesControllerState {\n return {\n namesByChainIdAndAddress: {},\n };\n}\n\n// === MESSENGER ===\n\nconst MESSENGER_EXPOSED_METHODS = ['assignPetname'] as const;\n\n/**\n * Retrieves the state of the {@link SamplePetnamesController}.\n */\nexport type SamplePetnamesControllerGetStateAction = ControllerGetStateAction<\n typeof CONTROLLER_NAME,\n SamplePetnamesControllerState\n>;\n\n/**\n * Actions that {@link SampleGasPricesMessenger} exposes to other consumers.\n */\nexport type SamplePetnamesControllerActions =\n | SamplePetnamesControllerGetStateAction\n | SamplePetnamesControllerMethodActions;\n\n/**\n * Actions from other messengers that {@link SampleGasPricesMessenger} calls.\n */\ntype AllowedActions = never;\n\n/**\n * Published when the state of {@link SamplePetnamesController} changes.\n */\nexport type SamplePetnamesControllerStateChangeEvent =\n ControllerStateChangeEvent<\n typeof CONTROLLER_NAME,\n SamplePetnamesControllerState\n >;\n\n/**\n * Events that {@link SampleGasPricesMessenger} exposes to other consumers.\n */\nexport type SamplePetnamesControllerEvents =\n SamplePetnamesControllerStateChangeEvent;\n\n/**\n * Events from other messengers that {@link SampleGasPricesMessenger} subscribes\n * to.\n */\ntype AllowedEvents = never;\n\n/**\n * The messenger restricted to actions and events accessed by\n * {@link SamplePetnamesController}.\n */\nexport type SamplePetnamesControllerMessenger = Messenger<\n typeof CONTROLLER_NAME,\n SamplePetnamesControllerActions | AllowedActions,\n SamplePetnamesControllerEvents | AllowedEvents\n>;\n\n// === CONTROLLER DEFINITION ===\n\n/**\n * `SamplePetnamesController` records user-provided nicknames for various\n * addresses on various chains.\n *\n * @example\n *\n * ``` ts\n * import { Messenger } from '@metamask/messenger';\n * import type {\n * SamplePetnamesControllerActions,\n * SamplePetnamesControllerEvents,\n * } from '@metamask/sample-controllers';\n *\n * const rootMessenger = new Messenger<\n * 'Root',\n * SamplePetnamesControllerActions,\n * SamplePetnamesControllerEvents\n * >({ namespace: 'Root' });\n * const samplePetnamesMessenger = new Messenger<\n * 'SamplePetnamesController',\n * SamplePetnamesControllerActions,\n * SamplePetnamesControllerEvents,\n * typeof rootMessenger,\n * >({\n * namespace: 'SamplePetnamesController',\n * parent: rootMessenger,\n * });\n * // Instantiate the controller to register its actions on the messenger\n * new SamplePetnamesController({\n * messenger: samplePetnamesMessenger,\n * });\n *\n * rootMessenger.call(\n * 'SamplePetnamesController:assignPetname',\n * [\n * '0x1',\n * '0xF57F855e17483B1f09bFec62783C9d3b6c8b3A99',\n * 'Primary Account',\n * ],\n * );\n * const samplePetnamesControllerState = await rootMessenger.call(\n * 'SamplePetnamesController:getState',\n * );\n * samplePetnamesControllerState.namesByChainIdAndAddress\n * // => { '0x1': { '0xF57F855e17483B1f09bFec62783C9d3b6c8b3A99': 'Primary Account' } }\n * ```\n */\nexport class SamplePetnamesController extends BaseController<\n typeof CONTROLLER_NAME,\n SamplePetnamesControllerState,\n SamplePetnamesControllerMessenger\n> {\n /**\n * Constructs a new {@link SamplePetnamesController}.\n *\n * @param args - The arguments to this controller.\n * @param args.messenger - The messenger suited for this controller.\n * @param args.state - The desired state with which to initialize this\n * controller. Missing properties will be filled in with defaults.\n */\n constructor({\n messenger,\n state,\n }: {\n messenger: SamplePetnamesControllerMessenger;\n state?: Partial<SamplePetnamesControllerState>;\n }) {\n super({\n messenger,\n metadata: samplePetnamesControllerMetadata,\n name: CONTROLLER_NAME,\n state: {\n ...getDefaultPetnamesControllerState(),\n ...state,\n },\n });\n\n this.messenger.registerMethodActionHandlers(\n this,\n MESSENGER_EXPOSED_METHODS,\n );\n }\n\n /**\n * Registers the given name with the given address (relative to the given\n * chain).\n *\n * @param chainId - The chain ID that the address belongs to.\n * @param address - The account address to name.\n * @param name - The name to assign to the address.\n */\n assignPetname(chainId: Hex, address: Hex, name: string): void {\n if (!isSafeDynamicKey(chainId)) {\n throw new Error('Invalid chain ID');\n }\n\n const normalizedAddress = address.toLowerCase() as Hex;\n\n this.update((state) => {\n state.namesByChainIdAndAddress[chainId] ??= {};\n state.namesByChainIdAndAddress[chainId][normalizedAddress] = name;\n });\n }\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@metamask-previews/sample-controllers",
3
- "version": "5.0.3-preview-ec4680201",
3
+ "version": "5.0.3-preview-40d5fb1e2",
4
4
  "description": "Sample package to illustrate best practices for controllers",
5
5
  "keywords": [
6
6
  "Ethereum",
@@ -46,8 +46,8 @@
46
46
  "changelog:validate": "../../scripts/validate-changelog.sh @metamask/sample-controllers",
47
47
  "lint:tsconfigs": "tsx ../../scripts/lint-tsconfigs/lint-tsconfigs.mts",
48
48
  "lint:tsconfigs:fix": "tsx ../../scripts/lint-tsconfigs/lint-tsconfigs.mts --fix",
49
- "messenger-action-types:check": "tsx ../../packages/messenger-cli/src/cli.ts --formatter oxfmt --esm --check",
50
- "messenger-action-types:generate": "tsx ../../packages/messenger-cli/src/cli.ts --formatter oxfmt --esm --generate",
49
+ "messenger-action-types:check": "tsx ../../packages/messenger-cli/src/cli.ts --formatter oxfmt --check",
50
+ "messenger-action-types:generate": "tsx ../../packages/messenger-cli/src/cli.ts --formatter oxfmt --generate",
51
51
  "since-latest-release": "../../scripts/since-latest-release.sh",
52
52
  "test": "NODE_OPTIONS=--experimental-vm-modules jest --reporters=jest-silent-reporter",
53
53
  "test:clean": "NODE_OPTIONS=--experimental-vm-modules jest --clearCache",
@@ -67,11 +67,11 @@
67
67
  "@metamask/auto-changelog": "^6.1.0",
68
68
  "@metamask/controller-utils": "^12.3.0",
69
69
  "@ts-bridge/cli": "^0.6.4",
70
- "@types/jest": "^30.0.0",
70
+ "@types/jest": "^29.5.14",
71
71
  "deepmerge": "^4.2.2",
72
- "jest": "^30.4.2",
72
+ "jest": "^29.7.0",
73
73
  "nock": "^13.3.1",
74
- "ts-jest": "^29.4.11",
74
+ "ts-jest": "^29.2.5",
75
75
  "tsx": "^4.20.5",
76
76
  "typedoc": "^0.25.13",
77
77
  "typedoc-plugin-missing-exports": "^2.0.0",