@sentio/runtime 2.54.0-rc.10 → 2.54.0-rc.12
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-TTUV7TP2.js} +8 -8
- package/lib/{chunk-ELCJQA22.js.map → chunk-TTUV7TP2.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 -8
- 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,14 +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])
|
46
|
-
this.patchVersion = version[2]
|
45
|
+
this.sdkVersion = parseSemver(sdkPackageJson.version)
|
47
46
|
}
|
48
47
|
|
49
48
|
instance: ProcessorServiceImplementation
|
50
|
-
|
51
|
-
patchVersion: string
|
49
|
+
sdkVersion: Semver
|
52
50
|
|
53
51
|
async getConfig(request: ProcessConfigRequest, context: CallContext) {
|
54
52
|
const config = await this.instance.getConfig(request, context)
|
@@ -95,7 +93,7 @@ export class FullProcessorServiceImpl implements ProcessorServiceImplementation
|
|
95
93
|
}
|
96
94
|
return result
|
97
95
|
} catch (e) {
|
98
|
-
if (this.
|
96
|
+
if (this.sdkVersion.minor <= 16) {
|
99
97
|
// Old sdk doesn't handle this well
|
100
98
|
if (
|
101
99
|
e.code === os.constants.errno.ECONNRESET ||
|
@@ -132,7 +130,7 @@ export class FullProcessorServiceImpl implements ProcessorServiceImplementation
|
|
132
130
|
}
|
133
131
|
switch (dataBinding.handlerType) {
|
134
132
|
case HandlerType.FUEL_TRANSACTION:
|
135
|
-
if (this.
|
133
|
+
if (compareSemver(this.sdkVersion, fuelProtoUpdateVersion) < 0) {
|
136
134
|
dataBinding.handlerType = HandlerType.FUEL_CALL
|
137
135
|
if (dataBinding.data) {
|
138
136
|
dataBinding.data.fuelCall = dataBinding.data?.fuelTransaction
|
@@ -140,7 +138,7 @@ export class FullProcessorServiceImpl implements ProcessorServiceImplementation
|
|
140
138
|
}
|
141
139
|
break
|
142
140
|
case HandlerType.FUEL_RECEIPT:
|
143
|
-
if (this.
|
141
|
+
if (compareSemver(this.sdkVersion, fuelProtoUpdateVersion) < 0) {
|
144
142
|
dataBinding.handlerType = HandlerType.FUEL_CALL
|
145
143
|
if (dataBinding.data) {
|
146
144
|
dataBinding.data.fuelCall = dataBinding.data?.fuelLog
|
@@ -216,3 +214,5 @@ function getSecondary(d: DataBinding) {
|
|
216
214
|
d.data?.ethTrace?.trace?.transactionPosition
|
217
215
|
)
|
218
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
|
+
}
|