Skip to content

Commit 35677b1

Browse files
authored
Merge pull request #18 from ora-io/dev
Dev
2 parents 8f3fc42 + 8fc2ce8 commit 35677b1

File tree

6 files changed

+16
-10
lines changed

6 files changed

+16
-10
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "ora-stack",
3-
"version": "0.1.7",
3+
"version": "0.1.8",
44
"private": true,
55
"packageManager": "[email protected]",
66
"description": "",

packages/orap/examples/declarativeDemo/app.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { EventLog } from 'ethers'
1+
import type { ContractEventPayload } from 'ethers'
22
import { Logger, randomStr, redisStore } from '@ora-io/utils'
33
import type { ListenOptions, ToKeyFn } from '../../src'
44
import { Orap, StoreManager } from '../../src'
@@ -57,13 +57,13 @@ export function startDemo(options: ListenOptions, storeConfig?: any) {
5757
)
5858
}
5959

60-
async function handleTask(from: string, to: string, amount: number) {
60+
async function handleTask(from: string, to: string, amount: number, _event: ContractEventPayload) {
6161
logger.log('[+] handleTask: from =', from, 'to =', to, 'amount =', amount)
6262
return true
6363
}
6464

65-
async function newEventSignalHook(from: string, to: string, amount: number, event: EventLog) {
66-
logger.log('receive new event signal, tx:', event.transactionHash)
65+
async function newEventSignalHook(from: string, to: string, amount: number, event: ContractEventPayload) {
66+
logger.log('receive new event signal, tx:', event.log.transactionHash)
6767
logger.debug(' - from:', from, ' - to:', to, ' - amount:', amount)
6868
return true // true to continue handle tasks, false to hijack the process.
6969
}

packages/orap/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@ora-io/orap",
33
"type": "module",
4-
"version": "0.1.7",
4+
"version": "0.1.8",
55
"packageManager": "[email protected]",
66
"description": "",
77
"author": "Norman (nom4dv3), MuRong",

packages/orap/src/signal/event.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type { EventFragment, Interface, InterfaceAbi, Log } from 'ethers'
2-
import { ContractEventPayload, ethers } from 'ethers'
2+
import { ContractEventPayload, ContractUnknownEventPayload, ethers } from 'ethers'
33
import { AutoCrossChecker, ONE_MINUTE_MS, RekuProviderManager } from '@ora-io/reku'
44
import type { AutoCrossCheckParam, Providers } from '@ora-io/reku'
55
import type { Signal } from './interface'
@@ -53,7 +53,7 @@ export class EventSignal implements Signal {
5353
// to align with subscribe listener, parse event params and add EventLog to the last
5454
this.crosscheckCallback = async (log: Log) => {
5555
const parsedLog = this.contract.interface.decodeEventLog(this.eventFragment, log.data, log.topics)
56-
const payload = new ContractEventPayload(this.contract, this.subscribeCallback, this.params.eventName, this.eventFragment, log)
56+
const payload = this._wrapContractEventPayload(log)
5757
await this.callback(...parsedLog, payload)
5858
}
5959

@@ -62,6 +62,12 @@ export class EventSignal implements Signal {
6262
this._setCrosscheckOptions(crosscheckOptions)
6363
}
6464

65+
private _wrapContractEventPayload(log: Log) {
66+
if (this.eventFragment)
67+
return new ContractEventPayload(this.contract, this.subscribeCallback, this.params.eventName, this.eventFragment, log)
68+
return new ContractUnknownEventPayload(this.contract, this.subscribeCallback, this.params.eventName, log)
69+
}
70+
6571
private _setCrosscheckOptions(options: Omit<AutoCrossCheckParam, 'address' | 'topics' | 'onMissingLog'>) {
6672
const {
6773
pollingInterval = ONE_MINUTE_MS * 60,

packages/reku/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@ora-io/reku",
33
"type": "module",
4-
"version": "0.1.7",
4+
"version": "0.1.8",
55
"packageManager": "[email protected]",
66
"description": "",
77
"author": "Norman (nom4dv3), MuRong",

packages/utils/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@ora-io/utils",
33
"type": "module",
4-
"version": "0.1.7",
4+
"version": "0.1.8",
55
"packageManager": "[email protected]",
66
"description": "",
77
"author": "Norman (nom4dv3), MuRong",

0 commit comments

Comments
 (0)