@metamask/ramps-controller 3.0.0 → 4.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.
@@ -1,8 +1,8 @@
1
1
  import type { ControllerGetStateAction, ControllerStateChangeEvent } from "@metamask/base-controller";
2
2
  import { BaseController } from "@metamask/base-controller";
3
3
  import type { Messenger } from "@metamask/messenger";
4
- import type { Country, Eligibility, TokensResponse } from "./RampsService.cjs";
5
- import type { RampsServiceGetGeolocationAction, RampsServiceGetCountriesAction, RampsServiceGetEligibilityAction, RampsServiceGetTokensAction } from "./RampsService-method-action-types.cjs";
4
+ import type { Country, TokensResponse, Provider, State } from "./RampsService.cjs";
5
+ import type { RampsServiceGetGeolocationAction, RampsServiceGetCountriesAction, RampsServiceGetTokensAction, RampsServiceGetProvidersAction } from "./RampsService-method-action-types.cjs";
6
6
  import type { RequestCache as RequestCacheType, RequestState, ExecuteRequestOptions } from "./RequestCache.cjs";
7
7
  /**
8
8
  * The name of the {@link RampsController}, used to namespace the
@@ -10,19 +10,43 @@ import type { RequestCache as RequestCacheType, RequestState, ExecuteRequestOpti
10
10
  * when composed with other controllers.
11
11
  */
12
12
  export declare const controllerName = "RampsController";
13
+ /**
14
+ * Represents the user's selected region with full country and state objects.
15
+ */
16
+ export type UserRegion = {
17
+ /**
18
+ * The country object for the selected region.
19
+ */
20
+ country: Country;
21
+ /**
22
+ * The state object if a state was selected, null if only country was selected.
23
+ */
24
+ state: State | null;
25
+ /**
26
+ * The region code string (e.g., "us-ut" or "fr") used for API calls.
27
+ */
28
+ regionCode: string;
29
+ };
13
30
  /**
14
31
  * Describes the shape of the state object for {@link RampsController}.
15
32
  */
