@metamask-previews/sample-controllers 5.0.6-preview-8bfa290fb → 6.0.0-preview-0a30e47
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.
- package/CHANGELOG.md +13 -1
- package/dist/{index.d.mts → index.d.ts} +10 -10
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +4 -0
- package/dist/{index.cjs.map → index.js.map} +1 -1
- package/dist/{sample-gas-prices-controller-method-action-types.d.cts → sample-gas-prices-controller-method-action-types.d.ts} +2 -2
- package/dist/sample-gas-prices-controller-method-action-types.d.ts.map +1 -0
- package/dist/{sample-gas-prices-controller-method-action-types.mjs → sample-gas-prices-controller-method-action-types.js} +1 -1
- package/dist/sample-gas-prices-controller-method-action-types.js.map +1 -0
- package/dist/{sample-gas-prices-controller.d.cts → sample-gas-prices-controller.d.ts} +8 -8
- package/dist/sample-gas-prices-controller.d.ts.map +1 -0
- package/dist/{sample-gas-prices-controller.mjs → sample-gas-prices-controller.js} +22 -29
- package/dist/sample-gas-prices-controller.js.map +1 -0
- package/dist/sample-gas-prices-service/{sample-gas-prices-service-method-action-types.d.cts → sample-gas-prices-service-method-action-types.d.ts} +2 -2
- package/dist/sample-gas-prices-service/sample-gas-prices-service-method-action-types.d.ts.map +1 -0
- package/dist/sample-gas-prices-service/{sample-gas-prices-service-method-action-types.mjs → sample-gas-prices-service-method-action-types.js} +1 -1
- package/dist/sample-gas-prices-service/sample-gas-prices-service-method-action-types.js.map +1 -0
- package/dist/sample-gas-prices-service/{sample-gas-prices-service.d.mts → sample-gas-prices-service.d.ts} +9 -9
- package/dist/sample-gas-prices-service/sample-gas-prices-service.d.ts.map +1 -0
- package/dist/sample-gas-prices-service/{sample-gas-prices-service.mjs → sample-gas-prices-service.js} +4 -4
- package/dist/sample-gas-prices-service/sample-gas-prices-service.js.map +1 -0
- package/dist/{sample-petnames-controller-method-action-types.d.cts → sample-petnames-controller-method-action-types.d.ts} +2 -2
- package/dist/sample-petnames-controller-method-action-types.d.ts.map +1 -0
- package/dist/{sample-petnames-controller-method-action-types.mjs → sample-petnames-controller-method-action-types.js} +1 -1
- package/dist/sample-petnames-controller-method-action-types.js.map +1 -0
- package/dist/{sample-petnames-controller.d.mts → sample-petnames-controller.d.ts} +6 -6
- package/dist/sample-petnames-controller.d.ts.map +1 -0
- package/dist/{sample-petnames-controller.mjs → sample-petnames-controller.js} +4 -5
- package/dist/sample-petnames-controller.js.map +1 -0
- package/package.json +17 -21
- package/dist/index.cjs +0 -12
- package/dist/index.d.cts +0 -10
- package/dist/index.d.cts.map +0 -1
- package/dist/index.d.mts.map +0 -1
- package/dist/index.mjs +0 -4
- package/dist/index.mjs.map +0 -1
- package/dist/sample-gas-prices-controller-method-action-types.cjs +0 -7
- package/dist/sample-gas-prices-controller-method-action-types.cjs.map +0 -1
- package/dist/sample-gas-prices-controller-method-action-types.d.cts.map +0 -1
- package/dist/sample-gas-prices-controller-method-action-types.d.mts +0 -21
- package/dist/sample-gas-prices-controller-method-action-types.d.mts.map +0 -1
- package/dist/sample-gas-prices-controller-method-action-types.mjs.map +0 -1
- package/dist/sample-gas-prices-controller.cjs +0 -179
- package/dist/sample-gas-prices-controller.cjs.map +0 -1
- package/dist/sample-gas-prices-controller.d.cts.map +0 -1
- package/dist/sample-gas-prices-controller.d.mts +0 -184
- package/dist/sample-gas-prices-controller.d.mts.map +0 -1
- package/dist/sample-gas-prices-controller.mjs.map +0 -1
- package/dist/sample-gas-prices-service/sample-gas-prices-service-method-action-types.cjs +0 -7
- package/dist/sample-gas-prices-service/sample-gas-prices-service-method-action-types.cjs.map +0 -1
- package/dist/sample-gas-prices-service/sample-gas-prices-service-method-action-types.d.cts.map +0 -1
- package/dist/sample-gas-prices-service/sample-gas-prices-service-method-action-types.d.mts +0 -21
- package/dist/sample-gas-prices-service/sample-gas-prices-service-method-action-types.d.mts.map +0 -1
- package/dist/sample-gas-prices-service/sample-gas-prices-service-method-action-types.mjs.map +0 -1
- package/dist/sample-gas-prices-service/sample-gas-prices-service.cjs +0 -121
- package/dist/sample-gas-prices-service/sample-gas-prices-service.cjs.map +0 -1
- package/dist/sample-gas-prices-service/sample-gas-prices-service.d.cts +0 -139
- package/dist/sample-gas-prices-service/sample-gas-prices-service.d.cts.map +0 -1
- package/dist/sample-gas-prices-service/sample-gas-prices-service.d.mts.map +0 -1
- package/dist/sample-gas-prices-service/sample-gas-prices-service.mjs.map +0 -1
- package/dist/sample-petnames-controller-method-action-types.cjs +0 -7
- package/dist/sample-petnames-controller-method-action-types.cjs.map +0 -1
- package/dist/sample-petnames-controller-method-action-types.d.cts.map +0 -1
- package/dist/sample-petnames-controller-method-action-types.d.mts +0 -22
- package/dist/sample-petnames-controller-method-action-types.d.mts.map +0 -1
- package/dist/sample-petnames-controller-method-action-types.mjs.map +0 -1
- package/dist/sample-petnames-controller.cjs +0 -130
- package/dist/sample-petnames-controller.cjs.map +0 -1
- package/dist/sample-petnames-controller.d.cts +0 -136
- package/dist/sample-petnames-controller.d.cts.map +0 -1
- package/dist/sample-petnames-controller.d.mts.map +0 -1
- package/dist/sample-petnames-controller.mjs.map +0 -1
package/dist/index.mjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
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 +0,0 @@
|
|
|
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 +0,0 @@
|
|
|
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,21 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This file is auto generated.
|
|
3
|
-
* Do not edit manually.
|
|
4
|
-
*/
|
|
5
|
-
import type { SampleGasPricesController } from "./sample-gas-prices-controller.mjs";
|
|
6
|
-
/**
|
|
7
|
-
* Fetches the latest gas prices for the given chain and persists them to
|
|
8
|
-
* state.
|
|
9
|
-
*
|
|
10
|
-
* @param args - The arguments to the function.
|
|
11
|
-
* @param args.chainId - The chain ID for which to fetch gas prices.
|
|
12
|
-
*/
|
|
13
|
-
export type SampleGasPricesControllerUpdateGasPricesAction = {
|
|
14
|
-
type: `SampleGasPricesController:updateGasPrices`;
|
|
15
|
-
handler: SampleGasPricesController['updateGasPrices'];
|
|
16
|
-
};
|
|
17
|
-
/**
|
|
18
|
-
* Union of all SampleGasPricesController action types.
|
|
19
|
-
*/
|
|
20
|
-
export type SampleGasPricesControllerMethodActions = SampleGasPricesControllerUpdateGasPricesAction;
|
|
21
|
-
//# sourceMappingURL=sample-gas-prices-controller-method-action-types.d.mts.map
|
|
@@ -1 +0,0 @@
|
|
|
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 +0,0 @@
|
|
|
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,179 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
3
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
4
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
5
|
-
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
6
|
-
};
|
|
7
|
-
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
8
|
-
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
9
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
10
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
11
|
-
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
12
|
-
};
|
|
13
|
-
var _SampleGasPricesController_instances, _SampleGasPricesController_selectedChainId, _SampleGasPricesController_onSelectedNetworkClientIdChange;
|
|
14
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.SampleGasPricesController = exports.getDefaultSampleGasPricesControllerState = void 0;
|
|
16
|
-
const base_controller_1 = require("@metamask/base-controller");
|
|
17
|
-
// === GENERAL ===
|
|
18
|
-
/**
|
|
19
|
-
* The name of the {@link SampleGasPricesController}, used to namespace the
|
|
20
|
-
* controller's actions and events and to namespace the controller's state data
|
|
21
|
-
* when composed with other controllers.
|
|
22
|
-
*/
|
|
23
|
-
const CONTROLLER_NAME = 'SampleGasPricesController';
|
|
24
|
-
/**
|
|
25
|
-
* The metadata for each property in {@link SampleGasPricesControllerState}.
|
|
26
|
-
*/
|
|
27
|
-
const gasPricesControllerMetadata = {
|
|
28
|
-
gasPricesByChainId: {
|
|
29
|
-
includeInDebugSnapshot: false,
|
|
30
|
-
includeInStateLogs: true,
|
|
31
|
-
persist: true,
|
|
32
|
-
usedInUi: true,
|
|
33
|
-
},
|
|
34
|
-
};
|
|
35
|
-
/**
|
|
36
|
-
* Constructs the default {@link SampleGasPricesController} state. This allows
|
|
37
|
-
* consumers to provide a partial state object when initializing the controller
|
|
38
|
-
* and also helps in constructing complete state objects for this controller in
|
|
39
|
-
* tests.
|
|
40
|
-
*
|
|
41
|
-
* @returns The default {@link SampleGasPricesController} state.
|
|
42
|
-
*/
|
|
43
|
-
function getDefaultSampleGasPricesControllerState() {
|
|
44
|
-
return {
|
|
45
|
-
gasPricesByChainId: {},
|
|
46
|
-
};
|
|
47
|
-
}
|
|
48
|
-
exports.getDefaultSampleGasPricesControllerState = getDefaultSampleGasPricesControllerState;
|
|
49
|
-
// === MESSENGER ===
|
|
50
|
-
const MESSENGER_EXPOSED_METHODS = ['updateGasPrices'];
|
|
51
|
-
// === CONTROLLER DEFINITION ===
|
|
52
|
-
/**
|
|
53
|
-
* `SampleGasPricesController` fetches and persists gas prices for various chains.
|
|
54
|
-
*
|
|
55
|
-
* @example
|
|
56
|
-
*
|
|
57
|
-
* ``` ts
|
|
58
|
-
* import { Messenger } from '@metamask/messenger';
|
|
59
|
-
* import type {
|
|
60
|
-
* NetworkControllerActions,
|
|
61
|
-
* NetworkControllerEvents,
|
|
62
|
-
* } from '@metamask/network-controller';
|
|
63
|
-
* import type {
|
|
64
|
-
* SampleGasPricesControllerActions,
|
|
65
|
-
* SampleGasPricesControllerEvents,
|
|
66
|
-
* SampleGasPricesServiceActions,
|
|
67
|
-
* SampleGasPricesServiceEvents,
|
|
68
|
-
* } from '@metamask/sample-controllers';
|
|
69
|
-
* import {
|
|
70
|
-
* SampleGasPricesController,
|
|
71
|
-
* SampleGasPricesService,
|
|
72
|
-
* selectGasPrices,
|
|
73
|
-
* } from '@metamask/sample-controllers';
|
|
74
|
-
*
|
|
75
|
-
* const rootMessenger = new Messenger<
|
|
76
|
-
* 'Root',
|
|
77
|
-
* SampleGasPricesServiceActions
|
|
78
|
-
* | SampleGasPricesControllerActions
|
|
79
|
-
* | NetworkControllerActions,
|
|
80
|
-
* SampleGasPricesServiceEvents
|
|
81
|
-
* | SampleGasPricesControllerEvents
|
|
82
|
-
* | NetworkControllerEvents
|
|
83
|
-
* >({ namespace: 'Root' });
|
|
84
|
-
* const gasPricesServiceMessenger = new Messenger<
|
|
85
|
-
* 'SampleGasPricesService',
|
|
86
|
-
* SampleGasPricesServiceActions,
|
|
87
|
-
* SampleGasPricesServiceEvents,
|
|
88
|
-
* typeof rootMessenger,
|
|
89
|
-
* >({
|
|
90
|
-
* namespace: 'SampleGasPricesService',
|
|
91
|
-
* parent: rootMessenger,
|
|
92
|
-
* });
|
|
93
|
-
* // Instantiate the service to register its actions on the messenger
|
|
94
|
-
* new SampleGasPricesService({
|
|
95
|
-
* messenger: gasPricesServiceMessenger,
|
|
96
|
-
* // We assume you're using this in the browser.
|
|
97
|
-
* fetch,
|
|
98
|
-
* });
|
|
99
|
-
* const gasPricesControllerMessenger = new Messenger<
|
|
100
|
-
* 'SampleGasPricesController',
|
|
101
|
-
* SampleGasPricesControllerActions | NetworkControllerGetNetworkClientByIdAction,
|
|
102
|
-
* SampleGasPricesControllerEvents | NetworkControllerStateChangeEvent,
|
|
103
|
-
* typeof rootMessenger,
|
|
104
|
-
* >({
|
|
105
|
-
* namespace: 'SampleGasPricesController',
|
|
106
|
-
* parent: rootMessenger,
|
|
107
|
-
* });
|
|
108
|
-
* // Instantiate the controller to register its actions on the messenger
|
|
109
|
-
* new SampleGasPricesController({
|
|
110
|
-
* messenger: gasPricesControllerMessenger,
|
|
111
|
-
* });
|
|
112
|
-
*
|
|
113
|
-
* // Later...
|
|
114
|
-
* await rootMessenger.call(
|
|
115
|
-
* 'SampleGasPricesController:updateGasPrices',
|
|
116
|
-
* { chainId: '0x42' },
|
|
117
|
-
* );
|
|
118
|
-
* const gasPricesControllerState = await rootMessenger.call(
|
|
119
|
-
* 'SampleGasPricesController:getState',
|
|
120
|
-
* );
|
|
121
|
-
* gasPricesControllerState.gasPricesByChainId
|
|
122
|
-
* // => { '0x42': { low: 5, average: 10, high: 15, fetchedDate: '2024-01-02T00:00:00.000Z' } }
|
|
123
|
-
* ```
|
|
124
|
-
*/
|
|
125
|
-
class SampleGasPricesController extends base_controller_1.BaseController {
|
|
126
|
-
/**
|
|
127
|
-
* Constructs a new {@link SampleGasPricesController}.
|
|
128
|
-
*
|
|
129
|
-
* @param args - The constructor arguments.
|
|
130
|
-
* @param args.messenger - The messenger suited for this controller.
|
|
131
|
-
* @param args.state - The desired state with which to initialize this
|
|
132
|
-
* controller. Missing properties will be filled in with defaults.
|
|
133
|
-
*/
|
|
134
|
-
constructor({ messenger, state, }) {
|
|
135
|
-
super({
|
|
136
|
-
messenger,
|
|
137
|
-
metadata: gasPricesControllerMetadata,
|
|
138
|
-
name: CONTROLLER_NAME,
|
|
139
|
-
state: {
|
|
140
|
-
...getDefaultSampleGasPricesControllerState(),
|
|
141
|
-
...state,
|
|
142
|
-
},
|
|
143
|
-
});
|
|
144
|
-
_SampleGasPricesController_instances.add(this);
|
|
145
|
-
/**
|
|
146
|
-
* The globally selected chain ID.
|
|
147
|
-
*/
|
|
148
|
-
_SampleGasPricesController_selectedChainId.set(this, void 0);
|
|
149
|
-
this.messenger.registerMethodActionHandlers(this, MESSENGER_EXPOSED_METHODS);
|
|
150
|
-
this.messenger.subscribe('NetworkController:stateChange', __classPrivateFieldGet(this, _SampleGasPricesController_instances, "m", _SampleGasPricesController_onSelectedNetworkClientIdChange).bind(this), (networkControllerState) => networkControllerState.selectedNetworkClientId);
|
|
151
|
-
}
|
|
152
|
-
/**
|
|
153
|
-
* Fetches the latest gas prices for the given chain and persists them to
|
|
154
|
-
* state.
|
|
155
|
-
*
|
|
156
|
-
* @param args - The arguments to the function.
|
|
157
|
-
* @param args.chainId - The chain ID for which to fetch gas prices.
|
|
158
|
-
*/
|
|
159
|
-
async updateGasPrices({ chainId }) {
|
|
160
|
-
const gasPricesResponse = await this.messenger.call('SampleGasPricesService:fetchGasPrices', chainId);
|
|
161
|
-
this.update((state) => {
|
|
162
|
-
state.gasPricesByChainId[chainId] = {
|
|
163
|
-
...gasPricesResponse,
|
|
164
|
-
fetchedDate: new Date().toISOString(),
|
|
165
|
-
};
|
|
166
|
-
});
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
exports.SampleGasPricesController = SampleGasPricesController;
|
|
170
|
-
_SampleGasPricesController_selectedChainId = new WeakMap(), _SampleGasPricesController_instances = new WeakSet(), _SampleGasPricesController_onSelectedNetworkClientIdChange = function _SampleGasPricesController_onSelectedNetworkClientIdChange(selectedNetworkClientId) {
|
|
171
|
-
const { configuration: { chainId }, } = this.messenger.call('NetworkController:getNetworkClientById', selectedNetworkClientId);
|
|
172
|
-
if (chainId !== __classPrivateFieldGet(this, _SampleGasPricesController_selectedChainId, "f")) {
|
|
173
|
-
__classPrivateFieldSet(this, _SampleGasPricesController_selectedChainId, chainId, "f");
|
|
174
|
-
this.updateGasPrices({ chainId }).catch((error) => {
|
|
175
|
-
this.messenger.captureException?.(error);
|
|
176
|
-
});
|
|
177
|
-
}
|
|
178
|
-
};
|
|
179
|
-
//# sourceMappingURL=sample-gas-prices-controller.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
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;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'@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 +0,0 @@
|
|
|
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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jD,+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,184 +0,0 @@
|
|
|
1
|
-
import type { ControllerGetStateAction, ControllerStateChangeEvent } from "@metamask/base-controller";
|
|
2
|
-
import { BaseController } from "@metamask/base-controller";
|
|
3
|
-
import type { Messenger } from "@metamask/messenger";
|
|
4
|
-
import type { NetworkControllerGetNetworkClientByIdAction, NetworkControllerStateChangeEvent } from "@metamask/network-controller";
|
|
5
|
-
import type { Hex } from "@metamask/utils";
|
|
6
|
-
import type { SampleGasPricesControllerMethodActions } from "./sample-gas-prices-controller-method-action-types.mjs";
|
|
7
|
-
import type { SampleGasPricesServiceFetchGasPricesAction } from "./sample-gas-prices-service/sample-gas-prices-service-method-action-types.mjs";
|
|
8
|
-
/**
|
|
9
|
-
* The name of the {@link SampleGasPricesController}, used to namespace the
|
|
10
|
-
* controller's actions and events and to namespace the controller's state data
|
|
11
|
-
* when composed with other controllers.
|
|
12
|
-
*/
|
|
13
|
-
declare const CONTROLLER_NAME = "SampleGasPricesController";
|
|
14
|
-
/**
|
|
15
|
-
* The collection of gas price data fetched periodically.
|
|
16
|
-
*/
|
|
17
|
-
type GasPrices = {
|
|
18
|
-
/**
|
|
19
|
-
* The total estimated gas in the "low" bucket.
|
|
20
|
-
*/
|
|
21
|
-
low: number;
|
|
22
|
-
/**
|
|
23
|
-
* The total estimated gas in the "average" bucket.
|
|
24
|
-
*/
|
|
25
|
-
average: number;
|
|
26
|
-
/**
|
|
27
|
-
* The total estimated gas in the "high" bucket.
|
|
28
|
-
*/
|
|
29
|
-
high: number;
|
|
30
|
-
/**
|
|
31
|
-
* The date/time (in ISO-8601 format) when prices were fetched.
|
|
32
|
-
*/
|
|
33
|
-
fetchedDate: string;
|
|
34
|
-
};
|
|
35
|
-
/**
|
|
36
|
-
* Describes the shape of the state object for {@link SampleGasPricesController}.
|
|
37
|
-
*/
|
|
38
|
-
export type SampleGasPricesControllerState = {
|
|
39
|
-
/**
|
|
40
|
-
* Fetched gas prices categorized by chain ID.
|
|
41
|
-
*/
|
|
42
|
-
gasPricesByChainId: {
|
|
43
|
-
[chainId: Hex]: GasPrices;
|
|
44
|
-
};
|
|
45
|
-
};
|
|
46
|
-
/**
|
|
47
|
-
* Constructs the default {@link SampleGasPricesController} state. This allows
|
|
48
|
-
* consumers to provide a partial state object when initializing the controller
|
|
49
|
-
* and also helps in constructing complete state objects for this controller in
|
|
50
|
-
* tests.
|
|
51
|
-
*
|
|
52
|
-
* @returns The default {@link SampleGasPricesController} state.
|
|
53
|
-
*/
|
|
54
|
-
export declare function getDefaultSampleGasPricesControllerState(): SampleGasPricesControllerState;
|
|
55
|
-
/**
|
|
56
|
-
* Retrieves the state of the {@link SampleGasPricesController}.
|
|
57
|
-
*/
|
|
58
|
-
export type SampleGasPricesControllerGetStateAction = ControllerGetStateAction<typeof CONTROLLER_NAME, SampleGasPricesControllerState>;
|
|
59
|
-
/**
|
|
60
|
-
* Actions that {@link SampleGasPricesMessenger} exposes to other consumers.
|
|
61
|
-
*/
|
|
62
|
-
export type SampleGasPricesControllerActions = SampleGasPricesControllerGetStateAction | SampleGasPricesControllerMethodActions;
|
|
63
|
-
/**
|
|
64
|
-
* Actions from other messengers that {@link SampleGasPricesMessenger} calls.
|
|
65
|
-
*/
|
|
66
|
-
type AllowedActions = NetworkControllerGetNetworkClientByIdAction | SampleGasPricesServiceFetchGasPricesAction;
|
|
67
|
-
/**
|
|
68
|
-
* Published when the state of {@link SampleGasPricesController} changes.
|
|
69
|
-
*/
|
|
70
|
-
export type SampleGasPricesControllerStateChangeEvent = ControllerStateChangeEvent<typeof CONTROLLER_NAME, SampleGasPricesControllerState>;
|
|
71
|
-
/**
|
|
72
|
-
* Events that {@link SampleGasPricesMessenger} exposes to other consumers.
|
|
73
|
-
*/
|
|
74
|
-
export type SampleGasPricesControllerEvents = SampleGasPricesControllerStateChangeEvent;
|
|
75
|
-
/**
|
|
76
|
-
* Events from other messengers that {@link SampleGasPricesMessenger} subscribes
|
|
77
|
-
* to.
|
|
78
|
-
*/
|
|
79
|
-
type AllowedEvents = NetworkControllerStateChangeEvent;
|
|
80
|
-
/**
|
|
81
|
-
* The messenger restricted to actions and events accessed by
|
|
82
|
-
* {@link SampleGasPricesController}.
|
|
83
|
-
*/
|
|
84
|
-
export type SampleGasPricesControllerMessenger = Messenger<typeof CONTROLLER_NAME, SampleGasPricesControllerActions | AllowedActions, SampleGasPricesControllerEvents | AllowedEvents>;
|
|
85
|
-
/**
|
|
86
|
-
* `SampleGasPricesController` fetches and persists gas prices for various chains.
|
|
87
|
-
*
|
|
88
|
-
* @example
|
|
89
|
-
*
|
|
90
|
-
* ``` ts
|
|
91
|
-
* import { Messenger } from '@metamask/messenger';
|
|
92
|
-
* import type {
|
|
93
|
-
* NetworkControllerActions,
|
|
94
|
-
* NetworkControllerEvents,
|
|
95
|
-
* } from '@metamask/network-controller';
|
|
96
|
-
* import type {
|
|
97
|
-
* SampleGasPricesControllerActions,
|
|
98
|
-
* SampleGasPricesControllerEvents,
|
|
99
|
-
* SampleGasPricesServiceActions,
|
|
100
|
-
* SampleGasPricesServiceEvents,
|
|
101
|
-
* } from '@metamask/sample-controllers';
|
|
102
|
-
* import {
|
|
103
|
-
* SampleGasPricesController,
|
|
104
|
-
* SampleGasPricesService,
|
|
105
|
-
* selectGasPrices,
|
|
106
|
-
* } from '@metamask/sample-controllers';
|
|
107
|
-
*
|
|
108
|
-
* const rootMessenger = new Messenger<
|
|
109
|
-
* 'Root',
|
|
110
|
-
* SampleGasPricesServiceActions
|
|
111
|
-
* | SampleGasPricesControllerActions
|
|
112
|
-
* | NetworkControllerActions,
|
|
113
|
-
* SampleGasPricesServiceEvents
|
|
114
|
-
* | SampleGasPricesControllerEvents
|
|
115
|
-
* | NetworkControllerEvents
|
|
116
|
-
* >({ namespace: 'Root' });
|
|
117
|
-
* const gasPricesServiceMessenger = new Messenger<
|
|
118
|
-
* 'SampleGasPricesService',
|
|
119
|
-
* SampleGasPricesServiceActions,
|
|
120
|
-
* SampleGasPricesServiceEvents,
|
|
121
|
-
* typeof rootMessenger,
|
|
122
|
-
* >({
|
|
123
|
-
* namespace: 'SampleGasPricesService',
|
|
124
|
-
* parent: rootMessenger,
|
|
125
|
-
* });
|
|
126
|
-
* // Instantiate the service to register its actions on the messenger
|
|
127
|
-
* new SampleGasPricesService({
|
|
128
|
-
* messenger: gasPricesServiceMessenger,
|
|
129
|
-
* // We assume you're using this in the browser.
|
|
130
|
-
* fetch,
|
|
131
|
-
* });
|
|
132
|
-
* const gasPricesControllerMessenger = new Messenger<
|
|
133
|
-
* 'SampleGasPricesController',
|
|
134
|
-
* SampleGasPricesControllerActions | NetworkControllerGetNetworkClientByIdAction,
|
|
135
|
-
* SampleGasPricesControllerEvents | NetworkControllerStateChangeEvent,
|
|
136
|
-
* typeof rootMessenger,
|
|
137
|
-
* >({
|
|
138
|
-
* namespace: 'SampleGasPricesController',
|
|
139
|
-
* parent: rootMessenger,
|
|
140
|
-
* });
|
|
141
|
-
* // Instantiate the controller to register its actions on the messenger
|
|
142
|
-
* new SampleGasPricesController({
|
|
143
|
-
* messenger: gasPricesControllerMessenger,
|
|
144
|
-
* });
|
|
145
|
-
*
|
|
146
|
-
* // Later...
|
|
147
|
-
* await rootMessenger.call(
|
|
148
|
-
* 'SampleGasPricesController:updateGasPrices',
|
|
149
|
-
* { chainId: '0x42' },
|
|
150
|
-
* );
|
|
151
|
-
* const gasPricesControllerState = await rootMessenger.call(
|
|
152
|
-
* 'SampleGasPricesController:getState',
|
|
153
|
-
* );
|
|
154
|
-
* gasPricesControllerState.gasPricesByChainId
|
|
155
|
-
* // => { '0x42': { low: 5, average: 10, high: 15, fetchedDate: '2024-01-02T00:00:00.000Z' } }
|
|
156
|
-
* ```
|
|
157
|
-
*/
|
|
158
|
-
export declare class SampleGasPricesController extends BaseController<typeof CONTROLLER_NAME, SampleGasPricesControllerState, SampleGasPricesControllerMessenger> {
|
|
159
|
-
#private;
|
|
160
|
-
/**
|
|
161
|
-
* Constructs a new {@link SampleGasPricesController}.
|
|
162
|
-
*
|
|
163
|
-
* @param args - The constructor arguments.
|
|
164
|
-
* @param args.messenger - The messenger suited for this controller.
|
|
165
|
-
* @param args.state - The desired state with which to initialize this
|
|
166
|
-
* controller. Missing properties will be filled in with defaults.
|
|
167
|
-
*/
|
|
168
|
-
constructor({ messenger, state, }: {
|
|
169
|
-
messenger: SampleGasPricesControllerMessenger;
|
|
170
|
-
state?: Partial<SampleGasPricesControllerState>;
|
|
171
|
-
});
|
|
172
|
-
/**
|
|
173
|
-
* Fetches the latest gas prices for the given chain and persists them to
|
|
174
|
-
* state.
|
|
175
|
-
*
|
|
176
|
-
* @param args - The arguments to the function.
|
|
177
|
-
* @param args.chainId - The chain ID for which to fetch gas prices.
|
|
178
|
-
*/
|
|
179
|
-
updateGasPrices({ chainId }: {
|
|
180
|
-
chainId: Hex;
|
|
181
|
-
}): Promise<void>;
|
|
182
|
-
}
|
|
183
|
-
export {};
|
|
184
|
-
//# sourceMappingURL=sample-gas-prices-controller.d.mts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"sample-gas-prices-controller.d.mts","sourceRoot":"","sources":["../src/sample-gas-prices-controller.ts"],"names":[],"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AC;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 +0,0 @@
|
|
|
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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,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"]}
|
package/dist/sample-gas-prices-service/sample-gas-prices-service-method-action-types.cjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
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"]}
|
package/dist/sample-gas-prices-service/sample-gas-prices-service-method-action-types.d.cts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
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,21 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This file is auto generated.
|
|
3
|
-
* Do not edit manually.
|
|
4
|
-
*/
|
|
5
|
-
import type { SampleGasPricesService } from "./sample-gas-prices-service.mjs";
|
|
6
|
-
/**
|
|
7
|
-
* Makes a request to the API in order to retrieve gas prices for a particular
|
|
8
|
-
* chain.
|
|
9
|
-
*
|
|
10
|
-
* @param chainId - The chain ID for which you want to fetch gas prices.
|
|
11
|
-
* @returns The gas prices for the given chain.
|
|
12
|
-
*/
|
|
13
|
-
export type SampleGasPricesServiceFetchGasPricesAction = {
|
|
14
|
-
type: `SampleGasPricesService:fetchGasPrices`;
|
|
15
|
-
handler: SampleGasPricesService['fetchGasPrices'];
|
|
16
|
-
};
|
|
17
|
-
/**
|
|
18
|
-
* Union of all SampleGasPricesService action types.
|
|
19
|
-
*/
|
|
20
|
-
export type SampleGasPricesServiceMethodActions = SampleGasPricesServiceFetchGasPricesAction;
|
|
21
|
-
//# sourceMappingURL=sample-gas-prices-service-method-action-types.d.mts.map
|
package/dist/sample-gas-prices-service/sample-gas-prices-service-method-action-types.d.mts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
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"}
|
package/dist/sample-gas-prices-service/sample-gas-prices-service-method-action-types.mjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
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"]}
|