@metamask/ramps-controller 1.0.0 → 2.0.0
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/RampsController.cjs +2 -2
- package/dist/RampsController.cjs.map +1 -1
- package/dist/RampsController.d.cts +3 -3
- package/dist/RampsController.d.cts.map +1 -1
- package/dist/RampsController.d.mts +3 -3
- package/dist/RampsController.d.mts.map +1 -1
- package/dist/RampsController.mjs +2 -2
- package/dist/RampsController.mjs.map +1 -1
- package/dist/{OnRampService-method-action-types.cjs → RampsService-method-action-types.cjs} +1 -1
- package/dist/RampsService-method-action-types.cjs.map +1 -0
- package/dist/RampsService-method-action-types.d.cts +20 -0
- package/dist/RampsService-method-action-types.d.cts.map +1 -0
- package/dist/RampsService-method-action-types.d.mts +20 -0
- package/dist/RampsService-method-action-types.d.mts.map +1 -0
- package/dist/{OnRampService-method-action-types.mjs → RampsService-method-action-types.mjs} +1 -1
- package/dist/RampsService-method-action-types.mjs.map +1 -0
- package/dist/{OnRampService.cjs → RampsService.cjs} +52 -50
- package/dist/RampsService.cjs.map +1 -0
- package/dist/{OnRampService.d.cts → RampsService.d.cts} +31 -31
- package/dist/RampsService.d.cts.map +1 -0
- package/dist/{OnRampService.d.mts → RampsService.d.mts} +31 -31
- package/dist/RampsService.d.mts.map +1 -0
- package/dist/{OnRampService.mjs → RampsService.mjs} +50 -48
- package/dist/RampsService.mjs.map +1 -0
- package/dist/index.cjs +4 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -3
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +3 -3
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -1
- package/dist/OnRampService-method-action-types.cjs.map +0 -1
- package/dist/OnRampService-method-action-types.d.cts +0 -20
- package/dist/OnRampService-method-action-types.d.cts.map +0 -1
- package/dist/OnRampService-method-action-types.d.mts +0 -20
- package/dist/OnRampService-method-action-types.d.mts.map +0 -1
- package/dist/OnRampService-method-action-types.mjs.map +0 -1
- package/dist/OnRampService.cjs.map +0 -1
- package/dist/OnRampService.d.cts.map +0 -1
- package/dist/OnRampService.d.mts.map +0 -1
- package/dist/OnRampService.mjs.map +0 -1
|
@@ -1,89 +1,89 @@
|
|
|
1
1
|
import type { CreateServicePolicyOptions, ServicePolicy } from "@metamask/controller-utils";
|
|
2
2
|
import type { Messenger } from "@metamask/messenger";
|
|
3
|
-
import type {
|
|
3
|
+
import type { RampsServiceMethodActions } from "./RampsService-method-action-types.cjs";
|
|
4
4
|
/**
|
|
5
|
-
* The name of the {@link
|
|
5
|
+
* The name of the {@link RampsService}, used to namespace the
|
|
6
6
|
* service's actions and events.
|
|
7
7
|
*/
|
|
8
|
-
export declare const serviceName = "
|
|
8
|
+
export declare const serviceName = "RampsService";
|
|
9
9
|
/**
|
|
10
10
|
* The environment to use for API requests.
|
|
11
11
|
*/
|
|
12
|
-
export declare enum
|
|
12
|
+
export declare enum RampsEnvironment {
|
|
13
13
|
Production = "production",
|
|
14
14
|
Staging = "staging",
|
|
15
15
|
Development = "development"
|
|
16
16
|
}
|
|
17
17
|
/**
|
|
18
|
-
* Actions that {@link
|
|
18
|
+
* Actions that {@link RampsService} exposes to other consumers.
|
|
19
19
|
*/
|
|
20
|
-
export type
|
|
20
|
+
export type RampsServiceActions = RampsServiceMethodActions;
|
|
21
21
|
/**
|
|
22
|
-
* Actions from other messengers that {@link
|
|
22
|
+
* Actions from other messengers that {@link RampsService} calls.
|
|
23
23
|
*/
|
|
24
24
|
type AllowedActions = never;
|
|
25
25
|
/**
|
|
26
|
-
* Events that {@link
|
|
26
|
+
* Events that {@link RampsService} exposes to other consumers.
|
|
27
27
|
*/
|
|
28
|
-
export type
|
|
28
|
+
export type RampsServiceEvents = never;
|
|
29
29
|
/**
|
|
30
|
-
* Events from other messengers that {@link
|
|
30
|
+
* Events from other messengers that {@link RampsService} subscribes to.
|
|
31
31
|
*/
|
|
32
32
|
type AllowedEvents = never;
|
|
33
33
|
/**
|
|
34
34
|
* The messenger which is restricted to actions and events accessed by
|
|
35
|
-
* {@link
|
|
35
|
+
* {@link RampsService}.
|
|
36
36
|
*/
|
|
37
|
-
export type
|
|
37
|
+
export type RampsServiceMessenger = Messenger<typeof serviceName, RampsServiceActions | AllowedActions, RampsServiceEvents | AllowedEvents>;
|
|
38
38
|
/**
|
|
39
|
-
* This service object is responsible for interacting with the
|
|
39
|
+
* This service object is responsible for interacting with the Ramps API.
|
|
40
40
|
*
|
|
41
41
|
* @example
|
|
42
42
|
*
|
|
43
43
|
* ``` ts
|
|
44
44
|
* import { Messenger } from '@metamask/messenger';
|
|
45
45
|
* import type {
|
|
46
|
-
*
|
|
47
|
-
*
|
|
46
|
+
* RampsServiceActions,
|
|
47
|
+
* RampsServiceEvents,
|
|
48
48
|
* } from '@metamask/ramps-controller';
|
|
49
49
|
*
|
|
50
50
|
* const rootMessenger = new Messenger<
|
|
51
51
|
* 'Root',
|
|
52
|
-
*
|
|
53
|
-
*
|
|
52
|
+
* RampsServiceActions
|
|
53
|
+
* RampsServiceEvents
|
|
54
54
|
* >({ namespace: 'Root' });
|
|
55
|
-
* const
|
|
56
|
-
* '
|
|
57
|
-
*
|
|
58
|
-
*
|
|
55
|
+
* const rampsServiceMessenger = new Messenger<
|
|
56
|
+
* 'RampsService',
|
|
57
|
+
* RampsServiceActions,
|
|
58
|
+
* RampsServiceEvents,
|
|
59
59
|
* typeof rootMessenger,
|
|
60
60
|
* >({
|
|
61
|
-
* namespace: '
|
|
61
|
+
* namespace: 'RampsService',
|
|
62
62
|
* parent: rootMessenger,
|
|
63
63
|
* });
|
|
64
64
|
* // Instantiate the service to register its actions on the messenger
|
|
65
|
-
* new
|
|
66
|
-
* messenger:
|
|
67
|
-
* environment:
|
|
65
|
+
* new RampsService({
|
|
66
|
+
* messenger: rampsServiceMessenger,
|
|
67
|
+
* environment: RampsEnvironment.Production,
|
|
68
68
|
* fetch,
|
|
69
69
|
* });
|
|
70
70
|
*
|
|
71
71
|
* // Later...
|
|
72
72
|
* // Get the user's geolocation
|
|
73
73
|
* const geolocation = await rootMessenger.call(
|
|
74
|
-
* '
|
|
74
|
+
* 'RampsService:getGeolocation',
|
|
75
75
|
* );
|
|
76
76
|
* // ... Do something with the geolocation ...
|
|
77
77
|
* ```
|
|
78
78
|
*/
|
|
79
|
-
export declare class
|
|
79
|
+
export declare class RampsService {
|
|
80
80
|
#private;
|
|
81
81
|
/**
|
|
82
82
|
* The name of the service.
|
|
83
83
|
*/
|
|
84
84
|
readonly name: typeof serviceName;
|
|
85
85
|
/**
|
|
86
|
-
* Constructs a new
|
|
86
|
+
* Constructs a new RampsService object.
|
|
87
87
|
*
|
|
88
88
|
* @param args - The constructor arguments.
|
|
89
89
|
* @param args.messenger - The messenger suited for this service.
|
|
@@ -96,8 +96,8 @@ export declare class OnRampService {
|
|
|
96
96
|
* is used to wrap each request. See {@link CreateServicePolicyOptions}.
|
|
97
97
|
*/
|
|
98
98
|
constructor({ messenger, environment, fetch: fetchFunction, policyOptions, }: {
|
|
99
|
-
messenger:
|
|
100
|
-
environment?:
|
|
99
|
+
messenger: RampsServiceMessenger;
|
|
100
|
+
environment?: RampsEnvironment;
|
|
101
101
|
fetch: typeof fetch;
|
|
102
102
|
policyOptions?: CreateServicePolicyOptions;
|
|
103
103
|
});
|
|
@@ -149,4 +149,4 @@ export declare class OnRampService {
|
|
|
149
149
|
getGeolocation(): Promise<string>;
|
|
150
150
|
}
|
|
151
151
|
export {};
|
|
152
|
-
//# sourceMappingURL=
|
|
152
|
+
//# sourceMappingURL=RampsService.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RampsService.d.cts","sourceRoot":"","sources":["../src/RampsService.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,0BAA0B,EAC1B,aAAa,EACd,mCAAmC;AAEpC,OAAO,KAAK,EAAE,SAAS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AAC,GAChD,UAAU,CAAC,aAAa,CAAC,SAAS,CAAC,CAAC;IAIvC;;;;;;;;;;;;;;;;OAgBG;IACH,UAAU,CACR,QAAQ,EAAE,UAAU,CAAC,aAAa,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC,GACnD,UAAU,CAAC,aAAa,CAAC,YAAY,CAAC,CAAC;IAI1C;;;;;OAKG;IACG,cAAc,IAAI,OAAO,CAAC,MAAM,CAAC;CAwBxC"}
|
|
@@ -1,89 +1,89 @@
|
|
|
1
1
|
import type { CreateServicePolicyOptions, ServicePolicy } from "@metamask/controller-utils";
|
|
2
2
|
import type { Messenger } from "@metamask/messenger";
|
|
3
|
-
import type {
|
|
3
|
+
import type { RampsServiceMethodActions } from "./RampsService-method-action-types.mjs";
|
|
4
4
|
/**
|
|
5
|
-
* The name of the {@link
|
|
5
|
+
* The name of the {@link RampsService}, used to namespace the
|
|
6
6
|
* service's actions and events.
|
|
7
7
|
*/
|
|
8
|
-
export declare const serviceName = "
|
|
8
|
+
export declare const serviceName = "RampsService";
|
|
9
9
|
/**
|
|
10
10
|
* The environment to use for API requests.
|
|
11
11
|
*/
|
|
12
|
-
export declare enum
|
|
12
|
+
export declare enum RampsEnvironment {
|
|
13
13
|
Production = "production",
|
|
14
14
|
Staging = "staging",
|
|
15
15
|
Development = "development"
|
|
16
16
|
}
|
|
17
17
|
/**
|
|
18
|
-
* Actions that {@link
|
|
18
|
+
* Actions that {@link RampsService} exposes to other consumers.
|
|
19
19
|
*/
|
|
20
|
-
export type
|
|
20
|
+
export type RampsServiceActions = RampsServiceMethodActions;
|
|
21
21
|
/**
|
|
22
|
-
* Actions from other messengers that {@link
|
|
22
|
+
* Actions from other messengers that {@link RampsService} calls.
|
|
23
23
|
*/
|
|
24
24
|
type AllowedActions = never;
|
|
25
25
|
/**
|
|
26
|
-
* Events that {@link
|
|
26
|
+
* Events that {@link RampsService} exposes to other consumers.
|
|
27
27
|
*/
|
|
28
|
-
export type
|
|
28
|
+
export type RampsServiceEvents = never;
|
|
29
29
|
/**
|
|
30
|
-
* Events from other messengers that {@link
|
|
30
|
+
* Events from other messengers that {@link RampsService} subscribes to.
|
|
31
31
|
*/
|
|
32
32
|
type AllowedEvents = never;
|
|
33
33
|
/**
|
|
34
34
|
* The messenger which is restricted to actions and events accessed by
|
|
35
|
-
* {@link
|
|
35
|
+
* {@link RampsService}.
|
|
36
36
|
*/
|
|
37
|
-
export type
|
|
37
|
+
export type RampsServiceMessenger = Messenger<typeof serviceName, RampsServiceActions | AllowedActions, RampsServiceEvents | AllowedEvents>;
|
|
38
38
|
/**
|
|
39
|
-
* This service object is responsible for interacting with the
|
|
39
|
+
* This service object is responsible for interacting with the Ramps API.
|
|
40
40
|
*
|
|
41
41
|
* @example
|
|
42
42
|
*
|
|
43
43
|
* ``` ts
|
|
44
44
|
* import { Messenger } from '@metamask/messenger';
|
|
45
45
|
* import type {
|
|
46
|
-
*
|
|
47
|
-
*
|
|
46
|
+
* RampsServiceActions,
|
|
47
|
+
* RampsServiceEvents,
|
|
48
48
|
* } from '@metamask/ramps-controller';
|
|
49
49
|
*
|
|
50
50
|
* const rootMessenger = new Messenger<
|
|
51
51
|
* 'Root',
|
|
52
|
-
*
|
|
53
|
-
*
|
|
52
|
+
* RampsServiceActions
|
|
53
|
+
* RampsServiceEvents
|
|
54
54
|
* >({ namespace: 'Root' });
|
|
55
|
-
* const
|
|
56
|
-
* '
|
|
57
|
-
*
|
|
58
|
-
*
|
|
55
|
+
* const rampsServiceMessenger = new Messenger<
|
|
56
|
+
* 'RampsService',
|
|
57
|
+
* RampsServiceActions,
|
|
58
|
+
* RampsServiceEvents,
|
|
59
59
|
* typeof rootMessenger,
|
|
60
60
|
* >({
|
|
61
|
-
* namespace: '
|
|
61
|
+
* namespace: 'RampsService',
|
|
62
62
|
* parent: rootMessenger,
|
|
63
63
|
* });
|
|
64
64
|
* // Instantiate the service to register its actions on the messenger
|
|
65
|
-
* new
|
|
66
|
-
* messenger:
|
|
67
|
-
* environment:
|
|
65
|
+
* new RampsService({
|
|
66
|
+
* messenger: rampsServiceMessenger,
|
|
67
|
+
* environment: RampsEnvironment.Production,
|
|
68
68
|
* fetch,
|
|
69
69
|
* });
|
|
70
70
|
*
|
|
71
71
|
* // Later...
|
|
72
72
|
* // Get the user's geolocation
|
|
73
73
|
* const geolocation = await rootMessenger.call(
|
|
74
|
-
* '
|
|
74
|
+
* 'RampsService:getGeolocation',
|
|
75
75
|
* );
|
|
76
76
|
* // ... Do something with the geolocation ...
|
|
77
77
|
* ```
|
|
78
78
|
*/
|
|
79
|
-
export declare class
|
|
79
|
+
export declare class RampsService {
|
|
80
80
|
#private;
|
|
81
81
|
/**
|
|
82
82
|
* The name of the service.
|
|
83
83
|
*/
|
|
84
84
|
readonly name: typeof serviceName;
|
|
85
85
|
/**
|
|
86
|
-
* Constructs a new
|
|
86
|
+
* Constructs a new RampsService object.
|
|
87
87
|
*
|
|
88
88
|
* @param args - The constructor arguments.
|
|
89
89
|
* @param args.messenger - The messenger suited for this service.
|
|
@@ -96,8 +96,8 @@ export declare class OnRampService {
|
|
|
96
96
|
* is used to wrap each request. See {@link CreateServicePolicyOptions}.
|
|
97
97
|
*/
|
|
98
98
|
constructor({ messenger, environment, fetch: fetchFunction, policyOptions, }: {
|
|
99
|
-
messenger:
|
|
100
|
-
environment?:
|
|
99
|
+
messenger: RampsServiceMessenger;
|
|
100
|
+
environment?: RampsEnvironment;
|
|
101
101
|
fetch: typeof fetch;
|
|
102
102
|
policyOptions?: CreateServicePolicyOptions;
|
|
103
103
|
});
|
|
@@ -149,4 +149,4 @@ export declare class OnRampService {
|
|
|
149
149
|
getGeolocation(): Promise<string>;
|
|
150
150
|
}
|
|
151
151
|
export {};
|
|
152
|
-
//# sourceMappingURL=
|
|
152
|
+
//# sourceMappingURL=RampsService.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RampsService.d.mts","sourceRoot":"","sources":["../src/RampsService.ts"],"names":[],"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;;;OAQG;IACH,OAAO,CACL,QAAQ,EAAE,UAAU,CAAC,aAAa,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,GAChD,UAAU,CAAC,aAAa,CAAC,SAAS,CAAC,CAAC;IAIvC;;;;;;;;;;;;;;;;OAgBG;IACH,UAAU,CACR,QAAQ,EAAE,UAAU,CAAC,aAAa,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC,GACnD,UAAU,CAAC,aAAa,CAAC,YAAY,CAAC,CAAC;IAI1C;;;;;OAKG;IACG,cAAc,IAAI,OAAO,CAAC,MAAM,CAAC;CAwBxC"}
|
|
@@ -9,23 +9,23 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
9
9
|
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");
|
|
10
10
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
11
11
|
};
|
|
12
|
-
var _a,
|
|
12
|
+
var _a, _RampsService_messenger, _RampsService_fetch, _RampsService_policy, _RampsService_baseUrl;
|
|
13
13
|
import { createServicePolicy, HttpError } from "@metamask/controller-utils";
|
|
14
14
|
// === GENERAL ===
|
|
15
15
|
/**
|
|
16
|
-
* The name of the {@link
|
|
16
|
+
* The name of the {@link RampsService}, used to namespace the
|
|
17
17
|
* service's actions and events.
|
|
18
18
|
*/
|
|
19
|
-
export const serviceName = '
|
|
19
|
+
export const serviceName = 'RampsService';
|
|
20
20
|
/**
|
|
21
21
|
* The environment to use for API requests.
|
|
22
22
|
*/
|
|
23
|
-
export var
|
|
24
|
-
(function (
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
})(
|
|
23
|
+
export var RampsEnvironment;
|
|
24
|
+
(function (RampsEnvironment) {
|
|
25
|
+
RampsEnvironment["Production"] = "production";
|
|
26
|
+
RampsEnvironment["Staging"] = "staging";
|
|
27
|
+
RampsEnvironment["Development"] = "development";
|
|
28
|
+
})(RampsEnvironment || (RampsEnvironment = {}));
|
|
29
29
|
// === MESSENGER ===
|
|
30
30
|
const MESSENGER_EXPOSED_METHODS = ['getGeolocation'];
|
|
31
31
|
// === SERVICE DEFINITION ===
|
|
@@ -37,60 +37,60 @@ const MESSENGER_EXPOSED_METHODS = ['getGeolocation'];
|
|
|
37
37
|
*/
|
|
38
38
|
function getBaseUrl(environment) {
|
|
39
39
|
switch (environment) {
|
|
40
|
-
case
|
|
40
|
+
case RampsEnvironment.Production:
|
|
41
41
|
return 'https://on-ramp.api.cx.metamask.io';
|
|
42
|
-
case
|
|
42
|
+
case RampsEnvironment.Staging:
|
|
43
43
|
return 'https://on-ramp.uat-api.cx.metamask.io';
|
|
44
|
-
case
|
|
44
|
+
case RampsEnvironment.Development:
|
|
45
45
|
return 'http://localhost:3000';
|
|
46
46
|
default:
|
|
47
47
|
throw new Error(`Invalid environment: ${String(environment)}`);
|
|
48
48
|
}
|
|
49
49
|
}
|
|
50
50
|
/**
|
|
51
|
-
* This service object is responsible for interacting with the
|
|
51
|
+
* This service object is responsible for interacting with the Ramps API.
|
|
52
52
|
*
|
|
53
53
|
* @example
|
|
54
54
|
*
|
|
55
55
|
* ``` ts
|
|
56
56
|
* import { Messenger } from '@metamask/messenger';
|
|
57
57
|
* import type {
|
|
58
|
-
*
|
|
59
|
-
*
|
|
58
|
+
* RampsServiceActions,
|
|
59
|
+
* RampsServiceEvents,
|
|
60
60
|
* } from '@metamask/ramps-controller';
|
|
61
61
|
*
|
|
62
62
|
* const rootMessenger = new Messenger<
|
|
63
63
|
* 'Root',
|
|
64
|
-
*
|
|
65
|
-
*
|
|
64
|
+
* RampsServiceActions
|
|
65
|
+
* RampsServiceEvents
|
|
66
66
|
* >({ namespace: 'Root' });
|
|
67
|
-
* const
|
|
68
|
-
* '
|
|
69
|
-
*
|
|
70
|
-
*
|
|
67
|
+
* const rampsServiceMessenger = new Messenger<
|
|
68
|
+
* 'RampsService',
|
|
69
|
+
* RampsServiceActions,
|
|
70
|
+
* RampsServiceEvents,
|
|
71
71
|
* typeof rootMessenger,
|
|
72
72
|
* >({
|
|
73
|
-
* namespace: '
|
|
73
|
+
* namespace: 'RampsService',
|
|
74
74
|
* parent: rootMessenger,
|
|
75
75
|
* });
|
|
76
76
|
* // Instantiate the service to register its actions on the messenger
|
|
77
|
-
* new
|
|
78
|
-
* messenger:
|
|
79
|
-
* environment:
|
|
77
|
+
* new RampsService({
|
|
78
|
+
* messenger: rampsServiceMessenger,
|
|
79
|
+
* environment: RampsEnvironment.Production,
|
|
80
80
|
* fetch,
|
|
81
81
|
* });
|
|
82
82
|
*
|
|
83
83
|
* // Later...
|
|
84
84
|
* // Get the user's geolocation
|
|
85
85
|
* const geolocation = await rootMessenger.call(
|
|
86
|
-
* '
|
|
86
|
+
* 'RampsService:getGeolocation',
|
|
87
87
|
* );
|
|
88
88
|
* // ... Do something with the geolocation ...
|
|
89
89
|
* ```
|
|
90
90
|
*/
|
|
91
|
-
export class
|
|
91
|
+
export class RampsService {
|
|
92
92
|
/**
|
|
93
|
-
* Constructs a new
|
|
93
|
+
* Constructs a new RampsService object.
|
|
94
94
|
*
|
|
95
95
|
* @param args - The constructor arguments.
|
|
96
96
|
* @param args.messenger - The messenger suited for this service.
|
|
@@ -102,31 +102,31 @@ export class OnRampService {
|
|
|
102
102
|
* @param args.policyOptions - Options to pass to `createServicePolicy`, which
|
|
103
103
|
* is used to wrap each request. See {@link CreateServicePolicyOptions}.
|
|
104
104
|
*/
|
|
105
|
-
constructor({ messenger, environment =
|
|
105
|
+
constructor({ messenger, environment = RampsEnvironment.Staging, fetch: fetchFunction, policyOptions = {}, }) {
|
|
106
106
|
/**
|
|
107
107
|
* The messenger suited for this service.
|
|
108
108
|
*/
|
|
109
|
-
|
|
109
|
+
_RampsService_messenger.set(this, void 0);
|
|
110
110
|
/**
|
|
111
111
|
* A function that can be used to make an HTTP request.
|
|
112
112
|
*/
|
|
113
|
-
|
|
113
|
+
_RampsService_fetch.set(this, void 0);
|
|
114
114
|
/**
|
|
115
115
|
* The policy that wraps the request.
|
|
116
116
|
*
|
|
117
117
|
* @see {@link createServicePolicy}
|
|
118
118
|
*/
|
|
119
|
-
|
|
119
|
+
_RampsService_policy.set(this, void 0);
|
|
120
120
|
/**
|
|
121
121
|
* The base URL for API requests.
|
|
122
122
|
*/
|
|
123
|
-
|
|
123
|
+
_RampsService_baseUrl.set(this, void 0);
|
|
124
124
|
this.name = serviceName;
|
|
125
|
-
__classPrivateFieldSet(this,
|
|
126
|
-
__classPrivateFieldSet(this,
|
|
127
|
-
__classPrivateFieldSet(this,
|
|
128
|
-
__classPrivateFieldSet(this,
|
|
129
|
-
__classPrivateFieldGet(this,
|
|
125
|
+
__classPrivateFieldSet(this, _RampsService_messenger, messenger, "f");
|
|
126
|
+
__classPrivateFieldSet(this, _RampsService_fetch, fetchFunction, "f");
|
|
127
|
+
__classPrivateFieldSet(this, _RampsService_policy, createServicePolicy(policyOptions), "f");
|
|
128
|
+
__classPrivateFieldSet(this, _RampsService_baseUrl, getBaseUrl(environment), "f");
|
|
129
|
+
__classPrivateFieldGet(this, _RampsService_messenger, "f").registerMethodActionHandlers(this, MESSENGER_EXPOSED_METHODS);
|
|
130
130
|
}
|
|
131
131
|
/**
|
|
132
132
|
* Registers a handler that will be called after a request returns a non-500
|
|
@@ -139,7 +139,7 @@ export class OnRampService {
|
|
|
139
139
|
* @see {@link createServicePolicy}
|
|
140
140
|
*/
|
|
141
141
|
onRetry(listener) {
|
|
142
|
-
return __classPrivateFieldGet(this,
|
|
142
|
+
return __classPrivateFieldGet(this, _RampsService_policy, "f").onRetry(listener);
|
|
143
143
|
}
|
|
144
144
|
/**
|
|
145
145
|
* Registers a handler that will be called after a set number of retry rounds
|
|
@@ -151,7 +151,7 @@ export class OnRampService {
|
|
|
151
151
|
* @see {@link createServicePolicy}
|
|
152
152
|
*/
|
|
153
153
|
onBreak(listener) {
|
|
154
|
-
return __classPrivateFieldGet(this,
|
|
154
|
+
return __classPrivateFieldGet(this, _RampsService_policy, "f").onBreak(listener);
|
|
155
155
|
}
|
|
156
156
|
/**
|
|
157
157
|
* Registers a handler that will be called under one of two circumstances:
|
|
@@ -171,7 +171,7 @@ export class OnRampService {
|
|
|
171
171
|
* {@link CockatielEvent}.
|
|
172
172
|
*/
|
|
173
173
|
onDegraded(listener) {
|
|
174
|
-
return __classPrivateFieldGet(this,
|
|
174
|
+
return __classPrivateFieldGet(this, _RampsService_policy, "f").onDegraded(listener);
|
|
175
175
|
}
|
|
176
176
|
/**
|
|
177
177
|
* Makes a request to the API in order to retrieve the user's geolocation
|
|
@@ -180,15 +180,17 @@ export class OnRampService {
|
|
|
180
180
|
* @returns The user's country/region code (e.g., "US-UT" for Utah, USA).
|
|
181
181
|
*/
|
|
182
182
|
async getGeolocation() {
|
|
183
|
-
const
|
|
184
|
-
const url = new URL('geolocation', __classPrivateFieldGet(this,
|
|
185
|
-
const localResponse = await __classPrivateFieldGet(this,
|
|
183
|
+
const responseData = await __classPrivateFieldGet(this, _RampsService_policy, "f").execute(async () => {
|
|
184
|
+
const url = new URL('geolocation', __classPrivateFieldGet(this, _RampsService_baseUrl, "f"));
|
|
185
|
+
const localResponse = await __classPrivateFieldGet(this, _RampsService_fetch, "f").call(this, url);
|
|
186
186
|
if (!localResponse.ok) {
|
|
187
187
|
throw new HttpError(localResponse.status, `Fetching '${url.toString()}' failed with status '${localResponse.status}'`);
|
|
188
188
|
}
|
|
189
|
-
|
|
189
|
+
const textResponse = await localResponse.text();
|
|
190
|
+
// Return both response and text content since we consumed the body
|
|
191
|
+
return { response: localResponse, text: textResponse };
|
|
190
192
|
});
|
|
191
|
-
const textResponse =
|
|
193
|
+
const textResponse = responseData.text;
|
|
192
194
|
const trimmedResponse = textResponse.trim();
|
|
193
195
|
if (trimmedResponse.length > 0) {
|
|
194
196
|
return trimmedResponse;
|
|
@@ -196,5 +198,5 @@ export class OnRampService {
|
|
|
196
198
|
throw new Error('Malformed response received from geolocation API');
|
|
197
199
|
}
|
|
198
200
|
}
|
|
199
|
-
_a =
|
|
200
|
-
//# sourceMappingURL=
|
|
201
|
+
_a = RampsService, _RampsService_messenger = new WeakMap(), _RampsService_fetch = new WeakMap(), _RampsService_policy = new WeakMap(), _RampsService_baseUrl = new WeakMap();
|
|
202
|
+
//# sourceMappingURL=RampsService.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RampsService.mjs","sourceRoot":"","sources":["../src/RampsService.ts"],"names":[],"mappings":";;;;;;;;;;;;AAIA,OAAO,EAAE,mBAAmB,EAAE,SAAS,EAAE,mCAAmC;AAK5E,kBAAkB;AAElB;;;GAGG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,cAAc,CAAC;AAE1C;;GAEG;AACH,MAAM,CAAN,IAAY,gBAIX;AAJD,WAAY,gBAAgB;IAC1B,6CAAyB,CAAA;IACzB,uCAAmB,CAAA;IACnB,+CAA2B,CAAA;AAC7B,CAAC,EAJW,gBAAgB,KAAhB,gBAAgB,QAI3B;AAED,oBAAoB;AAEpB,MAAM,yBAAyB,GAAG,CAAC,gBAAgB,CAAU,CAAC;AAgC9D,6BAA6B;AAE7B;;;;;GAKG;AACH,SAAS,UAAU,CAAC,WAA6B;IAC/C,QAAQ,WAAW,EAAE,CAAC;QACpB,KAAK,gBAAgB,CAAC,UAAU;YAC9B,OAAO,oCAAoC,CAAC;QAC9C,KAAK,gBAAgB,CAAC,OAAO;YAC3B,OAAO,wCAAwC,CAAC;QAClD,KAAK,gBAAgB,CAAC,WAAW;YAC/B,OAAO,uBAAuB,CAAC;QACjC;YACE,MAAM,IAAI,KAAK,CAAC,wBAAwB,MAAM,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC;IACnE,CAAC;AACH,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AACH,MAAM,OAAO,YAAY;IA8BvB;;;;;;;;;;;;OAYG;IACH,YAAY,EACV,SA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Q,GAAG,CAAC,CAAC;YAC7C,IAAI,CAAC,aAAa,CAAC,EAAE,EAAE,CAAC;gBACtB,MAAM,IAAI,SAAS,CACjB,aAAa,CAAC,MAAM,EACpB,aAAa,GAAG,CAAC,QAAQ,EAAE,yBAAyB,aAAa,CAAC,MAAM,GAAG,CAC5E,CAAC;YACJ,CAAC;YACD,MAAM,YAAY,GAAG,MAAM,aAAa,CAAC,IAAI,EAAE,CAAC;YAChD,mEAAmE;YACnE,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,IAAI,EAAE,YAAY,EAAE,CAAC;QACzD,CAAC,CAAC,CAAC;QAEH,MAAM,YAAY,GAAG,YAAY,CAAC,IAAI,CAAC;QACvC,MAAM,eAAe,GAAG,YAAY,CAAC,IAAI,EAAE,CAAC;QAE5C,IAAI,eAAe,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAC/B,OAAO,eAAe,CAAC;QACzB,CAAC;QAED,MAAM,IAAI,KAAK,CAAC,kDAAkD,CAAC,CAAC;IACtE,CAAC;CACF","sourcesContent":["import type {\n CreateServicePolicyOptions,\n ServicePolicy,\n} from '@metamask/controller-utils';\nimport { createServicePolicy, HttpError } from '@metamask/controller-utils';\nimport type { Messenger } from '@metamask/messenger';\n\nimport type { RampsServiceMethodActions } from './RampsService-method-action-types';\n\n// === GENERAL ===\n\n/**\n * The name of the {@link RampsService}, used to namespace the\n * service's actions and events.\n */\nexport const serviceName = 'RampsService';\n\n/**\n * The environment to use for API requests.\n */\nexport enum RampsEnvironment {\n Production = 'production',\n Staging = 'staging',\n Development = 'development',\n}\n\n// === MESSENGER ===\n\nconst MESSENGER_EXPOSED_METHODS = ['getGeolocation'] as const;\n\n/**\n * Actions that {@link RampsService} exposes to other consumers.\n */\nexport type RampsServiceActions = RampsServiceMethodActions;\n\n/**\n * Actions from other messengers that {@link RampsService} calls.\n */\ntype AllowedActions = never;\n\n/**\n * Events that {@link RampsService} exposes to other consumers.\n */\nexport type RampsServiceEvents = never;\n\n/**\n * Events from other messengers that {@link RampsService} subscribes to.\n */\ntype AllowedEvents = never;\n\n/**\n * The messenger which is restricted to actions and events accessed by\n * {@link RampsService}.\n */\nexport type RampsServiceMessenger = Messenger<\n typeof serviceName,\n RampsServiceActions | AllowedActions,\n RampsServiceEvents | AllowedEvents\n>;\n\n// === SERVICE DEFINITION ===\n\n/**\n * Gets the base URL for API requests based on the environment.\n *\n * @param environment - The environment to use.\n * @returns The base URL for API requests.\n */\nfunction getBaseUrl(environment: RampsEnvironment): string {\n switch (environment) {\n case RampsEnvironment.Production:\n return 'https://on-ramp.api.cx.metamask.io';\n case RampsEnvironment.Staging:\n return 'https://on-ramp.uat-api.cx.metamask.io';\n case RampsEnvironment.Development:\n return 'http://localhost:3000';\n default:\n throw new Error(`Invalid environment: ${String(environment)}`);\n }\n}\n\n/**\n * This service object is responsible for interacting with the Ramps API.\n *\n * @example\n *\n * ``` ts\n * import { Messenger } from '@metamask/messenger';\n * import type {\n * RampsServiceActions,\n * RampsServiceEvents,\n * } from '@metamask/ramps-controller';\n *\n * const rootMessenger = new Messenger<\n * 'Root',\n * RampsServiceActions\n * RampsServiceEvents\n * >({ namespace: 'Root' });\n * const rampsServiceMessenger = new Messenger<\n * 'RampsService',\n * RampsServiceActions,\n * RampsServiceEvents,\n * typeof rootMessenger,\n * >({\n * namespace: 'RampsService',\n * parent: rootMessenger,\n * });\n * // Instantiate the service to register its actions on the messenger\n * new RampsService({\n * messenger: rampsServiceMessenger,\n * environment: RampsEnvironment.Production,\n * fetch,\n * });\n *\n * // Later...\n * // Get the user's geolocation\n * const geolocation = await rootMessenger.call(\n * 'RampsService:getGeolocation',\n * );\n * // ... Do something with the geolocation ...\n * ```\n */\nexport class RampsService {\n /**\n * The name of the service.\n */\n readonly name: typeof serviceName;\n\n /**\n * The messenger suited for this service.\n */\n readonly #messenger: ConstructorParameters<\n typeof RampsService\n >[0]['messenger'];\n\n /**\n * A function that can be used to make an HTTP request.\n */\n readonly #fetch: ConstructorParameters<typeof RampsService>[0]['fetch'];\n\n /**\n * The policy that wraps the request.\n *\n * @see {@link createServicePolicy}\n */\n readonly #policy: ServicePolicy;\n\n /**\n * The base URL for API requests.\n */\n readonly #baseUrl: string;\n\n /**\n * Constructs a new RampsService object.\n *\n * @param args - The constructor arguments.\n * @param args.messenger - The messenger suited for this service.\n * @param args.environment - The environment to use for API requests.\n * @param args.fetch - A function that can be used to make an HTTP request. If\n * your JavaScript environment supports `fetch` natively, you'll probably want\n * to pass that; otherwise you can pass an equivalent (such as `fetch` via\n * `node-fetch`).\n * @param args.policyOptions - Options to pass to `createServicePolicy`, which\n * is used to wrap each request. See {@link CreateServicePolicyOptions}.\n */\n constructor({\n messenger,\n environment = RampsEnvironment.Staging,\n fetch: fetchFunction,\n policyOptions = {},\n }: {\n messenger: RampsServiceMessenger;\n environment?: RampsEnvironment;\n fetch: typeof fetch;\n policyOptions?: CreateServicePolicyOptions;\n }) {\n this.name = serviceName;\n this.#messenger = messenger;\n this.#fetch = fetchFunction;\n this.#policy = createServicePolicy(policyOptions);\n this.#baseUrl = getBaseUrl(environment);\n\n this.#messenger.registerMethodActionHandlers(\n this,\n MESSENGER_EXPOSED_METHODS,\n );\n }\n\n /**\n * Registers a handler that will be called after a request returns a non-500\n * response, causing a retry. Primarily useful in tests where timers are being\n * mocked.\n *\n * @param listener - The handler to be called.\n * @returns An object that can be used to unregister the handler. See\n * {@link CockatielEvent}.\n * @see {@link createServicePolicy}\n */\n onRetry(\n listener: Parameters<ServicePolicy['onRetry']>[0],\n ): ReturnType<ServicePolicy['onRetry']> {\n return this.#policy.onRetry(listener);\n }\n\n /**\n * Registers a handler that will be called after a set number of retry rounds\n * prove that requests to the API endpoint consistently return a 5xx response.\n *\n * @param listener - The handler to be called.\n * @returns An object that can be used to unregister the handler. See\n * {@link CockatielEvent}.\n * @see {@link createServicePolicy}\n */\n onBreak(\n listener: Parameters<ServicePolicy['onBreak']>[0],\n ): ReturnType<ServicePolicy['onBreak']> {\n return this.#policy.onBreak(listener);\n }\n\n /**\n * Registers a handler that will be called under one of two circumstances:\n *\n * 1. After a set number of retries prove that requests to the API\n * consistently result in one of the following failures:\n * 1. A connection initiation error\n * 2. A connection reset error\n * 3. A timeout error\n * 4. A non-JSON response\n * 5. A 502, 503, or 504 response\n * 2. After a successful request is made to the API, but the response takes\n * longer than a set duration to return.\n *\n * @param listener - The handler to be called.\n * @returns An object that can be used to unregister the handler. See\n * {@link CockatielEvent}.\n */\n onDegraded(\n listener: Parameters<ServicePolicy['onDegraded']>[0],\n ): ReturnType<ServicePolicy['onDegraded']> {\n return this.#policy.onDegraded(listener);\n }\n\n /**\n * Makes a request to the API in order to retrieve the user's geolocation\n * based on their IP address.\n *\n * @returns The user's country/region code (e.g., \"US-UT\" for Utah, USA).\n */\n async getGeolocation(): Promise<string> {\n const responseData = await this.#policy.execute(async () => {\n const url = new URL('geolocation', this.#baseUrl);\n const localResponse = await this.#fetch(url);\n if (!localResponse.ok) {\n throw new HttpError(\n localResponse.status,\n `Fetching '${url.toString()}' failed with status '${localResponse.status}'`,\n );\n }\n const textResponse = await localResponse.text();\n // Return both response and text content since we consumed the body\n return { response: localResponse, text: textResponse };\n });\n\n const textResponse = responseData.text;\n const trimmedResponse = textResponse.trim();\n\n if (trimmedResponse.length > 0) {\n return trimmedResponse;\n }\n\n throw new Error('Malformed response received from geolocation API');\n }\n}\n"]}
|
package/dist/index.cjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.RampsEnvironment = exports.RampsService = exports.getDefaultRampsControllerState = exports.RampsController = void 0;
|
|
4
4
|
var RampsController_1 = require("./RampsController.cjs");
|
|
5
5
|
Object.defineProperty(exports, "RampsController", { enumerable: true, get: function () { return RampsController_1.RampsController; } });
|
|
6
6
|
Object.defineProperty(exports, "getDefaultRampsControllerState", { enumerable: true, get: function () { return RampsController_1.getDefaultRampsControllerState; } });
|
|
7
|
-
var
|
|
8
|
-
Object.defineProperty(exports, "
|
|
9
|
-
Object.defineProperty(exports, "
|
|
7
|
+
var RampsService_1 = require("./RampsService.cjs");
|
|
8
|
+
Object.defineProperty(exports, "RampsService", { enumerable: true, get: function () { return RampsService_1.RampsService; } });
|
|
9
|
+
Object.defineProperty(exports, "RampsEnvironment", { enumerable: true, get: function () { return RampsService_1.RampsEnvironment; } });
|
|
10
10
|
//# sourceMappingURL=index.cjs.map
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAQA,yDAG2B;AAFzB,kHAAA,eAAe,OAAA;AACf,iIAAA,8BAA8B,OAAA;AAOhC,
|
|
1
|
+
{"version":3,"file":"index.cjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAQA,yDAG2B;AAFzB,kHAAA,eAAe,OAAA;AACf,iIAAA,8BAA8B,OAAA;AAOhC,mDAAgE;AAAvD,4GAAA,YAAY,OAAA;AAAE,gHAAA,gBAAgB,OAAA","sourcesContent":["export type {\n RampsControllerActions,\n RampsControllerEvents,\n RampsControllerGetStateAction,\n RampsControllerMessenger,\n RampsControllerState,\n RampsControllerStateChangeEvent,\n} from './RampsController';\nexport {\n RampsController,\n getDefaultRampsControllerState,\n} from './RampsController';\nexport type {\n RampsServiceActions,\n RampsServiceEvents,\n RampsServiceMessenger,\n} from './RampsService';\nexport { RampsService, RampsEnvironment } from './RampsService';\nexport type { RampsServiceGetGeolocationAction } from './RampsService-method-action-types';\n"]}
|
package/dist/index.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export type { RampsControllerActions, RampsControllerEvents, RampsControllerGetStateAction, RampsControllerMessenger, RampsControllerState, RampsControllerStateChangeEvent, } from "./RampsController.cjs";
|
|
2
2
|
export { RampsController, getDefaultRampsControllerState, } from "./RampsController.cjs";
|
|
3
|
-
export type {
|
|
4
|
-
export {
|
|
5
|
-
export type {
|
|
3
|
+
export type { RampsServiceActions, RampsServiceEvents, RampsServiceMessenger, } from "./RampsService.cjs";
|
|
4
|
+
export { RampsService, RampsEnvironment } from "./RampsService.cjs";
|
|
5
|
+
export type { RampsServiceGetGeolocationAction } from "./RampsService-method-action-types.cjs";
|
|
6
6
|
//# sourceMappingURL=index.d.cts.map
|
package/dist/index.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.cts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,sBAAsB,EACtB,qBAAqB,EACrB,6BAA6B,EAC7B,wBAAwB,EACxB,oBAAoB,EACpB,+BAA+B,GAChC,8BAA0B;AAC3B,OAAO,EACL,eAAe,EACf,8BAA8B,GAC/B,8BAA0B;AAC3B,YAAY,EACV,
|
|
1
|
+
{"version":3,"file":"index.d.cts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,sBAAsB,EACtB,qBAAqB,EACrB,6BAA6B,EAC7B,wBAAwB,EACxB,oBAAoB,EACpB,+BAA+B,GAChC,8BAA0B;AAC3B,OAAO,EACL,eAAe,EACf,8BAA8B,GAC/B,8BAA0B;AAC3B,YAAY,EACV,mBAAmB,EACnB,kBAAkB,EAClB,qBAAqB,GACtB,2BAAuB;AACxB,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,2BAAuB;AAChE,YAAY,EAAE,gCAAgC,EAAE,+CAA2C"}
|
package/dist/index.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export type { RampsControllerActions, RampsControllerEvents, RampsControllerGetStateAction, RampsControllerMessenger, RampsControllerState, RampsControllerStateChangeEvent, } from "./RampsController.mjs";
|
|
2
2
|
export { RampsController, getDefaultRampsControllerState, } from "./RampsController.mjs";
|
|
3
|
-
export type {
|
|
4
|
-
export {
|
|
5
|
-
export type {
|
|
3
|
+
export type { RampsServiceActions, RampsServiceEvents, RampsServiceMessenger, } from "./RampsService.mjs";
|
|
4
|
+
export { RampsService, RampsEnvironment } from "./RampsService.mjs";
|
|
5
|
+
export type { RampsServiceGetGeolocationAction } from "./RampsService-method-action-types.mjs";
|
|
6
6
|
//# sourceMappingURL=index.d.mts.map
|
package/dist/index.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,sBAAsB,EACtB,qBAAqB,EACrB,6BAA6B,EAC7B,wBAAwB,EACxB,oBAAoB,EACpB,+BAA+B,GAChC,8BAA0B;AAC3B,OAAO,EACL,eAAe,EACf,8BAA8B,GAC/B,8BAA0B;AAC3B,YAAY,EACV,
|
|
1
|
+
{"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,sBAAsB,EACtB,qBAAqB,EACrB,6BAA6B,EAC7B,wBAAwB,EACxB,oBAAoB,EACpB,+BAA+B,GAChC,8BAA0B;AAC3B,OAAO,EACL,eAAe,EACf,8BAA8B,GAC/B,8BAA0B;AAC3B,YAAY,EACV,mBAAmB,EACnB,kBAAkB,EAClB,qBAAqB,GACtB,2BAAuB;AACxB,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,2BAAuB;AAChE,YAAY,EAAE,gCAAgC,EAAE,+CAA2C"}
|
package/dist/index.mjs
CHANGED
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAQA,OAAO,EACL,eAAe,EACf,8BAA8B,EAC/B,8BAA0B;AAM3B,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.mjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAQA,OAAO,EACL,eAAe,EACf,8BAA8B,EAC/B,8BAA0B;AAM3B,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,2BAAuB","sourcesContent":["export type {\n RampsControllerActions,\n RampsControllerEvents,\n RampsControllerGetStateAction,\n RampsControllerMessenger,\n RampsControllerState,\n RampsControllerStateChangeEvent,\n} from './RampsController';\nexport {\n RampsController,\n getDefaultRampsControllerState,\n} from './RampsController';\nexport type {\n RampsServiceActions,\n RampsServiceEvents,\n RampsServiceMessenger,\n} from './RampsService';\nexport { RampsService, RampsEnvironment } from './RampsService';\nexport type { RampsServiceGetGeolocationAction } from './RampsService-method-action-types';\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@metamask/ramps-controller",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"description": "A controller for managing cryptocurrency on/off ramps functionality",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"MetaMask",
|
|
@@ -40,6 +40,7 @@
|
|
|
40
40
|
"build:docs": "typedoc",
|
|
41
41
|
"changelog:update": "../../scripts/update-changelog.sh @metamask/ramps-controller",
|
|
42
42
|
"changelog:validate": "../../scripts/validate-changelog.sh @metamask/ramps-controller",
|
|
43
|
+
"dev": "node dev-watch.js",
|
|
43
44
|
"publish:preview": "yarn npm publish --tag preview",
|
|
44
45
|
"since-latest-release": "../../scripts/since-latest-release.sh",
|
|
45
46
|
"test": "NODE_OPTIONS=--experimental-vm-modules jest --reporters=jest-silent-reporter",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"OnRampService-method-action-types.cjs","sourceRoot":"","sources":["../src/OnRampService-method-action-types.ts"],"names":[],"mappings":";AAAA;;;GAGG","sourcesContent":["/**\n * This file is auto generated by `scripts/generate-method-action-types.ts`.\n * Do not edit manually.\n */\n\nimport type { OnRampService } from './OnRampService';\n\n/**\n * Makes a request to the API in order to retrieve the user's geolocation\n * based on their IP address.\n *\n * @returns The user's country/region code (e.g., \"US-UT\" for Utah, USA).\n */\nexport type OnRampServiceGetGeolocationAction = {\n type: `OnRampService:getGeolocation`;\n handler: OnRampService['getGeolocation'];\n};\n\n/**\n * Union of all OnRampService action types.\n */\nexport type OnRampServiceMethodActions = OnRampServiceGetGeolocationAction;\n"]}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This file is auto generated by `scripts/generate-method-action-types.ts`.
|
|
3
|
-
* Do not edit manually.
|
|
4
|
-
*/
|
|
5
|
-
import type { OnRampService } from "./OnRampService.cjs";
|
|
6
|
-
/**
|
|
7
|
-
* Makes a request to the API in order to retrieve the user's geolocation
|
|
8
|
-
* based on their IP address.
|
|
9
|
-
*
|
|
10
|
-
* @returns The user's country/region code (e.g., "US-UT" for Utah, USA).
|
|
11
|
-
*/
|
|
12
|
-
export type OnRampServiceGetGeolocationAction = {
|
|
13
|
-
type: `OnRampService:getGeolocation`;
|
|
14
|
-
handler: OnRampService['getGeolocation'];
|
|
15
|
-
};
|
|
16
|
-
/**
|
|
17
|
-
* Union of all OnRampService action types.
|
|
18
|
-
*/
|
|
19
|
-
export type OnRampServiceMethodActions = OnRampServiceGetGeolocationAction;
|
|
20
|
-
//# sourceMappingURL=OnRampService-method-action-types.d.cts.map
|