Skip to content

Commit

Permalink
Simplify options for EngineConfig
Browse files Browse the repository at this point in the history
  • Loading branch information
samholmes committed Dec 19, 2024
1 parent 858f870 commit 2d5e4f8
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 25 deletions.
7 changes: 3 additions & 4 deletions src/common/plugin/CurrencyPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,9 @@ export function makeCurrencyPlugin(
currencyTools,
initOptions: asUtxoInitOptions(initOptions),
io,
options: {
...pluginOptions,
...engineOptions,
emitter
emitter,
engineOptions: {
...engineOptions
},
pluginState
}
Expand Down
7 changes: 2 additions & 5 deletions src/common/plugin/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -356,16 +356,13 @@ export interface EngineConfig {
pluginInfo: PluginInfo
pluginDisklet: Disklet
currencyTools: EdgeCurrencyTools
options: EngineOptions
engineOptions: EdgeCurrencyEngineOptions
emitter: EngineEmitter
initOptions: UtxoInitOptions
io: EdgeIo
pluginState: PluginState
}

export interface EngineOptions extends EdgeCurrencyEngineOptions {
emitter: EngineEmitter
}

export type LocalWalletMetadata = ReturnType<typeof asLocalWalletMetadata>
export const asLocalWalletMetadata = asObject({
balance: asString,
Expand Down
23 changes: 9 additions & 14 deletions src/common/utxobased/engine/UtxoEngine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,19 +73,14 @@ export async function makeUtxoEngine(
const {
pluginInfo,
pluginDisklet,
// Rename to make it explicit that this is sensitive memory
options,
emitter,
engineOptions,
io,
pluginState
} = config
const {
walletLocalDisklet,
walletLocalEncryptedDisklet,
emitter,
log
} = options
const { walletLocalDisklet, walletLocalEncryptedDisklet, log } = engineOptions
const { currencyInfo, engineInfo, coinInfo } = pluginInfo
const userSettings = asUtxoUserSettings(options.userSettings)
const userSettings = asUtxoUserSettings(engineOptions.userSettings)

// We should move the active server list to the engine state,
// since multiple accounts can be logged in at once,
Expand Down Expand Up @@ -120,7 +115,7 @@ export async function makeUtxoEngine(
disklet: pluginDisklet,
pluginInfo,
io,
log: config.options.log
log: config.engineOptions.log
})

const metadata = await makeMetadata({
Expand Down Expand Up @@ -983,11 +978,11 @@ export async function makeUtxoEngine(

const tmpEngineProcessor = makeUtxoEngineProcessor({
...config,
options: {
...config.options,
emitter: tmpEmitter,
engineOptions: {
...config.engineOptions,
walletLocalDisklet: tmpDisklet,
walletLocalEncryptedDisklet: tmpEncryptedDisklet,
emitter: tmpEmitter
walletLocalEncryptedDisklet: tmpEncryptedDisklet
},
pluginInfo: {
...pluginInfo,
Expand Down
5 changes: 3 additions & 2 deletions src/common/utxobased/engine/UtxoEngineProcessor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,14 +91,15 @@ export function makeUtxoEngineProcessor(
const {
initOptions,
io,
options,
emitter,
engineOptions,
pluginState,
pluginInfo,
dataLayer,
walletInfo,
walletTools
} = config
const { emitter, log } = options
const { log } = engineOptions

const { walletFormats } = walletInfo.keys

Expand Down

0 comments on commit 2d5e4f8

Please sign in to comment.