Fix send-only wallet save after device sync enabled (#1732)

* Rename walletData to recvConfig

* Use nested upsert during wallet update
This commit is contained in:
ekzyis 2024-12-19 18:31:11 +01:00 committed by GitHub
parent e4ca2d6e07
commit fdbe14d195
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 9 additions and 9 deletions

View File

@ -786,7 +786,7 @@ async function upsertWallet (
} }
} }
const { id, enabled, priority, ...walletData } = data const { id, enabled, priority, ...recvConfig } = data
const txs = [] const txs = []
@ -806,13 +806,13 @@ async function upsertWallet (
data: { data: {
enabled, enabled,
priority, priority,
// client only wallets has no walletData // client only wallets have no receive config and thus don't have their own table
...(Object.keys(walletData).length > 0 ...(Object.keys(recvConfig).length > 0
? { ? {
[wallet.field]: { [wallet.field]: {
update: { upsert: {
where: { walletId: Number(id) }, create: recvConfig,
data: walletData update: recvConfig
} }
} }
} }
@ -851,8 +851,8 @@ async function upsertWallet (
priority, priority,
userId: me.id, userId: me.id,
type: wallet.type, type: wallet.type,
// client only wallets has no walletData // client only wallets have no receive config and thus don't have their own table
...(Object.keys(walletData).length > 0 ? { [wallet.field]: { create: walletData } } : {}), ...(Object.keys(recvConfig).length > 0 ? { [wallet.field]: { create: recvConfig } } : {}),
...(vaultEntries ...(vaultEntries
? { ? {
vaultEntries: { vaultEntries: {
@ -876,7 +876,7 @@ async function upsertWallet (
) )
} }
if (canReceive({ def: walletDef, config: walletData })) { if (canReceive({ def: walletDef, config: recvConfig })) {
txs.push( txs.push(
models.walletLog.createMany({ models.walletLog.createMany({
data: { data: {