@sentio/runtime 2.54.0-rc.10 → 2.54.0-rc.11
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-PSAWYB4F.js} +15 -15
- package/lib/{chunk-ELCJQA22.js.map → chunk-PSAWYB4F.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 +6 -4
- 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 } from './utils.js'
|
22
23
|
|
23
24
|
const require = createRequire(import.meta.url)
|
24
25
|
|
@@ -34,6 +35,7 @@ function locatePackageJson(pkgId: string) {
|
|
34
35
|
}
|
35
36
|
|
36
37
|
export class FullProcessorServiceImpl implements ProcessorServiceImplementation {
|
38
|
+
private sdkVersion: string
|
37
39
|
constructor(instance: ProcessorServiceImplementation) {
|
38
40
|
this.instance = instance
|
39
41
|
const sdkPackageJson = locatePackageJson('@sentio/sdk')
|
@@ -43,12 +45,12 @@ export class FullProcessorServiceImpl implements ProcessorServiceImplementation
|
|
43
45
|
|
44
46
|
const version = sdkPackageJson.version.split('.')
|
45
47
|
this.sdkMinorVersion = parseInt(version[1])
|
46
|
-
this.
|
48
|
+
this.sdkVersion = sdkPackageJson.version
|
47
49
|
}
|
48
50
|
|
49
51
|
instance: ProcessorServiceImplementation
|
50
52
|
sdkMinorVersion: number
|
51
|
-
|
53
|
+
semver: string
|
52
54
|
|
53
55
|
async getConfig(request: ProcessConfigRequest, context: CallContext) {
|
54
56
|
const config = await this.instance.getConfig(request, context)
|
@@ -132,7 +134,7 @@ export class FullProcessorServiceImpl implements ProcessorServiceImplementation
|
|
132
134
|
}
|
133
135
|
switch (dataBinding.handlerType) {
|
134
136
|
case HandlerType.FUEL_TRANSACTION:
|
135
|
-
if (this.
|
137
|
+
if (compareSemver(this.sdkVersion, '2.54.0-rc.7') < 0) {
|
136
138
|
dataBinding.handlerType = HandlerType.FUEL_CALL
|
137
139
|
if (dataBinding.data) {
|
138
140
|
dataBinding.data.fuelCall = dataBinding.data?.fuelTransaction
|
@@ -140,7 +142,7 @@ export class FullProcessorServiceImpl implements ProcessorServiceImplementation
|
|
140
142
|
}
|
141
143
|
break
|
142
144
|
case HandlerType.FUEL_RECEIPT:
|
143
|
-
if (this.
|
145
|
+
if (compareSemver(this.sdkVersion, '2.54.0-rc.7') < 0) {
|
144
146
|
dataBinding.handlerType = HandlerType.FUEL_CALL
|
145
147
|
if (dataBinding.data) {
|
146
148
|
dataBinding.data.fuelCall = dataBinding.data?.fuelLog
|
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: string, b: string) {
|
65
|
+
const { major: ma, minor: mia, patch: pa, prerelease: pra } = parseSemver(a)
|
66
|
+
const { major: mb, minor: mib, patch: pb, prerelease: prb } = parseSemver(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
|
+
}
|