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

Conversation

AlexanderBuzz
Copy link
Contributor

No description provided.

@AlexanderBuzz
Copy link
Contributor Author

@JST5000 @mDuo13 This is the "JavaScript Desktop Wallet" in a new branch without all those hiccups

@AlexanderBuzz
Copy link
Contributor Author

AlexanderBuzz commented Jun 20, 2023

@SocketSecurity ignore [email protected]

@socket-security
Copy link

socket-security bot commented Jun 20, 2023

👍 Dependency issues cleared. Learn more about Socket for GitHub ↗︎

This PR previously contained dependency changes with security issues that have been resolved, removed, or ignored.

@socket-security
Copy link

socket-security bot commented Jun 20, 2023

New dependencies detected. Learn more about Socket for GitHub ↗︎

Packages Version New capabilities Transitives Size Publisher
node-fetch 2.6.12 network +3 493 kB node-fetch-bot
async 3.2.4 None +0 821 kB hargasinski
toml 3.0.0 filesystem +0 144 kB binarymuse
electron 22.3.2 network, filesystem, shell, environment +50 5.89 MB electron-nightly

@AlexanderBuzz
Copy link
Contributor Author

I'm currently reworking the steps to "code along" style, testing the tutorial myself to make sure everything works. I will drop you a note when I'm done which will also take care of the issues that are still open.

@AlexanderBuzz
Copy link
Contributor Author

@JST5000 1-7 is in, I've even played it through myself, repo here: https://github.com/AlexanderBuzz/xrpl-dev-desktop-wallet. Contains one commit per step, so it should work just from the explanation without jumping to external files.

@AlexanderBuzz
Copy link
Contributor Author

@JST5000 I forgot to push, now all steps are in.

@JST5000
Copy link
Contributor

JST5000 commented Jul 7, 2023

Hoping to review tomorrow :)

@JST5000
Copy link
Contributor

JST5000 commented Aug 11, 2023

Three remaining comments, but seems solid. I reached out to my teammate for next steps - once you've resolved those issues I'm happy to approve though!

@AlexanderBuzz
Copy link
Contributor Author

@JST5000 Ok, everything done, I left the bootstrap issue open for review.

@mDuo13 mDuo13 self-assigned this Aug 14, 2023
@JST5000
Copy link
Contributor

JST5000 commented Aug 15, 2023

One last comment from me - There's an error check which would be super helpful to avoid the app performing very oddly when entering the wrong password right here: https://github.com/XRPLF/xrpl-dev-portal/pull/1964/files/183bed65b131bc7c12bca00bb414a77822eb8742#r1283698777

@AlexanderBuzz
Copy link
Contributor Author

AlexanderBuzz commented Aug 15, 2023

@JST5000 I've added that check, as simple as possible, in order to bloat this mote than necessary. Next thing to add would be a state manager :)

Copy link
Collaborator

@mDuo13 mDuo13 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was making good progress through the tutorial, fixing a couple typos and suggesting some non-critical improvements to the wording, until I got to step 4, where I found a big problem.

This tutorial, as written, creates a wallet that is vulnerable to the partial payments exploit because it uses the transaction's Amount field rather than delivered_amount. That needs to change. I also noticed some other discrepancies that stopped me at step 4.

It feels really close, but I definitely can't approve this until the vulnerability is fixed.

Comment on lines +699 to +702
// Step 4 code additions - start
const transactions = prepareTxData([{tx: transaction.transaction}])
appWindow.webContents.send('update-transaction-data', transactions)
// Step 4 code additions - end
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This part doesn't seem to be enough on its own. Comparing mine to the version of index.js in 4-tx-history/, I'm missing the "Initial Transaction Request" section (the steps as called out in the tutorial never have you add it) and I'm not sure if that or something else is why I was getting a ReferenceError: transaction is not defined error at this stage, and the transaction table not populating.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It vanished from the tutorial somehow, I've re-added it

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think these changes got pushed to the branch—it looks like they're still missing here.

@mDuo13
Copy link
Collaborator

mDuo13 commented Aug 19, 2023

P.S. the other JS wallet tutorial has a similar problem, although it was less obvious because it only says "Amount" rather than "Amount delivered". I've opened #2075 to get that one fixed ASAP as well.

