Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Re-added code to clean branch (JavaScript Desktop Wallet) #1964

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
94 commits
Select commit Hold shift + click to select a range
b96d3a3
Re-added code to clean branch
AlexanderBuzz Jun 20, 2023
84d9a3c
Update content/tutorials/build-apps/build-a-desktop-wallet-in-javascr…
AlexanderBuzz Jul 1, 2023
5d17e9e
Update content/tutorials/build-apps/build-a-desktop-wallet-in-javascr…
AlexanderBuzz Jul 1, 2023
250a9c7
Update content/tutorials/build-apps/build-a-desktop-wallet-in-javascr…
AlexanderBuzz Jul 1, 2023
3853b76
Update content/tutorials/build-apps/build-a-desktop-wallet-in-javascr…
AlexanderBuzz Jul 1, 2023
b9eabf2
Update content/tutorials/build-apps/build-a-desktop-wallet-in-javascr…
AlexanderBuzz Jul 1, 2023
2fd5bb4
Update content/tutorials/build-apps/build-a-desktop-wallet-in-javascr…
AlexanderBuzz Jul 1, 2023
3d9a3ca
Restructured Step 0 + 1 to "code along" style
AlexanderBuzz Jul 3, 2023
bad6ce5
Restructured Step 0 + 1 to "code along" style
AlexanderBuzz Jul 3, 2023
b46e8a6
Restructured Step 2 - 7 to "code along" style
AlexanderBuzz Jul 5, 2023
f19b4b6
Restructured Step 8 to "code along" style
AlexanderBuzz Jul 6, 2023
0ccaee2
Update content/tutorials/build-apps/build-a-desktop-wallet-in-javascr…
AlexanderBuzz Jul 10, 2023
c251289
Update content/tutorials/build-apps/build-a-desktop-wallet-in-javascr…
AlexanderBuzz Jul 10, 2023
b6b4ff1
Update content/tutorials/build-apps/build-a-desktop-wallet-in-javascr…
AlexanderBuzz Jul 10, 2023
6aeb023
Update content/tutorials/build-apps/build-a-desktop-wallet-in-javascr…
AlexanderBuzz Jul 10, 2023
4dc145f
Update content/tutorials/build-apps/build-a-desktop-wallet-in-javascr…
AlexanderBuzz Jul 10, 2023
c70d3f5
Update content/tutorials/build-apps/build-a-desktop-wallet-in-javascr…
AlexanderBuzz Jul 10, 2023
7176e17
Update content/tutorials/build-apps/build-a-desktop-wallet-in-javascr…
AlexanderBuzz Jul 10, 2023
ea38cc9
Update content/tutorials/build-apps/build-a-desktop-wallet-in-javascr…
AlexanderBuzz Jul 10, 2023
5097179
Update content/tutorials/build-apps/build-a-desktop-wallet-in-javascr…
AlexanderBuzz Jul 10, 2023
4361638
Fixed typos
AlexanderBuzz Jul 10, 2023
49dc9c2
Added description of expected application behavior on startup (for ea…
AlexanderBuzz Jul 10, 2023
e223f6a
Split description in Step 2 for more clarity
AlexanderBuzz Jul 10, 2023
3e719ec
Fixed typo
AlexanderBuzz Jul 10, 2023
b4cf2fe
Fixed ambivalent formatting issue in Step 2
AlexanderBuzz Jul 10, 2023
11d9ea8
Update content/tutorials/build-apps/build-a-desktop-wallet-in-javascr…
AlexanderBuzz Jul 13, 2023
11b2695
Removed reset button from HTML dialog elements
AlexanderBuzz Jul 13, 2023
27de169
Fixed typo in tutorial file reference
AlexanderBuzz Jul 13, 2023
04d95be
Update content/tutorials/build-apps/build-a-desktop-wallet-in-javascr…
AlexanderBuzz Jul 13, 2023
afdbc75
Fixed typos in tutorial
AlexanderBuzz Jul 13, 2023
69e49df
Clarified preload.js description in Step 4
AlexanderBuzz Jul 13, 2023
e7f8ebf
Merge branch 'Bounties-JavaScriptSamples-DesktopWallet' of https://gi…
AlexanderBuzz Jul 13, 2023
183bed6
Added Developer Tools Tip
AlexanderBuzz Jul 13, 2023
b8bb488
Update content/_code-samples/build-a-wallet/desktop-js/view/4_tx-hist…
AlexanderBuzz Jul 27, 2023
0d94dc0
Fixed accidentally deleted submit-button
AlexanderBuzz Jul 27, 2023
85c952d
Update content/tutorials/build-apps/build-a-desktop-wallet-in-javascr…
AlexanderBuzz Jul 27, 2023
a0092c2
Update content/tutorials/build-apps/build-a-desktop-wallet-in-javascr…
AlexanderBuzz Jul 27, 2023
78d2ef6
Update content/tutorials/build-apps/build-a-desktop-wallet-in-javascr…
AlexanderBuzz Jul 27, 2023
8ce2cce
Update content/tutorials/build-apps/build-a-desktop-wallet-in-javascr…
AlexanderBuzz Jul 27, 2023
76fa3cd
Update content/tutorials/build-apps/build-a-desktop-wallet-in-javascr…
AlexanderBuzz Jul 27, 2023
147165c
Update content/tutorials/build-apps/build-a-desktop-wallet-in-javascr…
AlexanderBuzz Jul 27, 2023
3022672
Update content/tutorials/build-apps/build-a-desktop-wallet-in-javascr…
AlexanderBuzz Jul 27, 2023
eef42f3
Update content/tutorials/build-apps/build-a-desktop-wallet-in-javascr…
AlexanderBuzz Jul 27, 2023
c7d0c39
Update content/tutorials/build-apps/build-a-desktop-wallet-in-javascr…
AlexanderBuzz Jul 27, 2023
4393210
Update content/tutorials/build-apps/build-a-desktop-wallet-in-javascr…
AlexanderBuzz Jul 27, 2023
5b0b75a
Update content/tutorials/build-apps/build-a-desktop-wallet-in-javascr…
AlexanderBuzz Jul 27, 2023
d39ea74
Added "Change Seed" button
AlexanderBuzz Jul 27, 2023
99538a3
Fixed background color issue when scrolling left/right
AlexanderBuzz Jul 28, 2023
a5e2c9c
Improved explanation
AlexanderBuzz Jul 28, 2023
64cca16
Added instructions on which code to remove in Step 5
AlexanderBuzz Jul 28, 2023
017623b
Update content/tutorials/build-apps/build-a-desktop-wallet-in-javascr…
AlexanderBuzz Jul 28, 2023
49c5997
Improved Step 7
AlexanderBuzz Jul 28, 2023
767ab3d
Improved Step 8 instructions
AlexanderBuzz Jul 28, 2023
614c1d0
Removed text doublet in Step 8
AlexanderBuzz Jul 28, 2023
90b3feb
Removed X-Addresses sction in Step 8
AlexanderBuzz Jul 28, 2023
8bbccb9
Added status check in .toml file handling
AlexanderBuzz Jul 30, 2023
f1de2b6
Switched "Next Steps" for "Summary"
AlexanderBuzz Jul 30, 2023
cb629d1
Removed section (lsfDisallowFlag) as requested
AlexanderBuzz Jul 30, 2023
729687b
Changed folder structure
AlexanderBuzz Jul 31, 2023
781cf35
Changed file names / reference file consistency
AlexanderBuzz Jul 31, 2023
a957209
Update content/tutorials/build-apps/build-a-desktop-wallet-in-javascr…
AlexanderBuzz Aug 7, 2023
b86db48
Update content/tutorials/build-apps/build-a-desktop-wallet-in-javascr…
AlexanderBuzz Aug 7, 2023
a07e334
Update content/tutorials/build-apps/build-a-desktop-wallet-in-javascr…
AlexanderBuzz Aug 7, 2023
ba3a565
Update content/tutorials/build-apps/build-a-desktop-wallet-in-javascr…
AlexanderBuzz Aug 7, 2023
da5fbfd
Update content/tutorials/build-apps/build-a-desktop-wallet-in-javascr…
AlexanderBuzz Aug 7, 2023
38f69fe
Update content/tutorials/build-apps/build-a-desktop-wallet-in-javascr…
AlexanderBuzz Aug 7, 2023
6a3abde
Update content/tutorials/build-apps/build-a-desktop-wallet-in-javascr…
AlexanderBuzz Aug 7, 2023
d167deb
Update content/tutorials/build-apps/build-a-desktop-wallet-in-javascr…
AlexanderBuzz Aug 7, 2023
5140533
Update content/tutorials/build-apps/build-a-desktop-wallet-in-javascr…
AlexanderBuzz Aug 7, 2023
a180574
Update content/tutorials/build-apps/build-a-desktop-wallet-in-javascr…
AlexanderBuzz Aug 7, 2023
da186bd
Update content/tutorials/build-apps/build-a-desktop-wallet-in-javascr…
AlexanderBuzz Aug 7, 2023
b7cf61d
Removed unused/buggy accountReserve
AlexanderBuzz Aug 7, 2023
d087aa2
Fixed missing "Change seed" button in tutorial
AlexanderBuzz Aug 7, 2023
5b00e68
Fixed misleading section markers
AlexanderBuzz Aug 7, 2023
0a21d22
Consolidated directory handling, added warning to tutorial
AlexanderBuzz Aug 7, 2023
f6e54d6
Fixed "duplicate transaction display" bug
AlexanderBuzz Aug 7, 2023
0764442
Fixed "duplicate transaction display" bug
AlexanderBuzz Aug 7, 2023
a2d3810
Added to summary
AlexanderBuzz Aug 7, 2023
cd689da
Added image to summary
AlexanderBuzz Aug 7, 2023
f57a654
Clarified how to include bootstrap
AlexanderBuzz Aug 14, 2023
1c5737f
Directly linked bootrap includes
AlexanderBuzz Aug 14, 2023
66908d0
Clarified Step 1 instructions
AlexanderBuzz Aug 14, 2023
742e892
Clarified Step 1 instructions
AlexanderBuzz Aug 15, 2023
2b7716f
Update content/tutorials/build-apps/build-a-desktop-wallet-in-javascr…
AlexanderBuzz Sep 18, 2023
da230d4
Update content/tutorials/build-apps/build-a-desktop-wallet-in-javascr…
AlexanderBuzz Sep 18, 2023
112c404
Update content/tutorials/build-apps/build-a-desktop-wallet-in-javascr…
AlexanderBuzz Sep 18, 2023
59462b1
Update content/tutorials/build-apps/build-a-desktop-wallet-in-javascr…
AlexanderBuzz Sep 18, 2023
58e410b
Update content/tutorials/build-apps/build-a-desktop-wallet-in-javascr…
AlexanderBuzz Sep 18, 2023
ac9d9c7
Update content/tutorials/build-apps/build-a-desktop-wallet-in-javascr…
AlexanderBuzz Sep 18, 2023
2f8f7d9
Update content/tutorials/build-apps/build-a-desktop-wallet-in-javascr…
AlexanderBuzz Sep 18, 2023
2fcab18
- Fixed partial payment exploit
AlexanderBuzz Sep 22, 2023
ff65431
- Fixed snippet markers in tutorial for Step 3
AlexanderBuzz Sep 22, 2023
03e4596
- Re-adde missing Snippet to step 4 intsructions
AlexanderBuzz Sep 22, 2023
3a8da51
JS Desktop Wallet: edits per review
mDuo13 Sep 23, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
132 changes: 132 additions & 0 deletions content/_code-samples/build-a-wallet/desktop-js/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*
.pnpm-debug.log*

# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage
*.lcov

# nyc test coverage
.nyc_output

# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules/
jspm_packages/

# Snowpack dependency directory (https://snowpack.dev/)
web_modules/

# TypeScript cache
*.tsbuildinfo

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Optional stylelint cache
.stylelintcache

# Microbundle cache
.rpt2_cache/
.rts2_cache_cjs/
.rts2_cache_es/
.rts2_cache_umd/

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variable files
.env
.env.development.local
.env.test.local
.env.production.local
.env.local

# parcel-bundler cache (https://parceljs.org/)
.cache
.parcel-cache

# Next.js build output
.next
out

# Nuxt.js build / generate output
.nuxt
dist

# Gatsby files
.cache/
# Comment in the public line in if your project uses Gatsby and not Next.js
# https://nextjs.org/blog/next-9-1#public-directory-support
# public

# vuepress build output
.vuepress/dist

# vuepress v2.x temp and cache directory
.temp
.cache

# Docusaurus cache and generated files
.docusaurus

# Serverless directories
.serverless/

# FuseBox cache
.fusebox/

# DynamoDB Local files
.dynamodb/

# TernJS port file
.tern-port

# Stores VSCode versions used for testing VSCode extensions
.vscode-test

# yarn v2
.yarn/cache
.yarn/unplugged
.yarn/build-state.yml
.yarn/install-state.gz
.pnp.*

Wallet/
27 changes: 27 additions & 0 deletions content/_code-samples/build-a-wallet/desktop-js/0-hello/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
const { app, BrowserWindow } = require('electron')

const path = require('path')

/**
* This is our main function, it creates our application window, preloads the code we will need to communicate
* between the renderer Process and the main Process, loads a layout and performs the main logic
*/
const createWindow = () => {

// Creates the application window
const appWindow = new BrowserWindow({
width: 1024,
height: 768
})

// Loads a layout
appWindow.loadFile(path.join(__dirname, 'view', 'template.html'))

return appWindow
}

// Here we have to wait for the application to signal that it is ready
// to execute our code. In this case we just create a main window.
app.whenReady().then(() => {
createWindow()
})
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<!DOCTYPE html>
<html>

<head>
<meta charset="UTF-8" />
<meta http-equiv="Content-Security-Policy" content="default-src 'self'; script-src 'self'" />
<meta http-equiv="X-Content-Security-Policy" content="default-src 'self'; script-src 'self'" />
<title>XRPL Wallet Tutorial (JavaScript / Electron)</title>
</head>

<body>

<h3>Build a XRPL Wallet - Part 0/8</h3>
<span>Hello world!</span>

</body>

</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
const { app, BrowserWindow } = require('electron')

const path = require('path')
const xrpl = require("xrpl")

const TESTNET_URL = "wss://s.altnet.rippletest.net:51233"

/**
* This function creates a WebService client, which connects to the XRPL and fetches the latest ledger index.
*
* @returns {Promise<number>}
*/
const getValidatedLedgerIndex = async () => {
const client = new xrpl.Client(TESTNET_URL)

await client.connect()

// Reference: https://xrpl.org/ledger.html#ledger
const ledgerRequest = {
"command": "ledger",
"ledger_index": "validated"
}

const ledgerResponse = await client.request(ledgerRequest)

await client.disconnect()

return ledgerResponse.result.ledger_index
}

/**
* This is our main function, it creates our application window, preloads the code we will need to communicate
* between the renderer Process and the main Process, loads a layout and performs the main logic
*/
const createWindow = () => {

// Creates the application window
const appWindow = new BrowserWindow({
width: 1024,
height: 768,
webPreferences: {
preload: path.join(__dirname, 'view', 'preload.js'),
},
})

// Loads a layout
appWindow.loadFile(path.join(__dirname, 'view', 'template.html'))

return appWindow
}

// Here we have to wait for the application to signal that it is ready
// to execute our code. In this case we create a main window, query
// the ledger for its latest index and submit the result to the main
// window where it will be displayed
app.whenReady().then(() => {

const appWindow = createWindow()

getValidatedLedgerIndex().then((value) => {
appWindow.webContents.send('update-ledger-index', value)
})
})
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
const { contextBridge, ipcRenderer } = require('electron');

// Expose functionality from main process (aka. "backend") to be used by the renderer process(aka. "backend")
contextBridge.exposeInMainWorld('electronAPI', {
// By calling "onUpdateLedgerIndex" in the frontend process we can now attach a callback function to
// by making onUpdateLedgerIndex available at the window level.
// The subscribed function gets triggered whenever the backend process triggers the event 'update-ledger-index'
onUpdateLedgerIndex: (callback) => {
ipcRenderer.on('update-ledger-index', callback)
}
})
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
const ledgerIndexEl = document.getElementById('ledger-index')

// Here we define the callback function that performs the content update
// whenever 'update-ledger-index' is called by the main process
window.electronAPI.onUpdateLedgerIndex((_event, value) => {
ledgerIndexEl.innerText = value
})
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<!DOCTYPE html>
<html>

<head>
<meta charset="UTF-8" />
<meta http-equiv="Content-Security-Policy" content="default-src 'self'; script-src 'self'" />
<meta http-equiv="X-Content-Security-Policy" content="default-src 'self'; script-src 'self'" />
<title>XRPL Wallet Tutorial (JavaScript / Electron)</title>
</head>

<body>

<h3>Build a XRPL Wallet - Part 1/8</h3>
Latest validated ledger index: <strong id="ledger-index"></strong>

</body>

<script src="renderer.js"></script>

</html>
53 changes: 53 additions & 0 deletions content/_code-samples/build-a-wallet/desktop-js/2-async/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
const { app, BrowserWindow } = require('electron')
const path = require('path')
const xrpl = require("xrpl")

const TESTNET_URL = "wss://s.altnet.rippletest.net:51233"

/**
* This function creates our application window
*
* @returns {Electron.CrossProcessExports.BrowserWindow}
*/
const createWindow = () => {

const appWindow = new BrowserWindow({
width: 1024,
height: 768,
webPreferences: {
preload: path.join(__dirname, 'view', 'preload.js'),
},
})

appWindow.loadFile(path.join(__dirname, 'view', 'template.html'))

return appWindow
}

/**
* This function creates a XRPL client, subscribes to 'ledger' events from the XRPL and broadcasts those by
* dispatching the 'update-ledger-data' event which will be picked up by the frontend
*
* @returns {Promise<void>}
*/
const main = async () => {
const appWindow = createWindow()

const client = new xrpl.Client(TESTNET_URL)

await client.connect()

// Subscribe client to 'ledger' events
// Reference: https://xrpl.org/subscribe.html
await client.request({
"command": "subscribe",
"streams": ["ledger"]
})

// Dispatch 'update-ledger-data' event
client.on("ledgerClosed", async (ledger) => {
appWindow.webContents.send('update-ledger-data', ledger)
})
}

app.whenReady().then(main)
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
const { contextBridge, ipcRenderer } = require('electron');

contextBridge.exposeInMainWorld('electronAPI', {
onUpdateLedgerData: (callback) => {
ipcRenderer.on('update-ledger-data', callback)
}
})
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
const ledgerIndexEl = document.getElementById('ledger-index')

// Step 2 code additions - start
const ledgerHashEl = document.getElementById('ledger-hash')
const ledgerCloseTimeEl = document.getElementById('ledger-close-time')
// Step 2 code additions - end

window.electronAPI.onUpdateLedgerData((_event, value) => {
ledgerIndexEl.innerText = value.ledger_index

// Step 2 code additions - start
ledgerHashEl.innerText = value.ledger_hash
ledgerCloseTimeEl.innerText = value.ledger_time
// Step 2 code additions - end
})
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<!DOCTYPE html>
<html>

<head>
<meta charset="UTF-8" />
<meta http-equiv="Content-Security-Policy" content="default-src 'self'; script-src 'self'" />
<meta http-equiv="X-Content-Security-Policy" content="default-src 'self'; script-src 'self'" />
<title>XRPL Wallet Tutorial (JavaScript / Electron)</title>
</head>

<body>
<h3>Build a XRPL Wallet - Part 2/8</h3>
<b>Latest validated ledger stats</b><br />
Ledger Index: <strong id="ledger-index"></strong><br />
Ledger Hash: <strong id="ledger-hash"></strong><br />
Close Time: <strong id="ledger-close-time"></strong><br />
</body>

<script src="renderer.js"></script>

</html>
Loading