@sentio/sdk 2.8.0 → 2.9.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/aptos/aptos-plugin.js +3 -6
- package/lib/aptos/aptos-plugin.js.map +1 -1
- package/lib/core/chain.d.ts +1 -0
- package/lib/core/chain.js +59 -0
- package/lib/core/chain.js.map +1 -1
- package/lib/core/event-logger.d.ts +1 -1
- package/lib/core/event-logger.js.map +1 -1
- package/lib/core/index.d.ts +1 -0
- package/lib/core/index.js.map +1 -1
- package/lib/core/partial-optional.d.ts +1 -0
- package/lib/core/partial-optional.js +2 -0
- package/lib/core/partial-optional.js.map +1 -0
- package/lib/eth/account-processor.d.ts +3 -2
- package/lib/eth/account-processor.js +6 -9
- package/lib/eth/account-processor.js.map +1 -1
- package/lib/eth/base-processor-template.js +2 -2
- package/lib/eth/base-processor-template.js.map +1 -1
- package/lib/eth/base-processor.d.ts +10 -2
- package/lib/eth/base-processor.js +10 -9
- package/lib/eth/base-processor.js.map +1 -1
- package/lib/eth/bind-options.d.ts +2 -9
- package/lib/eth/bind-options.js +3 -15
- package/lib/eth/bind-options.js.map +1 -1
- package/lib/eth/binds.js +2 -2
- package/lib/eth/binds.js.map +1 -1
- package/lib/eth/eth-plugin.js +3 -6
- package/lib/eth/eth-plugin.js.map +1 -1
- package/lib/eth/provider.js +4 -3
- package/lib/eth/provider.js.map +1 -1
- package/lib/eth/provider.test.d.ts +1 -0
- package/lib/eth/provider.test.js.map +1 -0
- package/lib/sui/context.d.ts +9 -0
- package/lib/sui/context.js +29 -0
- package/lib/sui/context.js.map +1 -1
- package/lib/sui/sui-plugin.d.ts +2 -0
- package/lib/sui/sui-plugin.js +38 -2
- package/lib/sui/sui-plugin.js.map +1 -1
- package/lib/sui/sui-processor.d.ts +21 -3
- package/lib/sui/sui-processor.js +46 -2
- package/lib/sui/sui-processor.js.map +1 -1
- package/lib/testing/eth-facet.js +5 -5
- package/lib/testing/eth-facet.js.map +1 -1
- package/lib/utils/price.d.ts +2 -2
- package/package.json +5 -5
- package/src/aptos/aptos-plugin.ts +2 -5
- package/src/core/chain.ts +54 -0
- package/src/core/event-logger.ts +1 -1
- package/src/core/index.ts +1 -0
- package/src/core/partial-optional.ts +1 -0
- package/src/eth/account-processor.ts +8 -11
- package/src/eth/base-processor-template.ts +3 -2
- package/src/eth/base-processor.ts +12 -9
- package/src/eth/bind-options.ts +4 -16
- package/src/eth/binds.ts +3 -2
- package/src/eth/eth-plugin.ts +2 -5
- package/src/eth/provider.ts +4 -3
- package/src/sui/context.ts +33 -0
- package/src/sui/sui-plugin.ts +47 -1
- package/src/sui/sui-processor.ts +85 -3
- package/src/testing/eth-facet.ts +6 -5
package/src/sui/sui-processor.ts
CHANGED
@@ -1,9 +1,16 @@
|
|
1
|
-
import {
|
1
|
+
import {
|
2
|
+
Data_SuiCall,
|
3
|
+
Data_SuiEvent,
|
4
|
+
MoveFetchConfig,
|
5
|
+
Data_SuiObject,
|
6
|
+
ProcessResult,
|
7
|
+
HandleInterval,
|
8
|
+
} from '@sentio/protos'
|
2
9
|
import { ListStateStorage } from '@sentio/runtime'
|
3
10
|
import { SuiNetwork, getChainId } from './network.js'
|
4
11
|
import { ServerError, Status } from 'nice-grpc'
|
5
|
-
import { SuiContext } from './context.js'
|
6
|
-
import { MoveEvent, SuiTransactionResponse, MoveCall } from '@mysten/sui.js'
|
12
|
+
import { SuiContext, SuiObjectContext } from './context.js'
|
13
|
+
import { MoveEvent, SuiTransactionResponse, MoveCall, SuiMoveObject } from '@mysten/sui.js'
|
7
14
|
import { CallHandler, EventFilter, EventHandler, FunctionNameAndCallFilter } from '../move/index.js'
|
8
15
|
import { getMoveCalls } from './utils.js'
|
9
16
|
import { defaultMoveCoder } from './move-coder.js'
|
@@ -148,6 +155,81 @@ export class SuiBaseProcessor {
|
|
148
155
|
}
|
149
156
|
}
|
150
157
|
|
158
|
+
class ObjectHandler {
|
159
|
+
versionInterval?: HandleInterval
|
160
|
+
timeIntervalInMinutes?: HandleInterval
|
161
|
+
handler: (resource: Data_SuiObject) => Promise<ProcessResult>
|
162
|
+
}
|
163
|
+
|
164
|
+
export class SuiAccountProcessorState extends ListStateStorage<SuiAccountProcessor> {
|
165
|
+
static INSTANCE = new SuiAccountProcessorState()
|
166
|
+
}
|
167
|
+
|
168
|
+
export class SuiAccountProcessor {
|
169
|
+
config: IndexConfigure
|
170
|
+
|
171
|
+
objectHandlers: ObjectHandler[] = []
|
172
|
+
|
173
|
+
static bind(options: SuiBindOptions): SuiAccountProcessor {
|
174
|
+
return new SuiAccountProcessor(options)
|
175
|
+
}
|
176
|
+
|
177
|
+
protected constructor(options: SuiBindOptions) {
|
178
|
+
this.config = configure(options)
|
179
|
+
SuiAccountProcessorState.INSTANCE.addValue(this)
|
180
|
+
}
|
181
|
+
|
182
|
+
getChainId(): string {
|
183
|
+
return getChainId(this.config.network)
|
184
|
+
}
|
185
|
+
|
186
|
+
private onInterval(
|
187
|
+
handler: (resources: SuiMoveObject[], ctx: SuiObjectContext) => void,
|
188
|
+
timeInterval: HandleInterval | undefined,
|
189
|
+
versionInterval: HandleInterval | undefined
|
190
|
+
): this {
|
191
|
+
const processor = this
|
192
|
+
this.objectHandlers.push({
|
193
|
+
handler: async function (data) {
|
194
|
+
const ctx = new SuiObjectContext(
|
195
|
+
processor.config.network,
|
196
|
+
processor.config.address,
|
197
|
+
data.slot,
|
198
|
+
data.timestamp || new Date(0)
|
199
|
+
)
|
200
|
+
await handler(data.objects as SuiMoveObject[], ctx)
|
201
|
+
return ctx.getProcessResult()
|
202
|
+
},
|
203
|
+
timeIntervalInMinutes: timeInterval,
|
204
|
+
versionInterval: versionInterval,
|
205
|
+
})
|
206
|
+
return this
|
207
|
+
}
|
208
|
+
|
209
|
+
public onTimeInterval(
|
210
|
+
handler: (objects: SuiMoveObject[], ctx: SuiObjectContext) => void,
|
211
|
+
timeIntervalInMinutes = 60,
|
212
|
+
backfillTimeIntervalInMinutes = 240
|
213
|
+
): this {
|
214
|
+
return this.onInterval(
|
215
|
+
handler,
|
216
|
+
{
|
217
|
+
recentInterval: timeIntervalInMinutes,
|
218
|
+
backfillInterval: backfillTimeIntervalInMinutes,
|
219
|
+
},
|
220
|
+
undefined
|
221
|
+
)
|
222
|
+
}
|
223
|
+
|
224
|
+
public onSlotInterval(
|
225
|
+
handler: (objects: SuiMoveObject[], ctx: SuiObjectContext) => void,
|
226
|
+
slotInterval = 100000,
|
227
|
+
backfillSlotInterval = 400000
|
228
|
+
): this {
|
229
|
+
return this.onInterval(handler, undefined, { recentInterval: slotInterval, backfillInterval: backfillSlotInterval })
|
230
|
+
}
|
231
|
+
}
|
232
|
+
|
151
233
|
function configure(options: SuiBindOptions): IndexConfigure {
|
152
234
|
return {
|
153
235
|
startTimestamp: options.startTimestamp || 0,
|
package/src/testing/eth-facet.ts
CHANGED
@@ -1,8 +1,9 @@
|
|
1
1
|
import { TestProcessorServer } from './test-processor-server.js'
|
2
2
|
import { DataBinding, HandlerType, ProcessBindingResponse } from '@sentio/protos'
|
3
3
|
import { Trace } from '../eth/trace.js'
|
4
|
-
import { BlockParams, LogParams,
|
4
|
+
import { BlockParams, LogParams, Networkish } from 'ethers/providers'
|
5
5
|
import { Block } from 'ethers'
|
6
|
+
import { getNetworkFromCtxOrNetworkish } from '../eth/provider.js'
|
6
7
|
|
7
8
|
export class EthFacet {
|
8
9
|
server: TestProcessorServer
|
@@ -36,7 +37,7 @@ export class EthFacet {
|
|
36
37
|
const signature = trace.action.input.slice(0, 10)
|
37
38
|
|
38
39
|
for (const contract of this.server.contractConfigs) {
|
39
|
-
if (contract.contract?.chainId !==
|
40
|
+
if (contract.contract?.chainId !== getNetworkFromCtxOrNetworkish(network).chainId.toString()) {
|
40
41
|
continue
|
41
42
|
}
|
42
43
|
if (trace.action.to?.toLowerCase() !== contract.contract?.address.toLowerCase()) {
|
@@ -80,7 +81,7 @@ export class EthFacet {
|
|
80
81
|
|
81
82
|
buildLogBinding(log: LogParams, network: Networkish = 1): DataBinding | undefined {
|
82
83
|
for (const contract of this.server.contractConfigs) {
|
83
|
-
if (contract.contract?.chainId !==
|
84
|
+
if (contract.contract?.chainId !== getNetworkFromCtxOrNetworkish(network).chainId.toString()) {
|
84
85
|
continue
|
85
86
|
}
|
86
87
|
if (log.address.toLowerCase() !== contract.contract?.address.toLowerCase()) {
|
@@ -141,7 +142,7 @@ export class EthFacet {
|
|
141
142
|
|
142
143
|
buildAccountLogBinding(address: string, log: LogParams, network: Networkish = 1): DataBinding | undefined {
|
143
144
|
for (const account of this.server.accountConfigs) {
|
144
|
-
if (account.chainId !==
|
145
|
+
if (account.chainId !== getNetworkFromCtxOrNetworkish(network).chainId.toString()) {
|
145
146
|
continue
|
146
147
|
}
|
147
148
|
if (address.toLowerCase() !== account.address.toLowerCase()) {
|
@@ -213,7 +214,7 @@ export class EthFacet {
|
|
213
214
|
handlerIds: [],
|
214
215
|
}
|
215
216
|
for (const contract of this.server.contractConfigs) {
|
216
|
-
if (contract.contract?.chainId !==
|
217
|
+
if (contract.contract?.chainId !== getNetworkFromCtxOrNetworkish(network).chainId.toString()) {
|
217
218
|
continue
|
218
219
|
}
|
219
220
|
const longBlockNumber = block.number
|