@sentio/sdk 3.9.0-rc.9 → 4.0.0-rc.10
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 +11 -9
- 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/aptos/network.js +1 -1
- package/lib/aptos/network.js.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 -27
- 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 +17 -11
- package/lib/eth/context.js.map +1 -1
- package/lib/eth/eth-plugin.d.ts.map +1 -1
- package/lib/eth/eth-plugin.js +85 -76
- 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 +39 -26
- package/lib/eth/eth.js.map +1 -1
- package/lib/eth/generic-processor.js +1 -1
- package/lib/eth/generic-processor.js.map +1 -1
- package/lib/eth/index.d.ts +2 -2
- package/lib/eth/index.d.ts.map +1 -1
- package/lib/eth/index.js +1 -2
- package/lib/eth/index.js.map +1 -1
- package/lib/eth/provider.d.ts +13 -0
- package/lib/eth/provider.d.ts.map +1 -0
- package/lib/eth/provider.js +164 -0
- package/lib/eth/provider.js.map +1 -0
- 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/network.js +5 -5
- package/lib/fuel/network.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 +6 -6
- 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/network.d.ts.map +1 -1
- package/lib/sui/network.js +11 -6
- package/lib/sui/network.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 +29 -21
- 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 +23 -21
- package/lib/sui/sui-processor.js.map +1 -1
- package/lib/sui/to-client-types.d.ts +4 -0
- package/lib/sui/to-client-types.d.ts.map +1 -0
- package/lib/sui/to-client-types.js +69 -0
- package/lib/sui/to-client-types.js.map +1 -0
- 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 +11 -3
- package/lib/testing/memory-database.d.ts.map +1 -1
- package/lib/testing/memory-database.js +85 -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 +1452 -16
- package/lib/testing/test-processor-server.d.ts.map +1 -1
- package/lib/testing/test-processor-server.js +109 -46
- package/lib/testing/test-processor-server.js.map +1 -1
- package/lib/testing/test-provider.js +1 -1
- package/lib/testing/test-provider.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 +11 -10
- package/src/aptos/data.ts +4 -4
- package/src/aptos/network.ts +1 -1
- package/src/core/base-context.ts +19 -12
- package/src/core/core-plugin.ts +10 -7
- package/src/core/event-logger.ts +63 -35
- 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 +29 -13
- package/src/eth/eth-plugin.ts +137 -127
- package/src/eth/eth.ts +46 -32
- package/src/eth/generic-processor.ts +1 -1
- package/src/eth/index.ts +2 -2
- package/src/eth/provider.ts +193 -0
- 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/network.ts +5 -5
- 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 +6 -6
- 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/network.ts +12 -7
- package/src/sui/sui-object-processor-template.ts +25 -15
- package/src/sui/sui-object-processor.ts +50 -28
- package/src/sui/sui-plugin-part.ts +41 -34
- package/src/sui/sui-plugin.ts +49 -47
- package/src/sui/sui-processor.ts +38 -29
- package/src/sui/to-client-types.ts +75 -0
- 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 +126 -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 +170 -80
- package/src/testing/test-provider.ts +1 -1
- package/src/utils/price.ts +20 -13
|
@@ -1,31 +1,43 @@
|
|
|
1
1
|
import { StoreContext } from '../store/context.js'
|
|
2
2
|
import {
|
|
3
|
-
DBRequest,
|
|
4
|
-
DBRequest_DBFilter,
|
|
3
|
+
type DBRequest,
|
|
4
|
+
type DBRequest_DBFilter,
|
|
5
5
|
DBRequest_DBOperator,
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
type DBResponse,
|
|
7
|
+
DBResponseSchema,
|
|
8
|
+
type ProcessStreamResponseV3,
|
|
9
|
+
type RichStruct,
|
|
10
|
+
type RichValue,
|
|
11
|
+
RichValueSchema,
|
|
12
|
+
type RichValueList,
|
|
13
|
+
RichValueListSchema,
|
|
14
|
+
timestampNow
|
|
10
15
|
} from '@sentio/protos'
|
|
16
|
+
import { create } from '@bufbuild/protobuf'
|
|
11
17
|
import { GraphQLField, GraphQLSchema, parse, StringValueNode } from 'graphql/index.js'
|
|
12
18
|
import { DatabaseSchemaState } from '../core/database-schema.js'
|
|
13
19
|
import { buildSchema } from '../store/schema.js'
|
|
14
20
|
import { GraphQLList, GraphQLNonNull, GraphQLObjectType, GraphQLOutputType } from 'graphql'
|
|
15
|
-
import { PluginManager } from '@sentio/runtime'
|
|
21
|
+
import { type IStoreContext, PluginManager } from '@sentio/runtime'
|
|
16
22
|
import { BigDecimalConverter, BigIntConverter } from '../store/convert.js'
|
|
17
23
|
import { BigDecimal } from '@sentio/bigdecimal'
|
|
18
24
|
import { Store } from '../store/store.js'
|
|
25
|
+
import { Subject } from 'rxjs'
|
|
19
26
|
|
|
20
27
|
// Internal entity name used by MemoryCache - bypasses schema validation
|
|
21
28
|
const MEMORY_CACHE_ITEM_ENTITY = 'MemoryCacheItem'
|
|
22
29
|
|
|
30
|
+
type MemoryDatabaseContext = IStoreContext & {
|
|
31
|
+
subject: Subject<any>
|
|
32
|
+
result(dbResult: DBResponse, processId?: number): void
|
|
33
|
+
}
|
|
34
|
+
|
|
23
35
|
export class MemoryDatabase {
|
|
24
36
|
db = new Map<string, Record<string, any>>()
|
|
25
37
|
public lastDbRequest: DBRequest | undefined
|
|
26
38
|
_schema: GraphQLSchema
|
|
27
39
|
|
|
28
|
-
constructor(readonly dbContext:
|
|
40
|
+
constructor(readonly dbContext: MemoryDatabaseContext) {}
|
|
29
41
|
|
|
30
42
|
get schema() {
|
|
31
43
|
if (!this._schema) {
|
|
@@ -43,7 +55,9 @@ export class MemoryDatabase {
|
|
|
43
55
|
}
|
|
44
56
|
|
|
45
57
|
start() {
|
|
46
|
-
|
|
58
|
+
// The subject is typed as the `ProcessStreamResponseV3` init-shape, but at runtime it always carries a
|
|
59
|
+
// full response (the store context emits the complete oneof). Treat it as a full message and narrow inside.
|
|
60
|
+
this.dbContext.subject.subscribe((request) => this.processRequest(request as unknown as ProcessStreamResponseV3))
|
|
47
61
|
}
|
|
48
62
|
|
|
49
63
|
stop() {
|
|
@@ -111,20 +125,25 @@ export class MemoryDatabase {
|
|
|
111
125
|
if (elemDb) {
|
|
112
126
|
for (const elemID of Object.keys(elemDb)) {
|
|
113
127
|
const value = elemDb[elemID]
|
|
114
|
-
const deriveField = value.fields[derivedFrom]
|
|
128
|
+
const deriveField: RichValue | undefined = value.fields[derivedFrom]
|
|
115
129
|
let hasRelation = false
|
|
116
|
-
if (deriveField?.stringValue === id) {
|
|
130
|
+
if (deriveField?.value.case === 'stringValue' && deriveField.value.value === id) {
|
|
117
131
|
hasRelation = true
|
|
118
132
|
}
|
|
119
|
-
if (deriveField?.listValue) {
|
|
120
|
-
hasRelation = deriveField.
|
|
133
|
+
if (deriveField?.value.case === 'listValue') {
|
|
134
|
+
hasRelation = deriveField.value.value.values.some(
|
|
135
|
+
(v) => v.value.case === 'stringValue' && v.value.value === id
|
|
136
|
+
)
|
|
121
137
|
}
|
|
122
138
|
if (hasRelation) {
|
|
123
|
-
const arr = result.fields[field.name]
|
|
124
|
-
|
|
125
|
-
|
|
139
|
+
const arr: RichValue | undefined = result.fields[field.name]
|
|
140
|
+
const elem = create(RichValueSchema, { value: { case: 'stringValue', value: elemID } })
|
|
141
|
+
if (arr && arr.value.case === 'listValue') {
|
|
142
|
+
arr.value.value.values.push(elem)
|
|
126
143
|
} else {
|
|
127
|
-
result.fields[field.name] =
|
|
144
|
+
result.fields[field.name] = create(RichValueSchema, {
|
|
145
|
+
value: { case: 'listValue', value: { values: [elem] } }
|
|
146
|
+
})
|
|
128
147
|
}
|
|
129
148
|
}
|
|
130
149
|
}
|
|
@@ -137,8 +156,8 @@ export class MemoryDatabase {
|
|
|
137
156
|
return result
|
|
138
157
|
}
|
|
139
158
|
|
|
140
|
-
private processRequest(request:
|
|
141
|
-
const req = request.dbRequest
|
|
159
|
+
private processRequest(request: ProcessStreamResponseV3) {
|
|
160
|
+
const req = request.value.case === 'dbRequest' ? request.value.value : undefined
|
|
142
161
|
|
|
143
162
|
// Check if schema is required for this request
|
|
144
163
|
const requiresSchema = this.requestRequiresSchema(req)
|
|
@@ -149,63 +168,75 @@ export class MemoryDatabase {
|
|
|
149
168
|
|
|
150
169
|
this.lastDbRequest = req
|
|
151
170
|
if (req) {
|
|
152
|
-
if (req.upsert) {
|
|
153
|
-
const { entityData, entity } = req.
|
|
171
|
+
if (req.op.case === 'upsert') {
|
|
172
|
+
const { entityData, entity } = req.op.value
|
|
154
173
|
entityData.forEach((d, i) => {
|
|
155
|
-
const
|
|
174
|
+
const idField = d.fields['id']
|
|
175
|
+
const id = idField?.value.case === 'stringValue' ? idField.value.value : ''
|
|
156
176
|
const entityName = entity[i]
|
|
157
177
|
this.upsert(entityName, id, d)
|
|
158
178
|
})
|
|
159
179
|
|
|
160
|
-
this.
|
|
161
|
-
opId: req.opId
|
|
162
|
-
})
|
|
180
|
+
this.sendResult(request, create(DBResponseSchema, { opId: req.opId }))
|
|
163
181
|
}
|
|
164
|
-
if (req.delete) {
|
|
165
|
-
const { id, entity } = req.
|
|
182
|
+
if (req.op.case === 'delete') {
|
|
183
|
+
const { id, entity } = req.op.value
|
|
166
184
|
id.forEach((i, idx) => {
|
|
167
185
|
const entityName = entity[idx]
|
|
168
186
|
this.delete(entityName, i)
|
|
169
187
|
})
|
|
170
|
-
this.
|
|
171
|
-
opId: req.opId
|
|
172
|
-
})
|
|
188
|
+
this.sendResult(request, create(DBResponseSchema, { opId: req.opId }))
|
|
173
189
|
}
|
|
174
190
|
|
|
175
|
-
if (req.get) {
|
|
176
|
-
const { entity, id } = req.
|
|
191
|
+
if (req.op.case === 'get') {
|
|
192
|
+
const { entity, id } = req.op.value
|
|
177
193
|
const data = this.getById(entity, id)
|
|
178
|
-
this.
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
194
|
+
this.sendResult(
|
|
195
|
+
request,
|
|
196
|
+
create(DBResponseSchema, {
|
|
197
|
+
opId: req.opId,
|
|
198
|
+
value: {
|
|
199
|
+
case: 'entityList',
|
|
200
|
+
value: {
|
|
201
|
+
entities: data ? [toEntity(data)] : []
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
})
|
|
205
|
+
)
|
|
185
206
|
}
|
|
186
|
-
if (req.list) {
|
|
187
|
-
const { entity, cursor, filters } = req.
|
|
207
|
+
if (req.op.case === 'list') {
|
|
208
|
+
const { entity, cursor, filters } = req.op.value
|
|
188
209
|
const list = this.listEntities(entity, filters)
|
|
189
210
|
|
|
190
211
|
if (cursor) {
|
|
191
212
|
const idx = parseInt(cursor)
|
|
192
213
|
|
|
193
|
-
this.
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
214
|
+
this.sendResult(
|
|
215
|
+
request,
|
|
216
|
+
create(DBResponseSchema, {
|
|
217
|
+
opId: req.opId,
|
|
218
|
+
value: { case: 'entityList', value: { entities: list.slice(idx, idx + 1).map((d) => toEntity(d)) } },
|
|
219
|
+
nextCursor: idx + 1 < list.length ? `${idx + 1}` : undefined
|
|
220
|
+
})
|
|
221
|
+
)
|
|
198
222
|
} else {
|
|
199
|
-
this.
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
223
|
+
this.sendResult(
|
|
224
|
+
request,
|
|
225
|
+
create(DBResponseSchema, {
|
|
226
|
+
opId: req.opId,
|
|
227
|
+
value: { case: 'entityList', value: { entities: list.length ? [toEntity(list[0])] : [] } },
|
|
228
|
+
nextCursor: '1'
|
|
229
|
+
})
|
|
230
|
+
)
|
|
204
231
|
}
|
|
205
232
|
}
|
|
206
233
|
}
|
|
207
234
|
}
|
|
208
235
|
|
|
236
|
+
private sendResult(request: ProcessStreamResponseV3, response: DBResponse) {
|
|
237
|
+
this.dbContext.result(response, request.processId)
|
|
238
|
+
}
|
|
239
|
+
|
|
209
240
|
reset() {
|
|
210
241
|
this.db.clear()
|
|
211
242
|
}
|
|
@@ -215,19 +246,18 @@ export class MemoryDatabase {
|
|
|
215
246
|
if (!req) return false
|
|
216
247
|
|
|
217
248
|
// Check if all entities in the request are MemoryCacheItem
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
249
|
+
switch (req.op.case) {
|
|
250
|
+
case 'upsert':
|
|
251
|
+
return !req.op.value.entity.every((e) => e === MEMORY_CACHE_ITEM_ENTITY)
|
|
252
|
+
case 'delete':
|
|
253
|
+
return !req.op.value.entity.every((e) => e === MEMORY_CACHE_ITEM_ENTITY)
|
|
254
|
+
case 'get':
|
|
255
|
+
return req.op.value.entity !== MEMORY_CACHE_ITEM_ENTITY
|
|
256
|
+
case 'list':
|
|
257
|
+
return req.op.value.entity !== MEMORY_CACHE_ITEM_ENTITY
|
|
258
|
+
default:
|
|
259
|
+
return false
|
|
226
260
|
}
|
|
227
|
-
if (req.list) {
|
|
228
|
-
return req.list.entity !== MEMORY_CACHE_ITEM_ENTITY
|
|
229
|
-
}
|
|
230
|
-
return false
|
|
231
261
|
}
|
|
232
262
|
|
|
233
263
|
private listEntities(entity: string, filters?: DBRequest_DBFilter[]) {
|
|
@@ -268,37 +298,46 @@ function filter(entity: RichStruct, filter: DBRequest_DBFilter) {
|
|
|
268
298
|
case DBRequest_DBOperator.LE:
|
|
269
299
|
return lessThan(value, filter.value) || equal(value, filter.value)
|
|
270
300
|
case DBRequest_DBOperator.IN:
|
|
271
|
-
return filter.value?.values.some((v) => equal(value,
|
|
301
|
+
return filter.value?.values.some((v) => equal(value, singleList(v)))
|
|
272
302
|
case DBRequest_DBOperator.NOT_IN:
|
|
273
|
-
return !filter.value?.values.some((v) => equal(value,
|
|
303
|
+
return !filter.value?.values.some((v) => equal(value, singleList(v)))
|
|
274
304
|
case DBRequest_DBOperator.HAS_ALL:
|
|
275
|
-
return filter.value?.values.every((v) => equal(value,
|
|
305
|
+
return filter.value?.values.every((v) => equal(value, singleList(v)))
|
|
276
306
|
case DBRequest_DBOperator.HAS_ANY:
|
|
277
307
|
for (const a of filter.value?.values ?? []) {
|
|
278
|
-
|
|
308
|
+
const listValues = value.value.case === 'listValue' ? value.value.value.values : []
|
|
309
|
+
if (listValues.some((v) => equal(a, singleList(v)))) {
|
|
279
310
|
return true
|
|
280
311
|
}
|
|
281
312
|
}
|
|
282
313
|
return false
|
|
283
314
|
case DBRequest_DBOperator.LIKE:
|
|
284
|
-
return like(value
|
|
315
|
+
return like(richString(value), filter.value?.values[0] ? richString(filter.value.values[0]) : undefined)
|
|
285
316
|
default:
|
|
286
317
|
return false
|
|
287
318
|
}
|
|
288
319
|
}
|
|
289
320
|
|
|
321
|
+
function singleList(v: RichValue): RichValueList {
|
|
322
|
+
return create(RichValueListSchema, { values: [v] })
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
function richString(v?: RichValue): string | undefined {
|
|
326
|
+
return v?.value.case === 'stringValue' ? v.value.value : undefined
|
|
327
|
+
}
|
|
328
|
+
|
|
290
329
|
function getValue(entity: RichStruct, field: string) {
|
|
291
330
|
return entity.fields[field]
|
|
292
331
|
}
|
|
293
332
|
|
|
294
333
|
function equal(field: RichValue, value?: RichValueList): boolean {
|
|
295
|
-
if (field.
|
|
296
|
-
return field.
|
|
334
|
+
if (field.value.case === 'stringValue') {
|
|
335
|
+
return field.value.value === richString(value?.values[0])
|
|
297
336
|
}
|
|
298
|
-
if (field.listValue) {
|
|
299
|
-
return field.
|
|
337
|
+
if (field.value.case === 'listValue') {
|
|
338
|
+
return field.value.value.values.every((v, i) => {
|
|
300
339
|
const vv = value?.values[i]
|
|
301
|
-
return equal(v, vv ?
|
|
340
|
+
return equal(v, vv ? singleList(vv) : undefined)
|
|
302
341
|
})
|
|
303
342
|
}
|
|
304
343
|
const a = toNumber(field)
|
|
@@ -335,19 +374,21 @@ function lessThan(field: RichValue, value: RichValueList | undefined) {
|
|
|
335
374
|
}
|
|
336
375
|
|
|
337
376
|
function toNumber(value?: RichValue) {
|
|
338
|
-
if (value
|
|
339
|
-
return
|
|
340
|
-
}
|
|
341
|
-
if (value?.floatValue !== undefined) {
|
|
342
|
-
return value.floatValue
|
|
343
|
-
}
|
|
344
|
-
if (value?.bigintValue !== undefined) {
|
|
345
|
-
return BigIntConverter.to(value) as bigint
|
|
377
|
+
if (value === undefined) {
|
|
378
|
+
return undefined
|
|
346
379
|
}
|
|
347
|
-
|
|
348
|
-
|
|
380
|
+
switch (value.value.case) {
|
|
381
|
+
case 'intValue':
|
|
382
|
+
return value.value.value
|
|
383
|
+
case 'floatValue':
|
|
384
|
+
return value.value.value
|
|
385
|
+
case 'bigintValue':
|
|
386
|
+
return BigIntConverter.to(value) as bigint
|
|
387
|
+
case 'bigdecimalValue':
|
|
388
|
+
return BigDecimalConverter.to(value) as BigDecimal
|
|
389
|
+
default:
|
|
390
|
+
return undefined
|
|
349
391
|
}
|
|
350
|
-
return undefined
|
|
351
392
|
}
|
|
352
393
|
|
|
353
394
|
function toEntity(data: any) {
|
|
@@ -355,7 +396,7 @@ function toEntity(data: any) {
|
|
|
355
396
|
entity: data.entity,
|
|
356
397
|
genBlockChain: '',
|
|
357
398
|
genBlockNumber: 0n,
|
|
358
|
-
genBlockTime:
|
|
399
|
+
genBlockTime: timestampNow(),
|
|
359
400
|
data: { fields: data.fields }
|
|
360
401
|
}
|
|
361
402
|
}
|
|
@@ -1,26 +1,27 @@
|
|
|
1
|
-
import { MetricValue, ProcessResult } from '@sentio/protos'
|
|
1
|
+
import type { MetricValue, ProcessResult } from '@sentio/protos'
|
|
2
2
|
import { Numberish, BigDecimal } from '../core/index.js'
|
|
3
3
|
import { bytesToBigInt } from '../utils/conversion.js'
|
|
4
4
|
|
|
5
|
-
export function MetricValueToNumber(v:
|
|
5
|
+
export function MetricValueToNumber(v: MetricValue | undefined): Numberish | undefined {
|
|
6
6
|
if (v === undefined) {
|
|
7
7
|
return undefined
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
10
|
+
switch (v.value.case) {
|
|
11
|
+
case 'doubleValue':
|
|
12
|
+
return v.value.value
|
|
13
|
+
case 'bigInteger': {
|
|
14
|
+
let intValue = bytesToBigInt(v.value.value.data)
|
|
15
|
+
if (v.value.value.negative) {
|
|
16
|
+
intValue = -intValue
|
|
17
|
+
}
|
|
18
|
+
return intValue
|
|
17
19
|
}
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
20
|
+
case 'bigDecimal':
|
|
21
|
+
return new BigDecimal(v.value.value)
|
|
22
|
+
default:
|
|
23
|
+
return undefined
|
|
22
24
|
}
|
|
23
|
-
return undefined
|
|
24
25
|
}
|
|
25
26
|
|
|
26
27
|
export function firstCounterValue(result: ProcessResult | undefined, name: string): Numberish | undefined {
|
|
@@ -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
|
}
|