@metamask/ramps-controller 10.0.0 → 10.2.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 +18 -1
- package/dist/RampsController.cjs +188 -4
- package/dist/RampsController.cjs.map +1 -1
- package/dist/RampsController.d.cts +66 -2
- package/dist/RampsController.d.cts.map +1 -1
- package/dist/RampsController.d.mts +66 -2
- package/dist/RampsController.d.mts.map +1 -1
- package/dist/RampsController.mjs +188 -4
- package/dist/RampsController.mjs.map +1 -1
- package/dist/RampsService.cjs.map +1 -1
- package/dist/RampsService.d.cts +14 -0
- package/dist/RampsService.d.cts.map +1 -1
- package/dist/RampsService.d.mts +14 -0
- package/dist/RampsService.d.mts.map +1 -1
- package/dist/RampsService.mjs.map +1 -1
- package/dist/TransakService.cjs +14 -3
- package/dist/TransakService.cjs.map +1 -1
- package/dist/TransakService.d.cts +2 -1
- package/dist/TransakService.d.cts.map +1 -1
- package/dist/TransakService.d.mts +2 -1
- package/dist/TransakService.d.mts.map +1 -1
- package/dist/TransakService.mjs +14 -3
- package/dist/TransakService.mjs.map +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +2 -2
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
|
@@ -2,6 +2,7 @@ import type { ControllerGetStateAction, ControllerStateChangeEvent } from "@meta
|
|
|
2
2
|
import { BaseController } from "@metamask/base-controller";
|
|
3
3
|
import type { Messenger } from "@metamask/messenger";
|
|
4
4
|
import type { Country, TokensResponse, Provider, State, RampAction, PaymentMethod, PaymentMethodsResponse, QuotesResponse, Quote, RampsToken, RampsServiceActions, RampsOrder } from "./RampsService.cjs";
|
|
5
|
+
import { RampsOrderStatus } from "./RampsService.cjs";
|
|
5
6
|
import type { RampsServiceGetGeolocationAction, RampsServiceGetCountriesAction, RampsServiceGetTokensAction, RampsServiceGetProvidersAction, RampsServiceGetPaymentMethodsAction, RampsServiceGetQuotesAction, RampsServiceGetBuyWidgetUrlAction, RampsServiceGetOrderAction, RampsServiceGetOrderFromCallbackAction } from "./RampsService-method-action-types.cjs";
|
|
6
7
|
import type { RequestCache as RequestCacheType, RequestState, ExecuteRequestOptions } from "./RequestCache.cjs";
|
|
7
8
|
import type { TransakAccessToken, TransakUserDetails, TransakBuyQuote, TransakKycRequirement, TransakAdditionalRequirementsResponse, TransakDepositOrder, TransakUserLimits, TransakOttResponse, TransakQuoteTranslation, TransakTranslationRequest, TransakIdProofStatus, TransakOrderPaymentMethod, PatchUserRequestBody, TransakOrder } from "./TransakService.cjs";
|
|
@@ -117,6 +118,12 @@ export type RampsControllerState = {
|
|
|
117
118
|
* user details, quote, and KYC data.
|
|
118
119
|
*/
|
|
119
120
|
nativeProviders: NativeProvidersState;
|
|
121
|
+
/**
|
|
122
|
+
* V2 orders stored directly as RampsOrder[].
|
|
123
|
+
* The controller is the authority for V2 orders — it polls, updates,
|
|
124
|
+
* and persists them. No FiatOrder wrapper needed.
|
|
125
|
+
*/
|
|
126
|
+
orders: RampsOrder[];
|
|
120
127
|
};
|
|
121
128
|
/**
|
|
122
129
|
* Constructs the default {@link RampsController} state. This allows
|
|
@@ -131,10 +138,31 @@ export declare function getDefaultRampsControllerState(): RampsControllerState;
|
|
|
131
138
|
* Retrieves the state of the {@link RampsController}.
|
|
132
139
|
*/
|
|
133
140
|
export type RampsControllerGetStateAction = ControllerGetStateAction<typeof controllerName, RampsControllerState>;
|
|
141
|
+
/**
|
|
142
|
+
* Sets selected token in the {@link RampsController}.
|
|
143
|
+
*/
|
|
144
|
+
export type RampsControllerSetSelectedTokenAction = {
|
|
145
|
+
type: 'RampsController:setSelectedToken';
|
|
146
|
+
handler: RampsController['setSelectedToken'];
|
|
147
|
+
};
|
|
148
|
+
/**
|
|
149
|
+
* Fetches quotes via the {@link RampsController}.
|
|
150
|
+
*/
|
|
151
|
+
export type RampsControllerGetQuotesAction = {
|
|
152
|
+
type: 'RampsController:getQuotes';
|
|
153
|
+
handler: RampsController['getQuotes'];
|
|
154
|
+
};
|
|
155
|
+
/**
|
|
156
|
+
* Fetches an order via the {@link RampsController}.
|
|
157
|
+
*/
|
|
158
|
+
export type RampsControllerGetOrderAction = {
|
|
159
|
+
type: 'RampsController:getOrder';
|
|
160
|
+
handler: RampsController['getOrder'];
|
|
161
|
+
};
|
|
134
162
|
/**
|
|
135
163
|
* Actions that {@link RampsControllerMessenger} exposes to other consumers.
|
|
136
164
|
*/
|
|
137
|
-
export type RampsControllerActions = RampsControllerGetStateAction;
|
|
165
|
+
export type RampsControllerActions = RampsControllerGetStateAction | RampsControllerGetOrderAction | RampsControllerGetQuotesAction | RampsControllerSetSelectedTokenAction;
|
|
138
166
|
/**
|
|
139
167
|
* Actions from other messengers that {@link RampsController} calls.
|
|
140
168
|
*/
|
|
@@ -143,10 +171,21 @@ type AllowedActions = RampsServiceGetGeolocationAction | RampsServiceGetCountrie
|
|
|
143
171
|
* Published when the state of {@link RampsController} changes.
|
|
144
172
|
*/
|
|
145
173
|
export type RampsControllerStateChangeEvent = ControllerStateChangeEvent<typeof controllerName, RampsControllerState>;
|
|
174
|
+
/**
|
|
175
|
+
* Published when a V2 order's status transitions.
|
|
176
|
+
* Consumed by mobile's init layer for notifications and analytics.
|
|
177
|
+
*/
|
|
178
|
+
export type RampsControllerOrderStatusChangedEvent = {
|
|
179
|
+
type: `${typeof controllerName}:orderStatusChanged`;
|
|
180
|
+
payload: [{
|
|
181
|
+
order: RampsOrder;
|
|
182
|
+
previousStatus: RampsOrderStatus;
|
|
183
|
+
}];
|
|
184
|
+
};
|
|
146
185
|
/**
|
|
147
186
|
* Events that {@link RampsControllerMessenger} exposes to other consumers.
|
|
148
187
|
*/
|
|
149
|
-
export type RampsControllerEvents = RampsControllerStateChangeEvent;
|
|
188
|
+
export type RampsControllerEvents = RampsControllerStateChangeEvent | RampsControllerOrderStatusChangedEvent;
|
|
150
189
|
/**
|
|
151
190
|
* Events from other messengers that {@link RampsController} subscribes to.
|
|
152
191
|
*/
|
|
@@ -367,6 +406,31 @@ export declare class RampsController extends BaseController<typeof controllerNam
|
|
|
367
406
|
forceRefresh?: boolean;
|
|
368
407
|
ttl?: number;
|
|
369
408
|
}): Promise<QuotesResponse>;
|
|
409
|
+
/**
|
|
410
|
+
* Adds or updates a V2 order in controller state.
|
|
411
|
+
* If an order with the same providerOrderId already exists, the incoming
|
|
412
|
+
* fields are merged on top of the existing order so that fields not present
|
|
413
|
+
* in the update (e.g. paymentDetails from the Transak API) are preserved.
|
|
414
|
+
*
|
|
415
|
+
* @param order - The RampsOrder to add or update.
|
|
416
|
+
*/
|
|
417
|
+
addOrder(order: RampsOrder): void;
|
|
418
|
+
/**
|
|
419
|
+
* Removes a V2 order from controller state by providerOrderId.
|
|
420
|
+
*
|
|
421
|
+
* @param providerOrderId - The provider order ID to remove.
|
|
422
|
+
*/
|
|
423
|
+
removeOrder(providerOrderId: string): void;
|
|
424
|
+
/**
|
|
425
|
+
* Starts polling all pending V2 orders at a fixed interval.
|
|
426
|
+
* Each poll cycle iterates orders with non-terminal statuses,
|
|
427
|
+
* respects pollingSecondsMinimum and backoff from error count.
|
|
428
|
+
*/
|
|
429
|
+
startOrderPolling(): void;
|
|
430
|
+
/**
|
|
431
|
+
* Stops order polling and clears the interval.
|
|
432
|
+
*/
|
|
433
|
+
stopOrderPolling(): void;
|
|
370
434
|
/**
|
|
371
435
|
* Cleans up controller resources.
|
|
372
436
|
* Should be called when the controller is no longer needed.
|
|
@@ -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;AAIrD,OAAO,KAAK,E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;OAGG;IACH,cAAc,EAAE,aAAa,CAAC,aAAa,EAAE,EAAE,aAAa,GAAG,IAAI,CAAC,CAAC;IACrE;;;OAGG;IACH,QAAQ,EAAE,gBAAgB,CAAC;IAC3B;;;;OAIG;IACH,eAAe,EAAE,oBAAoB,CAAC;
|
|
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;AAIrD,OAAO,KAAK,EACV,OAAO,EACP,cAAc,EACd,QAAQ,EACR,KAAK,EACL,UAAU,EACV,aAAa,EACb,sBAAsB,EACtB,cAAc,EACd,KAAK,EACL,UAAU,EACV,mBAAmB,EACnB,UAAU,EACX,2BAAuB;AACxB,OAAO,EAAE,gBAAgB,EAAE,2BAAuB;AAClD,OAAO,KAAK,EACV,gCAAgC,EAChC,8BAA8B,EAC9B,2BAA2B,EAC3B,8BAA8B,EAC9B,mCAAmC,EACnC,2BAA2B,EAC3B,iCAAiC,EACjC,0BAA0B,EAC1B,sCAAsC,EACvC,+CAA2C;AAC5C,OAAO,KAAK,EACV,YAAY,IAAI,gBAAgB,EAChC,YAAY,EACZ,qBAAqB,EAGtB,2BAAuB;AAWxB,OAAO,KAAK,EACV,kBAAkB,EAClB,kBAAkB,EAClB,eAAe,EACf,qBAAqB,EACrB,qCAAqC,EACrC,mBAAmB,EACnB,iBAAiB,EACjB,kBAAkB,EAClB,uBAAuB,EACvB,yBAAyB,EACzB,oBAAoB,EACpB,yBAAyB,EACzB,oBAAoB,EACpB,YAAY,EACb,6BAAyB;AAC1B,OAAO,KAAK,EAAE,qBAAqB,EAAE,6BAAyB;AAC9D,OAAO,KAAK,EACV,6BAA6B,EAC7B,kCAAkC,EAClC,oCAAoC,EACpC,+BAA+B,EAC/B,i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 +2,7 @@ import type { ControllerGetStateAction, ControllerStateChangeEvent } from "@meta
|
|
|
2
2
|
import { BaseController } from "@metamask/base-controller";
|
|
3
3
|
import type { Messenger } from "@metamask/messenger";
|
|
4
4
|
import type { Country, TokensResponse, Provider, State, RampAction, PaymentMethod, PaymentMethodsResponse, QuotesResponse, Quote, RampsToken, RampsServiceActions, RampsOrder } from "./RampsService.mjs";
|
|
5
|
+
import { RampsOrderStatus } from "./RampsService.mjs";
|
|
5
6
|
import type { RampsServiceGetGeolocationAction, RampsServiceGetCountriesAction, RampsServiceGetTokensAction, RampsServiceGetProvidersAction, RampsServiceGetPaymentMethodsAction, RampsServiceGetQuotesAction, RampsServiceGetBuyWidgetUrlAction, RampsServiceGetOrderAction, RampsServiceGetOrderFromCallbackAction } from "./RampsService-method-action-types.mjs";
|
|
6
7
|
import type { RequestCache as RequestCacheType, RequestState, ExecuteRequestOptions } from "./RequestCache.mjs";
|
|
7
8
|
import type { TransakAccessToken, TransakUserDetails, TransakBuyQuote, TransakKycRequirement, TransakAdditionalRequirementsResponse, TransakDepositOrder, TransakUserLimits, TransakOttResponse, TransakQuoteTranslation, TransakTranslationRequest, TransakIdProofStatus, TransakOrderPaymentMethod, PatchUserRequestBody, TransakOrder } from "./TransakService.mjs";
|
|
@@ -117,6 +118,12 @@ export type RampsControllerState = {
|
|
|
117
118
|
* user details, quote, and KYC data.
|
|
118
119
|
*/
|
|
119
120
|
nativeProviders: NativeProvidersState;
|
|
121
|
+
/**
|
|
122
|
+
* V2 orders stored directly as RampsOrder[].
|
|
123
|
+
* The controller is the authority for V2 orders — it polls, updates,
|
|
124
|
+
* and persists them. No FiatOrder wrapper needed.
|
|
125
|
+
*/
|
|
126
|
+
orders: RampsOrder[];
|
|
120
127
|
};
|
|
121
128
|
/**
|
|
122
129
|
* Constructs the default {@link RampsController} state. This allows
|
|
@@ -131,10 +138,31 @@ export declare function getDefaultRampsControllerState(): RampsControllerState;
|
|
|
131
138
|
* Retrieves the state of the {@link RampsController}.
|
|
132
139
|
*/
|
|
133
140
|
export type RampsControllerGetStateAction = ControllerGetStateAction<typeof controllerName, RampsControllerState>;
|
|
141
|
+
/**
|
|
142
|
+
* Sets selected token in the {@link RampsController}.
|
|
143
|
+
*/
|
|
144
|
+
export type RampsControllerSetSelectedTokenAction = {
|
|
145
|
+
type: 'RampsController:setSelectedToken';
|
|
146
|
+
handler: RampsController['setSelectedToken'];
|
|
147
|
+
};
|
|
148
|
+
/**
|
|
149
|
+
* Fetches quotes via the {@link RampsController}.
|
|
150
|
+
*/
|
|
151
|
+
export type RampsControllerGetQuotesAction = {
|
|
152
|
+
type: 'RampsController:getQuotes';
|
|
153
|
+
handler: RampsController['getQuotes'];
|
|
154
|
+
};
|
|
155
|
+
/**
|
|
156
|
+
* Fetches an order via the {@link RampsController}.
|
|
157
|
+
*/
|
|
158
|
+
export type RampsControllerGetOrderAction = {
|
|
159
|
+
type: 'RampsController:getOrder';
|
|
160
|
+
handler: RampsController['getOrder'];
|
|
161
|
+
};
|
|
134
162
|
/**
|
|
135
163
|
* Actions that {@link RampsControllerMessenger} exposes to other consumers.
|
|
136
164
|
*/
|
|
137
|
-
export type RampsControllerActions = RampsControllerGetStateAction;
|
|
165
|
+
export type RampsControllerActions = RampsControllerGetStateAction | RampsControllerGetOrderAction | RampsControllerGetQuotesAction | RampsControllerSetSelectedTokenAction;
|
|
138
166
|
/**
|
|
139
167
|
* Actions from other messengers that {@link RampsController} calls.
|
|
140
168
|
*/
|
|
@@ -143,10 +171,21 @@ type AllowedActions = RampsServiceGetGeolocationAction | RampsServiceGetCountrie
|
|
|
143
171
|
* Published when the state of {@link RampsController} changes.
|
|
144
172
|
*/
|
|
145
173
|
export type RampsControllerStateChangeEvent = ControllerStateChangeEvent<typeof controllerName, RampsControllerState>;
|
|
174
|
+
/**
|
|
175
|
+
* Published when a V2 order's status transitions.
|
|
176
|
+
* Consumed by mobile's init layer for notifications and analytics.
|
|
177
|
+
*/
|
|
178
|
+
export type RampsControllerOrderStatusChangedEvent = {
|
|
179
|
+
type: `${typeof controllerName}:orderStatusChanged`;
|
|
180
|
+
payload: [{
|
|
181
|
+
order: RampsOrder;
|
|
182
|
+
previousStatus: RampsOrderStatus;
|
|
183
|
+
}];
|
|
184
|
+
};
|
|
146
185
|
/**
|
|
147
186
|
* Events that {@link RampsControllerMessenger} exposes to other consumers.
|
|
148
187
|
*/
|
|
149
|
-
export type RampsControllerEvents = RampsControllerStateChangeEvent;
|
|
188
|
+
export type RampsControllerEvents = RampsControllerStateChangeEvent | RampsControllerOrderStatusChangedEvent;
|
|
150
189
|
/**
|
|
151
190
|
* Events from other messengers that {@link RampsController} subscribes to.
|
|
152
191
|
*/
|
|
@@ -367,6 +406,31 @@ export declare class RampsController extends BaseController<typeof controllerNam
|
|
|
367
406
|
forceRefresh?: boolean;
|
|
368
407
|
ttl?: number;
|
|
369
408
|
}): Promise<QuotesResponse>;
|
|
409
|
+
/**
|
|
410
|
+
* Adds or updates a V2 order in controller state.
|
|
411
|
+
* If an order with the same providerOrderId already exists, the incoming
|
|
412
|
+
* fields are merged on top of the existing order so that fields not present
|
|
413
|
+
* in the update (e.g. paymentDetails from the Transak API) are preserved.
|
|
414
|
+
*
|
|
415
|
+
* @param order - The RampsOrder to add or update.
|
|
416
|
+
*/
|
|
417
|
+
addOrder(order: RampsOrder): void;
|
|
418
|
+
/**
|
|
419
|
+
* Removes a V2 order from controller state by providerOrderId.
|
|
420
|
+
*
|
|
421
|
+
* @param providerOrderId - The provider order ID to remove.
|
|
422
|
+
*/
|
|
423
|
+
removeOrder(providerOrderId: string): void;
|
|
424
|
+
/**
|
|
425
|
+
* Starts polling all pending V2 orders at a fixed interval.
|
|
426
|
+
* Each poll cycle iterates orders with non-terminal statuses,
|
|
427
|
+
* respects pollingSecondsMinimum and backoff from error count.
|
|
428
|
+
*/
|
|
429
|
+
startOrderPolling(): void;
|
|
430
|
+
/**
|
|
431
|
+
* Stops order polling and clears the interval.
|
|
432
|
+
*/
|
|
433
|
+
stopOrderPolling(): void;
|
|
370
434
|
/**
|
|
371
435
|
* Cleans up controller resources.
|
|
372
436
|
* Should be called when the controller is no longer needed.
|
|
@@ -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;AAIrD,OAAO,KAAK,EACV,OAAO,EACP,cAAc,EACd,QAAQ,EACR,KAAK,EACL,UAAU,EACV,aAAa,EACb,sBAAsB,EACtB,cAAc,EACd,KAAK,EACL,UAAU,EACV,mBAAmB,EACnB,UAAU,EACX,2BAAuB;AACxB,OAAO,KAAK,EACV,gCAAgC,EAChC,8BAA8B,EAC9B,2BAA2B,EAC3B,8BAA8B,EAC9B,mCAAmC,EACnC,2BAA2B,EAC3B,iCAAiC,EACjC,0BAA0B,EAC1B,sCAAsC,EACvC,+CAA2C;AAC5C,OAAO,KAAK,EACV,YAAY,IAAI,gBAAgB,EAChC,YAAY,EACZ,qBAAqB,EAGtB,2BAAuB;AAWxB,OAAO,KAAK,EACV,kBAAkB,EAClB,kBAAkB,EAClB,eAAe,EACf,qBAAqB,EACrB,qCAAqC,EACrC,mBAAmB,EACnB,iBAAiB,EACjB,kBAAkB,EAClB,uBAAuB,EACvB,yBAAyB,EACzB,oBAAoB,EACpB,yBAAyB,EACzB,oBAAoB,EACpB,YAAY,EACb,6BAAyB;AAC1B,OAAO,KAAK,EAAE,qBAAqB,EAAE,6BAAyB;AAC9D,OAAO,KAAK,EACV,6BAA6B,EAC7B,kCAAkC,EAClC,oCAAoC,EACpC,+BAA+B,EAC/B,iCAAiC,EACjC,0BAA0B,EAC1B,kCAAkC,EAClC,+BAA+B,EAC/B,qCAAqC,EACrC,6CAA6C,EAC7C,+BAA+B,EAC/B,4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GACjC,OAAO,CAAC,uBAAuB,CAAC;IAInC;;;;;OAKG;IACG,uBAAuB,CAC3B,aAAa,EAAE,MAAM,GACpB,OAAO,CAAC,oBAAoB,CAAC;IAYhC;;;;;OAKG;IACG,kBAAkB,CAAC,cAAc,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAY/D;;;;;OAKG;IACG,4BAA4B,IAAI,OAAO,CAAC,KAAK,EAAE,CAAC;IAStD;;;;OAIG;IACG,sBAAsB,IAAI,OAAO,CAAC,YAAY,EAAE,CAAC;CAQxD"}
|
package/dist/RampsController.mjs
CHANGED
|
@@ -9,8 +9,9 @@ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (
|
|
|
9
9
|
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
10
10
|
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
11
11
|
};
|
|
12
|
-
var _RampsController_instances, _RampsController_requestCacheTTL, _RampsController_requestCacheMaxSize, _RampsController_pendingRequests, _RampsController_pendingResourceCount, _RampsController_clearPendingResourceCountForDependentResources, _RampsController_abortDependentRequests, _RampsController_mutateRequests, _RampsController_removeRequestState, _RampsController_cleanupState, _RampsController_fireAndForget, _RampsController_requireRegion, _RampsController_isRegionCurrent, _RampsController_isTokenCurrent, _RampsController_isProviderCurrent, _RampsController_updateResourceField, _RampsController_setResourceLoading, _RampsController_setResourceError, _RampsController_updateRequestState, _RampsController_syncTransakAuthOnError;
|
|
12
|
+
var _RampsController_instances, _RampsController_requestCacheTTL, _RampsController_requestCacheMaxSize, _RampsController_pendingRequests, _RampsController_pendingResourceCount, _RampsController_orderPollingMeta, _RampsController_orderPollingTimer, _RampsController_isPolling, _RampsController_clearPendingResourceCountForDependentResources, _RampsController_abortDependentRequests, _RampsController_registerActionHandlers, _RampsController_mutateRequests, _RampsController_removeRequestState, _RampsController_cleanupState, _RampsController_fireAndForget, _RampsController_requireRegion, _RampsController_isRegionCurrent, _RampsController_isTokenCurrent, _RampsController_isProviderCurrent, _RampsController_updateResourceField, _RampsController_setResourceLoading, _RampsController_setResourceError, _RampsController_updateRequestState, _RampsController_refreshOrder, _RampsController_pollPendingOrders, _RampsController_syncTransakAuthOnError;
|
|
13
13
|
import { BaseController } from "@metamask/base-controller";
|
|
14
|
+
import { RampsOrderStatus } from "./RampsService.mjs";
|
|
14
15
|
import { DEFAULT_REQUEST_CACHE_TTL, DEFAULT_REQUEST_CACHE_MAX_SIZE, createCacheKey, isCacheExpired, createLoadingState, createSuccessState, createErrorState, RequestStatus } from "./RequestCache.mjs";
|
|
15
16
|
// === GENERAL ===
|
|
16
17
|
/**
|
|
@@ -110,6 +111,12 @@ const rampsControllerMetadata = {
|
|
|
110
111
|
includeInStateLogs: false,
|
|
111
112
|
usedInUi: true,
|
|
112
113
|
},
|
|
114
|
+
orders: {
|
|
115
|
+
persist: true,
|
|
116
|
+
includeInDebugSnapshot: true,
|
|
117
|
+
includeInStateLogs: true,
|
|
118
|
+
usedInUi: true,
|
|
119
|
+
},
|
|
113
120
|
};
|
|
114
121
|
/**
|
|
115
122
|
* Creates a default resource state object.
|
|
@@ -152,6 +159,7 @@ export function getDefaultRampsControllerState() {
|
|
|
152
159
|
kycRequirement: createDefaultResourceState(null),
|
|
153
160
|
},
|
|
154
161
|
},
|
|
162
|
+
orders: [],
|
|
155
163
|
};
|
|
156
164
|
}
|
|
157
165
|
const DEPENDENT_RESOURCE_KEYS = [
|
|
@@ -238,6 +246,21 @@ function findRegionFromCode(regionCode, countries) {
|
|
|
238
246
|
regionCode: normalizedCode,
|
|
239
247
|
};
|
|
240
248
|
}
|
|
249
|
+
// === ORDER POLLING CONSTANTS ===
|
|
250
|
+
const TERMINAL_ORDER_STATUSES = new Set([
|
|
251
|
+
RampsOrderStatus.Completed,
|
|
252
|
+
RampsOrderStatus.Failed,
|
|
253
|
+
RampsOrderStatus.Cancelled,
|
|
254
|
+
RampsOrderStatus.IdExpired,
|
|
255
|
+
]);
|
|
256
|
+
const PENDING_ORDER_STATUSES = new Set([
|
|
257
|
+
RampsOrderStatus.Pending,
|
|
258
|
+
RampsOrderStatus.Created,
|
|
259
|
+
RampsOrderStatus.Unknown,
|
|
260
|
+
RampsOrderStatus.Precreated,
|
|
261
|
+
]);
|
|
262
|
+
const DEFAULT_POLLING_INTERVAL_MS = 30000;
|
|
263
|
+
const MAX_ERROR_COUNT = 5;
|
|
241
264
|
// === CONTROLLER DEFINITION ===
|
|
242
265
|
/**
|
|
243
266
|
* Manages cryptocurrency on/off ramps functionality.
|
|
@@ -293,8 +316,12 @@ export class RampsController extends BaseController {
|
|
|
293
316
|
* Used so isLoading is only cleared when the last request for that resource finishes.
|
|
294
317
|
*/
|
|
295
318
|
_RampsController_pendingResourceCount.set(this, new Map());
|
|
319
|
+
_RampsController_orderPollingMeta.set(this, new Map());
|
|
320
|
+
_RampsController_orderPollingTimer.set(this, null);
|
|
321
|
+
_RampsController_isPolling.set(this, false);
|
|
296
322
|
__classPrivateFieldSet(this, _RampsController_requestCacheTTL, requestCacheTTL, "f");
|
|
297
323
|
__classPrivateFieldSet(this, _RampsController_requestCacheMaxSize, requestCacheMaxSize, "f");
|
|
324
|
+
__classPrivateFieldGet(this, _RampsController_instances, "m", _RampsController_registerActionHandlers).call(this);
|
|
298
325
|
}
|
|
299
326
|
/**
|
|
300
327
|
* Executes a request with caching, deduplication, and at most one in-flight
|
|
@@ -514,11 +541,21 @@ export class RampsController extends BaseController {
|
|
|
514
541
|
if (!provider) {
|
|
515
542
|
throw new Error(`Provider with ID "${providerId}" not found in available providers.`);
|
|
516
543
|
}
|
|
544
|
+
const selectedToken = this.state.tokens.selected;
|
|
545
|
+
const supportedCryptos = provider.supportedCryptoCurrencies;
|
|
546
|
+
// Only fetch payment methods if the selected token is supported by the new
|
|
547
|
+
// provider. If it isn't, the payment methods request would fail or return
|
|
548
|
+
// empty for the wrong reason; the UI will show the Token Not Available modal
|
|
549
|
+
// so the user can change token or pick a different provider.
|
|
550
|
+
const assetId = selectedToken?.assetId;
|
|
551
|
+
const tokenSupportedByProvider = !(assetId && supportedCryptos?.[assetId] === false);
|
|
517
552
|
this.update((state) => {
|
|
518
553
|
state.providers.selected = provider;
|
|
519
554
|
resetResource(state, 'paymentMethods');
|
|
520
555
|
});
|
|
521
|
-
|
|
556
|
+
if (tokenSupportedByProvider) {
|
|
557
|
+
__classPrivateFieldGet(this, _RampsController_instances, "m", _RampsController_fireAndForget).call(this, this.getPaymentMethods(regionCode, { provider: provider.id }));
|
|
558
|
+
}
|
|
522
559
|
}
|
|
523
560
|
/**
|
|
524
561
|
* Initializes the controller by fetching the user's region from geolocation.
|
|
@@ -838,11 +875,69 @@ export class RampsController extends BaseController {
|
|
|
838
875
|
ttl: options.ttl ?? DEFAULT_QUOTES_TTL,
|
|
839
876
|
});
|
|
840
877
|
}
|
|
878
|
+
// === ORDER MANAGEMENT ===
|
|
879
|
+
/**
|
|
880
|
+
* Adds or updates a V2 order in controller state.
|
|
881
|
+
* If an order with the same providerOrderId already exists, the incoming
|
|
882
|
+
* fields are merged on top of the existing order so that fields not present
|
|
883
|
+
* in the update (e.g. paymentDetails from the Transak API) are preserved.
|
|
884
|
+
*
|
|
885
|
+
* @param order - The RampsOrder to add or update.
|
|
886
|
+
*/
|
|
887
|
+
addOrder(order) {
|
|
888
|
+
this.update((state) => {
|
|
889
|
+
const idx = state.orders.findIndex((existing) => existing.providerOrderId === order.providerOrderId);
|
|
890
|
+
if (idx === -1) {
|
|
891
|
+
state.orders.push(order);
|
|
892
|
+
}
|
|
893
|
+
else {
|
|
894
|
+
state.orders[idx] = {
|
|
895
|
+
...state.orders[idx],
|
|
896
|
+
...order,
|
|
897
|
+
};
|
|
898
|
+
}
|
|
899
|
+
});
|
|
900
|
+
}
|
|
901
|
+
/**
|
|
902
|
+
* Removes a V2 order from controller state by providerOrderId.
|
|
903
|
+
*
|
|
904
|
+
* @param providerOrderId - The provider order ID to remove.
|
|
905
|
+
*/
|
|
906
|
+
removeOrder(providerOrderId) {
|
|
907
|
+
this.update((state) => {
|
|
908
|
+
state.orders = state.orders.filter((order) => order.providerOrderId !== providerOrderId);
|
|
909
|
+
});
|
|
910
|
+
__classPrivateFieldGet(this, _RampsController_orderPollingMeta, "f").delete(providerOrderId);
|
|
911
|
+
}
|
|
912
|
+
/**
|
|
913
|
+
* Starts polling all pending V2 orders at a fixed interval.
|
|
914
|
+
* Each poll cycle iterates orders with non-terminal statuses,
|
|
915
|
+
* respects pollingSecondsMinimum and backoff from error count.
|
|
916
|
+
*/
|
|
917
|
+
startOrderPolling() {
|
|
918
|
+
if (__classPrivateFieldGet(this, _RampsController_orderPollingTimer, "f")) {
|
|
919
|
+
return;
|
|
920
|
+
}
|
|
921
|
+
__classPrivateFieldSet(this, _RampsController_orderPollingTimer, setInterval(() => {
|
|
922
|
+
__classPrivateFieldGet(this, _RampsController_instances, "m", _RampsController_pollPendingOrders).call(this).catch(() => undefined);
|
|
923
|
+
}, DEFAULT_POLLING_INTERVAL_MS), "f");
|
|
924
|
+
__classPrivateFieldGet(this, _RampsController_instances, "m", _RampsController_pollPendingOrders).call(this).catch(() => undefined);
|
|
925
|
+
}
|
|
926
|
+
/**
|
|
927
|
+
* Stops order polling and clears the interval.
|
|
928
|
+
*/
|
|
929
|
+
stopOrderPolling() {
|
|
930
|
+
if (__classPrivateFieldGet(this, _RampsController_orderPollingTimer, "f")) {
|
|
931
|
+
clearInterval(__classPrivateFieldGet(this, _RampsController_orderPollingTimer, "f"));
|
|
932
|
+
__classPrivateFieldSet(this, _RampsController_orderPollingTimer, null, "f");
|
|
933
|
+
}
|
|
934
|
+
}
|
|
841
935
|
/**
|
|
842
936
|
* Cleans up controller resources.
|
|
843
937
|
* Should be called when the controller is no longer needed.
|
|
844
938
|
*/
|
|
845
939
|
destroy() {
|
|
940
|
+
this.stopOrderPolling();
|
|
846
941
|
super.destroy();
|
|
847
942
|
}
|
|
848
943
|
/**
|
|
@@ -876,7 +971,17 @@ export class RampsController extends BaseController {
|
|
|
876
971
|
* @returns The unified order data.
|
|
877
972
|
*/
|
|
878
973
|
async getOrder(providerCode, orderCode, wallet) {
|
|
879
|
-
|
|
974
|
+
const order = await this.messenger.call('RampsService:getOrder', providerCode, orderCode, wallet);
|
|
975
|
+
this.update((state) => {
|
|
976
|
+
const idx = state.orders.findIndex((existing) => existing.providerOrderId === orderCode);
|
|
977
|
+
if (idx !== -1) {
|
|
978
|
+
state.orders[idx] = {
|
|
979
|
+
...state.orders[idx],
|
|
980
|
+
...order,
|
|
981
|
+
};
|
|
982
|
+
}
|
|
983
|
+
});
|
|
984
|
+
return order;
|
|
880
985
|
}
|
|
881
986
|
/**
|
|
882
987
|
* Extracts an order from a provider callback URL.
|
|
@@ -1287,7 +1392,7 @@ export class RampsController extends BaseController {
|
|
|
1287
1392
|
}
|
|
1288
1393
|
}
|
|
1289
1394
|
}
|
|
1290
|
-
_RampsController_requestCacheTTL = new WeakMap(), _RampsController_requestCacheMaxSize = new WeakMap(), _RampsController_pendingRequests = new WeakMap(), _RampsController_pendingResourceCount = new WeakMap(), _RampsController_instances = new WeakSet(), _RampsController_clearPendingResourceCountForDependentResources = function _RampsController_clearPendingResourceCountForDependentResources() {
|
|
1395
|
+
_RampsController_requestCacheTTL = new WeakMap(), _RampsController_requestCacheMaxSize = new WeakMap(), _RampsController_pendingRequests = new WeakMap(), _RampsController_pendingResourceCount = new WeakMap(), _RampsController_orderPollingMeta = new WeakMap(), _RampsController_orderPollingTimer = new WeakMap(), _RampsController_isPolling = new WeakMap(), _RampsController_instances = new WeakSet(), _RampsController_clearPendingResourceCountForDependentResources = function _RampsController_clearPendingResourceCountForDependentResources() {
|
|
1291
1396
|
for (const resourceType of DEPENDENT_RESOURCE_KEYS) {
|
|
1292
1397
|
__classPrivateFieldGet(this, _RampsController_pendingResourceCount, "f").delete(resourceType);
|
|
1293
1398
|
}
|
|
@@ -1300,6 +1405,10 @@ _RampsController_requestCacheTTL = new WeakMap(), _RampsController_requestCacheM
|
|
|
1300
1405
|
__classPrivateFieldGet(this, _RampsController_instances, "m", _RampsController_removeRequestState).call(this, cacheKey);
|
|
1301
1406
|
}
|
|
1302
1407
|
}
|
|
1408
|
+
}, _RampsController_registerActionHandlers = function _RampsController_registerActionHandlers() {
|
|
1409
|
+
this.messenger.registerActionHandler('RampsController:getOrder', this.getOrder.bind(this));
|
|
1410
|
+
this.messenger.registerActionHandler('RampsController:getQuotes', this.getQuotes.bind(this));
|
|
1411
|
+
this.messenger.registerActionHandler('RampsController:setSelectedToken', this.setSelectedToken.bind(this));
|
|
1303
1412
|
}, _RampsController_mutateRequests = function _RampsController_mutateRequests(fn) {
|
|
1304
1413
|
this.update((state) => {
|
|
1305
1414
|
const requests = state.requests;
|
|
@@ -1370,6 +1479,81 @@ _RampsController_requestCacheTTL = new WeakMap(), _RampsController_requestCacheM
|
|
|
1370
1479
|
}
|
|
1371
1480
|
}
|
|
1372
1481
|
});
|
|
1482
|
+
}, _RampsController_refreshOrder =
|
|
1483
|
+
/**
|
|
1484
|
+
* Refreshes a single order via the V2 API and updates it in state.
|
|
1485
|
+
* Publishes orderStatusChanged if the status transitioned.
|
|
1486
|
+
*
|
|
1487
|
+
* @param order - The order to refresh (needs provider and providerOrderId).
|
|
1488
|
+
*/
|
|
1489
|
+
async function _RampsController_refreshOrder(order) {
|
|
1490
|
+
const providerCode = order.provider?.id ?? '';
|
|
1491
|
+
if (!providerCode || !order.providerOrderId || !order.walletAddress) {
|
|
1492
|
+
return;
|
|
1493
|
+
}
|
|
1494
|
+
const providerCodeSegment = providerCode.replace('/providers/', '');
|
|
1495
|
+
const previousStatus = order.status;
|
|
1496
|
+
try {
|
|
1497
|
+
const updatedOrder = await this.getOrder(providerCodeSegment, order.providerOrderId, order.walletAddress);
|
|
1498
|
+
const meta = __classPrivateFieldGet(this, _RampsController_orderPollingMeta, "f").get(order.providerOrderId) ?? {
|
|
1499
|
+
lastTimeFetched: 0,
|
|
1500
|
+
errorCount: 0,
|
|
1501
|
+
};
|
|
1502
|
+
if (updatedOrder.status === RampsOrderStatus.Unknown) {
|
|
1503
|
+
meta.errorCount = Math.min(meta.errorCount + 1, MAX_ERROR_COUNT);
|
|
1504
|
+
}
|
|
1505
|
+
else {
|
|
1506
|
+
meta.errorCount = 0;
|
|
1507
|
+
}
|
|
1508
|
+
meta.lastTimeFetched = Date.now();
|
|
1509
|
+
__classPrivateFieldGet(this, _RampsController_orderPollingMeta, "f").set(order.providerOrderId, meta);
|
|
1510
|
+
if (previousStatus !== updatedOrder.status &&
|
|
1511
|
+
previousStatus !== undefined) {
|
|
1512
|
+
this.messenger.publish('RampsController:orderStatusChanged', {
|
|
1513
|
+
order: updatedOrder,
|
|
1514
|
+
previousStatus,
|
|
1515
|
+
});
|
|
1516
|
+
}
|
|
1517
|
+
if (TERMINAL_ORDER_STATUSES.has(updatedOrder.status)) {
|
|
1518
|
+
__classPrivateFieldGet(this, _RampsController_orderPollingMeta, "f").delete(order.providerOrderId);
|
|
1519
|
+
}
|
|
1520
|
+
}
|
|
1521
|
+
catch {
|
|
1522
|
+
const meta = __classPrivateFieldGet(this, _RampsController_orderPollingMeta, "f").get(order.providerOrderId) ?? {
|
|
1523
|
+
lastTimeFetched: 0,
|
|
1524
|
+
errorCount: 0,
|
|
1525
|
+
};
|
|
1526
|
+
meta.errorCount = Math.min(meta.errorCount + 1, MAX_ERROR_COUNT);
|
|
1527
|
+
meta.lastTimeFetched = Date.now();
|
|
1528
|
+
__classPrivateFieldGet(this, _RampsController_orderPollingMeta, "f").set(order.providerOrderId, meta);
|
|
1529
|
+
}
|
|
1530
|
+
}, _RampsController_pollPendingOrders = async function _RampsController_pollPendingOrders() {
|
|
1531
|
+
if (__classPrivateFieldGet(this, _RampsController_isPolling, "f")) {
|
|
1532
|
+
return;
|
|
1533
|
+
}
|
|
1534
|
+
__classPrivateFieldSet(this, _RampsController_isPolling, true, "f");
|
|
1535
|
+
try {
|
|
1536
|
+
const pendingOrders = this.state.orders.filter((order) => PENDING_ORDER_STATUSES.has(order.status));
|
|
1537
|
+
const now = Date.now();
|
|
1538
|
+
await Promise.allSettled(pendingOrders.map(async (order) => {
|
|
1539
|
+
const meta = __classPrivateFieldGet(this, _RampsController_orderPollingMeta, "f").get(order.providerOrderId);
|
|
1540
|
+
if (meta) {
|
|
1541
|
+
const backoffMs = meta.errorCount > 0
|
|
1542
|
+
? Math.min(DEFAULT_POLLING_INTERVAL_MS *
|
|
1543
|
+
Math.pow(2, meta.errorCount - 1), 5 * 60 * 1000)
|
|
1544
|
+
: 0;
|
|
1545
|
+
const pollingMinMs = (order.pollingSecondsMinimum ?? 0) * 1000;
|
|
1546
|
+
const minWait = Math.max(backoffMs, pollingMinMs);
|
|
1547
|
+
if (now - meta.lastTimeFetched < minWait) {
|
|
1548
|
+
return;
|
|
1549
|
+
}
|
|
1550
|
+
}
|
|
1551
|
+
await __classPrivateFieldGet(this, _RampsController_instances, "m", _RampsController_refreshOrder).call(this, order);
|
|
1552
|
+
}));
|
|
1553
|
+
}
|
|
1554
|
+
finally {
|
|
1555
|
+
__classPrivateFieldSet(this, _RampsController_isPolling, false, "f");
|
|
1556
|
+
}
|
|
1373
1557
|
}, _RampsController_syncTransakAuthOnError = function _RampsController_syncTransakAuthOnError(error) {
|
|
1374
1558
|
if (error instanceof Error &&
|
|
1375
1559
|
'httpStatus' in error &&
|