16
33
  export type RampsControllerState = {
17
34
  /**
18
- * The user's selected region code (e.g., "US-CA").
35
+ * The user's selected region with full country and state objects.
19
36
  * Initially set via geolocation fetch, but can be manually changed by the user.
37
+ * Once set (either via geolocation or manual selection), it will not be overwritten
38
+ * by subsequent geolocation fetches.
20
39
  */
21
- userRegion: string | null;
40
+ userRegion: UserRegion | null;
22
41
  /**
23
- * Eligibility information for the user's current region.
42
+ * The user's preferred provider.
43
+ * Can be manually set by the user.
24
44
  */
25
- eligibility: Eligibility | null;
45
+ preferredProvider: Provider | null;
46
+ /**
47
+ * List of providers available for the current region.
48
+ */
49
+ providers: Provider[];
26
50
  /**
27
51
  * Tokens fetched for the current region and action.
28
52
  * Contains topTokens and allTokens arrays.
@@ -54,7 +78,7 @@ export type RampsControllerActions = RampsControllerGetStateAction;
54
78
  /**
55
79
  * Actions from other messengers that {@link RampsController} calls.
56
80
  */
57
- type AllowedActions = RampsServiceGetGeolocationAction | RampsServiceGetCountriesAction | RampsServiceGetEligibilityAction | RampsServiceGetTokensAction;
81
+ type AllowedActions = RampsServiceGetGeolocationAction | RampsServiceGetCountriesAction | RampsServiceGetTokensAction | RampsServiceGetProvidersAction;
58
82
  /**
59
83
  * Published when the state of {@link RampsController} changes.
60
84
  */
@@ -129,47 +153,47 @@ export declare class RampsController extends BaseController<typeof controllerNam
129
153
  */
130
154
  getRequestState(cacheKey: string): RequestState | undefined;
131
155
  /**
132
- * Updates the user's region by fetching geolocation and eligibility.
133
- * This method calls the RampsService to get the geolocation,
134
- * then automatically fetches eligibility for that region.
156
+ * Updates the user's region by fetching geolocation.
157
+ * This method calls the RampsService to get the geolocation.
135
158
  *
136
159
  * @param options - Options for cache behavior.
137
- * @returns The user region string.
160
+ * @returns The user region object.
138
161
  */
139
- updateUserRegion(options?: ExecuteRequestOptions): Promise<string>;
162
+ updateUserRegion(options?: ExecuteRequestOptions): Promise<UserRegion | null>;
140
163
  /**
141
164
  * Sets the user's region manually (without fetching geolocation).
142
165
  * This allows users to override the detected region.
143
166
  *
144
167
  * @param region - The region code to set (e.g., "US-CA").
145
- * @param options - Options for cache behavior when fetching eligibility.
146
- * @returns The eligibility information for the region.
168
+ * @param options - Options for cache behavior.
169
+ * @returns The user region object.
147
170
  */
148
- setUserRegion(region: string, options?: ExecuteRequestOptions): Promise<Eligibility>;
171
+ setUserRegion(region: string, options?: ExecuteRequestOptions): Promise<UserRegion>;
172
+ /**
173
+ * Sets the user's preferred provider.
174
+ * This allows users to set their preferred ramp provider.
175
+ *
176
+ * @param provider - The provider object to set.
177
+ */
178
+ setPreferredProvider(provider: Provider | null): void;
149
179
  /**
150
180
  * Initializes the controller by fetching the user's region from geolocation.
151
181
  * This should be called once at app startup to set up the initial region.
152
- * After the region is set and eligibility is determined, tokens are fetched
153
- * and saved to state.
182
+ * After the region is set, tokens are fetched and saved to state.
183
+ *
184
+ * If a userRegion already exists (from persistence or manual selection),
185
+ * this method will skip geolocation fetch and only fetch tokens if needed.
154
186
  *
155
187
  * @param options - Options for cache behavior.
156
188
  * @returns Promise that resolves when initialization is complete.
157
189
  */
158
190
  init(options?: ExecuteRequestOptions): Promise<void>;
159
- /**
160
- * Updates the eligibility information for a given region.
161
- *
162
- * @param isoCode - The ISO code for the region (e.g., "us", "fr", "us-ny").
163
- * @param options - Options for cache behavior.
164
- * @returns The eligibility information.
165
- */
166
- updateEligibility(isoCode: string, options?: ExecuteRequestOptions): Promise<Eligibility>;
167
191
  /**
168
192
  * Fetches the list of supported countries for a given ramp action.
169
193
  *
170
194
  * @param action - The ramp action type ('buy' or 'sell').
171
195
  * @param options - Options for cache behavior.
172
- * @returns An array of countries with their eligibility information.
196
+ * @returns An array of countries.
173
197
  */
174
198
  getCountries(action?: 'buy' | 'sell', options?: ExecuteRequestOptions): Promise<Country[]>;
175
199
  /**
@@ -182,6 +206,26 @@ export declare class RampsController extends BaseController<typeof controllerNam
182
206
  * @returns The tokens response containing topTokens and allTokens.
183
207
  */
184
208
  getTokens(region?: string, action?: 'buy' | 'sell', options?: ExecuteRequestOptions): Promise<TokensResponse>;
209
+ /**
210
+ * Fetches the list of providers for a given region.
211
+ * The providers are saved in the controller state once fetched.
212
+ *
213
+ * @param region - The region code (e.g., "us", "fr", "us-ny"). If not provided, uses the user's region from controller state.
214
+ * @param options - Options for cache behavior and query filters.
215
+ * @param options.provider - Provider ID(s) to filter by.
216
+ * @param options.crypto - Crypto currency ID(s) to filter by.
217
+ * @param options.fiat - Fiat currency ID(s) to filter by.
218
+ * @param options.payments - Payment method ID(s) to filter by.
219
+ * @returns The providers response containing providers array.
220
+ */
221
+ getProviders(region?: string, options?: ExecuteRequestOptions & {
222
+ provider?: string | string[];
223
+ crypto?: string | string[];
224
+ fiat?: string | string[];
225
+ payments?: string | string[];
226
+ }): Promise<{
227
+ providers: Provider[];
228
+ }>;
185
229
  }
