@sentio/sdk 1.0.0-development → 1.0.0-rc.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +55 -0
- package/lib/aptos/api.d.ts +2 -0
- package/lib/aptos/api.js +14 -0
- package/lib/aptos/api.js.map +1 -0
- package/lib/aptos/aptos-plugin.d.ts +14 -0
- package/lib/aptos/aptos-plugin.js +190 -0
- package/lib/aptos/aptos-plugin.js.map +1 -0
- package/lib/aptos/aptos-processor.d.ts +75 -0
- package/lib/aptos/aptos-processor.js +193 -0
- package/lib/aptos/aptos-processor.js.map +1 -0
- package/lib/aptos/context.d.ts +22 -0
- package/lib/aptos/context.js +69 -0
- package/lib/aptos/context.js.map +1 -0
- package/lib/aptos/index.d.ts +9 -0
- package/lib/aptos/index.js +34 -0
- package/lib/aptos/index.js.map +1 -0
- package/lib/aptos/models.d.ts +23 -0
- package/lib/aptos/models.js +3 -0
- package/lib/aptos/models.js.map +1 -0
- package/lib/aptos/network.d.ts +14 -0
- package/lib/aptos/network.js +46 -0
- package/lib/aptos/network.js.map +1 -0
- package/lib/aptos/runtime.d.ts +2 -0
- package/lib/aptos/runtime.js +16 -0
- package/lib/aptos/runtime.js.map +1 -0
- package/lib/aptos/type-registry.d.ts +21 -0
- package/lib/aptos/type-registry.js +156 -0
- package/lib/aptos/type-registry.js.map +1 -0
- package/lib/aptos/types.d.ts +9 -0
- package/lib/aptos/types.js +135 -0
- package/lib/aptos/types.js.map +1 -0
- package/{dist/numberish.test.d.ts → lib/aptos/types.test.d.ts} +0 -0
- package/lib/aptos/types.test.js.map +1 -0
- package/lib/aptos/utils.d.ts +7 -0
- package/lib/aptos/utils.js +27 -0
- package/lib/aptos/utils.js.map +1 -0
- package/lib/aptos-codegen/codegen.d.ts +23 -0
- package/lib/aptos-codegen/codegen.js +364 -0
- package/lib/aptos-codegen/codegen.js.map +1 -0
- package/lib/aptos-codegen/typegen.d.ts +17 -0
- package/lib/aptos-codegen/typegen.js +142 -0
- package/lib/aptos-codegen/typegen.js.map +1 -0
- package/lib/binds.d.ts +12 -0
- package/lib/binds.js +38 -0
- package/lib/binds.js.map +1 -0
- package/lib/builtin/aptos/0x1.d.ts +1913 -0
- package/lib/builtin/aptos/0x1.js +2748 -0
- package/lib/builtin/aptos/0x1.js.map +1 -0
- package/lib/builtin/aptos/0x3.d.ts +482 -0
- package/lib/builtin/aptos/0x3.js +526 -0
- package/lib/builtin/aptos/0x3.js.map +1 -0
- package/lib/builtin/aptos/index.d.ts +2 -0
- package/{dist/builtin/internal → lib/builtin/aptos}/index.js +3 -4
- package/lib/builtin/aptos/index.js.map +1 -0
- package/lib/builtin/eacaggregatorproxy/index.d.ts +2 -0
- package/lib/builtin/eacaggregatorproxy/index.js +22 -0
- package/lib/builtin/eacaggregatorproxy/index.js.map +1 -0
- package/lib/builtin/eacaggregatorproxy/test-utils.d.ts +6 -0
- package/lib/builtin/eacaggregatorproxy/test-utils.js +57 -0
- package/lib/builtin/eacaggregatorproxy/test-utils.js.map +1 -0
- package/lib/builtin/erc1155/index.d.ts +2 -0
- package/lib/builtin/erc1155/index.js +22 -0
- package/lib/builtin/erc1155/index.js.map +1 -0
- package/lib/builtin/erc1155/test-utils.d.ts +6 -0
- package/lib/builtin/erc1155/test-utils.js +57 -0
- package/lib/builtin/erc1155/test-utils.js.map +1 -0
- package/{dist → lib}/builtin/erc20/index.d.ts +1 -1
- package/{dist → lib}/builtin/erc20/index.js +1 -1
- package/lib/builtin/erc20/index.js.map +1 -0
- package/lib/builtin/erc20/test-utils.d.ts +5 -0
- package/lib/builtin/erc20/test-utils.js +46 -0
- package/lib/builtin/erc20/test-utils.js.map +1 -0
- package/lib/builtin/erc20bytes/index.d.ts +2 -0
- package/lib/builtin/erc20bytes/index.js +22 -0
- package/lib/builtin/erc20bytes/index.js.map +1 -0
- package/lib/builtin/erc20bytes/test-utils.d.ts +4 -0
- package/lib/builtin/erc20bytes/test-utils.js +35 -0
- package/lib/builtin/erc20bytes/test-utils.js.map +1 -0
- package/lib/builtin/erc721/index.d.ts +2 -0
- package/lib/builtin/erc721/index.js +22 -0
- package/lib/builtin/erc721/index.js.map +1 -0
- package/lib/builtin/erc721/test-utils.d.ts +5 -0
- package/lib/builtin/erc721/test-utils.js +46 -0
- package/lib/builtin/erc721/test-utils.js.map +1 -0
- package/lib/builtin/index.d.ts +6 -0
- package/lib/builtin/index.js +33 -0
- package/lib/builtin/index.js.map +1 -0
- package/lib/builtin/internal/EACAggregatorProxy.d.ts +460 -0
- package/lib/builtin/internal/EACAggregatorProxy.js +3 -0
- package/lib/builtin/internal/EACAggregatorProxy.js.map +1 -0
- package/lib/builtin/internal/ERC1155.d.ts +199 -0
- package/lib/builtin/internal/ERC1155.js +3 -0
- package/lib/builtin/internal/ERC1155.js.map +1 -0
- package/lib/builtin/internal/ERC20.d.ts +307 -0
- package/{dist/builtin/internal/Erc20.js → lib/builtin/internal/ERC20.js} +1 -1
- package/lib/builtin/internal/ERC20.js.map +1 -0
- package/{dist/builtin/internal/Erc20.d.ts → lib/builtin/internal/ERC20Bytes.d.ts} +62 -46
- package/lib/builtin/internal/ERC20Bytes.js +3 -0
- package/lib/builtin/internal/ERC20Bytes.js.map +1 -0
- package/lib/builtin/internal/ERC721.d.ts +252 -0
- package/lib/builtin/internal/ERC721.js +3 -0
- package/lib/builtin/internal/ERC721.js.map +1 -0
- package/lib/builtin/internal/WETH9.d.ts +221 -0
- package/lib/builtin/internal/WETH9.js +3 -0
- package/lib/builtin/internal/WETH9.js.map +1 -0
- package/{dist → lib}/builtin/internal/common.d.ts +0 -0
- package/{dist → lib}/builtin/internal/common.js +0 -0
- package/lib/builtin/internal/common.js.map +1 -0
- package/lib/builtin/internal/eacaggregatorproxy_processor.d.ts +294 -0
- package/lib/builtin/internal/eacaggregatorproxy_processor.js +761 -0
- package/lib/builtin/internal/eacaggregatorproxy_processor.js.map +1 -0
- package/lib/builtin/internal/erc1155_processor.d.ts +126 -0
- package/lib/builtin/internal/erc1155_processor.js +313 -0
- package/lib/builtin/internal/erc1155_processor.js.map +1 -0
- package/lib/builtin/internal/erc20_processor.d.ts +166 -0
- package/lib/builtin/internal/erc20_processor.js +418 -0
- package/lib/builtin/internal/erc20_processor.js.map +1 -0
- package/lib/builtin/internal/erc20bytes_processor.d.ts +101 -0
- package/lib/builtin/internal/erc20bytes_processor.js +311 -0
- package/lib/builtin/internal/erc20bytes_processor.js.map +1 -0
- package/lib/builtin/internal/erc721_processor.d.ts +155 -0
- package/lib/builtin/internal/erc721_processor.js +437 -0
- package/lib/builtin/internal/erc721_processor.js.map +1 -0
- package/lib/builtin/internal/factories/EACAggregatorProxy__factory.d.ts +46 -0
- package/lib/builtin/internal/factories/EACAggregatorProxy__factory.js +528 -0
- package/lib/builtin/internal/factories/EACAggregatorProxy__factory.js.map +1 -0
- package/{dist/builtin/internal/factories/Erc20__factory.d.ts → lib/builtin/internal/factories/ERC1155__factory.d.ts} +4 -4
- package/lib/builtin/internal/factories/ERC1155__factory.js +333 -0
- package/lib/builtin/internal/factories/ERC1155__factory.js.map +1 -0
- package/lib/builtin/internal/factories/ERC20Bytes__factory.d.ts +48 -0
- package/{dist/builtin/internal/factories/Erc20__factory.js → lib/builtin/internal/factories/ERC20Bytes__factory.js} +128 -89
- package/lib/builtin/internal/factories/ERC20Bytes__factory.js.map +1 -0
- package/lib/builtin/internal/factories/ERC20__factory.d.ts +42 -0
- package/lib/builtin/internal/factories/ERC20__factory.js +405 -0
- package/lib/builtin/internal/factories/ERC20__factory.js.map +1 -0
- package/lib/builtin/internal/factories/ERC721__factory.d.ts +51 -0
- package/lib/builtin/internal/factories/ERC721__factory.js +365 -0
- package/lib/builtin/internal/factories/ERC721__factory.js.map +1 -0
- package/lib/builtin/internal/factories/WETH9__factory.d.ts +45 -0
- package/lib/builtin/internal/factories/WETH9__factory.js +298 -0
- package/lib/builtin/internal/factories/WETH9__factory.js.map +1 -0
- package/lib/builtin/internal/factories/index.d.ts +6 -0
- package/lib/builtin/internal/factories/index.js +19 -0
- package/lib/builtin/internal/factories/index.js.map +1 -0
- package/lib/builtin/internal/index.d.ts +13 -0
- package/lib/builtin/internal/index.js +40 -0
- package/lib/builtin/internal/index.js.map +1 -0
- package/lib/builtin/internal/weth9_processor.d.ts +115 -0
- package/lib/builtin/internal/weth9_processor.js +353 -0
- package/lib/builtin/internal/weth9_processor.js.map +1 -0
- package/lib/builtin/solana/index.d.ts +2 -0
- package/lib/builtin/solana/index.js +19 -0
- package/lib/builtin/solana/index.js.map +1 -0
- package/lib/builtin/solana/spl-token-processor.d.ts +39 -0
- package/lib/builtin/solana/spl-token-processor.js +258 -0
- package/lib/builtin/solana/spl-token-processor.js.map +1 -0
- package/lib/builtin/solana/types.d.ts +427 -0
- package/lib/builtin/solana/types.js +203 -0
- package/lib/builtin/solana/types.js.map +1 -0
- package/lib/builtin/solana/wormhole-processor.d.ts +16 -0
- package/{dist/test-case/types/wormhole_processor.js → lib/builtin/solana/wormhole-processor.js} +57 -54
- package/lib/builtin/solana/wormhole-processor.js.map +1 -0
- package/lib/builtin/weth9/index.d.ts +2 -0
- package/lib/builtin/weth9/index.js +22 -0
- package/lib/builtin/weth9/index.js.map +1 -0
- package/lib/builtin/weth9/test-utils.d.ts +6 -0
- package/lib/builtin/weth9/test-utils.js +57 -0
- package/lib/builtin/weth9/test-utils.js.map +1 -0
- package/lib/chain-config.d.ts +6 -0
- package/lib/chain-config.js +3 -0
- package/lib/chain-config.js.map +1 -0
- package/lib/core/account-processor.d.ts +58 -0
- package/lib/core/account-processor.js +147 -0
- package/lib/core/account-processor.js.map +1 -0
- package/lib/core/base-context.d.ts +12 -0
- package/lib/core/base-context.js +25 -0
- package/lib/core/base-context.js.map +1 -0
- package/lib/core/base-processor-template.d.ts +42 -0
- package/{dist → lib/core}/base-processor-template.js +32 -6
- package/lib/core/base-processor-template.js.map +1 -0
- package/lib/core/base-processor.d.ts +39 -0
- package/lib/core/base-processor.js +153 -0
- package/lib/core/base-processor.js.map +1 -0
- package/lib/core/big-decimal.d.ts +1 -0
- package/lib/core/big-decimal.js +6 -0
- package/lib/core/big-decimal.js.map +1 -0
- package/{dist → lib/core}/bind-options.d.ts +5 -0
- package/{dist → lib/core}/bind-options.js +10 -1
- package/lib/core/bind-options.js.map +1 -0
- package/lib/core/context.d.ts +55 -0
- package/lib/core/context.js +162 -0
- package/lib/core/context.js.map +1 -0
- package/lib/core/eth-plugin.d.ts +14 -0
- package/lib/core/eth-plugin.js +221 -0
- package/lib/core/eth-plugin.js.map +1 -0
- package/lib/core/event-tracker.d.ts +26 -0
- package/lib/core/event-tracker.js +54 -0
- package/lib/core/event-tracker.js.map +1 -0
- package/lib/core/exporter.d.ts +13 -0
- package/lib/core/exporter.js +30 -0
- package/lib/core/exporter.js.map +1 -0
- package/lib/core/generic-processor.d.ts +10 -0
- package/lib/core/generic-processor.js +32 -0
- package/lib/core/generic-processor.js.map +1 -0
- package/{dist/test-case/erc20-template.test.d.ts → lib/core/generic-processor.test.d.ts} +0 -0
- package/lib/core/generic-processor.test.js.map +1 -0
- package/lib/core/index.d.ts +17 -0
- package/lib/core/index.js +46 -0
- package/lib/core/index.js.map +1 -0
- package/lib/core/logger.d.ts +14 -0
- package/lib/core/logger.js +42 -0
- package/lib/core/logger.js.map +1 -0
- package/lib/core/metadata.d.ts +7 -0
- package/lib/core/metadata.js +12 -0
- package/lib/core/metadata.js.map +1 -0
- package/lib/core/meter.d.ts +59 -0
- package/lib/core/meter.js +166 -0
- package/lib/core/meter.js.map +1 -0
- package/{dist/test-case/erc20.test.d.ts → lib/core/meter.test.d.ts} +0 -0
- package/lib/core/meter.test.js.map +1 -0
- package/lib/core/numberish.d.ts +8 -0
- package/lib/core/numberish.js +115 -0
- package/lib/core/numberish.js.map +1 -0
- package/{dist/test-case/mirrorworld.d.ts → lib/core/numberish.test.d.ts} +0 -0
- package/lib/core/numberish.test.js.map +1 -0
- package/lib/core/solana-context.d.ts +12 -0
- package/lib/core/solana-context.js +34 -0
- package/lib/core/solana-context.js.map +1 -0
- package/lib/core/solana-options.d.ts +9 -0
- package/lib/core/solana-options.js +13 -0
- package/lib/core/solana-options.js.map +1 -0
- package/lib/core/solana-plugin.d.ts +9 -0
- package/lib/core/solana-plugin.js +79 -0
- package/lib/core/solana-plugin.js.map +1 -0
- package/lib/core/solana-processor.d.ts +41 -0
- package/lib/core/solana-processor.js +90 -0
- package/lib/core/solana-processor.js.map +1 -0
- package/lib/core/sui-plugin.d.ts +8 -0
- package/lib/core/sui-plugin.js +46 -0
- package/lib/core/sui-plugin.js.map +1 -0
- package/lib/core/sui-processor.d.ts +26 -0
- package/lib/core/sui-processor.js +59 -0
- package/lib/core/sui-processor.js.map +1 -0
- package/lib/core/trace.d.ts +35 -0
- package/lib/core/trace.js +43 -0
- package/lib/core/trace.js.map +1 -0
- package/lib/endpoints.d.ts +6 -0
- package/lib/endpoints.js +11 -0
- package/lib/endpoints.js.map +1 -0
- package/lib/error.d.ts +7 -0
- package/lib/error.js +43 -0
- package/lib/error.js.map +1 -0
- package/{dist → lib}/gen/builtin.d.ts +0 -0
- package/{dist → lib}/gen/builtin.js +0 -0
- package/lib/gen/builtin.js.map +1 -0
- package/lib/gen/chainquery/protos/chainquery.d.ts +400 -0
- package/lib/gen/chainquery/protos/chainquery.js +972 -0
- package/lib/gen/chainquery/protos/chainquery.js.map +1 -0
- package/{dist → lib}/gen/google/protobuf/empty.d.ts +0 -0
- package/{dist → lib}/gen/google/protobuf/empty.js +0 -0
- package/lib/gen/google/protobuf/empty.js.map +1 -0
- package/lib/gen/google/protobuf/struct.d.ts +73 -0
- package/lib/gen/google/protobuf/struct.js +371 -0
- package/lib/gen/google/protobuf/struct.js.map +1 -0
- package/lib/gen/google/protobuf/timestamp.d.ts +18 -0
- package/lib/gen/google/protobuf/timestamp.js +71 -0
- package/lib/gen/google/protobuf/timestamp.js.map +1 -0
- package/lib/gen/index.d.ts +2 -0
- package/lib/gen/index.js +19 -0
- package/lib/gen/index.js.map +1 -0
- package/lib/gen/processor/protos/processor.d.ts +826 -0
- package/lib/gen/processor/protos/processor.js +3988 -0
- package/lib/gen/processor/protos/processor.js.map +1 -0
- package/lib/gen/service/price/protos/price.d.ts +85 -0
- package/lib/gen/service/price/protos/price.js +269 -0
- package/lib/gen/service/price/protos/price.js.map +1 -0
- package/lib/index.d.ts +7 -0
- package/lib/index.js +48 -0
- package/lib/index.js.map +1 -0
- package/lib/loader.d.ts +5 -0
- package/lib/loader.js +30 -0
- package/lib/loader.js.map +1 -0
- package/lib/plugin.d.ts +15 -0
- package/lib/plugin.js +32 -0
- package/lib/plugin.js.map +1 -0
- package/{dist → lib}/processor-runner.d.ts +0 -0
- package/lib/processor-runner.js +102 -0
- package/lib/processor-runner.js.map +1 -0
- package/lib/promise-or-void.d.ts +1 -0
- package/lib/promise-or-void.js +3 -0
- package/lib/promise-or-void.js.map +1 -0
- package/{dist → lib}/provider.d.ts +2 -1
- package/{dist → lib}/provider.js +19 -9
- package/lib/provider.js.map +1 -0
- package/lib/service.d.ts +26 -0
- package/lib/service.js +225 -0
- package/lib/service.js.map +1 -0
- package/lib/solana-codegen/codegen.d.ts +1 -0
- package/lib/solana-codegen/codegen.js +113 -0
- package/lib/solana-codegen/codegen.js.map +1 -0
- package/lib/state/processor-state.d.ts +3 -0
- package/lib/state/processor-state.js +8 -0
- package/lib/state/processor-state.js.map +1 -0
- package/lib/state/state-storage.d.ts +17 -0
- package/lib/state/state-storage.js +60 -0
- package/lib/state/state-storage.js.map +1 -0
- package/{dist/test-case/solana.test.d.ts → lib/state/state-storage.test.d.ts} +0 -0
- package/lib/state/state-storage.test.js.map +1 -0
- package/lib/target-ethers-sentio/event-handler.d.ts +3 -0
- package/lib/target-ethers-sentio/event-handler.js +35 -0
- package/lib/target-ethers-sentio/event-handler.js.map +1 -0
- package/{dist/target-ethers-sentio/codegen.d.ts → lib/target-ethers-sentio/file.d.ts} +1 -0
- package/lib/target-ethers-sentio/file.js +226 -0
- package/lib/target-ethers-sentio/file.js.map +1 -0
- package/lib/target-ethers-sentio/functions-handler.d.ts +3 -0
- package/lib/target-ethers-sentio/functions-handler.js +50 -0
- package/lib/target-ethers-sentio/functions-handler.js.map +1 -0
- package/{dist → lib}/target-ethers-sentio/index.d.ts +1 -0
- package/{dist → lib}/target-ethers-sentio/index.js +16 -3
- package/{dist → lib}/target-ethers-sentio/index.js.map +1 -1
- package/lib/target-ethers-sentio/types.d.ts +4 -0
- package/lib/target-ethers-sentio/types.js +46 -0
- package/lib/target-ethers-sentio/types.js.map +1 -0
- package/lib/target-ethers-sentio/view-function.d.ts +5 -0
- package/lib/target-ethers-sentio/view-function.js +74 -0
- package/lib/target-ethers-sentio/view-function.js.map +1 -0
- package/{dist/cli/cli.d.ts → lib/test-abi-code-gen.d.ts} +0 -0
- package/lib/test-abi-code-gen.js +20 -0
- package/lib/test-abi-code-gen.js.map +1 -0
- package/lib/testing/index.d.ts +2 -0
- package/lib/testing/index.js +11 -0
- package/lib/testing/index.js.map +1 -0
- package/lib/testing/metric-utils.d.ts +5 -0
- package/lib/testing/metric-utils.js +50 -0
- package/lib/testing/metric-utils.js.map +1 -0
- package/lib/testing/test-processor-server.d.ts +42 -0
- package/lib/testing/test-processor-server.js +293 -0
- package/lib/testing/test-processor-server.js.map +1 -0
- package/lib/testing/test-provider.d.ts +1 -0
- package/lib/testing/test-provider.js +33 -0
- package/lib/testing/test-provider.js.map +1 -0
- package/lib/utils/chain.d.ts +89 -0
- package/lib/utils/chain.js +128 -0
- package/lib/utils/chain.js.map +1 -0
- package/lib/utils/chainlink-oracles-goerli.csv +8 -0
- package/lib/utils/chainlink-oracles.csv +217 -0
- package/lib/utils/conversion.d.ts +6 -0
- package/lib/utils/conversion.js +27 -0
- package/lib/utils/conversion.js.map +1 -0
- package/lib/utils/dex-price.d.ts +22 -0
- package/lib/utils/dex-price.js +114 -0
- package/lib/utils/dex-price.js.map +1 -0
- package/{dist/test-case/wormhole-token-bridge.d.ts → lib/utils/dex-price.test.d.ts} +0 -0
- package/lib/utils/dex-price.test.js.map +1 -0
- package/lib/utils/erc20.test.d.ts +1 -0
- package/lib/utils/erc20.test.js.map +1 -0
- package/lib/utils/index.d.ts +4 -0
- package/lib/utils/index.js +31 -0
- package/lib/utils/index.js.map +1 -0
- package/lib/utils/price.d.ts +52 -0
- package/lib/utils/price.js +86 -0
- package/lib/utils/price.js.map +1 -0
- package/lib/utils/token.d.ts +15 -0
- package/lib/utils/token.js +60 -0
- package/lib/utils/token.js.map +1 -0
- package/package.json +43 -42
- package/src/abis/EACAggregatorProxy.json +227 -0
- package/src/abis/ERC1155.json +314 -0
- package/src/abis/ERC20.json +174 -0
- package/src/abis/ERC20Bytes.json +236 -0
- package/src/abis/ERC721.json +346 -0
- package/src/abis/WETH9.json +153 -0
- package/src/abis/aptos/0x1.json +9205 -0
- package/src/abis/aptos/0x3.json +1515 -0
- package/src/aptos/api.ts +11 -0
- package/src/aptos/aptos-plugin.ts +217 -0
- package/src/aptos/aptos-processor.ts +305 -0
- package/src/aptos/context.ts +75 -0
- package/src/aptos/index.ts +10 -0
- package/src/aptos/models.ts +34 -0
- package/src/aptos/network.ts +42 -0
- package/src/aptos/runtime.ts +13 -0
- package/src/aptos/type-registry.ts +187 -0
- package/src/aptos/types.ts +149 -0
- package/src/aptos/utils.ts +26 -0
- package/src/aptos-codegen/codegen.ts +428 -0
- package/src/aptos-codegen/tsconfig.json +9 -0
- package/src/aptos-codegen/typegen.ts +153 -0
- package/src/binds.ts +45 -0
- package/src/builtin/aptos/0x1.ts +4210 -0
- package/src/builtin/aptos/0x3.ts +888 -0
- package/src/builtin/aptos/index.ts +2 -0
- package/src/builtin/eacaggregatorproxy/index.ts +6 -0
- package/src/builtin/eacaggregatorproxy/test-utils.ts +89 -0
- package/src/builtin/erc1155/index.ts +6 -0
- package/src/builtin/erc1155/test-utils.ts +89 -0
- package/src/builtin/erc20/index.ts +6 -0
- package/src/builtin/erc20/test-utils.ts +71 -0
- package/src/builtin/erc20bytes/index.ts +6 -0
- package/src/builtin/erc20bytes/test-utils.ts +53 -0
- package/src/builtin/erc721/index.ts +6 -0
- package/src/builtin/erc721/test-utils.ts +71 -0
- package/src/builtin/index.ts +7 -0
- package/src/builtin/internal/EACAggregatorProxy.ts +861 -0
- package/src/builtin/internal/ERC1155.ts +529 -0
- package/src/builtin/internal/ERC20.ts +679 -0
- package/src/builtin/internal/ERC20Bytes.ts +384 -0
- package/src/builtin/internal/ERC721.ts +639 -0
- package/src/builtin/internal/WETH9.ts +480 -0
- package/src/builtin/internal/common.ts +46 -0
- package/src/builtin/internal/eacaggregatorproxy_processor.ts +1219 -0
- package/src/builtin/internal/erc1155_processor.ts +534 -0
- package/src/builtin/internal/erc20_processor.ts +663 -0
- package/src/builtin/internal/erc20bytes_processor.ts +474 -0
- package/src/builtin/internal/erc721_processor.ts +686 -0
- package/src/builtin/internal/factories/EACAggregatorProxy__factory.ts +534 -0
- package/src/builtin/internal/factories/ERC1155__factory.ts +336 -0
- package/src/builtin/internal/factories/ERC20Bytes__factory.ts +258 -0
- package/src/builtin/internal/factories/ERC20__factory.ts +405 -0
- package/src/builtin/internal/factories/ERC721__factory.ts +365 -0
- package/src/builtin/internal/factories/WETH9__factory.ts +298 -0
- package/src/builtin/internal/factories/index.ts +9 -0
- package/src/builtin/internal/index.ts +16 -0
- package/src/builtin/internal/weth9_processor.ts +536 -0
- package/src/builtin/solana/index.ts +2 -0
- package/src/builtin/solana/spl-token-processor.ts +298 -0
- package/src/builtin/solana/types.ts +279 -0
- package/src/builtin/solana/wormhole-processor.ts +178 -0
- package/src/builtin/weth9/index.ts +6 -0
- package/src/builtin/weth9/test-utils.ts +89 -0
- package/src/chain-config.ts +6 -0
- package/src/core/account-processor.ts +217 -0
- package/src/core/base-context.ts +28 -0
- package/src/core/base-processor-template.ts +150 -0
- package/src/core/base-processor.ts +217 -0
- package/src/core/big-decimal.ts +1 -0
- package/src/core/bind-options.ts +45 -0
- package/src/core/context.ts +183 -0
- package/src/core/eth-plugin.ts +255 -0
- package/src/core/event-tracker.ts +69 -0
- package/src/core/exporter.ts +32 -0
- package/src/core/generic-processor.ts +34 -0
- package/src/core/index.ts +22 -0
- package/src/core/logger.ts +49 -0
- package/src/core/metadata.ts +11 -0
- package/src/core/meter.ts +179 -0
- package/src/core/numberish.ts +121 -0
- package/src/core/solana-context.ts +35 -0
- package/src/core/solana-options.ts +10 -0
- package/src/core/solana-plugin.ts +97 -0
- package/src/core/solana-processor.ts +109 -0
- package/src/core/sui-plugin.ts +54 -0
- package/src/core/sui-processor.ts +65 -0
- package/src/core/trace.ts +86 -0
- package/src/endpoints.ts +9 -0
- package/src/error.ts +45 -0
- package/src/gen/builtin.ts +22 -0
- package/src/gen/chainquery/protos/chainquery.ts +1212 -0
- package/src/gen/google/protobuf/empty.ts +58 -0
- package/src/gen/google/protobuf/struct.ts +422 -0
- package/src/gen/google/protobuf/timestamp.ts +85 -0
- package/src/gen/index.ts +3 -0
- package/src/gen/processor/protos/processor.ts +4619 -0
- package/src/gen/service/price/protos/price.ts +329 -0
- package/src/index.ts +13 -0
- package/src/loader.ts +24 -0
- package/src/plugin.ts +41 -0
- package/src/processor-runner.ts +93 -0
- package/src/promise-or-void.ts +1 -0
- package/src/provider.ts +74 -0
- package/src/service.ts +255 -0
- package/src/solana-codegen/codegen.ts +116 -0
- package/src/state/processor-state.ts +3 -0
- package/src/state/state-storage.ts +65 -0
- package/src/target-ethers-sentio/event-handler.ts +31 -0
- package/src/target-ethers-sentio/file.ts +242 -0
- package/src/target-ethers-sentio/functions-handler.ts +57 -0
- package/src/target-ethers-sentio/index.ts +60 -0
- package/src/target-ethers-sentio/tsconfig.json +9 -0
- package/src/target-ethers-sentio/types.ts +42 -0
- package/src/target-ethers-sentio/view-function.ts +79 -0
- package/src/test-abi-code-gen.ts +16 -0
- package/src/testing/index.ts +4 -0
- package/src/testing/metric-utils.ts +48 -0
- package/src/testing/test-processor-server.ts +334 -0
- package/src/testing/test-provider.ts +33 -0
- package/src/types/global.d.ts +15 -0
- package/src/utils/chain.ts +127 -0
- package/src/utils/chainlink-oracles-goerli.csv +8 -0
- package/src/utils/chainlink-oracles.csv +217 -0
- package/src/utils/conversion.ts +27 -0
- package/src/utils/dex-price.ts +136 -0
- package/src/utils/index.ts +4 -0
- package/src/utils/price.ts +95 -0
- package/src/utils/token.ts +70 -0
- package/dist/base-processor-template.d.ts +0 -20
- package/dist/base-processor-template.js.map +0 -1
- package/dist/base-processor.d.ts +0 -22
- package/dist/base-processor.js +0 -103
- package/dist/base-processor.js.map +0 -1
- package/dist/bind-options.js.map +0 -1
- package/dist/binds.d.ts +0 -10
- package/dist/binds.js +0 -58
- package/dist/binds.js.map +0 -1
- package/dist/builtin/erc20/index.js.map +0 -1
- package/dist/builtin/internal/Erc20.js.map +0 -1
- package/dist/builtin/internal/common.js.map +0 -1
- package/dist/builtin/internal/erc20_processor.d.ts +0 -38
- package/dist/builtin/internal/erc20_processor.js +0 -209
- package/dist/builtin/internal/erc20_processor.js.map +0 -1
- package/dist/builtin/internal/factories/Erc20__factory.js.map +0 -1
- package/dist/builtin/internal/factories/index.d.ts +0 -1
- package/dist/builtin/internal/factories/index.js +0 -9
- package/dist/builtin/internal/factories/index.js.map +0 -1
- package/dist/builtin/internal/index.d.ts +0 -3
- package/dist/builtin/internal/index.js.map +0 -1
- package/dist/cli/build.d.ts +0 -3
- package/dist/cli/build.js +0 -161
- package/dist/cli/build.js.map +0 -1
- package/dist/cli/cli.js +0 -212
- package/dist/cli/cli.js.map +0 -1
- package/dist/cli/config.d.ts +0 -14
- package/dist/cli/config.js +0 -24
- package/dist/cli/config.js.map +0 -1
- package/dist/cli/key.d.ts +0 -2
- package/dist/cli/key.js +0 -44
- package/dist/cli/key.js.map +0 -1
- package/dist/cli/solana-code-gen.d.ts +0 -2
- package/dist/cli/solana-code-gen.js +0 -19
- package/dist/cli/solana-code-gen.js.map +0 -1
- package/dist/cli/upload.d.ts +0 -2
- package/dist/cli/upload.js +0 -76
- package/dist/cli/upload.js.map +0 -1
- package/dist/cli/webpack.config.js +0 -41
- package/dist/context.d.ts +0 -39
- package/dist/context.js +0 -75
- package/dist/context.js.map +0 -1
- package/dist/contract-namer.d.ts +0 -6
- package/dist/contract-namer.js +0 -20
- package/dist/contract-namer.js.map +0 -1
- package/dist/error.d.ts +0 -2
- package/dist/error.js +0 -39
- package/dist/error.js.map +0 -1
- package/dist/gen/builtin.js.map +0 -1
- package/dist/gen/google/protobuf/empty.js.map +0 -1
- package/dist/gen/processor/protos/processor.d.ts +0 -598
- package/dist/gen/processor/protos/processor.js +0 -2424
- package/dist/gen/processor/protos/processor.js.map +0 -1
- package/dist/index.d.ts +0 -13
- package/dist/index.js +0 -54
- package/dist/index.js.map +0 -1
- package/dist/meter.d.ts +0 -25
- package/dist/meter.js +0 -114
- package/dist/meter.js.map +0 -1
- package/dist/numberish.d.ts +0 -7
- package/dist/numberish.js +0 -74
- package/dist/numberish.js.map +0 -1
- package/dist/numberish.test.js +0 -54
- package/dist/numberish.test.js.map +0 -1
- package/dist/processor-runner.js +0 -66
- package/dist/processor-runner.js.map +0 -1
- package/dist/processor-state.d.ts +0 -16
- package/dist/processor-state.js +0 -20
- package/dist/processor-state.js.map +0 -1
- package/dist/provider.js.map +0 -1
- package/dist/service.d.ts +0 -22
- package/dist/service.js +0 -361
- package/dist/service.js.map +0 -1
- package/dist/solana/builtin/spl-token-processor.d.ts +0 -25
- package/dist/solana/builtin/spl-token-processor.js +0 -152
- package/dist/solana/builtin/spl-token-processor.js.map +0 -1
- package/dist/solana-processor.d.ts +0 -28
- package/dist/solana-processor.js +0 -79
- package/dist/solana-processor.js.map +0 -1
- package/dist/target-ethers-sentio/codegen.js +0 -201
- package/dist/target-ethers-sentio/codegen.js.map +0 -1
- package/dist/test-case/clean-test.d.ts +0 -1
- package/dist/test-case/clean-test.js +0 -9
- package/dist/test-case/clean-test.js.map +0 -1
- package/dist/test-case/erc20-template.d.ts +0 -1
- package/dist/test-case/erc20-template.js +0 -23
- package/dist/test-case/erc20-template.js.map +0 -1
- package/dist/test-case/erc20-template.test.js +0 -69
- package/dist/test-case/erc20-template.test.js.map +0 -1
- package/dist/test-case/erc20.d.ts +0 -1
- package/dist/test-case/erc20.js +0 -42
- package/dist/test-case/erc20.js.map +0 -1
- package/dist/test-case/erc20.test.js +0 -154
- package/dist/test-case/erc20.test.js.map +0 -1
- package/dist/test-case/mirrorworld.js +0 -42
- package/dist/test-case/mirrorworld.js.map +0 -1
- package/dist/test-case/solana.test.js +0 -58
- package/dist/test-case/solana.test.js.map +0 -1
- package/dist/test-case/types/game_wallet.d.ts +0 -45
- package/dist/test-case/types/game_wallet.js +0 -1396
- package/dist/test-case/types/game_wallet.js.map +0 -1
- package/dist/test-case/types/game_wallet_processor.d.ts +0 -107
- package/dist/test-case/types/game_wallet_processor.js +0 -102
- package/dist/test-case/types/game_wallet_processor.js.map +0 -1
- package/dist/test-case/types/wormhole_processor.d.ts +0 -16
- package/dist/test-case/types/wormhole_processor.js.map +0 -1
- package/dist/test-case/wormhole-token-bridge.js +0 -7
- package/dist/test-case/wormhole-token-bridge.js.map +0 -1
- package/dist/utils/chainmap.d.ts +0 -4
- package/dist/utils/chainmap.js +0 -95
- package/dist/utils/chainmap.js.map +0 -1
- package/dist/utils/index.d.ts +0 -1
- package/dist/utils/index.js +0 -6
- package/dist/utils/index.js.map +0 -1
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { BaseContext } from './base-context'
|
|
2
|
+
import { EventTrackingResult } from '../gen'
|
|
3
|
+
import { NamedResultDescriptor } from './metadata'
|
|
4
|
+
import { MapStateStorage } from '../state/state-storage'
|
|
5
|
+
|
|
6
|
+
export interface Event {
|
|
7
|
+
// The unique identifier of main identity associate with an event
|
|
8
|
+
// .e.g user id / toekn address / account address / contract address id
|
|
9
|
+
//
|
|
10
|
+
distinctId: string
|
|
11
|
+
payload?: Record<string, string>
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export interface TrackerOptions {
|
|
15
|
+
totalByDay?: boolean
|
|
16
|
+
unique?: boolean
|
|
17
|
+
distinctByDays?: number[]
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export class EventTrackerState extends MapStateStorage<EventTracker> {
|
|
21
|
+
static INSTANCE = new EventTrackerState()
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
// Track Event with an identity associate with it
|
|
25
|
+
export class EventTracker extends NamedResultDescriptor {
|
|
26
|
+
static DEFAULT_OPTIONS: TrackerOptions = {
|
|
27
|
+
totalByDay: true,
|
|
28
|
+
unique: true,
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
static register(eventName: string, options?: TrackerOptions) {
|
|
32
|
+
const tracker = new EventTracker(eventName, { ...EventTracker.DEFAULT_OPTIONS, ...options })
|
|
33
|
+
return EventTrackerState.INSTANCE.getOrSetValue(eventName, tracker)
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
options: TrackerOptions
|
|
37
|
+
protected constructor(eventName: string, options: TrackerOptions) {
|
|
38
|
+
super(eventName)
|
|
39
|
+
this.options = options
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
trackEvent(ctx: BaseContext, event: Event) {
|
|
43
|
+
const res: EventTrackingResult = {
|
|
44
|
+
metadata: ctx.getMetaData(this.name, {}),
|
|
45
|
+
distinctEntityId: event.distinctId,
|
|
46
|
+
attributes: JSON.stringify({}),
|
|
47
|
+
runtimeInfo: undefined,
|
|
48
|
+
}
|
|
49
|
+
ctx.res.events.push(res)
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export class AccountEventTracker extends EventTracker {
|
|
54
|
+
static DEFAULT_OPTIONS: TrackerOptions = {
|
|
55
|
+
totalByDay: true,
|
|
56
|
+
unique: true,
|
|
57
|
+
distinctByDays: [1, 7, 30],
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
static register(eventName?: string, options?: TrackerOptions) {
|
|
61
|
+
if (eventName) {
|
|
62
|
+
eventName = ['user', eventName].join('_')
|
|
63
|
+
} else {
|
|
64
|
+
eventName = 'user'
|
|
65
|
+
}
|
|
66
|
+
const tracker = new AccountEventTracker(eventName, { ...AccountEventTracker.DEFAULT_OPTIONS, ...options })
|
|
67
|
+
return EventTrackerState.INSTANCE.getOrSetValue(eventName, tracker)
|
|
68
|
+
}
|
|
69
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { BaseContext } from './base-context'
|
|
2
|
+
import { ExportResult } from '@sentio/sdk'
|
|
3
|
+
import { NamedResultDescriptor } from './metadata'
|
|
4
|
+
import { MapStateStorage } from '../state/state-storage'
|
|
5
|
+
|
|
6
|
+
export type Export = Record<string, any>
|
|
7
|
+
|
|
8
|
+
export class ExporterState extends MapStateStorage<Exporter> {
|
|
9
|
+
static INSTANCE = new ExporterState()
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export class Exporter extends NamedResultDescriptor {
|
|
13
|
+
static register(name: string, channel: string) {
|
|
14
|
+
const exporter = new Exporter(name, channel)
|
|
15
|
+
return ExporterState.INSTANCE.getOrSetValue(name, exporter)
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
channel: string
|
|
19
|
+
protected constructor(name: string, channel: string) {
|
|
20
|
+
super(name)
|
|
21
|
+
this.channel = channel
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
emit(ctx: BaseContext, data: Export) {
|
|
25
|
+
const res: ExportResult = {
|
|
26
|
+
metadata: ctx.getMetaData(this.name, {}),
|
|
27
|
+
payload: JSON.stringify(data),
|
|
28
|
+
runtimeInfo: undefined,
|
|
29
|
+
}
|
|
30
|
+
ctx.res.exports.push(res)
|
|
31
|
+
}
|
|
32
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { BaseContract } from '@ethersproject/contracts'
|
|
2
|
+
import { BoundContractView, ContractView } from './context'
|
|
3
|
+
import { BindOptions } from './bind-options'
|
|
4
|
+
import { BaseProcessor } from './base-processor'
|
|
5
|
+
import { getProvider } from '../provider'
|
|
6
|
+
import { addProcessor } from '../binds'
|
|
7
|
+
|
|
8
|
+
export class GenericProcessor extends BaseProcessor<
|
|
9
|
+
BaseContract,
|
|
10
|
+
BoundContractView<BaseContract, ContractView<BaseContract>>
|
|
11
|
+
> {
|
|
12
|
+
eventABI: string[]
|
|
13
|
+
constructor(eventABI: string[], options: BindOptions) {
|
|
14
|
+
super(options)
|
|
15
|
+
this.eventABI = eventABI
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
protected CreateBoundContractView(): BoundContractView<BaseContract, ContractView<BaseContract>> {
|
|
19
|
+
const contract = new BaseContract(this.config.address, this.eventABI, getProvider(this.config.network))
|
|
20
|
+
return new BoundContractView(new ContractView<BaseContract>(contract))
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
public static bind(eventABI: string[] | string, options: BindOptions): GenericProcessor {
|
|
24
|
+
if (!Array.isArray(eventABI)) {
|
|
25
|
+
eventABI = [eventABI]
|
|
26
|
+
}
|
|
27
|
+
if (!options.name) {
|
|
28
|
+
options.name = 'Generic'
|
|
29
|
+
}
|
|
30
|
+
const processor = new GenericProcessor(eventABI, options)
|
|
31
|
+
addProcessor(options, processor)
|
|
32
|
+
return processor
|
|
33
|
+
}
|
|
34
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export { BigDecimal } from './big-decimal'
|
|
2
|
+
export { ContractContext, ContractView, BoundContractView } from './context'
|
|
3
|
+
export { CounterBinding, Meter, GaugeBinding, Counter, Gauge, MetricOptions } from './meter'
|
|
4
|
+
export { EventTracker, AccountEventTracker } from './event-tracker'
|
|
5
|
+
export { type Numberish, toBigInteger, toMetricValue } from './numberish'
|
|
6
|
+
|
|
7
|
+
export { BindOptions } from './bind-options'
|
|
8
|
+
|
|
9
|
+
export { BaseProcessor } from './base-processor'
|
|
10
|
+
export { GenericProcessor } from './generic-processor'
|
|
11
|
+
export { BaseProcessorTemplate } from './base-processor-template'
|
|
12
|
+
export { SuiBaseProcessor, SuiBindOptions } from './sui-processor'
|
|
13
|
+
|
|
14
|
+
export { SolanaContext } from './solana-context'
|
|
15
|
+
export { SolanaBindOptions } from './solana-options'
|
|
16
|
+
export { SolanaBaseProcessor } from './solana-processor'
|
|
17
|
+
|
|
18
|
+
export type { TypedCallTrace, Trace } from './trace'
|
|
19
|
+
|
|
20
|
+
export { EthPlugin } from './eth-plugin'
|
|
21
|
+
export { SolanaPlugin } from './solana-plugin'
|
|
22
|
+
export { SuiPlugin } from './sui-plugin'
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { BaseContext } from './base-context'
|
|
2
|
+
import { LogLevel } from '../gen'
|
|
3
|
+
import { NamedResultDescriptor } from './metadata'
|
|
4
|
+
|
|
5
|
+
export type Attributes = Record<string, any>
|
|
6
|
+
|
|
7
|
+
export class Logger extends NamedResultDescriptor {
|
|
8
|
+
private readonly ctx: BaseContext
|
|
9
|
+
|
|
10
|
+
constructor(ctx: BaseContext, name = '') {
|
|
11
|
+
super(name)
|
|
12
|
+
this.ctx = ctx
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
withName(name: string) {
|
|
16
|
+
return new Logger(this.ctx, name)
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
log(level: LogLevel, message: any, attributes: Attributes = {}) {
|
|
20
|
+
if (typeof message !== 'string' && !(message instanceof String)) {
|
|
21
|
+
message = JSON.stringify(message)
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
this.ctx.res.logs.push({
|
|
25
|
+
// name: this.name,
|
|
26
|
+
metadata: this.ctx.getMetaData(this.name, {}), // GetRecordMetaData(this.ctx, this, {}),
|
|
27
|
+
level,
|
|
28
|
+
message,
|
|
29
|
+
attributes: JSON.stringify(attributes),
|
|
30
|
+
runtimeInfo: undefined,
|
|
31
|
+
})
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
info(msg: any, attributes: Attributes = {}) {
|
|
35
|
+
this.log(LogLevel.INFO, msg, attributes)
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
warn(msg: any, attributes: Attributes = {}) {
|
|
39
|
+
this.log(LogLevel.WARNING, msg, attributes)
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
error(msg: any, attributes: Attributes = {}) {
|
|
43
|
+
this.log(LogLevel.ERROR, msg, attributes)
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
critical(msg: any, attributes: Attributes = {}) {
|
|
47
|
+
this.log(LogLevel.CRITICAL, msg, attributes)
|
|
48
|
+
}
|
|
49
|
+
}
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
import { BaseContext } from './base-context'
|
|
2
|
+
import { Numberish, toMetricValue } from './numberish'
|
|
3
|
+
import { Labels, NamedResultDescriptor } from './metadata'
|
|
4
|
+
import { AggregationConfig, AggregationType, MetricConfig, MetricType } from '../gen'
|
|
5
|
+
import { MapStateStorage } from '../state/state-storage'
|
|
6
|
+
|
|
7
|
+
export function normalizeName(name: string): string {
|
|
8
|
+
const regex = new RegExp('![_.a-zA-Z0-9]')
|
|
9
|
+
return name.slice(0, 100).replace(regex, '_')
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export function normalizeKey(name: string): string {
|
|
13
|
+
if (name === 'labels') {
|
|
14
|
+
return 'labels_'
|
|
15
|
+
}
|
|
16
|
+
return normalizeName(name)
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export function normalizeValue(name: string): string {
|
|
20
|
+
return name.slice(0, 100)
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export function normalizeLabels(labels: Labels): Labels {
|
|
24
|
+
const normLabels: Labels = {}
|
|
25
|
+
for (const key in labels) {
|
|
26
|
+
normLabels[normalizeKey(key)] = normalizeValue(labels[key])
|
|
27
|
+
}
|
|
28
|
+
return normLabels
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export class MetricOptions {
|
|
32
|
+
unit?: string
|
|
33
|
+
description?: string
|
|
34
|
+
sparse?: boolean
|
|
35
|
+
aggregationConfig?: Partial<AggregationConfig>
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export class CounterOptions {
|
|
39
|
+
unit?: string
|
|
40
|
+
description?: string
|
|
41
|
+
sparse?: boolean
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// enum MetricType {
|
|
45
|
+
// Counter = 0,
|
|
46
|
+
// Gauge = 1,
|
|
47
|
+
// }
|
|
48
|
+
|
|
49
|
+
export class Metric extends NamedResultDescriptor {
|
|
50
|
+
config: MetricConfig
|
|
51
|
+
constructor(type: MetricType, name: string, option?: MetricOptions) {
|
|
52
|
+
super(name)
|
|
53
|
+
this.config = MetricConfig.fromPartial({ name: this.name, type: type, ...option })
|
|
54
|
+
const aggregationConfig = this.config.aggregationConfig
|
|
55
|
+
if (aggregationConfig && aggregationConfig.intervalInMinutes.length) {
|
|
56
|
+
if (aggregationConfig.intervalInMinutes.length > 1) {
|
|
57
|
+
console.error('current only support one intervalInMinutes, only first interval will be used for', name)
|
|
58
|
+
}
|
|
59
|
+
if (aggregationConfig.intervalInMinutes[0] > 0 && aggregationConfig.types.length === 0) {
|
|
60
|
+
aggregationConfig.types = [AggregationType.SUM, AggregationType.COUNT]
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export class MetricState extends MapStateStorage<Metric> {
|
|
67
|
+
static INSTANCE = new MetricState()
|
|
68
|
+
|
|
69
|
+
getOrRegisterMetric(type: MetricType, name: string, option?: CounterOptions | MetricOptions): Metric {
|
|
70
|
+
const metricMap = this.getOrRegister()
|
|
71
|
+
let metric = metricMap.get(name)
|
|
72
|
+
if (metric && metric.config.type !== type) {
|
|
73
|
+
throw Error(`redefine ${name} of metric type ${type} that is previously ${metric.config.type}`)
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
if (!metric) {
|
|
77
|
+
if (type === MetricType.COUNTER) {
|
|
78
|
+
metric = new Counter(name, option)
|
|
79
|
+
} else {
|
|
80
|
+
metric = new Gauge(name, option)
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
metricMap.set(name, metric)
|
|
84
|
+
return metric
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export class Counter extends Metric {
|
|
89
|
+
static register(name: string, option?: CounterOptions): Counter {
|
|
90
|
+
return MetricState.INSTANCE.getOrRegisterMetric(MetricType.COUNTER, name, option) as Counter
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
constructor(name: string, option?: MetricOptions) {
|
|
94
|
+
super(MetricType.COUNTER, name, option)
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
add(ctx: BaseContext, value: Numberish, labels: Labels = {}) {
|
|
98
|
+
this.record(ctx, value, labels, true)
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
sub(ctx: BaseContext, value: Numberish, labels: Labels = {}) {
|
|
102
|
+
this.record(ctx, value, labels, false)
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
private record(ctx: BaseContext, value: Numberish, labels: Labels, add: boolean) {
|
|
106
|
+
ctx.res.counters.push({
|
|
107
|
+
metadata: ctx.getMetaData(this.name, labels),
|
|
108
|
+
metricValue: toMetricValue(value),
|
|
109
|
+
add: add,
|
|
110
|
+
runtimeInfo: undefined,
|
|
111
|
+
})
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
export class CounterBinding {
|
|
116
|
+
private readonly ctx: BaseContext
|
|
117
|
+
private readonly counter: Counter
|
|
118
|
+
|
|
119
|
+
constructor(name: string, ctx: BaseContext) {
|
|
120
|
+
this.counter = new Counter(name)
|
|
121
|
+
this.ctx = ctx
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
add(value: Numberish, labels: Labels = {}) {
|
|
125
|
+
this.counter.add(this.ctx, value, labels)
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
sub(value: Numberish, labels: Labels = {}) {
|
|
129
|
+
this.counter.sub(this.ctx, value, labels)
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
export class Gauge extends Metric {
|
|
134
|
+
static register(name: string, option?: MetricOptions): Gauge {
|
|
135
|
+
return MetricState.INSTANCE.getOrRegisterMetric(MetricType.GAUGE, name, option) as Gauge
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
constructor(name: string, option?: MetricOptions) {
|
|
139
|
+
super(MetricType.GAUGE, name, option)
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
record(ctx: BaseContext, value: Numberish, labels: Labels = {}) {
|
|
143
|
+
ctx.res.gauges.push({
|
|
144
|
+
metadata: ctx.getMetaData(this.config.name, labels),
|
|
145
|
+
metricValue: toMetricValue(value),
|
|
146
|
+
runtimeInfo: undefined,
|
|
147
|
+
})
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
export class GaugeBinding {
|
|
152
|
+
private readonly gauge: Gauge
|
|
153
|
+
private readonly ctx: BaseContext
|
|
154
|
+
|
|
155
|
+
constructor(name: string, ctx: BaseContext) {
|
|
156
|
+
this.gauge = new Gauge(name)
|
|
157
|
+
this.ctx = ctx
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
record(value: Numberish, labels: Labels = {}) {
|
|
161
|
+
this.gauge.record(this.ctx, value, labels)
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
export class Meter {
|
|
166
|
+
private readonly ctx: BaseContext
|
|
167
|
+
|
|
168
|
+
constructor(ctx: BaseContext) {
|
|
169
|
+
this.ctx = ctx
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
Counter(name: string): CounterBinding {
|
|
173
|
+
return new CounterBinding(name, this.ctx)
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
Gauge(name: string): GaugeBinding {
|
|
177
|
+
return new GaugeBinding(name, this.ctx)
|
|
178
|
+
}
|
|
179
|
+
}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import { BigNumber } from 'ethers'
|
|
2
|
+
import { BigInteger, MetricValue } from '../gen'
|
|
3
|
+
import { BigDecimal } from '.'
|
|
4
|
+
import { BN } from '@project-serum/anchor'
|
|
5
|
+
import Long from 'long'
|
|
6
|
+
|
|
7
|
+
export type Numberish = number | BigNumber | bigint | BigDecimal
|
|
8
|
+
|
|
9
|
+
export function toMetricValue(value: Numberish): MetricValue {
|
|
10
|
+
if (value instanceof BigNumber) {
|
|
11
|
+
return MetricValue.fromPartial({
|
|
12
|
+
bigInteger: toBigInteger(value.toBigInt()),
|
|
13
|
+
})
|
|
14
|
+
}
|
|
15
|
+
if (value instanceof BigDecimal) {
|
|
16
|
+
// Carefully consider the use case here
|
|
17
|
+
if (value.isInteger()) {
|
|
18
|
+
return MetricValue.fromPartial({
|
|
19
|
+
bigInteger: bigDecimalToBigInteger(value),
|
|
20
|
+
})
|
|
21
|
+
} else {
|
|
22
|
+
if (value.isNaN()) {
|
|
23
|
+
throw new Error('Cannot record NaN value')
|
|
24
|
+
}
|
|
25
|
+
if (!value.isFinite()) {
|
|
26
|
+
// NaN also not finite
|
|
27
|
+
throw new Error('Cannot record infinite value')
|
|
28
|
+
}
|
|
29
|
+
return MetricValue.fromPartial({
|
|
30
|
+
bigDecimal: value.toString(), // e.g. -7.350918e-428
|
|
31
|
+
})
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
if (BN.isBN(value)) {
|
|
35
|
+
return MetricValue.fromPartial({
|
|
36
|
+
bigInteger: bnToBigInteger(value),
|
|
37
|
+
})
|
|
38
|
+
}
|
|
39
|
+
if (typeof value === 'bigint' || Number.isInteger(value)) {
|
|
40
|
+
return MetricValue.fromPartial({
|
|
41
|
+
bigInteger: toBigInteger(value),
|
|
42
|
+
})
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
if (typeof value === 'number') {
|
|
46
|
+
if (Number.isNaN(value)) {
|
|
47
|
+
throw new Error('Cannot record NaN value')
|
|
48
|
+
}
|
|
49
|
+
if (!Number.isFinite(value)) {
|
|
50
|
+
throw new Error('Cannot record infinite value')
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
return MetricValue.fromPartial({
|
|
55
|
+
doubleValue: Number(value),
|
|
56
|
+
})
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
function bigDecimalToBigInteger(a: BigDecimal): BigInteger {
|
|
60
|
+
const negative = a.isNegative()
|
|
61
|
+
if (negative) {
|
|
62
|
+
a = a.abs()
|
|
63
|
+
}
|
|
64
|
+
return hexToBigInteger(a.toString(16), negative)
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
function bnToBigInteger(a: BN): BigInteger {
|
|
68
|
+
const negative = a.isNeg()
|
|
69
|
+
if (negative) {
|
|
70
|
+
a = a.abs()
|
|
71
|
+
}
|
|
72
|
+
return hexToBigInteger(a.toString(16), negative)
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
function intToBigInteger(a: bigint | number): BigInteger {
|
|
76
|
+
const negative = a < 0
|
|
77
|
+
if (negative) {
|
|
78
|
+
a = -a
|
|
79
|
+
}
|
|
80
|
+
return hexToBigInteger(a.toString(16), negative)
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export function toBigInteger(a: Numberish): BigInteger {
|
|
84
|
+
if (a instanceof BigDecimal) {
|
|
85
|
+
return bigDecimalToBigInteger(a)
|
|
86
|
+
}
|
|
87
|
+
if (a instanceof BN) {
|
|
88
|
+
return bnToBigInteger(a)
|
|
89
|
+
}
|
|
90
|
+
if (a instanceof BigNumber) {
|
|
91
|
+
return intToBigInteger(a.toBigInt())
|
|
92
|
+
}
|
|
93
|
+
return intToBigInteger(a)
|
|
94
|
+
|
|
95
|
+
// Following code is actually very slow
|
|
96
|
+
// while (a > 0) {
|
|
97
|
+
// const d = a & 0xffn
|
|
98
|
+
// a >>= 8n
|
|
99
|
+
// value.push(Number(d))
|
|
100
|
+
// }
|
|
101
|
+
//
|
|
102
|
+
// return {
|
|
103
|
+
// negative, value: new Uint8Array(value.reverse()),
|
|
104
|
+
// }
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
function hexToBigInteger(hex: string, negative: boolean): BigInteger {
|
|
108
|
+
if (hex.length % 2 === 1) {
|
|
109
|
+
hex = '0' + hex
|
|
110
|
+
}
|
|
111
|
+
const buffer = Buffer.from(hex, 'hex')
|
|
112
|
+
|
|
113
|
+
return {
|
|
114
|
+
negative: negative,
|
|
115
|
+
data: new Uint8Array(buffer),
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
export function toBigInt(v: Long): bigint {
|
|
120
|
+
return BigInt(v.toString())
|
|
121
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { BaseContext } from './base-context'
|
|
2
|
+
import Long from 'long'
|
|
3
|
+
import { Labels } from './metadata'
|
|
4
|
+
import { RecordMetaData } from '@sentio/sdk'
|
|
5
|
+
import { CHAIN_IDS } from '../utils/chain'
|
|
6
|
+
import { normalizeLabels } from './meter'
|
|
7
|
+
|
|
8
|
+
export class SolanaContext extends BaseContext {
|
|
9
|
+
network: string
|
|
10
|
+
address: string
|
|
11
|
+
programName: string
|
|
12
|
+
blockNumber: Long
|
|
13
|
+
|
|
14
|
+
constructor(programName: string, network: string, address: string, slot: Long) {
|
|
15
|
+
super()
|
|
16
|
+
this.network = network || CHAIN_IDS.SOLANA_MAINNET
|
|
17
|
+
this.programName = programName
|
|
18
|
+
this.address = address
|
|
19
|
+
this.blockNumber = slot
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
getMetaData(name: string, labels: Labels): RecordMetaData {
|
|
23
|
+
return {
|
|
24
|
+
address: this.address,
|
|
25
|
+
contractName: this.programName,
|
|
26
|
+
blockNumber: this.blockNumber,
|
|
27
|
+
transactionIndex: 0,
|
|
28
|
+
transactionHash: '', // TODO add
|
|
29
|
+
logIndex: 0,
|
|
30
|
+
chainId: this.network,
|
|
31
|
+
name: name,
|
|
32
|
+
labels: normalizeLabels(labels),
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { Plugin, PluginManager } from '../plugin'
|
|
2
|
+
import {
|
|
3
|
+
ContractConfig,
|
|
4
|
+
Data_SolInstruction,
|
|
5
|
+
DataBinding,
|
|
6
|
+
HandlerType,
|
|
7
|
+
ProcessConfigResponse,
|
|
8
|
+
ProcessResult,
|
|
9
|
+
} from '../gen/processor/protos/processor'
|
|
10
|
+
import { DEFAULT_MAX_BLOCK, errorString, mergeProcessResults, USER_PROCESSOR, Utf8ArrayToStr } from '../service'
|
|
11
|
+
|
|
12
|
+
import { ServerError, Status } from 'nice-grpc'
|
|
13
|
+
|
|
14
|
+
import { SolanaProcessorState } from './solana-processor'
|
|
15
|
+
import { Instruction as SolInstruction } from '@project-serum/anchor/dist/cjs/coder/borsh/instruction'
|
|
16
|
+
|
|
17
|
+
export class SolanaPlugin implements Plugin {
|
|
18
|
+
name: string = 'SolanaPlugin'
|
|
19
|
+
|
|
20
|
+
configure(config: ProcessConfigResponse): void {
|
|
21
|
+
// Part 2, prepare solana constractors
|
|
22
|
+
for (const solanaProcessor of SolanaProcessorState.INSTANCE.getValues()) {
|
|
23
|
+
const contractConfig: ContractConfig = {
|
|
24
|
+
processorType: USER_PROCESSOR,
|
|
25
|
+
contract: {
|
|
26
|
+
name: solanaProcessor.contractName,
|
|
27
|
+
chainId: solanaProcessor.network,
|
|
28
|
+
address: solanaProcessor.address,
|
|
29
|
+
abi: '',
|
|
30
|
+
},
|
|
31
|
+
logConfigs: [],
|
|
32
|
+
traceConfigs: [],
|
|
33
|
+
intervalConfigs: [],
|
|
34
|
+
startBlock: solanaProcessor.config.startSlot,
|
|
35
|
+
endBlock: DEFAULT_MAX_BLOCK,
|
|
36
|
+
instructionConfig: {
|
|
37
|
+
innerInstruction: solanaProcessor.processInnerInstruction,
|
|
38
|
+
parsedInstruction: solanaProcessor.fromParsedInstruction !== null,
|
|
39
|
+
rawDataInstruction: solanaProcessor.decodeInstruction !== null,
|
|
40
|
+
},
|
|
41
|
+
aptosEventConfigs: [],
|
|
42
|
+
aptosCallConfigs: [],
|
|
43
|
+
}
|
|
44
|
+
config.contractConfigs.push(contractConfig)
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
supportedHandlers = [HandlerType.SOL_INSTRUCTION]
|
|
49
|
+
|
|
50
|
+
processBinding(request: DataBinding): Promise<ProcessResult> {
|
|
51
|
+
switch (request.handlerType) {
|
|
52
|
+
case HandlerType.SOL_INSTRUCTION:
|
|
53
|
+
return this.processSolInstruction(request)
|
|
54
|
+
default:
|
|
55
|
+
throw new ServerError(Status.INVALID_ARGUMENT, 'No handle type registered ' + request.handlerType)
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
async processSolInstruction(request: DataBinding): Promise<ProcessResult> {
|
|
60
|
+
if (!request.data) {
|
|
61
|
+
throw new ServerError(Status.INVALID_ARGUMENT, 'instruction data cannot be empty')
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
const instruction = request.data.solInstruction || Data_SolInstruction.decode(request.data.raw) // JSON.parse(jsonString)
|
|
65
|
+
const promises: Promise<ProcessResult>[] = []
|
|
66
|
+
|
|
67
|
+
// Only have instruction handlers for solana processors
|
|
68
|
+
for (const processor of SolanaProcessorState.INSTANCE.getValues()) {
|
|
69
|
+
if (processor.address === instruction.programAccountId) {
|
|
70
|
+
let parsedInstruction: SolInstruction | null = null
|
|
71
|
+
if (instruction.parsed) {
|
|
72
|
+
parsedInstruction = processor.getParsedInstruction(instruction.parsed as { type: string; info: any })
|
|
73
|
+
} else if (instruction.instructionData) {
|
|
74
|
+
parsedInstruction = processor.getParsedInstruction(instruction.instructionData)
|
|
75
|
+
}
|
|
76
|
+
if (parsedInstruction == null) {
|
|
77
|
+
continue
|
|
78
|
+
}
|
|
79
|
+
const insHandler = processor.getInstructionHandler(parsedInstruction)
|
|
80
|
+
if (insHandler == null) {
|
|
81
|
+
continue
|
|
82
|
+
}
|
|
83
|
+
const res = await processor.handleInstruction(
|
|
84
|
+
parsedInstruction,
|
|
85
|
+
instruction.accounts,
|
|
86
|
+
insHandler,
|
|
87
|
+
instruction.slot
|
|
88
|
+
)
|
|
89
|
+
|
|
90
|
+
promises.push(Promise.resolve(res))
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
return mergeProcessResults(await Promise.all(promises))
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
PluginManager.INSTANCE.register(new SolanaPlugin())
|