diff --git a/content/_code-samples/build-a-wallet/desktop-js/5_password.js b/content/_code-samples/build-a-wallet/desktop-js/5_password.js index 0611bd7045..3ae4401aaa 100644 --- a/content/_code-samples/build-a-wallet/desktop-js/5_password.js +++ b/content/_code-samples/build-a-wallet/desktop-js/5_password.js @@ -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 diff --git a/content/_code-samples/build-a-wallet/desktop-js/6_styling.js b/content/_code-samples/build-a-wallet/desktop-js/6_styling.js index 1639b2af48..096dcc762d 100644 --- a/content/_code-samples/build-a-wallet/desktop-js/6_styling.js +++ b/content/_code-samples/build-a-wallet/desktop-js/6_styling.js @@ -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', () => { diff --git a/content/_code-samples/build-a-wallet/desktop-js/7_send-xrp.js b/content/_code-samples/build-a-wallet/desktop-js/7_send-xrp.js index 20dae5645d..3e7020a8b8 100644 --- a/content/_code-samples/build-a-wallet/desktop-js/7_send-xrp.js +++ b/content/_code-samples/build-a-wallet/desktop-js/7_send-xrp.js @@ -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', () => { diff --git a/content/_code-samples/build-a-wallet/desktop-js/8_domain-verification.js b/content/_code-samples/build-a-wallet/desktop-js/8_domain-verification.js index d5ca9bac9a..e9b6bc33e5 100644 --- a/content/_code-samples/build-a-wallet/desktop-js/8_domain-verification.js +++ b/content/_code-samples/build-a-wallet/desktop-js/8_domain-verification.js @@ -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', () => { diff --git a/content/_code-samples/build-a-wallet/desktop-js/view/5_password.html b/content/_code-samples/build-a-wallet/desktop-js/view/5_password.html index be85f993ca..f9f43ffbbc 100644 --- a/content/_code-samples/build-a-wallet/desktop-js/view/5_password.html +++ b/content/_code-samples/build-a-wallet/desktop-js/view/5_password.html @@ -58,10 +58,11 @@
- +
+
diff --git a/content/_code-samples/build-a-wallet/desktop-js/view/5_preload.js b/content/_code-samples/build-a-wallet/desktop-js/view/5_preload.js index b51605e5ae..a142ed5b08 100644 --- a/content/_code-samples/build-a-wallet/desktop-js/view/5_preload.js +++ b/content/_code-samples/build-a-wallet/desktop-js/view/5_preload.js @@ -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) => { diff --git a/content/_code-samples/build-a-wallet/desktop-js/view/5_renderer.js b/content/_code-samples/build-a-wallet/desktop-js/view/5_renderer.js index cf243c6618..8903d62295 100644 --- a/content/_code-samples/build-a-wallet/desktop-js/view/5_renderer.js +++ b/content/_code-samples/build-a-wallet/desktop-js/view/5_renderer.js @@ -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 diff --git a/content/_code-samples/build-a-wallet/desktop-js/view/6_styling.html b/content/_code-samples/build-a-wallet/desktop-js/view/6_styling.html index 3e81a303e0..ffafdc812e 100644 --- a/content/_code-samples/build-a-wallet/desktop-js/view/6_styling.html +++ b/content/_code-samples/build-a-wallet/desktop-js/view/6_styling.html @@ -102,10 +102,11 @@
- +
+
diff --git a/content/_code-samples/build-a-wallet/desktop-js/view/7_preload.js b/content/_code-samples/build-a-wallet/desktop-js/view/7_preload.js index cff6964015..567609034f 100644 --- a/content/_code-samples/build-a-wallet/desktop-js/view/7_preload.js +++ b/content/_code-samples/build-a-wallet/desktop-js/view/7_preload.js @@ -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) }, diff --git a/content/_code-samples/build-a-wallet/desktop-js/view/7_renderer.js b/content/_code-samples/build-a-wallet/desktop-js/view/7_renderer.js index 4e2a7824f7..306db09768 100644 --- a/content/_code-samples/build-a-wallet/desktop-js/view/7_renderer.js +++ b/content/_code-samples/build-a-wallet/desktop-js/view/7_renderer.js @@ -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() }); diff --git a/content/_code-samples/build-a-wallet/desktop-js/view/7_send-xrp.html b/content/_code-samples/build-a-wallet/desktop-js/view/7_send-xrp.html index bab91547f2..fa11a71b71 100644 --- a/content/_code-samples/build-a-wallet/desktop-js/view/7_send-xrp.html +++ b/content/_code-samples/build-a-wallet/desktop-js/view/7_send-xrp.html @@ -138,11 +138,12 @@
- +
- + +
diff --git a/content/_code-samples/build-a-wallet/desktop-js/view/8_domain-verification.html b/content/_code-samples/build-a-wallet/desktop-js/view/8_domain-verification.html index 7a92e181cf..96b744d556 100644 --- a/content/_code-samples/build-a-wallet/desktop-js/view/8_domain-verification.html +++ b/content/_code-samples/build-a-wallet/desktop-js/view/8_domain-verification.html @@ -141,11 +141,12 @@
- +
- + +
diff --git a/content/_code-samples/build-a-wallet/desktop-js/view/8_preload.js b/content/_code-samples/build-a-wallet/desktop-js/view/8_preload.js index 0ca1e086cc..516b92a70d 100644 --- a/content/_code-samples/build-a-wallet/desktop-js/view/8_preload.js +++ b/content/_code-samples/build-a-wallet/desktop-js/view/8_preload.js @@ -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) }, diff --git a/content/_code-samples/build-a-wallet/desktop-js/view/8_renderer.js b/content/_code-samples/build-a-wallet/desktop-js/view/8_renderer.js index 53509b8143..7992aa1e89 100644 --- a/content/_code-samples/build-a-wallet/desktop-js/view/8_renderer.js +++ b/content/_code-samples/build-a-wallet/desktop-js/view/8_renderer.js @@ -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() }); diff --git a/content/tutorials/build-apps/build-a-desktop-wallet-in-javascript.md b/content/tutorials/build-apps/build-a-desktop-wallet-in-javascript.md index 25be5f5d4a..947fa3792f 100644 --- a/content/tutorials/build-apps/build-a-desktop-wallet-in-javascript.md +++ b/content/tutorials/build-apps/build-a-desktop-wallet-in-javascript.md @@ -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', {
- + +
@@ -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() }); ```