@mDuo13 mDuo13 assigned AlexanderBuzz and unassigned mDuo13 Aug 30, 2023
@AlexanderBuzz
Copy link
Contributor Author

@mDuo13 I'll fix that when in back from APEX.

@AlexanderBuzz
Copy link
Contributor Author

Continuing today, but we should see that we get a lid on this now. With the squashed branch from a couple of weeks ago we're at over 350 commits. Don't know why this bounty is expected to provide 10x the value it is valued at.

Copy link
Collaborator

@mDuo13 mDuo13 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good stuff! I still ran into a couple problems when running through the tutorial, but at this point it's close enough that I'm happy to resolve them myself as I merge this. Thanks so much for your efforts! For what it's worth, I've put in a word to get you a bonus since the level of effort you put into this bounty was above and beyond.

Comment on lines +17 to +27
// Step 3 - Section start - this remains as it is, the rest is new
const ledgerIndexEl = document.getElementById('ledger-index')
const ledgerHashEl = document.getElementById('ledger-hash')
const ledgerCloseTimeEl = document.getElementById('ledger-close-time')

window.electronAPI.onUpdateLedgerData((_event, ledger) => {
ledgerIndexEl.innerText = ledger.ledgerIndex
ledgerHashEl.innerText = ledger.ledgerHash
ledgerCloseTimeEl.innerText = ledger.ledgerCloseTime
})
// Step 3 - Section end
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't actually remain "as it is" from the previous step, which uses snake_case fields like ledger.ledger_index instead of camelCase fields like the ledger.ledgerIndex fields now being passed in from prepareLedgerData(...).

Probably the easiest fix is to tell the user to replace the whole file.

Suggested change
// Step 3 - Section start - this remains as it is, the rest is new
const ledgerIndexEl = document.getElementById('ledger-index')
const ledgerHashEl = document.getElementById('ledger-hash')
const ledgerCloseTimeEl = document.getElementById('ledger-close-time')
window.electronAPI.onUpdateLedgerData((_event, ledger) => {
ledgerIndexEl.innerText = ledger.ledgerIndex
ledgerHashEl.innerText = ledger.ledgerHash
ledgerCloseTimeEl.innerText = ledger.ledgerCloseTime
})
// Step 3 - Section end
const ledgerIndexEl = document.getElementById('ledger-index')
const ledgerHashEl = document.getElementById('ledger-hash')
const ledgerCloseTimeEl = document.getElementById('ledger-close-time')
window.electronAPI.onUpdateLedgerData((_event, ledger) => {
ledgerIndexEl.innerText = ledger.ledgerIndex
ledgerHashEl.innerText = ledger.ledgerHash
ledgerCloseTimeEl.innerText = ledger.ledgerCloseTime
})

<form method="dialog">
```

The table here will be filled dynamically with the accounts transactions.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix typo

Suggested change
The table here will be filled dynamically with the accounts transactions.
The table here will be filled dynamically with the account's transactions.

Comment on lines +699 to +702
// Step 4 code additions - start
const transactions = prepareTxData([{tx: transaction.transaction}])
appWindow.webContents.send('update-transaction-data', transactions)
// Step 4 code additions - end
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think these changes got pushed to the branch—it looks like they're still missing here.

confirmed: transaction.tx.date,
type: transaction.tx.TransactionType,
from: transaction.tx.Account,
to: transaction.tx.Destination,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this function can get passed any type of transaction, we need to handle transactions that don't have a Destination field. This will return the string - if the field is undefined:

Suggested change
to: transaction.tx.Destination,
to: transaction.tx.Destination ?? "-",

}

const getDisplayableAmount = (rawAmount) => {
if (rawAmount === 'unavailable') {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar to above, not all transactions have a delivered_amount field. (There are ones that don't deliver value, like AccountSet for example, and ones that don't have it implemented like EscrowFinish.)

The browser wallet handles this in the code that calls this function, but for this tutorial I think it's easier to handle it here by adding a case for undefined:

Suggested change
if (rawAmount === 'unavailable') {
if (rawAmount === undefined) {
// Not all transaction types have delivered_amount
return "-"
} else if (rawAmount === 'unavailable') {

@mDuo13 mDuo13 merged commit 3a8da51 into XRPLF:master Sep 23, 2023
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants