增加白名单
This commit is contained in:
parent
6b2bde5938
commit
6a7c3827d4
@ -7,6 +7,7 @@ import mongoose from 'mongoose'
|
||||
import { CheckIn } from 'models/chain/CheckIn'
|
||||
import { toEIP55 } from 'zutils/utils/chain.util'
|
||||
import { inertUser, insertWalletLoginLog } from 'services/fix.svr'
|
||||
import { FixAddress } from 'models/ctrl/FixAddress'
|
||||
|
||||
const dbMain = mongoose.createConnection(process.env.DB_MAIN)
|
||||
const dbChain = mongoose.createConnection(process.env.DB_CHAIN)
|
||||
@ -35,6 +36,9 @@ const insertTaskRecord = async () => {
|
||||
}
|
||||
|
||||
const parseOneRecord = async (record: any) => {
|
||||
if (!FixAddress.checkExist(record.from)) {
|
||||
return
|
||||
}
|
||||
let addressEip55 = toEIP55(record.from)
|
||||
console.log('parseOneRecord', addressEip55)
|
||||
const user = await dbCtrl.collection('users_test').findOne({ address: addressEip55 })
|
||||
|
21
src/models/ctrl/FixAddress.ts
Normal file
21
src/models/ctrl/FixAddress.ts
Normal file
@ -0,0 +1,21 @@
|
||||
import { getModelForClass, index, modelOptions, prop, Severity } from '@typegoose/typegoose'
|
||||
import { dbconn } from 'decorators/dbconn'
|
||||
import { BaseModule } from '../Base'
|
||||
|
||||
@dbconn('ctrl')
|
||||
// case insensitive unique index
|
||||
@index({ address: 1 }, { unique: true, collation: { locale: 'en', strength: 2 } })
|
||||
@modelOptions({
|
||||
schemaOptions: { collection: 'fix_addresses', timestamps: false, _id: false, strict: 'throw', versionKey: false },
|
||||
})
|
||||
export class FixAddressClass extends BaseModule {
|
||||
@prop({ required: true })
|
||||
public address: string
|
||||
|
||||
public static async checkExist(address: string): Promise<boolean> {
|
||||
let record = await FixAddress.findOne({ address }).collation({ locale: 'en', strength: 2 })
|
||||
return !!record
|
||||
}
|
||||
}
|
||||
|
||||
export const FixAddress = getModelForClass(FixAddressClass, { existingConnection: FixAddressClass.db })
|
Loading…
x
Reference in New Issue
Block a user