Added "Change Seed" button

This commit is contained in:
AlexanderBuzz
2023-07-27 15:27:48 +02:00
parent 5b0b75abd9
commit d39ea74e55
15 changed files with 97 additions and 26 deletions

View File

@@ -56,6 +56,12 @@ const main = async () => {
await initialize(client, wallet, appWindow)
})
ipcMain.on('request-seed-change', (event) => {
fs.rmSync(path.join(__dirname, WALLET_DIR , 'seed.txt'))
fs.rmSync(path.join(__dirname, WALLET_DIR , 'salt.txt'))
appWindow.webContents.send('open-seed-dialog')
})
// We have to wait for the application frontend to be ready, otherwise
// we might run into a race condition and the open-dialog events
// get triggered before the callbacks are attached

View File

@@ -57,7 +57,13 @@ const main = async () => {
})
// We have to wait for the application frontend to be ready, otherise
ipcMain.on('request-seed-change', (event) => {
fs.rmSync(path.join(__dirname, WALLET_DIR , 'seed.txt'))
fs.rmSync(path.join(__dirname, WALLET_DIR , 'salt.txt'))
appWindow.webContents.send('open-seed-dialog')
})
// We have to wait for the application frontend to be ready, otherwise
// we might run into a race condition and the ope-dialog events
// get triggered before the callbacks are attached
appWindow.once('ready-to-show', () => {

View File

@@ -64,7 +64,13 @@ const main = async () => {
})
// We have to wait for the application frontend to be ready, otherise
ipcMain.on('request-seed-change', (event) => {
fs.rmSync(path.join(__dirname, WALLET_DIR , 'seed.txt'))
fs.rmSync(path.join(__dirname, WALLET_DIR , 'salt.txt'))
appWindow.webContents.send('open-seed-dialog')
})
// We have to wait for the application frontend to be ready, otherwise
// we might run into a race condition and the ope-dialog events
// get triggered before the callbacks are attached
appWindow.once('ready-to-show', () => {

View File

@@ -71,7 +71,13 @@ const main = async () => {
})
// We have to wait for the application frontend to be ready, otherise
ipcMain.on('request-seed-change', (event) => {
fs.rmSync(path.join(__dirname, WALLET_DIR , 'seed.txt'))
fs.rmSync(path.join(__dirname, WALLET_DIR , 'salt.txt'))
appWindow.webContents.send('open-seed-dialog')
})
// We have to wait for the application frontend to be ready, otherwise
// we might run into a race condition and the ope-dialog events
// get triggered before the callbacks are attached
appWindow.once('ready-to-show', () => {

View File

@@ -58,10 +58,11 @@
<dialog id="password-dialog">
<form method="dialog">
<div>
<label for="password-input">Enter password (min-length 5):</label>
<label for="password-input">Enter password (min-length 5):</label><br />
<input type="text" id="password-input" name="password-input" />
</div>
<div>
<button type="button">Change Seed</button>
<button type="submit">Submit</button>
</div>
</form>

View File

@@ -14,6 +14,9 @@ contextBridge.exposeInMainWorld('electronAPI', {
onEnterPassword: (password) => {
ipcRenderer.send('password-entered', password)
},
requestSeedChange: () => {
ipcRenderer.send('request-seed-change')
},
// Step 5 code additions - end
onUpdateLedgerData: (callback) => {

View File

@@ -1,11 +1,11 @@
// Step 5 code additions - start
window.electronAPI.onOpenSeedDialog((_event) => {
const seedDialog = document.getElementById('seed-dialog');
const seedInput = seedDialog.querySelector('input');
const submitButton = seedDialog.querySelector('button[type="submit"]');
const seedDialog = document.getElementById('seed-dialog')
const seedInput = seedDialog.querySelector('input')
const submitButton = seedDialog.querySelector('button[type="submit"]')
submitButton.addEventListener('click', () => {
const seed = seedInput.value;
const seed = seedInput.value
window.electronAPI.onEnterSeed(seed)
seedDialog.close()
});
@@ -14,16 +14,22 @@ window.electronAPI.onOpenSeedDialog((_event) => {
})
window.electronAPI.onOpenPasswordDialog((_event) => {
const passwordDialog = document.getElementById('password-dialog');
const passwordInput = passwordDialog.querySelector('input');
const submitButton = passwordDialog.querySelector('button[type="submit"]');
const passwordDialog = document.getElementById('password-dialog')
const passwordInput = passwordDialog.querySelector('input')
const submitButton = passwordDialog.querySelector('button[type="submit"]')
const changeSeedButton = passwordDialog.querySelector('button[type="button"]')
submitButton.addEventListener('click', () => {
const password = passwordInput.value;
const password = passwordInput.value
window.electronAPI.onEnterPassword(password)
passwordDialog.close()
});
changeSeedButton.addEventListener('click', () => {
passwordDialog.close()
window.electronAPI.requestSeedChange()
});
passwordDialog.showModal()
});
// Step 5 code additions - end

View File

@@ -102,10 +102,11 @@
<dialog id="password-dialog">
<form method="dialog">
<div>
<label for="password-input">Enter password (min-length: 5):</label>
<label for="password-input">Enter password (min-length 5):</label><br />
<input type="text" id="password-input" name="password-input" />
</div>
<div>
<button type="button">Change Seed</button>
<button type="submit">Submit</button>
</div>
</form>

View File

@@ -13,6 +13,9 @@ contextBridge.exposeInMainWorld('electronAPI', {
onEnterPassword: (password) => {
ipcRenderer.send('password-entered', password)
},
requestSeedChange: () => {
ipcRenderer.send('request-seed-change')
},
onUpdateLedgerData: (callback) => {
ipcRenderer.on('update-ledger-data', callback)
},

View File

@@ -13,16 +13,22 @@ window.electronAPI.onOpenSeedDialog((_event) => {
})
window.electronAPI.onOpenPasswordDialog((_event) => {
const passwordDialog = document.getElementById('password-dialog');
const passwordInput = passwordDialog.querySelector('input');
const submitButton = passwordDialog.querySelector('button[type="submit"]');
const passwordDialog = document.getElementById('password-dialog')
const passwordInput = passwordDialog.querySelector('input')
const submitButton = passwordDialog.querySelector('button[type="submit"]')
const changeSeedButton = passwordDialog.querySelector('button[type="button"]')
submitButton.addEventListener('click', () => {
const password = passwordInput.value;
const password = passwordInput.value
window.electronAPI.onEnterPassword(password)
passwordDialog.close()
});
changeSeedButton.addEventListener('click', () => {
passwordDialog.close()
window.electronAPI.requestSeedChange()
});
passwordDialog.showModal()
});

View File

@@ -138,11 +138,12 @@
<dialog id="password-dialog">
<form method="dialog">
<div>
<label for="password-input">Enter password (min-length: 5):</label>
<label for="password-input">Enter password (min-length 5):</label><br />
<input type="text" id="password-input" name="password-input" />
</div>
<div>
<button type="submit">Confirm</button>
<button type="button">Change Seed</button>
<button type="submit">Submit</button>
</div>
</form>
</dialog>

View File

@@ -141,11 +141,12 @@
<dialog id="password-dialog">
<form method="dialog">
<div>
<label for="password-input">Enter password (min-length: 5):</label>
<label for="password-input">Enter password (min-length 5):</label><br />
<input type="text" id="password-input" name="password-input" />
</div>
<div>
<button type="submit">Confirm</button>
<button type="button">Change Seed</button>
<button type="submit">Submit</button>
</div>
</form>
</dialog>

View File

@@ -13,6 +13,9 @@ contextBridge.exposeInMainWorld('electronAPI', {
onEnterPassword: (password) => {
ipcRenderer.send('password-entered', password)
},
requestSeedChange: () => {
ipcRenderer.send('request-seed-change')
},
onUpdateLedgerData: (callback) => {
ipcRenderer.on('update-ledger-data', callback)
},

View File

@@ -13,16 +13,22 @@ window.electronAPI.onOpenSeedDialog((_event) => {
})
window.electronAPI.onOpenPasswordDialog((_event) => {
const passwordDialog = document.getElementById('password-dialog');
const passwordInput = passwordDialog.querySelector('input');
const submitButton = passwordDialog.querySelector('button[type="submit"]');
const passwordDialog = document.getElementById('password-dialog')
const passwordInput = passwordDialog.querySelector('input')
const submitButton = passwordDialog.querySelector('button[type="submit"]')
const changeSeedButton = passwordDialog.querySelector('button[type="button"]')
submitButton.addEventListener('click', () => {
const password = passwordInput.value;
const password = passwordInput.value
window.electronAPI.onEnterPassword(password)
passwordDialog.close()
});
changeSeedButton.addEventListener('click', () => {
passwordDialog.close()
window.electronAPI.requestSeedChange()
});
passwordDialog.showModal()
});

View File

@@ -862,6 +862,12 @@ const main = async () => {
await initialize(client, wallet, appWindow)
})
ipcMain.on('request-seed-change', (event) => {
fs.rmSync(path.join(__dirname, WALLET_DIR , 'seed.txt'))
fs.rmSync(path.join(__dirname, WALLET_DIR , 'salt.txt'))
appWindow.webContents.send('open-seed-dialog')
})
// We have to wait for the application frontend to be ready, otherwise
// we might run into a race condition and the open-dialog events
// get triggered before the callbacks are attached
@@ -896,6 +902,9 @@ contextBridge.exposeInMainWorld('electronAPI', {
onEnterPassword: (password) => {
ipcRenderer.send('password-entered', password)
},
requestSeedChange: () => {
ipcRenderer.send('request-seed-change')
},
// Step 5 code additions - end
onUpdateLedgerData: (callback) => {
@@ -925,7 +934,8 @@ contextBridge.exposeInMainWorld('electronAPI', {
<input type="text" id="password-input" name="password-input" />
</div>
<div>
<button type="submit">Confirm</button>
<button type="button">Change Seed</button>
<button type="submit">Submit</button>
</div>
</form>
</dialog>
@@ -952,6 +962,7 @@ window.electronAPI.onOpenPasswordDialog((_event) => {
const passwordDialog = document.getElementById('password-dialog');
const passwordInput = passwordDialog.querySelector('input');
const submitButton = passwordDialog.querySelector('button[type="submit"]');
const changeSeedButton = passwordDialog.querySelector('button[type="button"]')
submitButton.addEventListener('click', () => {
const password = passwordInput.value;
@@ -959,6 +970,11 @@ window.electronAPI.onOpenPasswordDialog((_event) => {
passwordDialog.close()
});
changeSeedButton.addEventListener('click', () => {
passwordDialog.close()
window.electronAPI.requestSeedChange()
});
passwordDialog.showModal()
});
```