Add currency settings, Settings service, and dialog to select fiat currency. Add support for non Official currencies like DOGE when using rates.
This commit is contained in:
@@ -12,6 +12,7 @@ import { SyncServer } from "../utils/sync-server.js";
|
||||
import { HistoryService } from "./history.js";
|
||||
import { type BlockchainService, ElectrumService } from "./electrum.js";
|
||||
import { RatesService } from "./rates.js";
|
||||
import { SettingsService } from "./settings.js";
|
||||
|
||||
import { EventEmitter } from "../utils/event-emitter.js";
|
||||
|
||||
@@ -49,6 +50,7 @@ export class AppService extends EventEmitter<AppEventMap> {
|
||||
public history: HistoryService;
|
||||
public electrum: BlockchainService;
|
||||
public rates: RatesService;
|
||||
public settings: SettingsService;
|
||||
|
||||
public invitations: Invitation[] = [];
|
||||
private invitationEventCleanup = new Map<
|
||||
@@ -59,7 +61,11 @@ export class AppService extends EventEmitter<AppEventMap> {
|
||||
}
|
||||
>();
|
||||
|
||||
static async create(seed: string, config: AppConfig): Promise<AppService> {
|
||||
static async create(
|
||||
seed: string,
|
||||
config: AppConfig,
|
||||
settings: SettingsService = new SettingsService(),
|
||||
): Promise<AppService> {
|
||||
// Because of a bug that lets wallets read the unspents of other wallets, we are going to manually namespace the storage paths for the app.
|
||||
// We are going to do this by computing a hash of the seed and prefixing the storage paths with it.
|
||||
const seedHash = createHash("sha256").update(seed).digest("hex");
|
||||
@@ -110,9 +116,9 @@ export class AppService extends EventEmitter<AppEventMap> {
|
||||
host: config.electrumHost,
|
||||
applicationIdentifier: config.electrumApplicationIdentifier,
|
||||
});
|
||||
const rates = await RatesService.create();
|
||||
const rates = await RatesService.create(settings);
|
||||
|
||||
return new AppService(engine, walletStorage, config, electrum, rates);
|
||||
return new AppService(engine, walletStorage, config, electrum, rates, settings);
|
||||
}
|
||||
|
||||
constructor(
|
||||
@@ -121,6 +127,7 @@ export class AppService extends EventEmitter<AppEventMap> {
|
||||
config: AppConfig,
|
||||
electrum: BlockchainService,
|
||||
rates: RatesService,
|
||||
settings: SettingsService,
|
||||
) {
|
||||
super();
|
||||
|
||||
@@ -129,6 +136,7 @@ export class AppService extends EventEmitter<AppEventMap> {
|
||||
this.config = config;
|
||||
this.electrum = electrum;
|
||||
this.rates = rates;
|
||||
this.settings = settings;
|
||||
this.history = new HistoryService(engine, this.invitations);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user