186
230
  export {};
187
231
  //# sourceMappingURL=RampsController.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"RampsController.d.cts","sourceRoot":"","sources":["../src/RampsController.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;AAGrD,OAAO,KAAK,EAAE,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,2BAAuB;AAC3E,OAAO,KAAK,EACV,gCAAgC,EAChC,8BAA8B,EAC9B,gCAAgC,EAChC,2BAA2B,EAC5B,+CAA2C;AAC5C,OAAO,KAAK,EACV,YAAY,IAAI,gBAAgB,EAChC,YAAY,EACZ,qBAAqB,EAEtB,2BAAuB;AAaxB;;;;GAIG;AACH,eAAO,MAAM,cAAc,oBAAoB,CAAC;AAIhD;;GAEG;AACH,MAAM,MAAM,oBAAoB,GAAG;IACjC;;;OAGG;IACH,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B;;OAEG;IACH,WAAW,EAAE,WAAW,GAAG,IAAI,CAAC;IAChC;;;OAGG;IACH,MAAM,EAAE,cAAc,GAAG,IAAI,CAAC;IAC9B;;;OAGG;IACH,QAAQ,EAAE,gBAAgB,CAAC;CAC5B,CAAC;AAgCF;;;;;;;GAOG;AACH,wBAAgB,8BAA8B,IAAI,oBAAo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qB,GAC9B,OAAO,CAAC,UAAU,CAAC;IAmDtB;;;;;OAKG;IACH,oBAAoB,CAAC,QAAQ,EAAE,QAAQ,GAAG,IAAI,GAAG,IAAI;IAMrD;;;;;;;;;;OAUG;IACG,IAAI,CAAC,OAAO,CAAC,EAAE,qBAAqB,GAAG,OAAO,CAAC,IAAI,CAAC;IAqB1D;;;;;;OAMG;IACG,YAAY,CAChB,MAAM,GAAE,KAAK,GAAG,MAAc,EAC9B,OAAO,CAAC,EAAE,qBAAqB,GAC9B,OAAO,CAAC,OAAO,EAAE,CAAC;IAYrB;;;;;;;;OAQG;IACG,SAAS,CACb,MAAM,CAAC,EAAE,MAAM,EACf,MAAM,GAAE,KAAK,GAAG,MAAc,EAC9B,OAAO,CAAC,EAAE,qBAAqB,GAC9B,OAAO,CAAC,cAAc,CAAC;IAmC1B;;;;;;;;;;;OAWG;IACG,YAAY,CAChB,MAAM,CAAC,EAAE,MAAM,EACf,OAAO,CAAC,EAAE,qBAAqB,GAAG;QAChC,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;QAC7B,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;QAC3B,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;QACzB,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;KAC9B,GACA,OAAO,CAAC;QAAE,SAAS,EAAE,QAAQ,EAAE,CAAA;KAAE,CAAC;CA6CtC"}
@@ -1,8 +1,8 @@
1
1
  import type { ControllerGetStateAction, ControllerStateChangeEvent } from "@metamask/base-controller";
2
2
  import { BaseController } from "@metamask/base-controller";
3
3
  import type { Messenger } from "@metamask/messenger";
