@sentio/sdk 2.16.0-rc.1 → 2.16.0-rc.3
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/core/core-plugin.js +3 -0
- package/lib/core/core-plugin.js.map +1 -1
- package/lib/eth/eth-plugin.js +0 -2
- package/lib/eth/eth-plugin.js.map +1 -1
- package/lib/sui/context.d.ts +11 -5
- package/lib/sui/context.js +20 -10
- package/lib/sui/context.js.map +1 -1
- package/lib/sui/ext/move-dex.d.ts +2 -2
- package/lib/sui/ext/move-dex.js.map +1 -1
- package/lib/sui/index.d.ts +1 -1
- package/lib/sui/index.js +1 -1
- package/lib/sui/index.js.map +1 -1
- package/lib/sui/sui-object-processor-template.d.ts +34 -0
- package/lib/sui/{sui-objects-processor-template.js → sui-object-processor-template.js} +11 -10
- package/lib/sui/sui-object-processor-template.js.map +1 -0
- package/lib/sui/sui-object-processor.d.ts +13 -13
- package/lib/sui/sui-object-processor.js +11 -11
- package/lib/sui/sui-object-processor.js.map +1 -1
- package/lib/sui/sui-plugin.js +2 -2
- package/lib/sui/sui-plugin.js.map +1 -1
- package/package.json +3 -3
- package/src/core/core-plugin.ts +4 -0
- package/src/eth/eth-plugin.ts +0 -2
- package/src/sui/context.ts +35 -10
- package/src/sui/ext/move-dex.ts +2 -2
- package/src/sui/index.ts +2 -2
- package/src/sui/{sui-objects-processor-template.ts → sui-object-processor-template.ts} +20 -19
- package/src/sui/sui-object-processor.ts +25 -25
- package/src/sui/sui-plugin.ts +6 -3
- package/lib/sui/sui-objects-processor-template.d.ts +0 -34
- package/lib/sui/sui-objects-processor-template.js.map +0 -1
@@ -1,7 +1,7 @@
|
|
1
1
|
import { Data_SuiObject, HandleInterval, MoveAccountFetchConfig, MoveOwnerType, ProcessResult } from '@sentio/protos'
|
2
2
|
import { ListStateStorage } from '@sentio/runtime'
|
3
3
|
import { SuiNetwork } from './network.js'
|
4
|
-
import {
|
4
|
+
import { SuiObjectContext } from './context.js'
|
5
5
|
import { SuiMoveObject } from '@mysten/sui.js'
|
6
6
|
import { PromiseOrVoid } from '../core/index.js'
|
7
7
|
import { configure, IndexConfigure, SuiBindOptions } from './sui-processor.js'
|
@@ -15,7 +15,7 @@ export interface SuiObjectBindOptions {
|
|
15
15
|
|
16
16
|
interface ObjectHandler {
|
17
17
|
type?: string
|
18
|
-
|
18
|
+
checkPointInterval?: HandleInterval
|
19
19
|
timeIntervalInMinutes?: HandleInterval
|
20
20
|
fetchConfig: MoveAccountFetchConfig
|
21
21
|
handler: (resource: Data_SuiObject) => Promise<ProcessResult>
|
@@ -25,7 +25,7 @@ export const DEFAULT_FETCH_CONFIG: MoveAccountFetchConfig = {
|
|
25
25
|
owned: true,
|
26
26
|
}
|
27
27
|
|
28
|
-
export class SuiAccountProcessorState extends ListStateStorage<
|
28
|
+
export class SuiAccountProcessorState extends ListStateStorage<SuiBaseObjectOrAddressProcessor<any>> {
|
29
29
|
static INSTANCE = new SuiAccountProcessorState()
|
30
30
|
}
|
31
31
|
|
@@ -33,7 +33,7 @@ export interface SuiInternalObjectsBindOptions extends SuiBindOptions {
|
|
33
33
|
ownerType: MoveOwnerType
|
34
34
|
}
|
35
35
|
|
36
|
-
export abstract class
|
36
|
+
export abstract class SuiBaseObjectOrAddressProcessor<HandlerType> {
|
37
37
|
config: IndexConfigure
|
38
38
|
ownerType: MoveOwnerType
|
39
39
|
|
@@ -55,19 +55,19 @@ export abstract class SuiBaseObjectsProcessor<HandlerType> {
|
|
55
55
|
|
56
56
|
// protected abstract transformObjects(objects: SuiMoveObject[]): SuiMoveObject[]
|
57
57
|
|
58
|
-
protected abstract doHandle(handler: HandlerType, data: Data_SuiObject, ctx:
|
58
|
+
protected abstract doHandle(handler: HandlerType, data: Data_SuiObject, ctx: SuiObjectContext): PromiseOrVoid
|
59
59
|
|
60
60
|
public onInterval(
|
61
61
|
handler: HandlerType, //(resources: SuiMoveObject[], ctx: SuiObjectsContext) => PromiseOrVoid,
|
62
62
|
timeInterval: HandleInterval | undefined,
|
63
|
-
|
63
|
+
checkpointInterval: HandleInterval | undefined,
|
64
64
|
type: string | undefined,
|
65
65
|
fetchConfig: Partial<MoveAccountFetchConfig> | undefined
|
66
66
|
): this {
|
67
67
|
const processor = this
|
68
68
|
this.objectHandlers.push({
|
69
69
|
handler: async function (data) {
|
70
|
-
const ctx = new
|
70
|
+
const ctx = new SuiObjectContext(
|
71
71
|
processor.config.network,
|
72
72
|
processor.config.address,
|
73
73
|
data.slot,
|
@@ -78,7 +78,7 @@ export abstract class SuiBaseObjectsProcessor<HandlerType> {
|
|
78
78
|
return ctx.getProcessResult()
|
79
79
|
},
|
80
80
|
timeIntervalInMinutes: timeInterval,
|
81
|
-
|
81
|
+
checkPointInterval: checkpointInterval,
|
82
82
|
type,
|
83
83
|
fetchConfig: { ...DEFAULT_FETCH_CONFIG, ...fetchConfig },
|
84
84
|
})
|
@@ -104,41 +104,41 @@ export abstract class SuiBaseObjectsProcessor<HandlerType> {
|
|
104
104
|
)
|
105
105
|
}
|
106
106
|
|
107
|
-
public
|
107
|
+
public onCheckpointInterval(
|
108
108
|
handler: HandlerType,
|
109
|
-
|
110
|
-
|
109
|
+
checkpointInterval = 100000,
|
110
|
+
backfillCheckpointInterval = 400000,
|
111
111
|
type?: string,
|
112
112
|
fetchConfig?: Partial<MoveAccountFetchConfig>
|
113
113
|
): this {
|
114
114
|
return this.onInterval(
|
115
115
|
handler,
|
116
116
|
undefined,
|
117
|
-
{ recentInterval:
|
117
|
+
{ recentInterval: checkpointInterval, backfillInterval: backfillCheckpointInterval },
|
118
118
|
type,
|
119
119
|
fetchConfig
|
120
120
|
)
|
121
121
|
}
|
122
122
|
}
|
123
123
|
|
124
|
-
export class SuiAddressProcessor extends
|
125
|
-
(objects: SuiMoveObject[], ctx:
|
124
|
+
export class SuiAddressProcessor extends SuiBaseObjectOrAddressProcessor<
|
125
|
+
(objects: SuiMoveObject[], ctx: SuiObjectContext) => PromiseOrVoid
|
126
126
|
> {
|
127
127
|
static bind(options: SuiBindOptions): SuiAddressProcessor {
|
128
128
|
return new SuiAddressProcessor({ ...options, ownerType: MoveOwnerType.ADDRESS })
|
129
129
|
}
|
130
130
|
|
131
131
|
protected doHandle(
|
132
|
-
handler: (objects: SuiMoveObject[], ctx:
|
132
|
+
handler: (objects: SuiMoveObject[], ctx: SuiObjectContext) => PromiseOrVoid,
|
133
133
|
data: Data_SuiObject,
|
134
|
-
ctx:
|
134
|
+
ctx: SuiObjectContext
|
135
135
|
): PromiseOrVoid {
|
136
136
|
return handler(data.objects as SuiMoveObject[], ctx)
|
137
137
|
}
|
138
138
|
}
|
139
139
|
|
140
|
-
export class SuiObjectProcessor extends
|
141
|
-
(self: SuiMoveObject, dynamicFieldObjects: SuiMoveObject[], ctx:
|
140
|
+
export class SuiObjectProcessor extends SuiBaseObjectOrAddressProcessor<
|
141
|
+
(self: SuiMoveObject, dynamicFieldObjects: SuiMoveObject[], ctx: SuiObjectContext) => PromiseOrVoid
|
142
142
|
> {
|
143
143
|
static bind(options: SuiObjectBindOptions): SuiObjectProcessor {
|
144
144
|
return new SuiObjectProcessor({
|
@@ -151,20 +151,20 @@ export class SuiObjectProcessor extends SuiBaseObjectsProcessor<
|
|
151
151
|
}
|
152
152
|
|
153
153
|
protected doHandle(
|
154
|
-
handler: (self: SuiMoveObject, dynamicFieldObjects: SuiMoveObject[], ctx:
|
154
|
+
handler: (self: SuiMoveObject, dynamicFieldObjects: SuiMoveObject[], ctx: SuiObjectContext) => PromiseOrVoid,
|
155
155
|
data: Data_SuiObject,
|
156
|
-
ctx:
|
156
|
+
ctx: SuiObjectContext
|
157
157
|
): PromiseOrVoid {
|
158
158
|
if (!data.self) {
|
159
|
-
console.log(`Sui object not existed in ${ctx.
|
159
|
+
console.log(`Sui object not existed in ${ctx.checkpoint}, please specific a start time`)
|
160
160
|
return
|
161
161
|
}
|
162
162
|
return handler(data.self as SuiMoveObject, data.objects as SuiMoveObject[], ctx)
|
163
163
|
}
|
164
164
|
}
|
165
165
|
|
166
|
-
export class SuiWrappedObjectProcessor extends
|
167
|
-
(dynamicFieldObjects: SuiMoveObject[], ctx:
|
166
|
+
export class SuiWrappedObjectProcessor extends SuiBaseObjectOrAddressProcessor<
|
167
|
+
(dynamicFieldObjects: SuiMoveObject[], ctx: SuiObjectContext) => PromiseOrVoid
|
168
168
|
> {
|
169
169
|
static bind(options: SuiObjectBindOptions): SuiWrappedObjectProcessor {
|
170
170
|
return new SuiWrappedObjectProcessor({
|
@@ -177,9 +177,9 @@ export class SuiWrappedObjectProcessor extends SuiBaseObjectsProcessor<
|
|
177
177
|
}
|
178
178
|
|
179
179
|
protected doHandle(
|
180
|
-
handler: (dynamicFieldObjects: SuiMoveObject[], ctx:
|
180
|
+
handler: (dynamicFieldObjects: SuiMoveObject[], ctx: SuiObjectContext) => PromiseOrVoid,
|
181
181
|
data: Data_SuiObject,
|
182
|
-
ctx:
|
182
|
+
ctx: SuiObjectContext
|
183
183
|
): PromiseOrVoid {
|
184
184
|
return handler(data.objects as SuiMoveObject[], ctx)
|
185
185
|
}
|
package/src/sui/sui-plugin.ts
CHANGED
@@ -21,7 +21,10 @@ import { SuiAccountProcessorState } from './sui-object-processor.js'
|
|
21
21
|
import { validateAndNormalizeAddress } from './utils.js'
|
22
22
|
import { initCoinList } from './ext/coin.js'
|
23
23
|
import { SuiChainId } from '../core/chain.js'
|
24
|
-
import {
|
24
|
+
import {
|
25
|
+
SuiAccountProcessorTemplateState,
|
26
|
+
SuiObjectOrAddressProcessorTemplate,
|
27
|
+
} from './sui-object-processor-template.js'
|
25
28
|
import { SuiNetwork } from './network.js'
|
26
29
|
import { SuiContext } from './context.js'
|
27
30
|
|
@@ -47,7 +50,7 @@ export class SuiPlugin extends Plugin {
|
|
47
50
|
continue
|
48
51
|
}
|
49
52
|
|
50
|
-
const template:
|
53
|
+
const template: SuiObjectOrAddressProcessorTemplate<any, any> =
|
51
54
|
SuiAccountProcessorTemplateState.INSTANCE.getValues()[instance.templateId]
|
52
55
|
|
53
56
|
template.bind(
|
@@ -126,7 +129,7 @@ export class SuiPlugin extends Plugin {
|
|
126
129
|
minutes: 0,
|
127
130
|
minutesInterval: handler.timeIntervalInMinutes,
|
128
131
|
slot: 0,
|
129
|
-
slotInterval: handler.
|
132
|
+
slotInterval: handler.checkPointInterval,
|
130
133
|
fetchConfig: undefined,
|
131
134
|
},
|
132
135
|
type: handler.type || '',
|
@@ -1,34 +0,0 @@
|
|
1
|
-
import { HandleInterval, MoveAccountFetchConfig } from '@sentio/protos';
|
2
|
-
import { ListStateStorage } from '@sentio/runtime';
|
3
|
-
import { SuiContext, SuiObjectsContext } from './context.js';
|
4
|
-
import { SuiMoveObject } from '@mysten/sui.js';
|
5
|
-
import { PromiseOrVoid } from '../core/index.js';
|
6
|
-
import { SuiBaseObjectsProcessor, SuiObjectBindOptions, SuiObjectProcessor, SuiWrappedObjectProcessor } from './sui-object-processor.js';
|
7
|
-
declare class ObjectHandler<HandlerType> {
|
8
|
-
type?: string;
|
9
|
-
versionInterval?: HandleInterval;
|
10
|
-
timeIntervalInMinutes?: HandleInterval;
|
11
|
-
handler: HandlerType;
|
12
|
-
fetchConfig: MoveAccountFetchConfig;
|
13
|
-
}
|
14
|
-
export declare class SuiAccountProcessorTemplateState extends ListStateStorage<SuiBaseObjectsProcessorTemplate<any, any>> {
|
15
|
-
static INSTANCE: SuiAccountProcessorTemplateState;
|
16
|
-
}
|
17
|
-
export declare abstract class SuiBaseObjectsProcessorTemplate<HandlerType, ProcessorType extends SuiBaseObjectsProcessor<HandlerType>> {
|
18
|
-
id: number;
|
19
|
-
objectHandlers: ObjectHandler<HandlerType>[];
|
20
|
-
binds: Set<string>;
|
21
|
-
protected constructor();
|
22
|
-
abstract createProcessor(options: SuiObjectBindOptions): ProcessorType;
|
23
|
-
bind(options: SuiObjectBindOptions, ctx: SuiContext): void;
|
24
|
-
protected onInterval(handler: HandlerType, timeInterval: HandleInterval | undefined, versionInterval: HandleInterval | undefined, type: string | undefined, fetchConfig: Partial<MoveAccountFetchConfig> | undefined): this;
|
25
|
-
onTimeInterval(handler: HandlerType, timeIntervalInMinutes?: number, backfillTimeIntervalInMinutes?: number, type?: string, fetchConfig?: Partial<MoveAccountFetchConfig>): this;
|
26
|
-
onSlotInterval(handler: HandlerType, slotInterval?: number, backfillSlotInterval?: number, type?: string, fetchConfig?: Partial<MoveAccountFetchConfig>): this;
|
27
|
-
}
|
28
|
-
export declare class SuiObjectsProcessorTemplate extends SuiBaseObjectsProcessorTemplate<(self: SuiMoveObject, dynamicFieldObjects: SuiMoveObject[], ctx: SuiObjectsContext) => PromiseOrVoid, SuiObjectProcessor> {
|
29
|
-
createProcessor(options: SuiObjectBindOptions): SuiObjectProcessor;
|
30
|
-
}
|
31
|
-
export declare class SuiWrappedObjectProcessorTemplate extends SuiBaseObjectsProcessorTemplate<(dynamicFieldObjects: SuiMoveObject[], ctx: SuiObjectsContext) => PromiseOrVoid, SuiWrappedObjectProcessor> {
|
32
|
-
createProcessor(options: SuiObjectBindOptions): SuiWrappedObjectProcessor;
|
33
|
-
}
|
34
|
-
export {};
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"sui-objects-processor-template.js","sourceRoot":"","sources":["../../src/sui/sui-objects-processor-template.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAA;AAIlD,OAAO,EACL,oBAAoB,EAGpB,kBAAkB,EAClB,yBAAyB,GAC1B,MAAM,2BAA2B,CAAA;AAClC,OAAO,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAA;AAE3D,MAAM,aAAa;IACjB,IAAI,CAAS;IACb,eAAe,CAAiB;IAChC,qBAAqB,CAAiB;IACtC,OAAO,CAAa;IACpB,WAAW,CAAwB;CACpC;AAED,MAAa,gCAAiC,SAAQ,gBAA2D;IAC/G,MAAM,CAAC,QAAQ,GAAG,IAAI,gCAAgC,EAAE,CAAA;;SAD7C,gCAAgC;AAI7C,MAAM,OAA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Ae,CAAC,OAA6B;QAC3C,OAAO,kBAAkB,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;IACzC,CAAC;CACF;AAED,MAAM,OAAO,iCAAkC,SAAQ,+BAItD;IACC,eAAe,CAAC,OAA6B;QAC3C,OAAO,yBAAyB,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;IAChD,CAAC;CACF","sourcesContent":["import { HandleInterval, MoveAccountFetchConfig } from '@sentio/protos'\nimport { ListStateStorage } from '@sentio/runtime'\nimport { SuiContext, SuiObjectsContext } from './context.js'\nimport { SuiMoveObject } from '@mysten/sui.js'\nimport { PromiseOrVoid } from '../core/index.js'\nimport {\n DEFAULT_FETCH_CONFIG,\n SuiBaseObjectsProcessor,\n SuiObjectBindOptions,\n SuiObjectProcessor,\n SuiWrappedObjectProcessor,\n} from './sui-object-processor.js'\nimport { TemplateInstanceState } from '../core/template.js'\n\nclass ObjectHandler<HandlerType> {\n type?: string\n versionInterval?: HandleInterval\n timeIntervalInMinutes?: HandleInterval\n handler: HandlerType\n fetchConfig: MoveAccountFetchConfig\n}\n\nexport class SuiAccountProcessorTemplateState extends ListStateStorage<SuiBaseObjectsProcessorTemplate<any, any>> {\n static INSTANCE = new SuiAccountProcessorTemplateState()\n}\n\nexport abstract class SuiBaseObjectsProcessorTemplate<\n HandlerType,\n // OptionType,\n ProcessorType extends SuiBaseObjectsProcessor<HandlerType>\n> {\n id: number\n objectHandlers: ObjectHandler<HandlerType>[] = []\n binds = new Set<string>()\n\n protected constructor() {\n this.id = SuiAccountProcessorTemplateState.INSTANCE.getValues().length\n SuiAccountProcessorTemplateState.INSTANCE.addValue(this)\n }\n\n abstract createProcessor(options: SuiObjectBindOptions): ProcessorType\n\n bind(options: SuiObjectBindOptions, ctx: SuiContext): void {\n options.network = options.network || ctx.network\n const sig = [options.network, options.objectId].join('_')\n if (this.binds.has(sig)) {\n console.log(`Same object id can be bind to one template only once, ignore duplicate bind: ${sig}`)\n return\n }\n this.binds.add(sig)\n\n const processor = this.createProcessor(options)\n for (const h of this.objectHandlers) {\n processor.onInterval(h.handler, h.timeIntervalInMinutes, h.versionInterval, h.type, h.fetchConfig)\n }\n const config = processor.config\n\n ctx._res.states.configUpdated = true\n TemplateInstanceState.INSTANCE.addValue({\n templateId: this.id,\n contract: {\n name: '',\n chainId: config.network,\n address: config.address,\n abi: '',\n },\n startBlock: config.startCheckpoint,\n endBlock: 0n,\n })\n }\n\n protected onInterval(\n handler: HandlerType,\n timeInterval: HandleInterval | undefined,\n versionInterval: HandleInterval | undefined,\n type: string | undefined,\n fetchConfig: Partial<MoveAccountFetchConfig> | undefined\n ): this {\n this.objectHandlers.push({\n handler: handler,\n timeIntervalInMinutes: timeInterval,\n versionInterval: versionInterval,\n type,\n fetchConfig: { ...DEFAULT_FETCH_CONFIG, ...fetchConfig },\n })\n return this\n }\n\n public onTimeInterval(\n handler: HandlerType,\n timeIntervalInMinutes = 60,\n backfillTimeIntervalInMinutes = 240,\n type?: string,\n fetchConfig?: Partial<MoveAccountFetchConfig>\n ): this {\n return this.onInterval(\n handler,\n {\n recentInterval: timeIntervalInMinutes,\n backfillInterval: backfillTimeIntervalInMinutes,\n },\n undefined,\n type,\n fetchConfig\n )\n }\n\n public onSlotInterval(\n handler: HandlerType,\n slotInterval = 100000,\n backfillSlotInterval = 400000,\n type?: string,\n fetchConfig?: Partial<MoveAccountFetchConfig>\n ): this {\n return this.onInterval(\n handler,\n undefined,\n { recentInterval: slotInterval, backfillInterval: backfillSlotInterval },\n type,\n fetchConfig\n )\n }\n}\n\n// export class SuiAddressProcessorTemplate extends SuiBaseObjectsProcessorTemplate<\n// (objects: SuiMoveObject[], ctx: SuiObjectsContext) => PromiseOrVoid,\n// SuiBindOptions,\n// SuiAddressProcessor\n// > {\n// bind(options: SuiBindOptions, ctx: SuiContext): SuiAddressProcessor {\n// return this.bindInternal(SuiAddressProcessorTemplate.bind(options), ctx)\n// }\n// }\n\nexport class SuiObjectsProcessorTemplate extends SuiBaseObjectsProcessorTemplate<\n (self: SuiMoveObject, dynamicFieldObjects: SuiMoveObject[], ctx: SuiObjectsContext) => PromiseOrVoid,\n // SuiObjectBindOptions,\n SuiObjectProcessor\n> {\n createProcessor(options: SuiObjectBindOptions): SuiObjectProcessor {\n return SuiObjectProcessor.bind(options)\n }\n}\n\nexport class SuiWrappedObjectProcessorTemplate extends SuiBaseObjectsProcessorTemplate<\n (dynamicFieldObjects: SuiMoveObject[], ctx: SuiObjectsContext) => PromiseOrVoid,\n // SuiObjectBindOptions,\n SuiWrappedObjectProcessor\n> {\n createProcessor(options: SuiObjectBindOptions): SuiWrappedObjectProcessor {\n return SuiWrappedObjectProcessor.bind(options)\n }\n}\n"]}
|