@metamask-previews/ramps-controller 10.2.0-preview-93519965c → 10.2.0-preview-ccd74c3b
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 +0 -4
- package/dist/RampsController.cjs +9 -16
- package/dist/RampsController.cjs.map +1 -1
- package/dist/RampsController.d.cts +0 -6
- package/dist/RampsController.d.cts.map +1 -1
- package/dist/RampsController.d.mts +0 -6
- package/dist/RampsController.d.mts.map +1 -1
- package/dist/RampsController.mjs +9 -16
- package/dist/RampsController.mjs.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -7,10 +7,6 @@ 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 `status` field to `ResourceState` to distinguish between uninitialized and empty-fetched states ([#8116](https://github.com/MetaMask/core/pull/8116))
|
|
13
|
-
|
|
14
10
|
## [10.2.0]
|
|
15
11
|
|
|
16
12
|
### Fixed
|
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, _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,
|
|
13
|
+
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;
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.RampsController = exports.getDefaultRampsControllerState = exports.RAMPS_CONTROLLER_REQUIRED_SERVICE_ACTIONS = exports.controllerName = void 0;
|
|
16
16
|
const base_controller_1 = require("@metamask/base-controller");
|
|
@@ -136,7 +136,6 @@ function createDefaultResourceState(data, selected = null) {
|
|
|
136
136
|
selected,
|
|
137
137
|
isLoading: false,
|
|
138
138
|
error: null,
|
|
139
|
-
status: RequestCache_1.RequestStatus.IDLE,
|
|
140
139
|
};
|
|
141
140
|
}
|
|
142
141
|
/**
|
|
@@ -180,7 +179,6 @@ function resetResource(state, resourceType, defaultResource) {
|
|
|
180
179
|
resource.selected = def.selected;
|
|
181
180
|
resource.isLoading = def.isLoading;
|
|
182
181
|
resource.error = def.error;
|
|
183
|
-
resource.status = def.status;
|
|
184
182
|
}
|
|
185
183
|
/**
|
|
186
184
|
* Resets region-dependent resources (userRegion, providers, tokens, paymentMethods).
|
|
@@ -384,12 +382,11 @@ class RampsController extends base_controller_1.BaseController {
|
|
|
384
382
|
const count = __classPrivateFieldGet(this, _RampsController_pendingResourceCount, "f").get(resourceType) ?? 0;
|
|
385
383
|
__classPrivateFieldGet(this, _RampsController_pendingResourceCount, "f").set(resourceType, count + 1);
|
|
386
384
|
if (count === 0) {
|
|
387
|
-
__classPrivateFieldGet(this, _RampsController_instances, "m",
|
|
385
|
+
__classPrivateFieldGet(this, _RampsController_instances, "m", _RampsController_setResourceLoading).call(this, resourceType, true);
|
|
388
386
|
}
|
|
389
387
|
}
|
|
390
388
|
// Create the fetch promise
|
|
391
389
|
const promise = (async () => {
|
|
392
|
-
let terminalStatus;
|
|
393
390
|
try {
|
|
394
391
|
const data = await fetcher(abortController.signal);
|
|
395
392
|
if (abortController.signal.aborted) {
|
|
@@ -400,7 +397,6 @@ class RampsController extends base_controller_1.BaseController {
|
|
|
400
397
|
const isCurrent = !options?.isResultCurrent || options.isResultCurrent();
|
|
401
398
|
if (isCurrent) {
|
|
402
399
|
__classPrivateFieldGet(this, _RampsController_instances, "m", _RampsController_setResourceError).call(this, resourceType, null);
|
|
403
|
-
terminalStatus = RequestCache_1.RequestStatus.SUCCESS;
|
|
404
400
|
}
|
|
405
401
|
}
|
|
406
402
|
return data;
|
|
@@ -415,7 +411,6 @@ class RampsController extends base_controller_1.BaseController {
|
|
|
415
411
|
const isCurrent = !options?.isResultCurrent || options.isResultCurrent();
|
|
416
412
|
if (isCurrent) {
|
|
417
413
|
__classPrivateFieldGet(this, _RampsController_instances, "m", _RampsController_setResourceError).call(this, resourceType, errorMessage);
|
|
418
|
-
terminalStatus = RequestCache_1.RequestStatus.ERROR;
|
|
419
414
|
}
|
|
420
415
|
}
|
|
421
416
|
throw error;
|
|
@@ -431,7 +426,7 @@ class RampsController extends base_controller_1.BaseController {
|
|
|
431
426
|
const next = Math.max(0, count - 1);
|
|
432
427
|
if (next === 0) {
|
|
433
428
|
__classPrivateFieldGet(this, _RampsController_pendingResourceCount, "f").delete(resourceType);
|
|
434
|
-
__classPrivateFieldGet(this, _RampsController_instances, "m",
|
|
429
|
+
__classPrivateFieldGet(this, _RampsController_instances, "m", _RampsController_setResourceLoading).call(this, resourceType, false);
|
|
435
430
|
}
|
|
436
431
|
else {
|
|
437
432
|
__classPrivateFieldGet(this, _RampsController_pendingResourceCount, "f").set(resourceType, next);
|
|
@@ -964,7 +959,7 @@ class RampsController extends base_controller_1.BaseController {
|
|
|
964
959
|
}
|
|
965
960
|
try {
|
|
966
961
|
const buyWidget = await this.messenger.call('RampsService:getBuyWidgetUrl', buyUrl);
|
|
967
|
-
return buyWidget.url;
|
|
962
|
+
return buyWidget.url ?? null;
|
|
968
963
|
}
|
|
969
964
|
catch {
|
|
970
965
|
return null;
|
|
@@ -1449,19 +1444,17 @@ _RampsController_requestCacheTTL = new WeakMap(), _RampsController_requestCacheM
|
|
|
1449
1444
|
}, _RampsController_isProviderCurrent = function _RampsController_isProviderCurrent(normalizedProviderId) {
|
|
1450
1445
|
const current = this.state.providers.selected?.id ?? '';
|
|
1451
1446
|
return current === normalizedProviderId;
|
|
1452
|
-
},
|
|
1447
|
+
}, _RampsController_updateResourceField = function _RampsController_updateResourceField(resourceType, field, value) {
|
|
1453
1448
|
this.update((state) => {
|
|
1454
1449
|
const resource = state[resourceType];
|
|
1455
1450
|
if (resource) {
|
|
1456
|
-
|
|
1457
|
-
resource[field] = value;
|
|
1458
|
-
}
|
|
1451
|
+
resource[field] = value;
|
|
1459
1452
|
}
|
|
1460
1453
|
});
|
|
1454
|
+
}, _RampsController_setResourceLoading = function _RampsController_setResourceLoading(resourceType, loading) {
|
|
1455
|
+
__classPrivateFieldGet(this, _RampsController_instances, "m", _RampsController_updateResourceField).call(this, resourceType, 'isLoading', loading);
|
|
1461
1456
|
}, _RampsController_setResourceError = function _RampsController_setResourceError(resourceType, error) {
|
|
1462
|
-
__classPrivateFieldGet(this, _RampsController_instances, "m",
|
|
1463
|
-
}, _RampsController_setResourceLoadingAndStatus = function _RampsController_setResourceLoadingAndStatus(resourceType, loading, status) {
|
|
1464
|
-
__classPrivateFieldGet(this, _RampsController_instances, "m", _RampsController_updateResourceFields).call(this, resourceType, { isLoading: loading, status });
|
|
1457
|
+
__classPrivateFieldGet(this, _RampsController_instances, "m", _RampsController_updateResourceField).call(this, resourceType, 'error', error);
|
|
1465
1458
|
}, _RampsController_updateRequestState = function _RampsController_updateRequestState(cacheKey, requestState) {
|
|
1466
1459
|
const maxSize = __classPrivateFieldGet(this, _RampsController_requestCacheMaxSize, "f");
|
|
1467
1460
|
const ttl = __classPrivateFieldGet(this, _RampsController_requestCacheTTL, "f");
|