-
-
Notifications
You must be signed in to change notification settings - Fork 132
Wallet v2 #2169
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
Conversation
️✅ There are no secrets present in this pull request anymore.If these secrets were true positive and are still valid, we highly recommend you to revoke them. 🦉 GitGuardian detects secrets in your source code to help developers and security teams secure the modern development process. You are seeing this because you or someone else with access to this repository has authorized GitGuardian to scan your pull request. |
8ab0a08
to
afcc412
Compare
d9af095
to
e94cfe7
Compare
412f2c6
to
690b10b
Compare
I refactored the wallet reducer in 8be0b30. Instead of storing I also fixed the flicker of 'attach wallets' -> 'unlock wallets' or 'attach wallets' -> list of wallets in 8be0b30 by adding a loading spinner while we're still determining what we want to show: ![]() With this refactor, I can now easily add another status when the wallets are unavailable instead of thinking in pages in the state. |
The useSendWallets hook was not checking if the returned send wallets are enabled. Since the components that used that hook only need to know if there is a send wallet, I replaced the useSendWallets hook with a useHasSendWallet hook.
Okay, I’m done here now. As far as I am concerned, this can be merged! |
Edit: I fixed this.When I attempt to migrate prod seed:
|
On brand new accounts, I'm being asked to unlock wallets |
Ohhh, good catch! There is a race condition in Update Pretty sure it's because of strict mode because the second
diff --git a/wallets/client/context/hooks.js b/wallets/client/context/hooks.js
index 99280325..025feb9b 100644
--- a/wallets/client/context/hooks.js
+++ b/wallets/client/context/hooks.js
@@ -121,6 +121,8 @@ export function useKeyInit () {
const loadKey = useLoadKey()
const loadOldKey = useLoadOldKey()
+ console.log('useKeyInit')
+
useEffect(() => {
if (!me?.id) return I read this now. As mentioned in that link, this is how we can deal with strict mode issues in development: useEffect(() => {
let mounted = true
async function effect() {
await Promise.resolve()
if (!mounted) return
// the following code will only run after first cleanup in strict mode
...
}
effect()
return () => { mounted = false }
}, dependencies) I've tested this by logging So by calling This looks like a hack / working against React Strict Mode instead of with it, but I think this is basically Fetching data with Effects with waiting for the cleanup before triggering the request, instead of only ignoring the response. So imo, doing this is fine when a bug is really only caused by strict mode and we know that there's no bug it's trying to reveal. Update Mhh, it actually is trying to reveal a bug: the code is prone to race conditions. To fix that, we would need to read and write the key in one transaction in a way that the second transaction does not read the key before we wrote it. Will check if IndexedDB has such functionality. |
IME: let strict mode help you. Do not hack around it. It's particularly tricky with this stateful/sideeffect initialization stuff. We need to learn a decent pattern around it imo. |
Yeah, I agree. I am using a single transaction in Since I open and close a database for each call in my refactored But the issue doesn't happen now anymore for another reason: Since I now have to check if the db is set before I run the queries and since afaict, the queries only run after strict mode went through "init db -> cleanup -> init db", the queries don't run twice at the same time anymore. I think I will have to rethink how to wrap IndexedDB properly in a hook so it doesn't limit us in important ways. Or just use a library at this point. |
The original |
Description
close #1495 fix #2234
DX for supporting a new wallet: 926c706
TODOs / Overview of Changes
Vault
table no longer contains foreign keys to wallets or usersWalletTemplate
Wallet
WalletProtocol
WalletSendNWC
,WalletRecvNWC
, ...)WalletTemplate
tableadd placeholder wallets like Phoenix?master
)(Use test payments with HODL invoices for wallet validation #1287)include wizard / multi-step formsprobably not in this PRCryptoKey
show status of wallet network tests on attach in dedicated UI instead of relying on wallet logsdon't show "logs", show wallet events like a walletthis means that there won't be multiple log messages for the same payment. we will just show the current status of a payment, just like a wallet would do.WALLETS
vsWALLET
query)WALLET
on save or detachWALLETS
if wallets changedCUSTOM
wallet intoNWC
andLN_ADDR
walletcan key hash and wallet encryption get out of sync?Test instructions
test_wallet_v2
(id 21001)sndev login test_wallet_v2
Screenshots
we now show wallets instead of protocols:
each wallet can now support multiple protocols for send or receive:
Checklist
Are your changes backwards compatible? Please answer below:
no
On a scale of 1-10 how well and how have you QA'd this change and any features it might affect? Please answer below:
8
For frontend changes: Tested on mobile, light and dark mode? Please answer below:
yes
Did you introduce any new environment variables? If so, call them out explicitly here:
no