diff --git a/config/scription_list.json b/config/scription_list.json index fe0d5bf..e7cb3db 100644 --- a/config/scription_list.json +++ b/config/scription_list.json @@ -1,8 +1,7 @@ [ { - "chain": 421614, - "rpc": "https://arb-sepolia.g.alchemy.com/v2/EKR1je8ZGia332kkemNc4mtXQuFskIq3", - "fromBlock": 26760154, + "chain": 5611, + "fromBlock": 25594195, "filters": [{ "key": "input", "op": "eq", @@ -17,9 +16,8 @@ "dataModel": "CheckIn" }, { - "chain": 421614, - "rpc": "https://arb-sepolia.g.alchemy.com/v2/EKR1je8ZGia332kkemNc4mtXQuFskIq3", - "fromBlock": 26760154, + "chain": 5611, + "fromBlock": 25594195, "filters": [{ "key": "input", "op": "like", @@ -32,5 +30,53 @@ "value": "0x50a8e60041a206acaa5f844a1104896224be6f39" }], "dataModel": "ChestRecord" + }, + { + "chain": 5611, + "fromBlock": 25594195, + "filters": [{ + "key": "input", + "op": "like", + "type": "regex", + "value": "data:,{\"p\":\"cf-20\",\"op\":\"task_claim\",\"val\":\"(.+?)\"}" + },{ + "key": "to", + "op": "eq", + "type": "address", + "value": "0x50a8e60041a206acaa5f844a1104896224be6f39" + }], + "dataModel": "GenernalScription" + }, + { + "chain": 5611, + "fromBlock": 25594195, + "filters": [{ + "key": "input", + "op": "like", + "type": "regex", + "value": "data:,{\"p\":\"cf-20\",\"op\":\"explore\",\"val\":\"(.+?)\"}" + },{ + "key": "to", + "op": "eq", + "type": "address", + "value": "0x50a8e60041a206acaa5f844a1104896224be6f39" + }], + "dataModel": "GenernalScription" + }, + { + "chain": 5611, + "fromBlock": 25594195, + "filters": [{ + "key": "input", + "op": "like", + "type": "regex", + "value": "data:,{\"p\":\"cf-20\",\"op\":\"chest_enhance\",\"val\":\"(.+?)\"}" + },{ + "key": "to", + "op": "eq", + "type": "address", + "value": "0x50a8e60041a206acaa5f844a1104896224be6f39" + }], + "dataModel": "GenernalScription" } ] \ No newline at end of file diff --git a/src/chain/allchain.ts b/src/chain/allchain.ts index b14d02f..a19d889 100644 --- a/src/chain/allchain.ts +++ b/src/chain/allchain.ts @@ -301,6 +301,22 @@ export const AllChains: IChain[] = [ symbol: 'ONE', explorerurl: 'https://explorer.harmony.one', }, + { + name: 'opBNB Mainnet', + type: 'Mainnet', + rpc: 'https://opbnb-rpc.publicnode.com', + id: 204, + symbol: 'BNB', + explorerurl: 'https://mainnet.opbnbscan.com', + }, + { + name: 'opBNB Testnet', + type: 'Testnet', + rpc: 'https://opbnb-testnet-rpc.bnbchain.org', + id: 5611, + symbol: 'tBNB', + explorerurl: 'https://opbnb-testnet.bscscan.com', + }, { name: 'Local Testnet', type: 'Local', diff --git a/src/models/GeneralScription.ts b/src/models/GeneralScription.ts new file mode 100644 index 0000000..5a93605 --- /dev/null +++ b/src/models/GeneralScription.ts @@ -0,0 +1,63 @@ +import { getModelForClass, index, modelOptions, prop } from '@typegoose/typegoose' +import { dbconn } from 'decorators/dbconn' +import { BaseModule } from './Base' +import { hexToUtf8 } from 'zutils/utils/string.util' +import logger from 'logger/logger' + +@dbconn() +@index({ from: 1 }, { unique: false }) +@index({ hash: 1 }, { unique: true }) +@index({ from: 1, blockTime: 1 }, { unique: false }) +@modelOptions({ + schemaOptions: { collection: 'general_scription_record', timestamps: true }, +}) +export class GeneralScriptionClass extends BaseModule { + @prop({ required: true }) + public from!: string + @prop() + public to: string + @prop({ required: true }) + public hash: string + @prop() + public blockNumber: string + @prop() + public blockHash: string + @prop() + public blockTime: number + @prop() + public dateTag: string + @prop() + public data: string + @prop() + public op: string + @prop() + public value: string + @prop() + public input: string + + public static async saveEvent(event: any) { + const dataStr = hexToUtf8(event.input) + const regexp = /data:,{\"p\":\"cf-20\",\"op\":\"(.+?)\",\"val\":\"(.+?)\"}/ + const match = dataStr.match(regexp) + if (!match) { + logger.log('not a general scription:', event.hash) + return + } + event.op = match[1] + event.data = match[2] + logger.log('general scription with op:', event.op, ' data:', event.data) + return GeneralScription.insertOrUpdate({ hash: event.hash }, event) + } + + public toJson() { + return { + address: this.from, + day: this.dateTag, + time: this.blockTime, + } + } +} + +export const GeneralScription = getModelForClass(GeneralScriptionClass, { + existingConnection: GeneralScriptionClass['db'], +}) diff --git a/src/scriptions.ts b/src/scriptions.ts index 42953d9..4f2142e 100644 --- a/src/scriptions.ts +++ b/src/scriptions.ts @@ -13,6 +13,7 @@ import { CheckIn } from 'models/CheckIn' import { ZRedisClient } from 'zutils' import { hexToUtf8 } from 'zutils/utils/string.util' import { ChestRecord } from 'models/ChestRecord' +import { GeneralScription } from 'models/GeneralScription' let svrs: any[] = [] let lock = false @@ -20,6 +21,7 @@ let lock = false let eventProcessers = { CheckIn: CheckIn, ChestRecord: ChestRecord, + GenernalScription: GeneralScription, } global.hexToUtf8 = hexToUtf8 @@ -79,6 +81,6 @@ async function parseAllEvents() { await initEventSvrs() setInterval(function () { parseAllEvents() - }, 6000) + }, 3000) parseAllEvents() })()