-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUtilities.js
More file actions
30 lines (25 loc) · 791 Bytes
/
Utilities.js
File metadata and controls
30 lines (25 loc) · 791 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
require('dotenv/config')
// XUMM related
const { XummSdk } = require('xumm-sdk')
const xumm = new XummSdk(process.env.XUMM_API_KEY, process.env.XUMM_API_SECRET)
const getxumm = () => {
return xumm
}
// Wallet related
const userSchema = require('./schemas/userSchema')
let Wallets = new Map()
const reloadWallets = async () => {
const users = await userSchema.find()
if (userSchema.length < 1) return
for (const user of users) {
Wallets.set(user._id, user.wallet)
}
}
const addWallet = async (user, wallet) => {
Wallets.set(user, wallet)
await userSchema.findOneAndUpdate({_id: user }, { wallet: wallet }, { upsert: true })
}
const getWallet = (user)=> {
return Wallets.get(user)
}
module.exports = { getxumm, reloadWallets, addWallet, getWallet }