Skip to content

Commit

Permalink
additions for adding to origin-squid-notifications
Browse files Browse the repository at this point in the history
  • Loading branch information
apexearth committed Jan 23, 2025
1 parent 8a05886 commit e1555a1
Show file tree
Hide file tree
Showing 16 changed files with 256 additions and 36 deletions.
1 change: 1 addition & 0 deletions lib/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,4 @@ export * from './range';
export * from './readLinesFromUrlInBatches';
export * from './retry';
export * from './state';
export * from './traceFilter';
1 change: 1 addition & 0 deletions lib/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/index.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/jsonify.d.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export declare const jsonify: (value: any, customReplacer?: (key: string, value: unknown) => unknown) => string;
export declare const jsonify: (value: any, customReplacer?: (key: string, value: unknown) => unknown, indent?: number) => string;
2 changes: 1 addition & 1 deletion lib/jsonify.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/jsonify.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

105 changes: 87 additions & 18 deletions lib/processor.d.ts
Original file line number Diff line number Diff line change
@@ -1,29 +1,98 @@
import { Chain } from 'viem';
import { DataHandlerContext, EvmBatchProcessor, EvmBatchProcessorFields } from '@subsquid/evm-processor';
import { DataHandlerContext, EvmBatchProcessor, EvmBatchProcessorFields, FieldSelection } from '@subsquid/evm-processor';
import { Store } from '@subsquid/typeorm-store';
import './polyfills/rpc-issues';
export declare const createEvmBatchProcessor: (config: ChainConfig) => EvmBatchProcessor<{
export declare const createEvmBatchProcessor: (config: ChainConfig, options?: {
fields: FieldSelection;
}) => EvmBatchProcessor<{
transaction: {
from: true;
to: true;
hash: true;
gasUsed: true;
effectiveGasPrice: true;
input: true;
status: true;
hash: boolean;
nonce?: boolean | undefined;
gasUsed: boolean;
sighash: boolean;
from: boolean;
to: boolean;
gas: boolean;
gasPrice?: boolean | undefined;
maxFeePerGas?: boolean | undefined;
maxPriorityFeePerGas?: boolean | undefined;
input: boolean;
value: boolean;
v?: boolean | undefined;
r?: boolean | undefined;
s?: boolean | undefined;
yParity?: boolean | undefined;
chainId?: boolean | undefined;
authorizationList?: boolean | undefined;
cumulativeGasUsed?: boolean | undefined;
effectiveGasPrice?: boolean | undefined;
contractAddress?: boolean | undefined;
type?: boolean | undefined;
status: boolean;
l1Fee?: boolean | undefined;
l1FeeScalar?: boolean | undefined;
l1GasPrice?: boolean | undefined;
l1GasUsed?: boolean | undefined;
l1BlobBaseFee?: boolean | undefined;
l1BlobBaseFeeScalar?: boolean | undefined;
l1BaseFeeScalar?: boolean | undefined;
};
log: {
transactionHash: true;
topics: true;
data: true;
transactionHash: boolean;
address?: boolean | undefined;
data: boolean;
topics: boolean;
};
trace: {
callFrom: true;
callTo: true;
callSighash: true;
callValue: true;
callInput: true;
createResultAddress: true;
subtraces?: boolean | undefined;
error?: boolean | undefined;
revertReason?: boolean | undefined;
createFrom?: boolean | undefined;
createGas?: boolean | undefined;
createValue?: boolean | undefined;
createInit?: boolean | undefined;
createResultGasUsed?: boolean | undefined;
createResultAddress: boolean;
createResultCode?: boolean | undefined;
callFrom: boolean;
callGas?: boolean | undefined;
callValue: boolean;
callSighash: boolean;
callTo: boolean;
callInput: boolean;
callCallType?: boolean | undefined;
callResultGasUsed?: boolean | undefined;
callResultOutput?: boolean | undefined;
suicideAddress: boolean;
suicideRefundAddress: boolean;
suicideBalance: boolean;
rewardValue?: boolean | undefined;
rewardType?: boolean | undefined;
rewardAuthor?: boolean | undefined;
};
block?: {
nonce?: boolean | undefined;
sha3Uncles?: boolean | undefined;
logsBloom?: boolean | undefined;
transactionsRoot?: boolean | undefined;
stateRoot?: boolean | undefined;
receiptsRoot?: boolean | undefined;
mixHash?: boolean | undefined;
miner?: boolean | undefined;
difficulty?: boolean | undefined;
totalDifficulty?: boolean | undefined;
extraData?: boolean | undefined;
size?: boolean | undefined;
gasLimit?: boolean | undefined;
gasUsed?: boolean | undefined;
timestamp?: boolean | undefined;
baseFeePerGas?: boolean | undefined;
l1BlockNumber?: boolean | undefined;
};
stateDiff?: {
kind?: boolean | undefined;
prev?: boolean | undefined;
next?: boolean | undefined;
};
}>;
export interface SquidProcessor {
Expand Down
17 changes: 11 additions & 6 deletions lib/processor.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/processor.js.map

Large diffs are not rendered by default.

25 changes: 25 additions & 0 deletions lib/traceFilter.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { Trace } from './processor';
type TraceType = 'call' | 'create' | 'suicide' | 'reward';
type TraceFilterParams = {
type: TraceType[];
callFrom?: string[];
callTo?: string[];
callSighash?: string[];
suicideRefundAddress?: string[];
transaction?: boolean;
transactionLogs?: boolean;
range?: {
from: number;
to?: number;
};
error?: boolean;
};
/**
* Helper to create and match traces.
*/
export declare const traceFilter: (filter: TraceFilterParams) => {
readonly value: TraceFilterParams;
readonly matches: (trace: Trace) => boolean;
};
export type TraceFilter = ReturnType<typeof traceFilter>;
export {};
46 changes: 46 additions & 0 deletions lib/traceFilter.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions lib/traceFilter.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,5 @@ export * from './range'
export * from './readLinesFromUrlInBatches'
export * from './retry'
export * from './state'
export * from './traceFilter'

2 changes: 2 additions & 0 deletions src/jsonify.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ function replacer(key: string, value: unknown) {
export const jsonify = (
value: any,
customReplacer?: (key: string, value: unknown) => unknown,
indent?: number,
) =>
JSON.stringify(value, (key, value) =>
replacer(key, customReplacer?.(key, value) ?? value),
indent,
)
21 changes: 14 additions & 7 deletions src/processor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { compact } from 'lodash'
import { Chain } from 'viem'
import { arbitrum, base, mainnet, sonic } from 'viem/chains'

import { DataHandlerContext, EvmBatchProcessor, EvmBatchProcessorFields } from '@subsquid/evm-processor'
import { DataHandlerContext, EvmBatchProcessor, EvmBatchProcessorFields, FieldSelection } from '@subsquid/evm-processor'
import { Store, TypeormDatabase } from '@subsquid/typeorm-store'
import { blockFrequencyTracker } from './blockFrequencyUpdater'
import { calculateBlockRate } from './calculateBlockRate'
Expand All @@ -17,7 +17,9 @@ import './polyfills/rpc-issues'
dayjs.extend(duration)
dayjs.extend(utc)

export const createEvmBatchProcessor = (config: ChainConfig) => {
export const createEvmBatchProcessor = (config: ChainConfig, options?: {
fields: FieldSelection
}) => {
const url = config.endpoints[0] || 'http://localhost:8545'
console.log('rpc url', url)
const processor = new EvmBatchProcessor()
Expand All @@ -32,23 +34,24 @@ export const createEvmBatchProcessor = (config: ChainConfig) => {
})
.setFinalityConfirmation(10)
.setFields({
...options?.fields,
transaction: {
from: true,
to: true,
hash: true,
gasUsed: true,
effectiveGasPrice: true,
// gas: true,
// gasPrice: true,
// value: true,
// sighash: true,
gas: true,
value: true,
sighash: true,
input: true,
status: true,
...options?.fields?.transaction,
},
log: {
transactionHash: true,
topics: true,
data: true,
...options?.fields?.log,
},
trace: {
callFrom: true,
Expand All @@ -57,6 +60,10 @@ export const createEvmBatchProcessor = (config: ChainConfig) => {
callValue: true,
callInput: true,
createResultAddress: true,
suicideRefundAddress: true,
suicideAddress: true,
suicideBalance: true,
...options?.fields?.trace,
},
})

Expand Down
Loading

0 comments on commit e1555a1

Please sign in to comment.