update abi

This commit is contained in:
zhl 2023-04-10 19:36:36 +08:00
parent f2a3f494a8
commit bf03e5476c
5 changed files with 4522 additions and 3860 deletions

File diff suppressed because one or more lines are too long

View File

@ -1,9 +1,9 @@
[ [
{ {
"address": "", "address": "0xc195196351566d2c4e13563C4492fB0BdB7894Fb",
"event": "Transfer", "event": "Confirmation",
"abi": "ERC721", "abi": "BEMultiSigWallet",
"fromBlock": 0, "fromBlock": 0,
"eventProcesser": "NftTransferEvent" "eventProcesser": "ScheduleConfirmEvent"
} }
] ]

View File

@ -1,4 +1,4 @@
import { getModelForClass, DocumentType, modelOptions, mongoose, prop, Severity } from '@typegoose/typegoose' import { getModelForClass, DocumentType, modelOptions, mongoose, prop, Severity, index } from '@typegoose/typegoose'
import { BlockChain } from 'chain/BlockChain' import { BlockChain } from 'chain/BlockChain'
import { dbconn } from 'decorators/dbconn' import { dbconn } from 'decorators/dbconn'
import logger from 'logger/logger' import logger from 'logger/logger'
@ -24,6 +24,7 @@ export enum ReqTaskStatus {
} }
@dbconn() @dbconn()
@index({ scheduleId: 1 }, { unique: false })
@modelOptions({ @modelOptions({
schemaOptions: { collection: 'chain_request_task', timestamps: true }, schemaOptions: { collection: 'chain_request_task', timestamps: true },
options: { allowMixed: Severity.ALLOW }, options: { allowMixed: Severity.ALLOW },
@ -44,8 +45,8 @@ export class RequestTaskClass extends BaseModule {
@prop({ required: true, default: 0 }) @prop({ required: true, default: 0 })
public maxTryCount: number public maxTryCount: number
@prop({ type: mongoose.Schema.Types.Mixed }) @prop({ type: mongoose.Schema.Types.Mixed, default: [] })
public reqDatas: any public reqDatas: any[]
@prop({ enum: ReqTaskStatus, default: ReqTaskStatus.NOTSTART }) @prop({ enum: ReqTaskStatus, default: ReqTaskStatus.NOTSTART })
public status: ReqTaskStatus public status: ReqTaskStatus

View File

@ -0,0 +1,55 @@
import { getModelForClass, index, modelOptions, prop } from '@typegoose/typegoose'
import { dbconn } from 'decorators/dbconn'
import { BaseModule } from './Base'
@dbconn()
@index({ tokenId: 1 }, { unique: false })
@index({ transactionHash: 1, tokenId: 1, from: 1, to: 1 }, { unique: true })
@modelOptions({
schemaOptions: { collection: 'schedule_confirm_event', timestamps: true },
})
export class ScheduleConfirmEventClass extends BaseModule {
@prop({ required: true })
public address!: string
@prop()
public event: string
@prop({ required: true })
public transactionHash: string
@prop()
public blockNumber: number
@prop()
public blockHash: string
@prop()
public removed: boolean
@prop()
public operater: string
@prop()
public scheduleId: string
@prop()
public blockTime: number
@prop({ default: 0 })
public version: number
public static async saveEvent(event: any) {
if (!event.success) {
return
}
const data = {
address: event.tokenAddress,
blockNumber: event.blockHeight,
removed: event.removed,
operater: event.sender,
scheduleId: event.id,
transactionHash: event.hash,
blockTime: new Date(event.time).getTime(),
$inc: { version: 1 },
}
return ScheduleConfirmEvent.insertOrUpdate({ transactionHash: event.hash }, data)
}
}
export const ScheduleConfirmEvent = getModelForClass(ScheduleConfirmEventClass, {
existingConnection: ScheduleConfirmEventClass['db'],
})

View File

@ -6,6 +6,7 @@ dotenv.config({ path: envFile })
import { EventSyncSvr } from 'service/event.sync.service' import { EventSyncSvr } from 'service/event.sync.service'
import { NftTransferEvent } from 'models/NftTransferEvent' import { NftTransferEvent } from 'models/NftTransferEvent'
import { FtTransferEvent } from 'models/FtTransferEvent' import { FtTransferEvent } from 'models/FtTransferEvent'
import { ScheduleConfirmEvent } from 'models/ScheduleConfirmEvent'
import 'common/Extend' import 'common/Extend'
@ -15,11 +16,12 @@ let lock = false
let eventProcessers = { let eventProcessers = {
NftTransferEvent: NftTransferEvent, NftTransferEvent: NftTransferEvent,
FtTransferEvent: FtTransferEvent, FtTransferEvent: FtTransferEvent,
ScheduleConfirmEvent: ScheduleConfirmEvent,
} }
const events = require('config/events.json') const events = require('config/events.json')
async function initNftSvrs() { async function initEventSvrs() {
// let nfts = [{ address: '0x37c30a2945799a53c5358636a721b442458fa691' }] // let nfts = [{ address: '0x37c30a2945799a53c5358636a721b442458fa691' }]
for (let event of events) { for (let event of events) {
let eventSvr = new EventSyncSvr({ let eventSvr = new EventSyncSvr({
@ -33,7 +35,7 @@ async function initNftSvrs() {
} }
} }
async function parseNfts() { async function parseAllEvents() {
if (lock) { if (lock) {
logger.info('sync in process, cancel.') logger.info('sync in process, cancel.')
return return
@ -55,12 +57,11 @@ async function main() {
let opts = { url: process.env.REDIS } let opts = { url: process.env.REDIS }
new RedisClient(opts) new RedisClient(opts)
logger.info('REDIS Connected') logger.info('REDIS Connected')
await initNftSvrs() await initEventSvrs()
logger.info('nft servers inited')
setInterval(function () { setInterval(function () {
parseNfts() parseAllEvents()
}, 60000) }, 60000)
parseNfts() parseAllEvents()
} }
main() main()