From eee4ee213df947f46e6478e049a855c7fcd105ea Mon Sep 17 00:00:00 2001 From: CounterFire2023 <136581895+CounterFire2023@users.noreply.github.com> Date: Sun, 14 Apr 2024 18:31:52 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96event=E5=88=B0scription?= =?UTF-8?q?=E7=9A=84=E8=BD=AC=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/event_list.json | 2 +- config/event_list_production.json | 2 +- src/models/TreasureHunt.ts | 4 ++-- src/service/event.batch.service.ts | 2 ++ 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/config/event_list.json b/config/event_list.json index 7b046f8..09f8071 100644 --- a/config/event_list.json +++ b/config/event_list.json @@ -5,7 +5,7 @@ "address": "0x0Fd13D2CD0B6c679B6f92590E0b91C18DDe7BD3A", "event": "ActionEvent", "abi": "TreasureHunt", - "fromBlock": 26202217, + "fromBlock": 26211451, "eventProcesser": "TreasureHunt" } ] \ No newline at end of file diff --git a/config/event_list_production.json b/config/event_list_production.json index d32d936..ba8c3e1 100644 --- a/config/event_list_production.json +++ b/config/event_list_production.json @@ -4,7 +4,7 @@ "address": "0x0Fd13D2CD0B6c679B6f92590E0b91C18DDe7BD3A", "event": "ActionEvent", "abi": "TreasureHunt", - "fromBlock": 26202217, + "fromBlock": 26211451, "eventProcesser": "TreasureHunt" } ] \ No newline at end of file diff --git a/src/models/TreasureHunt.ts b/src/models/TreasureHunt.ts index 3509625..405be5a 100644 --- a/src/models/TreasureHunt.ts +++ b/src/models/TreasureHunt.ts @@ -27,7 +27,7 @@ const inputs = { '5': 'data:,{"p":"cf-20","op":"task_claim","val":"${val}"}' } export class TreasureHunt { - public static async saveEvent(event: any) { + public static async parseEvent(event: any) { const hash = event.hash || event.transactionHash let {user, action, value} = event.decodedData @@ -45,7 +45,7 @@ export class TreasureHunt { if (action === '2' || action === '5') { let val = Web3.utils.numberToHex(value).replace('0x', '') // convert value from hex to base64 - value = Buffer.from(value.slice(2), 'hex').toString('base64') + val = Buffer.from(val, 'hex').toString() eventScription.input = inputs[action].replace('${val}', val) } else if (action === '3' || action === '4') { let val = Web3.utils.numberToHex(value).replace('0x', '') diff --git a/src/service/event.batch.service.ts b/src/service/event.batch.service.ts index 644d120..6db3707 100644 --- a/src/service/event.batch.service.ts +++ b/src/service/event.batch.service.ts @@ -11,11 +11,13 @@ import { NftStake } from 'models/NftStake' import { IEventCfg } from 'interface/IEventCfg' import { ZRedisClient } from 'zutils' import { formatDate } from 'utils/utcdate.util' +import { TreasureHunt } from 'models/TreasureHunt' let eventProcessers = { NftHolder: NftHolder, TokenHolder: TokenHolder, NftStake: NftStake, + TreasureHunt: TreasureHunt, } const INTERVAL = 100