1234567891011121314151617181920212223242526272829 |
- import express from 'express'
- import { PKMapping } from './singletons'
- import { ethers, getIndexedAccountPath } from 'ethers'
- import { CreateBridgeTaskJob } from './jobs/CreateBridgeTaskJob'
- import { BridgeJob } from './jobs/BridgeJob'
- import { ConfirmJob } from './jobs/ConfirmJob'
- const app = express()
- const port = 9900
- app.use(express.json())
- app.post('/start', (req, res) => {
- const { phrases, count } = req.body
- const generateCount = count ?? 500
- if (!phrases) throw new Error('phrases is required')
- PKMapping.instance.clear()
- for (let i = 0; i < generateCount; i++) {
- const wallet = ethers.HDNodeWallet.fromPhrase(phrases, null, getIndexedAccountPath(i))
- PKMapping.instance.set(wallet.address, wallet.privateKey)
- }
- res.send('OK')
- })
- app.listen(port, () => {
- console.log(`start listening at http://localhost:${port}`)
- })
- new CreateBridgeTaskJob().start('*/5 * * * *')
- new BridgeJob().start('* * * * *')
- new ConfirmJob().start('* * * * *')
|