@sentio/sdk 4.0.0-rc.1 → 4.0.0-rc.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/aptos/aptos-plugin.d.ts +1 -1
- package/lib/aptos/aptos-plugin.d.ts.map +1 -1
- package/lib/aptos/aptos-plugin.js +43 -42
- package/lib/aptos/aptos-plugin.js.map +1 -1
- package/lib/aptos/aptos-processor.d.ts +1 -1
- package/lib/aptos/aptos-processor.d.ts.map +1 -1
- package/lib/aptos/aptos-processor.js +25 -25
- package/lib/aptos/aptos-processor.js.map +1 -1
- package/lib/aptos/aptos-resource-processor-template.d.ts +1 -1
- package/lib/aptos/aptos-resource-processor-template.d.ts.map +1 -1
- package/lib/aptos/aptos-resource-processor-template.js +10 -5
- package/lib/aptos/aptos-resource-processor-template.js.map +1 -1
- package/lib/aptos/context.d.ts +1 -1
- package/lib/aptos/context.d.ts.map +1 -1
- package/lib/aptos/context.js +8 -6
- package/lib/aptos/context.js.map +1 -1
- package/lib/aptos/data.d.ts +4 -4
- package/lib/aptos/data.d.ts.map +1 -1
- package/lib/core/base-context.d.ts +3 -2
- package/lib/core/base-context.d.ts.map +1 -1
- package/lib/core/base-context.js +12 -11
- package/lib/core/base-context.js.map +1 -1
- package/lib/core/core-plugin.d.ts.map +1 -1
- package/lib/core/core-plugin.js +6 -4
- package/lib/core/core-plugin.js.map +1 -1
- package/lib/core/event-logger.d.ts +10 -2
- package/lib/core/event-logger.d.ts.map +1 -1
- package/lib/core/event-logger.js +42 -26
- package/lib/core/event-logger.js.map +1 -1
- package/lib/core/exporter.d.ts.map +1 -1
- package/lib/core/exporter.js +5 -3
- package/lib/core/exporter.js.map +1 -1
- package/lib/core/handler-options.d.ts +1 -1
- package/lib/core/handler-options.d.ts.map +1 -1
- package/lib/core/handler-register.d.ts +1 -1
- package/lib/core/handler-register.d.ts.map +1 -1
- package/lib/core/handler-register.js +2 -2
- package/lib/core/handler-register.js.map +1 -1
- package/lib/core/meter.d.ts +4 -3
- package/lib/core/meter.d.ts.map +1 -1
- package/lib/core/meter.js +5 -4
- package/lib/core/meter.js.map +1 -1
- package/lib/core/normalization.d.ts +1 -1
- package/lib/core/normalization.d.ts.map +1 -1
- package/lib/core/normalization.js +41 -31
- package/lib/core/normalization.js.map +1 -1
- package/lib/core/numberish.d.ts +1 -1
- package/lib/core/numberish.d.ts.map +1 -1
- package/lib/core/numberish.js +35 -30
- package/lib/core/numberish.js.map +1 -1
- package/lib/core/partition-handler-manager.d.ts +1 -1
- package/lib/core/partition-handler-manager.d.ts.map +1 -1
- package/lib/core/partition-handler-manager.js +10 -9
- package/lib/core/partition-handler-manager.js.map +1 -1
- package/lib/cosmos/context.d.ts.map +1 -1
- package/lib/cosmos/context.js +4 -2
- package/lib/cosmos/context.js.map +1 -1
- package/lib/cosmos/cosmos-plugin.d.ts.map +1 -1
- package/lib/cosmos/cosmos-plugin.js +11 -10
- package/lib/cosmos/cosmos-plugin.js.map +1 -1
- package/lib/cosmos/cosmos-processor.js.map +1 -1
- package/lib/eth/abi-decoder/decode-worker.js +2 -2
- package/lib/eth/abi-decoder/decode-worker.js.map +1 -1
- package/lib/eth/account-processor.d.ts +2 -2
- package/lib/eth/account-processor.d.ts.map +1 -1
- package/lib/eth/account-processor.js +10 -9
- package/lib/eth/account-processor.js.map +1 -1
- package/lib/eth/base-processor-template.d.ts +3 -3
- package/lib/eth/base-processor-template.d.ts.map +1 -1
- package/lib/eth/base-processor-template.js +12 -8
- package/lib/eth/base-processor-template.js.map +1 -1
- package/lib/eth/base-processor.d.ts +1 -1
- package/lib/eth/base-processor.d.ts.map +1 -1
- package/lib/eth/base-processor.js +53 -46
- package/lib/eth/base-processor.js.map +1 -1
- package/lib/eth/builtin/internal/eacaggregatorproxy-processor.d.ts.map +1 -1
- package/lib/eth/builtin/internal/eacaggregatorproxy-processor.js +48 -46
- package/lib/eth/builtin/internal/eacaggregatorproxy-processor.js.map +1 -1
- package/lib/eth/builtin/internal/erc1155-processor.d.ts.map +1 -1
- package/lib/eth/builtin/internal/erc1155-processor.js +18 -16
- package/lib/eth/builtin/internal/erc1155-processor.js.map +1 -1
- package/lib/eth/builtin/internal/erc20-processor.d.ts.map +1 -1
- package/lib/eth/builtin/internal/erc20-processor.js +38 -36
- package/lib/eth/builtin/internal/erc20-processor.js.map +1 -1
- package/lib/eth/builtin/internal/erc20bytes-processor.d.ts.map +1 -1
- package/lib/eth/builtin/internal/erc20bytes-processor.js +20 -18
- package/lib/eth/builtin/internal/erc20bytes-processor.js.map +1 -1
- package/lib/eth/builtin/internal/erc721-processor.d.ts.map +1 -1
- package/lib/eth/builtin/internal/erc721-processor.js +30 -28
- package/lib/eth/builtin/internal/erc721-processor.js.map +1 -1
- package/lib/eth/builtin/internal/weth9-processor.d.ts.map +1 -1
- package/lib/eth/builtin/internal/weth9-processor.js +24 -22
- package/lib/eth/builtin/internal/weth9-processor.js.map +1 -1
- package/lib/eth/codegen/file.d.ts.map +1 -1
- package/lib/eth/codegen/file.js +2 -1
- package/lib/eth/codegen/file.js.map +1 -1
- package/lib/eth/codegen/function-calls.js +1 -1
- package/lib/eth/context.d.ts +1 -1
- package/lib/eth/context.d.ts.map +1 -1
- package/lib/eth/context.js +12 -10
- package/lib/eth/context.js.map +1 -1
- package/lib/eth/eth-plugin.d.ts.map +1 -1
- package/lib/eth/eth-plugin.js +83 -75
- package/lib/eth/eth-plugin.js.map +1 -1
- package/lib/eth/eth.d.ts +6 -6
- package/lib/eth/eth.d.ts.map +1 -1
- package/lib/eth/eth.js +22 -14
- package/lib/eth/eth.js.map +1 -1
- package/lib/eth/index.d.ts +1 -1
- package/lib/eth/index.d.ts.map +1 -1
- package/lib/eth/index.js +0 -1
- package/lib/eth/index.js.map +1 -1
- package/lib/fuel/asset-processor.d.ts +2 -2
- package/lib/fuel/asset-processor.d.ts.map +1 -1
- package/lib/fuel/asset-processor.js +5 -3
- package/lib/fuel/asset-processor.js.map +1 -1
- package/lib/fuel/context.d.ts.map +1 -1
- package/lib/fuel/context.js +4 -2
- package/lib/fuel/context.js.map +1 -1
- package/lib/fuel/fuel-plugin.d.ts.map +1 -1
- package/lib/fuel/fuel-plugin.js +41 -53
- package/lib/fuel/fuel-plugin.js.map +1 -1
- package/lib/fuel/fuel-processor-template.d.ts.map +1 -1
- package/lib/fuel/fuel-processor-template.js +7 -5
- package/lib/fuel/fuel-processor-template.js.map +1 -1
- package/lib/fuel/fuel-processor.d.ts.map +1 -1
- package/lib/fuel/fuel-processor.js +30 -20
- package/lib/fuel/fuel-processor.js.map +1 -1
- package/lib/fuel/global-processor.d.ts.map +1 -1
- package/lib/fuel/global-processor.js +2 -1
- package/lib/fuel/global-processor.js.map +1 -1
- package/lib/fuel/types.d.ts +10 -4
- package/lib/fuel/types.d.ts.map +1 -1
- package/lib/fuel/types.js.map +1 -1
- package/lib/iota/context.d.ts +1 -1
- package/lib/iota/context.d.ts.map +1 -1
- package/lib/iota/context.js +8 -6
- package/lib/iota/context.js.map +1 -1
- package/lib/iota/iota-object-processor-template.d.ts +1 -1
- package/lib/iota/iota-object-processor-template.d.ts.map +1 -1
- package/lib/iota/iota-object-processor-template.js +17 -12
- package/lib/iota/iota-object-processor-template.js.map +1 -1
- package/lib/iota/iota-object-processor.d.ts +1 -1
- package/lib/iota/iota-object-processor.d.ts.map +1 -1
- package/lib/iota/iota-object-processor.js +23 -16
- package/lib/iota/iota-object-processor.js.map +1 -1
- package/lib/iota/iota-plugin-part.d.ts +1 -1
- package/lib/iota/iota-plugin-part.d.ts.map +1 -1
- package/lib/iota/iota-plugin-part.js +16 -15
- package/lib/iota/iota-plugin-part.js.map +1 -1
- package/lib/iota/iota-processor.d.ts +1 -1
- package/lib/iota/iota-processor.d.ts.map +1 -1
- package/lib/iota/iota-processor.js +18 -17
- package/lib/iota/iota-processor.js.map +1 -1
- package/lib/iota/network.js +2 -2
- package/lib/iota/network.js.map +1 -1
- package/lib/move/filter.d.ts +1 -1
- package/lib/move/filter.d.ts.map +1 -1
- package/lib/move/index.d.ts +1 -1
- package/lib/move/index.d.ts.map +1 -1
- package/lib/move/index.js +0 -1
- package/lib/move/index.js.map +1 -1
- package/lib/solana/builtin/types.d.ts +4 -4
- package/lib/solana/solana-context.d.ts.map +1 -1
- package/lib/solana/solana-context.js +4 -3
- package/lib/solana/solana-context.js.map +1 -1
- package/lib/solana/solana-plugin.d.ts.map +1 -1
- package/lib/solana/solana-plugin.js +19 -18
- package/lib/solana/solana-plugin.js.map +1 -1
- package/lib/solana/solana-processor.d.ts.map +1 -1
- package/lib/solana/solana-processor.js +8 -3
- package/lib/solana/solana-processor.js.map +1 -1
- package/lib/store/cache.d.ts.map +1 -1
- package/lib/store/cache.js +22 -17
- package/lib/store/cache.js.map +1 -1
- package/lib/store/convert.d.ts +1 -1
- package/lib/store/convert.d.ts.map +1 -1
- package/lib/store/convert.js +67 -104
- package/lib/store/convert.js.map +1 -1
- package/lib/store/decorators.d.ts +1 -1
- package/lib/store/decorators.d.ts.map +1 -1
- package/lib/store/decorators.js +3 -1
- package/lib/store/decorators.js.map +1 -1
- package/lib/store/store.d.ts.map +1 -1
- package/lib/store/store.js +24 -16
- package/lib/store/store.js.map +1 -1
- package/lib/store/types.js +24 -32
- package/lib/store/types.js.map +1 -1
- package/lib/store/util.d.ts +1 -1
- package/lib/store/util.d.ts.map +1 -1
- package/lib/store/util.js +13 -17
- package/lib/store/util.js.map +1 -1
- package/lib/sui/context.d.ts +1 -1
- package/lib/sui/context.d.ts.map +1 -1
- package/lib/sui/context.js +8 -6
- package/lib/sui/context.js.map +1 -1
- package/lib/sui/sui-object-processor-template.d.ts +1 -1
- package/lib/sui/sui-object-processor-template.d.ts.map +1 -1
- package/lib/sui/sui-object-processor-template.js +17 -12
- package/lib/sui/sui-object-processor-template.js.map +1 -1
- package/lib/sui/sui-object-processor.d.ts +1 -1
- package/lib/sui/sui-object-processor.d.ts.map +1 -1
- package/lib/sui/sui-object-processor.js +23 -16
- package/lib/sui/sui-object-processor.js.map +1 -1
- package/lib/sui/sui-plugin-part.d.ts +1 -1
- package/lib/sui/sui-plugin-part.d.ts.map +1 -1
- package/lib/sui/sui-plugin-part.js +16 -15
- package/lib/sui/sui-plugin-part.js.map +1 -1
- package/lib/sui/sui-plugin.d.ts +1 -1
- package/lib/sui/sui-plugin.d.ts.map +1 -1
- package/lib/sui/sui-plugin.js +35 -34
- package/lib/sui/sui-plugin.js.map +1 -1
- package/lib/sui/sui-processor.d.ts +1 -1
- package/lib/sui/sui-processor.d.ts.map +1 -1
- package/lib/sui/sui-processor.js +18 -17
- package/lib/sui/sui-processor.js.map +1 -1
- package/lib/testing/aptos-facet.d.ts.map +1 -1
- package/lib/testing/aptos-facet.js +18 -11
- package/lib/testing/aptos-facet.js.map +1 -1
- package/lib/testing/cosmos-facet.d.ts.map +1 -1
- package/lib/testing/cosmos-facet.js +10 -6
- package/lib/testing/cosmos-facet.js.map +1 -1
- package/lib/testing/eth-facet.d.ts +1 -1
- package/lib/testing/eth-facet.d.ts.map +1 -1
- package/lib/testing/eth-facet.js +34 -18
- package/lib/testing/eth-facet.js.map +1 -1
- package/lib/testing/fuel-facet.d.ts.map +1 -1
- package/lib/testing/fuel-facet.js +28 -18
- package/lib/testing/fuel-facet.js.map +1 -1
- package/lib/testing/iota-facet.d.ts.map +1 -1
- package/lib/testing/iota-facet.js +32 -20
- package/lib/testing/iota-facet.js.map +1 -1
- package/lib/testing/memory-database.d.ts +1 -1
- package/lib/testing/memory-database.d.ts.map +1 -1
- package/lib/testing/memory-database.js +81 -71
- package/lib/testing/memory-database.js.map +1 -1
- package/lib/testing/metric-utils.d.ts +2 -2
- package/lib/testing/metric-utils.d.ts.map +1 -1
- package/lib/testing/metric-utils.js +13 -12
- package/lib/testing/metric-utils.js.map +1 -1
- package/lib/testing/solana-facet.d.ts +3 -2
- package/lib/testing/solana-facet.d.ts.map +1 -1
- package/lib/testing/solana-facet.js +8 -5
- package/lib/testing/solana-facet.js.map +1 -1
- package/lib/testing/sui-facet.d.ts.map +1 -1
- package/lib/testing/sui-facet.js +30 -20
- package/lib/testing/sui-facet.js.map +1 -1
- package/lib/testing/test-processor-server.d.ts +19 -13
- package/lib/testing/test-processor-server.d.ts.map +1 -1
- package/lib/testing/test-processor-server.js +22 -20
- package/lib/testing/test-processor-server.js.map +1 -1
- package/lib/utils/price.d.ts +1 -1
- package/lib/utils/price.d.ts.map +1 -1
- package/lib/utils/price.js +19 -12
- package/lib/utils/price.js.map +1 -1
- package/package.json +5 -7
- package/src/aptos/aptos-plugin.ts +105 -91
- package/src/aptos/aptos-processor.ts +33 -25
- package/src/aptos/aptos-resource-processor-template.ts +15 -6
- package/src/aptos/context.ts +8 -7
- package/src/aptos/data.ts +4 -4
- package/src/core/base-context.ts +19 -12
- package/src/core/core-plugin.ts +10 -7
- package/src/core/event-logger.ts +63 -34
- package/src/core/exporter.ts +5 -4
- package/src/core/handler-options.ts +1 -1
- package/src/core/handler-register.ts +3 -3
- package/src/core/meter.ts +9 -7
- package/src/core/normalization.ts +53 -31
- package/src/core/numberish.ts +46 -30
- package/src/core/partition-handler-manager.ts +13 -11
- package/src/cosmos/context.ts +4 -3
- package/src/cosmos/cosmos-plugin.ts +19 -15
- package/src/cosmos/cosmos-processor.ts +2 -2
- package/src/eth/abi-decoder/decode-worker.ts +2 -2
- package/src/eth/account-processor.ts +21 -12
- package/src/eth/base-processor-template.ts +22 -10
- package/src/eth/base-processor.ts +66 -54
- package/src/eth/builtin/internal/eacaggregatorproxy-processor.ts +177 -116
- package/src/eth/builtin/internal/erc1155-processor.ts +73 -38
- package/src/eth/builtin/internal/erc20-processor.ts +152 -91
- package/src/eth/builtin/internal/erc20bytes-processor.ts +80 -46
- package/src/eth/builtin/internal/erc721-processor.ts +109 -65
- package/src/eth/builtin/internal/weth9-processor.ts +95 -56
- package/src/eth/codegen/file.ts +2 -1
- package/src/eth/codegen/function-calls.ts +1 -1
- package/src/eth/context.ts +18 -11
- package/src/eth/eth-plugin.ts +135 -118
- package/src/eth/eth.ts +29 -20
- package/src/eth/index.ts +1 -1
- package/src/fuel/asset-processor.ts +16 -8
- package/src/fuel/context.ts +4 -3
- package/src/fuel/fuel-plugin.ts +71 -73
- package/src/fuel/fuel-processor-template.ts +7 -6
- package/src/fuel/fuel-processor.ts +35 -23
- package/src/fuel/global-processor.ts +3 -3
- package/src/fuel/types.ts +10 -4
- package/src/iota/context.ts +8 -7
- package/src/iota/iota-object-processor-template.ts +25 -15
- package/src/iota/iota-object-processor.ts +33 -22
- package/src/iota/iota-plugin-part.ts +41 -34
- package/src/iota/iota-processor.ts +25 -17
- package/src/iota/network.ts +2 -2
- package/src/move/filter.ts +1 -1
- package/src/move/index.ts +1 -1
- package/src/solana/solana-context.ts +4 -3
- package/src/solana/solana-plugin.ts +27 -24
- package/src/solana/solana-processor.ts +14 -6
- package/src/store/cache.ts +22 -18
- package/src/store/convert.ts +68 -104
- package/src/store/decorators.ts +3 -2
- package/src/store/store.ts +30 -22
- package/src/store/types.ts +24 -33
- package/src/store/util.ts +13 -18
- package/src/sui/context.ts +8 -7
- package/src/sui/sui-object-processor-template.ts +25 -15
- package/src/sui/sui-object-processor.ts +33 -22
- package/src/sui/sui-plugin-part.ts +41 -34
- package/src/sui/sui-plugin.ts +49 -47
- package/src/sui/sui-processor.ts +25 -17
- package/src/testing/aptos-facet.ts +18 -11
- package/src/testing/cosmos-facet.ts +10 -6
- package/src/testing/eth-facet.ts +40 -18
- package/src/testing/fuel-facet.ts +28 -18
- package/src/testing/iota-facet.ts +32 -20
- package/src/testing/memory-database.ts +109 -85
- package/src/testing/metric-utils.ts +15 -14
- package/src/testing/solana-facet.ts +11 -6
- package/src/testing/sui-facet.ts +30 -20
- package/src/testing/test-processor-server.ts +64 -58
- package/src/utils/price.ts +20 -13
package/src/aptos/data.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Data_AptEvent, Data_AptCall, Data_AptResource } from '@sentio/protos'
|
|
1
|
+
import { type Data_AptEvent, type Data_AptCall, type Data_AptResource } from '@sentio/protos'
|
|
2
2
|
import { UserTransactionResponse, MoveResource } from '@aptos-labs/ts-sdk'
|
|
3
3
|
import { MoveCoder, decodeResourceChange, ResourceChange } from '@typemove/aptos'
|
|
4
4
|
|
|
@@ -18,7 +18,7 @@ type Data_AptResource_Ext = Data_AptResource & {
|
|
|
18
18
|
_decodedResources?: ResourceChange<any>[]
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
-
export class AptEvent
|
|
21
|
+
export class AptEvent {
|
|
22
22
|
constructor(readonly data: Data_AptEvent_Ext) {}
|
|
23
23
|
|
|
24
24
|
get rawEvent(): string {
|
|
@@ -57,7 +57,7 @@ export class AptEvent implements Data_AptEvent {
|
|
|
57
57
|
}
|
|
58
58
|
}
|
|
59
59
|
|
|
60
|
-
export class AptCall
|
|
60
|
+
export class AptCall {
|
|
61
61
|
constructor(readonly data: Data_AptCall_Ext) {}
|
|
62
62
|
|
|
63
63
|
get rawTransaction(): string {
|
|
@@ -88,7 +88,7 @@ export class AptCall implements Data_AptCall {
|
|
|
88
88
|
}
|
|
89
89
|
}
|
|
90
90
|
|
|
91
|
-
export class AptResource
|
|
91
|
+
export class AptResource {
|
|
92
92
|
constructor(readonly data: Data_AptResource_Ext) {}
|
|
93
93
|
|
|
94
94
|
get version(): bigint {
|
package/src/core/base-context.ts
CHANGED
|
@@ -1,10 +1,17 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
type ProcessResult,
|
|
3
|
+
ProcessResultSchema,
|
|
4
|
+
type RecordMetaData,
|
|
5
|
+
RecordMetaDataSchema,
|
|
6
|
+
type TemplateInstance
|
|
7
|
+
} from '@sentio/protos'
|
|
8
|
+
import { create, type MessageInitShape } from '@bufbuild/protobuf'
|
|
2
9
|
import { EventLoggerBinding } from './event-logger.js'
|
|
3
10
|
import { Meter, Labels } from './meter.js'
|
|
4
11
|
import { ChainId } from '@sentio/chain'
|
|
5
12
|
import { mergeProcessResultsInPlace, PluginManager } from '@sentio/runtime'
|
|
6
13
|
import { Required } from 'utility-types'
|
|
7
|
-
import {
|
|
14
|
+
import { ConnectError, Code } from '@connectrpc/connect'
|
|
8
15
|
import { Store } from '../store/store.js'
|
|
9
16
|
import { MemoryCache } from '../store/cache.js'
|
|
10
17
|
|
|
@@ -16,7 +23,7 @@ export abstract class BaseContext {
|
|
|
16
23
|
baseLabels: Labels
|
|
17
24
|
private active: boolean
|
|
18
25
|
|
|
19
|
-
private _res: Required<ProcessResult, 'states'> = {
|
|
26
|
+
private _res: Required<ProcessResult, 'states'> = create(ProcessResultSchema, {
|
|
20
27
|
counters: [],
|
|
21
28
|
events: [],
|
|
22
29
|
exports: [],
|
|
@@ -25,13 +32,13 @@ export abstract class BaseContext {
|
|
|
25
32
|
configUpdated: false
|
|
26
33
|
},
|
|
27
34
|
timeseriesResult: []
|
|
28
|
-
}
|
|
35
|
+
}) as Required<ProcessResult, 'states'>
|
|
29
36
|
|
|
30
|
-
public update(res:
|
|
37
|
+
public update(res: MessageInitShape<typeof ProcessResultSchema>) {
|
|
31
38
|
if (this.active) {
|
|
32
|
-
mergeProcessResultsInPlace(this._res, [
|
|
39
|
+
mergeProcessResultsInPlace(this._res, [create(ProcessResultSchema, res)])
|
|
33
40
|
} else {
|
|
34
|
-
throw new
|
|
41
|
+
throw new ConnectError('context not active, possible async function invoke without await', Code.Internal)
|
|
35
42
|
}
|
|
36
43
|
}
|
|
37
44
|
|
|
@@ -48,7 +55,7 @@ export abstract class BaseContext {
|
|
|
48
55
|
this.active = false
|
|
49
56
|
return this._res
|
|
50
57
|
} else {
|
|
51
|
-
throw new
|
|
58
|
+
throw new ConnectError("Can't get result from same context twice", Code.Internal)
|
|
52
59
|
}
|
|
53
60
|
}
|
|
54
61
|
|
|
@@ -58,19 +65,19 @@ export abstract class BaseContext {
|
|
|
58
65
|
if (Object.keys(labels).length === 0) {
|
|
59
66
|
let metadata = this.metadataCache.get(name)
|
|
60
67
|
if (!metadata) {
|
|
61
|
-
metadata = {
|
|
68
|
+
metadata = create(RecordMetaDataSchema, {
|
|
62
69
|
...this.baseLabels,
|
|
63
70
|
...this.getMetaDataInternal(name, labels)
|
|
64
|
-
}
|
|
71
|
+
})
|
|
65
72
|
this.metadataCache.set(name, metadata)
|
|
66
73
|
}
|
|
67
74
|
return metadata
|
|
68
75
|
}
|
|
69
76
|
|
|
70
|
-
return {
|
|
77
|
+
return create(RecordMetaDataSchema, {
|
|
71
78
|
...this.baseLabels,
|
|
72
79
|
...this.getMetaDataInternal(name, labels)
|
|
73
|
-
}
|
|
80
|
+
})
|
|
74
81
|
}
|
|
75
82
|
|
|
76
83
|
protected abstract getMetaDataInternal(name: string, labels: Labels): RecordMetaData
|
package/src/core/core-plugin.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { GLOBAL_CONFIG, Plugin, PluginManager } from '@sentio/runtime'
|
|
2
|
-
import { InitResponse, ProcessConfigResponse } from '@sentio/protos'
|
|
2
|
+
import { DataBaseSchemaSchema, ExportConfigSchema, InitResponse, ProcessConfigResponse } from '@sentio/protos'
|
|
3
|
+
import { create } from '@bufbuild/protobuf'
|
|
3
4
|
|
|
4
5
|
import { MetricState } from './meter.js'
|
|
5
6
|
import { ExporterState } from './exporter.js'
|
|
@@ -30,10 +31,12 @@ export class CorePlugin extends Plugin {
|
|
|
30
31
|
}
|
|
31
32
|
|
|
32
33
|
for (const exporter of ExporterState.INSTANCE.getValues()) {
|
|
33
|
-
config.exportConfigs.push(
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
34
|
+
config.exportConfigs.push(
|
|
35
|
+
create(ExportConfigSchema, {
|
|
36
|
+
name: exporter.name,
|
|
37
|
+
channel: exporter.channel
|
|
38
|
+
})
|
|
39
|
+
)
|
|
37
40
|
}
|
|
38
41
|
|
|
39
42
|
const schemas = DatabaseSchemaState.INSTANCE.getValues()
|
|
@@ -50,9 +53,9 @@ type MemoryCacheItem @cache(sizeMB: ${GLOBAL_CONFIG.cache.size || 100}) {
|
|
|
50
53
|
}
|
|
51
54
|
|
|
52
55
|
if (mergedSources.trim().length > 0) {
|
|
53
|
-
config.dbSchema = {
|
|
56
|
+
config.dbSchema = create(DataBaseSchemaSchema, {
|
|
54
57
|
gqlSchema: mergedSources
|
|
55
|
-
}
|
|
58
|
+
})
|
|
56
59
|
}
|
|
57
60
|
}
|
|
58
61
|
}
|
package/src/core/event-logger.ts
CHANGED
|
@@ -1,16 +1,24 @@
|
|
|
1
1
|
import { BaseContext } from './base-context.js'
|
|
2
2
|
import {
|
|
3
|
-
CoinID,
|
|
4
|
-
|
|
3
|
+
type CoinID,
|
|
4
|
+
CoinIDSchema,
|
|
5
|
+
CoinID_AddressIdentifierSchema,
|
|
6
|
+
type EventLogConfig,
|
|
7
|
+
EventLogConfigSchema,
|
|
5
8
|
EventLogConfig_BasicFieldType,
|
|
6
|
-
EventLogConfig_Field,
|
|
7
|
-
|
|
8
|
-
|
|
9
|
+
type EventLogConfig_Field,
|
|
10
|
+
EventLogConfig_FieldSchema,
|
|
11
|
+
EventLogConfig_StructFieldTypeSchema,
|
|
12
|
+
type EventTrackingResult,
|
|
13
|
+
EventTrackingResultSchema,
|
|
9
14
|
LogLevel,
|
|
10
|
-
RichStruct,
|
|
11
|
-
|
|
15
|
+
type RichStruct,
|
|
16
|
+
RichStructSchema,
|
|
17
|
+
type TimeseriesResult,
|
|
18
|
+
TimeseriesResultSchema,
|
|
12
19
|
TimeseriesResult_TimeseriesType
|
|
13
20
|
} from '@sentio/protos'
|
|
21
|
+
import { create } from '@bufbuild/protobuf'
|
|
14
22
|
import { normalizeAttribute, normalizeLabels, normalizeToRichStruct } from './normalization.js'
|
|
15
23
|
import { MapStateStorage, processMetrics } from '@sentio/runtime'
|
|
16
24
|
import { BN } from 'fuels'
|
|
@@ -53,7 +61,10 @@ export class EventLoggerBinding {
|
|
|
53
61
|
export type BasicFieldType = EventLogConfig_BasicFieldType
|
|
54
62
|
export const BasicFieldType = EventLogConfig_BasicFieldType
|
|
55
63
|
|
|
56
|
-
|
|
64
|
+
// User-facing coin descriptor (plain shape, matching the legacy CoinID surface).
|
|
65
|
+
export type CoinFieldType = { symbol: string } | { address: { address: string; chain: string } }
|
|
66
|
+
|
|
67
|
+
export type FieldType = CoinFieldType | BasicFieldType | Fields
|
|
57
68
|
|
|
58
69
|
export type Fields = { [key: string]: FieldType }
|
|
59
70
|
|
|
@@ -61,30 +72,48 @@ export interface EventLogOptions {
|
|
|
61
72
|
fields: Fields
|
|
62
73
|
}
|
|
63
74
|
|
|
75
|
+
function toCoinIDField(value: CoinFieldType): CoinID {
|
|
76
|
+
if ('symbol' in value && value.symbol) {
|
|
77
|
+
return create(CoinIDSchema, { id: { case: 'symbol', value: value.symbol } })
|
|
78
|
+
}
|
|
79
|
+
const address = (value as { address: { address: string; chain: string } }).address
|
|
80
|
+
return create(CoinIDSchema, {
|
|
81
|
+
id: {
|
|
82
|
+
case: 'address',
|
|
83
|
+
value: create(CoinID_AddressIdentifierSchema, {
|
|
84
|
+
address: address.address,
|
|
85
|
+
chain: address.chain
|
|
86
|
+
})
|
|
87
|
+
}
|
|
88
|
+
})
|
|
89
|
+
}
|
|
90
|
+
|
|
64
91
|
export function fieldsToProtos(fields: Fields): EventLogConfig_Field[] {
|
|
65
92
|
const fieldsProto: EventLogConfig_Field[] = []
|
|
66
93
|
for (const [key, value] of Object.entries(fields)) {
|
|
67
|
-
let
|
|
68
|
-
let coinType: CoinID | undefined
|
|
69
|
-
let structType: EventLogConfig_StructFieldType | undefined
|
|
94
|
+
let type: EventLogConfig_Field['type']
|
|
70
95
|
|
|
71
96
|
if (typeof value === 'number') {
|
|
72
|
-
|
|
97
|
+
type = { case: 'basicType', value }
|
|
73
98
|
} else {
|
|
74
|
-
|
|
75
|
-
|
|
99
|
+
const coin = value as CoinFieldType
|
|
100
|
+
if (('address' in coin && coin.address) || ('symbol' in coin && coin.symbol)) {
|
|
101
|
+
type = { case: 'coinType', value: toCoinIDField(coin) }
|
|
76
102
|
} else {
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
103
|
+
type = {
|
|
104
|
+
case: 'structType',
|
|
105
|
+
value: create(EventLogConfig_StructFieldTypeSchema, {
|
|
106
|
+
fields: fieldsToProtos(value as Fields)
|
|
107
|
+
})
|
|
108
|
+
}
|
|
80
109
|
}
|
|
81
110
|
}
|
|
82
|
-
fieldsProto.push(
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
111
|
+
fieldsProto.push(
|
|
112
|
+
create(EventLogConfig_FieldSchema, {
|
|
113
|
+
name: key,
|
|
114
|
+
type
|
|
115
|
+
})
|
|
116
|
+
)
|
|
88
117
|
}
|
|
89
118
|
return fieldsProto
|
|
90
119
|
}
|
|
@@ -100,10 +129,10 @@ export class EventLogger {
|
|
|
100
129
|
|
|
101
130
|
static register(eventName: string, options?: EventLogOptions): EventLogger {
|
|
102
131
|
checkEventName(eventName)
|
|
103
|
-
let config =
|
|
132
|
+
let config = create(EventLogConfigSchema)
|
|
104
133
|
|
|
105
134
|
if (options?.fields) {
|
|
106
|
-
config =
|
|
135
|
+
config = create(EventLogConfigSchema, {
|
|
107
136
|
name: eventName,
|
|
108
137
|
fields: fieldsToProtos(options.fields)
|
|
109
138
|
})
|
|
@@ -128,24 +157,24 @@ function checkEventName(eventName: string) {
|
|
|
128
157
|
function emit<T>(ctx: BaseContext, eventName: string, event: Event<T>) {
|
|
129
158
|
const { distinctId, severity, message, ...payload } = event
|
|
130
159
|
|
|
131
|
-
const data: RichStruct = {
|
|
160
|
+
const data: RichStruct = create(RichStructSchema, {
|
|
132
161
|
fields: {
|
|
133
162
|
severity: {
|
|
134
|
-
stringValue: (severity || LogLevel.INFO).toString()
|
|
163
|
+
value: { case: 'stringValue', value: (severity || LogLevel.INFO).toString() }
|
|
135
164
|
},
|
|
136
165
|
message: {
|
|
137
|
-
stringValue: message || ''
|
|
166
|
+
value: { case: 'stringValue', value: message || '' }
|
|
138
167
|
},
|
|
139
168
|
// don't rename to distinctEntityId in new events.
|
|
140
169
|
distinctId: {
|
|
141
|
-
stringValue: distinctId || ''
|
|
170
|
+
value: { case: 'stringValue', value: distinctId || '' }
|
|
142
171
|
},
|
|
143
172
|
...normalizeToRichStruct(ctx.baseLabels, payload).fields
|
|
144
173
|
}
|
|
145
|
-
}
|
|
174
|
+
})
|
|
146
175
|
|
|
147
176
|
// legacy v2 events, deprecating
|
|
148
|
-
const eventRes: EventTrackingResult = {
|
|
177
|
+
const eventRes: EventTrackingResult = create(EventTrackingResultSchema, {
|
|
149
178
|
metadata: ctx.getMetaData(eventName, {}),
|
|
150
179
|
severity: severity || LogLevel.INFO,
|
|
151
180
|
message: message || '',
|
|
@@ -157,14 +186,14 @@ function emit<T>(ctx: BaseContext, eventName: string, event: Event<T>) {
|
|
|
157
186
|
runtimeInfo: undefined,
|
|
158
187
|
noMetric: true,
|
|
159
188
|
attributes2: normalizeToRichStruct(ctx.baseLabels, payload)
|
|
160
|
-
}
|
|
189
|
+
})
|
|
161
190
|
|
|
162
|
-
const res: TimeseriesResult = {
|
|
191
|
+
const res: TimeseriesResult = create(TimeseriesResultSchema, {
|
|
163
192
|
metadata: ctx.getMetaData(eventName, {}),
|
|
164
193
|
type: TimeseriesResult_TimeseriesType.EVENT,
|
|
165
194
|
data,
|
|
166
195
|
runtimeInfo: undefined
|
|
167
|
-
}
|
|
196
|
+
})
|
|
168
197
|
|
|
169
198
|
processMetrics.process_eventemit_count.add(1)
|
|
170
199
|
ctx.update({ timeseriesResult: [res], events: [eventRes] })
|
package/src/core/exporter.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { BaseContext } from './base-context.js'
|
|
2
|
-
import { ExportResult } from '@sentio/protos'
|
|
2
|
+
import { ExportResult, ExportResultSchema } from '@sentio/protos'
|
|
3
3
|
import { NamedResultDescriptor } from './metadata.js'
|
|
4
4
|
import { MapStateStorage } from '@sentio/runtime'
|
|
5
|
+
import { create } from '@bufbuild/protobuf'
|
|
5
6
|
|
|
6
7
|
export type Export = Record<string, any>
|
|
7
8
|
|
|
@@ -22,11 +23,11 @@ export class Exporter extends NamedResultDescriptor {
|
|
|
22
23
|
}
|
|
23
24
|
|
|
24
25
|
emit(ctx: BaseContext, data: Export) {
|
|
25
|
-
const res: ExportResult = {
|
|
26
|
+
const res: ExportResult = create(ExportResultSchema, {
|
|
26
27
|
metadata: ctx.getMetaData(this.name, {}),
|
|
27
28
|
payload: JSON.stringify(data),
|
|
28
|
-
runtimeInfo: undefined
|
|
29
|
-
}
|
|
29
|
+
runtimeInfo: undefined
|
|
30
|
+
})
|
|
30
31
|
ctx.update({ exports: [res] })
|
|
31
32
|
}
|
|
32
33
|
}
|
|
@@ -9,7 +9,7 @@ export type PartitionHandler<D> = (data: D) => string | Promise<string>
|
|
|
9
9
|
* @template F The fetch configuration type (e.g., EthFetchConfig, MoveFetchConfig)
|
|
10
10
|
* @template D The data type that will be processed (e.g., Event, Transaction, Block)
|
|
11
11
|
*/
|
|
12
|
-
export type HandlerOptions<F, D> = Partial<F> & {
|
|
12
|
+
export type HandlerOptions<F, D> = Omit<Partial<F>, '$typeName' | '$unknown'> & {
|
|
13
13
|
/**
|
|
14
14
|
* Optional partition key for data partitioning.
|
|
15
15
|
* Can be a static string or a function that computes the key from the data.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ConnectError, Code } from '@connectrpc/connect'
|
|
2
2
|
import { ChainId } from '@sentio/chain'
|
|
3
|
-
import { ProcessResult } from '@sentio/protos'
|
|
3
|
+
import { type ProcessResult } from '@sentio/protos'
|
|
4
4
|
|
|
5
5
|
export type HandlerFunction = (...args: any[]) => Promise<ProcessResult>
|
|
6
6
|
|
|
@@ -37,7 +37,7 @@ export class HandlerRegister {
|
|
|
37
37
|
getHandlerById(chainId: ChainId | string, id: number): HandlerFunction {
|
|
38
38
|
const entries = this.handlerByChain.get(chainId)
|
|
39
39
|
if (!entries || id < 0 || id >= entries.length) {
|
|
40
|
-
throw new
|
|
40
|
+
throw new ConnectError(`Handler with ID ${id} not found.`, Code.Internal)
|
|
41
41
|
}
|
|
42
42
|
return entries[id].handler
|
|
43
43
|
}
|
package/src/core/meter.ts
CHANGED
|
@@ -2,12 +2,14 @@ import { BaseContext } from './base-context.js'
|
|
|
2
2
|
import { Numberish, toMetricValue, toTimeSeriesData } from './numberish.js'
|
|
3
3
|
import { NamedResultDescriptor } from './metadata.js'
|
|
4
4
|
import {
|
|
5
|
-
|
|
5
|
+
AggregationConfigSchema,
|
|
6
6
|
AggregationType,
|
|
7
|
-
MetricConfig,
|
|
7
|
+
type MetricConfig,
|
|
8
|
+
MetricConfigSchema,
|
|
8
9
|
MetricType,
|
|
9
10
|
TimeseriesResult_TimeseriesType
|
|
10
11
|
} from '@sentio/protos'
|
|
12
|
+
import { create, type MessageInitShape } from '@bufbuild/protobuf'
|
|
11
13
|
import { MapStateStorage, processMetrics } from '@sentio/runtime'
|
|
12
14
|
|
|
13
15
|
export type Labels = { [key: string]: string }
|
|
@@ -17,7 +19,7 @@ export class MetricOptions {
|
|
|
17
19
|
description?: string
|
|
18
20
|
sparse?: boolean
|
|
19
21
|
// persistentBetweenVersion?: boolean
|
|
20
|
-
aggregationConfig?:
|
|
22
|
+
aggregationConfig?: MessageInitShape<typeof AggregationConfigSchema>
|
|
21
23
|
}
|
|
22
24
|
|
|
23
25
|
export class CounterOptions {
|
|
@@ -37,9 +39,9 @@ export class CounterOptions {
|
|
|
37
39
|
export class Metric extends NamedResultDescriptor {
|
|
38
40
|
config: MetricConfig
|
|
39
41
|
|
|
40
|
-
constructor(type: MetricType, name: string, option?:
|
|
42
|
+
constructor(type: MetricType, name: string, option?: MessageInitShape<typeof MetricConfigSchema>) {
|
|
41
43
|
super(name)
|
|
42
|
-
this.config =
|
|
44
|
+
this.config = create(MetricConfigSchema, { ...option, name: this.name, type })
|
|
43
45
|
const aggregationConfig = this.config.aggregationConfig
|
|
44
46
|
if (aggregationConfig && aggregationConfig.intervalInMinutes.length) {
|
|
45
47
|
if (aggregationConfig.intervalInMinutes.length > 1) {
|
|
@@ -90,7 +92,7 @@ export class Counter extends Metric {
|
|
|
90
92
|
super(
|
|
91
93
|
MetricType.COUNTER,
|
|
92
94
|
name,
|
|
93
|
-
|
|
95
|
+
create(MetricConfigSchema, {
|
|
94
96
|
...option,
|
|
95
97
|
aggregationConfig: {
|
|
96
98
|
intervalInMinutes: option?.resolutionConfig ? [option?.resolutionConfig?.intervalInMinutes] : []
|
|
@@ -162,7 +164,7 @@ export class Gauge extends Metric {
|
|
|
162
164
|
}
|
|
163
165
|
|
|
164
166
|
protected constructor(name: string, option?: MetricOptions) {
|
|
165
|
-
super(MetricType.GAUGE, name,
|
|
167
|
+
super(MetricType.GAUGE, name, create(MetricConfigSchema, { ...option }))
|
|
166
168
|
}
|
|
167
169
|
|
|
168
170
|
record(ctx: BaseContext, value: Numberish, labels: Labels = {}) {
|
|
@@ -1,7 +1,20 @@
|
|
|
1
1
|
import { Labels } from './meter.js'
|
|
2
2
|
import { BigDecimal } from './big-decimal.js'
|
|
3
3
|
import { BN } from 'fuels'
|
|
4
|
-
import {
|
|
4
|
+
import {
|
|
5
|
+
type CoinID,
|
|
6
|
+
CoinIDSchema,
|
|
7
|
+
CoinID_AddressIdentifierSchema,
|
|
8
|
+
type RichStruct,
|
|
9
|
+
RichStructSchema,
|
|
10
|
+
type RichValue,
|
|
11
|
+
RichValueSchema,
|
|
12
|
+
RichValue_NullValue,
|
|
13
|
+
type TokenAmount,
|
|
14
|
+
TokenAmountSchema,
|
|
15
|
+
timestampFromDate
|
|
16
|
+
} from '@sentio/protos'
|
|
17
|
+
import { create } from '@bufbuild/protobuf'
|
|
5
18
|
import { toBigInteger, toBigDecimal } from './numberish.js'
|
|
6
19
|
|
|
7
20
|
export const SENTIO_BIGINT_STRING_SUFFIX = ':sto_bi'
|
|
@@ -107,73 +120,78 @@ export function normalizeAttribute(record: Record<string, any>): any {
|
|
|
107
120
|
|
|
108
121
|
function normalizeToRichValue(value: any): RichValue {
|
|
109
122
|
if (value == null) {
|
|
110
|
-
return { nullValue: RichValue_NullValue.NULL_VALUE }
|
|
123
|
+
return create(RichValueSchema, { value: { case: 'nullValue', value: RichValue_NullValue.NULL_VALUE } })
|
|
111
124
|
}
|
|
112
125
|
switch (typeof value) {
|
|
113
126
|
case 'string':
|
|
114
|
-
return {
|
|
127
|
+
return create(RichValueSchema, { value: { case: 'stringValue', value } })
|
|
115
128
|
case 'bigint':
|
|
116
129
|
const v = BigInt(value)
|
|
117
|
-
return { bigintValue: toBigInteger(v) }
|
|
130
|
+
return create(RichValueSchema, { value: { case: 'bigintValue', value: toBigInteger(v) } })
|
|
118
131
|
case 'number':
|
|
119
132
|
if (isNaN(value) || !isFinite(value)) {
|
|
120
133
|
throw new Error("can't submit NaN or Infinity value")
|
|
121
134
|
}
|
|
122
|
-
return
|
|
135
|
+
return create(RichValueSchema, {
|
|
136
|
+
value: { case: 'bigdecimalValue', value: toBigDecimal(new BigDecimal(value)) }
|
|
137
|
+
})
|
|
123
138
|
case 'function':
|
|
124
|
-
return { nullValue: RichValue_NullValue.
|
|
139
|
+
return create(RichValueSchema, { value: { case: 'nullValue', value: RichValue_NullValue.NULL_VALUE } })
|
|
125
140
|
case 'symbol':
|
|
126
|
-
return { stringValue: String(value) }
|
|
141
|
+
return create(RichValueSchema, { value: { case: 'stringValue', value: String(value) } })
|
|
127
142
|
case 'boolean':
|
|
128
|
-
return {
|
|
143
|
+
return create(RichValueSchema, { value: { case: 'boolValue', value } })
|
|
129
144
|
default:
|
|
130
145
|
if (value instanceof Uint8Array) {
|
|
131
|
-
return {
|
|
146
|
+
return create(RichValueSchema, { value: { case: 'bytesValue', value } })
|
|
132
147
|
}
|
|
133
148
|
if (value instanceof Date) {
|
|
134
|
-
return { timestampValue: value }
|
|
149
|
+
return create(RichValueSchema, { value: { case: 'timestampValue', value: timestampFromDate(value) } })
|
|
135
150
|
}
|
|
136
151
|
if (value instanceof BigDecimal) {
|
|
137
|
-
return { bigdecimalValue: toBigDecimal(value) }
|
|
152
|
+
return create(RichValueSchema, { value: { case: 'bigdecimalValue', value: toBigDecimal(value) } })
|
|
138
153
|
}
|
|
139
154
|
if (BN.isBN(value)) {
|
|
140
155
|
const value1 = new BigDecimal(value.toString())
|
|
141
156
|
if (value1.isNaN() || !value1.isFinite()) {
|
|
142
157
|
throw new Error("can't submit NaN or Infinity value")
|
|
143
158
|
}
|
|
144
|
-
return { bigdecimalValue: toBigDecimal(value1) }
|
|
159
|
+
return create(RichValueSchema, { value: { case: 'bigdecimalValue', value: toBigDecimal(value1) } })
|
|
145
160
|
}
|
|
146
161
|
if (Array.isArray(value)) {
|
|
147
|
-
return {
|
|
148
|
-
|
|
149
|
-
|
|
162
|
+
return create(RichValueSchema, {
|
|
163
|
+
value: {
|
|
164
|
+
case: 'listValue',
|
|
165
|
+
value: {
|
|
166
|
+
values: value.map((v) => normalizeToRichValue(v))
|
|
167
|
+
}
|
|
150
168
|
}
|
|
151
|
-
}
|
|
169
|
+
})
|
|
152
170
|
}
|
|
153
171
|
if (value instanceof Promise) {
|
|
154
172
|
console.error('Cannot submit promise')
|
|
155
|
-
return { nullValue: RichValue_NullValue.
|
|
173
|
+
return create(RichValueSchema, { value: { case: 'nullValue', value: RichValue_NullValue.NULL_VALUE } })
|
|
156
174
|
}
|
|
157
175
|
if (typeof value === 'object') {
|
|
158
176
|
const tokenAmount = toTokenAmount(value)
|
|
159
177
|
if (tokenAmount) {
|
|
160
|
-
return { tokenValue: tokenAmount }
|
|
178
|
+
return create(RichValueSchema, { value: { case: 'tokenValue', value: tokenAmount } })
|
|
161
179
|
}
|
|
162
180
|
|
|
163
|
-
return {
|
|
164
|
-
structValue: normalizeToRichStruct(value)
|
|
165
|
-
}
|
|
181
|
+
return create(RichValueSchema, {
|
|
182
|
+
value: { case: 'structValue', value: normalizeToRichStruct(value) }
|
|
183
|
+
})
|
|
166
184
|
}
|
|
167
185
|
|
|
168
186
|
console.warn('Cannot submit unsupported type ' + typeof value)
|
|
169
|
-
return { nullValue: RichValue_NullValue.
|
|
187
|
+
return create(RichValueSchema, { value: { case: 'nullValue', value: RichValue_NullValue.NULL_VALUE } })
|
|
170
188
|
}
|
|
171
189
|
}
|
|
172
190
|
|
|
173
191
|
export function normalizeToRichStruct(...objs: any[]): RichStruct {
|
|
174
|
-
const ret: RichStruct = {
|
|
192
|
+
const ret: RichStruct = create(RichStructSchema, {
|
|
175
193
|
fields: {}
|
|
176
|
-
}
|
|
194
|
+
})
|
|
177
195
|
for (const obj of objs) {
|
|
178
196
|
for (const [key, value] of Object.entries(obj)) {
|
|
179
197
|
try {
|
|
@@ -189,7 +207,7 @@ export function normalizeToRichStruct(...objs: any[]): RichStruct {
|
|
|
189
207
|
}
|
|
190
208
|
|
|
191
209
|
function toTokenAmount(value: any): TokenAmount | undefined {
|
|
192
|
-
const ret =
|
|
210
|
+
const ret = create(TokenAmountSchema)
|
|
193
211
|
|
|
194
212
|
for (const key of Object.getOwnPropertyNames(value)) {
|
|
195
213
|
switch (key) {
|
|
@@ -211,7 +229,7 @@ function toTokenAmount(value: any): TokenAmount | undefined {
|
|
|
211
229
|
break
|
|
212
230
|
case 'specifiedAt':
|
|
213
231
|
if (value.specifiedAt instanceof Date) {
|
|
214
|
-
ret.specifiedAt = value.specifiedAt
|
|
232
|
+
ret.specifiedAt = timestampFromDate(value.specifiedAt)
|
|
215
233
|
} else {
|
|
216
234
|
return undefined
|
|
217
235
|
}
|
|
@@ -225,13 +243,17 @@ function toTokenAmount(value: any): TokenAmount | undefined {
|
|
|
225
243
|
}
|
|
226
244
|
|
|
227
245
|
function toCoinID(coin: any): CoinID | undefined {
|
|
228
|
-
const ret =
|
|
246
|
+
const ret = create(CoinIDSchema)
|
|
229
247
|
if (typeof coin.symbol === 'string') {
|
|
230
|
-
|
|
248
|
+
ret.id = { case: 'symbol', value: coin.symbol }
|
|
249
|
+
return ret
|
|
231
250
|
} else if (coin.hasOwnProperty('address')) {
|
|
232
|
-
ret.
|
|
233
|
-
|
|
234
|
-
|
|
251
|
+
ret.id = {
|
|
252
|
+
case: 'address',
|
|
253
|
+
value: create(CoinID_AddressIdentifierSchema, {
|
|
254
|
+
address: coin.address.address,
|
|
255
|
+
chain: coin.address.chain
|
|
256
|
+
})
|
|
235
257
|
}
|
|
236
258
|
} else {
|
|
237
259
|
return undefined
|