@sentio/sdk 4.0.0-rc.1 → 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 +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 +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 +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 +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 +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/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 +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 +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/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/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 +1 -1
- package/lib/sui/sui-processor.d.ts.map +1 -1
- package/lib/sui/sui-processor.js +21 -19
- 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 +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 +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 +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 +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 +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 +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 +7 -6
- 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 +25 -17
- package/src/iota/network.ts +6 -6
- 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/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 +28 -19
- 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 -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 +170 -80
- package/src/testing/test-provider.ts +1 -1
- package/src/utils/price.ts +20 -13
package/src/eth/eth.ts
CHANGED
|
@@ -23,8 +23,9 @@ import {
|
|
|
23
23
|
import type { AccessList } from 'ethers/transaction'
|
|
24
24
|
import { ContractContext } from './context.js'
|
|
25
25
|
import { getAddress } from 'ethers/address'
|
|
26
|
-
import { getBigInt } from 'ethers/utils'
|
|
27
|
-
import { EthCallContext, EthCallParam } from '@sentio/protos'
|
|
26
|
+
import { getBigInt, getNumber } from 'ethers/utils'
|
|
27
|
+
import { type EthCallContext, type EthCallParam, EthCallParamSchema } from '@sentio/protos'
|
|
28
|
+
import { create } from '@bufbuild/protobuf'
|
|
28
29
|
import { ALL_ADDRESS } from '../core/index.js'
|
|
29
30
|
|
|
30
31
|
export interface IResult {
|
|
@@ -126,14 +127,14 @@ class FormattedTransactionReceipt implements TransactionReceiptParams {
|
|
|
126
127
|
return this.data.transactionHash
|
|
127
128
|
}
|
|
128
129
|
get index(): number {
|
|
129
|
-
return this.data.transactionIndex
|
|
130
|
+
return getNumber(this.data.transactionIndex)
|
|
130
131
|
}
|
|
131
132
|
|
|
132
133
|
get blockHash(): string {
|
|
133
134
|
return this.data.blockHash
|
|
134
135
|
}
|
|
135
136
|
get blockNumber(): number {
|
|
136
|
-
return this.data.blockNumber
|
|
137
|
+
return getNumber(this.data.blockNumber)
|
|
137
138
|
}
|
|
138
139
|
get logsBloom(): string {
|
|
139
140
|
return this.data.logsBloom
|
|
@@ -178,10 +179,10 @@ class FormattedTransactionReceipt implements TransactionReceiptParams {
|
|
|
178
179
|
return this._l1Fee !== undefined ? this._l1Fee : (this._l1Fee = allowNull(getBigInt)(this.data.l1Fee))
|
|
179
180
|
}
|
|
180
181
|
get type(): number {
|
|
181
|
-
return this.data.type
|
|
182
|
+
return allowNull(getNumber, 0)(this.data.type)
|
|
182
183
|
}
|
|
183
184
|
get status(): number | null {
|
|
184
|
-
return this.data.status
|
|
185
|
+
return allowNull(getNumber)(this.data.status)
|
|
185
186
|
}
|
|
186
187
|
get root(): string | null {
|
|
187
188
|
return this.data.root
|
|
@@ -197,7 +198,7 @@ export class FormattedLog implements LogParams {
|
|
|
197
198
|
return this.raw.blockHash
|
|
198
199
|
}
|
|
199
200
|
get blockNumber(): number {
|
|
200
|
-
return this.raw.blockNumber
|
|
201
|
+
return getNumber(this.raw.blockNumber)
|
|
201
202
|
}
|
|
202
203
|
get removed(): boolean {
|
|
203
204
|
return this.raw.removed
|
|
@@ -213,11 +214,14 @@ export class FormattedLog implements LogParams {
|
|
|
213
214
|
}
|
|
214
215
|
|
|
215
216
|
get transactionIndex(): number {
|
|
216
|
-
|
|
217
|
+
// Raw RPC logs carry these as hex strings (e.g. "0xf3"); coerce so the value honors the
|
|
218
|
+
// declared `number` type and is valid for the int32 RecordMetaData fields it feeds.
|
|
219
|
+
// (Restores the getNumber coercion that ethers' formatLog applied before #1411.)
|
|
220
|
+
return getNumber(this.raw.transactionIndex)
|
|
217
221
|
}
|
|
218
222
|
|
|
219
223
|
get index(): number {
|
|
220
|
-
return this.raw.logIndex
|
|
224
|
+
return getNumber(this.raw.logIndex)
|
|
221
225
|
}
|
|
222
226
|
|
|
223
227
|
get data(): string {
|
|
@@ -240,11 +244,12 @@ function formatLog(log: any): LogParams {
|
|
|
240
244
|
}
|
|
241
245
|
|
|
242
246
|
export function formatEthData(data: {
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
247
|
+
// raw_* JSON payloads sent by the driver
|
|
248
|
+
rawLog?: string
|
|
249
|
+
rawBlock?: string
|
|
250
|
+
rawTrace?: string
|
|
251
|
+
rawTransaction?: string
|
|
252
|
+
rawTransactionReceipt?: string
|
|
248
253
|
__formattedEthData?: any
|
|
249
254
|
}) {
|
|
250
255
|
// Return cached result if it exists
|
|
@@ -253,22 +258,29 @@ export function formatEthData(data: {
|
|
|
253
258
|
}
|
|
254
259
|
|
|
255
260
|
try {
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
261
|
+
// All Eth* data is delivered as raw_* JSON payloads; parse them here.
|
|
262
|
+
const logObj = data.rawLog ? JSON.parse(data.rawLog) : undefined
|
|
263
|
+
const blockObj = data.rawBlock ? JSON.parse(data.rawBlock) : undefined
|
|
264
|
+
const traceObj = data.rawTrace ? JSON.parse(data.rawTrace) : undefined
|
|
265
|
+
const transactionObj = data.rawTransaction ? JSON.parse(data.rawTransaction) : undefined
|
|
266
|
+
const transactionReceiptObj = data.rawTransactionReceipt ? JSON.parse(data.rawTransactionReceipt) : undefined
|
|
267
|
+
|
|
268
|
+
const log = logObj ? formatLog(logObj) : undefined
|
|
269
|
+
if (blockObj && !blockObj.transactions) {
|
|
270
|
+
blockObj.transactions = []
|
|
259
271
|
}
|
|
260
|
-
const block =
|
|
261
|
-
const trace =
|
|
272
|
+
const block = blockObj ? formatRichBlock(blockObj) : undefined
|
|
273
|
+
const trace = traceObj ? (traceObj as Trace) : undefined
|
|
262
274
|
let transaction = undefined
|
|
263
|
-
if (
|
|
264
|
-
if (!
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
275
|
+
if (transactionObj) {
|
|
276
|
+
if (!transactionObj.v) {
|
|
277
|
+
transactionObj.v = '0x1c'
|
|
278
|
+
transactionObj.r = '0x88ff6cf0fefd94db46111149ae4bfc179e9b94721fffd821d38d16464b3f71d0'
|
|
279
|
+
transactionObj.s = '0x45e0aff800961cfce805daef7016b9b675c137a6a41a548f7b60a3484c06a33a'
|
|
268
280
|
}
|
|
269
|
-
transaction = formatTransactionResponse(
|
|
281
|
+
transaction = formatTransactionResponse(transactionObj)
|
|
270
282
|
}
|
|
271
|
-
const transactionReceipt =
|
|
283
|
+
const transactionReceipt = transactionReceiptObj ? formatTransactionReceipt(transactionReceiptObj) : undefined
|
|
272
284
|
|
|
273
285
|
const result = {
|
|
274
286
|
log,
|
|
@@ -291,7 +303,7 @@ class FormattedTransactionResponse implements TransactionResponseParams {
|
|
|
291
303
|
constructor(readonly raw: any) {}
|
|
292
304
|
|
|
293
305
|
get blockNumber(): number | null {
|
|
294
|
-
return this.raw.blockNumber
|
|
306
|
+
return allowNull(getNumber)(this.raw.blockNumber)
|
|
295
307
|
}
|
|
296
308
|
_blockHash: string | undefined | null
|
|
297
309
|
get blockHash(): string | null {
|
|
@@ -309,13 +321,15 @@ class FormattedTransactionResponse implements TransactionResponseParams {
|
|
|
309
321
|
return this.raw.hash
|
|
310
322
|
}
|
|
311
323
|
get index(): number {
|
|
312
|
-
|
|
324
|
+
// transactionIndex is absent for pending/partial txs; default to 0 (matches the prior
|
|
325
|
+
// `this.transaction.index || 0` handling) while still coercing hex strings when present.
|
|
326
|
+
return allowNull(getNumber, 0)(this.raw.transactionIndex)
|
|
313
327
|
}
|
|
314
328
|
get type(): number {
|
|
315
329
|
if (this.raw.type === '0x' || this.raw.type == null) {
|
|
316
330
|
return 0
|
|
317
331
|
}
|
|
318
|
-
return this.raw.type
|
|
332
|
+
return getNumber(this.raw.type)
|
|
319
333
|
}
|
|
320
334
|
_to: string | null
|
|
321
335
|
get to(): string | null {
|
|
@@ -332,7 +346,7 @@ class FormattedTransactionResponse implements TransactionResponseParams {
|
|
|
332
346
|
return this._from ?? (this._from = getAddress(this.raw.from))
|
|
333
347
|
}
|
|
334
348
|
get nonce(): number {
|
|
335
|
-
return this.raw.nonce
|
|
349
|
+
return getNumber(this.raw.nonce)
|
|
336
350
|
}
|
|
337
351
|
_gasLimit: bigint
|
|
338
352
|
get gasLimit(): bigint {
|
|
@@ -528,10 +542,10 @@ export function encodeCallData(
|
|
|
528
542
|
try {
|
|
529
543
|
const iface = new Interface([funcABI])
|
|
530
544
|
const calldata = iface.encodeFunctionData(name, values)
|
|
531
|
-
return {
|
|
545
|
+
return create(EthCallParamSchema, {
|
|
532
546
|
context,
|
|
533
547
|
calldata
|
|
534
|
-
}
|
|
548
|
+
})
|
|
535
549
|
} catch (e) {
|
|
536
550
|
const stack = new Error().stack
|
|
537
551
|
throw transformEtherError(e, undefined, stack)
|
|
@@ -2,7 +2,7 @@ import { BaseContract } from 'ethers'
|
|
|
2
2
|
import { BoundContractView, ContractView } from './context.js'
|
|
3
3
|
import { BindOptions } from './bind-options.js'
|
|
4
4
|
import { BaseProcessor } from './base-processor.js'
|
|
5
|
-
import { getProvider } from '
|
|
5
|
+
import { getProvider } from './provider.js'
|
|
6
6
|
import { addProcessor } from './binds.js'
|
|
7
7
|
|
|
8
8
|
export class GenericProcessor extends BaseProcessor<
|
package/src/eth/index.ts
CHANGED
|
@@ -3,7 +3,7 @@ export { GenericProcessor } from './generic-processor.js'
|
|
|
3
3
|
export { BaseProcessorTemplate } from './base-processor-template.js'
|
|
4
4
|
export { AccountProcessor } from './account-processor.js'
|
|
5
5
|
|
|
6
|
-
export { getProvider, DummyProvider } from '
|
|
6
|
+
export { getProvider, DummyProvider } from './provider.js'
|
|
7
7
|
|
|
8
8
|
export { EthContext } from './context.js'
|
|
9
9
|
export * from './eth.js'
|
|
@@ -13,7 +13,7 @@ export { AccountContext, ContractContext, GlobalContext, ContractView, BoundCont
|
|
|
13
13
|
|
|
14
14
|
export { EthPlugin } from './eth-plugin.js'
|
|
15
15
|
|
|
16
|
-
export { EthFetchConfig, PreprocessResult } from '@sentio/protos'
|
|
16
|
+
export type { EthFetchConfig, PreprocessResult } from '@sentio/protos'
|
|
17
17
|
|
|
18
18
|
export { EthChainId } from '@sentio/chain'
|
|
19
19
|
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
import { JsonRpcProvider, Network } from 'ethers'
|
|
2
|
+
|
|
3
|
+
import PQueue from 'p-queue'
|
|
4
|
+
import { EthChainId } from '@sentio/chain'
|
|
5
|
+
import { LRUCache } from 'lru-cache'
|
|
6
|
+
import { Endpoints, providerMetrics, processMetrics, metricsStorage, GLOBAL_CONFIG } from '@sentio/runtime'
|
|
7
|
+
const { miss_count, hit_count, queue_size } = providerMetrics
|
|
8
|
+
|
|
9
|
+
export const DummyProvider = new JsonRpcProvider('', Network.from(1))
|
|
10
|
+
|
|
11
|
+
const providers = new Map<string, JsonRpcProvider>()
|
|
12
|
+
|
|
13
|
+
// export function getEthChainId(networkish?: EthContext | EthChainId): EthChainId {
|
|
14
|
+
// if (!networkish) {
|
|
15
|
+
// networkish = EthChainId.ETHEREUM
|
|
16
|
+
// }
|
|
17
|
+
// if (networkish instanceof BaseContext) {
|
|
18
|
+
// networkish = networkish.getChainId()
|
|
19
|
+
// }
|
|
20
|
+
// return networkish
|
|
21
|
+
// }
|
|
22
|
+
|
|
23
|
+
export function getProvider(chainId?: EthChainId): JsonRpcProvider {
|
|
24
|
+
// const network = getNetworkFromCtxOrNetworkish(networkish)
|
|
25
|
+
if (!chainId) {
|
|
26
|
+
chainId = EthChainId.ETHEREUM
|
|
27
|
+
}
|
|
28
|
+
const network = Network.from(parseInt(chainId))
|
|
29
|
+
// TODO check if other key needed
|
|
30
|
+
|
|
31
|
+
const address = Endpoints.INSTANCE.getChainRpcUrl(chainId)
|
|
32
|
+
const key = network.chainId.toString() + '-' + address
|
|
33
|
+
|
|
34
|
+
// console.debug(`init provider for ${chainId}, address: ${address}`)
|
|
35
|
+
let provider = providers.get(key)
|
|
36
|
+
|
|
37
|
+
if (provider) {
|
|
38
|
+
return provider
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
if (address === undefined) {
|
|
42
|
+
throw Error(
|
|
43
|
+
'Provider not found for chain ' +
|
|
44
|
+
network.chainId +
|
|
45
|
+
', configured chains: ' +
|
|
46
|
+
[...Endpoints.INSTANCE.chainRpc.keys()].join(' ')
|
|
47
|
+
)
|
|
48
|
+
}
|
|
49
|
+
// console.log(
|
|
50
|
+
// `init provider for chain ${network.chainId}, concurrency: ${Endpoints.INSTANCE.concurrency}, batchCount: ${Endpoints.INSTANCE.batchCount}`
|
|
51
|
+
// )
|
|
52
|
+
provider = new QueuedStaticJsonRpcProvider(
|
|
53
|
+
address,
|
|
54
|
+
network,
|
|
55
|
+
Endpoints.INSTANCE.concurrency,
|
|
56
|
+
Endpoints.INSTANCE.batchCount
|
|
57
|
+
)
|
|
58
|
+
providers.set(key, provider)
|
|
59
|
+
return provider
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
function getTag(prefix: string, value: any): string {
|
|
63
|
+
return (
|
|
64
|
+
prefix +
|
|
65
|
+
':' +
|
|
66
|
+
JSON.stringify(value, (k, v) => {
|
|
67
|
+
if (v == null) {
|
|
68
|
+
return 'null'
|
|
69
|
+
}
|
|
70
|
+
if (typeof v === 'bigint') {
|
|
71
|
+
return `bigint:${v.toString()}`
|
|
72
|
+
}
|
|
73
|
+
if (typeof v === 'string') {
|
|
74
|
+
return v.toLowerCase()
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// Sort object keys
|
|
78
|
+
if (typeof v === 'object' && !Array.isArray(v)) {
|
|
79
|
+
const keys = Object.keys(v)
|
|
80
|
+
keys.sort()
|
|
81
|
+
return keys.reduce(
|
|
82
|
+
(accum, key) => {
|
|
83
|
+
accum[key] = v[key]
|
|
84
|
+
return accum
|
|
85
|
+
},
|
|
86
|
+
<any>{}
|
|
87
|
+
)
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
return v
|
|
91
|
+
})
|
|
92
|
+
)
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
export class QueuedStaticJsonRpcProvider extends JsonRpcProvider {
|
|
96
|
+
executor: PQueue
|
|
97
|
+
#performCache = new LRUCache<string, Promise<any>>({
|
|
98
|
+
max: 300000, // 300k items
|
|
99
|
+
maxSize: 500 * 1024 * 1024 // 500mb key size for cache
|
|
100
|
+
// ttl: 1000 * 60 * 60, // 1 hour no ttl for better performance
|
|
101
|
+
// sizeCalculation: (value: any) => {
|
|
102
|
+
// assume each item is 1kb for simplicity
|
|
103
|
+
// return 1024
|
|
104
|
+
// }
|
|
105
|
+
})
|
|
106
|
+
#retryCache = new LRUCache<string, number>({
|
|
107
|
+
max: 300000 // 300k items
|
|
108
|
+
})
|
|
109
|
+
|
|
110
|
+
constructor(url: string, network: Network, concurrency: number, batchCount = 1) {
|
|
111
|
+
// TODO re-enable match when possible
|
|
112
|
+
super(url, network, { staticNetwork: network, batchMaxCount: batchCount })
|
|
113
|
+
this.executor = new PQueue({ concurrency: concurrency })
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
async send(method: string, params: Array<any>): Promise<any> {
|
|
117
|
+
if (method !== 'eth_call' || params.length > 2) {
|
|
118
|
+
return await this.executor.add(() => super.send(method, params))
|
|
119
|
+
}
|
|
120
|
+
const tag = getTag(method, params)
|
|
121
|
+
const block = params[params.length - 1]
|
|
122
|
+
let perform = this.#performCache.get(tag)
|
|
123
|
+
if (!perform) {
|
|
124
|
+
miss_count.add(1)
|
|
125
|
+
const handler = metricsStorage.getStore()
|
|
126
|
+
const queued: number = Date.now()
|
|
127
|
+
perform = this.executor.add(() => {
|
|
128
|
+
const started = Date.now()
|
|
129
|
+
processMetrics.processor_rpc_queue_duration.record(started - queued, {
|
|
130
|
+
chain_id: this._network.chainId.toString(),
|
|
131
|
+
handler
|
|
132
|
+
})
|
|
133
|
+
|
|
134
|
+
let success = true
|
|
135
|
+
return super
|
|
136
|
+
.send(method, params)
|
|
137
|
+
.catch((e) => {
|
|
138
|
+
success = false
|
|
139
|
+
throw e
|
|
140
|
+
})
|
|
141
|
+
.finally(() => {
|
|
142
|
+
processMetrics.processor_rpc_duration.record(Date.now() - started, {
|
|
143
|
+
chain_id: this._network.chainId.toString(),
|
|
144
|
+
handler,
|
|
145
|
+
success
|
|
146
|
+
})
|
|
147
|
+
})
|
|
148
|
+
})
|
|
149
|
+
|
|
150
|
+
queue_size.record(this.executor.size)
|
|
151
|
+
|
|
152
|
+
this.#performCache.set(tag, perform, {
|
|
153
|
+
size: tag.length
|
|
154
|
+
})
|
|
155
|
+
// For non latest block call, we cache permanently, otherwise we cache for one minute
|
|
156
|
+
if (block === 'latest') {
|
|
157
|
+
setTimeout(() => {
|
|
158
|
+
if (this.#performCache.get(tag) === perform) {
|
|
159
|
+
this.#performCache.delete(tag)
|
|
160
|
+
}
|
|
161
|
+
}, 60 * 1000)
|
|
162
|
+
}
|
|
163
|
+
} else {
|
|
164
|
+
hit_count.add(1)
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
let result
|
|
168
|
+
try {
|
|
169
|
+
result = await perform
|
|
170
|
+
} catch (e: any) {
|
|
171
|
+
this.#performCache.delete(tag)
|
|
172
|
+
if (e.code === 'TIMEOUT') {
|
|
173
|
+
let retryCount = this.#retryCache.get(tag)
|
|
174
|
+
if (GLOBAL_CONFIG.execution.rpcRetryTimes && retryCount === undefined) {
|
|
175
|
+
retryCount = GLOBAL_CONFIG.execution.rpcRetryTimes
|
|
176
|
+
}
|
|
177
|
+
if (retryCount) {
|
|
178
|
+
this.#retryCache.set(tag, retryCount - 1)
|
|
179
|
+
return this.send(method, params)
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
throw e
|
|
183
|
+
}
|
|
184
|
+
if (!result) {
|
|
185
|
+
throw Error('Unexpected null response')
|
|
186
|
+
}
|
|
187
|
+
return result
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
toString() {
|
|
191
|
+
return 'QueuedStaticJsonRpcProvider'
|
|
192
|
+
}
|
|
193
|
+
}
|
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
import { CallHandler, FuelBaseProcessor, FuelProcessorState } from './types.js'
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
Data_FuelTransaction,
|
|
4
|
+
FuelAssetHandlerConfig_AssetFilter,
|
|
5
|
+
FuelAssetHandlerConfig_AssetFilterSchema,
|
|
6
|
+
timestampDate
|
|
7
|
+
} from '@sentio/protos'
|
|
8
|
+
import { create } from '@bufbuild/protobuf'
|
|
3
9
|
import { FuelNetwork, getProvider } from './network.js'
|
|
4
10
|
import { FuelContext } from './context.js'
|
|
5
11
|
import { decodeFuelTransaction } from './transaction.js'
|
|
@@ -8,7 +14,7 @@ import { getOptionsSignature } from './fuel-processor.js'
|
|
|
8
14
|
import { getHandlerName, proxyProcessor } from '../utils/metrics.js'
|
|
9
15
|
|
|
10
16
|
export class FuelAssetProcessor implements FuelBaseProcessor<FuelAssetProcessorConfig> {
|
|
11
|
-
txHandlers: CallHandler<Data_FuelTransaction
|
|
17
|
+
txHandlers: CallHandler<Data_FuelTransaction>[] = []
|
|
12
18
|
blockHandlers = []
|
|
13
19
|
private provider: Provider
|
|
14
20
|
|
|
@@ -42,11 +48,13 @@ export class FuelAssetProcessor implements FuelBaseProcessor<FuelAssetProcessorC
|
|
|
42
48
|
for (const assetId of assetIds) {
|
|
43
49
|
for (const from of froms) {
|
|
44
50
|
for (const to of tos) {
|
|
45
|
-
filters.push(
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
51
|
+
filters.push(
|
|
52
|
+
create(FuelAssetHandlerConfig_AssetFilterSchema, {
|
|
53
|
+
assetId: assetId,
|
|
54
|
+
fromAddress: from,
|
|
55
|
+
toAddress: to
|
|
56
|
+
})
|
|
57
|
+
)
|
|
50
58
|
}
|
|
51
59
|
}
|
|
52
60
|
}
|
|
@@ -94,7 +102,7 @@ export class FuelAssetProcessor implements FuelBaseProcessor<FuelAssetProcessorC
|
|
|
94
102
|
this.config.chainId,
|
|
95
103
|
assetId,
|
|
96
104
|
this.config.name ?? '',
|
|
97
|
-
call.timestamp
|
|
105
|
+
call.timestamp ? timestampDate(call.timestamp) : new Date(0),
|
|
98
106
|
tx,
|
|
99
107
|
null
|
|
100
108
|
)
|
package/src/fuel/context.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { BaseContext, Labels, normalizeLabels } from '../core/index.js'
|
|
2
2
|
import { FuelChainId } from '@sentio/chain'
|
|
3
|
-
import { RecordMetaData } from '@sentio/protos'
|
|
3
|
+
import { RecordMetaData, RecordMetaDataSchema } from '@sentio/protos'
|
|
4
|
+
import { create } from '@bufbuild/protobuf'
|
|
4
5
|
import type { CallResult, Contract } from 'fuels'
|
|
5
6
|
import { InvocationScopeLike } from 'fuels'
|
|
6
7
|
import { FuelBlock, FuelLog, FuelTransaction } from './types.js'
|
|
@@ -39,7 +40,7 @@ export class FuelContext extends BaseContext {
|
|
|
39
40
|
}
|
|
40
41
|
|
|
41
42
|
protected getMetaDataInternal(name: string, labels: Labels): RecordMetaData {
|
|
42
|
-
return {
|
|
43
|
+
return create(RecordMetaDataSchema, {
|
|
43
44
|
address: this.contractAddress,
|
|
44
45
|
contractName: this.contractName,
|
|
45
46
|
blockNumber: BigInt(this.block?.height?.toString() ?? (this.transaction?.blockNumber || 0)),
|
|
@@ -49,7 +50,7 @@ export class FuelContext extends BaseContext {
|
|
|
49
50
|
name: name,
|
|
50
51
|
logIndex: this.logIndex,
|
|
51
52
|
labels: normalizeLabels(labels)
|
|
52
|
-
}
|
|
53
|
+
})
|
|
53
54
|
}
|
|
54
55
|
}
|
|
55
56
|
|