@sentio/runtime 2.54.3-rc.1 → 2.55.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sentio/runtime",
3
- "version": "2.54.3-rc.1",
3
+ "version": "2.55.0-rc.2",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "exports": {
@@ -23,6 +23,9 @@ import { compareSemver, parseSemver, Semver } from './utils.js'
23
23
 
24
24
  const require = createRequire(import.meta.url)
25
25
 
26
+ const FUEL_PROTO_UPDATE_VERSION = parseSemver('2.54.0-rc.7')
27
+ const MOVE_USE_RAW_VERSION = parseSemver('2.55.0-rc.1')
28
+
26
29
  function locatePackageJson(pkgId: string) {
27
30
  const m = require.resolve(pkgId)
28
31
 
@@ -78,9 +81,9 @@ export class FullProcessorServiceImpl implements ProcessorServiceImplementation
78
81
  }
79
82
 
80
83
  async processBindings(request: ProcessBindingsRequest, options: CallContext) {
81
- if (GLOBAL_CONFIG.execution.sequential) {
82
- request.bindings = request.bindings.sort(dataCompare)
83
- }
84
+ // if (GLOBAL_CONFIG.execution.sequential) {
85
+ // request.bindings = request.bindings.sort(dataCompare)
86
+ // }
84
87
 
85
88
  for (const binding of request.bindings) {
86
89
  this.adjustDataBinding(binding)
@@ -125,12 +128,14 @@ export class FullProcessorServiceImpl implements ProcessorServiceImplementation
125
128
  private adjustResult(res: ProcessResult): void {}
126
129
 
127
130
  private adjustDataBinding(dataBinding?: DataBinding): void {
131
+ const isBeforeMoveUseRawVersion = compareSemver(this.sdkVersion, MOVE_USE_RAW_VERSION) < 0
132
+
128
133
  if (!dataBinding) {
129
134
  return
130
135
  }
131
136
  switch (dataBinding.handlerType) {
132
137
  case HandlerType.FUEL_TRANSACTION:
133
- if (compareSemver(this.sdkVersion, fuelProtoUpdateVersion) < 0) {
138
+ if (compareSemver(this.sdkVersion, FUEL_PROTO_UPDATE_VERSION) < 0) {
134
139
  dataBinding.handlerType = HandlerType.FUEL_CALL
135
140
  if (dataBinding.data) {
136
141
  dataBinding.data.fuelCall = dataBinding.data?.fuelTransaction
@@ -138,7 +143,7 @@ export class FullProcessorServiceImpl implements ProcessorServiceImplementation
138
143
  }
139
144
  break
140
145
  case HandlerType.FUEL_RECEIPT:
141
- if (compareSemver(this.sdkVersion, fuelProtoUpdateVersion) < 0) {
146
+ if (compareSemver(this.sdkVersion, FUEL_PROTO_UPDATE_VERSION) < 0) {
142
147
  dataBinding.handlerType = HandlerType.FUEL_CALL
143
148
  if (dataBinding.data) {
144
149
  dataBinding.data.fuelCall = dataBinding.data?.fuelLog
@@ -147,72 +152,116 @@ export class FullProcessorServiceImpl implements ProcessorServiceImplementation
147
152
 
148
153
  break
149
154
  case HandlerType.APT_EVENT:
150
- if (dataBinding.data?.aptEvent) {
151
- if (dataBinding.data.aptEvent.rawTransaction && !dataBinding.data.aptEvent.transaction) {
152
- dataBinding.data.aptEvent.transaction = JSON.parse(dataBinding.data.aptEvent.rawTransaction)
155
+ const aptEvent = dataBinding.data?.aptEvent
156
+ if (aptEvent) {
157
+ if (isBeforeMoveUseRawVersion) {
158
+ aptEvent.transaction = JSON.parse(aptEvent.rawTransaction)
159
+ if (!aptEvent.transaction?.events?.length) {
160
+ // when fetch all is not true, then events is empty, we need to fill it to old format
161
+ aptEvent.transaction!.events = [JSON.parse(aptEvent.rawEvent)]
162
+ }
153
163
  }
154
164
  }
155
165
  break
156
166
  case HandlerType.APT_CALL:
157
- if (dataBinding.data?.aptCall) {
158
- if (dataBinding.data.aptCall.rawTransaction && !dataBinding.data.aptCall.transaction) {
159
- dataBinding.data.aptCall.transaction = JSON.parse(dataBinding.data.aptCall.rawTransaction)
167
+ const aptCall = dataBinding.data?.aptCall
168
+ if (aptCall) {
169
+ if (isBeforeMoveUseRawVersion) {
170
+ aptCall.transaction = JSON.parse(aptCall.rawTransaction)
160
171
  }
161
172
  }
162
173
  break
163
174
  case HandlerType.APT_RESOURCE:
164
- if (dataBinding.data?.aptResource?.resources) {
165
- if (dataBinding.data.aptResource.rawResources && dataBinding.data.aptResource.rawResources.length > 0) {
166
- dataBinding.data.aptResource.resources = dataBinding.data.aptResource.rawResources.map((e) => JSON.parse(e))
175
+ const aptResource = dataBinding.data?.aptResource
176
+ if (aptResource) {
177
+ if (isBeforeMoveUseRawVersion) {
178
+ aptResource.resources = aptResource.rawResources.map((e) => JSON.parse(e))
167
179
  }
168
180
  }
169
181
  break
170
- case HandlerType.UNKNOWN:
171
- if (dataBinding.data?.ethBlock) {
172
- if (dataBinding.data.raw.length === 0) {
173
- // This is actually not needed in current system, just as initla test propose, move to test only
174
- // when this is stable
175
- dataBinding.data.raw = new TextEncoder().encode(JSON.stringify(dataBinding.data.ethBlock.block))
182
+ case HandlerType.SUI_EVENT:
183
+ const suiEvent = dataBinding.data?.suiEvent
184
+ if (suiEvent) {
185
+ if (isBeforeMoveUseRawVersion) {
186
+ suiEvent.transaction = JSON.parse(suiEvent.rawTransaction)
187
+ if (!suiEvent.transaction?.events?.length) {
188
+ // when fetch all is not true, then events is empty, we need to fill it to old format
189
+ suiEvent.transaction!.events = [JSON.parse(suiEvent.rawEvent)]
190
+ }
191
+ }
192
+ }
193
+ break
194
+ case HandlerType.SUI_CALL:
195
+ const suiCall = dataBinding.data?.suiCall
196
+ if (suiCall) {
197
+ if (isBeforeMoveUseRawVersion) {
198
+ suiCall.transaction = JSON.parse(suiCall.rawTransaction)
199
+ }
200
+ }
201
+ break
202
+ case HandlerType.SUI_OBJECT:
203
+ const suiObject = dataBinding.data?.suiObject
204
+ if (suiObject) {
205
+ if (isBeforeMoveUseRawVersion) {
206
+ if (suiObject.rawSelf) {
207
+ suiObject.self = JSON.parse(suiObject.rawSelf)
208
+ }
209
+ suiObject.objects = suiObject.rawObjects.map((e) => JSON.parse(e))
210
+ }
211
+ }
212
+ break
213
+ case HandlerType.SUI_OBJECT_CHANGE:
214
+ const suiObjectChange = dataBinding.data?.suiObjectChange
215
+ if (suiObjectChange) {
216
+ if (isBeforeMoveUseRawVersion) {
217
+ suiObjectChange.changes = suiObjectChange.rawChanges.map((e) => JSON.parse(e))
176
218
  }
177
219
  }
178
220
  break
221
+ case HandlerType.UNKNOWN:
222
+ // if (dataBinding.data?.ethBlock) {
223
+ // if (dataBinding.data.raw.length === 0) {
224
+ // // This is actually not needed in current system, just as initla test propose, move to test only
225
+ // // when this is stable
226
+ // dataBinding.data.raw = new TextEncoder().encode(JSON.stringify(dataBinding.data.ethBlock.block))
227
+ // }
228
+ // }
229
+ break
179
230
  default:
180
231
  break
181
232
  }
182
233
  }
183
234
  }
184
235
 
185
- // TODO push the logic into sdk
186
- function dataCompare(a: DataBinding, b: DataBinding): number {
187
- const timeA = getTimestamp(a) || new Date(0)
188
- const timeB = getTimestamp(b) || new Date(0)
189
- const timeCmp = timeA.getTime() - timeB.getTime()
190
- if (timeCmp !== 0) {
191
- return timeCmp
192
- }
193
- return getSecondary(a) - getSecondary(b)
194
- }
195
-
196
- function getTimestamp(d: DataBinding): Date | undefined {
197
- return (
198
- d.data?.ethLog?.timestamp ||
199
- d.data?.ethTransaction?.timestamp ||
200
- (d.data?.ethBlock?.block?.timestamp ? new Date(Number(d.data.ethBlock.block.timestamp) * 1000) : undefined) ||
201
- d.data?.ethTrace?.timestamp ||
202
- (d.data?.aptCall?.transaction ? new Date(Number(d.data.aptCall.transaction.timestamp) / 1000) : undefined) ||
203
- (d.data?.aptEvent?.transaction ? new Date(Number(d.data.aptEvent.transaction.timestamp) / 1000) : undefined) ||
204
- (d.data?.aptResource?.timestampMicros ? new Date(Number(d.data.aptResource.timestampMicros) / 1000) : undefined) ||
205
- d.data?.fuelCall?.timestamp
206
- )
207
- }
208
-
209
- function getSecondary(d: DataBinding) {
210
- return (
211
- d.data?.ethLog?.log?.logIndex ||
212
- d.data?.ethTransaction?.transaction?.transactionIndex ||
213
- d.data?.ethBlock?.block?.number ||
214
- d.data?.ethTrace?.trace?.transactionPosition
215
- )
216
- }
217
-
218
- const fuelProtoUpdateVersion = parseSemver('2.54.0-rc.7')
236
+ // function dataCompare(a: DataBinding, b: DataBinding): number {
237
+ // const timeA = getTimestamp(a) || new Date(0)
238
+ // const timeB = getTimestamp(b) || new Date(0)
239
+ // const timeCmp = timeA.getTime() - timeB.getTime()
240
+ // if (timeCmp !== 0) {
241
+ // return timeCmp
242
+ // }
243
+ // return getSecondary(a) - getSecondary(b)
244
+ // }
245
+ //
246
+ // function getTimestamp(d: DataBinding): Date | undefined {
247
+ // return (
248
+ // d.data?.ethLog?.timestamp ||
249
+ // d.data?.ethTransaction?.timestamp ||
250
+ // (d.data?.ethBlock?.block?.timestamp ? new Date(Number(d.data.ethBlock.block.timestamp) * 1000) : undefined) ||
251
+ // d.data?.ethTrace?.timestamp ||
252
+ // (d.data?.aptCall?.transaction ? new Date(Number(d.data.aptCall.transaction.timestamp) / 1000) : undefined) ||
253
+ // (d.data?.aptEvent?.transaction ? new Date(Number(d.data.aptEvent.transaction.timestamp) / 1000) : undefined) ||
254
+ // (d.data?.aptResource?.timestampMicros ? new Date(Number(d.data.aptResource.timestampMicros) / 1000) : undefined) ||
255
+ // d.data?.fuelCall?.timestamp
256
+ // )
257
+ // }
258
+ //
259
+ // function getSecondary(d: DataBinding) {
260
+ // return (
261
+ // d.data?.ethLog?.log?.logIndex ||
262
+ // d.data?.ethTransaction?.transaction?.transactionIndex ||
263
+ // d.data?.ethBlock?.block?.number ||
264
+ // d.data?.ethTrace?.trace?.transactionPosition
265
+ // )
266
+ // }
267
+ //