@sentio/sdk 3.0.0-rc.7 → 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.
Files changed (74) hide show
  1. package/lib/aptos/aptos-plugin.js +1 -1
  2. package/lib/aptos/aptos-plugin.js.map +1 -1
  3. package/lib/aptos/aptos-resource-processor-template.d.ts +2 -1
  4. package/lib/aptos/aptos-resource-processor-template.d.ts.map +1 -1
  5. package/lib/aptos/aptos-resource-processor-template.js +28 -25
  6. package/lib/aptos/aptos-resource-processor-template.js.map +1 -1
  7. package/lib/core/base-context.d.ts +2 -1
  8. package/lib/core/base-context.d.ts.map +1 -1
  9. package/lib/core/base-context.js +6 -0
  10. package/lib/core/base-context.js.map +1 -1
  11. package/lib/core/core-plugin.d.ts.map +1 -1
  12. package/lib/core/core-plugin.js +0 -3
  13. package/lib/core/core-plugin.js.map +1 -1
  14. package/lib/cosmos/cosmos-plugin.d.ts +0 -1
  15. package/lib/cosmos/cosmos-plugin.d.ts.map +1 -1
  16. package/lib/cosmos/cosmos-plugin.js +0 -4
  17. package/lib/cosmos/cosmos-plugin.js.map +1 -1
  18. package/lib/eth/base-processor-template.d.ts +2 -1
  19. package/lib/eth/base-processor-template.d.ts.map +1 -1
  20. package/lib/eth/base-processor-template.js +26 -24
  21. package/lib/eth/base-processor-template.js.map +1 -1
  22. package/lib/eth/eth-plugin.d.ts +0 -1
  23. package/lib/eth/eth-plugin.d.ts.map +1 -1
  24. package/lib/eth/eth-plugin.js +1 -5
  25. package/lib/eth/eth-plugin.js.map +1 -1
  26. package/lib/fuel/fuel-plugin.d.ts +0 -1
  27. package/lib/fuel/fuel-plugin.d.ts.map +1 -1
  28. package/lib/fuel/fuel-plugin.js +0 -4
  29. package/lib/fuel/fuel-plugin.js.map +1 -1
  30. package/lib/fuel/fuel-processor-template.d.ts +2 -1
  31. package/lib/fuel/fuel-processor-template.d.ts.map +1 -1
  32. package/lib/fuel/fuel-processor-template.js +28 -23
  33. package/lib/fuel/fuel-processor-template.js.map +1 -1
  34. package/lib/iota/iota-object-processor-template.d.ts +2 -1
  35. package/lib/iota/iota-object-processor-template.d.ts.map +1 -1
  36. package/lib/iota/iota-object-processor-template.js +51 -39
  37. package/lib/iota/iota-object-processor-template.js.map +1 -1
  38. package/lib/iota/iota-plugin-part.js +1 -1
  39. package/lib/iota/iota-plugin-part.js.map +1 -1
  40. package/lib/stark/starknet-plugin.d.ts +0 -1
  41. package/lib/stark/starknet-plugin.d.ts.map +1 -1
  42. package/lib/stark/starknet-plugin.js +0 -4
  43. package/lib/stark/starknet-plugin.js.map +1 -1
  44. package/lib/sui/sui-object-processor-template.d.ts +2 -1
  45. package/lib/sui/sui-object-processor-template.d.ts.map +1 -1
  46. package/lib/sui/sui-object-processor-template.js +51 -39
  47. package/lib/sui/sui-object-processor-template.js.map +1 -1
  48. package/lib/sui/sui-plugin-part.js +1 -1
  49. package/lib/sui/sui-plugin-part.js.map +1 -1
  50. package/lib/testing/test-processor-server.d.ts +12 -3
  51. package/lib/testing/test-processor-server.d.ts.map +1 -1
  52. package/lib/testing/test-processor-server.js +47 -7
  53. package/lib/testing/test-processor-server.js.map +1 -1
  54. package/package.json +3 -3
  55. package/src/aptos/aptos-plugin.ts +1 -1
  56. package/src/aptos/aptos-resource-processor-template.ts +36 -30
  57. package/src/core/base-context.ts +8 -1
  58. package/src/core/core-plugin.ts +0 -4
  59. package/src/cosmos/cosmos-plugin.ts +0 -5
  60. package/src/eth/base-processor-template.ts +32 -27
  61. package/src/eth/eth-plugin.ts +1 -6
  62. package/src/fuel/fuel-plugin.ts +0 -5
  63. package/src/fuel/fuel-processor-template.ts +34 -26
  64. package/src/iota/iota-object-processor-template.ts +61 -46
  65. package/src/iota/iota-plugin-part.ts +1 -1
  66. package/src/stark/starknet-plugin.ts +0 -5
  67. package/src/sui/sui-object-processor-template.ts +63 -47
  68. package/src/sui/sui-plugin-part.ts +1 -1
  69. package/src/testing/test-processor-server.ts +64 -10
  70. package/lib/core/template.d.ts +0 -2
  71. package/lib/core/template.d.ts.map +0 -1
  72. package/lib/core/template.js +0 -2
  73. package/lib/core/template.js.map +0 -1
  74. 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 { Endpoints, PluginManager, ProcessorServiceImpl, State, StoreContext } from '@sentio/runtime'
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: 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 StoreContext(subject, 1)
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
- return this.service.getConfig(request, context)
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
- return this.service.processBindings(request, context)
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
- return PluginManager.INSTANCE.dbContextLocalStorage.run(this.storeContext, () => {
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
+ }
@@ -1,2 +0,0 @@
1
- export { TemplateInstanceState } from '@sentio/runtime';
2
- //# sourceMappingURL=template.d.ts.map
@@ -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"}
@@ -1,2 +0,0 @@
1
- export { TemplateInstanceState } from '@sentio/runtime';
2
- //# sourceMappingURL=template.js.map
@@ -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"}
@@ -1 +0,0 @@
1
- export { TemplateInstanceState } from '@sentio/runtime'