优化event到scription的转化

This commit is contained in:
CounterFire2023 2024-04-14 18:31:52 +08:00
parent d9aca9e482
commit eee4ee213d
4 changed files with 6 additions and 4 deletions

View File

@ -5,7 +5,7 @@
"address": "0x0Fd13D2CD0B6c679B6f92590E0b91C18DDe7BD3A", "address": "0x0Fd13D2CD0B6c679B6f92590E0b91C18DDe7BD3A",
"event": "ActionEvent", "event": "ActionEvent",
"abi": "TreasureHunt", "abi": "TreasureHunt",
"fromBlock": 26202217, "fromBlock": 26211451,
"eventProcesser": "TreasureHunt" "eventProcesser": "TreasureHunt"
} }
] ]

View File

@ -4,7 +4,7 @@
"address": "0x0Fd13D2CD0B6c679B6f92590E0b91C18DDe7BD3A", "address": "0x0Fd13D2CD0B6c679B6f92590E0b91C18DDe7BD3A",
"event": "ActionEvent", "event": "ActionEvent",
"abi": "TreasureHunt", "abi": "TreasureHunt",
"fromBlock": 26202217, "fromBlock": 26211451,
"eventProcesser": "TreasureHunt" "eventProcesser": "TreasureHunt"
} }
] ]

View File

@ -27,7 +27,7 @@ const inputs = {
'5': 'data:,{"p":"cf-20","op":"task_claim","val":"${val}"}' '5': 'data:,{"p":"cf-20","op":"task_claim","val":"${val}"}'
} }
export class TreasureHunt { export class TreasureHunt {
public static async saveEvent(event: any) { public static async parseEvent(event: any) {
const hash = event.hash || event.transactionHash const hash = event.hash || event.transactionHash
let {user, action, value} = event.decodedData let {user, action, value} = event.decodedData
@ -45,7 +45,7 @@ export class TreasureHunt {
if (action === '2' || action === '5') { if (action === '2' || action === '5') {
let val = Web3.utils.numberToHex(value).replace('0x', '') let val = Web3.utils.numberToHex(value).replace('0x', '')
// convert value from hex to base64 // 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) eventScription.input = inputs[action].replace('${val}', val)
} else if (action === '3' || action === '4') { } else if (action === '3' || action === '4') {
let val = Web3.utils.numberToHex(value).replace('0x', '') let val = Web3.utils.numberToHex(value).replace('0x', '')

View File

@ -11,11 +11,13 @@ import { NftStake } from 'models/NftStake'
import { IEventCfg } from 'interface/IEventCfg' import { IEventCfg } from 'interface/IEventCfg'
import { ZRedisClient } from 'zutils' import { ZRedisClient } from 'zutils'
import { formatDate } from 'utils/utcdate.util' import { formatDate } from 'utils/utcdate.util'
import { TreasureHunt } from 'models/TreasureHunt'
let eventProcessers = { let eventProcessers = {
NftHolder: NftHolder, NftHolder: NftHolder,
TokenHolder: TokenHolder, TokenHolder: TokenHolder,
NftStake: NftStake, NftStake: NftStake,
TreasureHunt: TreasureHunt,
} }
const INTERVAL = 100 const INTERVAL = 100