@sentio/sdk 3.0.0-rc.8 → 3.0.0-rc.9
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 +1 -1
- 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/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/eth-plugin.d.ts +0 -1
- package/lib/eth/eth-plugin.d.ts.map +1 -1
- package/lib/eth/eth-plugin.js +1 -5
- package/lib/eth/eth-plugin.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 +3 -3
- package/src/aptos/aptos-plugin.ts +1 -1
- 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/cosmos/cosmos-plugin.ts +0 -5
- package/src/eth/base-processor-template.ts +32 -27
- package/src/eth/eth-plugin.ts +1 -6
- 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
|
@@ -14,10 +14,19 @@ import {
|
|
|
14
14
|
ProcessStreamRequest,
|
|
15
15
|
ProcessStreamResponse,
|
|
16
16
|
ServerStreamingMethodResult,
|
|
17
|
-
StartRequest
|
|
17
|
+
StartRequest,
|
|
18
|
+
TemplateInstance,
|
|
19
|
+
TimeseriesResult
|
|
18
20
|
} from '@sentio/protos'
|
|
19
21
|
import { CallContext } from 'nice-grpc-common'
|
|
20
|
-
import {
|
|
22
|
+
import {
|
|
23
|
+
Endpoints,
|
|
24
|
+
IDataBindingContext,
|
|
25
|
+
PluginManager,
|
|
26
|
+
ProcessorServiceImpl,
|
|
27
|
+
State,
|
|
28
|
+
StoreContext
|
|
29
|
+
} from '@sentio/runtime'
|
|
21
30
|
|
|
22
31
|
import { AptosFacet } from './aptos-facet.js'
|
|
23
32
|
import { SolanaFacet } from './solana-facet.js'
|
|
@@ -45,7 +54,7 @@ export class TestProcessorServer implements ProcessorServiceImplementation {
|
|
|
45
54
|
service: ProcessorServiceImpl
|
|
46
55
|
contractConfigs: ContractConfig[]
|
|
47
56
|
accountConfigs: AccountConfig[]
|
|
48
|
-
storeContext:
|
|
57
|
+
storeContext: TestStoreContext
|
|
49
58
|
|
|
50
59
|
aptos: AptosFacet
|
|
51
60
|
eth: EthFacet
|
|
@@ -77,7 +86,7 @@ export class TestProcessorServer implements ProcessorServiceImplementation {
|
|
|
77
86
|
|
|
78
87
|
// start a memory database for testing
|
|
79
88
|
const subject = new Subject<DeepPartial<ProcessStreamResponse>>()
|
|
80
|
-
this.storeContext = new
|
|
89
|
+
this.storeContext = new TestStoreContext(subject, 1)
|
|
81
90
|
this._db = new MemoryDatabase(this.storeContext)
|
|
82
91
|
}
|
|
83
92
|
|
|
@@ -87,6 +96,7 @@ export class TestProcessorServer implements ProcessorServiceImplementation {
|
|
|
87
96
|
this.contractConfigs = config.contractConfigs
|
|
88
97
|
this.accountConfigs = config.accountConfigs
|
|
89
98
|
this._db.start()
|
|
99
|
+
this.storeContext.templateInstances = request.templateInstances
|
|
90
100
|
return res
|
|
91
101
|
}
|
|
92
102
|
|
|
@@ -94,23 +104,43 @@ export class TestProcessorServer implements ProcessorServiceImplementation {
|
|
|
94
104
|
return this.service.stop(request, context)
|
|
95
105
|
}
|
|
96
106
|
|
|
97
|
-
getConfig(request: ProcessConfigRequest, context = TEST_CONTEXT): Promise<ProcessConfigResponse> {
|
|
98
|
-
|
|
107
|
+
async getConfig(request: ProcessConfigRequest, context = TEST_CONTEXT): Promise<ProcessConfigResponse> {
|
|
108
|
+
const config = await this.service.getConfig(request, context)
|
|
109
|
+
return {
|
|
110
|
+
...config,
|
|
111
|
+
templateInstances: this.storeContext.templateInstances
|
|
112
|
+
}
|
|
99
113
|
}
|
|
100
114
|
|
|
101
115
|
processBindings(
|
|
102
116
|
request: ProcessBindingsRequest,
|
|
103
117
|
context: CallContext = TEST_CONTEXT
|
|
104
118
|
): Promise<ProcessBindingResponse> {
|
|
105
|
-
return PluginManager.INSTANCE.dbContextLocalStorage.run(this.storeContext, () => {
|
|
106
|
-
|
|
119
|
+
return PluginManager.INSTANCE.dbContextLocalStorage.run(this.storeContext, async () => {
|
|
120
|
+
const ret = await this.service.processBindings(request, context)
|
|
121
|
+
if (ret.result?.states?.configUpdated) {
|
|
122
|
+
// template may changed
|
|
123
|
+
await PluginManager.INSTANCE.updateTemplates({
|
|
124
|
+
chainId: request.bindings[0].chainId,
|
|
125
|
+
templateInstances: this.storeContext.templateInstances
|
|
126
|
+
})
|
|
127
|
+
}
|
|
128
|
+
return ret
|
|
107
129
|
})
|
|
108
130
|
}
|
|
109
131
|
|
|
110
|
-
processBinding(request: DataBinding, context: CallContext = TEST_CONTEXT): Promise<ProcessBindingResponse> {
|
|
111
|
-
|
|
132
|
+
async processBinding(request: DataBinding, context: CallContext = TEST_CONTEXT): Promise<ProcessBindingResponse> {
|
|
133
|
+
const ret = await PluginManager.INSTANCE.dbContextLocalStorage.run(this.storeContext, () => {
|
|
112
134
|
return this.service.processBindings({ bindings: [request] }, context)
|
|
113
135
|
})
|
|
136
|
+
if (ret.result?.states?.configUpdated) {
|
|
137
|
+
// template may changed
|
|
138
|
+
await PluginManager.INSTANCE.updateTemplates({
|
|
139
|
+
chainId: request.chainId,
|
|
140
|
+
templateInstances: this.storeContext.templateInstances
|
|
141
|
+
})
|
|
142
|
+
}
|
|
143
|
+
return ret
|
|
114
144
|
}
|
|
115
145
|
|
|
116
146
|
processBindingsStream(
|
|
@@ -138,3 +168,27 @@ export class TestProcessorServer implements ProcessorServiceImplementation {
|
|
|
138
168
|
return this._db.store
|
|
139
169
|
}
|
|
140
170
|
}
|
|
171
|
+
|
|
172
|
+
class TestStoreContext extends StoreContext implements IDataBindingContext {
|
|
173
|
+
constructor(
|
|
174
|
+
readonly subject: Subject<DeepPartial<ProcessStreamResponse>>,
|
|
175
|
+
processId: number
|
|
176
|
+
) {
|
|
177
|
+
super(subject, processId)
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
templateInstances: TemplateInstance[] = []
|
|
181
|
+
|
|
182
|
+
sendTemplateRequest(templates: Array<TemplateInstance>, remove: boolean): void {
|
|
183
|
+
if (remove) {
|
|
184
|
+
this.templateInstances = this.templateInstances.filter(
|
|
185
|
+
(i) => !templates.find((t) => t.templateId === i.templateId && t.contract?.address === i.contract?.address)
|
|
186
|
+
)
|
|
187
|
+
} else {
|
|
188
|
+
this.templateInstances.push(...templates)
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
sendTimeseriesRequest(timeseries: Array<TimeseriesResult>): void {
|
|
192
|
+
throw new Error('Method not implemented.')
|
|
193
|
+
}
|
|
194
|
+
}
|
package/lib/core/template.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"template.d.ts","sourceRoot":"","sources":["../../src/core/template.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAA"}
|
package/lib/core/template.js
DELETED
package/lib/core/template.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"template.js","sourceRoot":"","sources":["../../src/core/template.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAA"}
|
package/src/core/template.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { TemplateInstanceState } from '@sentio/runtime'
|