@metamask-previews/ramps-controller 3.0.0-preview-c72fc191 → 4.0.0-preview-4a66b658

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, Provider } 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,24 +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
42
  * The user's preferred provider.
24
43
  * Can be manually set by the user.
25
44
  */
26
45
  preferredProvider: Provider | null;
27
46
  /**
28
- * Eligibility information for the user's current region.
47
+ * List of providers available for the current region.
29
48
  */
30
- eligibility: Eligibility | null;
49
+ providers: Provider[];
31
50
  /**
32
51
  * Tokens fetched for the current region and action.
33
52
  * Contains topTokens and allTokens arrays.
@@ -59,7 +78,7 @@ export type RampsControllerActions = RampsControllerGetStateAction;
59
78
  /**
60
79
  * Actions from other messengers that {@link RampsController} calls.
61
80
  */
62
- type AllowedActions = RampsServiceGetGeolocationAction | RampsServiceGetCountriesAction | RampsServiceGetEligibilityAction | RampsServiceGetTokensAction;
81
+ type AllowedActions = RampsServiceGetGeolocationAction | RampsServiceGetCountriesAction | RampsServiceGetTokensAction | RampsServiceGetProvidersAction;
63
82
  /**
64
83
  * Published when the state of {@link RampsController} changes.
65
84
  */
@@ -134,23 +153,22 @@ export declare class RampsController extends BaseController<typeof controllerNam
134
153
  */
135
154
  getRequestState(cacheKey: string): RequestState | undefined;
136
155
  /**
137
- * Updates the user's region by fetching geolocation and eligibility.
138
- * This method calls the RampsService to get the geolocation,
139
- * 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.
140
158
  *
141
159
  * @param options - Options for cache behavior.
142
- * @returns The user region string.
160
+ * @returns The user region object.
143
161
  */
144
- updateUserRegion(options?: ExecuteRequestOptions): Promise<string>;
162
+ updateUserRegion(options?: ExecuteRequestOptions): Promise<UserRegion | null>;
145
163
  /**
146
164
  * Sets the user's region manually (without fetching geolocation).
147
165
  * This allows users to override the detected region.
148
166
  *
149
167
  * @param region - The region code to set (e.g., "US-CA").
150
- * @param options - Options for cache behavior when fetching eligibility.
151
- * @returns The eligibility information for the region.
168
+ * @param options - Options for cache behavior.
169
+ * @returns The user region object.
152
170
  */
153
- setUserRegion(region: string, options?: ExecuteRequestOptions): Promise<Eligibility>;
171
+ setUserRegion(region: string, options?: ExecuteRequestOptions): Promise<UserRegion>;
154
172
  /**
155
173
  * Sets the user's preferred provider.
156
174
  * This allows users to set their preferred ramp provider.
@@ -161,27 +179,21 @@ export declare class RampsController extends BaseController<typeof controllerNam
161
179
  /**
162
180
  * Initializes the controller by fetching the user's region from geolocation.
163
181
  * This should be called once at app startup to set up the initial region.
164
- * After the region is set and eligibility is determined, tokens are fetched
165
- * 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.
166
186
  *
167
187
  * @param options - Options for cache behavior.
168
188
  * @returns Promise that resolves when initialization is complete.
169
189
  */
170
190
  init(options?: ExecuteRequestOptions): Promise<void>;
171
- /**
172
- * Updates the eligibility information for a given region.
173
- *
174
- * @param isoCode - The ISO code for the region (e.g., "us", "fr", "us-ny").
175
- * @param options - Options for cache behavior.
176
- * @returns The eligibility information.
177
- */
178
- updateEligibility(isoCode: string, options?: ExecuteRequestOptions): Promise<Eligibility>;
179
191
  /**
180
192
  * Fetches the list of supported countries for a given ramp action.
181
193
  *
182
194
  * @param action - The ramp action type ('buy' or 'sell').
183
195
  * @param options - Options for cache behavior.
184
- * @returns An array of countries with their eligibility information.
196
+ * @returns An array of countries.
185
197
  */
186
198
  getCountries(action?: 'buy' | 'sell', options?: ExecuteRequestOptions): Promise<Country[]>;
187
199
  /**
@@ -194,6 +206,26 @@ export declare class RampsController extends BaseController<typeof controllerNam
194
206
  * @returns The tokens response containing topTokens and allTokens.
195
207
  */
196
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
+ }>;
197
229
  }
198
230
  export {};
199
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,EACV,OAAO,EACP,WAAW,EACX,cAAc,EACd,QAAQ,EACT,2BAAuB;AACxB,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;;;OAGG;IACH,iBAAiB,EAAE,QAAQ,GAAG,IAAI,CAAC;IACnC;;OAEG;IACH,WAAW,EAAE,WAAW,GAAG,IAAI,CAAC;IAChC;;;OAGG;IACH,MAAM,EAAE,cAAc,GAAG,IAAI,CAAC;IAC9B;;;OAGG;IACH,QAAQ,E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gBAAgB,CACpB,OAAO,CAAC,EAAE,qBAAqB,GAC9B,OAAO,CAAC,UAAU,GAAG,IAAI,CAAC;IAyF7B;;;;;;;OAOG;IACG,aAAa,CACjB,MAAM,EAAE,MAAM,EACd,OAAO,CAAC,EAAE,qBAAqB,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, Provider } 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,24 +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
42
  * The user's preferred provider.
