@metamask-previews/ramps-controller 18.0.1-preview-e58fe0640 → 18.0.1-preview-ea0a8c22f
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 +16 -0
- package/dist/RampsController.cjs +13 -18
- package/dist/RampsController.cjs.map +1 -1
- package/dist/RampsController.d.cts +3 -17
- package/dist/RampsController.d.cts.map +1 -1
- package/dist/RampsController.d.mts +3 -17
- package/dist/RampsController.d.mts.map +1 -1
- package/dist/RampsController.mjs +13 -18
- package/dist/RampsController.mjs.map +1 -1
- package/dist/RampsService-method-action-types.cjs.map +1 -1
- package/dist/RampsService-method-action-types.d.cts +31 -1
- package/dist/RampsService-method-action-types.d.cts.map +1 -1
- package/dist/RampsService-method-action-types.d.mts +31 -1
- package/dist/RampsService-method-action-types.d.mts.map +1 -1
- package/dist/RampsService-method-action-types.mjs.map +1 -1
- package/dist/RampsService.cjs +75 -1
- package/dist/RampsService.cjs.map +1 -1
- package/dist/RampsService.d.cts +52 -0
- package/dist/RampsService.d.cts.map +1 -1
- package/dist/RampsService.d.mts +52 -0
- package/dist/RampsService.d.mts.map +1 -1
- package/dist/RampsService.mjs +73 -0
- package/dist/RampsService.mjs.map +1 -1
- package/dist/index.cjs +2 -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 +1 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,22 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
### Added
|
|
11
|
+
|
|
12
|
+
- Add `RampsService.getDefaultRedirectCallbackUrl()` and the matching `RampsService:getDefaultRedirectCallbackUrl` messenger action (plus the exported `RampsServiceGetDefaultRedirectCallbackUrlAction` type), which return the widened Headless Buy default redirect ("fake callback") URL for the environment the service was constructed with. The method is synchronous. ([#9752](https://github.com/MetaMask/core/pull/9752))
|
|
13
|
+
- `baseUrlOverride` deliberately does not apply. It overrides the ramps API host for local development, which in production and staging is not the host that serves `/regions/fake-callback` (`on-ramp-content` versus `on-ramp{-cache}`), and the redirect URL is matched by client UI to detect flow completion. For development the callback already shares the API host family (`on-ramp.dev-api`). Use `RampsEnvironment.Local` for a localhost callback, noting it is pinned to `http://localhost:3000` and does not follow a non-3000 `baseUrlOverride`.
|
|
14
|
+
- Add the exported `getDefaultRedirectCallbackUrl(environment)` helper, the canonical environment-to-callback map that `RampsService` uses: `on-ramp-content` hosts for production and staging, `on-ramp.dev-api` for development (there is no `on-ramp-content.dev-api` deployment), and `localhost:3000` for local. Client code that needs the value synchronously, without the messenger, can call it directly with the same environment the service was given. ([#9752](https://github.com/MetaMask/core/pull/9752))
|
|
15
|
+
|
|
16
|
+
### Changed
|
|
17
|
+
|
|
18
|
+
- **BREAKING:** `RampsController` now calls `RampsService:getDefaultRedirectCallbackUrl` on the widened quote path, so hosts must delegate that action to the controller's messenger. It is included in the exported `RAMPS_CONTROLLER_REQUIRED_SERVICE_ACTIONS` list; hosts that spell out their delegated action list instead of spreading that constant have to add it, or the entire `RampsController:getQuotes` call rejects with a messenger "handler has not been delegated" error (including MM Pay's fiat quote path, which omits `redirectUrl` and relies on widening). ([#9752](https://github.com/MetaMask/core/pull/9752))
|
|
19
|
+
- The action is only called when the `moneyHeadlessAllProviders` widening is in effect and the caller omitted `redirectUrl`. An explicit `redirectUrl` and the native-only path never reach the service.
|
|
20
|
+
|
|
21
|
+
### Removed
|
|
22
|
+
|
|
23
|
+
- **BREAKING:** Remove the `getDefaultRedirectUrl` callback option from `RampsControllerOptions`. The controller asks `RampsService` for the default redirect URL instead, which keeps the environment a single runtime source of truth so the callback host cannot drift from the API host the service is talking to. ([#9752](https://github.com/MetaMask/core/pull/9752))
|
|
24
|
+
- Mobile should drop the `getDefaultRedirectUrl: () => getRampCallbackBaseUrl()` argument from its `RampsController` init once it upgrades, and reimplement `getRampCallbackBaseUrl()` as `getDefaultRedirectCallbackUrl(getRampsEnvironment())` so the UI callback matcher and the controller default resolve from the same environment source.
|
|
25
|
+
|
|
10
26
|
## [18.0.1]
|
|
11
27
|
|
|
12
28
|
### Changed
|
package/dist/RampsController.cjs
CHANGED
|
@@ -10,7 +10,7 @@ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (
|
|
|
10
10
|
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");
|
|
11
11
|
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
12
12
|
};
|
|
13
|
-
var _RampsController_instances, _RampsController_requestCacheTTL, _RampsController_requestCacheMaxSize,
|
|
13
|
+
var _RampsController_instances, _RampsController_requestCacheTTL, _RampsController_requestCacheMaxSize, _RampsController_pendingRequests, _RampsController_pendingResourceCount, _RampsController_pendingResourceGeneration, _RampsController_orderPollingMeta, _RampsController_orderPollingTimer, _RampsController_isPolling, _RampsController_initPromise, _RampsController_clearPendingResourceCountForDependentResources, _RampsController_abortDependentRequests, _RampsController_resolveAllProvidersFlag, _RampsController_mutateRequests, _RampsController_removeRequestState, _RampsController_cleanupState, _RampsController_requireRegion, _RampsController_isRegionCurrent, _RampsController_isTokenCurrent, _RampsController_isProviderCurrent, _RampsController_updateResourceField, _RampsController_setResourceLoading, _RampsController_setResourceError, _RampsController_updateRequestState, _RampsController_runInit, _RampsController_syncUserRegionFromCountriesCatalog, _RampsController_pickWidenedQuote, _RampsController_getSupportingProvidersForRegion, _RampsController_filterProviderIdsBySupport, _RampsController_resolveProviderIdsForQuote, _RampsController_getPreferredProviderIdsFromOrders, _RampsController_refreshOrder, _RampsController_pollPendingOrders, _RampsController_syncTransakAuthOnError, _RampsController_getNormalizedTransakError;
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.RampsController = exports.getInternalOrderCode = exports.getDefaultRampsControllerState = exports.RAMPS_CONTROLLER_REQUIRED_SERVICE_ACTIONS = exports.controllerName = void 0;
|
|
16
16
|
const base_controller_1 = require("@metamask/base-controller");
|
|
@@ -33,6 +33,7 @@ exports.controllerName = 'RampsController';
|
|
|
33
33
|
* these actions from the root messenger so the controller can function.
|
|
34
34
|
*/
|
|
35
35
|
exports.RAMPS_CONTROLLER_REQUIRED_SERVICE_ACTIONS = [
|
|
36
|
+
'RampsService:getDefaultRedirectCallbackUrl',
|
|
36
37
|
'RampsService:getGeolocation',
|
|
37
38
|
'RampsService:getCountries',
|
|
38
39
|
'RampsService:getTokens',
|
|
@@ -441,11 +442,8 @@ class RampsController extends base_controller_1.BaseController {
|
|
|
441
442
|
* controller. Missing properties will be filled in with defaults.
|
|
442
443
|
* @param args.requestCacheTTL - Time to live for cached requests in milliseconds.
|
|
443
444
|
* @param args.requestCacheMaxSize - Maximum number of entries in the request cache.
|
|
444
|
-
* @param args.getDefaultRedirectUrl - Optional callback returning the default
|
|
445
|
-
* redirect URL used for the widened quote fetch when the caller omits
|
|
446
|
-
* `redirectUrl`. Defaults to a callback returning `undefined`.
|
|
447
445
|
*/
|
|
448
|
-
constructor({ messenger, state = {}, requestCacheTTL = RequestCache_js_1.DEFAULT_REQUEST_CACHE_TTL, requestCacheMaxSize = RequestCache_js_1.DEFAULT_REQUEST_CACHE_MAX_SIZE,
|
|
446
|
+
constructor({ messenger, state = {}, requestCacheTTL = RequestCache_js_1.DEFAULT_REQUEST_CACHE_TTL, requestCacheMaxSize = RequestCache_js_1.DEFAULT_REQUEST_CACHE_MAX_SIZE, }) {
|
|
449
447
|
super({
|
|
450
448
|
messenger,
|
|
451
449
|
metadata: rampsControllerMetadata,
|
|
@@ -466,12 +464,6 @@ class RampsController extends base_controller_1.BaseController {
|
|
|
466
464
|
* Maximum number of entries in the request cache.
|
|
467
465
|
*/
|
|
468
466
|
_RampsController_requestCacheMaxSize.set(this, void 0);
|
|
469
|
-
/**
|
|
470
|
-
* Resolves the default redirect URL for the widened quote fetch when
|
|
471
|
-
* the caller omits `redirectUrl`. Defaults to `() => undefined` when no
|
|
472
|
-
* callback is injected.
|
|
473
|
-
*/
|
|
474
|
-
_RampsController_getDefaultRedirectUrl.set(this, void 0);
|
|
475
467
|
/**
|
|
476
468
|
* Map of pending requests for deduplication.
|
|
477
469
|
* Key is the cache key, value is the pending request with abort controller.
|
|
@@ -493,7 +485,6 @@ class RampsController extends base_controller_1.BaseController {
|
|
|
493
485
|
_RampsController_initPromise.set(this, null);
|
|
494
486
|
__classPrivateFieldSet(this, _RampsController_requestCacheTTL, requestCacheTTL, "f");
|
|
495
487
|
__classPrivateFieldSet(this, _RampsController_requestCacheMaxSize, requestCacheMaxSize, "f");
|
|
496
|
-
__classPrivateFieldSet(this, _RampsController_getDefaultRedirectUrl, getDefaultRedirectUrl ?? (() => undefined), "f");
|
|
497
488
|
this.messenger.registerMethodActionHandlers(this, MESSENGER_EXPOSED_METHODS);
|
|
498
489
|
}
|
|
499
490
|
/**
|
|
@@ -1088,12 +1079,16 @@ class RampsController extends base_controller_1.BaseController {
|
|
|
1088
1079
|
const normalizedAssetId = normalizedAssetIdForValidation;
|
|
1089
1080
|
const normalizedWalletAddress = options.walletAddress.trim();
|
|
1090
1081
|
// The quotes API only embeds a `buyURL`/`buyWidget` when a `redirectUrl` is
|
|
1091
|
-
// present, so on the widened path (where MM Pay omits one)
|
|
1092
|
-
//
|
|
1093
|
-
//
|
|
1094
|
-
//
|
|
1082
|
+
// present, so on the widened path (where MM Pay omits one) ask the service
|
|
1083
|
+
// for the callback URL of the environment it is configured with, so
|
|
1084
|
+
// aggregator quotes carry a usable widget URL that always matches the
|
|
1085
|
+
// environment the quotes came from. An explicit caller `redirectUrl`
|
|
1086
|
+
// always wins, and the native-only path (flag off) never injects, so
|
|
1087
|
+
// neither reaches the service.
|
|
1095
1088
|
const effectiveRedirectUrl = options.redirectUrl ??
|
|
1096
|
-
(widenToAllProviders
|
|
1089
|
+
(widenToAllProviders
|
|
1090
|
+
? this.messenger.call('RampsService:getDefaultRedirectCallbackUrl')
|
|
1091
|
+
: undefined);
|
|
1097
1092
|
const cacheKey = (0, RequestCache_js_1.createCacheKey)('getQuotes', [
|
|
1098
1093
|
normalizedRegion,
|
|
1099
1094
|
normalizedFiat,
|
|
@@ -1786,7 +1781,7 @@ class RampsController extends base_controller_1.BaseController {
|
|
|
1786
1781
|
}
|
|
1787
1782
|
}
|
|
1788
1783
|
exports.RampsController = RampsController;
|
|
1789
|
-
_RampsController_requestCacheTTL = new WeakMap(), _RampsController_requestCacheMaxSize = new WeakMap(),
|
|
1784
|
+
_RampsController_requestCacheTTL = new WeakMap(), _RampsController_requestCacheMaxSize = new WeakMap(), _RampsController_pendingRequests = new WeakMap(), _RampsController_pendingResourceCount = new WeakMap(), _RampsController_pendingResourceGeneration = new WeakMap(), _RampsController_orderPollingMeta = new WeakMap(), _RampsController_orderPollingTimer = new WeakMap(), _RampsController_isPolling = new WeakMap(), _RampsController_initPromise = new WeakMap(), _RampsController_instances = new WeakSet(), _RampsController_clearPendingResourceCountForDependentResources = function _RampsController_clearPendingResourceCountForDependentResources() {
|
|
1790
1785
|
for (const resourceType of DEPENDENT_RESOURCE_KEYS) {
|
|
1791
1786
|
__classPrivateFieldGet(this, _RampsController_pendingResourceCount, "f").delete(resourceType);
|
|
1792
1787
|
const generation = __classPrivateFieldGet(this, _RampsController_pendingResourceGeneration, "f").get(resourceType) ?? 0;
|