@metamask-previews/sample-controllers 1.0.0-preview-aa8c4291 → 1.0.0-preview-e821953
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 +23 -1
- package/dist/index.cjs +5 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +7 -3
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +7 -3
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +3 -3
- package/dist/index.mjs.map +1 -1
- package/dist/sample-gas-prices-controller-method-action-types.cjs +7 -0
- package/dist/sample-gas-prices-controller-method-action-types.cjs.map +1 -0
- package/dist/sample-gas-prices-controller-method-action-types.d.cts +21 -0
- package/dist/sample-gas-prices-controller-method-action-types.d.cts.map +1 -0
- package/dist/sample-gas-prices-controller-method-action-types.d.mts +21 -0
- package/dist/sample-gas-prices-controller-method-action-types.d.mts.map +1 -0
- package/dist/sample-gas-prices-controller-method-action-types.mjs +6 -0
- package/dist/sample-gas-prices-controller-method-action-types.mjs.map +1 -0
- package/dist/sample-gas-prices-controller.cjs +77 -39
- package/dist/sample-gas-prices-controller.cjs.map +1 -1
- package/dist/sample-gas-prices-controller.d.cts +74 -59
- package/dist/sample-gas-prices-controller.d.cts.map +1 -1
- package/dist/sample-gas-prices-controller.d.mts +74 -59
- package/dist/sample-gas-prices-controller.d.mts.map +1 -1
- package/dist/sample-gas-prices-controller.mjs +77 -39
- package/dist/sample-gas-prices-controller.mjs.map +1 -1
- package/dist/sample-gas-prices-service/sample-gas-prices-service-method-action-types.cjs +7 -0
- package/dist/sample-gas-prices-service/sample-gas-prices-service-method-action-types.cjs.map +1 -0
- package/dist/sample-gas-prices-service/sample-gas-prices-service-method-action-types.d.cts +21 -0
- package/dist/sample-gas-prices-service/sample-gas-prices-service-method-action-types.d.cts.map +1 -0
- package/dist/sample-gas-prices-service/sample-gas-prices-service-method-action-types.d.mts +21 -0
- package/dist/sample-gas-prices-service/sample-gas-prices-service-method-action-types.d.mts.map +1 -0
- package/dist/sample-gas-prices-service/sample-gas-prices-service-method-action-types.mjs +6 -0
- package/dist/sample-gas-prices-service/sample-gas-prices-service-method-action-types.mjs.map +1 -0
- package/dist/sample-gas-prices-service/sample-gas-prices-service.cjs +135 -29
- package/dist/sample-gas-prices-service/sample-gas-prices-service.cjs.map +1 -1
- package/dist/sample-gas-prices-service/sample-gas-prices-service.d.cts +122 -28
- package/dist/sample-gas-prices-service/sample-gas-prices-service.d.cts.map +1 -1
- package/dist/sample-gas-prices-service/sample-gas-prices-service.d.mts +122 -28
- package/dist/sample-gas-prices-service/sample-gas-prices-service.d.mts.map +1 -1
- package/dist/sample-gas-prices-service/sample-gas-prices-service.mjs +134 -28
- package/dist/sample-gas-prices-service/sample-gas-prices-service.mjs.map +1 -1
- package/dist/sample-petnames-controller-method-action-types.cjs +7 -0
- package/dist/sample-petnames-controller-method-action-types.cjs.map +1 -0
- package/dist/sample-petnames-controller-method-action-types.d.cts +22 -0
- package/dist/sample-petnames-controller-method-action-types.d.cts.map +1 -0
- package/dist/sample-petnames-controller-method-action-types.d.mts +22 -0
- package/dist/sample-petnames-controller-method-action-types.d.mts.map +1 -0
- package/dist/sample-petnames-controller-method-action-types.mjs +6 -0
- package/dist/sample-petnames-controller-method-action-types.mjs.map +1 -0
- package/dist/sample-petnames-controller.cjs +24 -13
- package/dist/sample-petnames-controller.cjs.map +1 -1
- package/dist/sample-petnames-controller.d.cts +38 -23
- package/dist/sample-petnames-controller.d.cts.map +1 -1
- package/dist/sample-petnames-controller.d.mts +38 -23
- package/dist/sample-petnames-controller.d.mts.map +1 -1
- package/dist/sample-petnames-controller.mjs +23 -13
- package/dist/sample-petnames-controller.mjs.map +1 -1
- package/package.json +2 -1
- package/dist/network-controller-types.cjs +0 -20
- package/dist/network-controller-types.cjs.map +0 -1
- package/dist/network-controller-types.d.cts +0 -34
- package/dist/network-controller-types.d.cts.map +0 -1
- package/dist/network-controller-types.d.mts +0 -34
- package/dist/network-controller-types.d.mts.map +0 -1
- package/dist/network-controller-types.mjs +0 -16
- package/dist/network-controller-types.mjs.map +0 -1
- package/dist/sample-gas-prices-service/index.cjs +0 -6
- package/dist/sample-gas-prices-service/index.cjs.map +0 -1
- package/dist/sample-gas-prices-service/index.d.cts +0 -3
- package/dist/sample-gas-prices-service/index.d.cts.map +0 -1
- package/dist/sample-gas-prices-service/index.d.mts +0 -3
- package/dist/sample-gas-prices-service/index.d.mts.map +0 -1
- package/dist/sample-gas-prices-service/index.mjs +0 -2
- package/dist/sample-gas-prices-service/index.mjs.map +0 -1
- package/dist/sample-gas-prices-service/sample-abstract-gas-prices-service.cjs +0 -3
- package/dist/sample-gas-prices-service/sample-abstract-gas-prices-service.cjs.map +0 -1
- package/dist/sample-gas-prices-service/sample-abstract-gas-prices-service.d.cts +0 -7
- package/dist/sample-gas-prices-service/sample-abstract-gas-prices-service.d.cts.map +0 -1
- package/dist/sample-gas-prices-service/sample-abstract-gas-prices-service.d.mts +0 -7
- package/dist/sample-gas-prices-service/sample-abstract-gas-prices-service.d.mts.map +0 -1
- package/dist/sample-gas-prices-service/sample-abstract-gas-prices-service.mjs +0 -2
- package/dist/sample-gas-prices-service/sample-abstract-gas-prices-service.mjs.map +0 -1
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { ControllerGetStateAction, ControllerStateChangeEvent, RestrictedMessenger } from "@metamask/base-controller";
|
|
2
2
|
import { BaseController } from "@metamask/base-controller";
|
|
3
3
|
import type { Hex } from "@metamask/utils";
|
|
4
|
+
import type { SamplePetnamesControllerMethodActions } from "./sample-petnames-controller-method-action-types.cjs";
|
|
4
5
|
/**
|
|
5
6
|
* The name of the {@link SamplePetnamesController}, used to namespace the
|
|
6
7
|
* controller's actions and events and to namespace the controller's state data
|
|
@@ -22,40 +23,47 @@ export type SamplePetnamesControllerState = {
|
|
|
22
23
|
};
|
|
23
24
|
};
|
|
24
25
|
/**
|
|
25
|
-
*
|
|
26
|
-
*
|
|
26
|
+
* Constructs the default {@link SamplePetnamesController} state. This allows
|
|
27
|
+
* consumers to provide a partial state object when initializing the controller
|
|
28
|
+
* and also helps in constructing complete state objects for this controller in
|
|
29
|
+
* tests.
|
|
30
|
+
*
|
|
31
|
+
* @returns The default {@link SamplePetnamesController} state.
|
|
32
|
+
*/
|
|
33
|
+
export declare function getDefaultPetnamesControllerState(): SamplePetnamesControllerState;
|
|
34
|
+
/**
|
|
35
|
+
* Retrieves the state of the {@link SamplePetnamesController}.
|
|
27
36
|
*/
|
|
28
37
|
export type SamplePetnamesControllerGetStateAction = ControllerGetStateAction<typeof controllerName, SamplePetnamesControllerState>;
|
|
29
38
|
/**
|
|
30
|
-
*
|
|
31
|
-
* externally.
|
|
39
|
+
* Actions that {@link SampleGasPricesMessenger} exposes to other consumers.
|
|
32
40
|
*/
|
|
33
|
-
export type SamplePetnamesControllerActions = SamplePetnamesControllerGetStateAction;
|
|
41
|
+
export type SamplePetnamesControllerActions = SamplePetnamesControllerGetStateAction | SamplePetnamesControllerMethodActions;
|
|
34
42
|
/**
|
|
35
|
-
*
|
|
43
|
+
* Actions from other messengers that {@link SampleGasPricesMessenger} calls.
|
|
36
44
|
*/
|
|
37
45
|
type AllowedActions = never;
|
|
38
46
|
/**
|
|
39
|
-
*
|
|
47
|
+
* Published when the state of {@link SamplePetnamesController} changes.
|
|
40
48
|
*/
|
|
41
49
|
export type SamplePetnamesControllerStateChangeEvent = ControllerStateChangeEvent<typeof controllerName, SamplePetnamesControllerState>;
|
|
42
50
|
/**
|
|
43
|
-
*
|
|
44
|
-
* externally.
|
|
51
|
+
* Events that {@link SampleGasPricesMessenger} exposes to other consumers.
|
|
45
52
|
*/
|
|
46
53
|
export type SamplePetnamesControllerEvents = SamplePetnamesControllerStateChangeEvent;
|
|
47
54
|
/**
|
|
48
|
-
*
|
|
55
|
+
* Events from other messengers that {@link SampleGasPricesMessenger} subscribes
|
|
56
|
+
* to.
|
|
49
57
|
*/
|
|
50
58
|
type AllowedEvents = never;
|
|
51
59
|
/**
|
|
52
|
-
* The messenger
|
|
60
|
+
* The messenger restricted to actions and events accessed by
|
|
53
61
|
* {@link SamplePetnamesController}.
|
|
54
62
|
*/
|
|
55
63
|
export type SamplePetnamesControllerMessenger = RestrictedMessenger<typeof controllerName, SamplePetnamesControllerActions | AllowedActions, SamplePetnamesControllerEvents | AllowedEvents, AllowedActions['type'], AllowedEvents['type']>;
|
|
56
64
|
/**
|
|
57
|
-
* `SamplePetnamesController` records user-provided nicknames for various
|
|
58
|
-
* various chains.
|
|
65
|
+
* `SamplePetnamesController` records user-provided nicknames for various
|
|
66
|
+
* addresses on various chains.
|
|
59
67
|
*
|
|
60
68
|
* @example
|
|
61
69
|
*
|
|
@@ -64,27 +72,34 @@ export type SamplePetnamesControllerMessenger = RestrictedMessenger<typeof contr
|
|
|
64
72
|
* import type {
|
|
65
73
|
* SamplePetnamesControllerActions,
|
|
66
74
|
* SamplePetnamesControllerEvents
|
|
67
|
-
* } from '@metamask/
|
|
75
|
+
* } from '@metamask/sample-controllers';
|
|
68
76
|
*
|
|
69
|
-
* const
|
|
77
|
+
* const globalMessenger = new Messenger<
|
|
70
78
|
* SamplePetnamesControllerActions,
|
|
71
79
|
* SamplePetnamesControllerEvents
|
|
72
80
|
* >();
|
|
73
|
-
* const samplePetnamesMessenger =
|
|
81
|
+
* const samplePetnamesMessenger = globalMessenger.getRestricted({
|
|
74
82
|
* name: 'SamplePetnamesController',
|
|
75
83
|
* allowedActions: [],
|
|
76
84
|
* allowedEvents: [],
|
|
77
85
|
* });
|
|
78
|
-
*
|
|
86
|
+
* // Instantiate the controller to register its actions on the messenger
|
|
87
|
+
* new SamplePetnamesController({
|
|
79
88
|
* messenger: samplePetnamesMessenger,
|
|
80
89
|
* });
|
|
81
90
|
*
|
|
82
|
-
*
|
|
83
|
-
* '
|
|
84
|
-
*
|
|
85
|
-
*
|
|
91
|
+
* globalMessenger.call(
|
|
92
|
+
* 'SamplePetnamesController:assignPetname',
|
|
93
|
+
* [
|
|
94
|
+
* '0x1',
|
|
95
|
+
* '0xF57F855e17483B1f09bFec62783C9d3b6c8b3A99',
|
|
96
|
+
* 'Primary Account',
|
|
97
|
+
* ],
|
|
98
|
+
* );
|
|
99
|
+
* const samplePetnamesControllerState = await globalMessenger.call(
|
|
100
|
+
* 'SamplePetnamesController:getState',
|
|
86
101
|
* );
|
|
87
|
-
*
|
|
102
|
+
* samplePetnamesControllerState.namesByChainIdAndAddress
|
|
88
103
|
* // => { '0x1': { '0xF57F855e17483B1f09bFec62783C9d3b6c8b3A99': 'Primary Account' } }
|
|
89
104
|
* ```
|
|
90
105
|
*/
|
|
@@ -92,7 +107,7 @@ export declare class SamplePetnamesController extends BaseController<typeof cont
|
|
|
92
107
|
/**
|
|
93
108
|
* Constructs a new {@link SamplePetnamesController}.
|
|
94
109
|
*
|
|
95
|
-
* @param args - The arguments to
|
|
110
|
+
* @param args - The arguments to this controller.
|
|
96
111
|
* @param args.messenger - The messenger suited for this controller.
|
|
97
112
|
* @param args.state - The desired state with which to initialize this
|
|
98
113
|
* controller. Missing properties will be filled in with defaults.
|
|
@@ -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,EAC1B,mBAAmB,EAEpB,kCAAkC;AACnC,OAAO,EAAE,cAAc,EAAE,kCAAkC;AAE3D,OAAO,KAAK,EAAE,GAAG,EAAE,wBAAwB;
|
|
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,EAC1B,mBAAmB,EAEpB,kCAAkC;AACnC,OAAO,EAAE,cAAc,EAAE,kCAAkC;AAE3D,OAAO,KAAK,EAAE,GAAG,EAAE,wBAAwB;AAE3C,OAAO,KAAK,EAAE,qCAAqC,EAAE,6DAAyD;AAI9G;;;;GAIG;AACH,eAAO,MAAM,cAAc,6BAA6B,CAAC;AAIzD;;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;AAYF;;;;;;;GAOG;AACH,wBAAgB,iCAAiC,IAAI,6BAA6B,CAIjF;AAMD;;GAEG;AACH,MAAM,MAAM,sCAAsC,GAAG,wBAAwB,CAC3E,OAAO,cAAc,EACrB,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,cAAc,EACrB,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,mBAAmB,CACjE,OAAO,cAAc,EACrB,+BAA+B,GAAG,cAAc,EAChD,8BAA8B,GAAG,aAAa,EAC9C,cAAc,CAAC,MAAM,CAAC,EACtB,aAAa,CAAC,MAAM,CAAC,CACtB,CAAC;AAIF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AACH,qBAAa,wBAAyB,SAAQ,cAAc,CAC1D,OAAO,cAAc,EACrB,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;CAYvD"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { ControllerGetStateAction, ControllerStateChangeEvent, RestrictedMessenger } from "@metamask/base-controller";
|
|
2
2
|
import { BaseController } from "@metamask/base-controller";
|
|
3
3
|
import type { Hex } from "@metamask/utils";
|
|
4
|
+
import type { SamplePetnamesControllerMethodActions } from "./sample-petnames-controller-method-action-types.mjs";
|
|
4
5
|
/**
|
|
5
6
|
* The name of the {@link SamplePetnamesController}, used to namespace the
|
|
6
7
|
* controller's actions and events and to namespace the controller's state data
|
|
@@ -22,40 +23,47 @@ export type SamplePetnamesControllerState = {
|
|
|
22
23
|
};
|
|
23
24
|
};
|
|
24
25
|
/**
|
|
25
|
-
*
|
|
26
|
-
*
|
|
26
|
+
* Constructs the default {@link SamplePetnamesController} state. This allows
|
|
27
|
+
* consumers to provide a partial state object when initializing the controller
|
|
28
|
+
* and also helps in constructing complete state objects for this controller in
|
|
29
|
+
* tests.
|
|
30
|
+
*
|
|
31
|
+
* @returns The default {@link SamplePetnamesController} state.
|
|
32
|
+
*/
|
|
33
|
+
export declare function getDefaultPetnamesControllerState(): SamplePetnamesControllerState;
|
|
34
|
+
/**
|
|
35
|
+
* Retrieves the state of the {@link SamplePetnamesController}.
|
|
27
36
|
*/
|
|
28
37
|
export type SamplePetnamesControllerGetStateAction = ControllerGetStateAction<typeof controllerName, SamplePetnamesControllerState>;
|
|
29
38
|
/**
|
|
30
|
-
*
|
|
31
|
-
* externally.
|
|
39
|
+
* Actions that {@link SampleGasPricesMessenger} exposes to other consumers.
|
|
32
40
|
*/
|
|
33
|
-
export type SamplePetnamesControllerActions = SamplePetnamesControllerGetStateAction;
|
|
41
|
+
export type SamplePetnamesControllerActions = SamplePetnamesControllerGetStateAction | SamplePetnamesControllerMethodActions;
|
|
34
42
|
/**
|
|
35
|
-
*
|
|
43
|
+
* Actions from other messengers that {@link SampleGasPricesMessenger} calls.
|
|
36
44
|
*/
|
|
37
45
|
type AllowedActions = never;
|
|
38
46
|
/**
|
|
39
|
-
*
|
|
47
|
+
* Published when the state of {@link SamplePetnamesController} changes.
|
|
40
48
|
*/
|
|
41
49
|
export type SamplePetnamesControllerStateChangeEvent = ControllerStateChangeEvent<typeof controllerName, SamplePetnamesControllerState>;
|
|
42
50
|
/**
|
|
43
|
-
*
|
|
44
|
-
* externally.
|
|
51
|
+
* Events that {@link SampleGasPricesMessenger} exposes to other consumers.
|
|
45
52
|
*/
|
|
46
53
|
export type SamplePetnamesControllerEvents = SamplePetnamesControllerStateChangeEvent;
|
|
47
54
|
/**
|
|
48
|
-
*
|
|
55
|
+
* Events from other messengers that {@link SampleGasPricesMessenger} subscribes
|
|
56
|
+
* to.
|
|
49
57
|
*/
|
|
50
58
|
type AllowedEvents = never;
|
|
51
59
|
/**
|
|
52
|
-
* The messenger
|
|
60
|
+
* The messenger restricted to actions and events accessed by
|
|
53
61
|
* {@link SamplePetnamesController}.
|
|
54
62
|
*/
|
|
55
63
|
export type SamplePetnamesControllerMessenger = RestrictedMessenger<typeof controllerName, SamplePetnamesControllerActions | AllowedActions, SamplePetnamesControllerEvents | AllowedEvents, AllowedActions['type'], AllowedEvents['type']>;
|
|
56
64
|
/**
|
|
57
|
-
* `SamplePetnamesController` records user-provided nicknames for various
|
|
58
|
-
* various chains.
|
|
65
|
+
* `SamplePetnamesController` records user-provided nicknames for various
|
|
66
|
+
* addresses on various chains.
|
|
59
67
|
*
|
|
60
68
|
* @example
|
|
61
69
|
*
|
|
@@ -64,27 +72,34 @@ export type SamplePetnamesControllerMessenger = RestrictedMessenger<typeof contr
|
|
|
64
72
|
* import type {
|
|
65
73
|
* SamplePetnamesControllerActions,
|
|
66
74
|
* SamplePetnamesControllerEvents
|
|
67
|
-
* } from '@metamask/
|
|
75
|
+
* } from '@metamask/sample-controllers';
|
|
68
76
|
*
|
|
69
|
-
* const
|
|
77
|
+
* const globalMessenger = new Messenger<
|
|
70
78
|
* SamplePetnamesControllerActions,
|
|
71
79
|
* SamplePetnamesControllerEvents
|
|
72
80
|
* >();
|
|
73
|
-
* const samplePetnamesMessenger =
|
|
81
|
+
* const samplePetnamesMessenger = globalMessenger.getRestricted({
|
|
74
82
|
* name: 'SamplePetnamesController',
|
|
75
83
|
* allowedActions: [],
|
|
76
84
|
* allowedEvents: [],
|
|
77
85
|
* });
|
|
78
|
-
*
|
|
86
|
+
* // Instantiate the controller to register its actions on the messenger
|
|
87
|
+
* new SamplePetnamesController({
|
|
79
88
|
* messenger: samplePetnamesMessenger,
|
|
80
89
|
* });
|
|
81
90
|
*
|
|
82
|
-
*
|
|
83
|
-
* '
|
|
84
|
-
*
|
|
85
|
-
*
|
|
91
|
+
* globalMessenger.call(
|
|
92
|
+
* 'SamplePetnamesController:assignPetname',
|
|
93
|
+
* [
|
|
94
|
+
* '0x1',
|
|
95
|
+
* '0xF57F855e17483B1f09bFec62783C9d3b6c8b3A99',
|
|
96
|
+
* 'Primary Account',
|
|
97
|
+
* ],
|
|
98
|
+
* );
|
|
99
|
+
* const samplePetnamesControllerState = await globalMessenger.call(
|
|
100
|
+
* 'SamplePetnamesController:getState',
|
|
86
101
|
* );
|
|
87
|
-
*
|
|
102
|
+
* samplePetnamesControllerState.namesByChainIdAndAddress
|
|
88
103
|
* // => { '0x1': { '0xF57F855e17483B1f09bFec62783C9d3b6c8b3A99': 'Primary Account' } }
|
|
89
104
|
* ```
|
|
90
105
|
*/
|
|
@@ -92,7 +107,7 @@ export declare class SamplePetnamesController extends BaseController<typeof cont
|
|
|
92
107
|
/**
|
|
93
108
|
* Constructs a new {@link SamplePetnamesController}.
|
|
94
109
|
*
|
|
95
|
-
* @param args - The arguments to
|
|
110
|
+
* @param args - The arguments to this controller.
|
|
96
111
|
* @param args.messenger - The messenger suited for this controller.
|
|
97
112
|
* @param args.state - The desired state with which to initialize this
|
|
98
113
|
* controller. Missing properties will be filled in with defaults.
|
|
@@ -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,EAC1B,mBAAmB,EAEpB,kCAAkC;AACnC,OAAO,EAAE,cAAc,EAAE,kCAAkC;AAE3D,OAAO,KAAK,EAAE,GAAG,EAAE,wBAAwB;
|
|
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,EAC1B,mBAAmB,EAEpB,kCAAkC;AACnC,OAAO,EAAE,cAAc,EAAE,kCAAkC;AAE3D,OAAO,KAAK,EAAE,GAAG,EAAE,wBAAwB;AAE3C,OAAO,KAAK,EAAE,qCAAqC,EAAE,6DAAyD;AAI9G;;;;GAIG;AACH,eAAO,MAAM,cAAc,6BAA6B,CAAC;AAIzD;;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;AAYF;;;;;;;GAOG;AACH,wBAAgB,iCAAiC,IAAI,6BAA6B,CAIjF;AAMD;;GAEG;AACH,MAAM,MAAM,sCAAsC,GAAG,wBAAwB,CAC3E,OAAO,cAAc,EACrB,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,cAAc,EACrB,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,mBAAmB,CACjE,OAAO,cAAc,EACrB,+BAA+B,GAAG,cAAc,EAChD,8BAA8B,GAAG,aAAa,EAC9C,cAAc,CAAC,MAAM,CAAC,EACtB,aAAa,CAAC,MAAM,CAAC,CACtB,CAAC;AAIF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AACH,qBAAa,wBAAyB,SAAQ,cAAc,CAC1D,OAAO,cAAc,EACrB,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;CAYvD"}
|
|
@@ -24,15 +24,17 @@ const samplePetnamesControllerMetadata = {
|
|
|
24
24
|
*
|
|
25
25
|
* @returns The default {@link SamplePetnamesController} state.
|
|
26
26
|
*/
|
|
27
|
-
function getDefaultPetnamesControllerState() {
|
|
27
|
+
export function getDefaultPetnamesControllerState() {
|
|
28
28
|
return {
|
|
29
29
|
namesByChainIdAndAddress: {},
|
|
30
30
|
};
|
|
31
31
|
}
|
|
32
|
+
// === MESSENGER ===
|
|
33
|
+
const MESSENGER_EXPOSED_METHODS = ['assignPetname'];
|
|
32
34
|
// === CONTROLLER DEFINITION ===
|
|
33
35
|
/**
|
|
34
|
-
* `SamplePetnamesController` records user-provided nicknames for various
|
|
35
|
-
* various chains.
|
|
36
|
+
* `SamplePetnamesController` records user-provided nicknames for various
|
|
37
|
+
* addresses on various chains.
|
|
36
38
|
*
|
|
37
39
|
* @example
|
|
38
40
|
*
|
|
@@ -41,27 +43,34 @@ function getDefaultPetnamesControllerState() {
|
|
|
41
43
|
* import type {
|
|
42
44
|
* SamplePetnamesControllerActions,
|
|
43
45
|
* SamplePetnamesControllerEvents
|
|
44
|
-
* } from '@metamask/
|
|
46
|
+
* } from '@metamask/sample-controllers';
|
|
45
47
|
*
|
|
46
|
-
* const
|
|
48
|
+
* const globalMessenger = new Messenger<
|
|
47
49
|
* SamplePetnamesControllerActions,
|
|
48
50
|
* SamplePetnamesControllerEvents
|
|
49
51
|
* >();
|
|
50
|
-
* const samplePetnamesMessenger =
|
|
52
|
+
* const samplePetnamesMessenger = globalMessenger.getRestricted({
|
|
51
53
|
* name: 'SamplePetnamesController',
|
|
52
54
|
* allowedActions: [],
|
|
53
55
|
* allowedEvents: [],
|
|
54
56
|
* });
|
|
55
|
-
*
|
|
57
|
+
* // Instantiate the controller to register its actions on the messenger
|
|
58
|
+
* new SamplePetnamesController({
|
|
56
59
|
* messenger: samplePetnamesMessenger,
|
|
57
60
|
* });
|
|
58
61
|
*
|
|
59
|
-
*
|
|
60
|
-
* '
|
|
61
|
-
*
|
|
62
|
-
*
|
|
62
|
+
* globalMessenger.call(
|
|
63
|
+
* 'SamplePetnamesController:assignPetname',
|
|
64
|
+
* [
|
|
65
|
+
* '0x1',
|
|
66
|
+
* '0xF57F855e17483B1f09bFec62783C9d3b6c8b3A99',
|
|
67
|
+
* 'Primary Account',
|
|
68
|
+
* ],
|
|
63
69
|
* );
|
|
64
|
-
*
|
|
70
|
+
* const samplePetnamesControllerState = await globalMessenger.call(
|
|
71
|
+
* 'SamplePetnamesController:getState',
|
|
72
|
+
* );
|
|
73
|
+
* samplePetnamesControllerState.namesByChainIdAndAddress
|
|
65
74
|
* // => { '0x1': { '0xF57F855e17483B1f09bFec62783C9d3b6c8b3A99': 'Primary Account' } }
|
|
66
75
|
* ```
|
|
67
76
|
*/
|
|
@@ -69,7 +78,7 @@ export class SamplePetnamesController extends BaseController {
|
|
|
69
78
|
/**
|
|
70
79
|
* Constructs a new {@link SamplePetnamesController}.
|
|
71
80
|
*
|
|
72
|
-
* @param args - The arguments to
|
|
81
|
+
* @param args - The arguments to this controller.
|
|
73
82
|
* @param args.messenger - The messenger suited for this controller.
|
|
74
83
|
* @param args.state - The desired state with which to initialize this
|
|
75
84
|
* controller. Missing properties will be filled in with defaults.
|
|
@@ -84,6 +93,7 @@ export class SamplePetnamesController extends BaseController {
|
|
|
84
93
|
...state,
|
|
85
94
|
},
|
|
86
95
|
});
|
|
96
|
+
this.messagingSystem.registerMethodActionHandlers(this, MESSENGER_EXPOSED_METHODS);
|
|
87
97
|
}
|
|
88
98
|
/**
|
|
89
99
|
* Registers the given name with the given address (relative to the given
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sample-petnames-controller.mjs","sourceRoot":"","sources":["../src/sample-petnames-controller.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,cAAc,EAAE,kCAAkC;AAC3D,OAAO,EAAE,gBAAgB,EAAE,mCAAmC;
|
|
1
|
+
{"version":3,"file":"sample-petnames-controller.mjs","sourceRoot":"","sources":["../src/sample-petnames-controller.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,cAAc,EAAE,kCAAkC;AAC3D,OAAO,EAAE,gBAAgB,EAAE,mCAAmC;AAK9D,kBAAkB;AAElB;;;;GAIG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,0BAA0B,CAAC;AAmBzD;;GAEG;AACH,MAAM,gCAAgC,GAAG;IACvC,wBAAwB,EAAE;QACxB,OAAO,EAAE,IAAI;QACb,SAAS,EAAE,KAAK;KACjB;CACqD,CAAC;AAEzD;;;;;;;GAOG;AACH,MAAM,UAAU,iCAAiC;IAC/C,OAAO;QACL,wBAAwB,EAAE,EAAE;KAC7B,CAAC;AACJ,CAAC;AAED,oBAAoB;AAEpB,MAAM,yBAAyB,GAAG,CAAC,eAAe,CAAU,CAAC;AAuD7D,gCAAgC;AAEhC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AACH,MAAM,OAAO,wBAAyB,SAAQ,cAI7C;IACC;;;;;;;OAOG;IACH,YAAY,EACV,SAAS,EACT,KAAK,GAIN;QACC,KAAK,CAAC;YACJ,SAAS;YACT,QAAQ,EAAE,gCAAgC;YAC1C,IAAI,EAAE,cAAc;YACpB,KAAK,EAAE;gBACL,GAAG,iCAAiC,EAAE;gBACtC,GAAG,KAAK;aACT;SACF,CAAC,CAAC;QAEH,IAAI,CAAC,eAAe,CAAC,4BAA4B,CAC/C,IAAI,EACJ,yBAAyB,CAC1B,CAAC;IACJ,CAAC;IAED;;;;;;;OAOG;IACH,aAAa,CAAC,OAAY,EAAE,OAAY,EAAE,IAAY;QACpD,IAAI,CAAC,gBAAgB,CAAC,OAAO,CAAC,EAAE;YAC9B,MAAM,IAAI,KAAK,CAAC,kBAAkB,CAAC,CAAC;SACrC;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","sourcesContent":["import type {\n ControllerGetStateAction,\n ControllerStateChangeEvent,\n RestrictedMessenger,\n StateMetadata,\n} from '@metamask/base-controller';\nimport { BaseController } from '@metamask/base-controller';\nimport { isSafeDynamicKey } from '@metamask/controller-utils';\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 */\nexport const controllerName = '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 persist: true,\n anonymous: false,\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 controllerName,\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 controllerName,\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 = RestrictedMessenger<\n typeof controllerName,\n SamplePetnamesControllerActions | AllowedActions,\n SamplePetnamesControllerEvents | AllowedEvents,\n AllowedActions['type'],\n AllowedEvents['type']\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/base-controller';\n * import type {\n * SamplePetnamesControllerActions,\n * SamplePetnamesControllerEvents\n * } from '@metamask/sample-controllers';\n *\n * const globalMessenger = new Messenger<\n * SamplePetnamesControllerActions,\n * SamplePetnamesControllerEvents\n * >();\n * const samplePetnamesMessenger = globalMessenger.getRestricted({\n * name: 'SamplePetnamesController',\n * allowedActions: [],\n * allowedEvents: [],\n * });\n * // Instantiate the controller to register its actions on the messenger\n * new SamplePetnamesController({\n * messenger: samplePetnamesMessenger,\n * });\n *\n * globalMessenger.call(\n * 'SamplePetnamesController:assignPetname',\n * [\n * '0x1',\n * '0xF57F855e17483B1f09bFec62783C9d3b6c8b3A99',\n * 'Primary Account',\n * ],\n * );\n * const samplePetnamesControllerState = await globalMessenger.call(\n * 'SamplePetnamesController:getState',\n * );\n * samplePetnamesControllerState.namesByChainIdAndAddress\n * // => { '0x1': { '0xF57F855e17483B1f09bFec62783C9d3b6c8b3A99': 'Primary Account' } }\n * ```\n */\nexport class SamplePetnamesController extends BaseController<\n typeof controllerName,\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: controllerName,\n state: {\n ...getDefaultPetnamesControllerState(),\n ...state,\n },\n });\n\n this.messagingSystem.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) {\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": "1.0.0-preview-
|
|
3
|
+
"version": "1.0.0-preview-e821953",
|
|
4
4
|
"description": "Sample package to illustrate best practices for controllers",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"MetaMask",
|
|
@@ -58,6 +58,7 @@
|
|
|
58
58
|
"deepmerge": "^4.2.2",
|
|
59
59
|
"jest": "^27.5.1",
|
|
60
60
|
"nock": "^13.3.1",
|
|
61
|
+
"sinon": "^9.2.4",
|
|
61
62
|
"ts-jest": "^27.1.4",
|
|
62
63
|
"typedoc": "^0.24.8",
|
|
63
64
|
"typedoc-plugin-missing-exports": "^2.0.0",
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getDefaultNetworkControllerState = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* Constructs a default representation of a theoretical NetworkController's
|
|
6
|
-
* state.
|
|
7
|
-
*
|
|
8
|
-
* Note that this package does not supply a NetworkController; this type is only
|
|
9
|
-
* here so it is possible to write a complete example.
|
|
10
|
-
*
|
|
11
|
-
* @returns The default network controller state.
|
|
12
|
-
*/
|
|
13
|
-
function getDefaultNetworkControllerState() {
|
|
14
|
-
return {
|
|
15
|
-
networkName: 'Some Network',
|
|
16
|
-
chainId: '0x1',
|
|
17
|
-
};
|
|
18
|
-
}
|
|
19
|
-
exports.getDefaultNetworkControllerState = getDefaultNetworkControllerState;
|
|
20
|
-
//# sourceMappingURL=network-controller-types.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"network-controller-types.cjs","sourceRoot":"","sources":["../src/network-controller-types.ts"],"names":[],"mappings":";;;AAaA;;;;;;;;GAQG;AACH,SAAgB,gCAAgC;IAC9C,OAAO;QACL,WAAW,EAAE,cAAc;QAC3B,OAAO,EAAE,KAAK;KACf,CAAC;AACJ,CAAC;AALD,4EAKC","sourcesContent":["import type { Hex } from '@metamask/utils';\n\n/**\n * Describes the shape of the state object for a theoretical NetworkController.\n *\n * Note that this package does not supply a NetworkController; this type is only\n * here so it is possible to write a complete example.\n */\ntype NetworkControllerState = {\n networkName: string;\n chainId: Hex;\n};\n\n/**\n * Constructs a default representation of a theoretical NetworkController's\n * state.\n *\n * Note that this package does not supply a NetworkController; this type is only\n * here so it is possible to write a complete example.\n *\n * @returns The default network controller state.\n */\nexport function getDefaultNetworkControllerState(): NetworkControllerState {\n return {\n networkName: 'Some Network',\n chainId: '0x1',\n };\n}\n\n/**\n * The action which can be used to obtain the state for a theoretical\n * NetworkController.\n *\n * Note that this package does not supply a NetworkController; this type is only\n * here so it is possible to write a complete example.\n */\nexport type NetworkControllerGetStateAction = {\n type: 'NetworkController:getState';\n handler: () => NetworkControllerState;\n};\n"]}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import type { Hex } from "@metamask/utils";
|
|
2
|
-
/**
|
|
3
|
-
* Describes the shape of the state object for a theoretical NetworkController.
|
|
4
|
-
*
|
|
5
|
-
* Note that this package does not supply a NetworkController; this type is only
|
|
6
|
-
* here so it is possible to write a complete example.
|
|
7
|
-
*/
|
|
8
|
-
type NetworkControllerState = {
|
|
9
|
-
networkName: string;
|
|
10
|
-
chainId: Hex;
|
|
11
|
-
};
|
|
12
|
-
/**
|
|
13
|
-
* Constructs a default representation of a theoretical NetworkController's
|
|
14
|
-
* state.
|
|
15
|
-
*
|
|
16
|
-
* Note that this package does not supply a NetworkController; this type is only
|
|
17
|
-
* here so it is possible to write a complete example.
|
|
18
|
-
*
|
|
19
|
-
* @returns The default network controller state.
|
|
20
|
-
*/
|
|
21
|
-
export declare function getDefaultNetworkControllerState(): NetworkControllerState;
|
|
22
|
-
/**
|
|
23
|
-
* The action which can be used to obtain the state for a theoretical
|
|
24
|
-
* NetworkController.
|
|
25
|
-
*
|
|
26
|
-
* Note that this package does not supply a NetworkController; this type is only
|
|
27
|
-
* here so it is possible to write a complete example.
|
|
28
|
-
*/
|
|
29
|
-
export type NetworkControllerGetStateAction = {
|
|
30
|
-
type: 'NetworkController:getState';
|
|
31
|
-
handler: () => NetworkControllerState;
|
|
32
|
-
};
|
|
33
|
-
export {};
|
|
34
|
-
//# sourceMappingURL=network-controller-types.d.cts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"network-controller-types.d.cts","sourceRoot":"","sources":["../src/network-controller-types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,wBAAwB;AAE3C;;;;;GAKG;AACH,KAAK,sBAAsB,GAAG;IAC5B,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,GAAG,CAAC;CACd,CAAC;AAEF;;;;;;;;GAQG;AACH,wBAAgB,gCAAgC,IAAI,sBAAsB,CAKzE;AAED;;;;;;GAMG;AACH,MAAM,MAAM,+BAA+B,GAAG;IAC5C,IAAI,EAAE,4BAA4B,CAAC;IACnC,OAAO,EAAE,MAAM,sBAAsB,CAAC;CACvC,CAAC"}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import type { Hex } from "@metamask/utils";
|
|
2
|
-
/**
|
|
3
|
-
* Describes the shape of the state object for a theoretical NetworkController.
|
|
4
|
-
*
|
|
5
|
-
* Note that this package does not supply a NetworkController; this type is only
|
|
6
|
-
* here so it is possible to write a complete example.
|
|
7
|
-
*/
|
|
8
|
-
type NetworkControllerState = {
|
|
9
|
-
networkName: string;
|
|
10
|
-
chainId: Hex;
|
|
11
|
-
};
|
|
12
|
-
/**
|
|
13
|
-
* Constructs a default representation of a theoretical NetworkController's
|
|
14
|
-
* state.
|
|
15
|
-
*
|
|
16
|
-
* Note that this package does not supply a NetworkController; this type is only
|
|
17
|
-
* here so it is possible to write a complete example.
|
|
18
|
-
*
|
|
19
|
-
* @returns The default network controller state.
|
|
20
|
-
*/
|
|
21
|
-
export declare function getDefaultNetworkControllerState(): NetworkControllerState;
|
|
22
|
-
/**
|
|
23
|
-
* The action which can be used to obtain the state for a theoretical
|
|
24
|
-
* NetworkController.
|
|
25
|
-
*
|
|
26
|
-
* Note that this package does not supply a NetworkController; this type is only
|
|
27
|
-
* here so it is possible to write a complete example.
|
|
28
|
-
*/
|
|
29
|
-
export type NetworkControllerGetStateAction = {
|
|
30
|
-
type: 'NetworkController:getState';
|
|
31
|
-
handler: () => NetworkControllerState;
|
|
32
|
-
};
|
|
33
|
-
export {};
|
|
34
|
-
//# sourceMappingURL=network-controller-types.d.mts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"network-controller-types.d.mts","sourceRoot":"","sources":["../src/network-controller-types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,wBAAwB;AAE3C;;;;;GAKG;AACH,KAAK,sBAAsB,GAAG;IAC5B,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,GAAG,CAAC;CACd,CAAC;AAEF;;;;;;;;GAQG;AACH,wBAAgB,gCAAgC,IAAI,sBAAsB,CAKzE;AAED;;;;;;GAMG;AACH,MAAM,MAAM,+BAA+B,GAAG;IAC5C,IAAI,EAAE,4BAA4B,CAAC;IACnC,OAAO,EAAE,MAAM,sBAAsB,CAAC;CACvC,CAAC"}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Constructs a default representation of a theoretical NetworkController's
|
|
3
|
-
* state.
|
|
4
|
-
*
|
|
5
|
-
* Note that this package does not supply a NetworkController; this type is only
|
|
6
|
-
* here so it is possible to write a complete example.
|
|
7
|
-
*
|
|
8
|
-
* @returns The default network controller state.
|
|
9
|
-
*/
|
|
10
|
-
export function getDefaultNetworkControllerState() {
|
|
11
|
-
return {
|
|
12
|
-
networkName: 'Some Network',
|
|
13
|
-
chainId: '0x1',
|
|
14
|
-
};
|
|
15
|
-
}
|
|
16
|
-
//# sourceMappingURL=network-controller-types.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"network-controller-types.mjs","sourceRoot":"","sources":["../src/network-controller-types.ts"],"names":[],"mappings":"AAaA;;;;;;;;GAQG;AACH,MAAM,UAAU,gCAAgC;IAC9C,OAAO;QACL,WAAW,EAAE,cAAc;QAC3B,OAAO,EAAE,KAAK;KACf,CAAC;AACJ,CAAC","sourcesContent":["import type { Hex } from '@metamask/utils';\n\n/**\n * Describes the shape of the state object for a theoretical NetworkController.\n *\n * Note that this package does not supply a NetworkController; this type is only\n * here so it is possible to write a complete example.\n */\ntype NetworkControllerState = {\n networkName: string;\n chainId: Hex;\n};\n\n/**\n * Constructs a default representation of a theoretical NetworkController's\n * state.\n *\n * Note that this package does not supply a NetworkController; this type is only\n * here so it is possible to write a complete example.\n *\n * @returns The default network controller state.\n */\nexport function getDefaultNetworkControllerState(): NetworkControllerState {\n return {\n networkName: 'Some Network',\n chainId: '0x1',\n };\n}\n\n/**\n * The action which can be used to obtain the state for a theoretical\n * NetworkController.\n *\n * Note that this package does not supply a NetworkController; this type is only\n * here so it is possible to write a complete example.\n */\nexport type NetworkControllerGetStateAction = {\n type: 'NetworkController:getState';\n handler: () => NetworkControllerState;\n};\n"]}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.SampleGasPricesService = void 0;
|
|
4
|
-
var sample_gas_prices_service_1 = require("./sample-gas-prices-service.cjs");
|
|
5
|
-
Object.defineProperty(exports, "SampleGasPricesService", { enumerable: true, get: function () { return sample_gas_prices_service_1.SampleGasPricesService; } });
|
|
6
|
-
//# sourceMappingURL=index.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sourceRoot":"","sources":["../../src/sample-gas-prices-service/index.ts"],"names":[],"mappings":";;;AACA,6EAAqE;AAA5D,mIAAA,sBAAsB,OAAA","sourcesContent":["export { type SampleAbstractGasPricesService } from './sample-abstract-gas-prices-service';\nexport { SampleGasPricesService } from './sample-gas-prices-service';\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.cts","sourceRoot":"","sources":["../../src/sample-gas-prices-service/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,8BAA8B,EAAE,iDAA6C;AAC3F,OAAO,EAAE,sBAAsB,EAAE,wCAAoC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../../src/sample-gas-prices-service/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,8BAA8B,EAAE,iDAA6C;AAC3F,OAAO,EAAE,sBAAsB,EAAE,wCAAoC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sourceRoot":"","sources":["../../src/sample-gas-prices-service/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,sBAAsB,EAAE,wCAAoC","sourcesContent":["export { type SampleAbstractGasPricesService } from './sample-abstract-gas-prices-service';\nexport { SampleGasPricesService } from './sample-gas-prices-service';\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"sample-abstract-gas-prices-service.cjs","sourceRoot":"","sources":["../../src/sample-gas-prices-service/sample-abstract-gas-prices-service.ts"],"names":[],"mappings":"","sourcesContent":["import type { PublicInterface } from '@metamask/utils';\n\nimport type { SampleGasPricesService } from './sample-gas-prices-service';\n\n/**\n * A service object which is responsible for fetching gas prices.\n */\nexport type SampleAbstractGasPricesService =\n PublicInterface<SampleGasPricesService>;\n"]}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import type { PublicInterface } from "@metamask/utils";
|
|
2
|
-
import type { SampleGasPricesService } from "./sample-gas-prices-service.cjs";
|
|
3
|
-
/**
|
|
4
|
-
* A service object which is responsible for fetching gas prices.
|
|
5
|
-
*/
|
|
6
|
-
export type SampleAbstractGasPricesService = PublicInterface<SampleGasPricesService>;
|
|
7
|
-
//# sourceMappingURL=sample-abstract-gas-prices-service.d.cts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"sample-abstract-gas-prices-service.d.cts","sourceRoot":"","sources":["../../src/sample-gas-prices-service/sample-abstract-gas-prices-service.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,wBAAwB;AAEvD,OAAO,KAAK,EAAE,sBAAsB,EAAE,wCAAoC;AAE1E;;GAEG;AACH,MAAM,MAAM,8BAA8B,GACxC,eAAe,CAAC,sBAAsB,CAAC,CAAC"}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import type { PublicInterface } from "@metamask/utils";
|
|
2
|
-
import type { SampleGasPricesService } from "./sample-gas-prices-service.mjs";
|
|
3
|
-
/**
|
|
4
|
-
* A service object which is responsible for fetching gas prices.
|
|
5
|
-
*/
|
|
6
|
-
export type SampleAbstractGasPricesService = PublicInterface<SampleGasPricesService>;
|
|
7
|
-
//# sourceMappingURL=sample-abstract-gas-prices-service.d.mts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"sample-abstract-gas-prices-service.d.mts","sourceRoot":"","sources":["../../src/sample-gas-prices-service/sample-abstract-gas-prices-service.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,wBAAwB;AAEvD,OAAO,KAAK,EAAE,sBAAsB,EAAE,wCAAoC;AAE1E;;GAEG;AACH,MAAM,MAAM,8BAA8B,GACxC,eAAe,CAAC,sBAAsB,CAAC,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"sample-abstract-gas-prices-service.mjs","sourceRoot":"","sources":["../../src/sample-gas-prices-service/sample-abstract-gas-prices-service.ts"],"names":[],"mappings":"","sourcesContent":["import type { PublicInterface } from '@metamask/utils';\n\nimport type { SampleGasPricesService } from './sample-gas-prices-service';\n\n/**\n * A service object which is responsible for fetching gas prices.\n */\nexport type SampleAbstractGasPricesService =\n PublicInterface<SampleGasPricesService>;\n"]}
|