4
- import type { Country, Eligibility, TokensResponse } from "./RampsService.mjs";
5
- import type { RampsServiceGetGeolocationAction, RampsServiceGetCountriesAction, RampsServiceGetEligibilityAction, RampsServiceGetTokensAction } from "./RampsService-method-action-types.mjs";
4
+ import type { Country, TokensResponse, Provider, State } from "./RampsService.mjs";
5
+ import type { RampsServiceGetGeolocationAction, RampsServiceGetCountriesAction, RampsServiceGetTokensAction, RampsServiceGetProvidersAction } from "./RampsService-method-action-types.mjs";
6
6
  import type { RequestCache as RequestCacheType, RequestState, ExecuteRequestOptions } from "./RequestCache.mjs";
7
7
  /**
8
8
  * The name of the {@link RampsController}, used to namespace the
@@ -10,19 +10,43 @@ import type { RequestCache as RequestCacheType, RequestState, ExecuteRequestOpti
10
10
  * when composed with other controllers.
11
11
  */
12
12
  export declare const controllerName = "RampsController";
13
+ /**
14
+ * Represents the user's selected region with full country and state objects.
15
+ */
16
+ export type UserRegion = {
17
+ /**
18
+ * The country object for the selected region.
19
+ */
20
+ country: Country;
21
+ /**
22
+ * The state object if a state was selected, null if only country was selected.
23
+ */
24
+ state: State | null;
25
+ /**
26
+ * The region code string (e.g., "us-ut" or "fr") used for API calls.
27
+ */
28
+ regionCode: string;
29
+ };
13
30
  /**
14
31
  * Describes the shape of the state object for {@link RampsController}.
15
32
  */
