@subql/frontier-evm-processor 0.1.4 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +24 -7
- package/dist/bundle.js +28 -28
- package/dist/frontierEthProvider.d.ts +1 -0
- package/dist/frontierEthProvider.js +40 -4
- package/dist/frontierEthProvider.js.map +1 -1
- package/dist/index.d.ts +39 -9
- package/dist/index.js +67 -32
- package/dist/index.js.map +1 -1
- package/dist/utils.js +1 -1
- package/dist/utils.js.map +1 -1
- package/package.json +3 -3
- package/src/frontierEthProvider.ts +1 -0
- package/src/index.ts +41 -10
- package/tsconfig.json +1 -1
package/src/index.ts
CHANGED
|
@@ -12,14 +12,14 @@ import {
|
|
|
12
12
|
SubstrateDatasourceProcessor,
|
|
13
13
|
SubstrateCustomDatasource,
|
|
14
14
|
SubstrateHandlerKind,
|
|
15
|
-
SubstrateNetworkFilter,
|
|
16
15
|
SubstrateExtrinsic,
|
|
17
16
|
SubstrateCustomHandler,
|
|
18
17
|
SubstrateMapping,
|
|
19
|
-
DictionaryQueryEntry,
|
|
20
18
|
SecondLayerHandlerProcessor_1_0_0,
|
|
21
19
|
TypedEventRecord,
|
|
20
|
+
SubstrateEvent,
|
|
22
21
|
} from '@subql/types';
|
|
22
|
+
import {DictionaryQueryEntry} from '@subql/types-core';
|
|
23
23
|
import {plainToClass} from 'class-transformer';
|
|
24
24
|
import {
|
|
25
25
|
IsOptional,
|
|
@@ -41,17 +41,34 @@ type Optional<T, K extends keyof T> = Pick<Partial<T>, K> & Omit<T, K>;
|
|
|
41
41
|
|
|
42
42
|
export type FrontierEvmDatasource = SubstrateCustomDatasource<
|
|
43
43
|
'substrate/FrontierEvm',
|
|
44
|
-
SubstrateNetworkFilter,
|
|
45
44
|
SubstrateMapping<SubstrateCustomHandler>,
|
|
46
45
|
FrontierEvmProcessorOptions
|
|
47
46
|
>;
|
|
48
47
|
|
|
49
|
-
export interface FrontierEvmEventFilter extends
|
|
48
|
+
export interface FrontierEvmEventFilter extends Record<string, any> {
|
|
49
|
+
/**
|
|
50
|
+
* You can filter by the topics in a log.
|
|
51
|
+
* These can be an address, event signature, null, '!null' or undefined
|
|
52
|
+
* @example
|
|
53
|
+
* topics: ['Transfer(address, address, uint256)'],
|
|
54
|
+
* @example
|
|
55
|
+
* topics: ['Transfer(address, address, uint256)', undefined, '0x220866B1A2219f40e72f5c628B65D54268cA3A9D']
|
|
56
|
+
*/
|
|
50
57
|
topics?: [TopicFilter, TopicFilter?, TopicFilter?, TopicFilter?];
|
|
51
58
|
}
|
|
52
59
|
|
|
53
|
-
export interface FrontierEvmCallFilter extends
|
|
60
|
+
export interface FrontierEvmCallFilter extends Record<string, any> {
|
|
61
|
+
/**
|
|
62
|
+
* The address of sender of the transaction
|
|
63
|
+
* @example
|
|
64
|
+
* from: '0x220866B1A2219f40e72f5c628B65D54268cA3A9D',
|
|
65
|
+
* */
|
|
54
66
|
from?: string;
|
|
67
|
+
/**
|
|
68
|
+
* The function sighash or function signature of the call. This is the first 32bytes of the data field
|
|
69
|
+
* @example
|
|
70
|
+
* function: 'setminimumStakingAmount(uint256 amount)',
|
|
71
|
+
* */
|
|
55
72
|
function?: string;
|
|
56
73
|
}
|
|
57
74
|
|
|
@@ -80,11 +97,23 @@ class TopicFilterValidator implements ValidatorConstraintInterface {
|
|
|
80
97
|
}
|
|
81
98
|
|
|
82
99
|
export class FrontierEvmProcessorOptions {
|
|
100
|
+
/**
|
|
101
|
+
* The name of the abi that is provided in the assets
|
|
102
|
+
* This is the abi that will be used to decode transaction or log arguments
|
|
103
|
+
* @example
|
|
104
|
+
* abi: 'erc20',
|
|
105
|
+
* */
|
|
83
106
|
@IsOptional()
|
|
84
107
|
@IsString()
|
|
85
108
|
abi?: string;
|
|
86
109
|
@IsOptional()
|
|
87
110
|
@IsEthereumAddress()
|
|
111
|
+
/**
|
|
112
|
+
* The specific contract that this datasource should filter.
|
|
113
|
+
* Alternatively this can be left blank and a transaction to filter can be used instead
|
|
114
|
+
* @example
|
|
115
|
+
* address: '0x220866B1A2219f40e72f5c628B65D54268cA3A9D',
|
|
116
|
+
* */
|
|
88
117
|
address?: string;
|
|
89
118
|
}
|
|
90
119
|
|
|
@@ -195,11 +224,13 @@ const EventProcessor: SecondLayerHandlerProcessor_1_0_0<
|
|
|
195
224
|
async transformer({api, assets, ds, input: original}): Promise<[FrontierEvmEvent]> {
|
|
196
225
|
const [eventData] = original.event.data;
|
|
197
226
|
|
|
227
|
+
const {extrinsic, block} = original as SubstrateEvent<[EvmLog]>;
|
|
228
|
+
|
|
198
229
|
const baseFilter = Array.isArray(EventProcessor.baseFilter)
|
|
199
230
|
? EventProcessor.baseFilter
|
|
200
231
|
: [EventProcessor.baseFilter];
|
|
201
232
|
const evmEvents =
|
|
202
|
-
|
|
233
|
+
extrinsic?.events.filter((evt) =>
|
|
203
234
|
baseFilter.find((filter) => filter.module === evt.event.section && filter.method === evt.event.method)
|
|
204
235
|
) ?? ([] as TypedEventRecord<EvmLog[]>[]);
|
|
205
236
|
|
|
@@ -207,14 +238,14 @@ const EventProcessor: SecondLayerHandlerProcessor_1_0_0<
|
|
|
207
238
|
* Example with no extrinsic https://rata.uncoverexplorer.com/block/3450156
|
|
208
239
|
* Would possibly happen with utils.batch/utils.batchAll as well
|
|
209
240
|
*/
|
|
210
|
-
const {hash} =
|
|
241
|
+
const {hash} = extrinsic ? getExecutionEvent(extrinsic) : {hash: undefined};
|
|
211
242
|
|
|
212
243
|
const log: FrontierEvmEvent = {
|
|
213
244
|
...(eventData.toJSON() as unknown as RawEvent),
|
|
214
245
|
blockNumber: original.block.block.header.number.toNumber(),
|
|
215
246
|
blockHash: await getEtheruemBlockHash(api, original.block.block.header.number.toNumber()),
|
|
216
|
-
blockTimestamp:
|
|
217
|
-
transactionIndex:
|
|
247
|
+
blockTimestamp: block.timestamp,
|
|
248
|
+
transactionIndex: extrinsic?.idx ?? -1,
|
|
218
249
|
transactionHash: hash,
|
|
219
250
|
removed: false,
|
|
220
251
|
logIndex: evmEvents.indexOf(original),
|
|
@@ -499,7 +530,7 @@ const CallProcessor: SecondLayerHandlerProcessor_1_0_0<
|
|
|
499
530
|
export const FrontierEvmDatasourcePlugin = <
|
|
500
531
|
SubstrateDatasourceProcessor<
|
|
501
532
|
'substrate/FrontierEvm',
|
|
502
|
-
|
|
533
|
+
FrontierEvmEventFilter | FrontierEvmCallFilter,
|
|
503
534
|
FrontierEvmDatasource,
|
|
504
535
|
{
|
|
505
536
|
'substrate/FrontierEvmEvent': typeof EventProcessor;
|