From 825d3c269e2fd5b339d0a75fd8bcc29ef2efa97d Mon Sep 17 00:00:00 2001
From: jojobyte <184880+jojobyte@users.noreply.github.com>
Date: Mon, 19 Feb 2024 18:24:33 -0700
Subject: [PATCH] fix(ui): :lipstick: change receive funds QR flow
---
src/components/contacts-list.js | 29 +++++++++-
src/main.js | 93 +++++++++++++++++++++++++++------
src/rigs/request-qr.js | 66 +++++++++++++++--------
src/rigs/send-confirm.js | 15 ------
src/rigs/send-or-request.js | 59 +++++++++------------
5 files changed, 175 insertions(+), 87 deletions(-)
diff --git a/src/components/contacts-list.js b/src/components/contacts-list.js
index 8b2f842..01487aa 100644
--- a/src/components/contacts-list.js
+++ b/src/components/contacts-list.js
@@ -53,7 +53,7 @@ const initialState = {
}
- ${state.footer(state)}
+ ${await state.footer(state)}
`,
item: async c => {
// console.warn('contact list item', c)
@@ -117,7 +117,32 @@ const initialState = {
`
},
- footer: state => html``,
+ footer: async state => html`
+
+ `,
slugs: {
},
elements: {
diff --git a/src/main.js b/src/main.js
index 5b6d511..68ab6b5 100644
--- a/src/main.js
+++ b/src/main.js
@@ -480,7 +480,7 @@ async function main() {
})
appDialogs.requestQr = await requestQrRig({
- mainApp, setupDialog,
+ mainApp, setupDialog, appDialogs, appState, userInfo,
})
appDialogs.pairQr = await pairQrRig({
@@ -501,22 +501,85 @@ async function main() {
if (formName === 'send_or_receive') {
event.preventDefault()
event.stopPropagation()
- let name = 'Send Funds'
+
if (fde.intent === 'receive') {
- name = 'Receive Funds'
- }
+ let receiveWallet
- await appDialogs.sendOrReceive.render({
- action: fde.intent,
- wallet,
- account: appState.account,
- // accounts,
- userInfo,
- contacts: appState.contacts,
- to: null,
- })
- appDialogs.sendOrReceive.showModal()
- // .catch(console.error)
+ if (wallet?.xpub) {
+ wallet.addressIndex = (
+ wallet?.addressIndex || 0
+ ) + 1
+ receiveWallet = await deriveWalletData(
+ appState.phrase,
+ wallet.accountIndex,
+ wallet.addressIndex,
+ )
+ }
+
+ if (receiveWallet?.xkeyId) {
+ let tmpWallet = await store.accounts.getItem(
+ receiveWallet.xkeyId,
+ )
+
+ // state.wallet =
+ let tmpAcct = await store.accounts.setItem(
+ receiveWallet.xkeyId,
+ {
+ ...tmpWallet,
+ updatedAt: (new Date()).toISOString(),
+ address: receiveWallet.address,
+ addressIndex: receiveWallet.addressIndex,
+ }
+ )
+
+ batchGenAcctAddrs(receiveWallet, tmpAcct)
+
+ console.log(
+ `${fde.intent} FROM CONTACT`,
+ {
+ stateWallet: wallet,
+ receiveWallet,
+ tmpAcct,
+ }
+ )
+
+ await appDialogs.requestQr.render(
+ {
+ name: 'Share to receive funds',
+ submitTxt: `Select a Contact`,
+ submitAlt: `Change the currently selected contact`,
+ footer: state => html`
+
+ `,
+ wallet: receiveWallet,
+ contacts: appState.contacts,
+ },
+ 'afterend',
+ )
+
+ let showRequestQR = await appDialogs.requestQr.showModal()
+ }
+ } else {
+ await appDialogs.sendOrReceive.render({
+ action: fde.intent,
+ wallet,
+ account: appState.account,
+ userInfo,
+ contacts: appState.contacts,
+ to: null,
+ })
+ appDialogs.sendOrReceive.showModal()
+ }
}
})
document.addEventListener('input', async event => {
diff --git a/src/rigs/request-qr.js b/src/rigs/request-qr.js
index 1f8b64c..da8d846 100644
--- a/src/rigs/request-qr.js
+++ b/src/rigs/request-qr.js
@@ -1,6 +1,7 @@
import { lit as html } from '../helpers/lit.js'
import { qrSvg } from '../helpers/qr.js'
import {
+ formDataEntries,
setClipboard,
openBlobSVG,
generatePaymentRequestURI,
@@ -12,7 +13,7 @@ export let requestQrRig = (async function (globals) {
'use strict';
let {
- mainApp, setupDialog,
+ mainApp, setupDialog, appDialogs, appState, userInfo,
} = globals;
let requestQr = await setupDialog(
@@ -28,16 +29,6 @@ export let requestQrRig = (async function (globals) {
closeTxt: html``,
closeAlt: `Close`,
amount: 0,
- getContact: state => {
- let to = state.contact?.info?.name
- if (!to && state.contact?.alias) {
- to = `@${state.contact?.alias}`
- }
- if (!to) {
- to = state.to
- }
- return to
- },
footer: state => html``,
@@ -60,19 +51,27 @@ export let requestQrRig = (async function (globals) {
`
},
+ aliasSelector: state => {
+ return html`
+
+ `
+ },
content: state => html`
${state.header(state)}