16
33
  export type RampsControllerState = {
17
34
  /**
18
- * The user's selected region code (e.g., "US-CA").
35
+ * The user's selected region with full country and state objects.
19
36
  * Initially set via geolocation fetch, but can be manually changed by the user.
37
+ * Once set (either via geolocation or manual selection), it will not be overwritten
38
+ * by subsequent geolocation fetches.
20
39
  */
21
- userRegion: string | null;
40
+ userRegion: UserRegion | null;
22
41
  /**
23
- * Eligibility information for the user's current region.
42
+ * The user's preferred provider.
43
+ * Can be manually set by the user.
24
44
  */
25
- eligibility: Eligibility | null;
45
+ preferredProvider: Provider | null;
46
+ /**
47
+ * List of providers available for the current region.
48
+ */
49
+ providers: Provider[];
26
50
  /**
27
51
  * Tokens fetched for the current region and action.
28
52
  * Contains topTokens and allTokens arrays.
@@ -54,7 +78,7 @@ export type RampsControllerActions = RampsControllerGetStateAction;
54
78
  /**
55
79
  * Actions from other messengers that {@link RampsController} calls.
56
80
  */
57
- type AllowedActions = RampsServiceGetGeolocationAction | RampsServiceGetCountriesAction | RampsServiceGetEligibilityAction | RampsServiceGetTokensAction;
81
+ type AllowedActions = RampsServiceGetGeolocationAction | RampsServiceGetCountriesAction | RampsServiceGetTokensAction | RampsServiceGetProvidersAction;
58
82
  /**
59
83
  * Published when the state of {@link RampsController} changes.
60
84
  */
@@ -129,47 +153,47 @@ export declare class RampsController extends BaseController<typeof controllerNam
129
153
  */
130
154
  getRequestState(cacheKey: string): RequestState | undefined;
131
155
  /**
132
- * Updates the user's region by fetching geolocation and eligibility.
133
- * This method calls the RampsService to get the geolocation,
134
- * then automatically fetches eligibility for that region.
156
+ * Updates the user's region by fetching geolocation.
157
+ * This method calls the RampsService to get the geolocation.
135
158
  *
136
159
  * @param options - Options for cache behavior.
137
- * @returns The user region string.
160
+ * @returns The user region object.
138
161
  */
139
- updateUserRegion(options?: ExecuteRequestOptions): Promise<string>;
162
+ updateUserRegion(options?: ExecuteRequestOptions): Promise<UserRegion | null>;
140
163
  /**
141
164
  * Sets the user's region manually (without fetching geolocation).
142
165
  * This allows users to override the detected region.
143
166
  *
144
167
  * @param region - The region code to set (e.g., "US-CA").
145
- * @param options - Options for cache behavior when fetching eligibility.
146
- * @returns The eligibility information for the region.
168
+ * @param options - Options for cache behavior.
169
+ * @returns The user region object.
147
170
  */
148
- setUserRegion(region: string, options?: ExecuteRequestOptions): Promise<Eligibility>;
171
+ setUserRegion(region: string, options?: ExecuteRequestOptions): Promise<UserRegion>;
172
+ /**
173
+ * Sets the user's preferred provider.
174
+ * This allows users to set their preferred ramp provider.
175
+ *
176
+ * @param provider - The provider object to set.
177
+ */
178
+ setPreferredProvider(provider: Provider | null): void;
149
179
  /**
150
180
  * Initializes the controller by fetching the user's region from geolocation.
151
181
  * This should be called once at app startup to set up the initial region.
152
- * After the region is set and eligibility is determined, tokens are fetched
153
- * and saved to state.
182
+ * After the region is set, tokens are fetched and saved to state.
183
+ *
184
+ * If a userRegion already exists (from persistence or manual selection),
185
+ * this method will skip geolocation fetch and only fetch tokens if needed.
154
186
  *
155
187
  * @param options - Options for cache behavior.
156
188
  * @returns Promise that resolves when initialization is complete.
157
189
  */
158
190
  init(options?: ExecuteRequestOptions): Promise<void>;
159
- /**
160
- * Updates the eligibility information for a given region.
161
- *
162
- * @param isoCode - The ISO code for the region (e.g., "us", "fr", "us-ny").
163
- * @param options - Options for cache behavior.
164
- * @returns The eligibility information.
165
- */
166
- updateEligibility(isoCode: string, options?: ExecuteRequestOptions): Promise<Eligibility>;
167
191
  /**
168
192
  * Fetches the list of supported countries for a given ramp action.
169
193
  *
170
194
  * @param action - The ramp action type ('buy' or 'sell').
171
195
  * @param options - Options for cache behavior.
172
- * @returns An array of countries with their eligibility information.
196
+ * @returns An array of countries.
173
197
  */
174
198
  getCountries(action?: 'buy' | 'sell', options?: ExecuteRequestOptions): Promise<Country[]>;
175
199
  /**
@@ -182,6 +206,26 @@ export declare class RampsController extends BaseController<typeof controllerNam
182
206
  * @returns The tokens response containing topTokens and allTokens.
183
207
  */
184
208
  getTokens(region?: string, action?: 'buy' | 'sell', options?: ExecuteRequestOptions): Promise<TokensResponse>;
209
+ /**
210
+ * Fetches the list of providers for a given region.
211
+ * The providers are saved in the controller state once fetched.
212
+ *
213
+ * @param region - The region code (e.g., "us", "fr", "us-ny"). If not provided, uses the user's region from controller state.
214
+ * @param options - Options for cache behavior and query filters.
215
+ * @param options.provider - Provider ID(s) to filter by.
216
+ * @param options.crypto - Crypto currency ID(s) to filter by.
217
+ * @param options.fiat - Fiat currency ID(s) to filter by.
218
+ * @param options.payments - Payment method ID(s) to filter by.
219
+ * @returns The providers response containing providers array.
220
+ */
221
+ getProviders(region?: string, options?: ExecuteRequestOptions & {
222
+ provider?: string | string[];
223
+ crypto?: string | string[];
224
+ fiat?: string | string[];
225
+ payments?: string | string[];
226
+ }): Promise<{
227
+ providers: Provider[];
228
+ }>;
185
229
  }
186
230
  export {};
187
231
  //# sourceMappingURL=RampsController.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"RampsController.d.mts","sourceRoot":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