Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Rebased on top of #3366This simplifies some code that runs in the main process and introduces a preload script that runs before the main wallet interface. This starts the work towards moving all node-related calls to the preload script, so that node integration can be turned off for the main UI code.
Notable changes:
Switch fromaxios
to standardfetch
calls(dropped this to send into a separate PR since it affects all third party calls)axios
still uses the old XMLHTTPRequest which is not needed in modern browsers.fetch
allows more config options and removes the need for an additional dependency.send/on
IPC calls withinvoke/handle
for commsinvoke/handle
automatically promisify calls and are asynchronous, thus removing the need for an error-prone architecture usingsend/on
for async comms with the main processfs
related code to separate filefs
module, the operations are shimmed through a local js module and call sites are updated accordlingyPreload scripts are specified by the main electron process code when creating a
BrowserWindow
object and run before the document specified byloadURL
is loaded. The main usefulness for preload scripts is (re-)introducing select node and electron APIs to the UI code when theBrowserWindow
is created withnodeIntegration: false
andcontextIsolation: true
(which is the default in electron v12 and is likely to become mandatory in the future).Unfortunately, due to the large number of places in the UI code where native node modules and electron API calls are happening today, it's going to be too difficult to write, test and review a single PR moving all code to the preload stage. Therefore, this is going to be broken up into a series of PRs that slowly improve the interface for IPC calls between the main and renderer processes and moves code to the preload script, such that a final PR can simply set the appropriate flags in the
webContents
during startup.