@sentio/sdk 3.9.0-rc.9 → 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 +4 -4
- 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 +14 -8
- package/lib/eth/base-processor-template.js.map +1 -1
- package/lib/eth/base-processor.d.ts +3 -3
- 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 +9 -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 +3 -3
- package/lib/iota/iota-processor.d.ts.map +1 -1
- package/lib/iota/iota-processor.js +20 -19
- 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/codegen/codegen.d.ts +1 -1
- package/lib/solana/codegen/codegen.d.ts.map +1 -1
- package/lib/solana/codegen/codegen.js +2 -2
- package/lib/solana/codegen/codegen.js.map +1 -1
- 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 +2 -2
- 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/codegen.js +2 -2
- package/lib/store/codegen.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 +3 -3
- package/lib/sui/sui-processor.d.ts.map +1 -1
- package/lib/sui/sui-processor.js +20 -19
- 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 +82 -69
- 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 +10 -12
- package/src/aptos/aptos-plugin.ts +105 -91
- package/src/aptos/aptos-processor.ts +42 -34
- 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 +27 -11
- package/src/eth/base-processor.ts +77 -65
- 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 +10 -7
- 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 +35 -27
- package/src/iota/network.ts +2 -2
- package/src/move/filter.ts +1 -1
- package/src/move/index.ts +1 -1
- package/src/solana/codegen/codegen.ts +2 -2
- package/src/solana/solana-context.ts +4 -3
- package/src/solana/solana-plugin.ts +27 -24
- package/src/solana/solana-processor.ts +23 -11
- package/src/store/cache.ts +22 -18
- package/src/store/codegen.ts +2 -2
- package/src/store/convert.ts +68 -104
- package/src/store/decorators.ts +3 -2
- package/src/store/store.ts +31 -23
- 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 +35 -27
- 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 -82
- 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
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { TestProcessorServer } from './test-processor-server.js'
|
|
2
|
-
import {
|
|
2
|
+
import { Data_SolInstructionSchema, DataBindingSchema, HandlerType, type ProcessBindingResponse } from '@sentio/protos'
|
|
3
|
+
import { create, type MessageInitShape } from '@bufbuild/protobuf'
|
|
3
4
|
import { ChainId } from '@sentio/chain'
|
|
4
5
|
|
|
5
6
|
export class SolanaFacet {
|
|
@@ -9,18 +10,22 @@ export class SolanaFacet {
|
|
|
9
10
|
this.server = server
|
|
10
11
|
}
|
|
11
12
|
|
|
12
|
-
testInstructions(
|
|
13
|
+
testInstructions(
|
|
14
|
+
instructions: MessageInitShape<typeof Data_SolInstructionSchema>[]
|
|
15
|
+
): Promise<ProcessBindingResponse> {
|
|
13
16
|
return this.server.processBindings({
|
|
14
17
|
bindings: instructions.map((instruction) => {
|
|
15
|
-
return {
|
|
18
|
+
return create(DataBindingSchema, {
|
|
16
19
|
data: {
|
|
17
|
-
|
|
18
|
-
|
|
20
|
+
value: {
|
|
21
|
+
case: 'solInstruction',
|
|
22
|
+
value: instruction
|
|
23
|
+
}
|
|
19
24
|
},
|
|
20
25
|
handlerIds: [],
|
|
21
26
|
handlerType: HandlerType.SOL_INSTRUCTION,
|
|
22
27
|
chainId: ChainId.SOLANA_MAINNET
|
|
23
|
-
}
|
|
28
|
+
})
|
|
24
29
|
})
|
|
25
30
|
})
|
|
26
31
|
}
|
package/src/testing/sui-facet.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { GrpcTypes } from '@mysten/sui/grpc'
|
|
2
|
-
import { DataBinding, HandlerType } from '@sentio/protos'
|
|
2
|
+
import { type DataBinding, DataBindingSchema, HandlerType, timestampNow } from '@sentio/protos'
|
|
3
|
+
import { create } from '@bufbuild/protobuf'
|
|
3
4
|
import { TestProcessorServer } from './test-processor-server.js'
|
|
4
5
|
import { accountTypeString, parseMoveType, SPLITTER } from '../move/index.js'
|
|
5
6
|
import { SuiNetwork } from '../sui/index.js'
|
|
@@ -47,18 +48,21 @@ export class SuiFacet {
|
|
|
47
48
|
for (const callConfig of config.moveCallConfigs) {
|
|
48
49
|
for (const callFilter of callConfig.filters) {
|
|
49
50
|
if (accountTypeString(config.contract.address) + '::' + callFilter.function === functionType) {
|
|
50
|
-
return {
|
|
51
|
+
return create(DataBindingSchema, {
|
|
51
52
|
data: {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
53
|
+
value: {
|
|
54
|
+
case: 'suiCall',
|
|
55
|
+
value: {
|
|
56
|
+
rawTransaction: JSON.stringify(transaction),
|
|
57
|
+
timestamp: timestampNow(),
|
|
58
|
+
slot: 10000n
|
|
59
|
+
}
|
|
56
60
|
}
|
|
57
61
|
},
|
|
58
62
|
handlerIds: [callConfig.handlerId],
|
|
59
63
|
handlerType: HandlerType.SUI_CALL,
|
|
60
64
|
chainId: network
|
|
61
|
-
}
|
|
65
|
+
})
|
|
62
66
|
}
|
|
63
67
|
}
|
|
64
68
|
}
|
|
@@ -91,18 +95,21 @@ export class SuiFacet {
|
|
|
91
95
|
throw Error('Invalid test global transaction: ' + JSON.stringify(transaction))
|
|
92
96
|
}
|
|
93
97
|
|
|
94
|
-
const binding: DataBinding = {
|
|
98
|
+
const binding: DataBinding = create(DataBindingSchema, {
|
|
95
99
|
handlerIds,
|
|
96
100
|
handlerType: HandlerType.SUI_CALL,
|
|
97
101
|
data: {
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
+
value: {
|
|
103
|
+
case: 'suiCall',
|
|
104
|
+
value: {
|
|
105
|
+
rawTransaction: JSON.stringify(transaction),
|
|
106
|
+
timestamp: timestampNow(),
|
|
107
|
+
slot: BigInt(transaction.checkpoint || 0)
|
|
108
|
+
}
|
|
102
109
|
}
|
|
103
110
|
},
|
|
104
111
|
chainId: network
|
|
105
|
-
}
|
|
112
|
+
})
|
|
106
113
|
return this.server.processBinding(binding)
|
|
107
114
|
}
|
|
108
115
|
|
|
@@ -123,19 +130,22 @@ export class SuiFacet {
|
|
|
123
130
|
accountTypeString(config.contract.address) + '::' + eventFilter.type ===
|
|
124
131
|
parseMoveType(event.eventType ?? '').qname
|
|
125
132
|
) {
|
|
126
|
-
return {
|
|
133
|
+
return create(DataBindingSchema, {
|
|
127
134
|
data: {
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
135
|
+
value: {
|
|
136
|
+
case: 'suiEvent',
|
|
137
|
+
value: {
|
|
138
|
+
rawEvent: JSON.stringify(event),
|
|
139
|
+
rawTransaction: JSON.stringify(transaction),
|
|
140
|
+
timestamp: timestampNow(),
|
|
141
|
+
slot: 10000n
|
|
142
|
+
}
|
|
133
143
|
}
|
|
134
144
|
},
|
|
135
145
|
handlerIds: [eventConfig.handlerId],
|
|
136
146
|
handlerType: HandlerType.SUI_EVENT,
|
|
137
147
|
chainId: network
|
|
138
|
-
}
|
|
148
|
+
})
|
|
139
149
|
}
|
|
140
150
|
}
|
|
141
151
|
}
|
|
@@ -1,24 +1,24 @@
|
|
|
1
1
|
import {
|
|
2
|
-
AccountConfig,
|
|
3
|
-
ContractConfig,
|
|
4
|
-
DataBinding,
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
PreprocessStreamRequest,
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
ProcessConfigResponse,
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
TimeseriesResult
|
|
2
|
+
type AccountConfig,
|
|
3
|
+
type ContractConfig,
|
|
4
|
+
type DataBinding,
|
|
5
|
+
type Empty,
|
|
6
|
+
EmptySchema,
|
|
7
|
+
type PreprocessStreamRequest,
|
|
8
|
+
type ProcessBindingResponse,
|
|
9
|
+
ProcessBindingResponseSchema,
|
|
10
|
+
ProcessBindingsRequestSchema,
|
|
11
|
+
ProcessConfigRequestSchema,
|
|
12
|
+
type ProcessConfigResponse,
|
|
13
|
+
type ProcessStreamRequest,
|
|
14
|
+
ProcessStreamResponseSchema,
|
|
15
|
+
StartRequestSchema,
|
|
16
|
+
type TemplateInstance,
|
|
17
|
+
type TimeseriesResult,
|
|
18
|
+
UpdateTemplatesRequestSchema
|
|
20
19
|
} from '@sentio/protos'
|
|
21
|
-
import {
|
|
20
|
+
import { create, type MessageInitShape } from '@bufbuild/protobuf'
|
|
21
|
+
import { type HandlerContext } from '@connectrpc/connect'
|
|
22
22
|
import {
|
|
23
23
|
Endpoints,
|
|
24
24
|
IDataBindingContext,
|
|
@@ -40,7 +40,9 @@ import { DatabaseSchemaState } from '../core/database-schema.js'
|
|
|
40
40
|
import { IotaFacet } from './iota-facet.js'
|
|
41
41
|
import { ChainInfo } from '@sentio/chain'
|
|
42
42
|
|
|
43
|
-
|
|
43
|
+
type ProcessStreamResponseInit = MessageInitShape<typeof ProcessStreamResponseSchema>
|
|
44
|
+
|
|
45
|
+
export const TEST_CONTEXT = {} as HandlerContext
|
|
44
46
|
|
|
45
47
|
export function cleanTest() {
|
|
46
48
|
// retain the DatabaseSchemaState
|
|
@@ -49,7 +51,7 @@ export function cleanTest() {
|
|
|
49
51
|
State.INSTANCE.stateMap.set(DatabaseSchemaState.INSTANCE.key(), state)
|
|
50
52
|
}
|
|
51
53
|
|
|
52
|
-
export class TestProcessorServer
|
|
54
|
+
export class TestProcessorServer {
|
|
53
55
|
service: ProcessorServiceImpl
|
|
54
56
|
contractConfigs: ContractConfig[]
|
|
55
57
|
accountConfigs: AccountConfig[]
|
|
@@ -82,79 +84,83 @@ export class TestProcessorServer implements ProcessorServiceImplementation {
|
|
|
82
84
|
}
|
|
83
85
|
|
|
84
86
|
// start a memory database for testing
|
|
85
|
-
const subject = new Subject<
|
|
87
|
+
const subject = new Subject<ProcessStreamResponseInit>()
|
|
86
88
|
this.storeContext = new TestStoreContext(subject, 1)
|
|
87
89
|
this._db = new MemoryDatabase(this.storeContext)
|
|
88
90
|
}
|
|
89
91
|
|
|
90
|
-
async start(
|
|
91
|
-
|
|
92
|
-
|
|
92
|
+
async start(
|
|
93
|
+
request: MessageInitShape<typeof StartRequestSchema> = { templateInstances: [] },
|
|
94
|
+
context = TEST_CONTEXT
|
|
95
|
+
) {
|
|
96
|
+
const req = create(StartRequestSchema, request)
|
|
97
|
+
const res = await this.service.start(req, context)
|
|
98
|
+
const config = await this.getConfig(create(ProcessConfigRequestSchema, {}))
|
|
93
99
|
this.contractConfigs = config.contractConfigs
|
|
94
100
|
this.accountConfigs = config.accountConfigs
|
|
95
101
|
this._db.start()
|
|
96
|
-
this.storeContext.templateInstances =
|
|
102
|
+
this.storeContext.templateInstances = req.templateInstances
|
|
97
103
|
return res
|
|
98
104
|
}
|
|
99
105
|
|
|
100
|
-
stop(request: Empty, context = TEST_CONTEXT)
|
|
106
|
+
stop(request: Empty = create(EmptySchema), context = TEST_CONTEXT) {
|
|
101
107
|
return this.service.stop(request, context)
|
|
102
108
|
}
|
|
103
109
|
|
|
104
|
-
async getConfig(
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
+
async getConfig(
|
|
111
|
+
request: MessageInitShape<typeof ProcessConfigRequestSchema> = {},
|
|
112
|
+
context = TEST_CONTEXT
|
|
113
|
+
): Promise<ProcessConfigResponse> {
|
|
114
|
+
const config = await this.service.getConfig(create(ProcessConfigRequestSchema, request), context)
|
|
115
|
+
config.templateInstances = this.storeContext.templateInstances
|
|
116
|
+
return config
|
|
110
117
|
}
|
|
111
118
|
|
|
112
119
|
processBindings(
|
|
113
|
-
request:
|
|
114
|
-
context:
|
|
120
|
+
request: MessageInitShape<typeof ProcessBindingsRequestSchema>,
|
|
121
|
+
context: HandlerContext = TEST_CONTEXT
|
|
115
122
|
): Promise<ProcessBindingResponse> {
|
|
123
|
+
const req = create(ProcessBindingsRequestSchema, request)
|
|
116
124
|
return PluginManager.INSTANCE.dbContextLocalStorage.run(this.storeContext, async () => {
|
|
117
|
-
const ret = await this.service.processBindings(
|
|
125
|
+
const ret = await this.service.processBindings(req, context)
|
|
118
126
|
if (ret.result?.states?.configUpdated) {
|
|
119
127
|
// template may changed
|
|
120
|
-
await PluginManager.INSTANCE.updateTemplates(
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
128
|
+
await PluginManager.INSTANCE.updateTemplates(
|
|
129
|
+
create(UpdateTemplatesRequestSchema, {
|
|
130
|
+
chainId: req.bindings[0].chainId,
|
|
131
|
+
templateInstances: this.storeContext.templateInstances
|
|
132
|
+
})
|
|
133
|
+
)
|
|
124
134
|
}
|
|
125
|
-
return ret
|
|
135
|
+
return create(ProcessBindingResponseSchema, ret)
|
|
126
136
|
})
|
|
127
137
|
}
|
|
128
138
|
|
|
129
|
-
async processBinding(request: DataBinding, context:
|
|
139
|
+
async processBinding(request: DataBinding, context: HandlerContext = TEST_CONTEXT): Promise<ProcessBindingResponse> {
|
|
130
140
|
const ret = await PluginManager.INSTANCE.dbContextLocalStorage.run(this.storeContext, () => {
|
|
131
|
-
return this.service.processBindings({ bindings: [request] }, context)
|
|
141
|
+
return this.service.processBindings(create(ProcessBindingsRequestSchema, { bindings: [request] }), context)
|
|
132
142
|
})
|
|
133
143
|
if (ret.result?.states?.configUpdated) {
|
|
134
144
|
// template may changed
|
|
135
|
-
await PluginManager.INSTANCE.updateTemplates(
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
145
|
+
await PluginManager.INSTANCE.updateTemplates(
|
|
146
|
+
create(UpdateTemplatesRequestSchema, {
|
|
147
|
+
chainId: request.chainId,
|
|
148
|
+
templateInstances: this.storeContext.templateInstances
|
|
149
|
+
})
|
|
150
|
+
)
|
|
139
151
|
}
|
|
140
|
-
return ret
|
|
152
|
+
return create(ProcessBindingResponseSchema, ret)
|
|
141
153
|
}
|
|
142
154
|
|
|
143
|
-
processBindingsStream(
|
|
144
|
-
requests: AsyncIterable<ProcessStreamRequest>,
|
|
145
|
-
context: CallContext
|
|
146
|
-
): ServerStreamingMethodResult<DeepPartial<ProcessStreamResponse>> {
|
|
155
|
+
processBindingsStream(requests: AsyncIterable<ProcessStreamRequest>, context: HandlerContext): never {
|
|
147
156
|
throw new Error('Method not implemented.')
|
|
148
157
|
}
|
|
149
158
|
|
|
150
|
-
preprocessBindingsStream(
|
|
151
|
-
requests: AsyncIterable<PreprocessStreamRequest>,
|
|
152
|
-
context: CallContext
|
|
153
|
-
): ServerStreamingMethodResult<DeepPartial<PreprocessStreamResponse>> {
|
|
159
|
+
preprocessBindingsStream(requests: AsyncIterable<PreprocessStreamRequest>, context: HandlerContext): never {
|
|
154
160
|
throw new Error('Method not implemented.')
|
|
155
161
|
}
|
|
156
162
|
|
|
157
|
-
// processBindingsStream(request: AsyncIterable<ProcessStreamRequest>, context:
|
|
163
|
+
// processBindingsStream(request: AsyncIterable<ProcessStreamRequest>, context: HandlerContext) {
|
|
158
164
|
// return this.service.processBindingsStream(request, context)
|
|
159
165
|
// }
|
|
160
166
|
get db() {
|
|
@@ -168,7 +174,7 @@ export class TestProcessorServer implements ProcessorServiceImplementation {
|
|
|
168
174
|
|
|
169
175
|
class TestStoreContext extends StoreContext implements IDataBindingContext {
|
|
170
176
|
constructor(
|
|
171
|
-
readonly subject: Subject<
|
|
177
|
+
readonly subject: Subject<ProcessStreamResponseInit>,
|
|
172
178
|
processId: number
|
|
173
179
|
) {
|
|
174
180
|
super(subject, processId)
|
package/src/utils/price.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { CoinID } from '@sentio/protos'
|
|
1
|
+
import { type CoinID, CoinIDSchema } from '@sentio/protos'
|
|
2
|
+
import { create } from '@bufbuild/protobuf'
|
|
2
3
|
import { Endpoints, processMetrics } from '@sentio/runtime'
|
|
3
4
|
import { ChainId } from '@sentio/chain'
|
|
4
5
|
import { LRUCache } from 'lru-cache'
|
|
@@ -56,11 +57,14 @@ export async function getPriceByTypeOrSymbolInternal(
|
|
|
56
57
|
const dateStr = dateString(date)
|
|
57
58
|
const todayDateString = dateString(new Date())
|
|
58
59
|
|
|
60
|
+
const symbol = coinId.id.case === 'symbol' ? coinId.id.value : undefined
|
|
61
|
+
const address = coinId.id.case === 'address' ? coinId.id.value : undefined
|
|
62
|
+
|
|
59
63
|
let key: string
|
|
60
|
-
if (
|
|
61
|
-
key = `${
|
|
64
|
+
if (symbol) {
|
|
65
|
+
key = `${symbol}-${dateStr}`
|
|
62
66
|
} else {
|
|
63
|
-
key = `${
|
|
67
|
+
key = `${address?.address}-${address?.chain}-${dateStr}`
|
|
64
68
|
}
|
|
65
69
|
let price = priceMap.get(key)
|
|
66
70
|
if (price) {
|
|
@@ -71,9 +75,9 @@ export async function getPriceByTypeOrSymbolInternal(
|
|
|
71
75
|
const response = priceClient.getPrice({
|
|
72
76
|
query: {
|
|
73
77
|
timestamp: date.toISOString(),
|
|
74
|
-
'coinId.symbol':
|
|
75
|
-
'coinId.address.address':
|
|
76
|
-
'coinId.address.chain':
|
|
78
|
+
'coinId.symbol': symbol,
|
|
79
|
+
'coinId.address.address': address?.address,
|
|
80
|
+
'coinId.address.chain': address?.chain
|
|
77
81
|
}
|
|
78
82
|
})
|
|
79
83
|
price = response
|
|
@@ -131,12 +135,15 @@ export async function getPriceByType(
|
|
|
131
135
|
): Promise<number | undefined> {
|
|
132
136
|
return getPriceByTypeOrSymbol(
|
|
133
137
|
date,
|
|
134
|
-
{
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
+
create(CoinIDSchema, {
|
|
139
|
+
id: {
|
|
140
|
+
case: 'address',
|
|
141
|
+
value: {
|
|
142
|
+
chain: chainId,
|
|
143
|
+
address: coinType
|
|
144
|
+
}
|
|
138
145
|
}
|
|
139
|
-
},
|
|
146
|
+
}),
|
|
140
147
|
options
|
|
141
148
|
)
|
|
142
149
|
}
|
|
@@ -151,7 +158,7 @@ export async function getPriceBySymbol(
|
|
|
151
158
|
date: Date,
|
|
152
159
|
options?: PriceOptions
|
|
153
160
|
): Promise<number | undefined> {
|
|
154
|
-
return getPriceByTypeOrSymbol(date, { symbol }, options)
|
|
161
|
+
return getPriceByTypeOrSymbol(date, create(CoinIDSchema, { id: { case: 'symbol', value: symbol } }), options)
|
|
155
162
|
}
|
|
156
163
|
|
|
157
164
|
function dateString(date: Date) {
|