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>
52 lines
1.4 KiB
TypeScript
52 lines
1.4 KiB
TypeScript
import * as admin from 'firebase-admin'
|
|
|
|
import { initAdmin } from 'shared/init-admin'
|
|
initAdmin()
|
|
|
|
import { PrivateUser, User } from 'common/user'
|
|
import { STARTING_BALANCE } from 'common/economy'
|
|
import { getDefaultNotificationPreferences } from 'common/user-notification-preferences'
|
|
|
|
const firestore = admin.firestore()
|
|
|
|
async function main() {
|
|
const snap = await firestore.collection('users').get()
|
|
const users = snap.docs.map((d) => d.data() as User)
|
|
|
|
for (const user of users) {
|
|
const fbUser = await admin.auth().getUser(user.id)
|
|
const email = fbUser.email
|
|
const privateUser: PrivateUser = {
|
|
id: user.id,
|
|
email,
|
|
notificationPreferences: getDefaultNotificationPreferences(),
|
|
blockedUserIds: [],
|
|
blockedByUserIds: [],
|
|
blockedContractIds: [],
|
|
blockedGroupSlugs: [],
|
|
}
|
|
|
|
if (user.totalDeposits === undefined) {
|
|
await firestore
|
|
.collection('users')
|
|
.doc(user.id)
|
|
.update({ totalDeposits: STARTING_BALANCE })
|
|
|
|
console.log('set starting balance for:', user.username)
|
|
}
|
|
|
|
try {
|
|
await firestore
|
|
.collection('private-users')
|
|
.doc(user.id)
|
|
.create(privateUser)
|
|
|
|
console.log('created private user for:', user.username)
|
|
} catch (_) {
|
|
// private user already created
|
|
}
|
|
}
|
|
}
|
|
|
|
if (require.main === module) main().then(() => process.exit())
|