@metamask-previews/perps-controller 15.1.0-preview-ea6a28c61 → 15.1.0-preview-e12b5ece6
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 +14 -0
- package/dist/PerpsController.cjs +19 -153
- package/dist/PerpsController.cjs.map +1 -1
- package/dist/PerpsController.d.cts +2 -42
- package/dist/PerpsController.d.cts.map +1 -1
- package/dist/PerpsController.d.mts +2 -42
- package/dist/PerpsController.d.mts.map +1 -1
- package/dist/PerpsController.mjs +18 -150
- package/dist/PerpsController.mjs.map +1 -1
- package/dist/aggregation/SubscriptionMultiplexer.cjs +1 -1
- package/dist/aggregation/SubscriptionMultiplexer.cjs.map +1 -1
- package/dist/aggregation/SubscriptionMultiplexer.d.cts +1 -1
- package/dist/aggregation/SubscriptionMultiplexer.d.mts +1 -1
- package/dist/aggregation/SubscriptionMultiplexer.mjs +1 -1
- package/dist/aggregation/SubscriptionMultiplexer.mjs.map +1 -1
- package/dist/constants/index.cjs +0 -1
- package/dist/constants/index.cjs.map +1 -1
- package/dist/constants/index.d.cts +0 -1
- package/dist/constants/index.d.cts.map +1 -1
- package/dist/constants/index.d.mts +0 -1
- package/dist/constants/index.d.mts.map +1 -1
- package/dist/constants/index.mjs +0 -1
- package/dist/constants/index.mjs.map +1 -1
- package/dist/constants/perpsConfig.cjs +4 -9
- package/dist/constants/perpsConfig.cjs.map +1 -1
- package/dist/constants/perpsConfig.d.cts +3 -5
- package/dist/constants/perpsConfig.d.cts.map +1 -1
- package/dist/constants/perpsConfig.d.mts +3 -5
- package/dist/constants/perpsConfig.d.mts.map +1 -1
- package/dist/constants/perpsConfig.mjs +4 -9
- package/dist/constants/perpsConfig.mjs.map +1 -1
- package/dist/index.cjs +146 -175
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +0 -1
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +0 -1
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +0 -1
- package/dist/index.mjs.map +1 -1
- package/dist/providers/AggregatedPerpsProvider.cjs +2 -2
- package/dist/providers/AggregatedPerpsProvider.cjs.map +1 -1
- package/dist/providers/AggregatedPerpsProvider.d.cts +2 -2
- package/dist/providers/AggregatedPerpsProvider.d.mts +2 -2
- package/dist/providers/AggregatedPerpsProvider.mjs +2 -2
- package/dist/providers/AggregatedPerpsProvider.mjs.map +1 -1
- package/dist/providers/LighterProvider.cjs +1 -1
- package/dist/providers/LighterProvider.cjs.map +1 -1
- package/dist/providers/LighterProvider.mjs +1 -1
- package/dist/providers/LighterProvider.mjs.map +1 -1
- package/dist/routing/ProviderRouter.cjs +1 -1
- package/dist/routing/ProviderRouter.cjs.map +1 -1
- package/dist/routing/ProviderRouter.d.cts +1 -1
- package/dist/routing/ProviderRouter.d.mts +1 -1
- package/dist/routing/ProviderRouter.mjs +1 -1
- package/dist/routing/ProviderRouter.mjs.map +1 -1
- package/dist/services/LighterWalletService.cjs +1 -1
- package/dist/services/LighterWalletService.cjs.map +1 -1
- package/dist/services/LighterWalletService.d.cts +1 -1
- package/dist/services/LighterWalletService.d.mts +1 -1
- package/dist/services/LighterWalletService.mjs +1 -1
- package/dist/services/LighterWalletService.mjs.map +1 -1
- package/dist/types/index.cjs.map +1 -1
- package/dist/types/index.d.cts +2 -16
- package/dist/types/index.d.cts.map +1 -1
- package/dist/types/index.d.mts +2 -16
- package/dist/types/index.d.mts.map +1 -1
- package/dist/types/index.mjs.map +1 -1
- package/dist/utils/lighterAdapter.cjs +1 -2
- package/dist/utils/lighterAdapter.cjs.map +1 -1
- package/dist/utils/lighterAdapter.d.cts +1 -2
- package/dist/utils/lighterAdapter.d.cts.map +1 -1
- package/dist/utils/lighterAdapter.d.mts +1 -2
- package/dist/utils/lighterAdapter.d.mts.map +1 -1
- package/dist/utils/lighterAdapter.mjs +1 -2
- package/dist/utils/lighterAdapter.mjs.map +1 -1
- package/package.json +4 -10
- package/dist/constants/myxConfig.cjs +0 -253
- package/dist/constants/myxConfig.cjs.map +0 -1
- package/dist/constants/myxConfig.d.cts +0 -145
- package/dist/constants/myxConfig.d.cts.map +0 -1
- package/dist/constants/myxConfig.d.mts +0 -145
- package/dist/constants/myxConfig.d.mts.map +0 -1
- package/dist/constants/myxConfig.mjs +0 -243
- package/dist/constants/myxConfig.mjs.map +0 -1
- package/dist/types/myx-types.cjs +0 -41
- package/dist/types/myx-types.cjs.map +0 -1
- package/dist/types/myx-types.d.cts +0 -94
- package/dist/types/myx-types.d.cts.map +0 -1
- package/dist/types/myx-types.d.mts +0 -94
- package/dist/types/myx-types.d.mts.map +0 -1
- package/dist/types/myx-types.mjs +0 -26
- package/dist/types/myx-types.mjs.map +0 -1
- package/dist/utils/myxAdapter.cjs +0 -569
- package/dist/utils/myxAdapter.cjs.map +0 -1
- package/dist/utils/myxAdapter.d.cts +0 -168
- package/dist/utils/myxAdapter.d.cts.map +0 -1
- package/dist/utils/myxAdapter.d.mts +0 -168
- package/dist/utils/myxAdapter.d.mts.map +0 -1
- package/dist/utils/myxAdapter.mjs +0 -548
- package/dist/utils/myxAdapter.mjs.map +0 -1
package/dist/PerpsController.mjs
CHANGED
|
@@ -9,7 +9,7 @@ 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 _PerpsController_instances, _a, _PerpsController_initializationPromise, _PerpsController_isReinitializing, _PerpsController_reinitializationOperationPromise, _PerpsController_disconnectOperationPromise,
|
|
12
|
+
var _PerpsController_instances, _a, _PerpsController_initializationPromise, _PerpsController_isReinitializing, _PerpsController_reinitializationOperationPromise, _PerpsController_disconnectOperationPromise, _PerpsController_lighterRegistrationPromise, _PerpsController_blockedRegionListVersion, _PerpsController_hip3Enabled, _PerpsController_hip3AllowlistMarkets, _PerpsController_hip3BlocklistMarkets, _PerpsController_hip3ConfigSource, _PerpsController_priceDeviationLimit, _PerpsController_attributionContext, _PerpsController_isLighterProviderEnabled, _PerpsController_standaloneProvider, _PerpsController_handlersRegistered, _PerpsController_standaloneProviderIsTestnet, _PerpsController_standaloneProviderHip3Version, _PerpsController_standaloneProviderOperations, _PerpsController_eligibilityCheckDeferred, _PerpsController_ausQueue, _PerpsController_userDiskWrite, _PerpsController_options, _PerpsController_tradingService, _PerpsController_marketDataService, _PerpsController_accountService, _PerpsController_eligibilityService, _PerpsController_dataLakeService, _PerpsController_depositService, _PerpsController_featureFlagConfigurationService, _PerpsController_rewardsIntegrationService, _PerpsController_publishChaseOrderMaxDistanceReached, _PerpsController_logError, _PerpsController_debugLog, _PerpsController_getAggregatedCacheProviderIds, _PerpsController_isMarketCacheEntryCurrent, _PerpsController_isUserCacheIdentityCurrent, _PerpsController_fetchAndCacheUserDataSnapshot, _PerpsController_getOrCreateStandaloneProvider, _PerpsController_trackStandaloneProviderOperation, _PerpsController_retireStandaloneProvider, _PerpsController_cleanupStandaloneProvider, _PerpsController_getMetrics, _PerpsController_findNetworkClientIdForChain, _PerpsController_submitTransaction, _PerpsController_migrateRequestsIfNeeded, _PerpsController_withStreamPause, _PerpsController_initWithoutDisconnectWait, _PerpsController_beginReinitialization, _PerpsController_performInitialization, _PerpsController_createProviders, _PerpsController_assignActiveProvider, _PerpsController_getErrorContext, _PerpsController_getControllerState, _PerpsController_buildMarketAllowedFilter, _PerpsController_compilePatternsSafely, _PerpsController_createServiceContext, _PerpsController_ensureTradingServiceDeps, _PerpsController_getActiveProviderWhenReady, _PerpsController_getUnavailableScalePriceLadder, _PerpsController_getUnavailableOrderCapabilities, _PerpsController_getDirectProviderId, _PerpsController_hasConflictingProviderRoute, _PerpsController_resolveRoutedOrderProvider, _PerpsController_buildGlobalSnapshotContext, _PerpsController_getStaticSnapshotDexes, _PerpsController_preloadWatchedPaths, _PerpsController_preloadTimer, _PerpsController_preloadStartRequested, _PerpsController_isPreloading, _PerpsController_marketPreloadQueued, _PerpsController_isPreloadingUserData, _PerpsController_userPreloadQueued, _PerpsController_lifecycleGeneration, _PerpsController_userSnapshotRequests, _PerpsController_preloadStateUnsubscribe, _PerpsController_accountChangeUnsubscribe, _PerpsController_previousIsTestnet, _PerpsController_previousHip3ConfigVersion, _PerpsController_preloadRefreshMs, _PerpsController_preloadGuardMs, _PerpsController_hydrateCacheFromDiskSync, _PerpsController_persistUserCacheToDisk, _PerpsController_performMarketDataPreload, _PerpsController_performUserDataPreload, _PerpsController_performDisconnect, _PerpsController_persistWatchlistToRemote, _PerpsController_syncWatchlistFromRemote;
|
|
13
13
|
import { BaseController } from "@metamask/base-controller";
|
|
14
14
|
import { ORIGIN_METAMASK } from "@metamask/controller-utils";
|
|
15
15
|
import { v4 as uuidv4 } from "uuid";
|
|
@@ -69,16 +69,6 @@ function cloneUserDataSnapshot(snapshot) {
|
|
|
69
69
|
},
|
|
70
70
|
};
|
|
71
71
|
}
|
|
72
|
-
/**
|
|
73
|
-
* Returns the first non-empty string from the given values.
|
|
74
|
-
* Env vars default to '' (not null/undefined), so ?? wouldn't fall through.
|
|
75
|
-
*
|
|
76
|
-
* @param vals - String values to check in order.
|
|
77
|
-
* @returns The first non-empty string, or '' if all are empty/undefined.
|
|
78
|
-
*/
|
|
79
|
-
export function firstNonEmpty(...vals) {
|
|
80
|
-
return (vals.find((val) => val !== null && val !== undefined && val !== '') ?? '');
|
|
81
|
-
}
|
|
82
72
|
/**
|
|
83
73
|
* Maps an active provider mode to the corresponding exchange key used in the
|
|
84
74
|
* AUS {@link PerpsWatchlistMarkets} schema.
|
|
@@ -94,31 +84,9 @@ export function firstNonEmpty(...vals) {
|
|
|
94
84
|
export function resolveWatchlistExchangeKey(activeProvider) {
|
|
95
85
|
const map = {
|
|
96
86
|
hyperliquid: 'hyperliquid',
|
|
97
|
-
myx: 'myx',
|
|
98
87
|
};
|
|
99
88
|
return map[activeProvider] ?? null;
|
|
100
89
|
}
|
|
101
|
-
/**
|
|
102
|
-
* Resolves MYX auth config from provider credentials, handling
|
|
103
|
-
* testnet/mainnet fallback logic.
|
|
104
|
-
*
|
|
105
|
-
* @param myx - MYX provider credentials.
|
|
106
|
-
* @param isTestnet - Whether the controller is in testnet mode.
|
|
107
|
-
* @returns Resolved appId, apiSecret, and brokerAddress.
|
|
108
|
-
*/
|
|
109
|
-
export function resolveMyxAuthConfig(myx, isTestnet) {
|
|
110
|
-
return {
|
|
111
|
-
appId: isTestnet
|
|
112
|
-
? (myx.appIdTestnet ?? '')
|
|
113
|
-
: firstNonEmpty(myx.appIdMainnet, myx.appIdTestnet),
|
|
114
|
-
apiSecret: isTestnet
|
|
115
|
-
? (myx.apiSecretTestnet ?? '')
|
|
116
|
-
: firstNonEmpty(myx.apiSecretMainnet, myx.apiSecretTestnet),
|
|
117
|
-
brokerAddress: isTestnet
|
|
118
|
-
? (myx.brokerAddressTestnet ?? '')
|
|
119
|
-
: firstNonEmpty(myx.brokerAddressMainnet, myx.brokerAddressTestnet),
|
|
120
|
-
};
|
|
121
|
-
}
|
|
122
90
|
// Re-export error codes from separate file to avoid circular dependencies
|
|
123
91
|
export { PERPS_ERROR_CODES } from "./perpsErrorCodes.mjs";
|
|
124
92
|
/**
|
|
@@ -140,7 +108,6 @@ export { PerpsMode, DEFAULT_ORDER_BOOK_PREFERENCES, DEFAULT_PERPS_MODE, DEFAULT_
|
|
|
140
108
|
* To change the active provider, modify the `activeProvider` value below:
|
|
141
109
|
* - 'hyperliquid': HyperLiquid provider (default, production)
|
|
142
110
|
* - 'aggregated': Multi-provider aggregation mode
|
|
143
|
-
* - 'myx': MYX provider (future implementation)
|
|
144
111
|
*
|
|
145
112
|
* @returns The default perps controller state.
|
|
146
113
|
*/
|
|
@@ -562,8 +529,6 @@ export class PerpsController extends BaseController {
|
|
|
562
529
|
_PerpsController_isReinitializing.set(this, false);
|
|
563
530
|
_PerpsController_reinitializationOperationPromise.set(this, null);
|
|
564
531
|
_PerpsController_disconnectOperationPromise.set(this, null);
|
|
565
|
-
/** Tracks the async MYX dynamic import so performInitialization can await it. */
|
|
566
|
-
_PerpsController_myxRegistrationPromise.set(this, null);
|
|
567
532
|
_PerpsController_lighterRegistrationPromise.set(this, null);
|
|
568
533
|
this.blockedRegionList = {
|
|
569
534
|
list: [],
|
|
@@ -593,7 +558,7 @@ export class PerpsController extends BaseController {
|
|
|
593
558
|
_PerpsController_attributionContext.set(this, {});
|
|
594
559
|
/**
|
|
595
560
|
* Active provider instance for routing operations.
|
|
596
|
-
* When activeProvider is 'hyperliquid' or '
|
|
561
|
+
* When activeProvider is 'hyperliquid' or 'lighter': points to specific provider directly
|
|
597
562
|
* When activeProvider is 'aggregated': points to AggregatedPerpsProvider wrapper
|
|
598
563
|
*/
|
|
599
564
|
this.activeProviderInstance = null;
|
|
@@ -1012,50 +977,6 @@ export class PerpsController extends BaseController {
|
|
|
1012
977
|
return __classPrivateFieldGet(this, _PerpsController_instances, "m", _PerpsController_initWithoutDisconnectWait).call(this);
|
|
1013
978
|
}
|
|
1014
979
|
}
|
|
1015
|
-
/**
|
|
1016
|
-
* Registers the MYX provider after dynamic import resolves.
|
|
1017
|
-
*
|
|
1018
|
-
* Extracted from the import().then() callback so it can be tested directly
|
|
1019
|
-
* (Jest cannot resolve dynamic imports without --experimental-vm-modules).
|
|
1020
|
-
*
|
|
1021
|
-
* @param MYXProvider - Constructor class for the MYX provider.
|
|
1022
|
-
*/
|
|
1023
|
-
registerMYXProvider(MYXProvider) {
|
|
1024
|
-
if (typeof MYXProvider !== 'function') {
|
|
1025
|
-
return;
|
|
1026
|
-
}
|
|
1027
|
-
const myxIsTestnet = PROVIDER_CONFIG.MYX_TESTNET_ONLY || this.state.isTestnet;
|
|
1028
|
-
const myx = __classPrivateFieldGet(this, _PerpsController_options, "f").clientConfig?.providerCredentials?.myx ?? {};
|
|
1029
|
-
const myxAuthConfig = resolveMyxAuthConfig(myx, myxIsTestnet);
|
|
1030
|
-
const MYXProviderConstructor = MYXProvider;
|
|
1031
|
-
const myxProvider = new MYXProviderConstructor({
|
|
1032
|
-
isTestnet: myxIsTestnet,
|
|
1033
|
-
platformDependencies: __classPrivateFieldGet(this, _PerpsController_options, "f").infrastructure,
|
|
1034
|
-
messenger: this.messenger,
|
|
1035
|
-
myxAuthConfig,
|
|
1036
|
-
});
|
|
1037
|
-
this.providers.set('myx', myxProvider);
|
|
1038
|
-
__classPrivateFieldGet(this, _PerpsController_instances, "m", _PerpsController_debugLog).call(this, 'PerpsController: MYX provider registered', {
|
|
1039
|
-
isTestnet: myxIsTestnet,
|
|
1040
|
-
});
|
|
1041
|
-
}
|
|
1042
|
-
/**
|
|
1043
|
-
* Handles errors from the MYX dynamic import.
|
|
1044
|
-
*
|
|
1045
|
-
* Module-not-found errors are expected (extension doesn't ship MYX) → debug log.
|
|
1046
|
-
* Other errors indicate constructor/config problems → Sentry via logError.
|
|
1047
|
-
*
|
|
1048
|
-
* @param error - The caught error from the dynamic import or constructor.
|
|
1049
|
-
*/
|
|
1050
|
-
handleMYXImportError(error) {
|
|
1051
|
-
const isModuleError = error?.code === 'MODULE_NOT_FOUND';
|
|
1052
|
-
if (isModuleError) {
|
|
1053
|
-
__classPrivateFieldGet(this, _PerpsController_instances, "m", _PerpsController_debugLog).call(this, 'PerpsController: MYX provider module not available, skipping registration');
|
|
1054
|
-
}
|
|
1055
|
-
else {
|
|
1056
|
-
__classPrivateFieldGet(this, _PerpsController_instances, "m", _PerpsController_logError).call(this, error instanceof Error ? error : new Error(String(error)), __classPrivateFieldGet(this, _PerpsController_instances, "m", _PerpsController_getErrorContext).call(this, 'createProviders.myx'));
|
|
1057
|
-
}
|
|
1058
|
-
}
|
|
1059
980
|
/**
|
|
1060
981
|
* Registers the Lighter provider after dynamic import resolves.
|
|
1061
982
|
*
|
|
@@ -1875,7 +1796,7 @@ export class PerpsController extends BaseController {
|
|
|
1875
1796
|
if (params?.standalone && params.userAddress) {
|
|
1876
1797
|
// Use activeProviderInstance if available (respects provider abstraction)
|
|
1877
1798
|
// Fallback to cached standalone provider for pre-initialization discovery
|
|
1878
|
-
// TODO: When adding new providers
|
|
1799
|
+
// TODO: When adding new providers, consider a provider factory pattern
|
|
1879
1800
|
const provider = this.activeProviderInstance ?? __classPrivateFieldGet(this, _PerpsController_instances, "m", _PerpsController_getOrCreateStandaloneProvider).call(this);
|
|
1880
1801
|
const operation = provider.getPositions(params);
|
|
1881
1802
|
return provider === __classPrivateFieldGet(this, _PerpsController_standaloneProvider, "f")
|
|
@@ -3860,36 +3781,7 @@ export class PerpsController extends BaseController {
|
|
|
3860
3781
|
return __classPrivateFieldGet(this, _PerpsController_isReinitializing, "f");
|
|
3861
3782
|
}
|
|
3862
3783
|
}
|
|
3863
|
-
_a = PerpsController, _PerpsController_initializationPromise = new WeakMap(), _PerpsController_isReinitializing = new WeakMap(), _PerpsController_reinitializationOperationPromise = new WeakMap(), _PerpsController_disconnectOperationPromise = new WeakMap(),
|
|
3864
|
-
const myx = __classPrivateFieldGet(this, _PerpsController_options, "f").clientConfig?.providerCredentials?.myx;
|
|
3865
|
-
// Local env-var override (MM_PERPS_MYX_PROVIDER_ENABLED) always wins —
|
|
3866
|
-
// matches the UI selector (resolvePerpsMyxProviderEnabled) so controller
|
|
3867
|
-
// and UI agree on whether MYX is available.
|
|
3868
|
-
if (myx?.enabled) {
|
|
3869
|
-
return true;
|
|
3870
|
-
}
|
|
3871
|
-
// Credentials present → MYX is enabled regardless of remote flag.
|
|
3872
|
-
// Use || so empty-string env vars (default '') fall through.
|
|
3873
|
-
const hasCredentials = Boolean(
|
|
3874
|
-
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
|
|
3875
|
-
myx?.appIdTestnet || myx?.appIdMainnet);
|
|
3876
|
-
if (hasCredentials) {
|
|
3877
|
-
return true;
|
|
3878
|
-
}
|
|
3879
|
-
// No local override or credentials — check remote flag as fallback
|
|
3880
|
-
try {
|
|
3881
|
-
const remoteState = this.messenger.call('RemoteFeatureFlagController:getState');
|
|
3882
|
-
const remoteFlag = remoteState.remoteFeatureFlags?.perpsMyxProviderEnabled;
|
|
3883
|
-
if (isVersionGatedFeatureFlag(remoteFlag)) {
|
|
3884
|
-
const validated = __classPrivateFieldGet(this, _PerpsController_options, "f").infrastructure.featureFlags.validateVersionGated(remoteFlag);
|
|
3885
|
-
return validated ?? false;
|
|
3886
|
-
}
|
|
3887
|
-
return false;
|
|
3888
|
-
}
|
|
3889
|
-
catch {
|
|
3890
|
-
return false;
|
|
3891
|
-
}
|
|
3892
|
-
}, _PerpsController_isLighterProviderEnabled = function _PerpsController_isLighterProviderEnabled() {
|
|
3784
|
+
_a = PerpsController, _PerpsController_initializationPromise = new WeakMap(), _PerpsController_isReinitializing = new WeakMap(), _PerpsController_reinitializationOperationPromise = new WeakMap(), _PerpsController_disconnectOperationPromise = new WeakMap(), _PerpsController_lighterRegistrationPromise = new WeakMap(), _PerpsController_blockedRegionListVersion = new WeakMap(), _PerpsController_hip3Enabled = new WeakMap(), _PerpsController_hip3AllowlistMarkets = new WeakMap(), _PerpsController_hip3BlocklistMarkets = new WeakMap(), _PerpsController_hip3ConfigSource = new WeakMap(), _PerpsController_priceDeviationLimit = new WeakMap(), _PerpsController_attributionContext = new WeakMap(), _PerpsController_standaloneProvider = new WeakMap(), _PerpsController_handlersRegistered = new WeakMap(), _PerpsController_standaloneProviderIsTestnet = new WeakMap(), _PerpsController_standaloneProviderHip3Version = new WeakMap(), _PerpsController_standaloneProviderOperations = new WeakMap(), _PerpsController_eligibilityCheckDeferred = new WeakMap(), _PerpsController_ausQueue = new WeakMap(), _PerpsController_userDiskWrite = 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_publishChaseOrderMaxDistanceReached = new WeakMap(), _PerpsController_preloadTimer = new WeakMap(), _PerpsController_preloadStartRequested = new WeakMap(), _PerpsController_isPreloading = new WeakMap(), _PerpsController_marketPreloadQueued = new WeakMap(), _PerpsController_isPreloadingUserData = new WeakMap(), _PerpsController_userPreloadQueued = new WeakMap(), _PerpsController_lifecycleGeneration = new WeakMap(), _PerpsController_userSnapshotRequests = new WeakMap(), _PerpsController_preloadStateUnsubscribe = new WeakMap(), _PerpsController_accountChangeUnsubscribe = new WeakMap(), _PerpsController_previousIsTestnet = new WeakMap(), _PerpsController_previousHip3ConfigVersion = new WeakMap(), _PerpsController_instances = new WeakSet(), _PerpsController_isLighterProviderEnabled = function _PerpsController_isLighterProviderEnabled() {
|
|
3893
3785
|
const lighter = __classPrivateFieldGet(this, _PerpsController_options, "f").clientConfig?.providerCredentials?.lighter;
|
|
3894
3786
|
if (lighter?.enabled) {
|
|
3895
3787
|
return true;
|
|
@@ -3927,7 +3819,6 @@ _a = PerpsController, _PerpsController_initializationPromise = new WeakMap(), _P
|
|
|
3927
3819
|
continue;
|
|
3928
3820
|
}
|
|
3929
3821
|
if (providerId === 'hyperliquid' ||
|
|
3930
|
-
(providerId === 'myx' && __classPrivateFieldGet(this, _PerpsController_instances, "m", _PerpsController_isMYXProviderEnabled).call(this)) ||
|
|
3931
3822
|
(providerId === 'lighter' && __classPrivateFieldGet(this, _PerpsController_instances, "m", _PerpsController_isLighterProviderEnabled).call(this)) ||
|
|
3932
3823
|
this.providers.has(providerId)) {
|
|
3933
3824
|
providerIds.add(providerId);
|
|
@@ -4272,15 +4163,13 @@ async function _PerpsController_performInitialization() {
|
|
|
4272
4163
|
this.providers.clear();
|
|
4273
4164
|
await __classPrivateFieldGet(this, _PerpsController_instances, "m", _PerpsController_cleanupStandaloneProvider).call(this);
|
|
4274
4165
|
__classPrivateFieldGet(this, _PerpsController_instances, "m", _PerpsController_createProviders).call(this);
|
|
4275
|
-
// Await
|
|
4276
|
-
// map before we assign the active provider. Runs concurrently
|
|
4277
|
-
// the WebSocket readiness delay for zero additional latency.
|
|
4166
|
+
// Await the Lighter dynamic import (if started) so Lighter is in the
|
|
4167
|
+
// providers map before we assign the active provider. Runs concurrently
|
|
4168
|
+
// with the WebSocket readiness delay for zero additional latency.
|
|
4278
4169
|
await Promise.all([
|
|
4279
4170
|
wait(PERPS_CONSTANTS.ReconnectionCleanupDelayMs),
|
|
4280
|
-
__classPrivateFieldGet(this, _PerpsController_myxRegistrationPromise, "f"),
|
|
4281
4171
|
__classPrivateFieldGet(this, _PerpsController_lighterRegistrationPromise, "f"),
|
|
4282
4172
|
]);
|
|
4283
|
-
__classPrivateFieldSet(this, _PerpsController_myxRegistrationPromise, null, "f");
|
|
4284
4173
|
__classPrivateFieldSet(this, _PerpsController_lighterRegistrationPromise, null, "f");
|
|
4285
4174
|
__classPrivateFieldGet(this, _PerpsController_instances, "m", _PerpsController_assignActiveProvider).call(this);
|
|
4286
4175
|
this.isInitialized = true;
|
|
@@ -4362,32 +4251,12 @@ async function _PerpsController_performInitialization() {
|
|
|
4362
4251
|
onChaseOrderMaxDistanceReached: __classPrivateFieldGet(this, _PerpsController_publishChaseOrderMaxDistanceReached, "f"),
|
|
4363
4252
|
});
|
|
4364
4253
|
this.providers.set('hyperliquid', hyperLiquidProvider);
|
|
4365
|
-
// Register
|
|
4366
|
-
//
|
|
4367
|
-
//
|
|
4368
|
-
//
|
|
4369
|
-
//
|
|
4370
|
-
//
|
|
4371
|
-
// explicitly enabled and selected.
|
|
4372
|
-
const isMYXEnabled = __classPrivateFieldGet(this, _PerpsController_instances, "m", _PerpsController_isMYXProviderEnabled).call(this);
|
|
4373
|
-
if (isMYXEnabled) {
|
|
4374
|
-
// IMPORTANT: Must use import() — NOT require() — for core/extension tree-shaking.
|
|
4375
|
-
// require() is synchronous and bundlers include it in the main bundle.
|
|
4376
|
-
// import() enables true code splitting so MYX is excluded when not enabled.
|
|
4377
|
-
// NOTE: Keep the path in a variable so ts-bridge does not rewrite the
|
|
4378
|
-
// import argument and strip the webpackIgnore magic comment in core dist.
|
|
4379
|
-
const myxModulePath = './providers/MYXProvider';
|
|
4380
|
-
__classPrivateFieldSet(this, _PerpsController_myxRegistrationPromise, import(
|
|
4381
|
-
/* webpackIgnore: true */ myxModulePath)
|
|
4382
|
-
.then(({ MYXProvider }) => {
|
|
4383
|
-
this.registerMYXProvider(MYXProvider);
|
|
4384
|
-
return undefined;
|
|
4385
|
-
})
|
|
4386
|
-
.catch((error) => this.handleMYXImportError(error)), "f");
|
|
4387
|
-
}
|
|
4388
|
-
// Register Lighter provider if enabled (POC). Same dynamic-import pattern
|
|
4389
|
-
// as MYX so clients that do not ship the Lighter files skip registration
|
|
4390
|
-
// silently.
|
|
4254
|
+
// Register Lighter provider if enabled (POC). Dynamic import so clients
|
|
4255
|
+
// that do not ship the Lighter files skip registration silently, and so
|
|
4256
|
+
// bundlers can code-split it out when it is not enabled.
|
|
4257
|
+
// Uses .then()/.catch() instead of await because #createProviders is not
|
|
4258
|
+
// async; registration completing asynchronously is fine since the provider
|
|
4259
|
+
// is only used when explicitly enabled and selected.
|
|
4391
4260
|
const isLighterEnabled = __classPrivateFieldGet(this, _PerpsController_instances, "m", _PerpsController_isLighterProviderEnabled).call(this);
|
|
4392
4261
|
if (isLighterEnabled) {
|
|
4393
4262
|
// NOTE: Keep the path in a variable so ts-bridge does not rewrite the
|
|
@@ -4419,7 +4288,11 @@ async function _PerpsController_performInitialization() {
|
|
|
4419
4288
|
this.activeProviderInstance = hyperLiquidProvider;
|
|
4420
4289
|
__classPrivateFieldGet(this, _PerpsController_instances, "m", _PerpsController_debugLog).call(this, `PerpsController: Using direct provider (${activeProvider})`);
|
|
4421
4290
|
}
|
|
4422
|
-
else
|
|
4291
|
+
else {
|
|
4292
|
+
// Any other direct provider, including a value persisted by an older
|
|
4293
|
+
// version whose venue has since been removed. `activeProvider` is
|
|
4294
|
+
// persisted, so throwing here would fail initialization on every
|
|
4295
|
+
// launch — the stale value must self-heal.
|
|
4423
4296
|
const directProvider = this.providers.get(activeProvider);
|
|
4424
4297
|
if (directProvider) {
|
|
4425
4298
|
this.activeProviderInstance = directProvider;
|
|
@@ -4433,9 +4306,6 @@ async function _PerpsController_performInitialization() {
|
|
|
4433
4306
|
}
|
|
4434
4307
|
__classPrivateFieldGet(this, _PerpsController_instances, "m", _PerpsController_debugLog).call(this, `PerpsController: Using direct provider (${this.activeProviderInstance === hyperLiquidProvider ? 'hyperliquid' : activeProvider})`);
|
|
4435
4308
|
}
|
|
4436
|
-
else {
|
|
4437
|
-
throw new Error(`Unsupported provider: ${String(activeProvider)}. Currently only 'hyperliquid', 'myx', 'lighter', and 'aggregated' are supported.`);
|
|
4438
|
-
}
|
|
4439
4309
|
}, _PerpsController_getErrorContext = function _PerpsController_getErrorContext(method, extra) {
|
|
4440
4310
|
return {
|
|
4441
4311
|
tags: {
|
|
@@ -5157,7 +5027,6 @@ async function _PerpsController_persistWatchlistToRemote(network) {
|
|
|
5157
5027
|
const existingWatchlist = prefs.perps
|
|
5158
5028
|
.watchlistMarkets ?? {
|
|
5159
5029
|
hyperliquid: { testnet: [], mainnet: [] },
|
|
5160
|
-
myx: { testnet: [], mainnet: [] },
|
|
5161
5030
|
};
|
|
5162
5031
|
const nextWatchlistMarkets = {
|
|
5163
5032
|
...existingWatchlist,
|
|
@@ -5225,7 +5094,6 @@ async function _PerpsController_syncWatchlistFromRemote() {
|
|
|
5225
5094
|
const existingWatchlist = prefs.perps
|
|
5226
5095
|
.watchlistMarkets ?? {
|
|
5227
5096
|
hyperliquid: { testnet: [], mainnet: [] },
|
|
5228
|
-
myx: { testnet: [], mainnet: [] },
|
|
5229
5097
|
};
|
|
5230
5098
|
const nextWatchlistMarkets = {
|
|
5231
5099
|
...existingWatchlist,
|