@sentio/sdk 2.0.0-rc.1 → 2.0.0-rc.11
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/builtin/eacaggregatorproxy/index.d.ts +3 -2
- package/lib/builtin/eacaggregatorproxy/index.js +3 -5
- package/lib/builtin/eacaggregatorproxy/index.js.map +1 -1
- package/lib/builtin/eacaggregatorproxy/test-utils.d.ts +1 -1
- package/lib/builtin/eacaggregatorproxy/test-utils.js +9 -16
- package/lib/builtin/eacaggregatorproxy/test-utils.js.map +1 -1
- package/lib/builtin/erc1155/index.d.ts +3 -2
- package/lib/builtin/erc1155/index.js +3 -5
- package/lib/builtin/erc1155/index.js.map +1 -1
- package/lib/builtin/erc1155/test-utils.d.ts +1 -1
- package/lib/builtin/erc1155/test-utils.js +9 -16
- package/lib/builtin/erc1155/test-utils.js.map +1 -1
- package/lib/builtin/erc20/index.d.ts +3 -2
- package/lib/builtin/erc20/index.js +3 -5
- package/lib/builtin/erc20/index.js.map +1 -1
- package/lib/builtin/erc20/test-utils.d.ts +1 -1
- package/lib/builtin/erc20/test-utils.js +7 -13
- package/lib/builtin/erc20/test-utils.js.map +1 -1
- package/lib/builtin/erc20bytes/index.d.ts +3 -2
- package/lib/builtin/erc20bytes/index.js +3 -5
- package/lib/builtin/erc20bytes/index.js.map +1 -1
- package/lib/builtin/erc20bytes/test-utils.d.ts +1 -1
- package/lib/builtin/erc20bytes/test-utils.js +5 -10
- package/lib/builtin/erc20bytes/test-utils.js.map +1 -1
- package/lib/builtin/erc721/index.d.ts +3 -2
- package/lib/builtin/erc721/index.js +3 -5
- package/lib/builtin/erc721/index.js.map +1 -1
- package/lib/builtin/erc721/test-utils.d.ts +1 -1
- package/lib/builtin/erc721/test-utils.js +7 -13
- package/lib/builtin/erc721/test-utils.js.map +1 -1
- package/lib/builtin/index.d.ts +8 -4
- package/lib/builtin/index.js +8 -8
- package/lib/builtin/index.js.map +1 -1
- package/lib/builtin/internal/EACAggregatorProxy.d.ts +6 -6
- package/lib/builtin/internal/EACAggregatorProxy.js +1 -2
- package/lib/builtin/internal/EACAggregatorProxy.js.map +1 -1
- package/lib/builtin/internal/ERC1155.d.ts +6 -6
- package/lib/builtin/internal/ERC1155.js +1 -2
- package/lib/builtin/internal/ERC1155.js.map +1 -1
- package/lib/builtin/internal/ERC20.d.ts +5 -5
- package/lib/builtin/internal/ERC20.js +1 -2
- package/lib/builtin/internal/ERC20.js.map +1 -1
- package/lib/builtin/internal/ERC20Bytes.d.ts +4 -4
- package/lib/builtin/internal/ERC20Bytes.js +1 -2
- package/lib/builtin/internal/ERC20Bytes.js.map +1 -1
- package/lib/builtin/internal/ERC721.d.ts +5 -5
- package/lib/builtin/internal/ERC721.js +1 -2
- package/lib/builtin/internal/ERC721.js.map +1 -1
- package/lib/builtin/internal/WETH9.d.ts +6 -6
- package/lib/builtin/internal/WETH9.js +1 -2
- package/lib/builtin/internal/WETH9.js.map +1 -1
- package/lib/builtin/internal/common.d.ts +4 -2
- package/lib/builtin/internal/common.js +1 -2
- package/lib/builtin/internal/common.js.map +1 -1
- package/lib/builtin/internal/eacaggregatorproxy_processor.d.ts +2 -2
- package/lib/builtin/internal/eacaggregatorproxy_processor.js +69 -77
- package/lib/builtin/internal/eacaggregatorproxy_processor.js.map +1 -1
- package/lib/builtin/internal/erc1155_processor.d.ts +2 -2
- package/lib/builtin/internal/erc1155_processor.js +30 -38
- package/lib/builtin/internal/erc1155_processor.js.map +1 -1
- package/lib/builtin/internal/erc20_processor.d.ts +2 -2
- package/lib/builtin/internal/erc20_processor.js +39 -47
- package/lib/builtin/internal/erc20_processor.js.map +1 -1
- package/lib/builtin/internal/erc20bytes_processor.d.ts +2 -2
- package/lib/builtin/internal/erc20bytes_processor.js +33 -41
- package/lib/builtin/internal/erc20bytes_processor.js.map +1 -1
- package/lib/builtin/internal/erc721_processor.d.ts +2 -2
- package/lib/builtin/internal/erc721_processor.js +42 -50
- package/lib/builtin/internal/erc721_processor.js.map +1 -1
- package/lib/builtin/internal/factories/EACAggregatorProxy__factory.d.ts +1 -1
- package/lib/builtin/internal/factories/EACAggregatorProxy__factory.js +4 -8
- package/lib/builtin/internal/factories/EACAggregatorProxy__factory.js.map +1 -1
- package/lib/builtin/internal/factories/ERC1155__factory.d.ts +1 -1
- package/lib/builtin/internal/factories/ERC1155__factory.js +4 -8
- package/lib/builtin/internal/factories/ERC1155__factory.js.map +1 -1
- package/lib/builtin/internal/factories/ERC20Bytes__factory.d.ts +1 -1
- package/lib/builtin/internal/factories/ERC20Bytes__factory.js +4 -8
- package/lib/builtin/internal/factories/ERC20Bytes__factory.js.map +1 -1
- package/lib/builtin/internal/factories/ERC20__factory.d.ts +1 -1
- package/lib/builtin/internal/factories/ERC20__factory.js +4 -8
- package/lib/builtin/internal/factories/ERC20__factory.js.map +1 -1
- package/lib/builtin/internal/factories/ERC721__factory.d.ts +1 -1
- package/lib/builtin/internal/factories/ERC721__factory.js +4 -8
- package/lib/builtin/internal/factories/ERC721__factory.js.map +1 -1
- package/lib/builtin/internal/factories/WETH9__factory.d.ts +1 -1
- package/lib/builtin/internal/factories/WETH9__factory.js +4 -8
- package/lib/builtin/internal/factories/WETH9__factory.js.map +1 -1
- package/lib/builtin/internal/factories/index.d.ts +6 -6
- package/lib/builtin/internal/factories/index.js +6 -15
- package/lib/builtin/internal/factories/index.js.map +1 -1
- package/lib/builtin/internal/index.d.ts +13 -13
- package/lib/builtin/internal/index.js +7 -17
- package/lib/builtin/internal/index.js.map +1 -1
- package/lib/builtin/internal/weth9_processor.d.ts +2 -2
- package/lib/builtin/internal/weth9_processor.js +33 -41
- package/lib/builtin/internal/weth9_processor.js.map +1 -1
- package/lib/builtin/weth9/index.d.ts +3 -2
- package/lib/builtin/weth9/index.js +3 -5
- package/lib/builtin/weth9/index.js.map +1 -1
- package/lib/builtin/weth9/test-utils.d.ts +1 -1
- package/lib/builtin/weth9/test-utils.js +9 -16
- package/lib/builtin/weth9/test-utils.js.map +1 -1
- package/lib/core/base-context.d.ts +4 -4
- package/lib/core/base-context.js +7 -11
- package/lib/core/base-context.js.map +1 -1
- package/lib/core/big-decimal.js +3 -7
- package/lib/core/big-decimal.js.map +1 -1
- package/lib/core/bind-options.js +6 -13
- package/lib/core/bind-options.js.map +1 -1
- package/lib/core/context.d.ts +5 -5
- package/lib/core/context.js +14 -23
- package/lib/core/context.js.map +1 -1
- package/lib/core/core-plugin.js +9 -13
- package/lib/core/core-plugin.js.map +1 -1
- package/lib/core/event-tracker.d.ts +2 -2
- package/lib/core/event-tracker.js +6 -13
- package/lib/core/event-tracker.js.map +1 -1
- package/lib/core/exporter.d.ts +2 -2
- package/lib/core/exporter.js +4 -9
- package/lib/core/exporter.js.map +1 -1
- package/lib/core/index.d.ts +12 -9
- package/lib/core/index.js +12 -32
- package/lib/core/index.js.map +1 -1
- package/lib/core/logger.d.ts +2 -2
- package/lib/core/logger.js +7 -11
- package/lib/core/logger.js.map +1 -1
- package/lib/core/metadata.d.ts +4 -0
- package/lib/core/metadata.js +21 -7
- package/lib/core/metadata.js.map +1 -1
- package/lib/core/meter.d.ts +3 -7
- package/lib/core/meter.js +22 -57
- package/lib/core/meter.js.map +1 -1
- package/lib/core/meter.test.js.map +1 -1
- package/lib/core/numberish.d.ts +1 -1
- package/lib/core/numberish.js +12 -18
- package/lib/core/numberish.js.map +1 -1
- package/lib/core/numberish.test.js.map +1 -1
- package/lib/core/sui-plugin.js +12 -16
- package/lib/core/sui-plugin.js.map +1 -1
- package/lib/core/sui-processor.d.ts +1 -1
- package/lib/core/sui-processor.js +6 -12
- package/lib/core/sui-processor.js.map +1 -1
- package/lib/error.d.ts +1 -1
- package/lib/error.js +2 -7
- package/lib/error.js.map +1 -1
- package/lib/eth/account-processor-state.d.ts +1 -1
- package/lib/eth/account-processor-state.js +2 -6
- package/lib/eth/account-processor-state.js.map +1 -1
- package/lib/eth/account-processor.d.ts +7 -7
- package/lib/eth/account-processor.js +23 -27
- package/lib/eth/account-processor.js.map +1 -1
- package/lib/eth/base-processor-template.d.ts +9 -9
- package/lib/eth/base-processor-template.js +8 -17
- package/lib/eth/base-processor-template.js.map +1 -1
- package/lib/eth/base-processor.d.ts +8 -8
- package/lib/eth/base-processor.js +22 -31
- package/lib/eth/base-processor.js.map +1 -1
- package/lib/eth/binds.d.ts +3 -3
- package/lib/eth/binds.js +11 -19
- package/lib/eth/binds.js.map +1 -1
- package/lib/eth/eth-event.d.ts +5 -0
- package/lib/eth/eth-event.js +2 -0
- package/lib/eth/eth-event.js.map +1 -0
- package/lib/eth/eth-plugin.js +30 -34
- package/lib/eth/eth-plugin.js.map +1 -1
- package/lib/eth/generic-processor.d.ts +3 -3
- package/lib/eth/generic-processor.js +9 -13
- package/lib/eth/generic-processor.js.map +1 -1
- package/lib/{core → eth}/generic-processor.test.d.ts +0 -0
- package/lib/eth/generic-processor.test.js.map +1 -0
- package/lib/eth/index.d.ts +7 -6
- package/lib/eth/index.js +6 -14
- package/lib/eth/index.js.map +1 -1
- package/lib/eth/provider.js +12 -17
- package/lib/eth/provider.js.map +1 -1
- package/lib/eth/trace.js +1 -2
- package/lib/eth/trace.js.map +1 -1
- package/lib/index.d.ts +4 -5
- package/lib/index.js +5 -16
- package/lib/index.js.map +1 -1
- package/lib/promise-or-void.js +1 -2
- package/lib/target-ethers-sentio/{event-handler.js → event-handler.cjs} +4 -4
- package/lib/target-ethers-sentio/event-handler.cjs.map +1 -0
- package/lib/target-ethers-sentio/{event-handler.d.ts → event-handler.d.cts} +0 -0
- package/lib/target-ethers-sentio/{file.js → file.cjs} +19 -18
- package/lib/target-ethers-sentio/file.cjs.map +1 -0
- package/lib/target-ethers-sentio/{file.d.ts → file.d.cts} +0 -0
- package/lib/target-ethers-sentio/{functions-handler.js → functions-handler.cjs} +6 -7
- package/lib/target-ethers-sentio/functions-handler.cjs.map +1 -0
- package/lib/target-ethers-sentio/{functions-handler.d.ts → functions-handler.d.cts} +0 -0
- package/lib/target-ethers-sentio/{index.js → index.cjs} +8 -5
- package/lib/target-ethers-sentio/index.cjs.map +1 -0
- package/lib/target-ethers-sentio/{index.d.ts → index.d.cts} +0 -0
- package/lib/target-ethers-sentio/{types.js → types.cjs} +1 -1
- package/lib/target-ethers-sentio/types.cjs.map +1 -0
- package/lib/target-ethers-sentio/{types.d.ts → types.d.cts} +0 -0
- package/lib/target-ethers-sentio/{view-function.js → view-function.cjs} +5 -5
- package/lib/target-ethers-sentio/view-function.cjs.map +1 -0
- package/lib/target-ethers-sentio/{view-function.d.ts → view-function.d.cts} +0 -0
- package/lib/testing/index.d.ts +3 -2
- package/lib/testing/index.js +3 -10
- package/lib/testing/index.js.map +1 -1
- package/lib/testing/metric-utils.d.ts +1 -1
- package/lib/testing/metric-utils.js +7 -13
- package/lib/testing/metric-utils.js.map +1 -1
- package/lib/testing/test-processor-server.d.ts +3 -4
- package/lib/testing/test-processor-server.js +24 -29
- package/lib/testing/test-processor-server.js.map +1 -1
- package/lib/testing/test-provider.js +5 -9
- package/lib/testing/test-provider.js.map +1 -1
- package/lib/tsup.config.ts +28 -0
- package/lib/utils/chain.js +7 -12
- package/lib/utils/chain.js.map +1 -1
- package/lib/utils/conversion.d.ts +0 -5
- package/lib/utils/conversion.js +22 -27
- package/lib/utils/conversion.js.map +1 -1
- package/lib/utils/dex-price.js +14 -19
- package/lib/utils/dex-price.js.map +1 -1
- package/lib/utils/dex-price.test.js.map +1 -1
- package/lib/utils/erc20.test.js.map +1 -1
- package/lib/utils/index.d.ts +4 -4
- package/lib/utils/index.js +4 -8
- package/lib/utils/index.js.map +1 -1
- package/lib/utils/price.d.ts +11 -11
- package/lib/utils/price.js +10 -16
- package/lib/utils/price.js.map +1 -1
- package/lib/utils/token.d.ts +1 -1
- package/lib/utils/token.js +15 -21
- package/lib/utils/token.js.map +1 -1
- package/package.json +23 -19
- package/src/builtin/eacaggregatorproxy/index.ts +3 -2
- package/src/builtin/eacaggregatorproxy/test-utils.ts +1 -1
- package/src/builtin/erc1155/index.ts +3 -2
- package/src/builtin/erc1155/test-utils.ts +1 -1
- package/src/builtin/erc20/index.ts +3 -2
- package/src/builtin/erc20/test-utils.ts +1 -1
- package/src/builtin/erc20bytes/index.ts +3 -2
- package/src/builtin/erc20bytes/test-utils.ts +1 -1
- package/src/builtin/erc721/index.ts +3 -2
- package/src/builtin/erc721/test-utils.ts +1 -1
- package/src/builtin/index.ts +8 -4
- package/src/builtin/internal/EACAggregatorProxy.ts +6 -10
- package/src/builtin/internal/ERC1155.ts +6 -10
- package/src/builtin/internal/ERC20.ts +5 -8
- package/src/builtin/internal/ERC20Bytes.ts +4 -6
- package/src/builtin/internal/ERC721.ts +5 -8
- package/src/builtin/internal/WETH9.ts +6 -10
- package/src/builtin/internal/common.ts +5 -29
- package/src/builtin/internal/eacaggregatorproxy_processor.ts +2 -2
- package/src/builtin/internal/erc1155_processor.ts +2 -2
- package/src/builtin/internal/erc20_processor.ts +2 -2
- package/src/builtin/internal/erc20bytes_processor.ts +2 -2
- package/src/builtin/internal/erc721_processor.ts +2 -2
- package/src/builtin/internal/factories/EACAggregatorProxy__factory.ts +1 -1
- package/src/builtin/internal/factories/ERC1155__factory.ts +1 -1
- package/src/builtin/internal/factories/ERC20Bytes__factory.ts +1 -1
- package/src/builtin/internal/factories/ERC20__factory.ts +1 -1
- package/src/builtin/internal/factories/ERC721__factory.ts +1 -1
- package/src/builtin/internal/factories/WETH9__factory.ts +1 -1
- package/src/builtin/internal/factories/index.ts +6 -6
- package/src/builtin/internal/index.ts +13 -13
- package/src/builtin/internal/weth9_processor.ts +2 -2
- package/src/builtin/weth9/index.ts +3 -2
- package/src/builtin/weth9/test-utils.ts +1 -1
- package/src/core/base-context.ts +4 -4
- package/src/core/context.ts +5 -6
- package/src/core/core-plugin.ts +3 -3
- package/src/core/event-tracker.ts +2 -2
- package/src/core/exporter.ts +3 -3
- package/src/core/index.ts +12 -9
- package/src/core/logger.ts +2 -2
- package/src/core/metadata.ts +23 -2
- package/src/core/meter.ts +3 -26
- package/src/core/numberish.ts +1 -1
- package/src/core/sui-plugin.ts +2 -2
- package/src/core/sui-processor.ts +1 -1
- package/src/error.ts +1 -1
- package/src/eth/account-processor-state.ts +1 -1
- package/src/eth/account-processor.ts +11 -11
- package/src/eth/base-processor-template.ts +8 -11
- package/src/eth/base-processor.ts +14 -28
- package/src/eth/binds.ts +3 -3
- package/src/eth/eth-event.ts +6 -0
- package/src/eth/eth-plugin.ts +3 -3
- package/src/eth/generic-processor.ts +5 -5
- package/src/eth/index.ts +8 -6
- package/src/index.ts +4 -6
- package/src/target-ethers-sentio/{event-handler.ts → event-handler.cts} +1 -1
- package/src/target-ethers-sentio/{file.ts → file.cts} +10 -9
- package/src/target-ethers-sentio/{functions-handler.ts → functions-handler.cts} +3 -4
- package/src/target-ethers-sentio/{index.ts → index.cts} +4 -1
- package/src/target-ethers-sentio/tsconfig.json +1 -1
- package/src/target-ethers-sentio/{types.ts → types.cts} +0 -0
- package/src/target-ethers-sentio/{view-function.ts → view-function.cts} +1 -1
- package/src/testing/index.ts +3 -3
- package/src/testing/metric-utils.ts +2 -2
- package/src/testing/test-processor-server.ts +5 -5
- package/src/testing/test-provider.ts +1 -1
- package/src/tsup.config.ts +28 -0
- package/src/utils/conversion.ts +21 -25
- package/src/utils/dex-price.ts +4 -5
- package/src/utils/index.ts +4 -4
- package/src/utils/price.ts +1 -1
- package/src/utils/token.ts +6 -6
- package/lib/core/generic-processor.test.js.map +0 -1
- package/lib/target-ethers-sentio/event-handler.js.map +0 -1
- package/lib/target-ethers-sentio/file.js.map +0 -1
- package/lib/target-ethers-sentio/functions-handler.js.map +0 -1
- package/lib/target-ethers-sentio/index.js.map +0 -1
- package/lib/target-ethers-sentio/types.js.map +0 -1
- package/lib/target-ethers-sentio/view-function.js.map +0 -1
- package/lib/webpack.config.js +0 -50
- package/src/webpack.config.js +0 -50
package/src/core/logger.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { BaseContext } from './base-context'
|
|
1
|
+
import { BaseContext } from './base-context.js'
|
|
2
2
|
import { LogLevel } from '@sentio/protos'
|
|
3
|
-
import { NamedResultDescriptor } from './metadata'
|
|
3
|
+
import { NamedResultDescriptor } from './metadata.js'
|
|
4
4
|
|
|
5
5
|
export type Attributes = Record<string, any>
|
|
6
6
|
|
package/src/core/metadata.ts
CHANGED
|
@@ -1,7 +1,28 @@
|
|
|
1
|
-
import { normalizeName } from './meter'
|
|
2
|
-
|
|
3
1
|
export type Labels = { [key: string]: string }
|
|
4
2
|
|
|
3
|
+
export function normalizeName(name: string): string {
|
|
4
|
+
return name.slice(0, 100).replace(/[^_\-a-zA-Z0-9]/g, '_')
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export function normalizeKey(name: string): string {
|
|
8
|
+
if (name === 'labels') {
|
|
9
|
+
return 'labels_'
|
|
10
|
+
}
|
|
11
|
+
return normalizeName(name)
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export function normalizeValue(name: string): string {
|
|
15
|
+
return name.slice(0, 100)
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export function normalizeLabels(labels: Labels): Labels {
|
|
19
|
+
const normLabels: Labels = {}
|
|
20
|
+
for (const key in labels) {
|
|
21
|
+
normLabels[normalizeKey(key)] = normalizeValue(labels[key])
|
|
22
|
+
}
|
|
23
|
+
return normLabels
|
|
24
|
+
}
|
|
25
|
+
|
|
5
26
|
export class NamedResultDescriptor {
|
|
6
27
|
name: string
|
|
7
28
|
|
package/src/core/meter.ts
CHANGED
|
@@ -1,32 +1,9 @@
|
|
|
1
|
-
import { BaseContext } from './base-context'
|
|
2
|
-
import { Numberish, toMetricValue } from './numberish'
|
|
3
|
-
import { Labels, NamedResultDescriptor } from './metadata'
|
|
1
|
+
import { BaseContext } from './base-context.js'
|
|
2
|
+
import { Numberish, toMetricValue } from './numberish.js'
|
|
3
|
+
import { Labels, NamedResultDescriptor, normalizeKey } from './metadata.js'
|
|
4
4
|
import { AggregationConfig, AggregationType, MetricConfig, MetricType } from '@sentio/protos'
|
|
5
5
|
import { MapStateStorage } from '@sentio/runtime'
|
|
6
6
|
|
|
7
|
-
export function normalizeName(name: string): string {
|
|
8
|
-
return name.slice(0, 100).replace(/[^_\-a-zA-Z0-9]/g, '_')
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export function normalizeKey(name: string): string {
|
|
12
|
-
if (name === 'labels') {
|
|
13
|
-
return 'labels_'
|
|
14
|
-
}
|
|
15
|
-
return normalizeName(name)
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export function normalizeValue(name: string): string {
|
|
19
|
-
return name.slice(0, 100)
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export function normalizeLabels(labels: Labels): Labels {
|
|
23
|
-
const normLabels: Labels = {}
|
|
24
|
-
for (const key in labels) {
|
|
25
|
-
normLabels[normalizeKey(key)] = normalizeValue(labels[key])
|
|
26
|
-
}
|
|
27
|
-
return normLabels
|
|
28
|
-
}
|
|
29
|
-
|
|
30
7
|
export class MetricOptions {
|
|
31
8
|
unit?: string
|
|
32
9
|
description?: string
|
package/src/core/numberish.ts
CHANGED
package/src/core/sui-plugin.ts
CHANGED
|
@@ -3,8 +3,8 @@ import { ContractConfig, DataBinding, HandlerType, ProcessConfigResponse, Proces
|
|
|
3
3
|
|
|
4
4
|
import { ServerError, Status } from 'nice-grpc'
|
|
5
5
|
|
|
6
|
-
import { CHAIN_IDS } from '../utils/chain'
|
|
7
|
-
import { SuiProcessorState } from './sui-processor'
|
|
6
|
+
import { CHAIN_IDS } from '../utils/chain.js'
|
|
7
|
+
import { SuiProcessorState } from './sui-processor.js'
|
|
8
8
|
|
|
9
9
|
export class SuiPlugin extends Plugin {
|
|
10
10
|
name: string = 'SuiPlugin'
|
package/src/error.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ListStateStorage } from '@sentio/runtime'
|
|
2
|
-
import { AccountProcessor } from './account-processor'
|
|
2
|
+
import { AccountProcessor } from './account-processor.js'
|
|
3
3
|
|
|
4
4
|
export class AccountProcessorState extends ListStateStorage<AccountProcessor> {
|
|
5
5
|
static INSTANCE = new AccountProcessorState()
|
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
import { ERC20__factory, ERC721__factory } from '../builtin/internal'
|
|
2
|
-
import { AddressType,
|
|
3
|
-
import { AccountBindOptions } from '../core/bind-options'
|
|
1
|
+
import { ERC20__factory, ERC721__factory } from '../builtin/internal/index.js'
|
|
2
|
+
import { AddressType, EthFetchConfig, ProcessResult } from '@sentio/protos'
|
|
3
|
+
import { AccountBindOptions } from '../core/bind-options.js'
|
|
4
4
|
|
|
5
5
|
import { Network, LogParams } from 'ethers/providers'
|
|
6
6
|
|
|
7
|
-
import { TransferEvent as ERC20TransferEvent } from '../builtin/internal/ERC20'
|
|
8
|
-
import { TransferEvent as ERC721TransferEvent } from '../builtin/internal/ERC721'
|
|
7
|
+
import { TransferEvent as ERC20TransferEvent } from '../builtin/internal/ERC20.js'
|
|
8
|
+
import { TransferEvent as ERC721TransferEvent } from '../builtin/internal/ERC721.js'
|
|
9
9
|
|
|
10
|
-
import { ERC20Processor } from '../builtin/internal/erc20_processor'
|
|
11
|
-
import { ERC721Processor } from '../builtin/internal/erc721_processor'
|
|
10
|
+
import { ERC20Processor } from '../builtin/internal/erc20_processor.js'
|
|
11
|
+
import { ERC721Processor } from '../builtin/internal/erc721_processor.js'
|
|
12
12
|
|
|
13
|
-
import { AccountContext } from '../core/context'
|
|
14
|
-
import { PromiseOrVoid } from '../promise-or-void'
|
|
15
|
-
import { AddressOrTypeEventFilter, EventsHandler } from './base-processor'
|
|
13
|
+
import { AccountContext } from '../core/context.js'
|
|
14
|
+
import { PromiseOrVoid } from '../promise-or-void.js'
|
|
15
|
+
import { AddressOrTypeEventFilter, EventsHandler } from './base-processor.js'
|
|
16
16
|
import { Transaction, Block, TransactionReceipt, LogDescription } from 'ethers'
|
|
17
|
-
import { AccountProcessorState } from './account-processor-state'
|
|
17
|
+
import { AccountProcessorState } from './account-processor-state.js'
|
|
18
18
|
|
|
19
19
|
const ERC20_INTERFACE = ERC20__factory.createInterface()
|
|
20
20
|
const ERC721_INTERFACE = ERC721__factory.createInterface()
|
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
import { BoundContractView, ContractContext, ContractView } from '../core/context'
|
|
1
|
+
import { BoundContractView, ContractContext, ContractView } from '../core/context.js'
|
|
2
2
|
import { BaseContract, ContractEvent, Block, LogDescription } from 'ethers'
|
|
3
|
-
import { AddressOrTypeEventFilter, BaseProcessor } from './base-processor'
|
|
4
|
-
import { BindOptions, getOptionsSignature } from '../core/bind-options'
|
|
3
|
+
import { AddressOrTypeEventFilter, BaseProcessor } from './base-processor.js'
|
|
4
|
+
import { BindOptions, getOptionsSignature } from '../core/bind-options.js'
|
|
5
5
|
import { EthFetchConfig, HandleInterval, TemplateInstance } from '@sentio/protos'
|
|
6
|
-
import { PromiseOrVoid } from '../promise-or-void'
|
|
7
|
-
import { Trace } from './trace'
|
|
6
|
+
import { PromiseOrVoid } from '../promise-or-void.js'
|
|
7
|
+
import { Trace } from './trace.js'
|
|
8
8
|
import { ListStateStorage } from '@sentio/runtime'
|
|
9
9
|
import { EventFilter, LogParams, Network } from 'ethers/providers'
|
|
10
10
|
import { DeferredTopicFilter } from 'ethers/contract'
|
|
11
|
+
import { EthEvent } from './eth-event.js'
|
|
11
12
|
|
|
12
13
|
export class ProcessorTemplateProcessorState extends ListStateStorage<
|
|
13
14
|
BaseProcessorTemplate<BaseContract, BoundContractView<BaseContract, any>>
|
|
@@ -36,7 +37,7 @@ export abstract class BaseProcessorTemplate<
|
|
|
36
37
|
fetchConfig?: EthFetchConfig
|
|
37
38
|
}[] = []
|
|
38
39
|
eventHandlers: {
|
|
39
|
-
handler: (event:
|
|
40
|
+
handler: (event: EthEvent, ctx: ContractContext<TContract, TBoundContractView>) => PromiseOrVoid
|
|
40
41
|
filter: DeferredTopicFilter | DeferredTopicFilter[]
|
|
41
42
|
fetchConfig?: EthFetchConfig
|
|
42
43
|
}[] = []
|
|
@@ -87,7 +88,7 @@ export abstract class BaseProcessorTemplate<
|
|
|
87
88
|
}
|
|
88
89
|
|
|
89
90
|
public onEvent(
|
|
90
|
-
handler: (event:
|
|
91
|
+
handler: (event: EthEvent, ctx: ContractContext<TContract, TBoundContractView>) => PromiseOrVoid,
|
|
91
92
|
filter: DeferredTopicFilter | DeferredTopicFilter[],
|
|
92
93
|
fetchConfig?: EthFetchConfig
|
|
93
94
|
) {
|
|
@@ -99,10 +100,6 @@ export abstract class BaseProcessorTemplate<
|
|
|
99
100
|
return this
|
|
100
101
|
}
|
|
101
102
|
|
|
102
|
-
public onBlock(handler: (block: Block, ctx: ContractContext<TContract, TBoundContractView>) => PromiseOrVoid) {
|
|
103
|
-
return this.onBlockInterval(handler)
|
|
104
|
-
}
|
|
105
|
-
|
|
106
103
|
public onBlockInterval(
|
|
107
104
|
handler: (block: Block, ctx: ContractContext<TContract, TBoundContractView>) => PromiseOrVoid,
|
|
108
105
|
blockInterval = 1000,
|
|
@@ -1,18 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
ContractEvent,
|
|
4
|
-
Log,
|
|
5
|
-
TransactionReceipt,
|
|
6
|
-
BytesLike,
|
|
7
|
-
BaseContract,
|
|
8
|
-
Transaction,
|
|
9
|
-
DeferredTopicFilter,
|
|
10
|
-
LogDescription,
|
|
11
|
-
EventFragment,
|
|
12
|
-
} from 'ethers'
|
|
13
|
-
import { EventFilter, LogParams, Network } from 'ethers/providers'
|
|
1
|
+
import { Block, TransactionReceipt, BaseContract, Transaction, DeferredTopicFilter } from 'ethers'
|
|
2
|
+
import { LogParams, Network } from 'ethers/providers'
|
|
14
3
|
|
|
15
|
-
import { BoundContractView, ContractContext, ContractView } from '../core/context'
|
|
4
|
+
import { BoundContractView, ContractContext, ContractView } from '../core/context.js'
|
|
16
5
|
import {
|
|
17
6
|
AddressType,
|
|
18
7
|
Data_EthBlock,
|
|
@@ -22,10 +11,11 @@ import {
|
|
|
22
11
|
HandleInterval,
|
|
23
12
|
ProcessResult,
|
|
24
13
|
} from '@sentio/protos'
|
|
25
|
-
import { BindInternalOptions, BindOptions } from '../core/bind-options'
|
|
26
|
-
import { PromiseOrVoid } from '../promise-or-void'
|
|
27
|
-
import { Trace } from './trace'
|
|
14
|
+
import { BindInternalOptions, BindOptions } from '../core/bind-options.js'
|
|
15
|
+
import { PromiseOrVoid } from '../promise-or-void.js'
|
|
16
|
+
import { Trace } from './trace.js'
|
|
28
17
|
import { ServerError, Status } from 'nice-grpc'
|
|
18
|
+
import { EthEvent } from './eth-event.js'
|
|
29
19
|
|
|
30
20
|
export interface AddressOrTypeEventFilter extends DeferredTopicFilter {
|
|
31
21
|
addressType?: AddressType
|
|
@@ -88,7 +78,7 @@ export abstract class BaseProcessor<
|
|
|
88
78
|
}
|
|
89
79
|
|
|
90
80
|
public onEvent(
|
|
91
|
-
handler: (event:
|
|
81
|
+
handler: (event: EthEvent, ctx: ContractContext<TContract, TBoundContractView>) => PromiseOrVoid,
|
|
92
82
|
filter: DeferredTopicFilter | DeferredTopicFilter[],
|
|
93
83
|
fetchConfig?: EthFetchConfig
|
|
94
84
|
) {
|
|
@@ -128,8 +118,10 @@ export abstract class BaseProcessor<
|
|
|
128
118
|
const logParam = log as any as { topics: Array<string>; data: string }
|
|
129
119
|
|
|
130
120
|
const parsed = contractView.rawContract.interface.parseLog(logParam)
|
|
121
|
+
|
|
131
122
|
if (parsed) {
|
|
132
|
-
|
|
123
|
+
const event: EthEvent = { ...log, args: parsed.args }
|
|
124
|
+
await handler(event, ctx)
|
|
133
125
|
return ctx.getProcessResult()
|
|
134
126
|
}
|
|
135
127
|
return ProcessResult.fromPartial({})
|
|
@@ -138,14 +130,10 @@ export abstract class BaseProcessor<
|
|
|
138
130
|
return this
|
|
139
131
|
}
|
|
140
132
|
|
|
141
|
-
public onBlock(handler: (block: Block, ctx: ContractContext<TContract, TBoundContractView>) => PromiseOrVoid) {
|
|
142
|
-
return this.onBlockInterval(handler)
|
|
143
|
-
}
|
|
144
|
-
|
|
145
133
|
public onBlockInterval(
|
|
146
134
|
handler: (block: Block, ctx: ContractContext<TContract, TBoundContractView>) => PromiseOrVoid,
|
|
147
|
-
blockInterval =
|
|
148
|
-
backfillBlockInterval =
|
|
135
|
+
blockInterval = 250,
|
|
136
|
+
backfillBlockInterval = 1000
|
|
149
137
|
) {
|
|
150
138
|
return this.onInterval(handler, undefined, {
|
|
151
139
|
recentInterval: blockInterval,
|
|
@@ -201,9 +189,7 @@ export abstract class BaseProcessor<
|
|
|
201
189
|
return this
|
|
202
190
|
}
|
|
203
191
|
|
|
204
|
-
public onAllEvents(
|
|
205
|
-
handler: (event: LogDescription, ctx: ContractContext<TContract, TBoundContractView>) => PromiseOrVoid
|
|
206
|
-
) {
|
|
192
|
+
public onAllEvents(handler: (event: EthEvent, ctx: ContractContext<TContract, TBoundContractView>) => PromiseOrVoid) {
|
|
207
193
|
const _filters: DeferredTopicFilter[] = []
|
|
208
194
|
const tmpContract = this.CreateBoundContractView()
|
|
209
195
|
|
package/src/eth/binds.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { BindOptions, getOptionsSignature } from '../core/bind-options'
|
|
2
|
-
import { ContractView } from '../core'
|
|
3
|
-
import { BaseProcessor } from './base-processor'
|
|
1
|
+
import { BindOptions, getOptionsSignature } from '../core/bind-options.js'
|
|
2
|
+
import { ContractView } from '../core/index.js'
|
|
3
|
+
import { BaseProcessor } from './base-processor.js'
|
|
4
4
|
import { Networkish, Network } from 'ethers/providers'
|
|
5
5
|
|
|
6
6
|
import { BaseContract } from 'ethers'
|
package/src/eth/eth-plugin.ts
CHANGED
|
@@ -15,9 +15,9 @@ import {
|
|
|
15
15
|
} from '@sentio/protos'
|
|
16
16
|
|
|
17
17
|
import { ServerError, Status } from 'nice-grpc'
|
|
18
|
-
import { ProcessorState } from './binds'
|
|
19
|
-
import { AccountProcessorState } from './account-processor-state'
|
|
20
|
-
import { ProcessorTemplateProcessorState, TemplateInstanceState } from './base-processor-template'
|
|
18
|
+
import { ProcessorState } from './binds.js'
|
|
19
|
+
import { AccountProcessorState } from './account-processor-state.js'
|
|
20
|
+
import { ProcessorTemplateProcessorState, TemplateInstanceState } from './base-processor-template.js'
|
|
21
21
|
|
|
22
22
|
export class EthPlugin extends Plugin {
|
|
23
23
|
name: string = 'EthPlugin'
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { BaseContract } from 'ethers'
|
|
2
|
-
import { BoundContractView, ContractView } from '../core/context'
|
|
3
|
-
import { BindOptions } from '../core/bind-options'
|
|
4
|
-
import { BaseProcessor } from './base-processor'
|
|
5
|
-
import { getProvider } from './provider'
|
|
6
|
-
import { addProcessor } from './binds'
|
|
2
|
+
import { BoundContractView, ContractView } from '../core/context.js'
|
|
3
|
+
import { BindOptions } from '../core/bind-options.js'
|
|
4
|
+
import { BaseProcessor } from './base-processor.js'
|
|
5
|
+
import { getProvider } from './provider.js'
|
|
6
|
+
import { addProcessor } from './binds.js'
|
|
7
7
|
|
|
8
8
|
export class GenericProcessor extends BaseProcessor<
|
|
9
9
|
BaseContract,
|
package/src/eth/index.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
export { BaseProcessor } from './base-processor'
|
|
2
|
-
export { GenericProcessor } from './generic-processor'
|
|
3
|
-
export { BaseProcessorTemplate } from './base-processor-template'
|
|
4
|
-
export { getProvider, DummyProvider } from './provider'
|
|
5
|
-
export type { TypedCallTrace, Trace } from './trace'
|
|
6
|
-
export { EthPlugin } from './eth-plugin'
|
|
1
|
+
export { BaseProcessor } from './base-processor.js'
|
|
2
|
+
export { GenericProcessor } from './generic-processor.js'
|
|
3
|
+
export { BaseProcessorTemplate } from './base-processor-template.js'
|
|
4
|
+
export { getProvider, DummyProvider } from './provider.js'
|
|
5
|
+
export type { TypedCallTrace, Trace } from './trace.js'
|
|
6
|
+
export { EthPlugin } from './eth-plugin.js'
|
|
7
|
+
|
|
8
|
+
export { getProcessor, addProcessor, getContractByABI, addContractByABI } from './binds.js'
|
package/src/index.ts
CHANGED
|
@@ -1,12 +1,10 @@
|
|
|
1
|
-
export { transformEtherError, EthersError } from './error'
|
|
2
|
-
|
|
3
|
-
export { getProcessor, addProcessor, getContractByABI, addContractByABI } from './eth/binds'
|
|
1
|
+
export { transformEtherError, EthersError } from './error.js'
|
|
4
2
|
|
|
5
3
|
// TODO maybe remove this
|
|
6
4
|
export * from '@sentio/protos'
|
|
7
5
|
|
|
8
|
-
export * from './core'
|
|
9
|
-
export * from './eth'
|
|
6
|
+
export * from './core/index.js'
|
|
7
|
+
export * from './eth/index.js'
|
|
10
8
|
|
|
11
|
-
export * from './utils/chain'
|
|
9
|
+
export * from './utils/chain.js'
|
|
12
10
|
// export * from './api'
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { EventDeclaration, Contract, getFullSignatureAsSymbolForEvent } from 'typechain'
|
|
2
|
-
import { getFullSignatureForEventPatched } from './types'
|
|
2
|
+
import { getFullSignatureForEventPatched } from './types.cjs'
|
|
3
3
|
import { generateEventInputs } from '@sentio/ethers-v6/dist/codegen/events'
|
|
4
4
|
|
|
5
5
|
export function generateEventHandler(event: EventDeclaration, contractName: string, includeArgTypes: boolean): string {
|
|
@@ -7,14 +7,15 @@ import {
|
|
|
7
7
|
|
|
8
8
|
import { reservedKeywords } from '@sentio/ethers-v6/dist/codegen/reserved-keywords'
|
|
9
9
|
import { getFullSignatureForEvent } from 'typechain/dist/utils/signatures'
|
|
10
|
-
import { codegenCallTraceTypes, generateCallHandlers } from './functions-handler'
|
|
11
|
-
import { generateEventFilters, generateEventHandlers } from './event-handler'
|
|
12
|
-
import { generateBoundViewFunctions, generateViewFunctions } from './view-function'
|
|
10
|
+
import { codegenCallTraceTypes, generateCallHandlers } from './functions-handler.cjs'
|
|
11
|
+
import { generateEventFilters, generateEventHandlers } from './event-handler.cjs'
|
|
12
|
+
import { generateBoundViewFunctions, generateViewFunctions } from './view-function.cjs'
|
|
13
13
|
|
|
14
14
|
export function codeGenIndex(contract: Contract): string {
|
|
15
15
|
return `
|
|
16
|
-
export * from '../internal/${contract.name.toLowerCase()}_processor'
|
|
17
|
-
export * from '../internal/${contract.name}'
|
|
16
|
+
export * from '../internal/${contract.name.toLowerCase()}_processor.js'
|
|
17
|
+
export * from '../internal/${contract.name}.js'
|
|
18
|
+
export * from './test-utils.js'
|
|
18
19
|
`
|
|
19
20
|
}
|
|
20
21
|
|
|
@@ -164,9 +165,9 @@ export class ${contract.name}ProcessorTemplate extends BaseProcessorTemplate<${c
|
|
|
164
165
|
'toBlockTag',
|
|
165
166
|
],
|
|
166
167
|
'@sentio/protos': ['EthFetchConfig'],
|
|
167
|
-
'./common': ['PromiseOrValue'],
|
|
168
|
-
'./index': [`${contract.name}`, `${contract.name}__factory`],
|
|
169
|
-
[`./${contract.name}`]: eventsImports.concat(uniqueStructImports),
|
|
168
|
+
'./common.js': ['PromiseOrValue'],
|
|
169
|
+
'./index.js': [`${contract.name}`, `${contract.name}__factory`],
|
|
170
|
+
[`./${contract.name}.js`]: eventsImports.concat(uniqueStructImports),
|
|
170
171
|
},
|
|
171
172
|
source
|
|
172
173
|
)
|
|
@@ -200,7 +201,7 @@ export function codeGenTestUtilsFile(contract: Contract): string {
|
|
|
200
201
|
const imports = createImportsForUsedIdentifiers(
|
|
201
202
|
{
|
|
202
203
|
'ethers/providers': ['LogParams'],
|
|
203
|
-
'.': [
|
|
204
|
+
'./index.js': [
|
|
204
205
|
`get${contract.name}Contract`,
|
|
205
206
|
...Object.values(contract.events).flatMap((events) => {
|
|
206
207
|
if (events.length === 1) {
|
|
@@ -2,10 +2,9 @@ import {
|
|
|
2
2
|
generateOutputComplexTypeAsArray,
|
|
3
3
|
generateOutputComplexTypesAsObject,
|
|
4
4
|
} from '@sentio/ethers-v6/dist/codegen/types'
|
|
5
|
-
import {
|
|
5
|
+
import { keccak_256 } from 'js-sha3'
|
|
6
6
|
import { FunctionDeclaration, getSignatureForFn } from 'typechain'
|
|
7
|
-
|
|
8
|
-
import { getFullSignatureAsSymbolForFunction } from './types'
|
|
7
|
+
import { getFullSignatureAsSymbolForFunction } from './types.cjs'
|
|
9
8
|
|
|
10
9
|
export function generateCallHandlers(fns: FunctionDeclaration[], contractName: string): string {
|
|
11
10
|
if (fns.length === 1) {
|
|
@@ -42,7 +41,7 @@ function generateCallHandler(fn: FunctionDeclaration, contractName: string, over
|
|
|
42
41
|
// utils.toUtf8Bytes(signature))
|
|
43
42
|
|
|
44
43
|
const test = new TextEncoder().encode(signature)
|
|
45
|
-
const sighash =
|
|
44
|
+
const sighash = "0x" + keccak_256(test).substring(0, 8)
|
|
46
45
|
|
|
47
46
|
return `
|
|
48
47
|
onCall${capitalizeFirstChar(overloadedName ?? fn.name)}(
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import Ethers from '@sentio/ethers-v6'
|
|
2
2
|
import { Config, extractAbi, extractDocumentation, FileDescription, parse, shortenFullJsonFilePath } from 'typechain'
|
|
3
3
|
import { dirname, join, relative } from 'path'
|
|
4
|
-
import { codeGenIndex, codeGenSentioFile, codeGenTestUtilsFile } from './file'
|
|
4
|
+
import { codeGenIndex, codeGenSentioFile, codeGenTestUtilsFile } from './file.cjs'
|
|
5
5
|
|
|
6
6
|
export default class EthersSentio extends Ethers {
|
|
7
7
|
constructor(config: Config) {
|
|
@@ -54,6 +54,9 @@ export default class EthersSentio extends Ethers {
|
|
|
54
54
|
if (file.path.endsWith('__factory.ts')) {
|
|
55
55
|
file.contents = '// @ts-nocheck\n' + file.contents
|
|
56
56
|
}
|
|
57
|
+
if (file.path.endsWith('factories/index.ts')) {
|
|
58
|
+
file.contents = file.contents.replaceAll("__factory'", "__factory.js'")
|
|
59
|
+
}
|
|
57
60
|
}
|
|
58
61
|
return files
|
|
59
62
|
}
|
|
File without changes
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// https://github.com/dethcrypto/TypeChain/blob/015abb28bd22826611051f27e0ec96a00f9a0b61/packages/target-ethers-v5/src/codegen/functions.ts#L54
|
|
2
2
|
import { FunctionDeclaration } from 'typechain'
|
|
3
3
|
import { generateInputTypes, generateOutputTypes } from '@sentio/ethers-v6/dist/codegen/types'
|
|
4
|
-
import { getFullSignatureAsSymbolForFunction, getFullSignatureForFunction } from './types'
|
|
4
|
+
import { getFullSignatureAsSymbolForFunction, getFullSignatureForFunction } from './types.cjs'
|
|
5
5
|
|
|
6
6
|
function generateReturnTypes(fn: FunctionDeclaration) {
|
|
7
7
|
// sounds like returnResultObject should be true but we need to set false to make it work
|
package/src/testing/index.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { TestProcessorServer } from './test-processor-server'
|
|
2
|
-
export { MetricValueToNumber, firstCounterValue, firstGaugeValue } from './metric-utils'
|
|
1
|
+
export { TestProcessorServer } from './test-processor-server.js'
|
|
2
|
+
export { MetricValueToNumber, firstCounterValue, firstGaugeValue } from './metric-utils.js'
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
export { loadTestProvidersFromEnv } from './test-provider.js' // TODO make the interface more standard and then export
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { MetricValue, ProcessResult } from '@sentio/protos'
|
|
2
|
-
import { Numberish, BigDecimal } from '../core'
|
|
3
|
-
import { bytesToBigInt } from '../utils/conversion'
|
|
2
|
+
import { Numberish, BigDecimal } from '../core/index.js'
|
|
3
|
+
import { bytesToBigInt } from '../utils/conversion.js'
|
|
4
4
|
|
|
5
5
|
export function MetricValueToNumber(v: Partial<MetricValue> | undefined): Numberish | undefined {
|
|
6
6
|
if (v === undefined) {
|
|
@@ -10,13 +10,13 @@ import {
|
|
|
10
10
|
ProcessConfigResponse,
|
|
11
11
|
ProcessorServiceImplementation,
|
|
12
12
|
StartRequest,
|
|
13
|
+
Empty,
|
|
13
14
|
} from '@sentio/protos'
|
|
14
15
|
import { CallContext } from 'nice-grpc-common'
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import { CHAIN_MAP } from '../utils/chain'
|
|
16
|
+
import { ProcessorServiceImpl, Endpoints, State } from '@sentio/runtime'
|
|
17
|
+
import { CHAIN_MAP } from '../utils/chain.js'
|
|
18
18
|
|
|
19
|
-
import { Trace } from '../eth/trace'
|
|
19
|
+
import { Trace } from '../eth/trace.js'
|
|
20
20
|
import { LogParams, Networkish, BlockParams, Network } from 'ethers/providers'
|
|
21
21
|
|
|
22
22
|
import { Block, Log } from 'ethers'
|
|
@@ -33,7 +33,7 @@ export class TestProcessorServer implements ProcessorServiceImplementation {
|
|
|
33
33
|
contractConfigs: ContractConfig[]
|
|
34
34
|
accountConfigs: AccountConfig[]
|
|
35
35
|
|
|
36
|
-
constructor(loader: () =>
|
|
36
|
+
constructor(loader: () => Promise<any>, httpEndpoints: Record<string, string> = {}) {
|
|
37
37
|
cleanTest()
|
|
38
38
|
|
|
39
39
|
this.service = new ProcessorServiceImpl(loader)
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { defineConfig } from 'tsup'
|
|
2
|
+
|
|
3
|
+
export default defineConfig({
|
|
4
|
+
esbuildOptions: (options) => {
|
|
5
|
+
options.banner = {
|
|
6
|
+
js: `import { createRequire } from 'module'; const require = createRequire(import.meta.url);`,
|
|
7
|
+
}
|
|
8
|
+
},
|
|
9
|
+
entry: {
|
|
10
|
+
lib: 'src/processor.ts',
|
|
11
|
+
},
|
|
12
|
+
minify: true,
|
|
13
|
+
sourcemap: 'inline',
|
|
14
|
+
clean: true,
|
|
15
|
+
format: 'esm',
|
|
16
|
+
external: [
|
|
17
|
+
'protobufjs',
|
|
18
|
+
'aptos',
|
|
19
|
+
'aptos-sdk',
|
|
20
|
+
'ethers',
|
|
21
|
+
'bs58',
|
|
22
|
+
'bn.js',
|
|
23
|
+
'csv-parse',
|
|
24
|
+
/^nice-grpc.*$/,
|
|
25
|
+
/^@(ethersproject|solana|project-serum).*$/,
|
|
26
|
+
/^@sentio\/(sdk|runtime|protos|bigdecimal|ethers).*$/,
|
|
27
|
+
],
|
|
28
|
+
})
|
package/src/utils/conversion.ts
CHANGED
|
@@ -1,10 +1,6 @@
|
|
|
1
|
-
import { BigDecimal } from '../core/big-decimal'
|
|
2
|
-
import { Numberish } from '../core'
|
|
3
|
-
import { MetricValue } from '@sentio/protos'
|
|
4
|
-
|
|
5
|
-
export function toBigDecimal(n: bigint) {
|
|
6
|
-
return new BigDecimal(n.toString())
|
|
7
|
-
}
|
|
1
|
+
// import { BigDecimal } from '../core/big-decimal.js'
|
|
2
|
+
// import { Numberish } from '../core/index.js'
|
|
3
|
+
// import { MetricValue } from '@sentio/protos'
|
|
8
4
|
|
|
9
5
|
export function bytesToBigInt(bytes: Uint8Array) {
|
|
10
6
|
let intValue = BigInt(0)
|
|
@@ -14,21 +10,21 @@ export function bytesToBigInt(bytes: Uint8Array) {
|
|
|
14
10
|
return intValue
|
|
15
11
|
}
|
|
16
12
|
|
|
17
|
-
export function metricValueToNumberish(v: MetricValue): Numberish {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
}
|
|
13
|
+
// export function metricValueToNumberish(v: MetricValue): Numberish {
|
|
14
|
+
// if (v.doubleValue) {
|
|
15
|
+
// return v.doubleValue
|
|
16
|
+
// }
|
|
17
|
+
// if (v.bigInteger) {
|
|
18
|
+
// let intValue = bytesToBigInt(v.bigInteger.data)
|
|
19
|
+
// if (v.bigInteger.negative) {
|
|
20
|
+
// intValue = -intValue
|
|
21
|
+
// }
|
|
22
|
+
// return intValue
|
|
23
|
+
// }
|
|
24
|
+
//
|
|
25
|
+
// if (v.bigDecimal) {
|
|
26
|
+
// return new BigDecimal(v.bigDecimal)
|
|
27
|
+
// }
|
|
28
|
+
//
|
|
29
|
+
// throw Error("MetricValue doesn't contain any of possible value")
|
|
30
|
+
// }
|