@sentio/runtime 2.54.0-rc.9 → 2.54.1-rc.1
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/{chunk-ELCJQA22.js → chunk-KVJ2GUGQ.js} +8 -8
- package/lib/{chunk-ELCJQA22.js.map → chunk-KVJ2GUGQ.js.map} +1 -1
- package/lib/index.d.ts +11 -1
- package/lib/index.js +1 -1
- package/lib/index.js.map +1 -1
- package/lib/processor-runner.js +29 -29
- package/lib/processor-runner.js.map +1 -1
- package/package.json +1 -1
- package/src/full-service.ts +8 -6
- package/src/utils.ts +55 -0
package/package.json
CHANGED
package/src/full-service.ts
CHANGED
@@ -19,6 +19,7 @@ import fs from 'fs-extra'
|
|
19
19
|
import path from 'path'
|
20
20
|
import os from 'os'
|
21
21
|
import { GLOBAL_CONFIG } from './global-config.js'
|
22
|
+
import { compareSemver, parseSemver, Semver } from './utils.js'
|
22
23
|
|
23
24
|
const require = createRequire(import.meta.url)
|
24
25
|
|
@@ -41,12 +42,11 @@ export class FullProcessorServiceImpl implements ProcessorServiceImplementation
|
|
41
42
|
|
42
43
|
console.log('Runtime version:', runtimePackageJson.version, 'SDK version:', sdkPackageJson.version)
|
43
44
|
|
44
|
-
|
45
|
-
this.sdkMinorVersion = parseInt(version[1])
|
45
|
+
this.sdkVersion = parseSemver(sdkPackageJson.version)
|
46
46
|
}
|
47
47
|
|
48
48
|
instance: ProcessorServiceImplementation
|
49
|
-
|
49
|
+
sdkVersion: Semver
|
50
50
|
|
51
51
|
async getConfig(request: ProcessConfigRequest, context: CallContext) {
|
52
52
|
const config = await this.instance.getConfig(request, context)
|
@@ -93,7 +93,7 @@ export class FullProcessorServiceImpl implements ProcessorServiceImplementation
|
|
93
93
|
}
|
94
94
|
return result
|
95
95
|
} catch (e) {
|
96
|
-
if (this.
|
96
|
+
if (this.sdkVersion.minor <= 16) {
|
97
97
|
// Old sdk doesn't handle this well
|
98
98
|
if (
|
99
99
|
e.code === os.constants.errno.ECONNRESET ||
|
@@ -130,7 +130,7 @@ export class FullProcessorServiceImpl implements ProcessorServiceImplementation
|
|
130
130
|
}
|
131
131
|
switch (dataBinding.handlerType) {
|
132
132
|
case HandlerType.FUEL_TRANSACTION:
|
133
|
-
if (this.
|
133
|
+
if (compareSemver(this.sdkVersion, fuelProtoUpdateVersion) < 0) {
|
134
134
|
dataBinding.handlerType = HandlerType.FUEL_CALL
|
135
135
|
if (dataBinding.data) {
|
136
136
|
dataBinding.data.fuelCall = dataBinding.data?.fuelTransaction
|
@@ -138,7 +138,7 @@ export class FullProcessorServiceImpl implements ProcessorServiceImplementation
|
|
138
138
|
}
|
139
139
|
break
|
140
140
|
case HandlerType.FUEL_RECEIPT:
|
141
|
-
if (this.
|
141
|
+
if (compareSemver(this.sdkVersion, fuelProtoUpdateVersion) < 0) {
|
142
142
|
dataBinding.handlerType = HandlerType.FUEL_CALL
|
143
143
|
if (dataBinding.data) {
|
144
144
|
dataBinding.data.fuelCall = dataBinding.data?.fuelLog
|
@@ -214,3 +214,5 @@ function getSecondary(d: DataBinding) {
|
|
214
214
|
d.data?.ethTrace?.trace?.transactionPosition
|
215
215
|
)
|
216
216
|
}
|
217
|
+
|
218
|
+
const fuelProtoUpdateVersion = parseSemver('2.54.0-rc.7')
|
package/src/utils.ts
CHANGED
@@ -36,3 +36,58 @@ export function makeEthCallKey(param: EthCallParam) {
|
|
36
36
|
const { chainId, address, blockTag } = param.context
|
37
37
|
return `${chainId}|${address}|${blockTag}|${param.calldata}`.toLowerCase()
|
38
38
|
}
|
39
|
+
|
40
|
+
export type Semver = {
|
41
|
+
semVer?: string
|
42
|
+
major: number
|
43
|
+
minor: number
|
44
|
+
patch: number
|
45
|
+
prerelease?: string
|
46
|
+
buildmetadata?: string
|
47
|
+
}
|
48
|
+
|
49
|
+
export function parseSemver(version: string): Semver {
|
50
|
+
const [semVer, major, minor, patch, prerelease, buildmetadata] =
|
51
|
+
version.match(
|
52
|
+
/^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$/
|
53
|
+
) ?? []
|
54
|
+
return {
|
55
|
+
semVer,
|
56
|
+
major: parseInt(major),
|
57
|
+
minor: parseInt(minor),
|
58
|
+
patch: parseInt(patch),
|
59
|
+
prerelease,
|
60
|
+
buildmetadata
|
61
|
+
}
|
62
|
+
}
|
63
|
+
|
64
|
+
export function compareSemver(a: Semver, b: Semver) {
|
65
|
+
const { major: ma, minor: mia, patch: pa, prerelease: pra } = a
|
66
|
+
const { major: mb, minor: mib, patch: pb, prerelease: prb } = b
|
67
|
+
|
68
|
+
if (ma !== mb) {
|
69
|
+
return ma - mb
|
70
|
+
}
|
71
|
+
if (mia !== mib) {
|
72
|
+
return mia - mib
|
73
|
+
}
|
74
|
+
|
75
|
+
if (pa !== pb) {
|
76
|
+
return pa - pb
|
77
|
+
}
|
78
|
+
if (pra && prb) {
|
79
|
+
const [sa, va] = pra.split('.')
|
80
|
+
const [sb, vb] = prb.split('.')
|
81
|
+
|
82
|
+
if (sa !== sb) {
|
83
|
+
return sa.localeCompare(sb)
|
84
|
+
}
|
85
|
+
|
86
|
+
return parseInt(va) - parseInt(vb)
|
87
|
+
} else if (pra) {
|
88
|
+
return -1
|
89
|
+
} else if (prb) {
|
90
|
+
return 1
|
91
|
+
}
|
92
|
+
return 0
|
93
|
+
}
|