@sentio/sdk 1.39.0 → 1.40.0-rc.2
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/lib/builtin/internal/eacaggregatorproxy_processor.d.ts +32 -31
- package/lib/builtin/internal/eacaggregatorproxy_processor.js +62 -62
- package/lib/builtin/internal/eacaggregatorproxy_processor.js.map +1 -1
- package/lib/builtin/internal/erc1155_processor.d.ts +17 -16
- package/lib/builtin/internal/erc1155_processor.js +32 -32
- package/lib/builtin/internal/erc1155_processor.js.map +1 -1
- package/lib/builtin/internal/erc20_processor.d.ts +25 -24
- package/lib/builtin/internal/erc20_processor.js +48 -48
- package/lib/builtin/internal/erc20_processor.js.map +1 -1
- package/lib/builtin/internal/erc20bytes_processor.d.ts +14 -13
- package/lib/builtin/internal/erc20bytes_processor.js +26 -26
- package/lib/builtin/internal/erc20bytes_processor.js.map +1 -1
- package/lib/builtin/internal/erc721_processor.d.ts +21 -20
- package/lib/builtin/internal/erc721_processor.js +40 -40
- package/lib/builtin/internal/erc721_processor.js.map +1 -1
- package/lib/builtin/internal/weth9_processor.d.ts +20 -19
- package/lib/builtin/internal/weth9_processor.js +38 -38
- package/lib/builtin/internal/weth9_processor.js.map +1 -1
- package/lib/core/account-processor.d.ts +14 -7
- package/lib/core/account-processor.js +27 -20
- package/lib/core/account-processor.js.map +1 -1
- package/lib/core/base-processor-template.d.ts +4 -2
- package/lib/core/base-processor-template.js +6 -2
- package/lib/core/base-processor-template.js.map +1 -1
- package/lib/core/base-processor.d.ts +5 -3
- package/lib/core/base-processor.js +9 -5
- package/lib/core/base-processor.js.map +1 -1
- package/lib/core/context.d.ts +8 -6
- package/lib/core/context.js +10 -6
- package/lib/core/context.js.map +1 -1
- package/lib/core/eth-plugin.js +4 -0
- package/lib/core/eth-plugin.js.map +1 -1
- package/lib/core/sui-plugin.js +1 -0
- package/lib/core/sui-plugin.js.map +1 -1
- package/lib/target-ethers-sentio/event-handler.js +3 -2
- package/lib/target-ethers-sentio/event-handler.js.map +1 -1
- package/lib/target-ethers-sentio/file.js +1 -0
- package/lib/target-ethers-sentio/file.js.map +1 -1
- package/lib/target-ethers-sentio/functions-handler.js +3 -2
- package/lib/target-ethers-sentio/functions-handler.js.map +1 -1
- package/lib/utils/price.js +1 -5
- package/lib/utils/price.js.map +1 -1
- package/package.json +4 -4
- package/src/builtin/internal/eacaggregatorproxy_processor.ts +101 -62
- package/src/builtin/internal/erc1155_processor.ts +54 -32
- package/src/builtin/internal/erc20_processor.ts +89 -48
- package/src/builtin/internal/erc20bytes_processor.ts +42 -26
- package/src/builtin/internal/erc721_processor.ts +69 -40
- package/src/builtin/internal/weth9_processor.ts +66 -38
- package/src/core/account-processor.ts +76 -28
- package/src/core/base-processor-template.ts +10 -3
- package/src/core/base-processor.ts +30 -11
- package/src/core/context.ts +25 -9
- package/src/core/eth-plugin.ts +4 -1
- package/src/core/sui-plugin.ts +1 -0
- package/src/target-ethers-sentio/event-handler.ts +3 -2
- package/src/target-ethers-sentio/file.ts +1 -0
- package/src/target-ethers-sentio/functions-handler.ts +3 -2
- package/src/utils/price.ts +1 -5
package/src/core/context.ts
CHANGED
|
@@ -1,29 +1,43 @@
|
|
|
1
1
|
import { RecordMetaData } from '@sentio/protos'
|
|
2
|
-
import { BaseContract, EventFilter } from 'ethers'
|
|
2
|
+
import { BaseContract, EventFilter, Transaction } from 'ethers'
|
|
3
3
|
import { Block, Log } from '@ethersproject/abstract-provider'
|
|
4
4
|
import { normalizeLabels } from './meter'
|
|
5
5
|
import { Trace } from './trace'
|
|
6
6
|
import { Labels } from './metadata'
|
|
7
7
|
import { CHAIN_IDS } from '../utils/chain'
|
|
8
8
|
import { BaseContext } from './base-context'
|
|
9
|
+
import { TransactionReceipt } from '@ethersproject/providers'
|
|
9
10
|
|
|
10
11
|
export abstract class EthContext extends BaseContext {
|
|
11
12
|
chainId: number
|
|
12
13
|
address: string
|
|
13
|
-
log?: Log
|
|
14
|
+
private readonly log?: Log
|
|
14
15
|
block?: Block
|
|
15
|
-
trace?: Trace
|
|
16
|
+
private readonly trace?: Trace
|
|
16
17
|
blockNumber: bigint | number
|
|
17
18
|
transactionHash?: string
|
|
19
|
+
transaction?: Transaction
|
|
20
|
+
transactionReceipt?: TransactionReceipt
|
|
18
21
|
timestamp: Date
|
|
19
22
|
|
|
20
|
-
|
|
23
|
+
constructor(
|
|
24
|
+
chainId: number,
|
|
25
|
+
address: string,
|
|
26
|
+
timestamp?: Date,
|
|
27
|
+
block?: Block,
|
|
28
|
+
log?: Log,
|
|
29
|
+
trace?: Trace,
|
|
30
|
+
transaction?: Transaction,
|
|
31
|
+
transactionReceipt?: TransactionReceipt
|
|
32
|
+
) {
|
|
21
33
|
super()
|
|
22
34
|
this.chainId = chainId
|
|
23
35
|
this.log = log
|
|
24
36
|
this.block = block
|
|
25
37
|
this.trace = trace
|
|
26
38
|
this.address = address
|
|
39
|
+
this.transaction = transaction
|
|
40
|
+
this.transactionReceipt = transactionReceipt
|
|
27
41
|
this.timestamp = timestamp || new Date(0)
|
|
28
42
|
if (log) {
|
|
29
43
|
this.blockNumber = log.blockNumber
|
|
@@ -83,9 +97,9 @@ export abstract class EthContext extends BaseContext {
|
|
|
83
97
|
}
|
|
84
98
|
|
|
85
99
|
export class AccountContext extends EthContext {
|
|
86
|
-
constructor(chainId: number, address: string, block?: Block, log?: Log, trace?: Trace) {
|
|
87
|
-
|
|
88
|
-
}
|
|
100
|
+
// constructor(chainId: number, address: string, block?: Block, log?: Log, trace?: Trace) {
|
|
101
|
+
// super(chainId, address, new Date(0), block, log, trace)
|
|
102
|
+
// }
|
|
89
103
|
protected getContractName(): string {
|
|
90
104
|
return 'account'
|
|
91
105
|
}
|
|
@@ -102,12 +116,14 @@ export class ContractContext<
|
|
|
102
116
|
contractName: string,
|
|
103
117
|
view: TContractBoundView,
|
|
104
118
|
chainId: number,
|
|
119
|
+
timestamp?: Date,
|
|
105
120
|
block?: Block,
|
|
106
121
|
log?: Log,
|
|
107
122
|
trace?: Trace,
|
|
108
|
-
|
|
123
|
+
transaction?: Transaction,
|
|
124
|
+
transactionReceipt?: TransactionReceipt
|
|
109
125
|
) {
|
|
110
|
-
super(chainId, view.rawContract.address, block, log, trace,
|
|
126
|
+
super(chainId, view.rawContract.address, timestamp, block, log, trace, transaction, transactionReceipt)
|
|
111
127
|
view.context = this
|
|
112
128
|
this.contractName = contractName
|
|
113
129
|
this.contract = view
|
package/src/core/eth-plugin.ts
CHANGED
|
@@ -15,7 +15,6 @@ import {
|
|
|
15
15
|
} from '@sentio/protos'
|
|
16
16
|
|
|
17
17
|
import { ServerError, Status } from 'nice-grpc'
|
|
18
|
-
import { Block, Log } from '@ethersproject/abstract-provider'
|
|
19
18
|
import { ProcessorState } from '../binds'
|
|
20
19
|
import { AccountProcessorState } from './account-processor'
|
|
21
20
|
import { ProcessorTemplateProcessorState, TemplateInstanceState } from './base-processor-template'
|
|
@@ -48,6 +47,7 @@ export class EthPlugin extends Plugin {
|
|
|
48
47
|
intervalConfigs: [],
|
|
49
48
|
logConfigs: [],
|
|
50
49
|
traceConfigs: [],
|
|
50
|
+
transactionConfig: [],
|
|
51
51
|
startBlock: processor.config.startBlock,
|
|
52
52
|
endBlock: 0n,
|
|
53
53
|
instructionConfig: undefined,
|
|
@@ -78,6 +78,7 @@ export class EthPlugin extends Plugin {
|
|
|
78
78
|
contractConfig.traceConfigs.push({
|
|
79
79
|
signature: traceHandler.signature,
|
|
80
80
|
handlerId: handlerId,
|
|
81
|
+
fetchConfig: traceHandler.fetchConfig,
|
|
81
82
|
})
|
|
82
83
|
}
|
|
83
84
|
|
|
@@ -88,6 +89,7 @@ export class EthPlugin extends Plugin {
|
|
|
88
89
|
const logConfig: LogHandlerConfig = {
|
|
89
90
|
handlerId: handlerId,
|
|
90
91
|
filters: [],
|
|
92
|
+
fetchConfig: eventsHandler.fetchConfig,
|
|
91
93
|
}
|
|
92
94
|
|
|
93
95
|
for (const filter of eventsHandler.filters) {
|
|
@@ -135,6 +137,7 @@ export class EthPlugin extends Plugin {
|
|
|
135
137
|
const logConfig: LogHandlerConfig = {
|
|
136
138
|
handlerId: handlerId,
|
|
137
139
|
filters: [],
|
|
140
|
+
fetchConfig: eventsHandler.fetchConfig,
|
|
138
141
|
}
|
|
139
142
|
|
|
140
143
|
for (const filter of eventsHandler.filters) {
|
package/src/core/sui-plugin.ts
CHANGED
|
@@ -12,6 +12,7 @@ export class SuiPlugin extends Plugin {
|
|
|
12
12
|
configure(config: ProcessConfigResponse): void {
|
|
13
13
|
for (const suiProcessor of SuiProcessorState.INSTANCE.getValues()) {
|
|
14
14
|
const contractConfig: ContractConfig = {
|
|
15
|
+
transactionConfig: [],
|
|
15
16
|
processorType: USER_PROCESSOR,
|
|
16
17
|
contract: {
|
|
17
18
|
name: 'sui contract',
|
|
@@ -9,7 +9,8 @@ export function generateEventHandler(event: EventDeclaration, contractName: stri
|
|
|
9
9
|
return `
|
|
10
10
|
onEvent${eventName}(
|
|
11
11
|
handler: (event: ${eventNamePrefix}Event, ctx: ${contractName}Context) => void,
|
|
12
|
-
filter?: ${eventNamePrefix}EventFilter | ${eventNamePrefix}EventFilter[]
|
|
12
|
+
filter?: ${eventNamePrefix}EventFilter | ${eventNamePrefix}EventFilter[],
|
|
13
|
+
fetchConfig?: EthFetchConfig
|
|
13
14
|
) {
|
|
14
15
|
if (!filter) {
|
|
15
16
|
// @ts-ignore
|
|
@@ -17,7 +18,7 @@ export function generateEventHandler(event: EventDeclaration, contractName: stri
|
|
|
17
18
|
// @ts-ignore
|
|
18
19
|
'${filterName}'](${event.inputs.map(() => 'null').join(',')})
|
|
19
20
|
}
|
|
20
|
-
return super.onEvent(handler, filter
|
|
21
|
+
return super.onEvent(handler, filter!, fetchConfig)
|
|
21
22
|
}
|
|
22
23
|
`
|
|
23
24
|
}
|
|
@@ -162,6 +162,7 @@ export function codeGenSentioFile(contract: Contract): string {
|
|
|
162
162
|
'TypedCallTrace',
|
|
163
163
|
'toBlockTag',
|
|
164
164
|
],
|
|
165
|
+
'@sentio/protos': ['EthFetchConfig'],
|
|
165
166
|
'./common': ['PromiseOrValue'],
|
|
166
167
|
'./index': [`${contract.name}`, `${contract.name}__factory`],
|
|
167
168
|
[`./${contract.name}`]: eventsImports.concat(uniqueStructImports),
|
|
@@ -42,9 +42,10 @@ function generateCallHandler(fn: FunctionDeclaration, contractName: string, over
|
|
|
42
42
|
|
|
43
43
|
return `
|
|
44
44
|
onCall${capitalizeFirstChar(overloadedName ?? fn.name)}(
|
|
45
|
-
handler: (call: ${capitalizeFirstChar(overloadedName ?? fn.name)}CallTrace, ctx: ${contractName}Context) => void
|
|
45
|
+
handler: (call: ${capitalizeFirstChar(overloadedName ?? fn.name)}CallTrace, ctx: ${contractName}Context) => void,
|
|
46
|
+
fetchConfig?: EthFetchConfig
|
|
46
47
|
) {
|
|
47
|
-
return super.onTrace("${sighash}", handler);
|
|
48
|
+
return super.onTrace("${sighash}", handler, fetchConfig);
|
|
48
49
|
}
|
|
49
50
|
`
|
|
50
51
|
}
|
package/src/utils/price.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { PriceServiceClient, PriceServiceDefinition } from '@sentio/protos/lib/service/price/protos/price'
|
|
2
2
|
import { createChannel, createClientFactory } from 'nice-grpc'
|
|
3
3
|
import { retryMiddleware, RetryOptions } from 'nice-grpc-client-middleware-retry'
|
|
4
|
-
import { errorDetailsClientMiddleware } from 'nice-grpc-error-details'
|
|
5
4
|
import { Endpoints } from '@sentio/runtime'
|
|
6
5
|
|
|
7
6
|
export function getPriceClient(address?: string) {
|
|
@@ -10,10 +9,7 @@ export function getPriceClient(address?: string) {
|
|
|
10
9
|
}
|
|
11
10
|
const channel = createChannel(address)
|
|
12
11
|
|
|
13
|
-
return createClientFactory()
|
|
14
|
-
.use(errorDetailsClientMiddleware)
|
|
15
|
-
.use(retryMiddleware)
|
|
16
|
-
.create(PriceServiceDefinition, channel)
|
|
12
|
+
return createClientFactory().use(retryMiddleware).create(PriceServiceDefinition, channel)
|
|
17
13
|
}
|
|
18
14
|
|
|
19
15
|
const priceMap = new Map<string, number>()
|