Skip to content

Commit 3d6d3c4

Browse files
committed
Update checkWallet
1 parent 90fc46d commit 3d6d3c4

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

worker/wallet.js

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,7 @@ import {
1212
paidActionCanceling
1313
} from './paidAction'
1414
import { payingActionConfirmed, payingActionFailed } from './payingAction'
15-
import { canReceive, getWalletByType } from '@/wallets/common'
1615
import { notifyNewStreak, notifyStreakLost } from '@/lib/webPush'
17-
import { hasVault, vaultPrismaFragments } from '@/wallets/vault'
1816

1917
export async function subscribeToWallet (args) {
2018
await subscribeToDeposits(args)
@@ -292,19 +290,20 @@ export async function checkWallet ({ data: { userId }, models }) {
292290
const pushNotifications = []
293291

294292
await models.$transaction(async tx => {
295-
// TODO: use UserWallet instead of Wallet table
296-
const wallets = await tx.wallet.findMany({
293+
const wallets = await tx.userWallet.findMany({
297294
where: {
298295
userId,
299296
enabled: true
300297
},
301-
include: vaultPrismaFragments.include()
298+
include: {
299+
protocols: true
300+
}
302301
})
303302

304303
const { hasRecvWallet: oldHasRecvWallet, hasSendWallet: oldHasSendWallet } = await tx.user.findUnique({ where: { id: userId } })
305304

306-
const newHasRecvWallet = wallets.some(({ type, wallet }) => canReceive({ def: getWalletByType(type), config: wallet }))
307-
const newHasSendWallet = wallets.some(hasVault)
305+
const newHasRecvWallet = wallets.some(({ protocols }) => protocols.some(proto => !proto.send))
306+
const newHasSendWallet = wallets.some(({ protocols }) => protocols.some(proto => proto.send))
308307

309308
await tx.user.update({
310309
where: { id: userId },

0 commit comments

Comments
 (0)