// See the Electron documentation for details on how to use preload scripts:
// https://www.electronjs.org/docs/latest/tutorial/process-model#preload-scripts
import { contextBridge, ipcRenderer } from 'electron'

contextBridge.exposeInMainWorld('walletApi', {
    createKeystore: (seed: string, password: string) =>
        ipcRenderer.invoke('wallet:createKeystore', seed, password),
    saveKeystoreAs: (seed: string, password: string) =>
        ipcRenderer.invoke('wallet:saveKeystoreAs', seed, password),
    decryptKeystore: (filePath: string, password: string) =>
        ipcRenderer.invoke('wallet:decryptKeystore', filePath, password),
    checkKeystore: () => ipcRenderer.invoke('wallet:checkKeystore'),
    generateKeysFromSeed: (seedPhrase: string[]) =>
        ipcRenderer.invoke('wallet:generateKeysFromSeed', seedPhrase),
    buildTransaction: (args: any) => ipcRenderer.invoke('wallet:buildTransaction', args),
    updateMinBlockHeight: (filePath: string | null, minBlockHeight: number | null) =>
        ipcRenderer.invoke('wallet:updateMinBlockHeight', filePath, minBlockHeight),
    getMinBlockHeight: (filePath: string | null) =>
        ipcRenderer.invoke('wallet:getMinBlockHeight', filePath),
})
