@metamask-previews/perps-controller 0.0.0-preview-e4aa1532 → 0.0.0-preview-6dfa4aeba
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 +1 -11
- package/dist/PerpsController.cjs +66 -2224
- package/dist/PerpsController.cjs.map +1 -1
- package/dist/PerpsController.d.cts +79 -933
- package/dist/PerpsController.d.cts.map +1 -1
- package/dist/PerpsController.d.mts +79 -933
- package/dist/PerpsController.d.mts.map +1 -1
- package/dist/PerpsController.mjs +64 -2221
- package/dist/PerpsController.mjs.map +1 -1
- package/dist/index.cjs +1 -32
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -6
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +2 -6
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +1 -9
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -19
- package/dist/__mocks__/hyperliquidMock.cjs +0 -68
- package/dist/__mocks__/hyperliquidMock.cjs.map +0 -1
- package/dist/__mocks__/hyperliquidMock.d.cts +0 -15
- package/dist/__mocks__/hyperliquidMock.d.cts.map +0 -1
- package/dist/__mocks__/hyperliquidMock.d.mts +0 -15
- package/dist/__mocks__/hyperliquidMock.d.mts.map +0 -1
- package/dist/__mocks__/hyperliquidMock.mjs +0 -65
- package/dist/__mocks__/hyperliquidMock.mjs.map +0 -1
- package/dist/__mocks__/providerMocks.cjs +0 -144
- package/dist/__mocks__/providerMocks.cjs.map +0 -1
- package/dist/__mocks__/providerMocks.d.cts +0 -44
- package/dist/__mocks__/providerMocks.d.cts.map +0 -1
- package/dist/__mocks__/providerMocks.d.mts +0 -44
- package/dist/__mocks__/providerMocks.d.mts.map +0 -1
- package/dist/__mocks__/providerMocks.mjs +0 -136
- package/dist/__mocks__/providerMocks.mjs.map +0 -1
- package/dist/__mocks__/serviceMocks.cjs +0 -187
- package/dist/__mocks__/serviceMocks.cjs.map +0 -1
- package/dist/__mocks__/serviceMocks.d.cts +0 -58
- package/dist/__mocks__/serviceMocks.d.cts.map +0 -1
- package/dist/__mocks__/serviceMocks.d.mts +0 -58
- package/dist/__mocks__/serviceMocks.d.mts.map +0 -1
- package/dist/__mocks__/serviceMocks.mjs +0 -180
- package/dist/__mocks__/serviceMocks.mjs.map +0 -1
- package/dist/aggregation/SubscriptionMultiplexer.cjs +0 -459
- package/dist/aggregation/SubscriptionMultiplexer.cjs.map +0 -1
- package/dist/aggregation/SubscriptionMultiplexer.d.cts +0 -222
- package/dist/aggregation/SubscriptionMultiplexer.d.cts.map +0 -1
- package/dist/aggregation/SubscriptionMultiplexer.d.mts +0 -222
- package/dist/aggregation/SubscriptionMultiplexer.d.mts.map +0 -1
- package/dist/aggregation/SubscriptionMultiplexer.mjs +0 -455
- package/dist/aggregation/SubscriptionMultiplexer.mjs.map +0 -1
- package/dist/aggregation/index.cjs +0 -9
- package/dist/aggregation/index.cjs.map +0 -1
- package/dist/aggregation/index.d.cts +0 -6
- package/dist/aggregation/index.d.cts.map +0 -1
- package/dist/aggregation/index.d.mts +0 -6
- package/dist/aggregation/index.d.mts.map +0 -1
- package/dist/aggregation/index.mjs +0 -5
- package/dist/aggregation/index.mjs.map +0 -1
- package/dist/constants/eventNames.cjs +0 -117
- package/dist/constants/eventNames.cjs.map +0 -1
- package/dist/constants/eventNames.d.cts +0 -106
- package/dist/constants/eventNames.d.cts.map +0 -1
- package/dist/constants/eventNames.d.mts +0 -106
- package/dist/constants/eventNames.d.mts.map +0 -1
- package/dist/constants/eventNames.mjs +0 -114
- package/dist/constants/eventNames.mjs.map +0 -1
- package/dist/constants/hyperLiquidConfig.cjs +0 -366
- package/dist/constants/hyperLiquidConfig.cjs.map +0 -1
- package/dist/constants/hyperLiquidConfig.d.cts +0 -276
- package/dist/constants/hyperLiquidConfig.d.cts.map +0 -1
- package/dist/constants/hyperLiquidConfig.d.mts +0 -276
- package/dist/constants/hyperLiquidConfig.d.mts.map +0 -1
- package/dist/constants/hyperLiquidConfig.mjs +0 -357
- package/dist/constants/hyperLiquidConfig.mjs.map +0 -1
- package/dist/constants/index.cjs +0 -23
- package/dist/constants/index.cjs.map +0 -1
- package/dist/constants/index.d.cts +0 -7
- package/dist/constants/index.d.cts.map +0 -1
- package/dist/constants/index.d.mts +0 -7
- package/dist/constants/index.d.mts.map +0 -1
- package/dist/constants/index.mjs +0 -7
- package/dist/constants/index.mjs.map +0 -1
- package/dist/constants/orderTypes.cjs +0 -31
- package/dist/constants/orderTypes.cjs.map +0 -1
- package/dist/constants/orderTypes.d.cts +0 -19
- package/dist/constants/orderTypes.d.cts.map +0 -1
- package/dist/constants/orderTypes.d.mts +0 -19
- package/dist/constants/orderTypes.d.mts.map +0 -1
- package/dist/constants/orderTypes.mjs +0 -27
- package/dist/constants/orderTypes.mjs.map +0 -1
- package/dist/constants/performanceMetrics.cjs +0 -61
- package/dist/constants/performanceMetrics.cjs.map +0 -1
- package/dist/constants/performanceMetrics.d.cts +0 -44
- package/dist/constants/performanceMetrics.d.cts.map +0 -1
- package/dist/constants/performanceMetrics.d.mts +0 -44
- package/dist/constants/performanceMetrics.d.mts.map +0 -1
- package/dist/constants/performanceMetrics.mjs +0 -58
- package/dist/constants/performanceMetrics.mjs.map +0 -1
- package/dist/constants/perpsConfig.cjs +0 -461
- package/dist/constants/perpsConfig.cjs.map +0 -1
- package/dist/constants/perpsConfig.d.cts +0 -343
- package/dist/constants/perpsConfig.d.cts.map +0 -1
- package/dist/constants/perpsConfig.d.mts +0 -343
- package/dist/constants/perpsConfig.d.mts.map +0 -1
- package/dist/constants/perpsConfig.mjs +0 -458
- package/dist/constants/perpsConfig.mjs.map +0 -1
- package/dist/constants/perpsErrorCodes.cjs +0 -79
- package/dist/constants/perpsErrorCodes.cjs.map +0 -1
- package/dist/constants/perpsErrorCodes.d.cts +0 -64
- package/dist/constants/perpsErrorCodes.d.cts.map +0 -1
- package/dist/constants/perpsErrorCodes.d.mts +0 -64
- package/dist/constants/perpsErrorCodes.d.mts.map +0 -1
- package/dist/constants/perpsErrorCodes.mjs +0 -76
- package/dist/constants/perpsErrorCodes.mjs.map +0 -1
- package/dist/platform-services/HyperLiquidClientService.cjs +0 -857
- package/dist/platform-services/HyperLiquidClientService.cjs.map +0 -1
- package/dist/platform-services/HyperLiquidClientService.d.cts +0 -263
- package/dist/platform-services/HyperLiquidClientService.d.cts.map +0 -1
- package/dist/platform-services/HyperLiquidClientService.d.mts +0 -263
- package/dist/platform-services/HyperLiquidClientService.d.mts.map +0 -1
- package/dist/platform-services/HyperLiquidClientService.mjs +0 -853
- package/dist/platform-services/HyperLiquidClientService.mjs.map +0 -1
- package/dist/platform-services/HyperLiquidSubscriptionService.cjs +0 -2170
- package/dist/platform-services/HyperLiquidSubscriptionService.cjs.map +0 -1
- package/dist/platform-services/HyperLiquidSubscriptionService.d.cts +0 -424
- package/dist/platform-services/HyperLiquidSubscriptionService.d.cts.map +0 -1
- package/dist/platform-services/HyperLiquidSubscriptionService.d.mts +0 -424
- package/dist/platform-services/HyperLiquidSubscriptionService.d.mts.map +0 -1
- package/dist/platform-services/HyperLiquidSubscriptionService.mjs +0 -2166
- package/dist/platform-services/HyperLiquidSubscriptionService.mjs.map +0 -1
- package/dist/platform-services/HyperLiquidWalletService.cjs +0 -140
- package/dist/platform-services/HyperLiquidWalletService.cjs.map +0 -1
- package/dist/platform-services/HyperLiquidWalletService.d.cts +0 -78
- package/dist/platform-services/HyperLiquidWalletService.d.cts.map +0 -1
- package/dist/platform-services/HyperLiquidWalletService.d.mts +0 -78
- package/dist/platform-services/HyperLiquidWalletService.d.mts.map +0 -1
- package/dist/platform-services/HyperLiquidWalletService.mjs +0 -136
- package/dist/platform-services/HyperLiquidWalletService.mjs.map +0 -1
- package/dist/providers/AggregatedPerpsProvider.cjs +0 -777
- package/dist/providers/AggregatedPerpsProvider.cjs.map +0 -1
- package/dist/providers/AggregatedPerpsProvider.d.cts +0 -466
- package/dist/providers/AggregatedPerpsProvider.d.cts.map +0 -1
- package/dist/providers/AggregatedPerpsProvider.d.mts +0 -466
- package/dist/providers/AggregatedPerpsProvider.d.mts.map +0 -1
- package/dist/providers/AggregatedPerpsProvider.mjs +0 -773
- package/dist/providers/AggregatedPerpsProvider.mjs.map +0 -1
- package/dist/providers/HyperLiquidProvider.cjs +0 -5172
- package/dist/providers/HyperLiquidProvider.cjs.map +0 -1
- package/dist/providers/HyperLiquidProvider.d.cts +0 -881
- package/dist/providers/HyperLiquidProvider.d.cts.map +0 -1
- package/dist/providers/HyperLiquidProvider.d.mts +0 -881
- package/dist/providers/HyperLiquidProvider.d.mts.map +0 -1
- package/dist/providers/HyperLiquidProvider.mjs +0 -5168
- package/dist/providers/HyperLiquidProvider.mjs.map +0 -1
- package/dist/providers/index.cjs +0 -11
- package/dist/providers/index.cjs.map +0 -1
- package/dist/providers/index.d.cts +0 -6
- package/dist/providers/index.d.cts.map +0 -1
- package/dist/providers/index.d.mts +0 -6
- package/dist/providers/index.d.mts.map +0 -1
- package/dist/providers/index.mjs +0 -6
- package/dist/providers/index.mjs.map +0 -1
- package/dist/routing/ProviderRouter.cjs +0 -148
- package/dist/routing/ProviderRouter.cjs.map +0 -1
- package/dist/routing/ProviderRouter.d.cts +0 -124
- package/dist/routing/ProviderRouter.d.cts.map +0 -1
- package/dist/routing/ProviderRouter.d.mts +0 -124
- package/dist/routing/ProviderRouter.d.mts.map +0 -1
- package/dist/routing/ProviderRouter.mjs +0 -144
- package/dist/routing/ProviderRouter.mjs.map +0 -1
- package/dist/routing/index.cjs +0 -9
- package/dist/routing/index.cjs.map +0 -1
- package/dist/routing/index.d.cts +0 -6
- package/dist/routing/index.d.cts.map +0 -1
- package/dist/routing/index.d.mts +0 -6
- package/dist/routing/index.d.mts.map +0 -1
- package/dist/routing/index.mjs +0 -5
- package/dist/routing/index.mjs.map +0 -1
- package/dist/selectors.cjs +0 -161
- package/dist/selectors.cjs.map +0 -1
- package/dist/selectors.d.cts +0 -345
- package/dist/selectors.d.cts.map +0 -1
- package/dist/selectors.d.mts +0 -345
- package/dist/selectors.d.mts.map +0 -1
- package/dist/selectors.mjs +0 -153
- package/dist/selectors.mjs.map +0 -1
- package/dist/services/AccountService.cjs +0 -313
- package/dist/services/AccountService.cjs.map +0 -1
- package/dist/services/AccountService.d.cts +0 -53
- package/dist/services/AccountService.d.cts.map +0 -1
- package/dist/services/AccountService.d.mts +0 -53
- package/dist/services/AccountService.d.mts.map +0 -1
- package/dist/services/AccountService.mjs +0 -309
- package/dist/services/AccountService.mjs.map +0 -1
- package/dist/services/DataLakeService.cjs +0 -219
- package/dist/services/DataLakeService.cjs.map +0 -1
- package/dist/services/DataLakeService.d.cts +0 -49
- package/dist/services/DataLakeService.d.cts.map +0 -1
- package/dist/services/DataLakeService.d.mts +0 -49
- package/dist/services/DataLakeService.d.mts.map +0 -1
- package/dist/services/DataLakeService.mjs +0 -215
- package/dist/services/DataLakeService.mjs.map +0 -1
- package/dist/services/DepositService.cjs +0 -96
- package/dist/services/DepositService.cjs.map +0 -1
- package/dist/services/DepositService.d.cts +0 -37
- package/dist/services/DepositService.d.cts.map +0 -1
- package/dist/services/DepositService.d.mts +0 -37
- package/dist/services/DepositService.d.mts.map +0 -1
- package/dist/services/DepositService.mjs +0 -92
- package/dist/services/DepositService.mjs.map +0 -1
- package/dist/services/EligibilityService.cjs +0 -156
- package/dist/services/EligibilityService.cjs.map +0 -1
- package/dist/services/EligibilityService.d.cts +0 -48
- package/dist/services/EligibilityService.d.cts.map +0 -1
- package/dist/services/EligibilityService.d.mts +0 -48
- package/dist/services/EligibilityService.d.mts.map +0 -1
- package/dist/services/EligibilityService.mjs +0 -152
- package/dist/services/EligibilityService.mjs.map +0 -1
- package/dist/services/FeatureFlagConfigurationService.cjs +0 -258
- package/dist/services/FeatureFlagConfigurationService.cjs.map +0 -1
- package/dist/services/FeatureFlagConfigurationService.d.cts +0 -100
- package/dist/services/FeatureFlagConfigurationService.d.cts.map +0 -1
- package/dist/services/FeatureFlagConfigurationService.d.mts +0 -100
- package/dist/services/FeatureFlagConfigurationService.d.mts.map +0 -1
- package/dist/services/FeatureFlagConfigurationService.mjs +0 -254
- package/dist/services/FeatureFlagConfigurationService.mjs.map +0 -1
- package/dist/services/MarketDataService.cjs +0 -875
- package/dist/services/MarketDataService.cjs.map +0 -1
- package/dist/services/MarketDataService.d.cts +0 -289
- package/dist/services/MarketDataService.d.cts.map +0 -1
- package/dist/services/MarketDataService.d.mts +0 -289
- package/dist/services/MarketDataService.d.mts.map +0 -1
- package/dist/services/MarketDataService.mjs +0 -871
- package/dist/services/MarketDataService.mjs.map +0 -1
- package/dist/services/RewardsIntegrationService.cjs +0 -94
- package/dist/services/RewardsIntegrationService.cjs.map +0 -1
- package/dist/services/RewardsIntegrationService.d.cts +0 -30
- package/dist/services/RewardsIntegrationService.d.cts.map +0 -1
- package/dist/services/RewardsIntegrationService.d.mts +0 -30
- package/dist/services/RewardsIntegrationService.d.mts.map +0 -1
- package/dist/services/RewardsIntegrationService.mjs +0 -90
- package/dist/services/RewardsIntegrationService.mjs.map +0 -1
- package/dist/services/ServiceContext.cjs +0 -3
- package/dist/services/ServiceContext.cjs.map +0 -1
- package/dist/services/ServiceContext.d.cts +0 -110
- package/dist/services/ServiceContext.d.cts.map +0 -1
- package/dist/services/ServiceContext.d.mts +0 -110
- package/dist/services/ServiceContext.d.mts.map +0 -1
- package/dist/services/ServiceContext.mjs +0 -2
- package/dist/services/ServiceContext.mjs.map +0 -1
- package/dist/services/TradingService.cjs +0 -1481
- package/dist/services/TradingService.cjs.map +0 -1
- package/dist/services/TradingService.d.cts +0 -308
- package/dist/services/TradingService.d.cts.map +0 -1
- package/dist/services/TradingService.d.mts +0 -308
- package/dist/services/TradingService.d.mts.map +0 -1
- package/dist/services/TradingService.mjs +0 -1477
- package/dist/services/TradingService.mjs.map +0 -1
- package/dist/services/index.cjs +0 -26
- package/dist/services/index.cjs.map +0 -1
- package/dist/services/index.d.cts +0 -11
- package/dist/services/index.d.cts.map +0 -1
- package/dist/services/index.d.mts +0 -11
- package/dist/services/index.d.mts.map +0 -1
- package/dist/services/index.mjs +0 -10
- package/dist/services/index.mjs.map +0 -1
- package/dist/services/utils.cjs +0 -16
- package/dist/services/utils.cjs.map +0 -1
- package/dist/services/utils.d.cts +0 -8
- package/dist/services/utils.d.cts.map +0 -1
- package/dist/services/utils.d.mts +0 -8
- package/dist/services/utils.d.mts.map +0 -1
- package/dist/services/utils.mjs +0 -12
- package/dist/services/utils.mjs.map +0 -1
- package/dist/types/chart.cjs +0 -42
- package/dist/types/chart.cjs.map +0 -1
- package/dist/types/chart.d.cts +0 -62
- package/dist/types/chart.d.cts.map +0 -1
- package/dist/types/chart.d.mts +0 -62
- package/dist/types/chart.d.mts.map +0 -1
- package/dist/types/chart.mjs +0 -39
- package/dist/types/chart.mjs.map +0 -1
- package/dist/types/hyperliquid-types.cjs +0 -3
- package/dist/types/hyperliquid-types.cjs.map +0 -1
- package/dist/types/hyperliquid-types.d.cts +0 -52
- package/dist/types/hyperliquid-types.d.cts.map +0 -1
- package/dist/types/hyperliquid-types.d.mts +0 -52
- package/dist/types/hyperliquid-types.d.mts.map +0 -1
- package/dist/types/hyperliquid-types.mjs +0 -2
- package/dist/types/hyperliquid-types.mjs.map +0 -1
- package/dist/types/index.cjs +0 -96
- package/dist/types/index.cjs.map +0 -1
- package/dist/types/index.d.cts +0 -1153
- package/dist/types/index.d.cts.map +0 -1
- package/dist/types/index.d.mts +0 -1153
- package/dist/types/index.d.mts.map +0 -1
- package/dist/types/index.mjs +0 -79
- package/dist/types/index.mjs.map +0 -1
- package/dist/types/transactionTypes.cjs +0 -28
- package/dist/types/transactionTypes.cjs.map +0 -1
- package/dist/types/transactionTypes.d.cts +0 -64
- package/dist/types/transactionTypes.d.cts.map +0 -1
- package/dist/types/transactionTypes.d.mts +0 -64
- package/dist/types/transactionTypes.d.mts.map +0 -1
- package/dist/types/transactionTypes.mjs +0 -23
- package/dist/types/transactionTypes.mjs.map +0 -1
- package/dist/utils/accountUtils.cjs +0 -65
- package/dist/utils/accountUtils.cjs.map +0 -1
- package/dist/utils/accountUtils.d.cts +0 -26
- package/dist/utils/accountUtils.d.cts.map +0 -1
- package/dist/utils/accountUtils.d.mts +0 -26
- package/dist/utils/accountUtils.d.mts.map +0 -1
- package/dist/utils/accountUtils.mjs +0 -61
- package/dist/utils/accountUtils.mjs.map +0 -1
- package/dist/utils/amountConversion.cjs +0 -61
- package/dist/utils/amountConversion.cjs.map +0 -1
- package/dist/utils/amountConversion.d.cts +0 -16
- package/dist/utils/amountConversion.d.cts.map +0 -1
- package/dist/utils/amountConversion.d.mts +0 -16
- package/dist/utils/amountConversion.d.mts.map +0 -1
- package/dist/utils/amountConversion.mjs +0 -54
- package/dist/utils/amountConversion.mjs.map +0 -1
- package/dist/utils/chartUtils.cjs +0 -98
- package/dist/utils/chartUtils.cjs.map +0 -1
- package/dist/utils/chartUtils.d.cts +0 -14
- package/dist/utils/chartUtils.d.cts.map +0 -1
- package/dist/utils/chartUtils.d.mts +0 -14
- package/dist/utils/chartUtils.d.mts.map +0 -1
- package/dist/utils/chartUtils.mjs +0 -94
- package/dist/utils/chartUtils.mjs.map +0 -1
- package/dist/utils/errorUtils.cjs +0 -22
- package/dist/utils/errorUtils.cjs.map +0 -1
- package/dist/utils/errorUtils.d.cts +0 -13
- package/dist/utils/errorUtils.d.cts.map +0 -1
- package/dist/utils/errorUtils.d.mts +0 -13
- package/dist/utils/errorUtils.d.mts.map +0 -1
- package/dist/utils/errorUtils.mjs +0 -18
- package/dist/utils/errorUtils.mjs.map +0 -1
- package/dist/utils/formatUtils.cjs +0 -987
- package/dist/utils/formatUtils.cjs.map +0 -1
- package/dist/utils/formatUtils.d.cts +0 -387
- package/dist/utils/formatUtils.d.cts.map +0 -1
- package/dist/utils/formatUtils.d.mts +0 -387
- package/dist/utils/formatUtils.d.mts.map +0 -1
- package/dist/utils/formatUtils.mjs +0 -966
- package/dist/utils/formatUtils.mjs.map +0 -1
- package/dist/utils/hyperLiquidAdapter.cjs +0 -454
- package/dist/utils/hyperLiquidAdapter.cjs.map +0 -1
- package/dist/utils/hyperLiquidAdapter.d.cts +0 -158
- package/dist/utils/hyperLiquidAdapter.d.cts.map +0 -1
- package/dist/utils/hyperLiquidAdapter.d.mts +0 -158
- package/dist/utils/hyperLiquidAdapter.d.mts.map +0 -1
- package/dist/utils/hyperLiquidAdapter.mjs +0 -439
- package/dist/utils/hyperLiquidAdapter.mjs.map +0 -1
- package/dist/utils/hyperLiquidOrderBookProcessor.cjs +0 -89
- package/dist/utils/hyperLiquidOrderBookProcessor.cjs.map +0 -1
- package/dist/utils/hyperLiquidOrderBookProcessor.d.cts +0 -58
- package/dist/utils/hyperLiquidOrderBookProcessor.d.cts.map +0 -1
- package/dist/utils/hyperLiquidOrderBookProcessor.d.mts +0 -58
- package/dist/utils/hyperLiquidOrderBookProcessor.d.mts.map +0 -1
- package/dist/utils/hyperLiquidOrderBookProcessor.mjs +0 -84
- package/dist/utils/hyperLiquidOrderBookProcessor.mjs.map +0 -1
- package/dist/utils/hyperLiquidValidation.cjs +0 -426
- package/dist/utils/hyperLiquidValidation.cjs.map +0 -1
- package/dist/utils/hyperLiquidValidation.d.cts +0 -143
- package/dist/utils/hyperLiquidValidation.d.cts.map +0 -1
- package/dist/utils/hyperLiquidValidation.d.mts +0 -143
- package/dist/utils/hyperLiquidValidation.d.mts.map +0 -1
- package/dist/utils/hyperLiquidValidation.mjs +0 -413
- package/dist/utils/hyperLiquidValidation.mjs.map +0 -1
- package/dist/utils/idUtils.cjs +0 -50
- package/dist/utils/idUtils.cjs.map +0 -1
- package/dist/utils/idUtils.d.cts +0 -38
- package/dist/utils/idUtils.d.cts.map +0 -1
- package/dist/utils/idUtils.d.mts +0 -38
- package/dist/utils/idUtils.d.mts.map +0 -1
- package/dist/utils/idUtils.mjs +0 -42
- package/dist/utils/idUtils.mjs.map +0 -1
- package/dist/utils/marginUtils.cjs +0 -137
- package/dist/utils/marginUtils.cjs.map +0 -1
- package/dist/utils/marginUtils.d.cts +0 -64
- package/dist/utils/marginUtils.d.cts.map +0 -1
- package/dist/utils/marginUtils.d.mts +0 -64
- package/dist/utils/marginUtils.d.mts.map +0 -1
- package/dist/utils/marginUtils.mjs +0 -131
- package/dist/utils/marginUtils.mjs.map +0 -1
- package/dist/utils/marketDataTransform.cjs +0 -227
- package/dist/utils/marketDataTransform.cjs.map +0 -1
- package/dist/utils/marketDataTransform.d.cts +0 -45
- package/dist/utils/marketDataTransform.d.cts.map +0 -1
- package/dist/utils/marketDataTransform.d.mts +0 -45
- package/dist/utils/marketDataTransform.d.mts.map +0 -1
- package/dist/utils/marketDataTransform.mjs +0 -220
- package/dist/utils/marketDataTransform.mjs.map +0 -1
- package/dist/utils/marketUtils.cjs +0 -420
- package/dist/utils/marketUtils.cjs.map +0 -1
- package/dist/utils/marketUtils.d.cts +0 -227
- package/dist/utils/marketUtils.d.cts.map +0 -1
- package/dist/utils/marketUtils.d.mts +0 -227
- package/dist/utils/marketUtils.d.mts.map +0 -1
- package/dist/utils/marketUtils.mjs +0 -404
- package/dist/utils/marketUtils.mjs.map +0 -1
- package/dist/utils/orderBookGrouping.cjs +0 -151
- package/dist/utils/orderBookGrouping.cjs.map +0 -1
- package/dist/utils/orderBookGrouping.d.cts +0 -76
- package/dist/utils/orderBookGrouping.d.cts.map +0 -1
- package/dist/utils/orderBookGrouping.d.mts +0 -76
- package/dist/utils/orderBookGrouping.d.mts.map +0 -1
- package/dist/utils/orderBookGrouping.mjs +0 -143
- package/dist/utils/orderBookGrouping.mjs.map +0 -1
- package/dist/utils/orderCalculations.cjs +0 -283
- package/dist/utils/orderCalculations.cjs.map +0 -1
- package/dist/utils/orderCalculations.d.cts +0 -107
- package/dist/utils/orderCalculations.d.cts.map +0 -1
- package/dist/utils/orderCalculations.d.mts +0 -107
- package/dist/utils/orderCalculations.d.mts.map +0 -1
- package/dist/utils/orderCalculations.mjs +0 -274
- package/dist/utils/orderCalculations.mjs.map +0 -1
- package/dist/utils/orderUtils.cjs +0 -159
- package/dist/utils/orderUtils.cjs.map +0 -1
- package/dist/utils/orderUtils.d.cts +0 -66
- package/dist/utils/orderUtils.d.cts.map +0 -1
- package/dist/utils/orderUtils.d.mts +0 -66
- package/dist/utils/orderUtils.d.mts.map +0 -1
- package/dist/utils/orderUtils.mjs +0 -151
- package/dist/utils/orderUtils.mjs.map +0 -1
- package/dist/utils/pnlCalculations.cjs +0 -107
- package/dist/utils/pnlCalculations.cjs.map +0 -1
- package/dist/utils/pnlCalculations.d.cts +0 -79
- package/dist/utils/pnlCalculations.d.cts.map +0 -1
- package/dist/utils/pnlCalculations.d.mts +0 -79
- package/dist/utils/pnlCalculations.d.mts.map +0 -1
- package/dist/utils/pnlCalculations.mjs +0 -97
- package/dist/utils/pnlCalculations.mjs.map +0 -1
- package/dist/utils/positionCalculations.cjs +0 -176
- package/dist/utils/positionCalculations.cjs.map +0 -1
- package/dist/utils/positionCalculations.d.cts +0 -85
- package/dist/utils/positionCalculations.d.cts.map +0 -1
- package/dist/utils/positionCalculations.d.mts +0 -85
- package/dist/utils/positionCalculations.d.mts.map +0 -1
- package/dist/utils/positionCalculations.mjs +0 -165
- package/dist/utils/positionCalculations.mjs.map +0 -1
- package/dist/utils/sortMarkets.cjs +0 -88
- package/dist/utils/sortMarkets.cjs.map +0 -1
- package/dist/utils/sortMarkets.d.cts +0 -21
- package/dist/utils/sortMarkets.d.cts.map +0 -1
- package/dist/utils/sortMarkets.d.mts +0 -21
- package/dist/utils/sortMarkets.d.mts.map +0 -1
- package/dist/utils/sortMarkets.mjs +0 -84
- package/dist/utils/sortMarkets.mjs.map +0 -1
- package/dist/utils/standaloneInfoClient.cjs +0 -34
- package/dist/utils/standaloneInfoClient.cjs.map +0 -1
- package/dist/utils/standaloneInfoClient.d.cts +0 -31
- package/dist/utils/standaloneInfoClient.d.cts.map +0 -1
- package/dist/utils/standaloneInfoClient.d.mts +0 -31
- package/dist/utils/standaloneInfoClient.d.mts.map +0 -1
- package/dist/utils/standaloneInfoClient.mjs +0 -30
- package/dist/utils/standaloneInfoClient.mjs.map +0 -1
- package/dist/utils/stringParseUtils.cjs +0 -49
- package/dist/utils/stringParseUtils.cjs.map +0 -1
- package/dist/utils/stringParseUtils.d.cts +0 -35
- package/dist/utils/stringParseUtils.d.cts.map +0 -1
- package/dist/utils/stringParseUtils.d.mts +0 -35
- package/dist/utils/stringParseUtils.d.mts.map +0 -1
- package/dist/utils/stringParseUtils.mjs +0 -44
- package/dist/utils/stringParseUtils.mjs.map +0 -1
- package/dist/utils/time.cjs +0 -37
- package/dist/utils/time.cjs.map +0 -1
- package/dist/utils/time.d.cts +0 -17
- package/dist/utils/time.d.cts.map +0 -1
- package/dist/utils/time.d.mts +0 -17
- package/dist/utils/time.d.mts.map +0 -1
- package/dist/utils/time.mjs +0 -33
- package/dist/utils/time.mjs.map +0 -1
- package/dist/utils/tpslValidation.cjs +0 -505
- package/dist/utils/tpslValidation.cjs.map +0 -1
- package/dist/utils/tpslValidation.d.cts +0 -182
- package/dist/utils/tpslValidation.d.cts.map +0 -1
- package/dist/utils/tpslValidation.d.mts +0 -182
- package/dist/utils/tpslValidation.d.mts.map +0 -1
- package/dist/utils/tpslValidation.mjs +0 -482
- package/dist/utils/tpslValidation.mjs.map +0 -1
- package/dist/utils/transactionUtils.cjs +0 -36
- package/dist/utils/transactionUtils.cjs.map +0 -1
- package/dist/utils/transactionUtils.d.cts +0 -17
- package/dist/utils/transactionUtils.d.cts.map +0 -1
- package/dist/utils/transactionUtils.d.mts +0 -17
- package/dist/utils/transactionUtils.d.mts.map +0 -1
- package/dist/utils/transactionUtils.mjs +0 -32
- package/dist/utils/transactionUtils.mjs.map +0 -1
- package/dist/utils/wait.cjs +0 -12
- package/dist/utils/wait.cjs.map +0 -1
- package/dist/utils/wait.d.cts +0 -8
- package/dist/utils/wait.d.cts.map +0 -1
- package/dist/utils/wait.d.mts +0 -8
- package/dist/utils/wait.d.mts.map +0 -1
- package/dist/utils/wait.mjs +0 -8
- package/dist/utils/wait.mjs.map +0 -1
|
@@ -1,187 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Shared service mocks for Perps service tests
|
|
4
|
-
* Provides reusable mock implementations for ServiceContext and related types
|
|
5
|
-
*/
|
|
6
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.createMockEvmAccount = exports.createMockServiceContext = exports.createMockPerpsControllerState = exports.createMockInfrastructure = void 0;
|
|
8
|
-
/**
|
|
9
|
-
* Create a mock PerpsPlatformDependencies instance.
|
|
10
|
-
* Returns a type-safe mock with jest.Mock functions for all methods.
|
|
11
|
-
* Uses `as unknown as jest.Mocked<PerpsPlatformDependencies>` pattern
|
|
12
|
-
* to ensure compatibility with both the interface contract and Jest mock APIs.
|
|
13
|
-
*
|
|
14
|
-
* Architecture:
|
|
15
|
-
* - Observability: logger, debugLogger, metrics, performance, tracer (stateless utilities)
|
|
16
|
-
* - Platform: streamManager (mobile/extension specific capabilities)
|
|
17
|
-
* - Controllers: consolidated access to all external controllers
|
|
18
|
-
*
|
|
19
|
-
* @returns Mocked PerpsPlatformDependencies
|
|
20
|
-
*/
|
|
21
|
-
const createMockInfrastructure = () => ({
|
|
22
|
-
// === Observability (stateless utilities) ===
|
|
23
|
-
logger: {
|
|
24
|
-
error: jest.fn(),
|
|
25
|
-
},
|
|
26
|
-
debugLogger: {
|
|
27
|
-
log: jest.fn(),
|
|
28
|
-
},
|
|
29
|
-
metrics: {
|
|
30
|
-
trackEvent: jest.fn(),
|
|
31
|
-
isEnabled: jest.fn(() => true),
|
|
32
|
-
trackPerpsEvent: jest.fn(),
|
|
33
|
-
},
|
|
34
|
-
performance: {
|
|
35
|
-
now: jest.fn(() => Date.now()),
|
|
36
|
-
},
|
|
37
|
-
tracer: {
|
|
38
|
-
trace: jest.fn(() => undefined),
|
|
39
|
-
endTrace: jest.fn(),
|
|
40
|
-
setMeasurement: jest.fn(),
|
|
41
|
-
},
|
|
42
|
-
// === Platform Services ===
|
|
43
|
-
streamManager: {
|
|
44
|
-
pauseChannel: jest.fn(),
|
|
45
|
-
resumeChannel: jest.fn(),
|
|
46
|
-
clearAllChannels: jest.fn(),
|
|
47
|
-
},
|
|
48
|
-
// === Controller Access (ALL controllers consolidated) ===
|
|
49
|
-
controllers: {
|
|
50
|
-
// Account operations (wraps AccountsController)
|
|
51
|
-
accounts: {
|
|
52
|
-
getSelectedEvmAccount: jest.fn(() => ({
|
|
53
|
-
address: '0x1234567890abcdef1234567890abcdef12345678',
|
|
54
|
-
})),
|
|
55
|
-
formatAccountToCaipId: jest.fn((address, chainId) => `eip155:${chainId}:${address}`),
|
|
56
|
-
},
|
|
57
|
-
// Keyring operations (wraps KeyringController)
|
|
58
|
-
keyring: {
|
|
59
|
-
signTypedMessage: jest.fn().mockResolvedValue('0xSignatureResult'),
|
|
60
|
-
},
|
|
61
|
-
// Network operations (wraps NetworkController)
|
|
62
|
-
network: {
|
|
63
|
-
getChainIdForNetwork: jest.fn().mockReturnValue('0x1'),
|
|
64
|
-
findNetworkClientIdForChain: jest.fn().mockReturnValue('mainnet'),
|
|
65
|
-
getSelectedNetworkClientId: jest.fn().mockReturnValue('mainnet'),
|
|
66
|
-
},
|
|
67
|
-
// Transaction operations (wraps TransactionController)
|
|
68
|
-
transaction: {
|
|
69
|
-
submit: jest.fn().mockResolvedValue({
|
|
70
|
-
result: Promise.resolve('0xTransactionHash'),
|
|
71
|
-
transactionMeta: { id: 'tx-id-123', hash: '0xTransactionHash' },
|
|
72
|
-
}),
|
|
73
|
-
},
|
|
74
|
-
// Rewards operations (wraps RewardsController, optional)
|
|
75
|
-
rewards: {
|
|
76
|
-
getFeeDiscount: jest.fn().mockResolvedValue(0),
|
|
77
|
-
},
|
|
78
|
-
// Authentication operations (wraps AuthenticationController)
|
|
79
|
-
authentication: {
|
|
80
|
-
getBearerToken: jest.fn().mockResolvedValue('mock-bearer-token'),
|
|
81
|
-
},
|
|
82
|
-
},
|
|
83
|
-
});
|
|
84
|
-
exports.createMockInfrastructure = createMockInfrastructure;
|
|
85
|
-
/**
|
|
86
|
-
* Create a mock PerpsControllerState.
|
|
87
|
-
*
|
|
88
|
-
* @param overrides - Optional overrides for the mock state
|
|
89
|
-
* @returns Mock PerpsControllerState
|
|
90
|
-
*/
|
|
91
|
-
function createMockPerpsControllerState(overrides = {}) {
|
|
92
|
-
return {
|
|
93
|
-
activeProvider: 'hyperliquid',
|
|
94
|
-
isTestnet: false,
|
|
95
|
-
initializationState: 'initialized',
|
|
96
|
-
initializationError: null,
|
|
97
|
-
initializationAttempts: 0,
|
|
98
|
-
accountState: null,
|
|
99
|
-
perpsBalances: {},
|
|
100
|
-
depositInProgress: false,
|
|
101
|
-
lastDepositTransactionId: null,
|
|
102
|
-
lastDepositResult: null,
|
|
103
|
-
withdrawInProgress: false,
|
|
104
|
-
lastWithdrawResult: null,
|
|
105
|
-
withdrawalRequests: [],
|
|
106
|
-
withdrawalProgress: {
|
|
107
|
-
progress: 0,
|
|
108
|
-
lastUpdated: 0,
|
|
109
|
-
activeWithdrawalId: null,
|
|
110
|
-
},
|
|
111
|
-
depositRequests: [],
|
|
112
|
-
isEligible: true,
|
|
113
|
-
isFirstTimeUser: {
|
|
114
|
-
testnet: true,
|
|
115
|
-
mainnet: true,
|
|
116
|
-
},
|
|
117
|
-
hasPlacedFirstOrder: {
|
|
118
|
-
testnet: false,
|
|
119
|
-
mainnet: false,
|
|
120
|
-
},
|
|
121
|
-
watchlistMarkets: {
|
|
122
|
-
testnet: [],
|
|
123
|
-
mainnet: [],
|
|
124
|
-
},
|
|
125
|
-
tradeConfigurations: {
|
|
126
|
-
testnet: {},
|
|
127
|
-
mainnet: {},
|
|
128
|
-
},
|
|
129
|
-
marketFilterPreferences: {
|
|
130
|
-
optionId: 'volume',
|
|
131
|
-
direction: 'desc',
|
|
132
|
-
},
|
|
133
|
-
lastError: null,
|
|
134
|
-
lastUpdateTimestamp: Date.now(),
|
|
135
|
-
hip3ConfigVersion: 0,
|
|
136
|
-
...overrides,
|
|
137
|
-
};
|
|
138
|
-
}
|
|
139
|
-
exports.createMockPerpsControllerState = createMockPerpsControllerState;
|
|
140
|
-
/**
|
|
141
|
-
* Create a mock ServiceContext with optional overrides
|
|
142
|
-
* Note: infrastructure is no longer part of ServiceContext - it's now injected
|
|
143
|
-
* into service instances via constructor.
|
|
144
|
-
*
|
|
145
|
-
* @param overrides - Optional overrides for the mock context
|
|
146
|
-
* @returns Mock ServiceContext
|
|
147
|
-
*/
|
|
148
|
-
function createMockServiceContext(overrides = {}) {
|
|
149
|
-
return {
|
|
150
|
-
tracingContext: {
|
|
151
|
-
provider: 'hyperliquid',
|
|
152
|
-
isTestnet: false,
|
|
153
|
-
},
|
|
154
|
-
errorContext: {
|
|
155
|
-
controller: 'TestService',
|
|
156
|
-
method: 'testMethod',
|
|
157
|
-
},
|
|
158
|
-
stateManager: {
|
|
159
|
-
update: jest.fn(),
|
|
160
|
-
getState: jest.fn(() => createMockPerpsControllerState()),
|
|
161
|
-
},
|
|
162
|
-
...overrides,
|
|
163
|
-
};
|
|
164
|
-
}
|
|
165
|
-
exports.createMockServiceContext = createMockServiceContext;
|
|
166
|
-
/**
|
|
167
|
-
* Create a mock EVM account (KeyringAccount).
|
|
168
|
-
*
|
|
169
|
-
* @returns Mock EVM account
|
|
170
|
-
*/
|
|
171
|
-
function createMockEvmAccount() {
|
|
172
|
-
return {
|
|
173
|
-
id: '00000000-0000-0000-0000-000000000000',
|
|
174
|
-
address: '0x1234567890abcdef1234567890abcdef12345678',
|
|
175
|
-
type: 'eip155:eoa',
|
|
176
|
-
options: {},
|
|
177
|
-
scopes: ['eip155:1'],
|
|
178
|
-
methods: ['eth_signTransaction', 'eth_sign'],
|
|
179
|
-
metadata: {
|
|
180
|
-
name: 'Test Account',
|
|
181
|
-
importTime: Date.now(),
|
|
182
|
-
keyring: { type: 'HD Key Tree' },
|
|
183
|
-
},
|
|
184
|
-
};
|
|
185
|
-
}
|
|
186
|
-
exports.createMockEvmAccount = createMockEvmAccount;
|
|
187
|
-
//# sourceMappingURL=serviceMocks.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"serviceMocks.cjs","sourceRoot":"","sources":["../../src/__mocks__/serviceMocks.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AASH;;;;;;;;;;;;GAYG;AACI,MAAM,wBAAwB,GACnC,GAA2C,EAAE,CAC3C,CAAC;IACC,8CAA8C;IAC9C,MAAM,EAAE;QACN,KAAK,EAAE,IAAI,CAAC,EAAE,EAAE;KACjB;IACD,WAAW,EAAE;QACX,GAAG,EAAE,IAAI,CAAC,EAAE,EAAE;KACf;IACD,OAAO,EAAE;QACP,UAAU,EAAE,IAAI,CAAC,EAAE,EAAE;QACrB,SAAS,EAAE,IAAI,CAAC,EAAE,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC;QAC9B,eAAe,EAAE,IAAI,CAAC,EAAE,EAAE;KAC3B;IACD,WAAW,EAAE;QACX,GAAG,EAAE,IAAI,CAAC,EAAE,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC;KAC/B;IACD,MAAM,EAAE;QACN,KAAK,EAAE,IAAI,CAAC,EAAE,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC;QAC/B,QAAQ,EAAE,IAAI,CAAC,EAAE,EAAE;QACnB,cAAc,EAAE,IAAI,CAAC,EAAE,EAAE;KAC1B;IAED,4BAA4B;IAC5B,aAAa,EAAE;QACb,YAAY,EAAE,IAAI,CAAC,EAAE,EAAE;QACvB,aAAa,EAAE,IAAI,CAAC,EAAE,EAAE;QACxB,gBAAgB,EAAE,IAAI,CAAC,EAAE,EAAE;KAC5B;IAED,2DAA2D;IAC3D,WAAW,EAAE;QACX,gDAAgD;QAChD,QAAQ,EAAE;YACR,qBAAqB,EAAE,IAAI,CAAC,EAAE,CAAC,GAAG,EAAE,CAAC,CAAC;gBACpC,OAAO,EAAE,4CAA4C;aACtD,CAAC,CAAC;YACH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SAAS;KACb,CAAC;AACJ,CAAC;AAlBD,4DAkBC;AAED;;;;GAIG;AACH,SAAgB,oBAAoB;IAalC,OAAO;QACL,EAAE,EAAE,sCAAsC;QAC1C,OAAO,EAAE,4CAA6D;QACtE,IAAI,EAAE,YAAqB;QAC3B,OAAO,EAAE,EAAE;QACX,MAAM,EAAE,CAAC,UAAU,CAAC;QACpB,OAAO,EAAE,CAAC,qBAAqB,EAAE,UAAU,CAAC;QAC5C,QAAQ,EAAE;YACR,IAAI,EAAE,cAAc;YACpB,UAAU,EAAE,IAAI,CAAC,GAAG,EAAE;YACtB,OAAO,EAAE,EAAE,IAAI,EAAE,aAAa,EAAE;SACjC;KACF,CAAC;AACJ,CAAC;AA1BD,oDA0BC","sourcesContent":["/**\n * Shared service mocks for Perps service tests\n * Provides reusable mock implementations for ServiceContext and related types\n */\n\nimport type {\n PerpsControllerState,\n InitializationState,\n} from '../PerpsController';\nimport type { ServiceContext } from '../services/ServiceContext';\nimport type { PerpsPlatformDependencies } from '../types';\n\n/**\n * Create a mock PerpsPlatformDependencies instance.\n * Returns a type-safe mock with jest.Mock functions for all methods.\n * Uses `as unknown as jest.Mocked<PerpsPlatformDependencies>` pattern\n * to ensure compatibility with both the interface contract and Jest mock APIs.\n *\n * Architecture:\n * - Observability: logger, debugLogger, metrics, performance, tracer (stateless utilities)\n * - Platform: streamManager (mobile/extension specific capabilities)\n * - Controllers: consolidated access to all external controllers\n *\n * @returns Mocked PerpsPlatformDependencies\n */\nexport const createMockInfrastructure =\n (): jest.Mocked<PerpsPlatformDependencies> =>\n ({\n // === Observability (stateless utilities) ===\n logger: {\n error: jest.fn(),\n },\n debugLogger: {\n log: jest.fn(),\n },\n metrics: {\n trackEvent: jest.fn(),\n isEnabled: jest.fn(() => true),\n trackPerpsEvent: jest.fn(),\n },\n performance: {\n now: jest.fn(() => Date.now()),\n },\n tracer: {\n trace: jest.fn(() => undefined),\n endTrace: jest.fn(),\n setMeasurement: jest.fn(),\n },\n\n // === Platform Services ===\n streamManager: {\n pauseChannel: jest.fn(),\n resumeChannel: jest.fn(),\n clearAllChannels: jest.fn(),\n },\n\n // === Controller Access (ALL controllers consolidated) ===\n controllers: {\n // Account operations (wraps AccountsController)\n accounts: {\n getSelectedEvmAccount: jest.fn(() => ({\n address: '0x1234567890abcdef1234567890abcdef12345678',\n })),\n formatAccountToCaipId: jest.fn(\n (address: string, chainId: string) =>\n `eip155:${chainId}:${address}`,\n ),\n },\n // Keyring operations (wraps KeyringController)\n keyring: {\n signTypedMessage: jest.fn().mockResolvedValue('0xSignatureResult'),\n },\n // Network operations (wraps NetworkController)\n network: {\n getChainIdForNetwork: jest.fn().mockReturnValue('0x1'),\n findNetworkClientIdForChain: jest.fn().mockReturnValue('mainnet'),\n getSelectedNetworkClientId: jest.fn().mockReturnValue('mainnet'),\n },\n // Transaction operations (wraps TransactionController)\n transaction: {\n submit: jest.fn().mockResolvedValue({\n result: Promise.resolve('0xTransactionHash'),\n transactionMeta: { id: 'tx-id-123', hash: '0xTransactionHash' },\n }),\n },\n // Rewards operations (wraps RewardsController, optional)\n rewards: {\n getFeeDiscount: jest.fn().mockResolvedValue(0),\n },\n // Authentication operations (wraps AuthenticationController)\n authentication: {\n getBearerToken: jest.fn().mockResolvedValue('mock-bearer-token'),\n },\n },\n }) as unknown as jest.Mocked<PerpsPlatformDependencies>;\n\n/**\n * Create a mock PerpsControllerState.\n *\n * @param overrides - Optional overrides for the mock state\n * @returns Mock PerpsControllerState\n */\nexport function createMockPerpsControllerState(\n overrides: Partial<PerpsControllerState> = {},\n): PerpsControllerState {\n return {\n activeProvider: 'hyperliquid',\n isTestnet: false,\n initializationState: 'initialized' as InitializationState,\n initializationError: null,\n initializationAttempts: 0,\n accountState: null,\n perpsBalances: {},\n depositInProgress: false,\n lastDepositTransactionId: null,\n lastDepositResult: null,\n withdrawInProgress: false,\n lastWithdrawResult: null,\n withdrawalRequests: [],\n withdrawalProgress: {\n progress: 0,\n lastUpdated: 0,\n activeWithdrawalId: null,\n },\n depositRequests: [],\n isEligible: true,\n isFirstTimeUser: {\n testnet: true,\n mainnet: true,\n },\n hasPlacedFirstOrder: {\n testnet: false,\n mainnet: false,\n },\n watchlistMarkets: {\n testnet: [],\n mainnet: [],\n },\n tradeConfigurations: {\n testnet: {},\n mainnet: {},\n },\n marketFilterPreferences: {\n optionId: 'volume',\n direction: 'desc',\n },\n lastError: null,\n lastUpdateTimestamp: Date.now(),\n hip3ConfigVersion: 0,\n ...overrides,\n };\n}\n\n/**\n * Create a mock ServiceContext with optional overrides\n * Note: infrastructure is no longer part of ServiceContext - it's now injected\n * into service instances via constructor.\n *\n * @param overrides - Optional overrides for the mock context\n * @returns Mock ServiceContext\n */\nexport function createMockServiceContext(\n overrides: Partial<ServiceContext> = {},\n): ServiceContext {\n return {\n tracingContext: {\n provider: 'hyperliquid',\n isTestnet: false,\n },\n errorContext: {\n controller: 'TestService',\n method: 'testMethod',\n },\n stateManager: {\n update: jest.fn(),\n getState: jest.fn(() => createMockPerpsControllerState()),\n },\n ...overrides,\n };\n}\n\n/**\n * Create a mock EVM account (KeyringAccount).\n *\n * @returns Mock EVM account\n */\nexport function createMockEvmAccount(): {\n id: string;\n address: `0x${string}`;\n type: 'eip155:eoa';\n options: Record<string, never>;\n scopes: string[];\n methods: string[];\n metadata: {\n name: string;\n importTime: number;\n keyring: { type: string };\n };\n} {\n return {\n id: '00000000-0000-0000-0000-000000000000',\n address: '0x1234567890abcdef1234567890abcdef12345678' as `0x${string}`,\n type: 'eip155:eoa' as const,\n options: {},\n scopes: ['eip155:1'],\n methods: ['eth_signTransaction', 'eth_sign'],\n metadata: {\n name: 'Test Account',\n importTime: Date.now(),\n keyring: { type: 'HD Key Tree' },\n },\n };\n}\n"]}
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Shared service mocks for Perps service tests
|
|
3
|
-
* Provides reusable mock implementations for ServiceContext and related types
|
|
4
|
-
*/
|
|
5
|
-
import type { PerpsControllerState } from "../PerpsController.cjs";
|
|
6
|
-
import type { ServiceContext } from "../services/ServiceContext.cjs";
|
|
7
|
-
import type { PerpsPlatformDependencies } from "../types/index.cjs";
|
|
8
|
-
/**
|
|
9
|
-
* Create a mock PerpsPlatformDependencies instance.
|
|
10
|
-
* Returns a type-safe mock with jest.Mock functions for all methods.
|
|
11
|
-
* Uses `as unknown as jest.Mocked<PerpsPlatformDependencies>` pattern
|
|
12
|
-
* to ensure compatibility with both the interface contract and Jest mock APIs.
|
|
13
|
-
*
|
|
14
|
-
* Architecture:
|
|
15
|
-
* - Observability: logger, debugLogger, metrics, performance, tracer (stateless utilities)
|
|
16
|
-
* - Platform: streamManager (mobile/extension specific capabilities)
|
|
17
|
-
* - Controllers: consolidated access to all external controllers
|
|
18
|
-
*
|
|
19
|
-
* @returns Mocked PerpsPlatformDependencies
|
|
20
|
-
*/
|
|
21
|
-
export declare const createMockInfrastructure: () => jest.Mocked<PerpsPlatformDependencies>;
|
|
22
|
-
/**
|
|
23
|
-
* Create a mock PerpsControllerState.
|
|
24
|
-
*
|
|
25
|
-
* @param overrides - Optional overrides for the mock state
|
|
26
|
-
* @returns Mock PerpsControllerState
|
|
27
|
-
*/
|
|
28
|
-
export declare function createMockPerpsControllerState(overrides?: Partial<PerpsControllerState>): PerpsControllerState;
|
|
29
|
-
/**
|
|
30
|
-
* Create a mock ServiceContext with optional overrides
|
|
31
|
-
* Note: infrastructure is no longer part of ServiceContext - it's now injected
|
|
32
|
-
* into service instances via constructor.
|
|
33
|
-
*
|
|
34
|
-
* @param overrides - Optional overrides for the mock context
|
|
35
|
-
* @returns Mock ServiceContext
|
|
36
|
-
*/
|
|
37
|
-
export declare function createMockServiceContext(overrides?: Partial<ServiceContext>): ServiceContext;
|
|
38
|
-
/**
|
|
39
|
-
* Create a mock EVM account (KeyringAccount).
|
|
40
|
-
*
|
|
41
|
-
* @returns Mock EVM account
|
|
42
|
-
*/
|
|
43
|
-
export declare function createMockEvmAccount(): {
|
|
44
|
-
id: string;
|
|
45
|
-
address: `0x${string}`;
|
|
46
|
-
type: 'eip155:eoa';
|
|
47
|
-
options: Record<string, never>;
|
|
48
|
-
scopes: string[];
|
|
49
|
-
methods: string[];
|
|
50
|
-
metadata: {
|
|
51
|
-
name: string;
|
|
52
|
-
importTime: number;
|
|
53
|
-
keyring: {
|
|
54
|
-
type: string;
|
|
55
|
-
};
|
|
56
|
-
};
|
|
57
|
-
};
|
|
58
|
-
//# sourceMappingURL=serviceMocks.d.cts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"serviceMocks.d.cts","sourceRoot":"","sources":["../../src/__mocks__/serviceMocks.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EACV,oBAAoB,EAErB,+BAA2B;AAC5B,OAAO,KAAK,EAAE,cAAc,EAAE,uCAAmC;AACjE,OAAO,KAAK,EAAE,yBAAyB,EAAE,2BAAiB;AAE1D;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,wBAAwB,QAC/B,KAAK,MAAM,CAAC,yBAAyB,CAoEgB,CAAC;AAE5D;;;;;GAKG;AACH,wBAAgB,8BAA8B,CAC5C,SAAS,GAAE,OAAO,CAAC,oBAAoB,CAAM,GAC5C,oBAAoB,CA+CtB;AAED;;;;;;;GAOG;AACH,wBAAgB,wBAAwB,CACtC,SAAS,GAAE,OAAO,CAAC,cAAc,CAAM,GACtC,cAAc,CAgBhB;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,IAAI;IACtC,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,EAAE,KAAK,MAAM,EAAE,CAAC;IACvB,IAAI,EAAE,YAAY,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;IAC/B,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,QAAQ,EAAE;QACR,IAAI,EAAE,MAAM,CAAC;QACb,UAAU,EAAE,MAAM,CAAC;QACnB,OAAO,EAAE;YAAE,IAAI,EAAE,MAAM,CAAA;SAAE,CAAC;KAC3B,CAAC;CACH,CAcA"}
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Shared service mocks for Perps service tests
|
|
3
|
-
* Provides reusable mock implementations for ServiceContext and related types
|
|
4
|
-
*/
|
|
5
|
-
import type { PerpsControllerState } from "../PerpsController.mjs";
|
|
6
|
-
import type { ServiceContext } from "../services/ServiceContext.mjs";
|
|
7
|
-
import type { PerpsPlatformDependencies } from "../types/index.mjs";
|
|
8
|
-
/**
|
|
9
|
-
* Create a mock PerpsPlatformDependencies instance.
|
|
10
|
-
* Returns a type-safe mock with jest.Mock functions for all methods.
|
|
11
|
-
* Uses `as unknown as jest.Mocked<PerpsPlatformDependencies>` pattern
|
|
12
|
-
* to ensure compatibility with both the interface contract and Jest mock APIs.
|
|
13
|
-
*
|
|
14
|
-
* Architecture:
|
|
15
|
-
* - Observability: logger, debugLogger, metrics, performance, tracer (stateless utilities)
|
|
16
|
-
* - Platform: streamManager (mobile/extension specific capabilities)
|
|
17
|
-
* - Controllers: consolidated access to all external controllers
|
|
18
|
-
*
|
|
19
|
-
* @returns Mocked PerpsPlatformDependencies
|
|
20
|
-
*/
|
|
21
|
-
export declare const createMockInfrastructure: () => jest.Mocked<PerpsPlatformDependencies>;
|
|
22
|
-
/**
|
|
23
|
-
* Create a mock PerpsControllerState.
|
|
24
|
-
*
|
|
25
|
-
* @param overrides - Optional overrides for the mock state
|
|
26
|
-
* @returns Mock PerpsControllerState
|
|
27
|
-
*/
|
|
28
|
-
export declare function createMockPerpsControllerState(overrides?: Partial<PerpsControllerState>): PerpsControllerState;
|
|
29
|
-
/**
|
|
30
|
-
* Create a mock ServiceContext with optional overrides
|
|
31
|
-
* Note: infrastructure is no longer part of ServiceContext - it's now injected
|
|
32
|
-
* into service instances via constructor.
|
|
33
|
-
*
|
|
34
|
-
* @param overrides - Optional overrides for the mock context
|
|
35
|
-
* @returns Mock ServiceContext
|
|
36
|
-
*/
|
|
37
|
-
export declare function createMockServiceContext(overrides?: Partial<ServiceContext>): ServiceContext;
|
|
38
|
-
/**
|
|
39
|
-
* Create a mock EVM account (KeyringAccount).
|
|
40
|
-
*
|
|
41
|
-
* @returns Mock EVM account
|
|
42
|
-
*/
|
|
43
|
-
export declare function createMockEvmAccount(): {
|
|
44
|
-
id: string;
|
|
45
|
-
address: `0x${string}`;
|
|
46
|
-
type: 'eip155:eoa';
|
|
47
|
-
options: Record<string, never>;
|
|
48
|
-
scopes: string[];
|
|
49
|
-
methods: string[];
|
|
50
|
-
metadata: {
|
|
51
|
-
name: string;
|
|
52
|
-
importTime: number;
|
|
53
|
-
keyring: {
|
|
54
|
-
type: string;
|
|
55
|
-
};
|
|
56
|
-
};
|
|
57
|
-
};
|
|
58
|
-
//# sourceMappingURL=serviceMocks.d.mts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"serviceMocks.d.mts","sourceRoot":"","sources":["../../src/__mocks__/serviceMocks.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EACV,oBAAoB,EAErB,+BAA2B;AAC5B,OAAO,KAAK,EAAE,cAAc,EAAE,uCAAmC;AACjE,OAAO,KAAK,EAAE,yBAAyB,EAAE,2BAAiB;AAE1D;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,wBAAwB,QAC/B,KAAK,MAAM,CAAC,yBAAyB,CAoEgB,CAAC;AAE5D;;;;;GAKG;AACH,wBAAgB,8BAA8B,CAC5C,SAAS,GAAE,OAAO,CAAC,oBAAoB,CAAM,GAC5C,oBAAoB,CA+CtB;AAED;;;;;;;GAOG;AACH,wBAAgB,wBAAwB,CACtC,SAAS,GAAE,OAAO,CAAC,cAAc,CAAM,GACtC,cAAc,CAgBhB;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,IAAI;IACtC,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,EAAE,KAAK,MAAM,EAAE,CAAC;IACvB,IAAI,EAAE,YAAY,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;IAC/B,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,QAAQ,EAAE;QACR,IAAI,EAAE,MAAM,CAAC;QACb,UAAU,EAAE,MAAM,CAAC;QACnB,OAAO,EAAE;YAAE,IAAI,EAAE,MAAM,CAAA;SAAE,CAAC;KAC3B,CAAC;CACH,CAcA"}
|
|
@@ -1,180 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Shared service mocks for Perps service tests
|
|
3
|
-
* Provides reusable mock implementations for ServiceContext and related types
|
|
4
|
-
*/
|
|
5
|
-
/**
|
|
6
|
-
* Create a mock PerpsPlatformDependencies instance.
|
|
7
|
-
* Returns a type-safe mock with jest.Mock functions for all methods.
|
|
8
|
-
* Uses `as unknown as jest.Mocked<PerpsPlatformDependencies>` pattern
|
|
9
|
-
* to ensure compatibility with both the interface contract and Jest mock APIs.
|
|
10
|
-
*
|
|
11
|
-
* Architecture:
|
|
12
|
-
* - Observability: logger, debugLogger, metrics, performance, tracer (stateless utilities)
|
|
13
|
-
* - Platform: streamManager (mobile/extension specific capabilities)
|
|
14
|
-
* - Controllers: consolidated access to all external controllers
|
|
15
|
-
*
|
|
16
|
-
* @returns Mocked PerpsPlatformDependencies
|
|
17
|
-
*/
|
|
18
|
-
export const createMockInfrastructure = () => ({
|
|
19
|
-
// === Observability (stateless utilities) ===
|
|
20
|
-
logger: {
|
|
21
|
-
error: jest.fn(),
|
|
22
|
-
},
|
|
23
|
-
debugLogger: {
|
|
24
|
-
log: jest.fn(),
|
|
25
|
-
},
|
|
26
|
-
metrics: {
|
|
27
|
-
trackEvent: jest.fn(),
|
|
28
|
-
isEnabled: jest.fn(() => true),
|
|
29
|
-
trackPerpsEvent: jest.fn(),
|
|
30
|
-
},
|
|
31
|
-
performance: {
|
|
32
|
-
now: jest.fn(() => Date.now()),
|
|
33
|
-
},
|
|
34
|
-
tracer: {
|
|
35
|
-
trace: jest.fn(() => undefined),
|
|
36
|
-
endTrace: jest.fn(),
|
|
37
|
-
setMeasurement: jest.fn(),
|
|
38
|
-
},
|
|
39
|
-
// === Platform Services ===
|
|
40
|
-
streamManager: {
|
|
41
|
-
pauseChannel: jest.fn(),
|
|
42
|
-
resumeChannel: jest.fn(),
|
|
43
|
-
clearAllChannels: jest.fn(),
|
|
44
|
-
},
|
|
45
|
-
// === Controller Access (ALL controllers consolidated) ===
|
|
46
|
-
controllers: {
|
|
47
|
-
// Account operations (wraps AccountsController)
|
|
48
|
-
accounts: {
|
|
49
|
-
getSelectedEvmAccount: jest.fn(() => ({
|
|
50
|
-
address: '0x1234567890abcdef1234567890abcdef12345678',
|
|
51
|
-
})),
|
|
52
|
-
formatAccountToCaipId: jest.fn((address, chainId) => `eip155:${chainId}:${address}`),
|
|
53
|
-
},
|
|
54
|
-
// Keyring operations (wraps KeyringController)
|
|
55
|
-
keyring: {
|
|
56
|
-
signTypedMessage: jest.fn().mockResolvedValue('0xSignatureResult'),
|
|
57
|
-
},
|
|
58
|
-
// Network operations (wraps NetworkController)
|
|
59
|
-
network: {
|
|
60
|
-
getChainIdForNetwork: jest.fn().mockReturnValue('0x1'),
|
|
61
|
-
findNetworkClientIdForChain: jest.fn().mockReturnValue('mainnet'),
|
|
62
|
-
getSelectedNetworkClientId: jest.fn().mockReturnValue('mainnet'),
|
|
63
|
-
},
|
|
64
|
-
// Transaction operations (wraps TransactionController)
|
|
65
|
-
transaction: {
|
|
66
|
-
submit: jest.fn().mockResolvedValue({
|
|
67
|
-
result: Promise.resolve('0xTransactionHash'),
|
|
68
|
-
transactionMeta: { id: 'tx-id-123', hash: '0xTransactionHash' },
|
|
69
|
-
}),
|
|
70
|
-
},
|
|
71
|
-
// Rewards operations (wraps RewardsController, optional)
|
|
72
|
-
rewards: {
|
|
73
|
-
getFeeDiscount: jest.fn().mockResolvedValue(0),
|
|
74
|
-
},
|
|
75
|
-
// Authentication operations (wraps AuthenticationController)
|
|
76
|
-
authentication: {
|
|
77
|
-
getBearerToken: jest.fn().mockResolvedValue('mock-bearer-token'),
|
|
78
|
-
},
|
|
79
|
-
},
|
|
80
|
-
});
|
|
81
|
-
/**
|
|
82
|
-
* Create a mock PerpsControllerState.
|
|
83
|
-
*
|
|
84
|
-
* @param overrides - Optional overrides for the mock state
|
|
85
|
-
* @returns Mock PerpsControllerState
|
|
86
|
-
*/
|
|
87
|
-
export function createMockPerpsControllerState(overrides = {}) {
|
|
88
|
-
return {
|
|
89
|
-
activeProvider: 'hyperliquid',
|
|
90
|
-
isTestnet: false,
|
|
91
|
-
initializationState: 'initialized',
|
|
92
|
-
initializationError: null,
|
|
93
|
-
initializationAttempts: 0,
|
|
94
|
-
accountState: null,
|
|
95
|
-
perpsBalances: {},
|
|
96
|
-
depositInProgress: false,
|
|
97
|
-
lastDepositTransactionId: null,
|
|
98
|
-
lastDepositResult: null,
|
|
99
|
-
withdrawInProgress: false,
|
|
100
|
-
lastWithdrawResult: null,
|
|
101
|
-
withdrawalRequests: [],
|
|
102
|
-
withdrawalProgress: {
|
|
103
|
-
progress: 0,
|
|
104
|
-
lastUpdated: 0,
|
|
105
|
-
activeWithdrawalId: null,
|
|
106
|
-
},
|
|
107
|
-
depositRequests: [],
|
|
108
|
-
isEligible: true,
|
|
109
|
-
isFirstTimeUser: {
|
|
110
|
-
testnet: true,
|
|
111
|
-
mainnet: true,
|
|
112
|
-
},
|
|
113
|
-
hasPlacedFirstOrder: {
|
|
114
|
-
testnet: false,
|
|
115
|
-
mainnet: false,
|
|
116
|
-
},
|
|
117
|
-
watchlistMarkets: {
|
|
118
|
-
testnet: [],
|
|
119
|
-
mainnet: [],
|
|
120
|
-
},
|
|
121
|
-
tradeConfigurations: {
|
|
122
|
-
testnet: {},
|
|
123
|
-
mainnet: {},
|
|
124
|
-
},
|
|
125
|
-
marketFilterPreferences: {
|
|
126
|
-
optionId: 'volume',
|
|
127
|
-
direction: 'desc',
|
|
128
|
-
},
|
|
129
|
-
lastError: null,
|
|
130
|
-
lastUpdateTimestamp: Date.now(),
|
|
131
|
-
hip3ConfigVersion: 0,
|
|
132
|
-
...overrides,
|
|
133
|
-
};
|
|
134
|
-
}
|
|
135
|
-
/**
|
|
136
|
-
* Create a mock ServiceContext with optional overrides
|
|
137
|
-
* Note: infrastructure is no longer part of ServiceContext - it's now injected
|
|
138
|
-
* into service instances via constructor.
|
|
139
|
-
*
|
|
140
|
-
* @param overrides - Optional overrides for the mock context
|
|
141
|
-
* @returns Mock ServiceContext
|
|
142
|
-
*/
|
|
143
|
-
export function createMockServiceContext(overrides = {}) {
|
|
144
|
-
return {
|
|
145
|
-
tracingContext: {
|
|
146
|
-
provider: 'hyperliquid',
|
|
147
|
-
isTestnet: false,
|
|
148
|
-
},
|
|
149
|
-
errorContext: {
|
|
150
|
-
controller: 'TestService',
|
|
151
|
-
method: 'testMethod',
|
|
152
|
-
},
|
|
153
|
-
stateManager: {
|
|
154
|
-
update: jest.fn(),
|
|
155
|
-
getState: jest.fn(() => createMockPerpsControllerState()),
|
|
156
|
-
},
|
|
157
|
-
...overrides,
|
|
158
|
-
};
|
|
159
|
-
}
|
|
160
|
-
/**
|
|
161
|
-
* Create a mock EVM account (KeyringAccount).
|
|
162
|
-
*
|
|
163
|
-
* @returns Mock EVM account
|
|
164
|
-
*/
|
|
165
|
-
export function createMockEvmAccount() {
|
|
166
|
-
return {
|
|
167
|
-
id: '00000000-0000-0000-0000-000000000000',
|
|
168
|
-
address: '0x1234567890abcdef1234567890abcdef12345678',
|
|
169
|
-
type: 'eip155:eoa',
|
|
170
|
-
options: {},
|
|
171
|
-
scopes: ['eip155:1'],
|
|
172
|
-
methods: ['eth_signTransaction', 'eth_sign'],
|
|
173
|
-
metadata: {
|
|
174
|
-
name: 'Test Account',
|
|
175
|
-
importTime: Date.now(),
|
|
176
|
-
keyring: { type: 'HD Key Tree' },
|
|
177
|
-
},
|
|
178
|
-
};
|
|
179
|
-
}
|
|
180
|
-
//# sourceMappingURL=serviceMocks.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"serviceMocks.mjs","sourceRoot":"","sources":["../../src/__mocks__/serviceMocks.ts"],"names":[],"mappings":"AAAA;;;GAGG;AASH;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,MAAM,wBAAwB,GACnC,GAA2C,EAAE,CAC3C,CAAC;IACC,8CAA8C;IAC9C,MAAM,EAAE;QACN,KAAK,EAAE,IAAI,CAAC,EAAE,EAAE;KACjB;IACD,WAAW,EAAE;QACX,GAAG,EAAE,IAAI,CAAC,EAAE,EAAE;KACf;IACD,OAAO,EAAE;QACP,UAAU,EAAE,IAAI,CAAC,EAAE,EAAE;QACrB,SAAS,EAAE,IAAI,CAAC,EAAE,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC;QAC9B,eAAe,EAAE,IAAI,CAAC,EAAE,EAAE;KAC3B;IACD,WAAW,EAAE;QACX,GAAG,EAAE,IAAI,CAAC,EAAE,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC;KAC/B;IACD,MAAM,EAAE;QACN,KAAK,EAAE,IAAI,CAAC,EAAE,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC;QAC/B,QAAQ,EAAE,IAAI,CAAC,EAAE,EAAE;QACnB,cAAc,EAAE,IAAI,CAAC,EAAE,EAAE;KAC1B;IAED,4BAA4B;IAC5B,aAAa,EAAE;QACb,YAAY,EAAE,IAAI,CAAC,EAAE,EAAE;QACvB,aAAa,EAAE,IAAI,CAAC,EAAE,EAAE;QACxB,gBAAgB,EAAE,IAAI,CAAC,EAAE,EAAE;KAC5B;IAED,2DAA2D;IAC3D,WAAW,EAAE;QACX,gDAAgD;QAChD,QAAQ,EAAE;YACR,qBAAqB,EAAE,IAAI,CAAC,EAAE,CAAC,GAAG,EAAE,CAAC,CAAC;gBACpC,OAAO,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AAS;KACb,CAAC;AACJ,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,oBAAoB;IAalC,OAAO;QACL,EAAE,EAAE,sCAAsC;QAC1C,OAAO,EAAE,4CAA6D;QACtE,IAAI,EAAE,YAAqB;QAC3B,OAAO,EAAE,EAAE;QACX,MAAM,EAAE,CAAC,UAAU,CAAC;QACpB,OAAO,EAAE,CAAC,qBAAqB,EAAE,UAAU,CAAC;QAC5C,QAAQ,EAAE;YACR,IAAI,EAAE,cAAc;YACpB,UAAU,EAAE,IAAI,CAAC,GAAG,EAAE;YACtB,OAAO,EAAE,EAAE,IAAI,EAAE,aAAa,EAAE;SACjC;KACF,CAAC;AACJ,CAAC","sourcesContent":["/**\n * Shared service mocks for Perps service tests\n * Provides reusable mock implementations for ServiceContext and related types\n */\n\nimport type {\n PerpsControllerState,\n InitializationState,\n} from '../PerpsController';\nimport type { ServiceContext } from '../services/ServiceContext';\nimport type { PerpsPlatformDependencies } from '../types';\n\n/**\n * Create a mock PerpsPlatformDependencies instance.\n * Returns a type-safe mock with jest.Mock functions for all methods.\n * Uses `as unknown as jest.Mocked<PerpsPlatformDependencies>` pattern\n * to ensure compatibility with both the interface contract and Jest mock APIs.\n *\n * Architecture:\n * - Observability: logger, debugLogger, metrics, performance, tracer (stateless utilities)\n * - Platform: streamManager (mobile/extension specific capabilities)\n * - Controllers: consolidated access to all external controllers\n *\n * @returns Mocked PerpsPlatformDependencies\n */\nexport const createMockInfrastructure =\n (): jest.Mocked<PerpsPlatformDependencies> =>\n ({\n // === Observability (stateless utilities) ===\n logger: {\n error: jest.fn(),\n },\n debugLogger: {\n log: jest.fn(),\n },\n metrics: {\n trackEvent: jest.fn(),\n isEnabled: jest.fn(() => true),\n trackPerpsEvent: jest.fn(),\n },\n performance: {\n now: jest.fn(() => Date.now()),\n },\n tracer: {\n trace: jest.fn(() => undefined),\n endTrace: jest.fn(),\n setMeasurement: jest.fn(),\n },\n\n // === Platform Services ===\n streamManager: {\n pauseChannel: jest.fn(),\n resumeChannel: jest.fn(),\n clearAllChannels: jest.fn(),\n },\n\n // === Controller Access (ALL controllers consolidated) ===\n controllers: {\n // Account operations (wraps AccountsController)\n accounts: {\n getSelectedEvmAccount: jest.fn(() => ({\n address: '0x1234567890abcdef1234567890abcdef12345678',\n })),\n formatAccountToCaipId: jest.fn(\n (address: string, chainId: string) =>\n `eip155:${chainId}:${address}`,\n ),\n },\n // Keyring operations (wraps KeyringController)\n keyring: {\n signTypedMessage: jest.fn().mockResolvedValue('0xSignatureResult'),\n },\n // Network operations (wraps NetworkController)\n network: {\n getChainIdForNetwork: jest.fn().mockReturnValue('0x1'),\n findNetworkClientIdForChain: jest.fn().mockReturnValue('mainnet'),\n getSelectedNetworkClientId: jest.fn().mockReturnValue('mainnet'),\n },\n // Transaction operations (wraps TransactionController)\n transaction: {\n submit: jest.fn().mockResolvedValue({\n result: Promise.resolve('0xTransactionHash'),\n transactionMeta: { id: 'tx-id-123', hash: '0xTransactionHash' },\n }),\n },\n // Rewards operations (wraps RewardsController, optional)\n rewards: {\n getFeeDiscount: jest.fn().mockResolvedValue(0),\n },\n // Authentication operations (wraps AuthenticationController)\n authentication: {\n getBearerToken: jest.fn().mockResolvedValue('mock-bearer-token'),\n },\n },\n }) as unknown as jest.Mocked<PerpsPlatformDependencies>;\n\n/**\n * Create a mock PerpsControllerState.\n *\n * @param overrides - Optional overrides for the mock state\n * @returns Mock PerpsControllerState\n */\nexport function createMockPerpsControllerState(\n overrides: Partial<PerpsControllerState> = {},\n): PerpsControllerState {\n return {\n activeProvider: 'hyperliquid',\n isTestnet: false,\n initializationState: 'initialized' as InitializationState,\n initializationError: null,\n initializationAttempts: 0,\n accountState: null,\n perpsBalances: {},\n depositInProgress: false,\n lastDepositTransactionId: null,\n lastDepositResult: null,\n withdrawInProgress: false,\n lastWithdrawResult: null,\n withdrawalRequests: [],\n withdrawalProgress: {\n progress: 0,\n lastUpdated: 0,\n activeWithdrawalId: null,\n },\n depositRequests: [],\n isEligible: true,\n isFirstTimeUser: {\n testnet: true,\n mainnet: true,\n },\n hasPlacedFirstOrder: {\n testnet: false,\n mainnet: false,\n },\n watchlistMarkets: {\n testnet: [],\n mainnet: [],\n },\n tradeConfigurations: {\n testnet: {},\n mainnet: {},\n },\n marketFilterPreferences: {\n optionId: 'volume',\n direction: 'desc',\n },\n lastError: null,\n lastUpdateTimestamp: Date.now(),\n hip3ConfigVersion: 0,\n ...overrides,\n };\n}\n\n/**\n * Create a mock ServiceContext with optional overrides\n * Note: infrastructure is no longer part of ServiceContext - it's now injected\n * into service instances via constructor.\n *\n * @param overrides - Optional overrides for the mock context\n * @returns Mock ServiceContext\n */\nexport function createMockServiceContext(\n overrides: Partial<ServiceContext> = {},\n): ServiceContext {\n return {\n tracingContext: {\n provider: 'hyperliquid',\n isTestnet: false,\n },\n errorContext: {\n controller: 'TestService',\n method: 'testMethod',\n },\n stateManager: {\n update: jest.fn(),\n getState: jest.fn(() => createMockPerpsControllerState()),\n },\n ...overrides,\n };\n}\n\n/**\n * Create a mock EVM account (KeyringAccount).\n *\n * @returns Mock EVM account\n */\nexport function createMockEvmAccount(): {\n id: string;\n address: `0x${string}`;\n type: 'eip155:eoa';\n options: Record<string, never>;\n scopes: string[];\n methods: string[];\n metadata: {\n name: string;\n importTime: number;\n keyring: { type: string };\n };\n} {\n return {\n id: '00000000-0000-0000-0000-000000000000',\n address: '0x1234567890abcdef1234567890abcdef12345678' as `0x${string}`,\n type: 'eip155:eoa' as const,\n options: {},\n scopes: ['eip155:1'],\n methods: ['eth_signTransaction', 'eth_sign'],\n metadata: {\n name: 'Test Account',\n importTime: Date.now(),\n keyring: { type: 'HD Key Tree' },\n },\n };\n}\n"]}
|