1
+ /* eslint-disable prefer-rest-params */
1
2
import type { ContractEventPayload } from 'ethers'
2
- import { Logger , randomStr , redisStore } from '@ora-io/utils'
3
+ import { Logger , objectKeys , randomStr , redisStore } from '@ora-io/utils'
3
4
import type { ListenOptions , ToKeyFn } from '../../src'
4
- import { Orap , StoreManager } from '../../src'
5
+ import { Orap , StoreManager , getTaskContext } from '../../src'
5
6
import ABI from './erc20.abi.json'
6
7
7
8
const MAINNET_USDT_ADDR = '0xdAC17F958D2ee523a2206206994597C13D831ec7'
@@ -59,7 +60,10 @@ export function startDemo(options: ListenOptions, storeConfig?: any) {
59
60
60
61
async function handleTask ( from : string , to : string , amount : number , _event : ContractEventPayload ) {
61
62
logger . log ( '[+] handleTask: from =' , from , 'to =' , to , 'amount =' , amount )
62
- return true
63
+ const args = objectKeys ( arguments ) . map ( k => arguments [ k ] )
64
+
65
+ const { next } = getTaskContext ( ...args )
66
+ await next ( )
63
67
}
64
68
65
69
async function newEventSignalHook ( from : string , to : string , amount : number , event : ContractEventPayload ) {
@@ -70,5 +74,8 @@ async function newEventSignalHook(from: string, to: string, amount: number, even
70
74
71
75
async function handleTask_2 ( from : string , to : string , amount : number ) {
72
76
logger . log ( '[+] handleTask_2: from =' , from , 'to =' , to , 'amount =' , amount )
73
- return true
77
+ const args = objectKeys ( arguments ) . map ( k => arguments [ k ] )
78
+
79
+ const { next } = getTaskContext ( ...args )
80
+ await next ( )
74
81
}
0 commit comments