@sentio/sdk 3.0.0-rc-next.5 → 3.0.0-rc.10
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 +22 -22
- package/lib/aptos/aptos-plugin.js.map +1 -1
- package/lib/aptos/aptos-resource-processor-template.d.ts +2 -1
- package/lib/aptos/aptos-resource-processor-template.d.ts.map +1 -1
- package/lib/aptos/aptos-resource-processor-template.js +28 -25
- package/lib/aptos/aptos-resource-processor-template.js.map +1 -1
- package/lib/core/base-context.d.ts +2 -1
- package/lib/core/base-context.d.ts.map +1 -1
- package/lib/core/base-context.js +6 -0
- package/lib/core/base-context.js.map +1 -1
- package/lib/core/core-plugin.d.ts.map +1 -1
- package/lib/core/core-plugin.js +0 -3
- package/lib/core/core-plugin.js.map +1 -1
- package/lib/core/normalization.d.ts.map +1 -1
- package/lib/core/normalization.js +1 -7
- package/lib/core/normalization.js.map +1 -1
- package/lib/cosmos/cosmos-plugin.d.ts +0 -1
- package/lib/cosmos/cosmos-plugin.d.ts.map +1 -1
- package/lib/cosmos/cosmos-plugin.js +0 -4
- package/lib/cosmos/cosmos-plugin.js.map +1 -1
- package/lib/eth/base-processor-template.d.ts +2 -1
- package/lib/eth/base-processor-template.d.ts.map +1 -1
- package/lib/eth/base-processor-template.js +26 -24
- package/lib/eth/base-processor-template.js.map +1 -1
- package/lib/eth/base-processor.d.ts +2 -2
- package/lib/eth/base-processor.d.ts.map +1 -1
- package/lib/eth/base-processor.js +5 -1
- package/lib/eth/base-processor.js.map +1 -1
- package/lib/eth/eth-plugin.d.ts +0 -1
- package/lib/eth/eth-plugin.d.ts.map +1 -1
- package/lib/eth/eth-plugin.js +12 -8
- package/lib/eth/eth-plugin.js.map +1 -1
- package/lib/eth/eth.d.ts +1 -0
- package/lib/eth/eth.d.ts.map +1 -1
- package/lib/eth/eth.js.map +1 -1
- package/lib/fuel/fuel-plugin.d.ts +0 -1
- package/lib/fuel/fuel-plugin.d.ts.map +1 -1
- package/lib/fuel/fuel-plugin.js +0 -4
- package/lib/fuel/fuel-plugin.js.map +1 -1
- package/lib/fuel/fuel-processor-template.d.ts +2 -1
- package/lib/fuel/fuel-processor-template.d.ts.map +1 -1
- package/lib/fuel/fuel-processor-template.js +28 -23
- package/lib/fuel/fuel-processor-template.js.map +1 -1
- package/lib/iota/iota-object-processor-template.d.ts +2 -1
- package/lib/iota/iota-object-processor-template.d.ts.map +1 -1
- package/lib/iota/iota-object-processor-template.js +51 -39
- package/lib/iota/iota-object-processor-template.js.map +1 -1
- package/lib/iota/iota-plugin-part.js +1 -1
- package/lib/iota/iota-plugin-part.js.map +1 -1
- package/lib/stark/starknet-plugin.d.ts +0 -1
- package/lib/stark/starknet-plugin.d.ts.map +1 -1
- package/lib/stark/starknet-plugin.js +0 -4
- package/lib/stark/starknet-plugin.js.map +1 -1
- package/lib/sui/sui-object-processor-template.d.ts +2 -1
- package/lib/sui/sui-object-processor-template.d.ts.map +1 -1
- package/lib/sui/sui-object-processor-template.js +51 -39
- package/lib/sui/sui-object-processor-template.js.map +1 -1
- package/lib/sui/sui-plugin-part.js +1 -1
- package/lib/sui/sui-plugin-part.js.map +1 -1
- package/lib/testing/test-processor-server.d.ts +12 -3
- package/lib/testing/test-processor-server.d.ts.map +1 -1
- package/lib/testing/test-processor-server.js +47 -7
- package/lib/testing/test-processor-server.js.map +1 -1
- package/package.json +5 -5
- package/src/aptos/aptos-plugin.ts +23 -23
- package/src/aptos/aptos-resource-processor-template.ts +36 -30
- package/src/core/base-context.ts +8 -1
- package/src/core/core-plugin.ts +0 -4
- package/src/core/normalization.ts +1 -6
- package/src/cosmos/cosmos-plugin.ts +0 -5
- package/src/eth/base-processor-template.ts +32 -27
- package/src/eth/base-processor.ts +19 -15
- package/src/eth/eth-plugin.ts +11 -9
- package/src/eth/eth.ts +2 -0
- package/src/fuel/fuel-plugin.ts +0 -5
- package/src/fuel/fuel-processor-template.ts +34 -26
- package/src/iota/iota-object-processor-template.ts +61 -46
- package/src/iota/iota-plugin-part.ts +1 -1
- package/src/stark/starknet-plugin.ts +0 -5
- package/src/sui/sui-object-processor-template.ts +63 -47
- package/src/sui/sui-plugin-part.ts +1 -1
- package/src/testing/test-processor-server.ts +64 -10
- package/lib/core/template.d.ts +0 -2
- package/lib/core/template.d.ts.map +0 -1
- package/lib/core/template.js +0 -2
- package/lib/core/template.js.map +0 -1
- package/src/core/template.ts +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"test-processor-server.d.ts","sourceRoot":"","sources":["../../src/testing/test-processor-server.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,EACb,cAAc,EACd,WAAW,EACX,WAAW,EACX,KAAK,EACL,uBAAuB,EACvB,wBAAwB,EACxB,sBAAsB,EACtB,sBAAsB,EACtB,oBAAoB,EACpB,qBAAqB,EACrB,8BAA8B,EAC9B,oBAAoB,EACpB,qBAAqB,EACrB,2BAA2B,EAC3B,YAAY,
|
|
1
|
+
{"version":3,"file":"test-processor-server.d.ts","sourceRoot":"","sources":["../../src/testing/test-processor-server.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,EACb,cAAc,EACd,WAAW,EACX,WAAW,EACX,KAAK,EACL,uBAAuB,EACvB,wBAAwB,EACxB,sBAAsB,EACtB,sBAAsB,EACtB,oBAAoB,EACpB,qBAAqB,EACrB,8BAA8B,EAC9B,oBAAoB,EACpB,qBAAqB,EACrB,2BAA2B,EAC3B,YAAY,EACZ,gBAAgB,EAChB,gBAAgB,EACjB,MAAM,gBAAgB,CAAA;AACvB,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAC9C,OAAO,EAEL,mBAAmB,EAEnB,oBAAoB,EAEpB,YAAY,EACb,MAAM,iBAAiB,CAAA;AAExB,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAC7C,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAC/C,OAAO,E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,OAAO,cAAe,GAAG,OAAO,CAAC,qBAAqB,CAAC;IAQtG,eAAe,CACb,OAAO,EAAE,sBAAsB,EAC/B,OAAO,GAAE,WAA0B,GAClC,OAAO,CAAC,sBAAsB,CAAC;IAc5B,cAAc,CAAC,OAAO,EAAE,WAAW,EAAE,OAAO,GAAE,WAA0B,GAAG,OAAO,CAAC,sBAAsB,CAAC;IAchH,qBAAqB,CACnB,QAAQ,EAAE,aAAa,CAAC,oBAAoB,CAAC,EAC7C,OAAO,EAAE,WAAW,GACnB,2BAA2B,CAAC,WAAW,CAAC,qBAAqB,CAAC,CAAC;IAIlE,wBAAwB,CACtB,QAAQ,EAAE,aAAa,CAAC,uBAAuB,CAAC,EAChD,OAAO,EAAE,WAAW,GACnB,2BAA2B,CAAC,WAAW,CAAC,wBAAwB,CAAC,CAAC;IAOrE,IAAI,EAAE,mBAEL;IAED,IAAI,KAAK,sCAER;CACF;AAED,cAAM,gBAAiB,SAAQ,YAAa,YAAW,mBAAmB;IAEtE,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC,WAAW,CAAC,qBAAqB,CAAC,CAAC;gBAApD,OAAO,EAAE,OAAO,CAAC,WAAW,CAAC,qBAAqB,CAAC,CAAC,EAC7D,SAAS,EAAE,MAAM;IAKnB,iBAAiB,EAAE,gBAAgB,EAAE,CAAK;IAE1C,mBAAmB,CAAC,SAAS,EAAE,KAAK,CAAC,gBAAgB,CAAC,EAAE,MAAM,EAAE,OAAO,GAAG,IAAI;IAS9E,qBAAqB,CAAC,UAAU,EAAE,KAAK,CAAC,gBAAgB,CAAC,GAAG,IAAI;CAGjE"}
|
|
@@ -49,7 +49,7 @@ export class TestProcessorServer {
|
|
|
49
49
|
}
|
|
50
50
|
// start a memory database for testing
|
|
51
51
|
const subject = new Subject();
|
|
52
|
-
this.storeContext = new
|
|
52
|
+
this.storeContext = new TestStoreContext(subject, 1);
|
|
53
53
|
this._db = new MemoryDatabase(this.storeContext);
|
|
54
54
|
}
|
|
55
55
|
async start(request = { templateInstances: [] }, context = TEST_CONTEXT) {
|
|
@@ -58,23 +58,44 @@ export class TestProcessorServer {
|
|
|
58
58
|
this.contractConfigs = config.contractConfigs;
|
|
59
59
|
this.accountConfigs = config.accountConfigs;
|
|
60
60
|
this._db.start();
|
|
61
|
+
this.storeContext.templateInstances = request.templateInstances;
|
|
61
62
|
return res;
|
|
62
63
|
}
|
|
63
64
|
stop(request, context = TEST_CONTEXT) {
|
|
64
65
|
return this.service.stop(request, context);
|
|
65
66
|
}
|
|
66
|
-
getConfig(request, context = TEST_CONTEXT) {
|
|
67
|
-
|
|
67
|
+
async getConfig(request, context = TEST_CONTEXT) {
|
|
68
|
+
const config = await this.service.getConfig(request, context);
|
|
69
|
+
return {
|
|
70
|
+
...config,
|
|
71
|
+
templateInstances: this.storeContext.templateInstances
|
|
72
|
+
};
|
|
68
73
|
}
|
|
69
74
|
processBindings(request, context = TEST_CONTEXT) {
|
|
70
|
-
return PluginManager.INSTANCE.dbContextLocalStorage.run(this.storeContext, () => {
|
|
71
|
-
|
|
75
|
+
return PluginManager.INSTANCE.dbContextLocalStorage.run(this.storeContext, async () => {
|
|
76
|
+
const ret = await this.service.processBindings(request, context);
|
|
77
|
+
if (ret.result?.states?.configUpdated) {
|
|
78
|
+
// template may changed
|
|
79
|
+
await PluginManager.INSTANCE.updateTemplates({
|
|
80
|
+
chainId: request.bindings[0].chainId,
|
|
81
|
+
templateInstances: this.storeContext.templateInstances
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
return ret;
|
|
72
85
|
});
|
|
73
86
|
}
|
|
74
|
-
processBinding(request, context = TEST_CONTEXT) {
|
|
75
|
-
|
|
87
|
+
async processBinding(request, context = TEST_CONTEXT) {
|
|
88
|
+
const ret = await PluginManager.INSTANCE.dbContextLocalStorage.run(this.storeContext, () => {
|
|
76
89
|
return this.service.processBindings({ bindings: [request] }, context);
|
|
77
90
|
});
|
|
91
|
+
if (ret.result?.states?.configUpdated) {
|
|
92
|
+
// template may changed
|
|
93
|
+
await PluginManager.INSTANCE.updateTemplates({
|
|
94
|
+
chainId: request.chainId,
|
|
95
|
+
templateInstances: this.storeContext.templateInstances
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
return ret;
|
|
78
99
|
}
|
|
79
100
|
processBindingsStream(requests, context) {
|
|
80
101
|
throw new Error('Method not implemented.');
|
|
@@ -92,4 +113,23 @@ export class TestProcessorServer {
|
|
|
92
113
|
return this._db.store;
|
|
93
114
|
}
|
|
94
115
|
}
|
|
116
|
+
class TestStoreContext extends StoreContext {
|
|
117
|
+
subject;
|
|
118
|
+
constructor(subject, processId) {
|
|
119
|
+
super(subject, processId);
|
|
120
|
+
this.subject = subject;
|
|
121
|
+
}
|
|
122
|
+
templateInstances = [];
|
|
123
|
+
sendTemplateRequest(templates, remove) {
|
|
124
|
+
if (remove) {
|
|
125
|
+
this.templateInstances = this.templateInstances.filter((i) => !templates.find((t) => t.templateId === i.templateId && t.contract?.address === i.contract?.address));
|
|
126
|
+
}
|
|
127
|
+
else {
|
|
128
|
+
this.templateInstances.push(...templates);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
sendTimeseriesRequest(timeseries) {
|
|
132
|
+
throw new Error('Method not implemented.');
|
|
133
|
+
}
|
|
134
|
+
}
|
|
95
135
|
//# sourceMappingURL=test-processor-server.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"test-processor-server.js","sourceRoot":"","sources":["../../src/testing/test-processor-server.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"test-processor-server.js","sourceRoot":"","sources":["../../src/testing/test-processor-server.ts"],"names":[],"mappings":"AAqBA,OAAO,EACL,SAAS,EAET,aAAa,EACb,oBAAoB,EACpB,KAAK,EACL,YAAY,EACb,MAAM,iBAAiB,CAAA;AAExB,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAC7C,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAC/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,SAAS,CAAC,CAAA;QAHhB,YAAO,GAAP,OAAO,CAA6C;IAI/D,CAAC;IAED,iBAAiB,GAAuB,EAAE,CAAA;IAE1C,mBAAmB,CAAC,SAAkC,EAAE,MAAe;QACrE,IAAI,MAAM,EAAE,CAAC;YACX,IAAI,CAAC,iBAAiB,GAAG,IAAI,CAAC,iBAAiB,CAAC,MAAM,CACpD,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,UAAU,KAAK,CAAC,CAAC,UAAU,IAAI,CAAC,CAAC,QAAQ,EAAE,OAAO,KAAK,CAAC,CAAC,QAAQ,EAAE,OAAO,CAAC,CAC5G,CAAA;QACH,CAAC;aAAM,CAAC;YACN,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,GAAG,SAAS,CAAC,CAAA;QAC3C,CAAC;IACH,CAAC;IACD,qBAAqB,CAAC,UAAmC;QACvD,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAA;IAC5C,CAAC;CACF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sentio/sdk",
|
|
3
|
-
"version": "3.0.0-rc
|
|
3
|
+
"version": "3.0.0-rc.10",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -66,7 +66,7 @@
|
|
|
66
66
|
"@sentio/abi-wan-kanabi": "2.2.2-1",
|
|
67
67
|
"@sentio/api": "1.0.2",
|
|
68
68
|
"@sentio/bigdecimal": "9.1.1-patch.3",
|
|
69
|
-
"@sentio/chain": "~3.4.
|
|
69
|
+
"@sentio/chain": "~3.4.15",
|
|
70
70
|
"@sentio/ethers-v6": "^1.0.29",
|
|
71
71
|
"@solana/web3.js": "^1.98.3",
|
|
72
72
|
"@typemove/aptos": "~1.13.3",
|
|
@@ -77,7 +77,7 @@
|
|
|
77
77
|
"chalk": "^5.3.0",
|
|
78
78
|
"csv-parse": "^6.0.0",
|
|
79
79
|
"ethers": "npm:@sentio/ethers@6.13.1-patch.6",
|
|
80
|
-
"fuels": "^0.
|
|
80
|
+
"fuels": "^0.102.0",
|
|
81
81
|
"got": "^14.4.7",
|
|
82
82
|
"graphql": "^16.11.0",
|
|
83
83
|
"js-sha3": "^0.9.3",
|
|
@@ -97,8 +97,8 @@
|
|
|
97
97
|
"typechain": "^8.3.2",
|
|
98
98
|
"utility-types": "^3.11.0",
|
|
99
99
|
"yaml": "^2.3.4",
|
|
100
|
-
"@sentio/
|
|
101
|
-
"@sentio/
|
|
100
|
+
"@sentio/protos": "3.0.0-rc.10",
|
|
101
|
+
"@sentio/runtime": "^3.0.0-rc.10"
|
|
102
102
|
},
|
|
103
103
|
"peerDependencies": {
|
|
104
104
|
"@sentio/tsup": "^8.3.5-rc.1"
|
|
@@ -55,7 +55,7 @@ export class AptosPlugin extends Plugin {
|
|
|
55
55
|
const template: AptosResourceProcessorTemplate =
|
|
56
56
|
AptosResourceProcessorTemplateState.INSTANCE.getValues()[instance.templateId]
|
|
57
57
|
|
|
58
|
-
template.
|
|
58
|
+
template.startInstance(
|
|
59
59
|
{
|
|
60
60
|
address: instance.contract?.address || '',
|
|
61
61
|
network: <AptosNetwork>instance.contract?.chainId || AptosNetwork.MAIN_NET,
|
|
@@ -127,10 +127,31 @@ export class AptosPlugin extends Plugin {
|
|
|
127
127
|
contractConfig.moveCallConfigs.push(functionHandlerConfig)
|
|
128
128
|
}
|
|
129
129
|
|
|
130
|
+
// 3. Prepare onInterval handlers
|
|
131
|
+
for (const handler of aptosProcessor.transactionIntervalHandlers) {
|
|
132
|
+
const handlerId = this.handlerRegister.register(handler.handler, chainId)
|
|
133
|
+
this.partitionManager.registerPartitionHandler(HandlerType.APT_CALL, handlerId, handler.partitionHandler)
|
|
134
|
+
contractConfig.moveIntervalConfigs.push({
|
|
135
|
+
intervalConfig: {
|
|
136
|
+
handlerId: handlerId,
|
|
137
|
+
handlerName: handler.handlerName,
|
|
138
|
+
minutes: 0,
|
|
139
|
+
minutesInterval: handler.timeIntervalInMinutes,
|
|
140
|
+
slot: 0,
|
|
141
|
+
slotInterval: handler.versionInterval,
|
|
142
|
+
fetchConfig: undefined
|
|
143
|
+
},
|
|
144
|
+
ownerType: MoveOwnerType.ADDRESS,
|
|
145
|
+
fetchConfig: handler.fetchConfig,
|
|
146
|
+
resourceFetchConfig: undefined,
|
|
147
|
+
type: ''
|
|
148
|
+
})
|
|
149
|
+
}
|
|
150
|
+
|
|
130
151
|
config.contractConfigs.push(contractConfig)
|
|
131
152
|
}
|
|
132
153
|
|
|
133
|
-
// Prepare resource handlers
|
|
154
|
+
// Prepare resource change handlers
|
|
134
155
|
for (const aptosProcessor of AptosProcessorState.INSTANCE.getValues()) {
|
|
135
156
|
const chainId = aptosProcessor.getChainId()
|
|
136
157
|
if (forChainId !== undefined && forChainId !== chainId.toString()) {
|
|
@@ -153,27 +174,6 @@ export class AptosPlugin extends Plugin {
|
|
|
153
174
|
})
|
|
154
175
|
}
|
|
155
176
|
|
|
156
|
-
// Prepare interval handlers
|
|
157
|
-
for (const handler of aptosProcessor.transactionIntervalHandlers) {
|
|
158
|
-
const handlerId = this.handlerRegister.register(handler.handler, chainId)
|
|
159
|
-
this.partitionManager.registerPartitionHandler(HandlerType.APT_CALL, handlerId, handler.partitionHandler)
|
|
160
|
-
accountConfig.moveIntervalConfigs.push({
|
|
161
|
-
intervalConfig: {
|
|
162
|
-
handlerId: handlerId,
|
|
163
|
-
handlerName: handler.handlerName,
|
|
164
|
-
minutes: 0,
|
|
165
|
-
minutesInterval: handler.timeIntervalInMinutes,
|
|
166
|
-
slot: 0,
|
|
167
|
-
slotInterval: handler.versionInterval,
|
|
168
|
-
fetchConfig: undefined
|
|
169
|
-
},
|
|
170
|
-
ownerType: MoveOwnerType.ADDRESS,
|
|
171
|
-
fetchConfig: handler.fetchConfig,
|
|
172
|
-
resourceFetchConfig: undefined,
|
|
173
|
-
type: ''
|
|
174
|
-
})
|
|
175
|
-
}
|
|
176
|
-
|
|
177
177
|
config.accountConfigs.push(accountConfig)
|
|
178
178
|
}
|
|
179
179
|
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { ListStateStorage, processMetrics } from '@sentio/runtime'
|
|
2
|
-
import { TemplateInstanceState } from '../core/template.js'
|
|
3
2
|
import { AptosResourcesContext } from './context.js'
|
|
4
3
|
import { AptosBindOptions } from './network.js'
|
|
5
4
|
import { AptosResourcesProcessor, DEFAULT_RESOURCE_FETCH_CONFIG } from './aptos-processor.js'
|
|
6
|
-
import { HandleInterval, MoveAccountFetchConfig } from '@sentio/protos'
|
|
5
|
+
import { HandleInterval, MoveAccountFetchConfig, TemplateInstance } from '@sentio/protos'
|
|
7
6
|
import { MoveResource } from '@aptos-labs/ts-sdk'
|
|
8
7
|
import { PromiseOrVoid } from '../core/index.js'
|
|
9
8
|
import { getHandlerName, proxyProcessor } from '../utils/metrics.js'
|
|
@@ -24,8 +23,8 @@ class Handler {
|
|
|
24
23
|
|
|
25
24
|
export class AptosResourceProcessorTemplate {
|
|
26
25
|
id: number
|
|
27
|
-
binds = new Set<string>()
|
|
28
26
|
handlers: Handler[] = []
|
|
27
|
+
instances = new Set<string>()
|
|
29
28
|
|
|
30
29
|
constructor() {
|
|
31
30
|
this.id = AptosResourceProcessorTemplateState.INSTANCE.getValues().length
|
|
@@ -40,14 +39,45 @@ export class AptosResourceProcessorTemplate {
|
|
|
40
39
|
bind(options: AptosBindOptions, ctx: AptosResourcesContext): void {
|
|
41
40
|
options.network = options.network || ctx.network
|
|
42
41
|
options.startVersion = options.startVersion || ctx.version
|
|
42
|
+
|
|
43
|
+
const instance: TemplateInstance = {
|
|
44
|
+
templateId: this.id,
|
|
45
|
+
contract: {
|
|
46
|
+
name: '',
|
|
47
|
+
chainId: options.network,
|
|
48
|
+
address: options.address,
|
|
49
|
+
abi: ''
|
|
50
|
+
},
|
|
51
|
+
startBlock: options.startVersion ? BigInt(options.startVersion) : 0n,
|
|
52
|
+
endBlock: options.endVersion ? BigInt(options.endVersion) : 0n,
|
|
53
|
+
baseLabels: options.baseLabels
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
ctx.sendTemplateInstance(instance)
|
|
57
|
+
|
|
58
|
+
ctx.update({
|
|
59
|
+
states: {
|
|
60
|
+
configUpdated: true
|
|
61
|
+
}
|
|
62
|
+
})
|
|
63
|
+
|
|
64
|
+
processMetrics.processor_template_instance_count.add(1, {
|
|
65
|
+
chain_id: options.network,
|
|
66
|
+
template: this.constructor.name
|
|
67
|
+
})
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
startInstance(options: AptosBindOptions, ctx: AptosResourcesContext): void {
|
|
71
|
+
options.network = options.network || ctx.network
|
|
72
|
+
options.startVersion = options.startVersion || ctx.version
|
|
43
73
|
const id = options.address
|
|
44
74
|
|
|
45
75
|
const sig = [options.network, id].join('_')
|
|
46
|
-
if (this.
|
|
47
|
-
console.
|
|
76
|
+
if (this.instances.has(sig)) {
|
|
77
|
+
console.debug(`Same object id can be bind to one template only once, ignore duplicate bind: ${sig}`)
|
|
48
78
|
return
|
|
49
79
|
}
|
|
50
|
-
this.
|
|
80
|
+
this.instances.add(sig)
|
|
51
81
|
|
|
52
82
|
const processor = this.createProcessor(options)
|
|
53
83
|
for (const h of this.handlers) {
|
|
@@ -60,30 +90,6 @@ export class AptosResourceProcessorTemplate {
|
|
|
60
90
|
h.handlerName
|
|
61
91
|
)
|
|
62
92
|
}
|
|
63
|
-
const config = processor.config
|
|
64
|
-
|
|
65
|
-
ctx.update({
|
|
66
|
-
states: {
|
|
67
|
-
configUpdated: true
|
|
68
|
-
}
|
|
69
|
-
})
|
|
70
|
-
TemplateInstanceState.INSTANCE.addValue({
|
|
71
|
-
templateId: this.id,
|
|
72
|
-
contract: {
|
|
73
|
-
name: '',
|
|
74
|
-
chainId: config.network,
|
|
75
|
-
address: config.address,
|
|
76
|
-
abi: ''
|
|
77
|
-
},
|
|
78
|
-
startBlock: config.startVersion,
|
|
79
|
-
endBlock: 0n,
|
|
80
|
-
baseLabels: config.baseLabels
|
|
81
|
-
})
|
|
82
|
-
|
|
83
|
-
processMetrics.processor_template_instance_count.add(1, {
|
|
84
|
-
chain_id: options.network,
|
|
85
|
-
template: this.constructor.name
|
|
86
|
-
})
|
|
87
93
|
}
|
|
88
94
|
|
|
89
95
|
protected onInterval(
|
package/src/core/base-context.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ProcessResult, RecordMetaData } from '@sentio/protos'
|
|
1
|
+
import { ProcessResult, RecordMetaData, TemplateInstance } from '@sentio/protos'
|
|
2
2
|
import { EventLoggerBinding } from './event-logger.js'
|
|
3
3
|
import { Meter, Labels } from './meter.js'
|
|
4
4
|
import { ChainId } from '@sentio/chain'
|
|
@@ -92,4 +92,11 @@ export abstract class BaseContext {
|
|
|
92
92
|
this._store = new Store(dbContext)
|
|
93
93
|
}
|
|
94
94
|
}
|
|
95
|
+
|
|
96
|
+
sendTemplateInstance(instance: TemplateInstance, unbind: boolean = false) {
|
|
97
|
+
const store = PluginManager.INSTANCE.dbContextLocalStorage.getStore()
|
|
98
|
+
if (store && 'sendTemplateRequest' in store) {
|
|
99
|
+
store?.sendTemplateRequest([instance], unbind)
|
|
100
|
+
}
|
|
101
|
+
}
|
|
95
102
|
}
|
package/src/core/core-plugin.ts
CHANGED
|
@@ -3,7 +3,6 @@ import { InitResponse, ProcessConfigResponse } from '@sentio/protos'
|
|
|
3
3
|
|
|
4
4
|
import { MetricState } from './meter.js'
|
|
5
5
|
import { ExporterState } from './exporter.js'
|
|
6
|
-
import { TemplateInstanceState } from './template.js'
|
|
7
6
|
import { EventLoggerState } from './event-logger.js'
|
|
8
7
|
import { DatabaseSchemaState, mergeSchemas } from './database-schema.js'
|
|
9
8
|
|
|
@@ -11,9 +10,6 @@ export class CorePlugin extends Plugin {
|
|
|
11
10
|
name: string = 'CorePlugin'
|
|
12
11
|
|
|
13
12
|
async configure(config: ProcessConfigResponse): Promise<void> {
|
|
14
|
-
// This syntax is to copy values instead of using references
|
|
15
|
-
config.templateInstances = [...TemplateInstanceState.INSTANCE.getValues()]
|
|
16
|
-
|
|
17
13
|
this.initStartupConfig(config)
|
|
18
14
|
}
|
|
19
15
|
|
|
@@ -119,12 +119,7 @@ function normalizeToRichValue(value: any): RichValue {
|
|
|
119
119
|
if (isNaN(value) || !isFinite(value)) {
|
|
120
120
|
throw new Error("can't submit NaN or Infinity value")
|
|
121
121
|
}
|
|
122
|
-
|
|
123
|
-
return { int64Value: BigInt(value) }
|
|
124
|
-
} else if (Number.isInteger(value)) {
|
|
125
|
-
throw new Error('This value is outside of safe integer range, please use BigDecimal or BigInt instead')
|
|
126
|
-
}
|
|
127
|
-
return { floatValue: value }
|
|
122
|
+
return { bigdecimalValue: toBigDecimal(new BigDecimal(value)) }
|
|
128
123
|
case 'function':
|
|
129
124
|
return { nullValue: RichValue_NullValue.UNRECOGNIZED }
|
|
130
125
|
case 'symbol':
|
|
@@ -9,7 +9,6 @@ import {
|
|
|
9
9
|
StartRequest
|
|
10
10
|
} from '@sentio/protos'
|
|
11
11
|
import { ServerError, Status } from 'nice-grpc'
|
|
12
|
-
import { TemplateInstanceState } from '../core/template.js'
|
|
13
12
|
import { HandlerRegister } from '../core/handler-register.js'
|
|
14
13
|
import { CosmosProcessorState } from './types.js'
|
|
15
14
|
|
|
@@ -72,10 +71,6 @@ export class CosmosPlugin extends Plugin {
|
|
|
72
71
|
|
|
73
72
|
async start(request: StartRequest) {}
|
|
74
73
|
|
|
75
|
-
stateDiff(config: ProcessConfigResponse): boolean {
|
|
76
|
-
return TemplateInstanceState.INSTANCE.getValues().length !== config.templateInstances.length
|
|
77
|
-
}
|
|
78
|
-
|
|
79
74
|
async processTransaction(binding: DataBinding): Promise<ProcessResult> {
|
|
80
75
|
if (!binding.data?.cosmosCall?.transaction) {
|
|
81
76
|
throw new ServerError(Status.INVALID_ARGUMENT, "transaction can't be null")
|
|
@@ -8,7 +8,6 @@ import { ListStateStorage, processMetrics } from '@sentio/runtime'
|
|
|
8
8
|
import { BlockParams } from 'ethers/providers'
|
|
9
9
|
import { DeferredTopicFilter } from 'ethers/contract'
|
|
10
10
|
import { TypedEvent, TypedCallTrace, validateAndNormalizeAddress } from './eth.js'
|
|
11
|
-
import { TemplateInstanceState } from '../core/template.js'
|
|
12
11
|
import { getHandlerName, proxyProcessor } from '../utils/metrics.js'
|
|
13
12
|
|
|
14
13
|
export class ProcessorTemplateProcessorState extends ListStateStorage<
|
|
@@ -22,7 +21,6 @@ export abstract class BaseProcessorTemplate<
|
|
|
22
21
|
TBoundContractView extends BoundContractView<TContract, ContractView<TContract>>
|
|
23
22
|
> {
|
|
24
23
|
id: number
|
|
25
|
-
binds = new Set<string>()
|
|
26
24
|
blockHandlers: {
|
|
27
25
|
handlerName: string
|
|
28
26
|
handler: (block: BlockParams, ctx: ContractContext<TContract, TBoundContractView>) => PromiseOrVoid
|
|
@@ -58,6 +56,8 @@ export abstract class BaseProcessorTemplate<
|
|
|
58
56
|
fetchConfig?: EthFetchConfig
|
|
59
57
|
}[] = []
|
|
60
58
|
|
|
59
|
+
instances = new Set<string>()
|
|
60
|
+
|
|
61
61
|
constructor() {
|
|
62
62
|
this.id = ProcessorTemplateProcessorState.INSTANCE.getValues().length
|
|
63
63
|
ProcessorTemplateProcessorState.INSTANCE.addValue(this)
|
|
@@ -72,18 +72,43 @@ export abstract class BaseProcessorTemplate<
|
|
|
72
72
|
public bind(options: Omit<BindOptions, 'network'>, ctx: EthContext): void {
|
|
73
73
|
options = { ...options, address: validateAndNormalizeAddress(options.address) }
|
|
74
74
|
|
|
75
|
+
const instance: TemplateInstance = {
|
|
76
|
+
templateId: this.id,
|
|
77
|
+
contract: {
|
|
78
|
+
address: options.address,
|
|
79
|
+
name: options.name || '',
|
|
80
|
+
chainId: ctx.chainId,
|
|
81
|
+
abi: ''
|
|
82
|
+
},
|
|
83
|
+
startBlock: BigInt(options.startBlock || 0),
|
|
84
|
+
endBlock: BigInt(options.endBlock || 0),
|
|
85
|
+
baseLabels: options.baseLabels
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
ctx.sendTemplateInstance(instance)
|
|
89
|
+
|
|
90
|
+
ctx.update({
|
|
91
|
+
states: {
|
|
92
|
+
configUpdated: true
|
|
93
|
+
}
|
|
94
|
+
})
|
|
95
|
+
|
|
96
|
+
processMetrics.processor_template_instance_count.add(1, { chain_id: ctx.chainId, template: this.constructor.name })
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
public startInstance(options: Omit<BindOptions, 'network'>, ctx: EthContext) {
|
|
100
|
+
options = { ...options, address: validateAndNormalizeAddress(options.address) }
|
|
75
101
|
const sig = getOptionsSignature({
|
|
76
102
|
address: options.address,
|
|
77
103
|
network: ctx.chainId
|
|
78
104
|
})
|
|
79
|
-
|
|
80
|
-
|
|
105
|
+
|
|
106
|
+
if (this.instances.has(sig)) {
|
|
107
|
+
console.debug(`Same address can be bind to one template only once, ignore duplicate bind: ${sig}`)
|
|
81
108
|
return
|
|
82
109
|
}
|
|
83
|
-
this.binds.add(sig)
|
|
84
110
|
|
|
85
111
|
const processor = this.bindInternal({ ...options, network: ctx.chainId })
|
|
86
|
-
|
|
87
112
|
for (const eh of this.eventHandlers) {
|
|
88
113
|
// @ts-ignore friendly
|
|
89
114
|
processor.onEthEvent(eh.handler, eh.filter, eh.fetchConfig, eh.preprocessHandler, eh.handlerName)
|
|
@@ -102,27 +127,7 @@ export abstract class BaseProcessorTemplate<
|
|
|
102
127
|
bh.handlerName
|
|
103
128
|
)
|
|
104
129
|
}
|
|
105
|
-
|
|
106
|
-
const instance: TemplateInstance = {
|
|
107
|
-
templateId: this.id,
|
|
108
|
-
contract: {
|
|
109
|
-
address: options.address,
|
|
110
|
-
name: options.name || '',
|
|
111
|
-
chainId: ctx.chainId,
|
|
112
|
-
abi: ''
|
|
113
|
-
},
|
|
114
|
-
startBlock: BigInt(options.startBlock || 0),
|
|
115
|
-
endBlock: BigInt(options.endBlock || 0),
|
|
116
|
-
baseLabels: options.baseLabels
|
|
117
|
-
}
|
|
118
|
-
TemplateInstanceState.INSTANCE.addValue(instance)
|
|
119
|
-
ctx.update({
|
|
120
|
-
states: {
|
|
121
|
-
configUpdated: true
|
|
122
|
-
}
|
|
123
|
-
})
|
|
124
|
-
|
|
125
|
-
processMetrics.processor_template_instance_count.add(1, { chain_id: ctx.chainId, template: this.constructor.name })
|
|
130
|
+
this.instances.add(sig)
|
|
126
131
|
}
|
|
127
132
|
|
|
128
133
|
protected onEthEvent(
|
|
@@ -19,6 +19,7 @@ import { ServerError, Status } from 'nice-grpc'
|
|
|
19
19
|
import {
|
|
20
20
|
fixEmptyKey,
|
|
21
21
|
formatEthData,
|
|
22
|
+
RawEvent,
|
|
22
23
|
RichBlock,
|
|
23
24
|
Trace,
|
|
24
25
|
TypedCallTrace,
|
|
@@ -520,7 +521,7 @@ export abstract class BaseProcessor<
|
|
|
520
521
|
}
|
|
521
522
|
|
|
522
523
|
protected onEthEvent(
|
|
523
|
-
handler: (event: TypedEvent, ctx: ContractContext<TContract, TBoundContractView>) => PromiseOrVoid,
|
|
524
|
+
handler: (event: TypedEvent | RawEvent, ctx: ContractContext<TContract, TBoundContractView>) => PromiseOrVoid,
|
|
524
525
|
filter: DeferredTopicFilter | DeferredTopicFilter[],
|
|
525
526
|
handlerOptions?: HandlerOptions<EthFetchConfig, TypedEvent>,
|
|
526
527
|
preprocessHandler: (
|
|
@@ -560,7 +561,23 @@ export abstract class BaseProcessor<
|
|
|
560
561
|
if (processor.config.address === '*') {
|
|
561
562
|
contractView.address = log.address
|
|
562
563
|
}
|
|
563
|
-
|
|
564
|
+
const ctx = new ContractContext<TContract, TBoundContractView>(
|
|
565
|
+
contractName,
|
|
566
|
+
contractView,
|
|
567
|
+
chainId,
|
|
568
|
+
data.timestamp,
|
|
569
|
+
block,
|
|
570
|
+
log,
|
|
571
|
+
undefined,
|
|
572
|
+
transaction,
|
|
573
|
+
transactionReceipt,
|
|
574
|
+
processor.config.baseLabels,
|
|
575
|
+
preparedData
|
|
576
|
+
)
|
|
577
|
+
if (handlerOptions?.skipDecoding) {
|
|
578
|
+
await handler(log, ctx)
|
|
579
|
+
return ctx.stopAndGetResult()
|
|
580
|
+
}
|
|
564
581
|
let parsed: LogDescription | null = null
|
|
565
582
|
try {
|
|
566
583
|
parsed = await getCachedParsedLog(data, processor, log)
|
|
@@ -575,19 +592,6 @@ export abstract class BaseProcessor<
|
|
|
575
592
|
throw e
|
|
576
593
|
}
|
|
577
594
|
if (parsed) {
|
|
578
|
-
const ctx = new ContractContext<TContract, TBoundContractView>(
|
|
579
|
-
contractName,
|
|
580
|
-
contractView,
|
|
581
|
-
chainId,
|
|
582
|
-
data.timestamp,
|
|
583
|
-
block,
|
|
584
|
-
log,
|
|
585
|
-
undefined,
|
|
586
|
-
transaction,
|
|
587
|
-
transactionReceipt,
|
|
588
|
-
processor.config.baseLabels,
|
|
589
|
-
preparedData
|
|
590
|
-
)
|
|
591
595
|
const event: TypedEvent = { ...log, name: parsed.name, args: fixEmptyKey(parsed) }
|
|
592
596
|
await handler(event, ctx)
|
|
593
597
|
return ctx.stopAndGetResult()
|
package/src/eth/eth-plugin.ts
CHANGED
|
@@ -32,7 +32,6 @@ import { GlobalProcessorState } from './base-processor.js'
|
|
|
32
32
|
import { validateAndNormalizeAddress } from './eth.js'
|
|
33
33
|
import { EthChainId } from '@sentio/chain'
|
|
34
34
|
import { EthContext } from './context.js'
|
|
35
|
-
import { TemplateInstanceState } from '../core/template.js'
|
|
36
35
|
import { timeOrBlockToBlockNumber } from '@sentio/sdk/utils'
|
|
37
36
|
import { HandlerRegister } from '../core/handler-register.js'
|
|
38
37
|
|
|
@@ -158,9 +157,16 @@ export class EthPlugin extends Plugin {
|
|
|
158
157
|
if (forChainId !== undefined && forChainId !== chainId.toString()) {
|
|
159
158
|
continue
|
|
160
159
|
}
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
160
|
+
let startBlock, endBlock: bigint | undefined
|
|
161
|
+
try {
|
|
162
|
+
const provider = getProvider(chainId)
|
|
163
|
+
startBlock = await timeOrBlockToBlockNumber(provider, processor.config.start)
|
|
164
|
+
endBlock = processor.config.end ? await timeOrBlockToBlockNumber(provider, processor.config.end) : undefined
|
|
165
|
+
} catch (e) {
|
|
166
|
+
console.error('failed to get start/end block', e)
|
|
167
|
+
startBlock = processor.config.start?.block != undefined ? BigInt(processor.config.start.block) : undefined
|
|
168
|
+
endBlock = processor.config.end?.block != undefined ? BigInt(processor.config.end.block) : undefined
|
|
169
|
+
}
|
|
164
170
|
|
|
165
171
|
const contractConfig = ContractConfig.fromPartial({
|
|
166
172
|
processorType: USER_PROCESSOR,
|
|
@@ -392,7 +398,7 @@ export class EthPlugin extends Plugin {
|
|
|
392
398
|
throw new ServerError(Status.INVALID_ARGUMENT, 'Contract Empty from:' + instance)
|
|
393
399
|
}
|
|
394
400
|
const ctx = new NoopContext(instance.contract.chainId as EthChainId)
|
|
395
|
-
template.
|
|
401
|
+
template.startInstance(
|
|
396
402
|
{
|
|
397
403
|
name: instance.contract.name,
|
|
398
404
|
address: validateAndNormalizeAddress(instance.contract.address),
|
|
@@ -405,10 +411,6 @@ export class EthPlugin extends Plugin {
|
|
|
405
411
|
}
|
|
406
412
|
}
|
|
407
413
|
|
|
408
|
-
stateDiff(config: ProcessConfigResponse): boolean {
|
|
409
|
-
return TemplateInstanceState.INSTANCE.getValues().length !== config.templateInstances.length
|
|
410
|
-
}
|
|
411
|
-
|
|
412
414
|
async processLog(request: DataBinding, preparedData: PreparedData | undefined): Promise<ProcessResult> {
|
|
413
415
|
if (!request.data?.ethLog?.log) {
|
|
414
416
|
throw new ServerError(Status.INVALID_ARGUMENT, "Log can't be null")
|
package/src/eth/eth.ts
CHANGED
|
@@ -45,6 +45,8 @@ export interface TypedEvent<TArgsArray extends Array<any> = any, TArgsObject = a
|
|
|
45
45
|
name: string
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
+
export type RawEvent = Record<string, any>
|
|
49
|
+
|
|
48
50
|
export type TypedEventFilter<_TEvent extends TypedEvent> = DeferredTopicFilter
|
|
49
51
|
|
|
50
52
|
export interface RichBlock extends BlockParams {
|
package/src/fuel/fuel-plugin.ts
CHANGED
|
@@ -13,7 +13,6 @@ import {
|
|
|
13
13
|
} from '@sentio/protos'
|
|
14
14
|
|
|
15
15
|
import { ServerError, Status } from 'nice-grpc'
|
|
16
|
-
import { TemplateInstanceState } from '../core/template.js'
|
|
17
16
|
import { FuelAssetProcessor } from './asset-processor.js'
|
|
18
17
|
import { FuelProcessorState } from './types.js'
|
|
19
18
|
import { FuelProcessor } from './fuel-processor.js'
|
|
@@ -191,10 +190,6 @@ export class FuelPlugin extends Plugin {
|
|
|
191
190
|
}
|
|
192
191
|
}
|
|
193
192
|
|
|
194
|
-
stateDiff(config: ProcessConfigResponse): boolean {
|
|
195
|
-
return TemplateInstanceState.INSTANCE.getValues().length !== config.templateInstances.length
|
|
196
|
-
}
|
|
197
|
-
|
|
198
193
|
async processReceipt(binding: DataBinding): Promise<ProcessResult> {
|
|
199
194
|
const receipt = binding?.data?.fuelLog
|
|
200
195
|
|