Skip to content

Commit

Permalink
Fix send-only wallet save after device sync enabled (#1732)
Browse files Browse the repository at this point in the history
* Rename walletData to recvConfig

* Use nested upsert during wallet update
  • Loading branch information
ekzyis authored Dec 19, 2024
1 parent e4ca2d6 commit fdbe14d
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions api/resolvers/wallet.js
Original file line number Diff line number Diff line change
Expand Up @@ -786,7 +786,7 @@ async function upsertWallet (
}
}

const { id, enabled, priority, ...walletData } = data
const { id, enabled, priority, ...recvConfig } = data

const txs = []

Expand All @@ -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
}
}
}
Expand Down Expand Up @@ -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: {
Expand All @@ -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: {
Expand Down

0 comments on commit fdbe14d

Please sign in to comment.