Skip to content

Commit da9bdb2

Browse files
committed
feat(data): ✨ batch gen addrs for new contact pairing
1 parent 88b0fbd commit da9bdb2

File tree

1 file changed

+25
-4
lines changed

1 file changed

+25
-4
lines changed

src/rigs/add-contact.js

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export let addContactRig = (async function (globals) {
2828
let {
2929
setupDialog, appDialogs, appState, appTools, store,
3030
mainApp, wallet, userInfo, contactsList,
31-
updateAllFunds,
31+
updateAllFunds, batchXkeyAddressGenerate, dashsight,
3232
} = globals;
3333

3434
let aliases = {}
@@ -117,6 +117,7 @@ export let addContactRig = (async function (globals) {
117117
let outgoing = {}
118118

119119
let existingContacts
120+
let contactWallet
120121

121122
if (!xkey && address) {
122123
existingContacts = appState.contacts.filter(
@@ -132,14 +133,15 @@ export let addContactRig = (async function (globals) {
132133
}
133134

134135
if (xkey) {
136+
contactWallet = await deriveWalletData(
137+
xkey,
138+
)
135139
let {
136140
xkeyId,
137141
addressKeyId,
138142
addressIndex,
139143
address: addr,
140-
} = await deriveWalletData(
141-
xkey,
142-
)
144+
} = contactWallet
143145

144146
existingContacts = appState.contacts.filter(
145147
c => c.outgoing?.[xkeyId]
@@ -197,6 +199,25 @@ export let addContactRig = (async function (globals) {
197199
target.reportValidity()
198200
return;
199201
} else {
202+
if (Object.keys(outgoing).length > 0 && contactWallet) {
203+
let contactAddrs = await batchXkeyAddressGenerate(
204+
contactWallet,
205+
contactWallet.addressIndex,
206+
)
207+
let addresses = contactAddrs.addresses.map(g => g.address)
208+
209+
let txs = await dashsight.getAllTxs(
210+
addresses
211+
)
212+
213+
// outgoing[contactWallet.xkeyId] = {
214+
// ...(outgoing[contactWallet.xkeyId] || {}),
215+
// addressIndex: contactAddrs.finalAddressIndex,
216+
// }
217+
218+
console.log('contactAddrs', {addresses, txs})
219+
}
220+
200221
newContact = await appTools.storedData.encryptItem(
201222
store.contacts,
202223
state.wallet.xkeyId,

0 commit comments

Comments
 (0)