@sentio/sdk 4.0.0-rc.1 → 4.0.0-rc.3
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 +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 +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 +39 -26
- 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 +11 -3
- package/lib/testing/memory-database.d.ts.map +1 -1
- package/lib/testing/memory-database.js +84 -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 +1453 -16
- package/lib/testing/test-processor-server.d.ts.map +1 -1
- package/lib/testing/test-processor-server.js +108 -45
- 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 +29 -13
- package/src/eth/eth-plugin.ts +135 -118
- package/src/eth/eth.ts +46 -32
- 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 +126 -88
- 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 +169 -79
- 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,10 +55,9 @@ export class MemoryDatabase {
|
|
|
43
55
|
}
|
|
44
56
|
|
|
45
57
|
start() {
|
|
46
|
-
// The subject is typed `
|
|
47
|
-
// full response
|
|
48
|
-
|
|
49
|
-
this.dbContext.subject.subscribe((request) => this.processRequest(request as ProcessStreamResponse))
|
|
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))
|
|
50
61
|
}
|
|
51
62
|
|
|
52
63
|
stop() {
|
|
@@ -114,20 +125,25 @@ export class MemoryDatabase {
|
|
|
114
125
|
if (elemDb) {
|
|
115
126
|
for (const elemID of Object.keys(elemDb)) {
|
|
116
127
|
const value = elemDb[elemID]
|
|
117
|
-
const deriveField = value.fields[derivedFrom]
|
|
128
|
+
const deriveField: RichValue | undefined = value.fields[derivedFrom]
|
|
118
129
|
let hasRelation = false
|
|
119
|
-
if (deriveField?.stringValue === id) {
|
|
130
|
+
if (deriveField?.value.case === 'stringValue' && deriveField.value.value === id) {
|
|
120
131
|
hasRelation = true
|
|
121
132
|
}
|
|
122
|
-
if (deriveField?.listValue) {
|
|
123
|
-
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
|
+
)
|
|
124
137
|
}
|
|
125
138
|
if (hasRelation) {
|
|
126
|
-
const arr = result.fields[field.name]
|
|
127
|
-
|
|
128
|
-
|
|
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)
|
|
129
143
|
} else {
|
|
130
|
-
result.fields[field.name] =
|
|
144
|
+
result.fields[field.name] = create(RichValueSchema, {
|
|
145
|
+
value: { case: 'listValue', value: { values: [elem] } }
|
|
146
|
+
})
|
|
131
147
|
}
|
|
132
148
|
}
|
|
133
149
|
}
|
|
@@ -140,8 +156,8 @@ export class MemoryDatabase {
|
|
|
140
156
|
return result
|
|
141
157
|
}
|
|
142
158
|
|
|
143
|
-
private processRequest(request:
|
|
144
|
-
const req = request.dbRequest
|
|
159
|
+
private processRequest(request: ProcessStreamResponseV3) {
|
|
160
|
+
const req = request.value.case === 'dbRequest' ? request.value.value : undefined
|
|
145
161
|
|
|
146
162
|
// Check if schema is required for this request
|
|
147
163
|
const requiresSchema = this.requestRequiresSchema(req)
|
|
@@ -152,63 +168,75 @@ export class MemoryDatabase {
|
|
|
152
168
|
|
|
153
169
|
this.lastDbRequest = req
|
|
154
170
|
if (req) {
|
|
155
|
-
if (req.upsert) {
|
|
156
|
-
const { entityData, entity } = req.
|
|
171
|
+
if (req.op.case === 'upsert') {
|
|
172
|
+
const { entityData, entity } = req.op.value
|
|
157
173
|
entityData.forEach((d, i) => {
|
|
158
|
-
const
|
|
174
|
+
const idField = d.fields['id']
|
|
175
|
+
const id = idField?.value.case === 'stringValue' ? idField.value.value : ''
|
|
159
176
|
const entityName = entity[i]
|
|
160
177
|
this.upsert(entityName, id, d)
|
|
161
178
|
})
|
|
162
179
|
|
|
163
|
-
this.
|
|
164
|
-
opId: req.opId
|
|
165
|
-
})
|
|
180
|
+
this.sendResult(request, create(DBResponseSchema, { opId: req.opId }))
|
|
166
181
|
}
|
|
167
|
-
if (req.delete) {
|
|
168
|
-
const { id, entity } = req.
|
|
182
|
+
if (req.op.case === 'delete') {
|
|
183
|
+
const { id, entity } = req.op.value
|
|
169
184
|
id.forEach((i, idx) => {
|
|
170
185
|
const entityName = entity[idx]
|
|
171
186
|
this.delete(entityName, i)
|
|
172
187
|
})
|
|
173
|
-
this.
|
|
174
|
-
opId: req.opId
|
|
175
|
-
})
|
|
188
|
+
this.sendResult(request, create(DBResponseSchema, { opId: req.opId }))
|
|
176
189
|
}
|
|
177
190
|
|
|
178
|
-
if (req.get) {
|
|
179
|
-
const { entity, id } = req.
|
|
191
|
+
if (req.op.case === 'get') {
|
|
192
|
+
const { entity, id } = req.op.value
|
|
180
193
|
const data = this.getById(entity, id)
|
|
181
|
-
this.
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
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
|
+
)
|
|
188
206
|
}
|
|
189
|
-
if (req.list) {
|
|
190
|
-
const { entity, cursor, filters } = req.
|
|
207
|
+
if (req.op.case === 'list') {
|
|
208
|
+
const { entity, cursor, filters } = req.op.value
|
|
191
209
|
const list = this.listEntities(entity, filters)
|
|
192
210
|
|
|
193
211
|
if (cursor) {
|
|
194
212
|
const idx = parseInt(cursor)
|
|
195
213
|
|
|
196
|
-
this.
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
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
|
+
)
|
|
201
222
|
} else {
|
|
202
|
-
this.
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
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
|
+
)
|
|
207
231
|
}
|
|
208
232
|
}
|
|
209
233
|
}
|
|
210
234
|
}
|
|
211
235
|
|
|
236
|
+
private sendResult(request: ProcessStreamResponseV3, response: DBResponse) {
|
|
237
|
+
this.dbContext.result(response, request.processId)
|
|
238
|
+
}
|
|
239
|
+
|
|
212
240
|
reset() {
|
|
213
241
|
this.db.clear()
|
|
214
242
|
}
|
|
@@ -218,19 +246,18 @@ export class MemoryDatabase {
|
|
|
218
246
|
if (!req) return false
|
|
219
247
|
|
|
220
248
|
// Check if all entities in the request are MemoryCacheItem
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
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
|
|
229
260
|
}
|
|
230
|
-
if (req.list) {
|
|
231
|
-
return req.list.entity !== MEMORY_CACHE_ITEM_ENTITY
|
|
232
|
-
}
|
|
233
|
-
return false
|
|
234
261
|
}
|
|
235
262
|
|
|
236
263
|
private listEntities(entity: string, filters?: DBRequest_DBFilter[]) {
|
|
@@ -271,37 +298,46 @@ function filter(entity: RichStruct, filter: DBRequest_DBFilter) {
|
|
|
271
298
|
case DBRequest_DBOperator.LE:
|
|
272
299
|
return lessThan(value, filter.value) || equal(value, filter.value)
|
|
273
300
|
case DBRequest_DBOperator.IN:
|
|
274
|
-
return filter.value?.values.some((v) => equal(value,
|
|
301
|
+
return filter.value?.values.some((v) => equal(value, singleList(v)))
|
|
275
302
|
case DBRequest_DBOperator.NOT_IN:
|
|
276
|
-
return !filter.value?.values.some((v) => equal(value,
|
|
303
|
+
return !filter.value?.values.some((v) => equal(value, singleList(v)))
|
|
277
304
|
case DBRequest_DBOperator.HAS_ALL:
|
|
278
|
-
return filter.value?.values.every((v) => equal(value,
|
|
305
|
+
return filter.value?.values.every((v) => equal(value, singleList(v)))
|
|
279
306
|
case DBRequest_DBOperator.HAS_ANY:
|
|
280
307
|
for (const a of filter.value?.values ?? []) {
|
|
281
|
-
|
|
308
|
+
const listValues = value.value.case === 'listValue' ? value.value.value.values : []
|
|
309
|
+
if (listValues.some((v) => equal(a, singleList(v)))) {
|
|
282
310
|
return true
|
|
283
311
|
}
|
|
284
312
|
}
|
|
285
313
|
return false
|
|
286
314
|
case DBRequest_DBOperator.LIKE:
|
|
287
|
-
return like(value
|
|
315
|
+
return like(richString(value), filter.value?.values[0] ? richString(filter.value.values[0]) : undefined)
|
|
288
316
|
default:
|
|
289
317
|
return false
|
|
290
318
|
}
|
|
291
319
|
}
|
|
292
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
|
+
|
|
293
329
|
function getValue(entity: RichStruct, field: string) {
|
|
294
330
|
return entity.fields[field]
|
|
295
331
|
}
|
|
296
332
|
|
|
297
333
|
function equal(field: RichValue, value?: RichValueList): boolean {
|
|
298
|
-
if (field.
|
|
299
|
-
return field.
|
|
334
|
+
if (field.value.case === 'stringValue') {
|
|
335
|
+
return field.value.value === richString(value?.values[0])
|
|
300
336
|
}
|
|
301
|
-
if (field.listValue) {
|
|
302
|
-
return field.
|
|
337
|
+
if (field.value.case === 'listValue') {
|
|
338
|
+
return field.value.value.values.every((v, i) => {
|
|
303
339
|
const vv = value?.values[i]
|
|
304
|
-
return equal(v, vv ?
|
|
340
|
+
return equal(v, vv ? singleList(vv) : undefined)
|
|
305
341
|
})
|
|
306
342
|
}
|
|
307
343
|
const a = toNumber(field)
|
|
@@ -338,19 +374,21 @@ function lessThan(field: RichValue, value: RichValueList | undefined) {
|
|
|
338
374
|
}
|
|
339
375
|
|
|
340
376
|
function toNumber(value?: RichValue) {
|
|
341
|
-
if (value
|
|
342
|
-
return
|
|
343
|
-
}
|
|
344
|
-
if (value?.floatValue !== undefined) {
|
|
345
|
-
return value.floatValue
|
|
346
|
-
}
|
|
347
|
-
if (value?.bigintValue !== undefined) {
|
|
348
|
-
return BigIntConverter.to(value) as bigint
|
|
377
|
+
if (value === undefined) {
|
|
378
|
+
return undefined
|
|
349
379
|
}
|
|
350
|
-
|
|
351
|
-
|
|
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
|
|
352
391
|
}
|
|
353
|
-
return undefined
|
|
354
392
|
}
|
|
355
393
|
|
|
356
394
|
function toEntity(data: any) {
|
|
@@ -358,7 +396,7 @@ function toEntity(data: any) {
|
|
|
358
396
|
entity: data.entity,
|
|
359
397
|
genBlockChain: '',
|
|
360
398
|
genBlockNumber: 0n,
|
|
361
|
-
genBlockTime:
|
|
399
|
+
genBlockTime: timestampNow(),
|
|
362
400
|
data: { fields: data.fields }
|
|
363
401
|
}
|
|
364
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
|
}
|