Skip to content

Commit

Permalink
User Gift Script
Browse files Browse the repository at this point in the history
  • Loading branch information
casesandberg committed Aug 31, 2024
1 parent 722195d commit 4df79d0
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions packages/database/scripts/send-user-gift.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import Decimal from 'decimal.js'
import { createHouseUserGiftTransaction } from '@play-money/finance/lib/createHouseUserGiftTransaction'
import { getUserById } from '@play-money/users/lib/getUserById'
import db from '../prisma'

const userId = 'cm0ioq1nl0000v2k9p427yejq'
const amount = new Decimal(0)

async function main() {
try {
const user = await getUserById({ id: userId })

if (user.primaryAccountId) {
await createHouseUserGiftTransaction({ userId: user.id, amount, initiatorId: '' })

console.log(`Gifted user ${userId} ${amount}`)
}
} catch (fetchError) {
const error = fetchError as Error
console.error(`An error occurred while sending user gift: ${error.message}`)
} finally {
await db.$disconnect()
console.log('Database connection closed.')
}
}

main().catch((e) => {
const error = e as Error
console.error(`Unexpected error: ${error.message}`)
process.exit(1)
})

0 comments on commit 4df79d0

Please sign in to comment.