From bf04aa48073522d53eb23dd0711070484b770d45 Mon Sep 17 00:00:00 2001 From: Peter Sanderson Date: Fri, 30 Jan 2026 01:31:26 +0100 Subject: [PATCH] fix: user service from DI, not to create one in place --- packages/suite/src/support/extraDependencies.ts | 1 + suite-common/redux-utils/package.json | 1 + suite-common/redux-utils/src/extraDependenciesType.ts | 2 ++ suite-common/redux-utils/tsconfig.json | 3 +++ .../src/increaseOwnerQuotaThunk.ts | 11 +---------- .../test-utils/src/extraDependenciesCommonMock.ts | 8 +++++++- suite-native/state/src/extraDependencies.ts | 1 + yarn.lock | 1 + 8 files changed, 17 insertions(+), 11 deletions(-) diff --git a/packages/suite/src/support/extraDependencies.ts b/packages/suite/src/support/extraDependencies.ts index 801717ac99..cf58c399e2 100644 --- a/packages/suite/src/support/extraDependencies.ts +++ b/packages/suite/src/support/extraDependencies.ts @@ -136,6 +136,7 @@ export const createSuiteServicesCompositionRoot = (deps: SuiteAppDeps): SuiteSer return { suiteSync, + ensureDelegatedIdentityKey, platformEncryption, analytics, disableLegacyMetadataIfNeeded, diff --git a/suite-common/redux-utils/package.json b/suite-common/redux-utils/package.json index 559a6e8be7..4bee8e6142 100644 --- a/suite-common/redux-utils/package.json +++ b/suite-common/redux-utils/package.json @@ -13,6 +13,7 @@ "dependencies": { "@reduxjs/toolkit": "2.11.0", "@suite-common/analytics": "workspace:*", + "@suite-common/delegated-identity-key-types": "workspace:*", "@suite-common/metadata-types": "workspace:*", "@suite-common/platform-encryption": "workspace:*", "@suite-common/suite-rbf-labels-migrations-types": "workspace:*", diff --git a/suite-common/redux-utils/src/extraDependenciesType.ts b/suite-common/redux-utils/src/extraDependenciesType.ts index fa29c4989e..b8b24659c6 100644 --- a/suite-common/redux-utils/src/extraDependenciesType.ts +++ b/suite-common/redux-utils/src/extraDependenciesType.ts @@ -5,6 +5,7 @@ import { } from '@reduxjs/toolkit'; import type { AnalyticsSharedEvents } from '@suite-common/analytics'; +import { EnsureDelegatedIdentityKeyDep } from '@suite-common/delegated-identity-key-types'; import { MetadataAddPayload } from '@suite-common/metadata-types'; import { PlatformEncryptionDep } from '@suite-common/platform-encryption'; // also only types import { MigrateSuiteSyncLabelsForRbfTransactionDep } from '@suite-common/suite-rbf-labels-migrations-types'; @@ -37,6 +38,7 @@ export type ConnectInitSettings = { } & Partial; export type CommonServices = SuiteSyncDep & + EnsureDelegatedIdentityKeyDep & PlatformEncryptionDep & { analytics: Analytics; saveAs: (data: Blob, fileName: string) => void; diff --git a/suite-common/redux-utils/tsconfig.json b/suite-common/redux-utils/tsconfig.json index ad4c67bcf4..4b65e89ca7 100644 --- a/suite-common/redux-utils/tsconfig.json +++ b/suite-common/redux-utils/tsconfig.json @@ -3,6 +3,9 @@ "compilerOptions": { "outDir": "libDev" }, "references": [ { "path": "../analytics" }, + { + "path": "../delegated-identity-key-types" + }, { "path": "../metadata-types" }, { "path": "../platform-encryption" }, { diff --git a/suite-common/suite-sync-quota-manager/src/increaseOwnerQuotaThunk.ts b/suite-common/suite-sync-quota-manager/src/increaseOwnerQuotaThunk.ts index 332aae84cf..cd86af1317 100644 --- a/suite-common/suite-sync-quota-manager/src/increaseOwnerQuotaThunk.ts +++ b/suite-common/suite-sync-quota-manager/src/increaseOwnerQuotaThunk.ts @@ -4,12 +4,10 @@ import { getProofOfDelegatedIdentity, getPublicIdentityKeyFromDelegatedKey, } from '@suite-common/delegated-identity-key'; -import { delegatedIdentityKeyCompositionRoot } from '@suite-common/delegated-identity-key/src/delegatedIdentityKeyCompositionRoot'; import { ExtraDependencies } from '@suite-common/redux-utils'; import { SuiteSyncOwnerId, asDelegatedIdentityKey } from '@suite-common/suite-types'; import { selectSelectedDevice } from '@suite-common/wallet-core'; import { isTrezorDeviceWithState, parseDeviceStaticSessionId } from '@suite-common/wallet-utils'; -import TrezorConnect from '@trezor/connect'; import { prepareChallengeSession } from './challenge/prepareChallengeSession'; import { @@ -38,14 +36,7 @@ export const increaseOwnerQuotaThunk = const { walletDescriptor } = parseDeviceStaticSessionId(device.state.staticSessionId); const quotaManagerBaseUrl = selectQuotaManagerBaseUrl(getState()); - const { ensureDelegatedIdentityKey } = delegatedIdentityKeyCompositionRoot({ - dispatch, - getState, - trezorConnect: TrezorConnect, - platformEncryption: extra.services.platformEncryption, - }); - - const delegatedKey = await ensureDelegatedIdentityKey({ device }); + const delegatedKey = await extra.services.ensureDelegatedIdentityKey({ device }); if (!delegatedKey.success) { return; } diff --git a/suite-common/test-utils/src/extraDependenciesCommonMock.ts b/suite-common/test-utils/src/extraDependenciesCommonMock.ts index 469e97ea03..ea31f37e26 100644 --- a/suite-common/test-utils/src/extraDependenciesCommonMock.ts +++ b/suite-common/test-utils/src/extraDependenciesCommonMock.ts @@ -14,7 +14,11 @@ import { notImplementedThunk, } from '@suite-common/redux-utils'; import type { SuiteSync } from '@suite-common/suite-sync-types'; -import { ReportSecurityCheckParams, Route } from '@suite-common/suite-types'; +import { + ReportSecurityCheckParams, + Route, + asDelegatedIdentityKey, +} from '@suite-common/suite-types'; import { mockSuiteDevice } from '@suite-common/suite-types/mocks'; import { AddressDisplayOptions, @@ -77,6 +81,8 @@ export const extraDependenciesCommonMock: ExtraDependencies = { }, services: { suiteSync: suiteSyncMock, + ensureDelegatedIdentityKey: () => + Promise.resolve(ok(asDelegatedIdentityKey('mockDelegatedIdentityKey'))), platformEncryption: platformEncryptionMock, analytics: analyticsMock, reportSecurityCheck: ({ level, checkType }: ReportSecurityCheckParams) => diff --git a/suite-native/state/src/extraDependencies.ts b/suite-native/state/src/extraDependencies.ts index b4934e2d7b..84a621ac7b 100644 --- a/suite-native/state/src/extraDependencies.ts +++ b/suite-native/state/src/extraDependencies.ts @@ -72,6 +72,7 @@ export const createNativeCompositionRoot = (deps: NativeAppDeps): NativeServices return { suiteSync, + ensureDelegatedIdentityKey, platformEncryption, analytics, getMMKVStorage: () => deps.mmkvStorage.getMMKV(), diff --git a/yarn.lock b/yarn.lock index e4377e1fe8..fa24f504c6 100644 --- a/yarn.lock +++ b/yarn.lock @@ -11222,6 +11222,7 @@ __metadata: dependencies: "@reduxjs/toolkit": "npm:2.11.0" "@suite-common/analytics": "workspace:*" + "@suite-common/delegated-identity-key-types": "workspace:*" "@suite-common/metadata-types": "workspace:*" "@suite-common/platform-encryption": "workspace:*" "@suite-common/suite-rbf-labels-migrations-types": "workspace:*"