diff --git a/content/_code-samples/build-a-wallet/desktop-js/5-password/index.js b/content/_code-samples/build-a-wallet/desktop-js/5-password/index.js index 0a73a84b6a..6cb2d56a94 100644 --- a/content/_code-samples/build-a-wallet/desktop-js/5-password/index.js +++ b/content/_code-samples/build-a-wallet/desktop-js/5-password/index.js @@ -6,7 +6,7 @@ const { initialize, subscribe, saveSaltedSeed, loadSaltedSeed } = require('../li const TESTNET_URL = "wss://s.altnet.rippletest.net:51233" -const WALLET_DIR = 'Wallet' +const WALLET_DIR = '../Wallet' const createWindow = () => { @@ -27,7 +27,7 @@ const main = async () => { const appWindow = createWindow() // Create Wallet directory in case it does not exist yet - if (!fs.existsSync(WALLET_DIR)) { + if (!fs.existsSync(path.join(__dirname, WALLET_DIR))) { fs.mkdirSync(path.join(__dirname, WALLET_DIR)); } @@ -40,9 +40,9 @@ const main = async () => { ipcMain.on('password-entered', async (event, password) => { if (!fs.existsSync(path.join(__dirname, WALLET_DIR , 'seed.txt'))) { - saveSaltedSeed('../' + WALLET_DIR, seed, password) + saveSaltedSeed(WALLET_DIR, seed, password) } else { - seed = loadSaltedSeed('../' + WALLET_DIR, password) + seed = loadSaltedSeed(WALLET_DIR, password) } const wallet = xrpl.Wallet.fromSeed(seed) diff --git a/content/_code-samples/build-a-wallet/desktop-js/6-styling/index.js b/content/_code-samples/build-a-wallet/desktop-js/6-styling/index.js index 3518b5489a..edafe8859d 100644 --- a/content/_code-samples/build-a-wallet/desktop-js/6-styling/index.js +++ b/content/_code-samples/build-a-wallet/desktop-js/6-styling/index.js @@ -6,7 +6,7 @@ const { initialize, subscribe, saveSaltedSeed, loadSaltedSeed } = require('../li const TESTNET_URL = "wss://s.altnet.rippletest.net:51233" -const WALLET_DIR = 'Wallet' +const WALLET_DIR = '../Wallet' const createWindow = () => { @@ -26,8 +26,8 @@ const createWindow = () => { const main = async () => { const appWindow = createWindow() - if (!fs.existsSync(WALLET_DIR)) { - // Create Wallet directory in case it does not exist yet + // Create Wallet directory in case it does not exist yet + if (!fs.existsSync(path.join(__dirname, WALLET_DIR))) { fs.mkdirSync(path.join(__dirname, WALLET_DIR)); } @@ -40,9 +40,9 @@ const main = async () => { ipcMain.on('password-entered', async (event, password) => { if (!fs.existsSync(path.join(__dirname, WALLET_DIR , 'seed.txt'))) { - saveSaltedSeed('../' + WALLET_DIR, seed, password) + saveSaltedSeed(WALLET_DIR, seed, password) } else { - seed = loadSaltedSeed('../' + WALLET_DIR, password) + seed = loadSaltedSeed(WALLET_DIR, password) } const wallet = xrpl.Wallet.fromSeed(seed) @@ -54,7 +54,6 @@ const main = async () => { await subscribe(client, wallet, appWindow) await initialize(client, wallet, appWindow) - }) ipcMain.on('request-seed-change', (event) => { diff --git a/content/_code-samples/build-a-wallet/desktop-js/7-send-xrp/index.js b/content/_code-samples/build-a-wallet/desktop-js/7-send-xrp/index.js index 95c4d1fd13..51ac9e82b3 100644 --- a/content/_code-samples/build-a-wallet/desktop-js/7-send-xrp/index.js +++ b/content/_code-samples/build-a-wallet/desktop-js/7-send-xrp/index.js @@ -7,7 +7,7 @@ const { sendXrp } = require('../library/7_helpers') const TESTNET_URL = "wss://s.altnet.rippletest.net:51233" -const WALLET_DIR = 'Wallet' +const WALLET_DIR = '../Wallet' const createWindow = () => { @@ -27,8 +27,8 @@ const createWindow = () => { const main = async () => { const appWindow = createWindow() - if (!fs.existsSync(WALLET_DIR)) { - // Create Wallet directory in case it does not exist yet + // Create Wallet directory in case it does not exist yet + if (!fs.existsSync(path.join(__dirname, WALLET_DIR))) { fs.mkdirSync(path.join(__dirname, WALLET_DIR)); } @@ -41,9 +41,9 @@ const main = async () => { ipcMain.on('password-entered', async (event, password) => { if (!fs.existsSync(path.join(__dirname, WALLET_DIR , 'seed.txt'))) { - saveSaltedSeed('../' + WALLET_DIR, seed, password) + saveSaltedSeed(WALLET_DIR, seed, password) } else { - seed = loadSaltedSeed('../' + WALLET_DIR, password) + seed = loadSaltedSeed(WALLET_DIR, password) } const wallet = xrpl.Wallet.fromSeed(seed) diff --git a/content/_code-samples/build-a-wallet/desktop-js/8-domain-verification/index.js b/content/_code-samples/build-a-wallet/desktop-js/8-domain-verification/index.js index 08bc493da6..3f22598770 100644 --- a/content/_code-samples/build-a-wallet/desktop-js/8-domain-verification/index.js +++ b/content/_code-samples/build-a-wallet/desktop-js/8-domain-verification/index.js @@ -8,7 +8,7 @@ const { verify } = require('../library/8_helpers') const TESTNET_URL = "wss://s.altnet.rippletest.net:51233" -const WALLET_DIR = 'Wallet' +const WALLET_DIR = '../Wallet' const createWindow = () => { @@ -28,8 +28,8 @@ const createWindow = () => { const main = async () => { const appWindow = createWindow() - if (!fs.existsSync(WALLET_DIR)) { - // Create Wallet directory in case it does not exist yet + // Create Wallet directory in case it does not exist yet + if (!fs.existsSync(path.join(__dirname, WALLET_DIR))) { fs.mkdirSync(path.join(__dirname, WALLET_DIR)); } @@ -42,9 +42,9 @@ const main = async () => { ipcMain.on('password-entered', async (event, password) => { if (!fs.existsSync(path.join(__dirname, WALLET_DIR , 'seed.txt'))) { - saveSaltedSeed('../' + WALLET_DIR, seed, password) + saveSaltedSeed(WALLET_DIR, seed, password) } else { - seed = loadSaltedSeed('../' + WALLET_DIR, password) + seed = loadSaltedSeed(WALLET_DIR, password) } const wallet = xrpl.Wallet.fromSeed(seed) 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 bf599cce34..3c1b02686a 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 @@ -23,7 +23,9 @@ To complete this tutorial, you should meet the following requirements: ### Source Code -You can find the complete source code for all of this tutorial's examples in the [code samples section of this website's repository]({{target.github_forkurl}}/tree/{{target.github_branch}}/content/_code-samples/build-a-wallet/desktop-js/). +You can find the complete source code for all of this tutorial's examples in the [code samples section of this website's repository]({{target.github_forkurl}}/tree/{{target.github_branch}}/content/_code-samples/build-a-wallet/desktop-js/). After a `npm install` in this directory you can run the application for each step as described in the `scripts` section of `package.json`, e.g, `npm run ledger-index`. + +**Caution:** As the source code is grouped into one folder for each step, you have to be careful should you copy-and-paste directly from there. Some shared imports and file operations have different directories in these examples. This goes for everything to do with `library`, `bootstrap`, and `WALLET_DIR`. ## Rationale @@ -54,8 +56,7 @@ The application in this tutorial _doesn't_ have the ability to send or trade [to use other [payment types](payment-types.html) like [Escrow](https://xrpl.org/escrow.html) or [Payment Channels](https://xrpl.org/payment-channels.html). However, it provides a foundation that you can implement those and other features on top of. -In addition to the above features, you'll also learn a bit about Events, IPC (inter-process-communication) -and asynchronous (async) code in JavaScript. +In addition to the above features, you'll also learn a bit about Events, IPC (inter-process-communication) and asynchronous (async) code in JavaScript. ## Steps @@ -830,7 +831,7 @@ const main = async () => { const appWindow = createWindow() // Create Wallet directory in case it does not exist yet - if (!fs.existsSync(WALLET_DIR)) { + if (!fs.existsSync(path.join(__dirname, WALLET_DIR))) { fs.mkdirSync(path.join(__dirname, WALLET_DIR)); }