@sentio/sdk 4.0.0-rc.1 → 4.0.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/lib/aptos/aptos-plugin.d.ts +1 -1
- package/lib/aptos/aptos-plugin.d.ts.map +1 -1
- package/lib/aptos/aptos-plugin.js +43 -42
- package/lib/aptos/aptos-plugin.js.map +1 -1
- package/lib/aptos/aptos-processor.d.ts +1 -1
- package/lib/aptos/aptos-processor.d.ts.map +1 -1
- package/lib/aptos/aptos-processor.js +25 -25
- package/lib/aptos/aptos-processor.js.map +1 -1
- package/lib/aptos/aptos-resource-processor-template.d.ts +1 -1
- package/lib/aptos/aptos-resource-processor-template.d.ts.map +1 -1
- package/lib/aptos/aptos-resource-processor-template.js +10 -5
- package/lib/aptos/aptos-resource-processor-template.js.map +1 -1
- package/lib/aptos/context.d.ts +1 -1
- package/lib/aptos/context.d.ts.map +1 -1
- package/lib/aptos/context.js +8 -6
- package/lib/aptos/context.js.map +1 -1
- package/lib/aptos/data.d.ts +4 -4
- package/lib/aptos/data.d.ts.map +1 -1
- package/lib/core/base-context.d.ts +3 -2
- package/lib/core/base-context.d.ts.map +1 -1
- package/lib/core/base-context.js +12 -11
- package/lib/core/base-context.js.map +1 -1
- package/lib/core/core-plugin.d.ts.map +1 -1
- package/lib/core/core-plugin.js +6 -4
- package/lib/core/core-plugin.js.map +1 -1
- package/lib/core/event-logger.d.ts +10 -2
- package/lib/core/event-logger.d.ts.map +1 -1
- package/lib/core/event-logger.js +42 -26
- package/lib/core/event-logger.js.map +1 -1
- package/lib/core/exporter.d.ts.map +1 -1
- package/lib/core/exporter.js +5 -3
- package/lib/core/exporter.js.map +1 -1
- package/lib/core/handler-options.d.ts +1 -1
- package/lib/core/handler-options.d.ts.map +1 -1
- package/lib/core/handler-register.d.ts +1 -1
- package/lib/core/handler-register.d.ts.map +1 -1
- package/lib/core/handler-register.js +2 -2
- package/lib/core/handler-register.js.map +1 -1
- package/lib/core/meter.d.ts +4 -3
- package/lib/core/meter.d.ts.map +1 -1
- package/lib/core/meter.js +5 -4
- package/lib/core/meter.js.map +1 -1
- package/lib/core/normalization.d.ts +1 -1
- package/lib/core/normalization.d.ts.map +1 -1
- package/lib/core/normalization.js +41 -31
- package/lib/core/normalization.js.map +1 -1
- package/lib/core/numberish.d.ts +1 -1
- package/lib/core/numberish.d.ts.map +1 -1
- package/lib/core/numberish.js +35 -30
- package/lib/core/numberish.js.map +1 -1
- package/lib/core/partition-handler-manager.d.ts +1 -1
- package/lib/core/partition-handler-manager.d.ts.map +1 -1
- package/lib/core/partition-handler-manager.js +10 -9
- package/lib/core/partition-handler-manager.js.map +1 -1
- package/lib/cosmos/context.d.ts.map +1 -1
- package/lib/cosmos/context.js +4 -2
- package/lib/cosmos/context.js.map +1 -1
- package/lib/cosmos/cosmos-plugin.d.ts.map +1 -1
- package/lib/cosmos/cosmos-plugin.js +11 -10
- package/lib/cosmos/cosmos-plugin.js.map +1 -1
- package/lib/cosmos/cosmos-processor.js.map +1 -1
- package/lib/eth/abi-decoder/decode-worker.js +2 -2
- package/lib/eth/abi-decoder/decode-worker.js.map +1 -1
- package/lib/eth/account-processor.d.ts +2 -2
- package/lib/eth/account-processor.d.ts.map +1 -1
- package/lib/eth/account-processor.js +10 -9
- package/lib/eth/account-processor.js.map +1 -1
- package/lib/eth/base-processor-template.d.ts +3 -3
- package/lib/eth/base-processor-template.d.ts.map +1 -1
- package/lib/eth/base-processor-template.js +12 -8
- package/lib/eth/base-processor-template.js.map +1 -1
- package/lib/eth/base-processor.d.ts +1 -1
- package/lib/eth/base-processor.d.ts.map +1 -1
- package/lib/eth/base-processor.js +53 -46
- package/lib/eth/base-processor.js.map +1 -1
- package/lib/eth/builtin/internal/eacaggregatorproxy-processor.d.ts.map +1 -1
- package/lib/eth/builtin/internal/eacaggregatorproxy-processor.js +48 -46
- package/lib/eth/builtin/internal/eacaggregatorproxy-processor.js.map +1 -1
- package/lib/eth/builtin/internal/erc1155-processor.d.ts.map +1 -1
- package/lib/eth/builtin/internal/erc1155-processor.js +18 -16
- package/lib/eth/builtin/internal/erc1155-processor.js.map +1 -1
- package/lib/eth/builtin/internal/erc20-processor.d.ts.map +1 -1
- package/lib/eth/builtin/internal/erc20-processor.js +38 -36
- package/lib/eth/builtin/internal/erc20-processor.js.map +1 -1
- package/lib/eth/builtin/internal/erc20bytes-processor.d.ts.map +1 -1
- package/lib/eth/builtin/internal/erc20bytes-processor.js +20 -18
- package/lib/eth/builtin/internal/erc20bytes-processor.js.map +1 -1
- package/lib/eth/builtin/internal/erc721-processor.d.ts.map +1 -1
- package/lib/eth/builtin/internal/erc721-processor.js +30 -28
- package/lib/eth/builtin/internal/erc721-processor.js.map +1 -1
- package/lib/eth/builtin/internal/weth9-processor.d.ts.map +1 -1
- package/lib/eth/builtin/internal/weth9-processor.js +24 -22
- package/lib/eth/builtin/internal/weth9-processor.js.map +1 -1
- package/lib/eth/codegen/file.d.ts.map +1 -1
- package/lib/eth/codegen/file.js +2 -1
- package/lib/eth/codegen/file.js.map +1 -1
- package/lib/eth/codegen/function-calls.js +1 -1
- package/lib/eth/context.d.ts +1 -1
- package/lib/eth/context.d.ts.map +1 -1
- package/lib/eth/context.js +12 -10
- package/lib/eth/context.js.map +1 -1
- package/lib/eth/eth-plugin.d.ts.map +1 -1
- package/lib/eth/eth-plugin.js +83 -75
- package/lib/eth/eth-plugin.js.map +1 -1
- package/lib/eth/eth.d.ts +6 -6
- package/lib/eth/eth.d.ts.map +1 -1
- package/lib/eth/eth.js +22 -14
- package/lib/eth/eth.js.map +1 -1
- package/lib/eth/index.d.ts +1 -1
- package/lib/eth/index.d.ts.map +1 -1
- package/lib/eth/index.js +0 -1
- package/lib/eth/index.js.map +1 -1
- package/lib/fuel/asset-processor.d.ts +2 -2
- package/lib/fuel/asset-processor.d.ts.map +1 -1
- package/lib/fuel/asset-processor.js +5 -3
- package/lib/fuel/asset-processor.js.map +1 -1
- package/lib/fuel/context.d.ts.map +1 -1
- package/lib/fuel/context.js +4 -2
- package/lib/fuel/context.js.map +1 -1
- package/lib/fuel/fuel-plugin.d.ts.map +1 -1
- package/lib/fuel/fuel-plugin.js +41 -53
- package/lib/fuel/fuel-plugin.js.map +1 -1
- package/lib/fuel/fuel-processor-template.d.ts.map +1 -1
- package/lib/fuel/fuel-processor-template.js +7 -5
- package/lib/fuel/fuel-processor-template.js.map +1 -1
- package/lib/fuel/fuel-processor.d.ts.map +1 -1
- package/lib/fuel/fuel-processor.js +30 -20
- package/lib/fuel/fuel-processor.js.map +1 -1
- package/lib/fuel/global-processor.d.ts.map +1 -1
- package/lib/fuel/global-processor.js +2 -1
- package/lib/fuel/global-processor.js.map +1 -1
- package/lib/fuel/types.d.ts +10 -4
- package/lib/fuel/types.d.ts.map +1 -1
- package/lib/fuel/types.js.map +1 -1
- package/lib/iota/context.d.ts +1 -1
- package/lib/iota/context.d.ts.map +1 -1
- package/lib/iota/context.js +8 -6
- package/lib/iota/context.js.map +1 -1
- package/lib/iota/iota-object-processor-template.d.ts +1 -1
- package/lib/iota/iota-object-processor-template.d.ts.map +1 -1
- package/lib/iota/iota-object-processor-template.js +17 -12
- package/lib/iota/iota-object-processor-template.js.map +1 -1
- package/lib/iota/iota-object-processor.d.ts +1 -1
- package/lib/iota/iota-object-processor.d.ts.map +1 -1
- package/lib/iota/iota-object-processor.js +23 -16
- package/lib/iota/iota-object-processor.js.map +1 -1
- package/lib/iota/iota-plugin-part.d.ts +1 -1
- package/lib/iota/iota-plugin-part.d.ts.map +1 -1
- package/lib/iota/iota-plugin-part.js +16 -15
- package/lib/iota/iota-plugin-part.js.map +1 -1
- package/lib/iota/iota-processor.d.ts +1 -1
- package/lib/iota/iota-processor.d.ts.map +1 -1
- package/lib/iota/iota-processor.js +18 -17
- package/lib/iota/iota-processor.js.map +1 -1
- package/lib/iota/network.js +2 -2
- package/lib/iota/network.js.map +1 -1
- package/lib/move/filter.d.ts +1 -1
- package/lib/move/filter.d.ts.map +1 -1
- package/lib/move/index.d.ts +1 -1
- package/lib/move/index.d.ts.map +1 -1
- package/lib/move/index.js +0 -1
- package/lib/move/index.js.map +1 -1
- package/lib/solana/builtin/types.d.ts +4 -4
- package/lib/solana/solana-context.d.ts.map +1 -1
- package/lib/solana/solana-context.js +4 -3
- package/lib/solana/solana-context.js.map +1 -1
- package/lib/solana/solana-plugin.d.ts.map +1 -1
- package/lib/solana/solana-plugin.js +19 -18
- package/lib/solana/solana-plugin.js.map +1 -1
- package/lib/solana/solana-processor.d.ts.map +1 -1
- package/lib/solana/solana-processor.js +8 -3
- package/lib/solana/solana-processor.js.map +1 -1
- package/lib/store/cache.d.ts.map +1 -1
- package/lib/store/cache.js +22 -17
- package/lib/store/cache.js.map +1 -1
- package/lib/store/convert.d.ts +1 -1
- package/lib/store/convert.d.ts.map +1 -1
- package/lib/store/convert.js +67 -104
- package/lib/store/convert.js.map +1 -1
- package/lib/store/decorators.d.ts +1 -1
- package/lib/store/decorators.d.ts.map +1 -1
- package/lib/store/decorators.js +3 -1
- package/lib/store/decorators.js.map +1 -1
- package/lib/store/store.d.ts.map +1 -1
- package/lib/store/store.js +24 -16
- package/lib/store/store.js.map +1 -1
- package/lib/store/types.js +24 -32
- package/lib/store/types.js.map +1 -1
- package/lib/store/util.d.ts +1 -1
- package/lib/store/util.d.ts.map +1 -1
- package/lib/store/util.js +13 -17
- package/lib/store/util.js.map +1 -1
- package/lib/sui/context.d.ts +1 -1
- package/lib/sui/context.d.ts.map +1 -1
- package/lib/sui/context.js +8 -6
- package/lib/sui/context.js.map +1 -1
- package/lib/sui/sui-object-processor-template.d.ts +1 -1
- package/lib/sui/sui-object-processor-template.d.ts.map +1 -1
- package/lib/sui/sui-object-processor-template.js +17 -12
- package/lib/sui/sui-object-processor-template.js.map +1 -1
- package/lib/sui/sui-object-processor.d.ts +1 -1
- package/lib/sui/sui-object-processor.d.ts.map +1 -1
- package/lib/sui/sui-object-processor.js +23 -16
- package/lib/sui/sui-object-processor.js.map +1 -1
- package/lib/sui/sui-plugin-part.d.ts +1 -1
- package/lib/sui/sui-plugin-part.d.ts.map +1 -1
- package/lib/sui/sui-plugin-part.js +16 -15
- package/lib/sui/sui-plugin-part.js.map +1 -1
- package/lib/sui/sui-plugin.d.ts +1 -1
- package/lib/sui/sui-plugin.d.ts.map +1 -1
- package/lib/sui/sui-plugin.js +35 -34
- package/lib/sui/sui-plugin.js.map +1 -1
- package/lib/sui/sui-processor.d.ts +1 -1
- package/lib/sui/sui-processor.d.ts.map +1 -1
- package/lib/sui/sui-processor.js +18 -17
- package/lib/sui/sui-processor.js.map +1 -1
- package/lib/testing/aptos-facet.d.ts.map +1 -1
- package/lib/testing/aptos-facet.js +18 -11
- package/lib/testing/aptos-facet.js.map +1 -1
- package/lib/testing/cosmos-facet.d.ts.map +1 -1
- package/lib/testing/cosmos-facet.js +10 -6
- package/lib/testing/cosmos-facet.js.map +1 -1
- package/lib/testing/eth-facet.d.ts +1 -1
- package/lib/testing/eth-facet.d.ts.map +1 -1
- package/lib/testing/eth-facet.js +34 -18
- package/lib/testing/eth-facet.js.map +1 -1
- package/lib/testing/fuel-facet.d.ts.map +1 -1
- package/lib/testing/fuel-facet.js +28 -18
- package/lib/testing/fuel-facet.js.map +1 -1
- package/lib/testing/iota-facet.d.ts.map +1 -1
- package/lib/testing/iota-facet.js +32 -20
- package/lib/testing/iota-facet.js.map +1 -1
- package/lib/testing/memory-database.d.ts +1 -1
- package/lib/testing/memory-database.d.ts.map +1 -1
- package/lib/testing/memory-database.js +81 -71
- package/lib/testing/memory-database.js.map +1 -1
- package/lib/testing/metric-utils.d.ts +2 -2
- package/lib/testing/metric-utils.d.ts.map +1 -1
- package/lib/testing/metric-utils.js +13 -12
- package/lib/testing/metric-utils.js.map +1 -1
- package/lib/testing/solana-facet.d.ts +3 -2
- package/lib/testing/solana-facet.d.ts.map +1 -1
- package/lib/testing/solana-facet.js +8 -5
- package/lib/testing/solana-facet.js.map +1 -1
- package/lib/testing/sui-facet.d.ts.map +1 -1
- package/lib/testing/sui-facet.js +30 -20
- package/lib/testing/sui-facet.js.map +1 -1
- package/lib/testing/test-processor-server.d.ts +19 -13
- package/lib/testing/test-processor-server.d.ts.map +1 -1
- package/lib/testing/test-processor-server.js +22 -20
- package/lib/testing/test-processor-server.js.map +1 -1
- package/lib/utils/price.d.ts +1 -1
- package/lib/utils/price.d.ts.map +1 -1
- package/lib/utils/price.js +19 -12
- package/lib/utils/price.js.map +1 -1
- package/package.json +5 -7
- package/src/aptos/aptos-plugin.ts +105 -91
- package/src/aptos/aptos-processor.ts +33 -25
- package/src/aptos/aptos-resource-processor-template.ts +15 -6
- package/src/aptos/context.ts +8 -7
- package/src/aptos/data.ts +4 -4
- package/src/core/base-context.ts +19 -12
- package/src/core/core-plugin.ts +10 -7
- package/src/core/event-logger.ts +63 -34
- package/src/core/exporter.ts +5 -4
- package/src/core/handler-options.ts +1 -1
- package/src/core/handler-register.ts +3 -3
- package/src/core/meter.ts +9 -7
- package/src/core/normalization.ts +53 -31
- package/src/core/numberish.ts +46 -30
- package/src/core/partition-handler-manager.ts +13 -11
- package/src/cosmos/context.ts +4 -3
- package/src/cosmos/cosmos-plugin.ts +19 -15
- package/src/cosmos/cosmos-processor.ts +2 -2
- package/src/eth/abi-decoder/decode-worker.ts +2 -2
- package/src/eth/account-processor.ts +21 -12
- package/src/eth/base-processor-template.ts +22 -10
- package/src/eth/base-processor.ts +66 -54
- package/src/eth/builtin/internal/eacaggregatorproxy-processor.ts +177 -116
- package/src/eth/builtin/internal/erc1155-processor.ts +73 -38
- package/src/eth/builtin/internal/erc20-processor.ts +152 -91
- package/src/eth/builtin/internal/erc20bytes-processor.ts +80 -46
- package/src/eth/builtin/internal/erc721-processor.ts +109 -65
- package/src/eth/builtin/internal/weth9-processor.ts +95 -56
- package/src/eth/codegen/file.ts +2 -1
- package/src/eth/codegen/function-calls.ts +1 -1
- package/src/eth/context.ts +18 -11
- package/src/eth/eth-plugin.ts +135 -118
- package/src/eth/eth.ts +29 -20
- package/src/eth/index.ts +1 -1
- package/src/fuel/asset-processor.ts +16 -8
- package/src/fuel/context.ts +4 -3
- package/src/fuel/fuel-plugin.ts +71 -73
- package/src/fuel/fuel-processor-template.ts +7 -6
- package/src/fuel/fuel-processor.ts +35 -23
- package/src/fuel/global-processor.ts +3 -3
- package/src/fuel/types.ts +10 -4
- package/src/iota/context.ts +8 -7
- package/src/iota/iota-object-processor-template.ts +25 -15
- package/src/iota/iota-object-processor.ts +33 -22
- package/src/iota/iota-plugin-part.ts +41 -34
- package/src/iota/iota-processor.ts +25 -17
- package/src/iota/network.ts +2 -2
- package/src/move/filter.ts +1 -1
- package/src/move/index.ts +1 -1
- package/src/solana/solana-context.ts +4 -3
- package/src/solana/solana-plugin.ts +27 -24
- package/src/solana/solana-processor.ts +14 -6
- package/src/store/cache.ts +22 -18
- package/src/store/convert.ts +68 -104
- package/src/store/decorators.ts +3 -2
- package/src/store/store.ts +30 -22
- package/src/store/types.ts +24 -33
- package/src/store/util.ts +13 -18
- package/src/sui/context.ts +8 -7
- package/src/sui/sui-object-processor-template.ts +25 -15
- package/src/sui/sui-object-processor.ts +33 -22
- package/src/sui/sui-plugin-part.ts +41 -34
- package/src/sui/sui-plugin.ts +49 -47
- package/src/sui/sui-processor.ts +25 -17
- package/src/testing/aptos-facet.ts +18 -11
- package/src/testing/cosmos-facet.ts +10 -6
- package/src/testing/eth-facet.ts +40 -18
- package/src/testing/fuel-facet.ts +28 -18
- package/src/testing/iota-facet.ts +32 -20
- package/src/testing/memory-database.ts +109 -85
- package/src/testing/metric-utils.ts +15 -14
- package/src/testing/solana-facet.ts +11 -6
- package/src/testing/sui-facet.ts +30 -20
- package/src/testing/test-processor-server.ts +64 -58
- package/src/utils/price.ts +20 -13
package/src/core/numberish.ts
CHANGED
|
@@ -1,4 +1,16 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
type BigDecimalRichValue,
|
|
3
|
+
BigDecimalRichValueSchema,
|
|
4
|
+
type BigInteger,
|
|
5
|
+
BigIntegerSchema,
|
|
6
|
+
type MetricValue,
|
|
7
|
+
MetricValueSchema,
|
|
8
|
+
type RichStruct,
|
|
9
|
+
RichStructSchema,
|
|
10
|
+
RichValueSchema,
|
|
11
|
+
RichValue_NullValue
|
|
12
|
+
} from '@sentio/protos'
|
|
13
|
+
import { create } from '@bufbuild/protobuf'
|
|
2
14
|
import { BigDecimal } from './big-decimal.js'
|
|
3
15
|
|
|
4
16
|
export type Numberish = number | bigint | BigDecimal | string
|
|
@@ -12,30 +24,30 @@ export function toMetricValue(value: Numberish): MetricValue {
|
|
|
12
24
|
throw new Error('Cannot record infinite value')
|
|
13
25
|
}
|
|
14
26
|
if (Number.isInteger(value) && !Number.isSafeInteger(value)) {
|
|
15
|
-
return
|
|
16
|
-
bigInteger: toBigInteger(value)
|
|
27
|
+
return create(MetricValueSchema, {
|
|
28
|
+
value: { case: 'bigInteger', value: toBigInteger(value) }
|
|
17
29
|
})
|
|
18
30
|
}
|
|
19
31
|
|
|
20
|
-
return
|
|
21
|
-
doubleValue: Number(value)
|
|
32
|
+
return create(MetricValueSchema, {
|
|
33
|
+
value: { case: 'doubleValue', value: Number(value) }
|
|
22
34
|
})
|
|
23
35
|
}
|
|
24
36
|
if (typeof value === 'bigint') {
|
|
25
|
-
return
|
|
26
|
-
bigInteger: toBigInteger(value)
|
|
37
|
+
return create(MetricValueSchema, {
|
|
38
|
+
value: { case: 'bigInteger', value: toBigInteger(value) }
|
|
27
39
|
})
|
|
28
40
|
}
|
|
29
41
|
if (typeof value === 'string') {
|
|
30
|
-
return
|
|
31
|
-
bigDecimal: value
|
|
42
|
+
return create(MetricValueSchema, {
|
|
43
|
+
value: { case: 'bigDecimal', value: value }
|
|
32
44
|
})
|
|
33
45
|
}
|
|
34
46
|
// if (value instanceof BigDecimal) {
|
|
35
47
|
// Carefully consider the use case here
|
|
36
48
|
if (value.isInteger()) {
|
|
37
|
-
return
|
|
38
|
-
bigInteger: bigDecimalToBigInteger(value)
|
|
49
|
+
return create(MetricValueSchema, {
|
|
50
|
+
value: { case: 'bigInteger', value: bigDecimalToBigInteger(value) }
|
|
39
51
|
})
|
|
40
52
|
} else {
|
|
41
53
|
if (value.isNaN()) {
|
|
@@ -45,8 +57,8 @@ export function toMetricValue(value: Numberish): MetricValue {
|
|
|
45
57
|
// NaN also not finite
|
|
46
58
|
throw new Error('Cannot record infinite value')
|
|
47
59
|
}
|
|
48
|
-
return
|
|
49
|
-
bigDecimal: value.toString() // e.g. -7.350918e-428
|
|
60
|
+
return create(MetricValueSchema, {
|
|
61
|
+
value: { case: 'bigDecimal', value: value.toString() } // e.g. -7.350918e-428
|
|
50
62
|
})
|
|
51
63
|
}
|
|
52
64
|
// }
|
|
@@ -101,10 +113,10 @@ function hexToBigInteger(hex: string, negative: boolean): BigInteger {
|
|
|
101
113
|
}
|
|
102
114
|
const buffer = Buffer.from(hex, 'hex')
|
|
103
115
|
|
|
104
|
-
return {
|
|
116
|
+
return create(BigIntegerSchema, {
|
|
105
117
|
negative: negative,
|
|
106
118
|
data: new Uint8Array(buffer)
|
|
107
|
-
}
|
|
119
|
+
})
|
|
108
120
|
}
|
|
109
121
|
|
|
110
122
|
export function toBigDecimal(value: BigDecimal): BigDecimalRichValue {
|
|
@@ -115,41 +127,45 @@ export function toBigDecimal(value: BigDecimal): BigDecimalRichValue {
|
|
|
115
127
|
.join('')
|
|
116
128
|
const exp = -(s.length - (value.e ?? 0) - 1)
|
|
117
129
|
|
|
118
|
-
return {
|
|
130
|
+
return create(BigDecimalRichValueSchema, {
|
|
119
131
|
value: toBigInteger(BigInt(s) * BigInt(value.s ?? 1)),
|
|
120
132
|
exp: exp
|
|
121
|
-
}
|
|
133
|
+
})
|
|
122
134
|
}
|
|
123
135
|
|
|
124
136
|
export function toTimeSeriesData(value: Numberish, labels: Record<string, string>, neg: boolean) {
|
|
125
137
|
const mv = toMetricValue(value)
|
|
126
|
-
const data: RichStruct = {
|
|
138
|
+
const data: RichStruct = create(RichStructSchema, {
|
|
127
139
|
fields: {
|
|
128
140
|
value: {}
|
|
129
141
|
}
|
|
130
|
-
}
|
|
142
|
+
})
|
|
131
143
|
|
|
132
144
|
for (const key in labels) {
|
|
133
145
|
if (labels[key] == null) {
|
|
134
|
-
data.fields[key] = {
|
|
146
|
+
data.fields[key] = create(RichValueSchema, {
|
|
147
|
+
value: { case: 'nullValue', value: RichValue_NullValue.NULL_VALUE }
|
|
148
|
+
})
|
|
135
149
|
} else {
|
|
136
|
-
data.fields[key] = { stringValue: labels[key] }
|
|
150
|
+
data.fields[key] = create(RichValueSchema, { value: { case: 'stringValue', value: labels[key] } })
|
|
137
151
|
}
|
|
138
152
|
}
|
|
139
153
|
|
|
140
|
-
if (mv.
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
154
|
+
if (mv.value.case === 'bigInteger') {
|
|
155
|
+
const bigInteger = mv.value.value
|
|
156
|
+
bigInteger.negative = neg ? !bigInteger.negative : bigInteger.negative
|
|
157
|
+
data.fields.value.value = { case: 'bigintValue', value: bigInteger }
|
|
158
|
+
} else if (mv.value.case === 'bigDecimal') {
|
|
159
|
+
let v = new BigDecimal(mv.value.value)
|
|
145
160
|
if (neg) {
|
|
146
161
|
v = v.negated()
|
|
147
162
|
}
|
|
148
|
-
data.fields.value.
|
|
149
|
-
} else if (mv.
|
|
150
|
-
|
|
163
|
+
data.fields.value.value = { case: 'bigdecimalValue', value: toBigDecimal(v) }
|
|
164
|
+
} else if (mv.value.case === 'doubleValue') {
|
|
165
|
+
const doubleValue = mv.value.value
|
|
166
|
+
data.fields.value.value = { case: 'floatValue', value: neg ? -doubleValue : doubleValue }
|
|
151
167
|
} else {
|
|
152
|
-
data.fields.value.
|
|
168
|
+
data.fields.value.value = { case: 'nullValue', value: RichValue_NullValue.NULL_VALUE }
|
|
153
169
|
}
|
|
154
170
|
return data
|
|
155
171
|
}
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
2
|
HandlerType,
|
|
3
|
-
ProcessStreamResponse_Partitions_Partition,
|
|
3
|
+
type ProcessStreamResponse_Partitions_Partition,
|
|
4
|
+
ProcessStreamResponse_Partitions_PartitionSchema,
|
|
4
5
|
ProcessStreamResponse_Partitions_Partition_SysValue
|
|
5
6
|
} from '@sentio/protos'
|
|
6
|
-
import {
|
|
7
|
+
import { create } from '@bufbuild/protobuf'
|
|
8
|
+
import { ConnectError, Code } from '@connectrpc/connect'
|
|
7
9
|
|
|
8
10
|
/**
|
|
9
11
|
* Type for partition handler functions that can process any data type
|
|
@@ -51,20 +53,20 @@ export class PartitionHandlerManager {
|
|
|
51
53
|
if (partitionHandler && data) {
|
|
52
54
|
try {
|
|
53
55
|
const partitionValue = await partitionHandler(data)
|
|
54
|
-
result[handlerId] = {
|
|
55
|
-
userValue: partitionValue
|
|
56
|
-
}
|
|
56
|
+
result[handlerId] = create(ProcessStreamResponse_Partitions_PartitionSchema, {
|
|
57
|
+
value: { case: 'userValue', value: partitionValue ?? '' }
|
|
58
|
+
})
|
|
57
59
|
} catch (error) {
|
|
58
60
|
// If partition handler fails, fall back to unrecognized
|
|
59
|
-
throw new
|
|
60
|
-
|
|
61
|
-
|
|
61
|
+
throw new ConnectError(
|
|
62
|
+
'compute partition key failed, error:' + (error instanceof Error ? error.message : String(error)),
|
|
63
|
+
Code.InvalidArgument
|
|
62
64
|
)
|
|
63
65
|
}
|
|
64
66
|
} else {
|
|
65
|
-
result[handlerId] = {
|
|
66
|
-
sysValue: ProcessStreamResponse_Partitions_Partition_SysValue.
|
|
67
|
-
}
|
|
67
|
+
result[handlerId] = create(ProcessStreamResponse_Partitions_PartitionSchema, {
|
|
68
|
+
value: { case: 'sysValue', value: ProcessStreamResponse_Partitions_Partition_SysValue.BLOCK_NUMBER }
|
|
69
|
+
})
|
|
68
70
|
}
|
|
69
71
|
}
|
|
70
72
|
|
package/src/cosmos/context.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { BaseContext, Labels, normalizeLabels } from '../core/index.js'
|
|
2
2
|
import { ChainId, CosmosChainId } from '@sentio/chain'
|
|
3
|
-
import { RecordMetaData } from '@sentio/protos'
|
|
3
|
+
import { RecordMetaData, RecordMetaDataSchema } from '@sentio/protos'
|
|
4
|
+
import { create } from '@bufbuild/protobuf'
|
|
4
5
|
import { CosmosTransaction } from './transaction.js'
|
|
5
6
|
|
|
6
7
|
export class CosmosContext extends BaseContext {
|
|
@@ -23,7 +24,7 @@ export class CosmosContext extends BaseContext {
|
|
|
23
24
|
}
|
|
24
25
|
|
|
25
26
|
protected getMetaDataInternal(name: string, labels: Labels): RecordMetaData {
|
|
26
|
-
return {
|
|
27
|
+
return create(RecordMetaDataSchema, {
|
|
27
28
|
address: this.contractAddress,
|
|
28
29
|
contractName: labels['name'] || '',
|
|
29
30
|
blockNumber: BigInt(this.transaction?.height || 0),
|
|
@@ -33,6 +34,6 @@ export class CosmosContext extends BaseContext {
|
|
|
33
34
|
name: name,
|
|
34
35
|
logIndex: this.logIndex,
|
|
35
36
|
labels: normalizeLabels(labels)
|
|
36
|
-
}
|
|
37
|
+
})
|
|
37
38
|
}
|
|
38
39
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { errorString, GLOBAL_CONFIG, mergeProcessResults, Plugin, PluginManager, USER_PROCESSOR } from '@sentio/runtime'
|
|
2
2
|
import {
|
|
3
|
-
|
|
3
|
+
ContractConfigSchema,
|
|
4
|
+
CosmosLogHandlerConfigSchema,
|
|
4
5
|
DataBinding,
|
|
5
6
|
HandlerType,
|
|
6
7
|
InitResponse,
|
|
@@ -8,7 +9,8 @@ import {
|
|
|
8
9
|
ProcessResult,
|
|
9
10
|
StartRequest
|
|
10
11
|
} from '@sentio/protos'
|
|
11
|
-
import {
|
|
12
|
+
import { create } from '@bufbuild/protobuf'
|
|
13
|
+
import { ConnectError, Code } from '@connectrpc/connect'
|
|
12
14
|
import { HandlerRegister } from '../core/handler-register.js'
|
|
13
15
|
import { CosmosProcessorState } from './types.js'
|
|
14
16
|
|
|
@@ -31,7 +33,7 @@ export class CosmosPlugin extends Plugin {
|
|
|
31
33
|
if (forChainId !== undefined && forChainId !== chainId.toString()) {
|
|
32
34
|
continue
|
|
33
35
|
}
|
|
34
|
-
const contractConfig =
|
|
36
|
+
const contractConfig = create(ContractConfigSchema, {
|
|
35
37
|
processorType: USER_PROCESSOR,
|
|
36
38
|
contract: {
|
|
37
39
|
name: processor.config.name,
|
|
@@ -46,11 +48,13 @@ export class CosmosPlugin extends Plugin {
|
|
|
46
48
|
for (const callHandler of processor.callHandlers) {
|
|
47
49
|
const handlerId = this.handlerRegister.register(callHandler.handler, chainId)
|
|
48
50
|
|
|
49
|
-
contractConfig.cosmosLogConfigs.push(
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
51
|
+
contractConfig.cosmosLogConfigs.push(
|
|
52
|
+
create(CosmosLogHandlerConfigSchema, {
|
|
53
|
+
handlerId,
|
|
54
|
+
handlerName: callHandler.handlerName,
|
|
55
|
+
logFilters: callHandler.logConfig?.logFilters || []
|
|
56
|
+
})
|
|
57
|
+
)
|
|
54
58
|
}
|
|
55
59
|
|
|
56
60
|
// Finish up a contract
|
|
@@ -65,17 +69,17 @@ export class CosmosPlugin extends Plugin {
|
|
|
65
69
|
case HandlerType.COSMOS_CALL:
|
|
66
70
|
return this.processTransaction(request)
|
|
67
71
|
default:
|
|
68
|
-
throw new
|
|
72
|
+
throw new ConnectError('No handle type registered ' + request.handlerType, Code.InvalidArgument)
|
|
69
73
|
}
|
|
70
74
|
}
|
|
71
75
|
|
|
72
76
|
async start(request: StartRequest) {}
|
|
73
77
|
|
|
74
78
|
async processTransaction(binding: DataBinding): Promise<ProcessResult> {
|
|
75
|
-
if (
|
|
76
|
-
throw new
|
|
79
|
+
if (binding.data?.value.case !== 'cosmosCall' || !binding.data.value.value.transaction) {
|
|
80
|
+
throw new ConnectError("transaction can't be null", Code.InvalidArgument)
|
|
77
81
|
}
|
|
78
|
-
const call = binding.data.
|
|
82
|
+
const call = binding.data.value.value
|
|
79
83
|
|
|
80
84
|
const promises: Promise<ProcessResult>[] = []
|
|
81
85
|
|
|
@@ -86,9 +90,9 @@ export class CosmosPlugin extends Plugin {
|
|
|
86
90
|
handlerId
|
|
87
91
|
)(call)
|
|
88
92
|
.catch((e) => {
|
|
89
|
-
throw new
|
|
90
|
-
|
|
91
|
-
|
|
93
|
+
throw new ConnectError(
|
|
94
|
+
'error processing transaction: ' + JSON.stringify(call.transaction) + '\n' + errorString(e),
|
|
95
|
+
Code.Internal
|
|
92
96
|
)
|
|
93
97
|
})
|
|
94
98
|
if (GLOBAL_CONFIG.execution.sequential) {
|
|
@@ -27,7 +27,7 @@ export class CosmosProcessor {
|
|
|
27
27
|
const callHandler = {
|
|
28
28
|
handlerName: getHandlerName(),
|
|
29
29
|
handler: async (call: Data_CosmosCall) => {
|
|
30
|
-
const transaction = call.transaction as CosmosTransaction
|
|
30
|
+
const transaction = call.transaction as unknown as CosmosTransaction
|
|
31
31
|
|
|
32
32
|
const ctx = new CosmosContext(this.config.chainId, this.config.address, transaction)
|
|
33
33
|
|
|
@@ -46,7 +46,7 @@ export class CosmosProcessor {
|
|
|
46
46
|
const p = handlerOptions?.partitionKey
|
|
47
47
|
if (!p) return undefined
|
|
48
48
|
if (typeof p === 'function') {
|
|
49
|
-
const transaction = call.transaction as CosmosTransaction
|
|
49
|
+
const transaction = call.transaction as unknown as CosmosTransaction
|
|
50
50
|
return p(transaction)
|
|
51
51
|
}
|
|
52
52
|
return p
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Interface, LogDescription, LogParams, ParamType, Result } from 'ethers'
|
|
2
2
|
import { Piscina } from 'piscina'
|
|
3
|
-
import {
|
|
3
|
+
import { ConnectError, Code } from '@connectrpc/connect'
|
|
4
4
|
import { FormattedLog } from '../eth.js'
|
|
5
5
|
|
|
6
6
|
export interface IResult {
|
|
@@ -41,7 +41,7 @@ export interface ILogDescription {
|
|
|
41
41
|
|
|
42
42
|
export function parseLogInline(contractViewInterface: any, log: LogParams): LogDescription | null {
|
|
43
43
|
if (!log) {
|
|
44
|
-
throw new
|
|
44
|
+
throw new ConnectError('Log is empty', Code.InvalidArgument)
|
|
45
45
|
}
|
|
46
46
|
const topics = log.topics
|
|
47
47
|
const data = log.data
|
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
import { ERC20__factory, ERC721__factory } from './builtin/internal/index.js'
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
AddressType,
|
|
4
|
+
type EthFetchConfig,
|
|
5
|
+
EthFetchConfigSchema,
|
|
6
|
+
type PreprocessResult,
|
|
7
|
+
PreprocessResultSchema,
|
|
8
|
+
ProcessResultSchema,
|
|
9
|
+
timestampDate
|
|
10
|
+
} from '@sentio/protos'
|
|
11
|
+
import { create } from '@bufbuild/protobuf'
|
|
12
|
+
import { ConnectError, Code } from '@connectrpc/connect'
|
|
3
13
|
|
|
4
14
|
import { PartiallyOptional, PromiseOrVoid } from '../core/index.js'
|
|
5
15
|
|
|
@@ -12,7 +22,6 @@ import { Block } from 'ethers'
|
|
|
12
22
|
import { AccountProcessorState } from './account-processor-state.js'
|
|
13
23
|
import { fixEmptyKey, formatEthData, TypedEvent, validateAndNormalizeAddress } from './eth.js'
|
|
14
24
|
import { EthChainId } from '@sentio/chain'
|
|
15
|
-
import { ServerError, Status } from 'nice-grpc'
|
|
16
25
|
import { getHandlerName, proxyProcessor } from '../utils/metrics.js'
|
|
17
26
|
|
|
18
27
|
const ERC20_INTERFACE = ERC20__factory.createInterface()
|
|
@@ -258,7 +267,7 @@ export class AccountProcessor {
|
|
|
258
267
|
protected onEvent(
|
|
259
268
|
handler: (event: TypedEvent, ctx: AccountContext) => PromiseOrVoid,
|
|
260
269
|
filter: AddressOrTypeEventFilter | AddressOrTypeEventFilter[],
|
|
261
|
-
fetchConfig?: Partial<EthFetchConfig>,
|
|
270
|
+
fetchConfig?: Omit<Partial<EthFetchConfig>, '$typeName' | '$unknown'>,
|
|
262
271
|
preprocessHandler: (
|
|
263
272
|
event: TypedEvent,
|
|
264
273
|
ctx: AccountContext,
|
|
@@ -295,19 +304,19 @@ export class AccountProcessor {
|
|
|
295
304
|
|
|
296
305
|
this.eventHandlers.push({
|
|
297
306
|
filters: _filters,
|
|
298
|
-
fetchConfig:
|
|
307
|
+
fetchConfig: create(EthFetchConfigSchema, fetchConfig || {}),
|
|
299
308
|
handlerName: getHandlerName(),
|
|
300
309
|
handler: async function (data) {
|
|
301
310
|
const { log, block, transaction, transactionReceipt } = formatEthData(data)
|
|
302
311
|
if (!log) {
|
|
303
|
-
throw new
|
|
312
|
+
throw new ConnectError('Log is empty', Code.InvalidArgument)
|
|
304
313
|
}
|
|
305
314
|
// const log = data.log as { topics: Array<string>; data: string }
|
|
306
315
|
const ctx = new AccountContext(
|
|
307
316
|
chainId,
|
|
308
317
|
config.address,
|
|
309
|
-
data.timestamp,
|
|
310
|
-
|
|
318
|
+
data.timestamp ? timestampDate(data.timestamp) : undefined,
|
|
319
|
+
block as Block,
|
|
311
320
|
log,
|
|
312
321
|
undefined,
|
|
313
322
|
transaction,
|
|
@@ -321,19 +330,19 @@ export class AccountProcessor {
|
|
|
321
330
|
await handler(event, ctx)
|
|
322
331
|
return ctx.stopAndGetResult()
|
|
323
332
|
}
|
|
324
|
-
return
|
|
333
|
+
return create(ProcessResultSchema)
|
|
325
334
|
},
|
|
326
335
|
preprocessHandler: async function (data, preprocessStore: { [k: string]: any }) {
|
|
327
336
|
const { log, block, transaction, transactionReceipt } = formatEthData(data)
|
|
328
337
|
if (!log) {
|
|
329
|
-
throw new
|
|
338
|
+
throw new ConnectError('Log is empty', Code.InvalidArgument)
|
|
330
339
|
}
|
|
331
340
|
// const log = data.log as { topics: Array<string>; data: string }
|
|
332
341
|
const ctx = new AccountContext(
|
|
333
342
|
chainId,
|
|
334
343
|
config.address,
|
|
335
|
-
data.timestamp,
|
|
336
|
-
|
|
344
|
+
data.timestamp ? timestampDate(data.timestamp) : undefined,
|
|
345
|
+
block as Block,
|
|
337
346
|
log,
|
|
338
347
|
undefined,
|
|
339
348
|
transaction,
|
|
@@ -346,7 +355,7 @@ export class AccountProcessor {
|
|
|
346
355
|
const event: TypedEvent = new TypedEvent(log, parsed.name, fixEmptyKey(parsed))
|
|
347
356
|
return preprocessHandler(event, ctx, preprocessStore)
|
|
348
357
|
}
|
|
349
|
-
return
|
|
358
|
+
return create(PreprocessResultSchema)
|
|
350
359
|
}
|
|
351
360
|
})
|
|
352
361
|
|
|
@@ -2,7 +2,16 @@ import { BoundContractView, ContractContext, ContractView, EthContext } from './
|
|
|
2
2
|
import { BaseContract } from 'ethers'
|
|
3
3
|
import { BaseProcessor, defaultPreprocessHandler } from './base-processor.js'
|
|
4
4
|
import { BindOptions, getOptionsSignature } from './bind-options.js'
|
|
5
|
-
import {
|
|
5
|
+
import {
|
|
6
|
+
type EthFetchConfig,
|
|
7
|
+
EthFetchConfigSchema,
|
|
8
|
+
type HandleInterval,
|
|
9
|
+
HandleIntervalSchema,
|
|
10
|
+
type TemplateInstance,
|
|
11
|
+
TemplateInstanceSchema,
|
|
12
|
+
type PreprocessResult
|
|
13
|
+
} from '@sentio/protos'
|
|
14
|
+
import { create } from '@bufbuild/protobuf'
|
|
6
15
|
import { PromiseOrVoid } from '../core/promises.js'
|
|
7
16
|
import { ListStateStorage, processMetrics } from '@sentio/runtime'
|
|
8
17
|
import { BlockParams } from 'ethers/providers'
|
|
@@ -78,7 +87,7 @@ export abstract class BaseProcessorTemplate<
|
|
|
78
87
|
public bind(options: Omit<BindOptions, 'network'>, ctx: EthContext): void {
|
|
79
88
|
options = { ...options, address: validateAndNormalizeAddress(options.address) }
|
|
80
89
|
|
|
81
|
-
const instance: TemplateInstance = {
|
|
90
|
+
const instance: TemplateInstance = create(TemplateInstanceSchema, {
|
|
82
91
|
templateId: this.id,
|
|
83
92
|
contract: {
|
|
84
93
|
address: options.address,
|
|
@@ -89,7 +98,7 @@ export abstract class BaseProcessorTemplate<
|
|
|
89
98
|
startBlock: BigInt(options.startBlock || 0),
|
|
90
99
|
endBlock: BigInt(options.endBlock || 0),
|
|
91
100
|
baseLabels: options.baseLabels
|
|
92
|
-
}
|
|
101
|
+
})
|
|
93
102
|
|
|
94
103
|
ctx.sendTemplateInstance(instance)
|
|
95
104
|
|
|
@@ -141,7 +150,7 @@ export abstract class BaseProcessorTemplate<
|
|
|
141
150
|
protected onEthEvent(
|
|
142
151
|
handler: (event: TypedEvent, ctx: ContractContext<TContract, TBoundContractView>) => PromiseOrVoid,
|
|
143
152
|
filter: DeferredTopicFilter | DeferredTopicFilter[],
|
|
144
|
-
fetchConfig?: Partial<EthFetchConfig>,
|
|
153
|
+
fetchConfig?: Omit<Partial<EthFetchConfig>, '$typeName' | '$unknown'>,
|
|
145
154
|
preprocessHandler: (
|
|
146
155
|
event: TypedEvent,
|
|
147
156
|
ctx: ContractContext<TContract, TBoundContractView>,
|
|
@@ -153,7 +162,7 @@ export abstract class BaseProcessorTemplate<
|
|
|
153
162
|
handler: handler,
|
|
154
163
|
preprocessHandler,
|
|
155
164
|
filter: filter,
|
|
156
|
-
fetchConfig:
|
|
165
|
+
fetchConfig: create(EthFetchConfigSchema, fetchConfig || {})
|
|
157
166
|
})
|
|
158
167
|
return this
|
|
159
168
|
}
|
|
@@ -172,10 +181,10 @@ export abstract class BaseProcessorTemplate<
|
|
|
172
181
|
return this.onInterval(
|
|
173
182
|
handler,
|
|
174
183
|
undefined,
|
|
175
|
-
{
|
|
184
|
+
create(HandleIntervalSchema, {
|
|
176
185
|
recentInterval: blockInterval,
|
|
177
186
|
backfillInterval: backfillBlockInterval
|
|
178
|
-
},
|
|
187
|
+
}),
|
|
179
188
|
fetchConfig,
|
|
180
189
|
preprocessHandler
|
|
181
190
|
)
|
|
@@ -194,7 +203,10 @@ export abstract class BaseProcessorTemplate<
|
|
|
194
203
|
) {
|
|
195
204
|
return this.onInterval(
|
|
196
205
|
handler,
|
|
197
|
-
|
|
206
|
+
create(HandleIntervalSchema, {
|
|
207
|
+
recentInterval: timeIntervalInMinutes,
|
|
208
|
+
backfillInterval: backfillTimeIntervalInMinutes
|
|
209
|
+
}),
|
|
198
210
|
undefined,
|
|
199
211
|
fetchConfig,
|
|
200
212
|
preprocessHandler
|
|
@@ -226,7 +238,7 @@ export abstract class BaseProcessorTemplate<
|
|
|
226
238
|
public onTrace(
|
|
227
239
|
signature: string,
|
|
228
240
|
handler: (trace: TypedCallTrace, ctx: ContractContext<TContract, TBoundContractView>) => PromiseOrVoid,
|
|
229
|
-
fetchConfig?: Partial<EthFetchConfig>,
|
|
241
|
+
fetchConfig?: Omit<Partial<EthFetchConfig>, '$typeName' | '$unknown'>,
|
|
230
242
|
preprocessHandler: (
|
|
231
243
|
trace: TypedCallTrace,
|
|
232
244
|
ctx: ContractContext<TContract, TBoundContractView>,
|
|
@@ -238,7 +250,7 @@ export abstract class BaseProcessorTemplate<
|
|
|
238
250
|
handlerName: getHandlerName(),
|
|
239
251
|
handler,
|
|
240
252
|
preprocessHandler,
|
|
241
|
-
fetchConfig:
|
|
253
|
+
fetchConfig: create(EthFetchConfigSchema, fetchConfig || {})
|
|
242
254
|
})
|
|
243
255
|
return this
|
|
244
256
|
}
|