predikt/oracle/backend/scripts/backfill-stripe-purchase-txns.ts
caelum0x 2b68bde5d5 Predikt: full Polymarket-style prediction market — web + mobile + on-chain + bots
Working tree is now the canonical repo. Off-chain play-money + trustless on-chain
(FPMM AMM + CLOB via UMA settlement), AI market factory, creator/social/distribution,
mobile shell + push, one-command demo + deploy-kit. Secrets excluded (see ENV-AND-KEYS.md).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-06 23:29:50 +03:00

49 lines
1.2 KiB
TypeScript

import { ManaPurchaseTxn } from 'common/txn'
import * as admin from 'firebase-admin'
import { initAdmin } from 'shared/init-admin'
initAdmin()
const firestore = admin.firestore()
async function doIt() {
const purchases = await firestore
.collection('stripe-transactions')
.where('timestamp', '<', 1691610957301)
.select('manticDollarQuantity', 'userId', 'timestamp')
.get()
if (purchases.empty) {
throw new Error('No purchases found.')
}
await firestore.runTransaction(async (trans) => {
purchases.docs.forEach((doc) => {
const purchase = doc.data()
const { manticDollarQuantity, userId, timestamp } = purchase
// console.log({ manticDollarQuantity, userId, timestamp })
const txnRef = firestore.collection('txns/').doc()
const txn: ManaPurchaseTxn = {
id: txnRef.id,
fromId: 'EXTERNAL',
fromType: 'BANK',
toId: userId,
toType: 'USER',
amount: manticDollarQuantity,
token: 'M$',
category: 'MANA_PURCHASE',
data: {
stripeTransactionId: doc.id,
type: 'stripe',
},
createdTime: timestamp,
}
trans.create(txnRef, txn)
})
})
}
if (require.main === module) {
doIt()
}