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