@metamask-previews/perps-controller 1.0.1-preview-935b6049c → 1.0.1-preview-ab77ad36e
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 -5
- package/dist/PerpsController.cjs +6 -28
- package/dist/PerpsController.cjs.map +1 -1
- package/dist/PerpsController.d.cts +4 -19
- package/dist/PerpsController.d.cts.map +1 -1
- package/dist/PerpsController.d.mts +4 -19
- package/dist/PerpsController.d.mts.map +1 -1
- package/dist/PerpsController.mjs +6 -28
- package/dist/PerpsController.mjs.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -7,11 +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 `deferEligibilityCheck` option to `PerpsControllerOptions` to skip the eager geolocation fetch during construction
|
|
13
|
-
- Add `startEligibilityMonitoring()` method to activate geo-blocking eligibility checks post-onboarding
|
|
14
|
-
|
|
15
10
|
## [1.0.1]
|
|
16
11
|
|
|
17
12
|
### Changed
|
package/dist/PerpsController.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 _PerpsController_instances, _a, _PerpsController_initializationPromise, _PerpsController_isReinitializing, _PerpsController_blockedRegionListVersion, _PerpsController_hip3Enabled, _PerpsController_hip3AllowlistMarkets, _PerpsController_hip3BlocklistMarkets, _PerpsController_hip3ConfigSource, _PerpsController_isMYXProviderEnabled, _PerpsController_standaloneProvider, _PerpsController_standaloneProviderIsTestnet, _PerpsController_standaloneProviderHip3Version,
|
|
13
|
+
var _PerpsController_instances, _a, _PerpsController_initializationPromise, _PerpsController_isReinitializing, _PerpsController_blockedRegionListVersion, _PerpsController_hip3Enabled, _PerpsController_hip3AllowlistMarkets, _PerpsController_hip3BlocklistMarkets, _PerpsController_hip3ConfigSource, _PerpsController_isMYXProviderEnabled, _PerpsController_standaloneProvider, _PerpsController_standaloneProviderIsTestnet, _PerpsController_standaloneProviderHip3Version, _PerpsController_options, _PerpsController_tradingService, _PerpsController_marketDataService, _PerpsController_accountService, _PerpsController_eligibilityService, _PerpsController_dataLakeService, _PerpsController_depositService, _PerpsController_featureFlagConfigurationService, _PerpsController_rewardsIntegrationService, _PerpsController_logError, _PerpsController_debugLog, _PerpsController_getOrCreateStandaloneProvider, _PerpsController_cleanupStandaloneProvider, _PerpsController_getMetrics, _PerpsController_findNetworkClientIdForChain, _PerpsController_submitTransaction, _PerpsController_migrateRequestsIfNeeded, _PerpsController_withStreamPause, _PerpsController_performInitialization, _PerpsController_getErrorContext, _PerpsController_getControllerState, _PerpsController_createServiceContext, _PerpsController_ensureTradingServiceDeps, _PerpsController_preloadWatchedPaths, _PerpsController_preloadTimer, _PerpsController_isPreloading, _PerpsController_isPreloadingUserData, _PerpsController_preloadStateUnsubscribe, _PerpsController_accountChangeUnsubscribe, _PerpsController_previousIsTestnet, _PerpsController_previousHip3ConfigVersion, _PerpsController_preloadRefreshMs, _PerpsController_preloadGuardMs, _PerpsController_performMarketDataPreload, _PerpsController_performUserDataPreload;
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.PerpsController = exports.getDefaultPerpsControllerState = exports.InitializationState = exports.PERPS_ERROR_CODES = void 0;
|
|
16
16
|
const base_controller_1 = require("@metamask/base-controller");
|
|
@@ -347,7 +347,6 @@ const MESSENGER_EXPOSED_METHODS = [
|
|
|
347
347
|
'saveOrderBookGrouping',
|
|
348
348
|
'setSelectedPaymentToken',
|
|
349
349
|
'resetSelectedPaymentToken',
|
|
350
|
-
'startEligibilityMonitoring',
|
|
351
350
|
];
|
|
352
351
|
/**
|
|
353
352
|
* PerpsController - Protocol-agnostic perpetuals trading controller
|
|
@@ -358,7 +357,7 @@ const MESSENGER_EXPOSED_METHODS = [
|
|
|
358
357
|
* - Live data uses direct callbacks for maximum performance
|
|
359
358
|
*/
|
|
360
359
|
class PerpsController extends base_controller_1.BaseController {
|
|
361
|
-
constructor({ messenger, state = {}, clientConfig = {}, infrastructure,
|
|
360
|
+
constructor({ messenger, state = {}, clientConfig = {}, infrastructure, }) {
|
|
362
361
|
super({
|
|
363
362
|
name: 'PerpsController',
|
|
364
363
|
metadata,
|
|
@@ -399,7 +398,6 @@ class PerpsController extends base_controller_1.BaseController {
|
|
|
399
398
|
_PerpsController_standaloneProvider.set(this, null);
|
|
400
399
|
_PerpsController_standaloneProviderIsTestnet.set(this, null);
|
|
401
400
|
_PerpsController_standaloneProviderHip3Version.set(this, null);
|
|
402
|
-
_PerpsController_eligibilityCheckDeferred.set(this, void 0);
|
|
403
401
|
// Store options for dependency injection (allows core package to inject platform-specific services)
|
|
404
402
|
_PerpsController_options.set(this, void 0);
|
|
405
403
|
// Service instances (instantiated with platform dependencies)
|
|
@@ -418,7 +416,6 @@ class PerpsController extends base_controller_1.BaseController {
|
|
|
418
416
|
_PerpsController_accountChangeUnsubscribe.set(this, null);
|
|
419
417
|
_PerpsController_previousIsTestnet.set(this, null);
|
|
420
418
|
_PerpsController_previousHip3ConfigVersion.set(this, null);
|
|
421
|
-
__classPrivateFieldSet(this, _PerpsController_eligibilityCheckDeferred, deferEligibilityCheck, "f");
|
|
422
419
|
// Store options for dependency injection
|
|
423
420
|
__classPrivateFieldSet(this, _PerpsController_options, {
|
|
424
421
|
messenger,
|
|
@@ -2087,34 +2084,15 @@ class PerpsController extends base_controller_1.BaseController {
|
|
|
2087
2084
|
* Eligibility (Geo-Blocking)
|
|
2088
2085
|
*/
|
|
2089
2086
|
/**
|
|
2090
|
-
*
|
|
2091
|
-
* Call this after onboarding is complete when the controller was constructed
|
|
2092
|
-
* with `deferEligibilityCheck: true`.
|
|
2087
|
+
* Fetch geo location
|
|
2093
2088
|
*
|
|
2094
|
-
*
|
|
2095
|
-
*
|
|
2096
|
-
* future feature-flag updates flow through normally.
|
|
2097
|
-
* Safe to call multiple times; subsequent calls simply re-check eligibility.
|
|
2089
|
+
* Returned in Country or Country-Region format
|
|
2090
|
+
* Example: FR, DE, US-MI, CA-ON
|
|
2098
2091
|
*/
|
|
2099
|
-
startEligibilityMonitoring() {
|
|
2100
|
-
__classPrivateFieldSet(this, _PerpsController_eligibilityCheckDeferred, false, "f");
|
|
2101
|
-
try {
|
|
2102
|
-
const currentState = this.messenger.call('RemoteFeatureFlagController:getState');
|
|
2103
|
-
this.refreshEligibilityOnFeatureFlagChange(currentState);
|
|
2104
|
-
}
|
|
2105
|
-
catch (error) {
|
|
2106
|
-
__classPrivateFieldGet(this, _PerpsController_instances, "m", _PerpsController_logError).call(this, (0, errorUtils_1.ensureError)(error, 'PerpsController.startEligibilityMonitoring'), __classPrivateFieldGet(this, _PerpsController_instances, "m", _PerpsController_getErrorContext).call(this, 'startEligibilityMonitoring', {
|
|
2107
|
-
operation: 'readRemoteFeatureFlags',
|
|
2108
|
-
}));
|
|
2109
|
-
}
|
|
2110
|
-
}
|
|
2111
2092
|
/**
|
|
2112
2093
|
* Refresh eligibility status
|
|
2113
2094
|
*/
|
|
2114
2095
|
async refreshEligibility() {
|
|
2115
|
-
if (__classPrivateFieldGet(this, _PerpsController_eligibilityCheckDeferred, "f")) {
|
|
2116
|
-
return;
|
|
2117
|
-
}
|
|
2118
2096
|
// Capture the current version before starting the async operation.
|
|
2119
2097
|
// This prevents race conditions where stale eligibility checks
|
|
2120
2098
|
// (started with fallback config) overwrite results from newer checks
|
|
@@ -2607,7 +2585,7 @@ class PerpsController extends base_controller_1.BaseController {
|
|
|
2607
2585
|
}
|
|
2608
2586
|
}
|
|
2609
2587
|
exports.PerpsController = PerpsController;
|
|
2610
|
-
_a = PerpsController, _PerpsController_initializationPromise = new WeakMap(), _PerpsController_isReinitializing = new WeakMap(), _PerpsController_blockedRegionListVersion = new WeakMap(), _PerpsController_hip3Enabled = new WeakMap(), _PerpsController_hip3AllowlistMarkets = new WeakMap(), _PerpsController_hip3BlocklistMarkets = new WeakMap(), _PerpsController_hip3ConfigSource = new WeakMap(), _PerpsController_standaloneProvider = new WeakMap(), _PerpsController_standaloneProviderIsTestnet = new WeakMap(), _PerpsController_standaloneProviderHip3Version = new WeakMap(),
|
|
2588
|
+
_a = PerpsController, _PerpsController_initializationPromise = new WeakMap(), _PerpsController_isReinitializing = new WeakMap(), _PerpsController_blockedRegionListVersion = new WeakMap(), _PerpsController_hip3Enabled = new WeakMap(), _PerpsController_hip3AllowlistMarkets = new WeakMap(), _PerpsController_hip3BlocklistMarkets = new WeakMap(), _PerpsController_hip3ConfigSource = new WeakMap(), _PerpsController_standaloneProvider = new WeakMap(), _PerpsController_standaloneProviderIsTestnet = new WeakMap(), _PerpsController_standaloneProviderHip3Version = new WeakMap(), _PerpsController_options = new WeakMap(), _PerpsController_tradingService = new WeakMap(), _PerpsController_marketDataService = new WeakMap(), _PerpsController_accountService = new WeakMap(), _PerpsController_eligibilityService = new WeakMap(), _PerpsController_dataLakeService = new WeakMap(), _PerpsController_depositService = new WeakMap(), _PerpsController_featureFlagConfigurationService = new WeakMap(), _PerpsController_rewardsIntegrationService = new WeakMap(), _PerpsController_preloadTimer = new WeakMap(), _PerpsController_isPreloading = new WeakMap(), _PerpsController_isPreloadingUserData = new WeakMap(), _PerpsController_preloadStateUnsubscribe = new WeakMap(), _PerpsController_accountChangeUnsubscribe = new WeakMap(), _PerpsController_previousIsTestnet = new WeakMap(), _PerpsController_previousHip3ConfigVersion = new WeakMap(), _PerpsController_instances = new WeakSet(), _PerpsController_isMYXProviderEnabled = function _PerpsController_isMYXProviderEnabled() {
|
|
2611
2589
|
const getLocalFlag = () => typeof globalThis.process !== 'undefined' &&
|
|
2612
2590
|
globalThis.process.env?.MM_PERPS_MYX_PROVIDER_ENABLED === 'true';
|
|
2613
2591
|
try {
|