@sentio/sdk 0.6.5 → 1.0.0-rc.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/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 -41
- 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 -160
- 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 -59
- 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 -67
- 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
package/src/aptos/api.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { AptosQueryClient, AptosQueryDefinition } from '../gen/chainquery/protos/chainquery'
|
|
2
|
+
import { createChannel, createClient } from 'nice-grpc'
|
|
3
|
+
|
|
4
|
+
export function getChainQueryClient(address?: string): AptosQueryClient {
|
|
5
|
+
if (!address) {
|
|
6
|
+
address = global.ENDPOINTS.chainQueryAPI
|
|
7
|
+
}
|
|
8
|
+
const channel = createChannel(address)
|
|
9
|
+
|
|
10
|
+
return createClient(AptosQueryDefinition, channel)
|
|
11
|
+
}
|
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
import { Plugin, PluginManager } from '../plugin'
|
|
2
|
+
import {
|
|
3
|
+
AccountConfig,
|
|
4
|
+
AptosCallHandlerConfig,
|
|
5
|
+
AptosEventHandlerConfig,
|
|
6
|
+
ContractConfig,
|
|
7
|
+
DataBinding,
|
|
8
|
+
HandlerType,
|
|
9
|
+
ProcessConfigResponse,
|
|
10
|
+
ProcessResult,
|
|
11
|
+
} from '../gen/processor/protos/processor'
|
|
12
|
+
import { DEFAULT_MAX_BLOCK, errorString, mergeProcessResults, USER_PROCESSOR, Utf8ArrayToStr } from '../service'
|
|
13
|
+
|
|
14
|
+
import { ServerError, Status } from 'nice-grpc'
|
|
15
|
+
|
|
16
|
+
import { MoveResource, Transaction_UserTransaction } from 'aptos-sdk/src/generated'
|
|
17
|
+
import { AptosAccountProcessorState, AptosProcessorState, MoveResourcesWithVersionPayload } from './aptos-processor'
|
|
18
|
+
import { toBigInt } from '../core/numberish'
|
|
19
|
+
import Long from 'long'
|
|
20
|
+
|
|
21
|
+
export class AptosPlugin implements Plugin {
|
|
22
|
+
name: string = 'AptosPlugin'
|
|
23
|
+
|
|
24
|
+
private aptosEventHandlers: ((event: any) => Promise<ProcessResult>)[] = []
|
|
25
|
+
private aptosCallHandlers: ((func: any) => Promise<ProcessResult>)[] = []
|
|
26
|
+
private aptosResourceHandlers: ((resourceWithVersion: MoveResourcesWithVersionPayload) => Promise<ProcessResult>)[] =
|
|
27
|
+
[]
|
|
28
|
+
|
|
29
|
+
configure(config: ProcessConfigResponse): void {
|
|
30
|
+
for (const aptosProcessor of AptosProcessorState.INSTANCE.getValues()) {
|
|
31
|
+
const contractConfig: ContractConfig = {
|
|
32
|
+
processorType: USER_PROCESSOR,
|
|
33
|
+
contract: {
|
|
34
|
+
name: aptosProcessor.moduleName,
|
|
35
|
+
chainId: aptosProcessor.getChainId(),
|
|
36
|
+
address: aptosProcessor.config.address,
|
|
37
|
+
abi: '',
|
|
38
|
+
},
|
|
39
|
+
intervalConfigs: [],
|
|
40
|
+
logConfigs: [],
|
|
41
|
+
traceConfigs: [],
|
|
42
|
+
startBlock: Long.fromString(aptosProcessor.config.startVersion.toString()),
|
|
43
|
+
endBlock: DEFAULT_MAX_BLOCK,
|
|
44
|
+
instructionConfig: undefined,
|
|
45
|
+
aptosEventConfigs: [],
|
|
46
|
+
aptosCallConfigs: [],
|
|
47
|
+
}
|
|
48
|
+
// 1. Prepare event handlers
|
|
49
|
+
for (const handler of aptosProcessor.eventHandlers) {
|
|
50
|
+
const handlerId = this.aptosEventHandlers.push(handler.handler) - 1
|
|
51
|
+
const eventHandlerConfig: AptosEventHandlerConfig = {
|
|
52
|
+
filters: handler.filters.map((f) => {
|
|
53
|
+
return {
|
|
54
|
+
type: f.type,
|
|
55
|
+
account: f.account || '',
|
|
56
|
+
}
|
|
57
|
+
}),
|
|
58
|
+
handlerId,
|
|
59
|
+
}
|
|
60
|
+
contractConfig.aptosEventConfigs.push(eventHandlerConfig)
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
// 2. Prepare function handlers
|
|
64
|
+
for (const handler of aptosProcessor.callHandlers) {
|
|
65
|
+
const handlerId = this.aptosCallHandlers.push(handler.handler) - 1
|
|
66
|
+
const functionHandlerConfig: AptosCallHandlerConfig = {
|
|
67
|
+
filters: handler.filters.map((filter) => {
|
|
68
|
+
return {
|
|
69
|
+
function: filter.function,
|
|
70
|
+
typeArguments: filter.typeArguments || [],
|
|
71
|
+
withTypeArguments: filter.typeArguments ? true : false,
|
|
72
|
+
includeFailed: filter.includeFailed || false,
|
|
73
|
+
}
|
|
74
|
+
}),
|
|
75
|
+
handlerId,
|
|
76
|
+
}
|
|
77
|
+
contractConfig.aptosCallConfigs.push(functionHandlerConfig)
|
|
78
|
+
}
|
|
79
|
+
config.contractConfigs.push(contractConfig)
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
for (const aptosProcessor of AptosAccountProcessorState.INSTANCE.getValues()) {
|
|
83
|
+
const accountConfig: AccountConfig = {
|
|
84
|
+
address: aptosProcessor.config.address,
|
|
85
|
+
chainId: aptosProcessor.getChainId(),
|
|
86
|
+
startBlock: Long.fromValue(aptosProcessor.config.startVersion.toString()),
|
|
87
|
+
aptosIntervalConfigs: [],
|
|
88
|
+
intervalConfigs: [],
|
|
89
|
+
logConfigs: [],
|
|
90
|
+
}
|
|
91
|
+
for (const handler of aptosProcessor.resourcesHandlers) {
|
|
92
|
+
const handlerId = this.aptosResourceHandlers.push(handler.handler) - 1
|
|
93
|
+
accountConfig.aptosIntervalConfigs.push({
|
|
94
|
+
intervalConfig: {
|
|
95
|
+
handlerId: handlerId,
|
|
96
|
+
minutes: 0,
|
|
97
|
+
minutesInterval: handler.timeIntervalInMinutes,
|
|
98
|
+
slot: 0,
|
|
99
|
+
slotInterval: handler.versionInterval,
|
|
100
|
+
},
|
|
101
|
+
type: handler.type || '',
|
|
102
|
+
})
|
|
103
|
+
}
|
|
104
|
+
config.accountConfigs.push(accountConfig)
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
supportedHandlers = [HandlerType.APT_CALL, HandlerType.APT_RESOURCE, HandlerType.APT_EVENT]
|
|
109
|
+
|
|
110
|
+
processBinding(request: DataBinding): Promise<ProcessResult> {
|
|
111
|
+
switch (request.handlerType) {
|
|
112
|
+
case HandlerType.APT_CALL:
|
|
113
|
+
return this.processAptosFunctionCall(request)
|
|
114
|
+
case HandlerType.APT_EVENT:
|
|
115
|
+
return this.processAptosEvent(request)
|
|
116
|
+
case HandlerType.APT_RESOURCE:
|
|
117
|
+
return this.processAptosResource(request)
|
|
118
|
+
// case HandlerType.INSTRUCTION:
|
|
119
|
+
// return this.processInstruction(request)
|
|
120
|
+
default:
|
|
121
|
+
throw new ServerError(Status.INVALID_ARGUMENT, 'No handle type registered ' + request.handlerType)
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
async processAptosEvent(binding: DataBinding): Promise<ProcessResult> {
|
|
126
|
+
if (!binding.data) {
|
|
127
|
+
throw new ServerError(Status.INVALID_ARGUMENT, "Event can't be empty")
|
|
128
|
+
}
|
|
129
|
+
const promises: Promise<ProcessResult>[] = []
|
|
130
|
+
let event: Transaction_UserTransaction
|
|
131
|
+
if (binding.data.aptEvent?.event) {
|
|
132
|
+
event = binding.data.aptEvent?.event as Transaction_UserTransaction
|
|
133
|
+
} else {
|
|
134
|
+
const jsonString = Utf8ArrayToStr(binding.data.raw)
|
|
135
|
+
event = JSON.parse(jsonString)
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
for (const handlerId of binding.handlerIds) {
|
|
139
|
+
// only support aptos event for now
|
|
140
|
+
promises.push(
|
|
141
|
+
this.aptosEventHandlers[handlerId](event).catch((e) => {
|
|
142
|
+
throw new ServerError(
|
|
143
|
+
Status.INTERNAL,
|
|
144
|
+
'error processing event: ' + JSON.stringify(event) + '\n' + errorString(e)
|
|
145
|
+
)
|
|
146
|
+
})
|
|
147
|
+
)
|
|
148
|
+
}
|
|
149
|
+
return mergeProcessResults(await Promise.all(promises))
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
async processAptosResource(binding: DataBinding): Promise<ProcessResult> {
|
|
153
|
+
if (!binding.data) {
|
|
154
|
+
throw new ServerError(Status.INVALID_ARGUMENT, "Event can't be empty")
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
const resource: MoveResourcesWithVersionPayload = {
|
|
158
|
+
resources: [],
|
|
159
|
+
version: 0n,
|
|
160
|
+
timestamp: 0,
|
|
161
|
+
}
|
|
162
|
+
if (binding.data.aptResource?.resources) {
|
|
163
|
+
if (binding.data.aptResource.timestampMicros.greaterThan(Number.MAX_SAFE_INTEGER)) {
|
|
164
|
+
throw new ServerError(Status.INVALID_ARGUMENT, 'timestamp is too large')
|
|
165
|
+
}
|
|
166
|
+
resource.timestamp = binding.data.aptResource.timestampMicros.toNumber()
|
|
167
|
+
resource.version = toBigInt(binding.data.aptResource.version)
|
|
168
|
+
resource.resources = binding.data.aptResource.resources as MoveResource[]
|
|
169
|
+
} else {
|
|
170
|
+
const jsonString = Utf8ArrayToStr(binding.data.raw)
|
|
171
|
+
const json = JSON.parse(jsonString)
|
|
172
|
+
if (Long.fromString(json.timestamp).greaterThan(Number.MAX_SAFE_INTEGER)) {
|
|
173
|
+
throw new ServerError(Status.INVALID_ARGUMENT, 'timestamp is too large')
|
|
174
|
+
}
|
|
175
|
+
resource.timestamp = parseInt(json.timestamp)
|
|
176
|
+
resource.version = toBigInt(json.version)
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
const promises: Promise<ProcessResult>[] = []
|
|
180
|
+
for (const handlerId of binding.handlerIds) {
|
|
181
|
+
promises.push(
|
|
182
|
+
this.aptosResourceHandlers[handlerId](resource).catch((e) => {
|
|
183
|
+
throw new ServerError(
|
|
184
|
+
Status.INTERNAL,
|
|
185
|
+
'error processing event: ' + JSON.stringify(resource) + '\n' + errorString(e)
|
|
186
|
+
)
|
|
187
|
+
})
|
|
188
|
+
)
|
|
189
|
+
}
|
|
190
|
+
return mergeProcessResults(await Promise.all(promises))
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
async processAptosFunctionCall(binding: DataBinding): Promise<ProcessResult> {
|
|
194
|
+
if (!binding.data) {
|
|
195
|
+
throw new ServerError(Status.INVALID_ARGUMENT, "Event can't be empty")
|
|
196
|
+
}
|
|
197
|
+
let call: Transaction_UserTransaction
|
|
198
|
+
if (binding.data.aptCall?.call) {
|
|
199
|
+
call = binding.data.aptCall?.call as Transaction_UserTransaction
|
|
200
|
+
} else {
|
|
201
|
+
const jsonString = Utf8ArrayToStr(binding.data.raw)
|
|
202
|
+
call = JSON.parse(jsonString)
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
const promises: Promise<ProcessResult>[] = []
|
|
206
|
+
for (const handlerId of binding.handlerIds) {
|
|
207
|
+
// only support aptos call for now
|
|
208
|
+
const promise = this.aptosCallHandlers[handlerId](call).catch((e) => {
|
|
209
|
+
throw new ServerError(Status.INTERNAL, 'error processing call: ' + JSON.stringify(call) + '\n' + errorString(e))
|
|
210
|
+
})
|
|
211
|
+
promises.push(promise)
|
|
212
|
+
}
|
|
213
|
+
return mergeProcessResults(await Promise.all(promises))
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
PluginManager.INSTANCE.register(new AptosPlugin())
|
|
@@ -0,0 +1,305 @@
|
|
|
1
|
+
import {
|
|
2
|
+
MoveResource,
|
|
3
|
+
Transaction_UserTransaction,
|
|
4
|
+
TransactionPayload_EntryFunctionPayload,
|
|
5
|
+
} from 'aptos-sdk/src/generated'
|
|
6
|
+
|
|
7
|
+
import { TYPE_REGISTRY, TypeRegistry } from './type-registry'
|
|
8
|
+
import { AptosBindOptions, AptosNetwork, getChainId } from './network'
|
|
9
|
+
import { AptosContext, AptosResourceContext } from './context'
|
|
10
|
+
import { EventInstance } from './models'
|
|
11
|
+
import { ListStateStorage } from '../state/state-storage'
|
|
12
|
+
import { HandleInterval, ProcessResult } from '../gen'
|
|
13
|
+
|
|
14
|
+
type IndexConfigure = {
|
|
15
|
+
address: string
|
|
16
|
+
network: AptosNetwork
|
|
17
|
+
startVersion: bigint
|
|
18
|
+
// endSeqNumber?: Long
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
// TODO extends ArgumentsFilter
|
|
22
|
+
export interface EventFilter {
|
|
23
|
+
type: string
|
|
24
|
+
account?: string
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export interface FunctionNameAndCallFilter extends CallFilter {
|
|
28
|
+
function: string
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// TODO extends ArgumentsFilter
|
|
32
|
+
export interface CallFilter {
|
|
33
|
+
includeFailed?: boolean
|
|
34
|
+
typeArguments?: string[]
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export interface ArgumentsFilter {
|
|
38
|
+
arguments?: string[]
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
class EventHandler {
|
|
42
|
+
filters: EventFilter[]
|
|
43
|
+
handler: (event: Transaction_UserTransaction) => Promise<ProcessResult>
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
class CallHandler {
|
|
47
|
+
filters: FunctionNameAndCallFilter[]
|
|
48
|
+
handler: (call: Transaction_UserTransaction) => Promise<ProcessResult>
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export class MoveResourcesWithVersionPayload {
|
|
52
|
+
resources: MoveResource[]
|
|
53
|
+
version: bigint
|
|
54
|
+
timestamp: number
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
class ResourceHandlder {
|
|
58
|
+
type?: string
|
|
59
|
+
versionInterval?: HandleInterval
|
|
60
|
+
timeIntervalInMinutes?: HandleInterval
|
|
61
|
+
handler: (resource: MoveResourcesWithVersionPayload) => Promise<ProcessResult>
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export class AptosProcessorState extends ListStateStorage<AptosBaseProcessor> {
|
|
65
|
+
static INSTANCE = new AptosProcessorState()
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export class AptosBaseProcessor {
|
|
69
|
+
readonly moduleName: string
|
|
70
|
+
config: IndexConfigure
|
|
71
|
+
eventHandlers: EventHandler[] = []
|
|
72
|
+
callHandlers: CallHandler[] = []
|
|
73
|
+
|
|
74
|
+
constructor(moduleName: string, options: AptosBindOptions) {
|
|
75
|
+
this.moduleName = moduleName
|
|
76
|
+
this.config = configure(options)
|
|
77
|
+
AptosProcessorState.INSTANCE.addValue(this)
|
|
78
|
+
this.loadTypes(TYPE_REGISTRY)
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
// getABI(): MoveModule | undefined {
|
|
82
|
+
// return undefined
|
|
83
|
+
// }
|
|
84
|
+
|
|
85
|
+
public onTransaction(
|
|
86
|
+
handler: (transaction: Transaction_UserTransaction, ctx: AptosContext) => void,
|
|
87
|
+
includedFailed = false
|
|
88
|
+
): AptosBaseProcessor {
|
|
89
|
+
// const address = this.config.address
|
|
90
|
+
// const moduleName = this.moduleName
|
|
91
|
+
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
92
|
+
const processor = this
|
|
93
|
+
this.callHandlers.push({
|
|
94
|
+
handler: async function (tx) {
|
|
95
|
+
const ctx = new AptosContext(
|
|
96
|
+
processor.moduleName,
|
|
97
|
+
processor.config.network,
|
|
98
|
+
processor.config.address,
|
|
99
|
+
BigInt(tx.version),
|
|
100
|
+
tx
|
|
101
|
+
)
|
|
102
|
+
if (tx) {
|
|
103
|
+
await handler(tx, ctx)
|
|
104
|
+
}
|
|
105
|
+
return ctx.getProcessResult()
|
|
106
|
+
},
|
|
107
|
+
filters: [{ function: '', includeFailed: includedFailed }],
|
|
108
|
+
})
|
|
109
|
+
return this
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
public onEvent(
|
|
113
|
+
handler: (event: EventInstance, ctx: AptosContext) => void,
|
|
114
|
+
filter: EventFilter | EventFilter[]
|
|
115
|
+
): AptosBaseProcessor {
|
|
116
|
+
let _filters: EventFilter[] = []
|
|
117
|
+
|
|
118
|
+
if (Array.isArray(filter)) {
|
|
119
|
+
_filters = filter
|
|
120
|
+
} else {
|
|
121
|
+
_filters.push(filter)
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
// const address = this.config.address
|
|
125
|
+
// const moduleName = this.moduleName
|
|
126
|
+
|
|
127
|
+
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
128
|
+
const processor = this
|
|
129
|
+
|
|
130
|
+
this.eventHandlers.push({
|
|
131
|
+
handler: async function (txn) {
|
|
132
|
+
const ctx = new AptosContext(
|
|
133
|
+
processor.moduleName,
|
|
134
|
+
processor.config.network,
|
|
135
|
+
processor.config.address,
|
|
136
|
+
BigInt(txn.version),
|
|
137
|
+
txn
|
|
138
|
+
)
|
|
139
|
+
if (txn && txn.events) {
|
|
140
|
+
const events = txn.events
|
|
141
|
+
txn.events = []
|
|
142
|
+
for (const evt of events) {
|
|
143
|
+
const eventInstance = evt as EventInstance
|
|
144
|
+
const decoded = TYPE_REGISTRY.decodeEvent<any>(eventInstance)
|
|
145
|
+
await handler(decoded || eventInstance, ctx)
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
return ctx.getProcessResult()
|
|
149
|
+
},
|
|
150
|
+
filters: _filters,
|
|
151
|
+
})
|
|
152
|
+
return this
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
public onEntryFunctionCall(
|
|
156
|
+
handler: (call: TransactionPayload_EntryFunctionPayload, ctx: AptosContext) => void,
|
|
157
|
+
filter: FunctionNameAndCallFilter | FunctionNameAndCallFilter[]
|
|
158
|
+
): AptosBaseProcessor {
|
|
159
|
+
let _filters: FunctionNameAndCallFilter[] = []
|
|
160
|
+
|
|
161
|
+
if (Array.isArray(filter)) {
|
|
162
|
+
_filters = filter
|
|
163
|
+
} else {
|
|
164
|
+
_filters.push(filter)
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
// const address = this.config.address
|
|
168
|
+
// const moduleName = this.moduleName
|
|
169
|
+
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
170
|
+
const processor = this
|
|
171
|
+
|
|
172
|
+
this.callHandlers.push({
|
|
173
|
+
handler: async function (tx) {
|
|
174
|
+
const ctx = new AptosContext(
|
|
175
|
+
processor.moduleName,
|
|
176
|
+
processor.config.network,
|
|
177
|
+
processor.config.address,
|
|
178
|
+
BigInt(tx.version),
|
|
179
|
+
tx
|
|
180
|
+
)
|
|
181
|
+
if (tx) {
|
|
182
|
+
const payload = tx.payload as TransactionPayload_EntryFunctionPayload
|
|
183
|
+
const decoded = TYPE_REGISTRY.decodeFunctionPayload(payload)
|
|
184
|
+
await handler(decoded, ctx)
|
|
185
|
+
}
|
|
186
|
+
return ctx.getProcessResult()
|
|
187
|
+
},
|
|
188
|
+
filters: _filters,
|
|
189
|
+
})
|
|
190
|
+
return this
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
getChainId(): string {
|
|
194
|
+
return getChainId(this.config.network)
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
loadTypes(registry: TypeRegistry) {
|
|
198
|
+
if (registry.contains(this.config.address, this.moduleName)) {
|
|
199
|
+
return
|
|
200
|
+
}
|
|
201
|
+
this.loadTypesInternal(registry)
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
protected loadTypesInternal(registry: TypeRegistry) {
|
|
205
|
+
// should be override by subclass
|
|
206
|
+
console.log('')
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
export class AptosAccountProcessorState extends ListStateStorage<AptosAccountProcessor> {
|
|
211
|
+
static INSTANCE = new AptosAccountProcessorState()
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
export class AptosAccountProcessor {
|
|
215
|
+
config: IndexConfigure
|
|
216
|
+
|
|
217
|
+
resourcesHandlers: ResourceHandlder[] = []
|
|
218
|
+
|
|
219
|
+
static bind(options: AptosBindOptions): AptosAccountProcessor {
|
|
220
|
+
return new AptosAccountProcessor(options)
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
protected constructor(options: AptosBindOptions) {
|
|
224
|
+
this.config = configure(options)
|
|
225
|
+
AptosAccountProcessorState.INSTANCE.addValue(this)
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
getChainId(): string {
|
|
229
|
+
return getChainId(this.config.network)
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
private onInterval(
|
|
233
|
+
handler: (resources: MoveResource[], ctx: AptosResourceContext) => void,
|
|
234
|
+
timeInterval: HandleInterval | undefined,
|
|
235
|
+
versionInterval: HandleInterval | undefined,
|
|
236
|
+
type: string | undefined
|
|
237
|
+
) {
|
|
238
|
+
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
239
|
+
const processor = this
|
|
240
|
+
this.resourcesHandlers.push({
|
|
241
|
+
handler: async function (arg) {
|
|
242
|
+
const ctx = new AptosResourceContext(
|
|
243
|
+
processor.config.network,
|
|
244
|
+
processor.config.address,
|
|
245
|
+
arg.version,
|
|
246
|
+
arg.timestamp
|
|
247
|
+
)
|
|
248
|
+
await handler(arg.resources, ctx)
|
|
249
|
+
return ctx.getProcessResult()
|
|
250
|
+
},
|
|
251
|
+
timeIntervalInMinutes: timeInterval,
|
|
252
|
+
versionInterval: versionInterval,
|
|
253
|
+
type: type,
|
|
254
|
+
})
|
|
255
|
+
return this
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
public onTimeInterval(
|
|
259
|
+
handler: (resources: MoveResource[], ctx: AptosResourceContext) => void,
|
|
260
|
+
timeIntervalInMinutes = 60,
|
|
261
|
+
backfillTimeIntervalInMinutes = 240,
|
|
262
|
+
type?: string
|
|
263
|
+
) {
|
|
264
|
+
return this.onInterval(
|
|
265
|
+
handler,
|
|
266
|
+
{
|
|
267
|
+
recentInterval: timeIntervalInMinutes,
|
|
268
|
+
backfillInterval: backfillTimeIntervalInMinutes,
|
|
269
|
+
},
|
|
270
|
+
undefined,
|
|
271
|
+
type
|
|
272
|
+
)
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
public onVersionInterval(
|
|
276
|
+
handler: (resources: MoveResource[], ctx: AptosResourceContext) => void,
|
|
277
|
+
versionInterval = 100000,
|
|
278
|
+
backfillVersionInterval = 400000,
|
|
279
|
+
typePrefix?: string
|
|
280
|
+
) {
|
|
281
|
+
return this.onInterval(
|
|
282
|
+
handler,
|
|
283
|
+
undefined,
|
|
284
|
+
{ recentInterval: versionInterval, backfillInterval: backfillVersionInterval },
|
|
285
|
+
typePrefix
|
|
286
|
+
)
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
function configure(options: AptosBindOptions): IndexConfigure {
|
|
291
|
+
let startVersion = 0n
|
|
292
|
+
if (options.startVersion !== undefined) {
|
|
293
|
+
if (typeof options.startVersion === 'number') {
|
|
294
|
+
startVersion = BigInt(options.startVersion)
|
|
295
|
+
} else {
|
|
296
|
+
startVersion = options.startVersion
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
return {
|
|
301
|
+
startVersion: startVersion,
|
|
302
|
+
address: options.address,
|
|
303
|
+
network: options.network || AptosNetwork.MAIN_NET,
|
|
304
|
+
}
|
|
305
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import Long from 'long'
|
|
2
|
+
import { RecordMetaData } from '../gen'
|
|
3
|
+
import { Labels } from '../core/metadata'
|
|
4
|
+
import { normalizeLabels } from '../core/meter'
|
|
5
|
+
import { BaseContext } from '../core/base-context'
|
|
6
|
+
import { Transaction_UserTransaction } from 'aptos-sdk/src/generated'
|
|
7
|
+
import { AptosNetwork, getChainId } from './network'
|
|
8
|
+
|
|
9
|
+
export class AptosContext extends BaseContext {
|
|
10
|
+
address: string
|
|
11
|
+
network: AptosNetwork
|
|
12
|
+
moduleName: string
|
|
13
|
+
version: bigint
|
|
14
|
+
transaction: Transaction_UserTransaction
|
|
15
|
+
|
|
16
|
+
constructor(
|
|
17
|
+
moduleName: string,
|
|
18
|
+
network: AptosNetwork,
|
|
19
|
+
address: string,
|
|
20
|
+
version: bigint,
|
|
21
|
+
transaction?: Transaction_UserTransaction
|
|
22
|
+
) {
|
|
23
|
+
super()
|
|
24
|
+
this.address = address
|
|
25
|
+
this.network = network
|
|
26
|
+
this.moduleName = moduleName
|
|
27
|
+
this.version = version
|
|
28
|
+
if (transaction) {
|
|
29
|
+
this.transaction = transaction
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
getMetaData(name: string, labels: Labels): RecordMetaData {
|
|
34
|
+
return {
|
|
35
|
+
address: this.address,
|
|
36
|
+
contractName: this.moduleName,
|
|
37
|
+
blockNumber: Long.fromString(this.version.toString()),
|
|
38
|
+
transactionIndex: 0,
|
|
39
|
+
transactionHash: this.transaction?.hash || '', // TODO
|
|
40
|
+
logIndex: 0,
|
|
41
|
+
chainId: getChainId(this.network),
|
|
42
|
+
name: name,
|
|
43
|
+
labels: normalizeLabels(labels),
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export class AptosResourceContext extends BaseContext {
|
|
49
|
+
address: string
|
|
50
|
+
network: AptosNetwork
|
|
51
|
+
version: bigint
|
|
52
|
+
timestampInMicros: number
|
|
53
|
+
|
|
54
|
+
constructor(network: AptosNetwork, address: string, version: bigint, timestampInMicros: number) {
|
|
55
|
+
super()
|
|
56
|
+
this.address = address
|
|
57
|
+
this.network = network
|
|
58
|
+
this.version = version
|
|
59
|
+
this.timestampInMicros = timestampInMicros
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
getMetaData(name: string, labels: Labels): RecordMetaData {
|
|
63
|
+
return {
|
|
64
|
+
address: this.address,
|
|
65
|
+
contractName: 'resources',
|
|
66
|
+
blockNumber: Long.fromString(this.version.toString()),
|
|
67
|
+
transactionIndex: 0,
|
|
68
|
+
transactionHash: '',
|
|
69
|
+
logIndex: 0,
|
|
70
|
+
chainId: getChainId(this.network),
|
|
71
|
+
name: name,
|
|
72
|
+
labels: normalizeLabels(labels),
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export type { Transaction_UserTransaction, TransactionPayload_EntryFunctionPayload } from 'aptos-sdk/src/generated'
|
|
2
|
+
export type { EventInstance, TypedEventInstance, TypedEntryFunctionPayload, TypedMoveResource } from './models'
|
|
3
|
+
export { TYPE_REGISTRY, TypeRegistry } from './type-registry'
|
|
4
|
+
export type { FunctionNameAndCallFilter, EventFilter, CallFilter, ArgumentsFilter } from './aptos-processor'
|
|
5
|
+
export { AptosBaseProcessor, AptosAccountProcessor } from './aptos-processor'
|
|
6
|
+
export { AptosContext, AptosResourceContext } from './context'
|
|
7
|
+
export { AptosBindOptions, AptosNetwork, getRpcClient } from './network'
|
|
8
|
+
export * from './api'
|
|
9
|
+
|
|
10
|
+
export { AptosPlugin } from './aptos-plugin'
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { Event, MoveResource, TransactionPayload_EntryFunctionPayload } from 'aptos-sdk/src/generated'
|
|
2
|
+
|
|
3
|
+
export type EventInstance = Event & {
|
|
4
|
+
version: string
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export type TypedEventInstance<T> = EventInstance & {
|
|
8
|
+
// Typed data converted from ABI
|
|
9
|
+
// undefined if there is converting error, usually because the ABI/data
|
|
10
|
+
// mismatch
|
|
11
|
+
data_typed: T
|
|
12
|
+
|
|
13
|
+
type_arguments: string[]
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
// Don't use intermedidate type to make IDE happier
|
|
17
|
+
export type TypedEntryFunctionPayload<T extends Array<any>> = TransactionPayload_EntryFunctionPayload & {
|
|
18
|
+
arguments_typed: T
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export type TypedMoveResource<T> = MoveResource & {
|
|
22
|
+
data_typed: T
|
|
23
|
+
type_arguments: string[]
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export interface StructWithTag {
|
|
27
|
+
type: string
|
|
28
|
+
data: any
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export interface StructWithType<T> extends StructWithTag {
|
|
32
|
+
data_typed: T
|
|
33
|
+
type_arguments: string[]
|
|
34
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { CHAIN_IDS, CHAIN_MAP, getChainName } from '../utils/chain'
|
|
2
|
+
import { AptosClient } from 'aptos-sdk'
|
|
3
|
+
|
|
4
|
+
export enum AptosNetwork {
|
|
5
|
+
MAIN_NET = 1,
|
|
6
|
+
TEST_NET = 2,
|
|
7
|
+
// DEV_NET,
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export function getChainId(network: AptosNetwork): string {
|
|
11
|
+
switch (network) {
|
|
12
|
+
case AptosNetwork.TEST_NET:
|
|
13
|
+
return CHAIN_IDS.APTOS_TESTNET
|
|
14
|
+
}
|
|
15
|
+
return CHAIN_IDS.APTOS_MAINNET
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export function getAptosChainName(network: AptosNetwork): string {
|
|
19
|
+
switch (network) {
|
|
20
|
+
case AptosNetwork.TEST_NET:
|
|
21
|
+
return getChainName(CHAIN_IDS.APTOS_TESTNET)
|
|
22
|
+
}
|
|
23
|
+
return getChainName(CHAIN_IDS.APTOS_MAINNET)
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export function getRpcEndpoint(network: AptosNetwork): string {
|
|
27
|
+
switch (network) {
|
|
28
|
+
case AptosNetwork.TEST_NET:
|
|
29
|
+
return 'https://testnet.aptoslabs.com/'
|
|
30
|
+
}
|
|
31
|
+
return 'https://mainnet.aptoslabs.com/'
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export function getRpcClient(network: AptosNetwork): AptosClient {
|
|
35
|
+
return new AptosClient(getRpcEndpoint(network))
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export class AptosBindOptions {
|
|
39
|
+
address: string
|
|
40
|
+
network?: AptosNetwork = AptosNetwork.MAIN_NET
|
|
41
|
+
startVersion?: bigint | number
|
|
42
|
+
}
|