24
43
  * Can be manually set by the user.
25
44
  */
26
45
  preferredProvider: Provider | null;
27
46
  /**
28
- * Eligibility information for the user's current region.
47
+ * List of providers available for the current region.
29
48
  */
30
- eligibility: Eligibility | null;
49
+ providers: Provider[];
31
50
  /**
32
51
  * Tokens fetched for the current region and action.
33
52
  * Contains topTokens and allTokens arrays.
@@ -59,7 +78,7 @@ export type RampsControllerActions = RampsControllerGetStateAction;
59
78
  /**
60
79
  * Actions from other messengers that {@link RampsController} calls.
61
80
  */
62
- type AllowedActions = RampsServiceGetGeolocationAction | RampsServiceGetCountriesAction | RampsServiceGetEligibilityAction | RampsServiceGetTokensAction;
81
+ type AllowedActions = RampsServiceGetGeolocationAction | RampsServiceGetCountriesAction | RampsServiceGetTokensAction | RampsServiceGetProvidersAction;
63
82
  /**
64
83
  * Published when the state of {@link RampsController} changes.
65
84
  */
@@ -134,23 +153,22 @@ export declare class RampsController extends BaseController<typeof controllerNam
134
153
  */
135
154
  getRequestState(cacheKey: string): RequestState | undefined;
136
155
  /**
137
- * Updates the user's region by fetching geolocation and eligibility.
138
- * This method calls the RampsService to get the geolocation,
139
- * 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.
140
158
  *
141
159
  * @param options - Options for cache behavior.
142
- * @returns The user region string.
160
+ * @returns The user region object.
143
161
  */
144
- updateUserRegion(options?: ExecuteRequestOptions): Promise<string>;
162
+ updateUserRegion(options?: ExecuteRequestOptions): Promise<UserRegion | null>;
145
163
  /**
146
164
  * Sets the user's region manually (without fetching geolocation).
147
165
  * This allows users to override the detected region.
148
166
  *
149
167
  * @param region - The region code to set (e.g., "US-CA").
150
- * @param options - Options for cache behavior when fetching eligibility.
151
- * @returns The eligibility information for the region.
168
+ * @param options - Options for cache behavior.
169
+ * @returns The user region object.
152
170
  */
153
- setUserRegion(region: string, options?: ExecuteRequestOptions): Promise<Eligibility>;
171
+ setUserRegion(region: string, options?: ExecuteRequestOptions): Promise<UserRegion>;
154
172
  /**
155
173
  * Sets the user's preferred provider.
156
174
  * This allows users to set their preferred ramp provider.
@@ -161,27 +179,21 @@ export declare class RampsController extends BaseController<typeof controllerNam
161
179
  /**
162
180
  * Initializes the controller by fetching the user's region from geolocation.
163
181
  * This should be called once at app startup to set up the initial region.
164
- * After the region is set and eligibility is determined, tokens are fetched
165
- * 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.
166
186
  *
167
187
  * @param options - Options for cache behavior.
168
188
  * @returns Promise that resolves when initialization is complete.
169
189
  */
170
190
  init(options?: ExecuteRequestOptions): Promise<void>;
171
- /**
172
- * Updates the eligibility information for a given region.
173
- *
174
- * @param isoCode - The ISO code for the region (e.g., "us", "fr", "us-ny").
175
- * @param options - Options for cache behavior.
176
- * @returns The eligibility information.
177
- */
178
- updateEligibility(isoCode: string, options?: ExecuteRequestOptions): Promise<Eligibility>;
179
191
  /**
180
192
  * Fetches the list of supported countries for a given ramp action.
181
193
  *
182
194
  * @param action - The ramp action type ('buy' or 'sell').
183
195
  * @param options - Options for cache behavior.
184
- * @returns An array of countries with their eligibility information.
196
+ * @returns An array of countries.
185
197
  */
186
198
  getCountries(action?: 'buy' | 'sell', options?: ExecuteRequestOptions): Promise<Country[]>;
187
199
  /**
@@ -194,6 +206,26 @@ export declare class RampsController extends BaseController<typeof controllerNam
194
206
  * @returns The tokens response containing topTokens and allTokens.
195
207
  */
196
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
+ }>;
197
229
  }
198
230
  export {};
199
231
  //# sourceMappingURL=RampsController.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"RampsController.d.mts","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,EACV,OAAO,EACP,WAAW,EACX,cAAc,EACd,QAAQ,EACT,2BAAuB;AACxB,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;;;OAGG;IACH,iBAAiB,EAAE,QAAQ,GAAG,IAAI,CAAC;IACnC;;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;AAsCF;;;;;;;GAOG;AACH,wBAAgB,8BAA8B,IAAI,oBAAoB,CAQrE;AAID;;GAEG;AACH,MAAM,MAAM,6BAA6B,GAAG,wBAAwB,CAClE,OAAO,cAAc,EACrB,oBAAoB,CACrB,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,sBAAsB,GAAG,6BAA6B,CAAC;AAEnE;;GAEG;AACH,KAAK,c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