Skip to content

Commit

Permalink
chore(suite): allow override
Browse files Browse the repository at this point in the history
  • Loading branch information
marekrjpolak committed Jun 3, 2024
1 parent 19fc24d commit fdc018c
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
4 changes: 2 additions & 2 deletions packages/suite/src/actions/wallet/coinjoinClientActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -788,11 +788,11 @@ export const initCoinjoinService =
});

try {
const settings = getCoinjoinConfig(symbol, environment);
const config = getCoinjoinConfig(symbol, environment);
const service = await CoinjoinService.createInstance({
network: symbol,
prison,
settings,
settings: { ...config, ...debug?.coinjoinConfigOverride?.[symbol] },
});
if (isCoinjoinDisabledByFeatureFlag) {
dispatch(clientEnableFailed(symbol));
Expand Down
7 changes: 4 additions & 3 deletions packages/suite/src/services/coinjoin/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ import type { PartialRecord } from '@trezor/type-utils';
import type { CoinjoinServerEnvironment } from 'src/types/wallet/coinjoin';
import type { NetworkSymbol } from '@suite-common/wallet-config';

export type CoinjoinNetworksConfig = CoinjoinBackendSettings & CoinjoinClientSettings;
export type CoinjoinNetworksConfig = CoinjoinBackendSettings &
CoinjoinClientSettings & { blockbookUrls: string[] };

type ServerEnvironment = PartialRecord<CoinjoinServerEnvironment, CoinjoinNetworksConfig>;

Expand Down Expand Up @@ -167,13 +168,13 @@ export const ANONYMITY_GAINS_HINDSIGHT_DAYS = 30;
export const getCoinjoinConfig = (
network: NetworkSymbol,
environment?: CoinjoinServerEnvironment,
) => {
): CoinjoinNetworksConfig => {
const config = COINJOIN_NETWORKS[network];
const settings = config
? config[environment ?? (Object.keys(config)[0] as CoinjoinServerEnvironment)]
: undefined;
if (!settings)
throw new Error(`Missing settings for coinjoin network ${network} env ${environment}`);

return settings;
return { affiliationId: 'trezor', ...settings };
};
2 changes: 2 additions & 0 deletions packages/suite/src/types/wallet/coinjoin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
EndRoundState,
WabiSabiProtocolErrorCode,
} from '@trezor/coinjoin/src/enums';
import type { CoinjoinNetworksConfig } from 'src/services/coinjoin';

export { EndRoundState, WabiSabiProtocolErrorCode };
export type { RoundPhase, SessionPhase };
Expand Down Expand Up @@ -100,6 +101,7 @@ export type CoinjoinServerEnvironment = 'public' | 'staging' | 'localhost';
export interface CoinjoinDebugSettings {
coinjoinAllowNoTor?: boolean;
coinjoinServerEnvironment?: PartialRecord<NetworkSymbol, CoinjoinServerEnvironment>;
coinjoinConfigOverride?: PartialRecord<NetworkSymbol, Partial<CoinjoinNetworksConfig>>;
}

export interface CoinjoinConfig {
Expand Down

0 comments on commit fdc018c

Please sign in to comment.