@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
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.AptosResourceContext = exports.AptosContext = void 0;
|
|
7
|
+
const long_1 = __importDefault(require("long"));
|
|
8
|
+
const meter_1 = require("../core/meter");
|
|
9
|
+
const base_context_1 = require("../core/base-context");
|
|
10
|
+
const network_1 = require("./network");
|
|
11
|
+
class AptosContext extends base_context_1.BaseContext {
|
|
12
|
+
address;
|
|
13
|
+
network;
|
|
14
|
+
moduleName;
|
|
15
|
+
version;
|
|
16
|
+
transaction;
|
|
17
|
+
constructor(moduleName, network, address, version, transaction) {
|
|
18
|
+
super();
|
|
19
|
+
this.address = address;
|
|
20
|
+
this.network = network;
|
|
21
|
+
this.moduleName = moduleName;
|
|
22
|
+
this.version = version;
|
|
23
|
+
if (transaction) {
|
|
24
|
+
this.transaction = transaction;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
getMetaData(name, labels) {
|
|
28
|
+
return {
|
|
29
|
+
address: this.address,
|
|
30
|
+
contractName: this.moduleName,
|
|
31
|
+
blockNumber: long_1.default.fromString(this.version.toString()),
|
|
32
|
+
transactionIndex: 0,
|
|
33
|
+
transactionHash: this.transaction?.hash || '',
|
|
34
|
+
logIndex: 0,
|
|
35
|
+
chainId: (0, network_1.getChainId)(this.network),
|
|
36
|
+
name: name,
|
|
37
|
+
labels: (0, meter_1.normalizeLabels)(labels),
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
exports.AptosContext = AptosContext;
|
|
42
|
+
class AptosResourceContext extends base_context_1.BaseContext {
|
|
43
|
+
address;
|
|
44
|
+
network;
|
|
45
|
+
version;
|
|
46
|
+
timestampInMicros;
|
|
47
|
+
constructor(network, address, version, timestampInMicros) {
|
|
48
|
+
super();
|
|
49
|
+
this.address = address;
|
|
50
|
+
this.network = network;
|
|
51
|
+
this.version = version;
|
|
52
|
+
this.timestampInMicros = timestampInMicros;
|
|
53
|
+
}
|
|
54
|
+
getMetaData(name, labels) {
|
|
55
|
+
return {
|
|
56
|
+
address: this.address,
|
|
57
|
+
contractName: 'resources',
|
|
58
|
+
blockNumber: long_1.default.fromString(this.version.toString()),
|
|
59
|
+
transactionIndex: 0,
|
|
60
|
+
transactionHash: '',
|
|
61
|
+
logIndex: 0,
|
|
62
|
+
chainId: (0, network_1.getChainId)(this.network),
|
|
63
|
+
name: name,
|
|
64
|
+
labels: (0, meter_1.normalizeLabels)(labels),
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
exports.AptosResourceContext = AptosResourceContext;
|
|
69
|
+
//# sourceMappingURL=context.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context.js","sourceRoot":"","sources":["../../src/aptos/context.ts"],"names":[],"mappings":";;;;;;AAAA,gDAAuB;AAGvB,yCAA+C;AAC/C,uDAAkD;AAElD,uCAAoD;AAEpD,MAAa,YAAa,SAAQ,0BAAW;IAC3C,OAAO,CAAQ;IACf,OAAO,CAAc;IACrB,UAAU,CAAQ;IAClB,OAAO,CAAQ;IACf,WAAW,CAA6B;IAExC,YACE,UAAkB,EAClB,OAAqB,EACrB,OAAe,EACf,OAAe,EACf,WAAyC;QAEzC,KAAK,EAAE,CAAA;QACP,IAAI,CAAC,OAAO,GAAG,OAAO,CAAA;QACtB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAA;QACtB,IAAI,CAAC,UAAU,GAAG,UAAU,CAAA;QAC5B,IAAI,CAAC,OAAO,GAAG,OAAO,CAAA;QACtB,IAAI,WAAW,EAAE;YACf,IAAI,CAAC,WAAW,GAAG,WAAW,CAAA;SAC/B;IACH,CAAC;IAED,WAAW,CAAC,IAAY,EAAE,MAAc;QACtC,OAAO;YACL,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,YAAY,EAAE,IAAI,CAAC,UAAU;YAC7B,WAAW,EAAE,cAAI,CAAC,UAAU,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC;YACrD,gBAAgB,EAAE,CAAC;YACnB,eAAe,EAAE,IAAI,CAAC,WAAW,EAAE,IAAI,IAAI,EAAE;YAC7C,QAAQ,EAAE,CAAC;YACX,OAAO,EAAE,IAAA,oBAAU,EAAC,IAAI,CAAC,OAAO,CAAC;YACjC,IAAI,EAAE,IAAI;YACV,MAAM,EAAE,IAAA,uBAAe,EAAC,MAAM,CAAC;SAChC,CAAA;IACH,CAAC;CACF;AArCD,oCAqCC;AAED,MAAa,oBAAqB,SAAQ,0BAAW;IACnD,OAAO,CAAQ;IACf,OAAO,CAAc;IACrB,OAAO,CAAQ;IACf,iBAAiB,CAAQ;IAEzB,YAAY,OAAqB,EAAE,OAAe,EAAE,OAAe,EAAE,iBAAyB;QAC5F,KAAK,EAAE,CAAA;QACP,IAAI,CAAC,OAAO,GAAG,OAAO,CAAA;QACtB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAA;QACtB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAA;QACtB,IAAI,CAAC,iBAAiB,GAAG,iBAAiB,CAAA;IAC5C,CAAC;IAED,WAAW,CAAC,IAAY,EAAE,MAAc;QACtC,OAAO;YACL,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,YAAY,EAAE,WAAW;YACzB,WAAW,EAAE,cAAI,CAAC,UAAU,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC;YACrD,gBAAgB,EAAE,CAAC;YACnB,eAAe,EAAE,EAAE;YACnB,QAAQ,EAAE,CAAC;YACX,OAAO,EAAE,IAAA,oBAAU,EAAC,IAAI,CAAC,OAAO,CAAC;YACjC,IAAI,EAAE,IAAI;YACV,MAAM,EAAE,IAAA,uBAAe,EAAC,MAAM,CAAC;SAChC,CAAA;IACH,CAAC;CACF;AA3BD,oDA2BC","sourcesContent":["import Long from 'long'\nimport { RecordMetaData } from '../gen'\nimport { Labels } from '../core/metadata'\nimport { normalizeLabels } from '../core/meter'\nimport { BaseContext } from '../core/base-context'\nimport { Transaction_UserTransaction } from 'aptos-sdk/src/generated'\nimport { AptosNetwork, getChainId } from './network'\n\nexport class AptosContext extends BaseContext {\n address: string\n network: AptosNetwork\n moduleName: string\n version: bigint\n transaction: Transaction_UserTransaction\n\n constructor(\n moduleName: string,\n network: AptosNetwork,\n address: string,\n version: bigint,\n transaction?: Transaction_UserTransaction\n ) {\n super()\n this.address = address\n this.network = network\n this.moduleName = moduleName\n this.version = version\n if (transaction) {\n this.transaction = transaction\n }\n }\n\n getMetaData(name: string, labels: Labels): RecordMetaData {\n return {\n address: this.address,\n contractName: this.moduleName,\n blockNumber: Long.fromString(this.version.toString()),\n transactionIndex: 0,\n transactionHash: this.transaction?.hash || '', // TODO\n logIndex: 0,\n chainId: getChainId(this.network),\n name: name,\n labels: normalizeLabels(labels),\n }\n }\n}\n\nexport class AptosResourceContext extends BaseContext {\n address: string\n network: AptosNetwork\n version: bigint\n timestampInMicros: number\n\n constructor(network: AptosNetwork, address: string, version: bigint, timestampInMicros: number) {\n super()\n this.address = address\n this.network = network\n this.version = version\n this.timestampInMicros = timestampInMicros\n }\n\n getMetaData(name: string, labels: Labels): RecordMetaData {\n return {\n address: this.address,\n contractName: 'resources',\n blockNumber: Long.fromString(this.version.toString()),\n transactionIndex: 0,\n transactionHash: '',\n logIndex: 0,\n chainId: getChainId(this.network),\n name: name,\n labels: normalizeLabels(labels),\n }\n }\n}\n"]}
|
|
@@ -0,0 +1,9 @@
|
|
|
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
|
+
export { AptosPlugin } from './aptos-plugin';
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.AptosPlugin = exports.getRpcClient = exports.AptosNetwork = exports.AptosBindOptions = exports.AptosResourceContext = exports.AptosContext = exports.AptosAccountProcessor = exports.AptosBaseProcessor = exports.TypeRegistry = exports.TYPE_REGISTRY = void 0;
|
|
18
|
+
var type_registry_1 = require("./type-registry");
|
|
19
|
+
Object.defineProperty(exports, "TYPE_REGISTRY", { enumerable: true, get: function () { return type_registry_1.TYPE_REGISTRY; } });
|
|
20
|
+
Object.defineProperty(exports, "TypeRegistry", { enumerable: true, get: function () { return type_registry_1.TypeRegistry; } });
|
|
21
|
+
var aptos_processor_1 = require("./aptos-processor");
|
|
22
|
+
Object.defineProperty(exports, "AptosBaseProcessor", { enumerable: true, get: function () { return aptos_processor_1.AptosBaseProcessor; } });
|
|
23
|
+
Object.defineProperty(exports, "AptosAccountProcessor", { enumerable: true, get: function () { return aptos_processor_1.AptosAccountProcessor; } });
|
|
24
|
+
var context_1 = require("./context");
|
|
25
|
+
Object.defineProperty(exports, "AptosContext", { enumerable: true, get: function () { return context_1.AptosContext; } });
|
|
26
|
+
Object.defineProperty(exports, "AptosResourceContext", { enumerable: true, get: function () { return context_1.AptosResourceContext; } });
|
|
27
|
+
var network_1 = require("./network");
|
|
28
|
+
Object.defineProperty(exports, "AptosBindOptions", { enumerable: true, get: function () { return network_1.AptosBindOptions; } });
|
|
29
|
+
Object.defineProperty(exports, "AptosNetwork", { enumerable: true, get: function () { return network_1.AptosNetwork; } });
|
|
30
|
+
Object.defineProperty(exports, "getRpcClient", { enumerable: true, get: function () { return network_1.getRpcClient; } });
|
|
31
|
+
__exportStar(require("./api"), exports);
|
|
32
|
+
var aptos_plugin_1 = require("./aptos-plugin");
|
|
33
|
+
Object.defineProperty(exports, "AptosPlugin", { enumerable: true, get: function () { return aptos_plugin_1.AptosPlugin; } });
|
|
34
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/aptos/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAEA,iDAA6D;AAApD,8GAAA,aAAa,OAAA;AAAE,6GAAA,YAAY,OAAA;AAEpC,qDAA6E;AAApE,qHAAA,kBAAkB,OAAA;AAAE,wHAAA,qBAAqB,OAAA;AAClD,qCAA8D;AAArD,uGAAA,YAAY,OAAA;AAAE,+GAAA,oBAAoB,OAAA;AAC3C,qCAAwE;AAA/D,2GAAA,gBAAgB,OAAA;AAAE,uGAAA,YAAY,OAAA;AAAE,uGAAA,YAAY,OAAA;AACrD,wCAAqB;AAErB,+CAA4C;AAAnC,2GAAA,WAAW,OAAA","sourcesContent":["export type { Transaction_UserTransaction, TransactionPayload_EntryFunctionPayload } from 'aptos-sdk/src/generated'\nexport type { EventInstance, TypedEventInstance, TypedEntryFunctionPayload, TypedMoveResource } from './models'\nexport { TYPE_REGISTRY, TypeRegistry } from './type-registry'\nexport type { FunctionNameAndCallFilter, EventFilter, CallFilter, ArgumentsFilter } from './aptos-processor'\nexport { AptosBaseProcessor, AptosAccountProcessor } from './aptos-processor'\nexport { AptosContext, AptosResourceContext } from './context'\nexport { AptosBindOptions, AptosNetwork, getRpcClient } from './network'\nexport * from './api'\n\nexport { AptosPlugin } from './aptos-plugin'\n"]}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Event, MoveResource, TransactionPayload_EntryFunctionPayload } from 'aptos-sdk/src/generated';
|
|
2
|
+
export declare type EventInstance = Event & {
|
|
3
|
+
version: string;
|
|
4
|
+
};
|
|
5
|
+
export declare type TypedEventInstance<T> = EventInstance & {
|
|
6
|
+
data_typed: T;
|
|
7
|
+
type_arguments: string[];
|
|
8
|
+
};
|
|
9
|
+
export declare type TypedEntryFunctionPayload<T extends Array<any>> = TransactionPayload_EntryFunctionPayload & {
|
|
10
|
+
arguments_typed: T;
|
|
11
|
+
};
|
|
12
|
+
export declare type TypedMoveResource<T> = MoveResource & {
|
|
13
|
+
data_typed: T;
|
|
14
|
+
type_arguments: string[];
|
|
15
|
+
};
|
|
16
|
+
export interface StructWithTag {
|
|
17
|
+
type: string;
|
|
18
|
+
data: any;
|
|
19
|
+
}
|
|
20
|
+
export interface StructWithType<T> extends StructWithTag {
|
|
21
|
+
data_typed: T;
|
|
22
|
+
type_arguments: string[];
|
|
23
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"models.js","sourceRoot":"","sources":["../../src/aptos/models.ts"],"names":[],"mappings":"","sourcesContent":["import { Event, MoveResource, TransactionPayload_EntryFunctionPayload } from 'aptos-sdk/src/generated'\n\nexport type EventInstance = Event & {\n version: string\n}\n\nexport type TypedEventInstance<T> = EventInstance & {\n // Typed data converted from ABI\n // undefined if there is converting error, usually because the ABI/data\n // mismatch\n data_typed: T\n\n type_arguments: string[]\n}\n\n// Don't use intermedidate type to make IDE happier\nexport type TypedEntryFunctionPayload<T extends Array<any>> = TransactionPayload_EntryFunctionPayload & {\n arguments_typed: T\n}\n\nexport type TypedMoveResource<T> = MoveResource & {\n data_typed: T\n type_arguments: string[]\n}\n\nexport interface StructWithTag {\n type: string\n data: any\n}\n\nexport interface StructWithType<T> extends StructWithTag {\n data_typed: T\n type_arguments: string[]\n}\n"]}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { AptosClient } from 'aptos-sdk';
|
|
2
|
+
export declare enum AptosNetwork {
|
|
3
|
+
MAIN_NET = 1,
|
|
4
|
+
TEST_NET = 2
|
|
5
|
+
}
|
|
6
|
+
export declare function getChainId(network: AptosNetwork): string;
|
|
7
|
+
export declare function getAptosChainName(network: AptosNetwork): string;
|
|
8
|
+
export declare function getRpcEndpoint(network: AptosNetwork): string;
|
|
9
|
+
export declare function getRpcClient(network: AptosNetwork): AptosClient;
|
|
10
|
+
export declare class AptosBindOptions {
|
|
11
|
+
address: string;
|
|
12
|
+
network?: AptosNetwork;
|
|
13
|
+
startVersion?: bigint | number;
|
|
14
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AptosBindOptions = exports.getRpcClient = exports.getRpcEndpoint = exports.getAptosChainName = exports.getChainId = exports.AptosNetwork = void 0;
|
|
4
|
+
const chain_1 = require("../utils/chain");
|
|
5
|
+
const aptos_sdk_1 = require("aptos-sdk");
|
|
6
|
+
var AptosNetwork;
|
|
7
|
+
(function (AptosNetwork) {
|
|
8
|
+
AptosNetwork[AptosNetwork["MAIN_NET"] = 1] = "MAIN_NET";
|
|
9
|
+
AptosNetwork[AptosNetwork["TEST_NET"] = 2] = "TEST_NET";
|
|
10
|
+
// DEV_NET,
|
|
11
|
+
})(AptosNetwork = exports.AptosNetwork || (exports.AptosNetwork = {}));
|
|
12
|
+
function getChainId(network) {
|
|
13
|
+
switch (network) {
|
|
14
|
+
case AptosNetwork.TEST_NET:
|
|
15
|
+
return chain_1.CHAIN_IDS.APTOS_TESTNET;
|
|
16
|
+
}
|
|
17
|
+
return chain_1.CHAIN_IDS.APTOS_MAINNET;
|
|
18
|
+
}
|
|
19
|
+
exports.getChainId = getChainId;
|
|
20
|
+
function getAptosChainName(network) {
|
|
21
|
+
switch (network) {
|
|
22
|
+
case AptosNetwork.TEST_NET:
|
|
23
|
+
return (0, chain_1.getChainName)(chain_1.CHAIN_IDS.APTOS_TESTNET);
|
|
24
|
+
}
|
|
25
|
+
return (0, chain_1.getChainName)(chain_1.CHAIN_IDS.APTOS_MAINNET);
|
|
26
|
+
}
|
|
27
|
+
exports.getAptosChainName = getAptosChainName;
|
|
28
|
+
function getRpcEndpoint(network) {
|
|
29
|
+
switch (network) {
|
|
30
|
+
case AptosNetwork.TEST_NET:
|
|
31
|
+
return 'https://testnet.aptoslabs.com/';
|
|
32
|
+
}
|
|
33
|
+
return 'https://mainnet.aptoslabs.com/';
|
|
34
|
+
}
|
|
35
|
+
exports.getRpcEndpoint = getRpcEndpoint;
|
|
36
|
+
function getRpcClient(network) {
|
|
37
|
+
return new aptos_sdk_1.AptosClient(getRpcEndpoint(network));
|
|
38
|
+
}
|
|
39
|
+
exports.getRpcClient = getRpcClient;
|
|
40
|
+
class AptosBindOptions {
|
|
41
|
+
address;
|
|
42
|
+
network = AptosNetwork.MAIN_NET;
|
|
43
|
+
startVersion;
|
|
44
|
+
}
|
|
45
|
+
exports.AptosBindOptions = AptosBindOptions;
|
|
46
|
+
//# sourceMappingURL=network.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"network.js","sourceRoot":"","sources":["../../src/aptos/network.ts"],"names":[],"mappings":";;;AAAA,0CAAmE;AACnE,yCAAuC;AAEvC,IAAY,YAIX;AAJD,WAAY,YAAY;IACtB,uDAAY,CAAA;IACZ,uDAAY,CAAA;IACZ,WAAW;AACb,CAAC,EAJW,YAAY,GAAZ,oBAAY,KAAZ,oBAAY,QAIvB;AAED,SAAgB,UAAU,CAAC,OAAqB;IAC9C,QAAQ,OAAO,EAAE;QACf,KAAK,YAAY,CAAC,QAAQ;YACxB,OAAO,iBAAS,CAAC,aAAa,CAAA;KACjC;IACD,OAAO,iBAAS,CAAC,aAAa,CAAA;AAChC,CAAC;AAND,gCAMC;AAED,SAAgB,iBAAiB,CAAC,OAAqB;IACrD,QAAQ,OAAO,EAAE;QACf,KAAK,YAAY,CAAC,QAAQ;YACxB,OAAO,IAAA,oBAAY,EAAC,iBAAS,CAAC,aAAa,CAAC,CAAA;KAC/C;IACD,OAAO,IAAA,oBAAY,EAAC,iBAAS,CAAC,aAAa,CAAC,CAAA;AAC9C,CAAC;AAND,8CAMC;AAED,SAAgB,cAAc,CAAC,OAAqB;IAClD,QAAQ,OAAO,EAAE;QACf,KAAK,YAAY,CAAC,QAAQ;YACxB,OAAO,gCAAgC,CAAA;KAC1C;IACD,OAAO,gCAAgC,CAAA;AACzC,CAAC;AAND,wCAMC;AAED,SAAgB,YAAY,CAAC,OAAqB;IAChD,OAAO,IAAI,uBAAW,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC,CAAA;AACjD,CAAC;AAFD,oCAEC;AAED,MAAa,gBAAgB;IAC3B,OAAO,CAAQ;IACf,OAAO,GAAkB,YAAY,CAAC,QAAQ,CAAA;IAC9C,YAAY,CAAkB;CAC/B;AAJD,4CAIC","sourcesContent":["import { CHAIN_IDS, CHAIN_MAP, getChainName } from '../utils/chain'\nimport { AptosClient } from 'aptos-sdk'\n\nexport enum AptosNetwork {\n MAIN_NET = 1,\n TEST_NET = 2,\n // DEV_NET,\n}\n\nexport function getChainId(network: AptosNetwork): string {\n switch (network) {\n case AptosNetwork.TEST_NET:\n return CHAIN_IDS.APTOS_TESTNET\n }\n return CHAIN_IDS.APTOS_MAINNET\n}\n\nexport function getAptosChainName(network: AptosNetwork): string {\n switch (network) {\n case AptosNetwork.TEST_NET:\n return getChainName(CHAIN_IDS.APTOS_TESTNET)\n }\n return getChainName(CHAIN_IDS.APTOS_MAINNET)\n}\n\nexport function getRpcEndpoint(network: AptosNetwork): string {\n switch (network) {\n case AptosNetwork.TEST_NET:\n return 'https://testnet.aptoslabs.com/'\n }\n return 'https://mainnet.aptoslabs.com/'\n}\n\nexport function getRpcClient(network: AptosNetwork): AptosClient {\n return new AptosClient(getRpcEndpoint(network))\n}\n\nexport class AptosBindOptions {\n address: string\n network?: AptosNetwork = AptosNetwork.MAIN_NET\n startVersion?: bigint | number\n}\n"]}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.decode = void 0;
|
|
4
|
+
function decode(struct, args) {
|
|
5
|
+
if (args.length != struct.fields.length) {
|
|
6
|
+
console.log('type mismatch actually data for', struct.name);
|
|
7
|
+
return undefined;
|
|
8
|
+
}
|
|
9
|
+
const res = {};
|
|
10
|
+
for (const [i, field] of struct.fields.entries()) {
|
|
11
|
+
res[field.name] = args[i];
|
|
12
|
+
}
|
|
13
|
+
return res;
|
|
14
|
+
}
|
|
15
|
+
exports.decode = decode;
|
|
16
|
+
//# sourceMappingURL=runtime.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtime.js","sourceRoot":"","sources":["../../src/aptos/runtime.ts"],"names":[],"mappings":";;;AAEA,SAAgB,MAAM,CAAI,MAAkB,EAAE,IAAW;IACvD,IAAI,IAAI,CAAC,MAAM,IAAI,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE;QACvC,OAAO,CAAC,GAAG,CAAC,iCAAiC,EAAE,MAAM,CAAC,IAAI,CAAC,CAAA;QAC3D,OAAO,SAAS,CAAA;KACjB;IACD,MAAM,GAAG,GAAQ,EAAE,CAAA;IACnB,KAAK,MAAM,CAAC,CAAC,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE,EAAE;QAChD,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,CAAA;KAC1B;IACD,OAAO,GAAQ,CAAA;AACjB,CAAC;AAVD,wBAUC","sourcesContent":["import { MoveStruct } from 'aptos-sdk/src/generated'\n\nexport function decode<T>(struct: MoveStruct, args: any[]): T | undefined {\n if (args.length != struct.fields.length) {\n console.log('type mismatch actually data for', struct.name)\n return undefined\n }\n const res: any = {}\n for (const [i, field] of struct.fields.entries()) {\n res[field.name] = args[i]\n }\n return res as T\n}\n"]}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Event, MoveFunction, MoveModule, MoveResource, MoveStruct, TransactionPayload_EntryFunctionPayload } from 'aptos-sdk/src/generated';
|
|
2
|
+
import { TypeDescriptor } from './types';
|
|
3
|
+
import { TypedEventInstance, TypedMoveResource } from './models';
|
|
4
|
+
export declare class TypeRegistry {
|
|
5
|
+
moduleMapping: Map<string, MoveModule>;
|
|
6
|
+
typeMapping: Map<string, MoveStruct>;
|
|
7
|
+
funcMapping: Map<string, MoveFunction>;
|
|
8
|
+
contains(account: string, name: string): boolean;
|
|
9
|
+
load(module: MoveModule): void;
|
|
10
|
+
getMoveStruct(type: string): MoveStruct;
|
|
11
|
+
getMoveFunction(type: string): MoveFunction;
|
|
12
|
+
decode(data: any, type: TypeDescriptor): any;
|
|
13
|
+
decodeEvent<T>(event: Event): TypedEventInstance<T> | undefined;
|
|
14
|
+
filterAndDecodeEvents<T>(typeQname: string, resources: Event[]): TypedEventInstance<T>[];
|
|
15
|
+
decodeResource<T>(res: MoveResource): TypedMoveResource<T> | undefined;
|
|
16
|
+
filterAndDecodeResources<T>(typeQname: string, resources: MoveResource[]): TypedMoveResource<T>[];
|
|
17
|
+
private filterAndDecodeInternal;
|
|
18
|
+
private decodedInternal;
|
|
19
|
+
decodeFunctionPayload(payload: TransactionPayload_EntryFunctionPayload): TransactionPayload_EntryFunctionPayload;
|
|
20
|
+
}
|
|
21
|
+
export declare const TYPE_REGISTRY: TypeRegistry;
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TYPE_REGISTRY = exports.TypeRegistry = void 0;
|
|
4
|
+
const utils_1 = require("./utils");
|
|
5
|
+
const types_1 = require("./types");
|
|
6
|
+
class TypeRegistry {
|
|
7
|
+
moduleMapping = new Map();
|
|
8
|
+
typeMapping = new Map();
|
|
9
|
+
funcMapping = new Map();
|
|
10
|
+
contains(account, name) {
|
|
11
|
+
return this.moduleMapping.has(account + '::' + name);
|
|
12
|
+
}
|
|
13
|
+
load(module) {
|
|
14
|
+
if (this.contains(module.address, module.name)) {
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
this.moduleMapping.set((0, utils_1.moduleQname)(module), module);
|
|
18
|
+
for (const struct of module.structs) {
|
|
19
|
+
// TODO move to util
|
|
20
|
+
const key = [module.address, module.name, struct.name].join(utils_1.SPLITTER);
|
|
21
|
+
this.typeMapping.set(key, struct);
|
|
22
|
+
}
|
|
23
|
+
for (const func of module.exposed_functions) {
|
|
24
|
+
if (!func.is_entry) {
|
|
25
|
+
continue;
|
|
26
|
+
}
|
|
27
|
+
const key = [module.address, module.name, func.name].join(utils_1.SPLITTER);
|
|
28
|
+
this.funcMapping.set(key, func);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
getMoveStruct(type) {
|
|
32
|
+
const struct = this.typeMapping.get(type);
|
|
33
|
+
if (!struct) {
|
|
34
|
+
throw new Error('Failed to load type' + type);
|
|
35
|
+
}
|
|
36
|
+
return struct;
|
|
37
|
+
}
|
|
38
|
+
getMoveFunction(type) {
|
|
39
|
+
const func = this.funcMapping.get(type);
|
|
40
|
+
if (!func) {
|
|
41
|
+
throw new Error('Failed to load function' + type);
|
|
42
|
+
}
|
|
43
|
+
return func;
|
|
44
|
+
}
|
|
45
|
+
decode(data, type) {
|
|
46
|
+
// process simple type
|
|
47
|
+
if (type.qname.startsWith('&')) {
|
|
48
|
+
return data;
|
|
49
|
+
}
|
|
50
|
+
switch (type.qname) {
|
|
51
|
+
case 'signer': // TODO check this
|
|
52
|
+
case 'address':
|
|
53
|
+
case '0x1::string::String':
|
|
54
|
+
case 'bool':
|
|
55
|
+
case 'u8':
|
|
56
|
+
case 'u16':
|
|
57
|
+
case 'u32':
|
|
58
|
+
return data;
|
|
59
|
+
case 'u64':
|
|
60
|
+
case 'u128':
|
|
61
|
+
return BigInt(data);
|
|
62
|
+
}
|
|
63
|
+
// process vector
|
|
64
|
+
if (type.qname === utils_1.VECTOR_STR) {
|
|
65
|
+
// vector<u8> as hex string
|
|
66
|
+
if (type.typeArgs[0].qname === 'u8') {
|
|
67
|
+
return data;
|
|
68
|
+
}
|
|
69
|
+
const res = [];
|
|
70
|
+
for (const entry of data) {
|
|
71
|
+
res.push(this.decode(entry, type.typeArgs[0]));
|
|
72
|
+
}
|
|
73
|
+
return res;
|
|
74
|
+
}
|
|
75
|
+
// Process complex type
|
|
76
|
+
const struct = this.getMoveStruct(type.qname);
|
|
77
|
+
const typeCtx = new Map();
|
|
78
|
+
for (const [idx, typeArg] of type.typeArgs.entries()) {
|
|
79
|
+
typeCtx.set('T' + idx, typeArg);
|
|
80
|
+
}
|
|
81
|
+
const typedData = {};
|
|
82
|
+
for (const field of struct.fields) {
|
|
83
|
+
let filedType = (0, types_1.parseMoveType)(field.type);
|
|
84
|
+
filedType = filedType.applyTypeArgs(typeCtx);
|
|
85
|
+
const value = this.decode(data[field.name], filedType);
|
|
86
|
+
typedData[field.name] = value;
|
|
87
|
+
}
|
|
88
|
+
return typedData;
|
|
89
|
+
}
|
|
90
|
+
decodeEvent(event) {
|
|
91
|
+
return this.decodedInternal(event);
|
|
92
|
+
}
|
|
93
|
+
filterAndDecodeEvents(typeQname, resources) {
|
|
94
|
+
return this.filterAndDecodeInternal(typeQname, resources);
|
|
95
|
+
}
|
|
96
|
+
decodeResource(res) {
|
|
97
|
+
return this.decodedInternal(res);
|
|
98
|
+
}
|
|
99
|
+
filterAndDecodeResources(typeQname, resources) {
|
|
100
|
+
return this.filterAndDecodeInternal(typeQname, resources);
|
|
101
|
+
}
|
|
102
|
+
filterAndDecodeInternal(typeQname, structs) {
|
|
103
|
+
if (!structs) {
|
|
104
|
+
return [];
|
|
105
|
+
}
|
|
106
|
+
const results = [];
|
|
107
|
+
for (const resource of structs) {
|
|
108
|
+
if (resource.type.split('<')[0] !== typeQname) {
|
|
109
|
+
continue;
|
|
110
|
+
}
|
|
111
|
+
const result = this.decodedInternal(resource);
|
|
112
|
+
if (result) {
|
|
113
|
+
results.push(result);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
return results;
|
|
117
|
+
}
|
|
118
|
+
decodedInternal(typeStruct) {
|
|
119
|
+
const registry = exports.TYPE_REGISTRY;
|
|
120
|
+
// this.loadTypes(registry)
|
|
121
|
+
// TODO check if module is not loaded
|
|
122
|
+
const typeDescriptor = (0, types_1.parseMoveType)(typeStruct.type);
|
|
123
|
+
const typeArguments = typeDescriptor.typeArgs.map((t) => t.getSignature());
|
|
124
|
+
let dataTyped = undefined;
|
|
125
|
+
try {
|
|
126
|
+
dataTyped = registry.decode(typeStruct.data, typeDescriptor);
|
|
127
|
+
}
|
|
128
|
+
catch (e) {
|
|
129
|
+
console.error('Decoding error for ', JSON.stringify(typeStruct), e);
|
|
130
|
+
return undefined;
|
|
131
|
+
}
|
|
132
|
+
return { ...typeStruct, data_typed: dataTyped, type_arguments: typeArguments };
|
|
133
|
+
}
|
|
134
|
+
decodeFunctionPayload(payload) {
|
|
135
|
+
const registry = exports.TYPE_REGISTRY;
|
|
136
|
+
// this.loadTypes(registry)
|
|
137
|
+
const argumentsTyped = [];
|
|
138
|
+
try {
|
|
139
|
+
const func = registry.getMoveFunction(payload.function);
|
|
140
|
+
const params = (0, utils_1.getMeaningfulFunctionParams)(func);
|
|
141
|
+
for (const [idx, arg] of payload.arguments.entries()) {
|
|
142
|
+
// TODO consider apply payload.type_arguments, but this might be hard since we don't code gen for them
|
|
143
|
+
const argType = (0, types_1.parseMoveType)(params[idx]);
|
|
144
|
+
argumentsTyped.push(registry.decode(arg, argType));
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
catch (e) {
|
|
148
|
+
console.error('Decoding error for ', JSON.stringify(payload), e);
|
|
149
|
+
return payload;
|
|
150
|
+
}
|
|
151
|
+
return { ...payload, arguments_typed: argumentsTyped };
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
exports.TypeRegistry = TypeRegistry;
|
|
155
|
+
exports.TYPE_REGISTRY = new TypeRegistry();
|
|
156
|
+
//# sourceMappingURL=type-registry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"type-registry.js","sourceRoot":"","sources":["../../src/aptos/type-registry.ts"],"names":[],"mappings":";;;AAQA,mCAAwF;AACxF,mCAAuD;AASvD,MAAa,YAAY;IACvB,aAAa,GAAG,IAAI,GAAG,EAAsB,CAAA;IAC7C,WAAW,GAAG,IAAI,GAAG,EAAsB,CAAA;IAC3C,WAAW,GAAG,IAAI,GAAG,EAAwB,CAAA;IAE7C,QAAQ,CAAC,OAAe,EAAE,IAAY;QACpC,OAAO,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,OAAO,GAAG,IAAI,GAAG,IAAI,CAAC,CAAA;IACtD,CAAC;IAED,IAAI,CAAC,MAAkB;QACrB,IAAI,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,OAAO,EAAE,MAAM,CAAC,IAAI,CAAC,EAAE;YAC9C,OAAM;SACP;QACD,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,IAAA,mBAAW,EAAC,MAAM,CAAC,EAAE,MAAM,CAAC,CAAA;QAEnD,KAAK,MAAM,MAAM,IAAI,MAAM,CAAC,OAAO,EAAE;YACnC,oBAAoB;YACpB,MAAM,GAAG,GAAG,CAAC,MAAM,CAAC,OAAO,EAAE,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,gBAAQ,CAAC,CAAA;YACrE,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,GAAG,EAAE,MAAM,CAAC,CAAA;SAClC;QAED,KAAK,MAAM,IAAI,IAAI,MAAM,CAAC,iBAAiB,EAAE;YAC3C,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE;gBAClB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\n} from 'aptos-sdk/src/generated'\nimport { getMeaningfulFunctionParams, moduleQname, SPLITTER, VECTOR_STR } from './utils'\nimport { parseMoveType, TypeDescriptor } from './types'\nimport {\n TypedEventInstance,\n TypedMoveResource,\n StructWithTag,\n StructWithType,\n TypedEntryFunctionPayload,\n} from './models'\n\nexport class TypeRegistry {\n moduleMapping = new Map<string, MoveModule>()\n typeMapping = new Map<string, MoveStruct>()\n funcMapping = new Map<string, MoveFunction>()\n\n contains(account: string, name: string) {\n return this.moduleMapping.has(account + '::' + name)\n }\n\n load(module: MoveModule) {\n if (this.contains(module.address, module.name)) {\n return\n }\n this.moduleMapping.set(moduleQname(module), module)\n\n for (const struct of module.structs) {\n // TODO move to util\n const key = [module.address, module.name, struct.name].join(SPLITTER)\n this.typeMapping.set(key, struct)\n }\n\n for (const func of module.exposed_functions) {\n if (!func.is_entry) {\n continue\n }\n const key = [module.address, module.name, func.name].join(SPLITTER)\n this.funcMapping.set(key, func)\n }\n }\n\n getMoveStruct(type: string): MoveStruct {\n const struct = this.typeMapping.get(type)\n if (!struct) {\n throw new Error('Failed to load type' + type)\n }\n return struct\n }\n\n getMoveFunction(type: string): MoveFunction {\n const func = this.funcMapping.get(type)\n if (!func) {\n throw new Error('Failed to load function' + type)\n }\n return func\n }\n\n decode(data: any, type: TypeDescriptor): any {\n // process simple type\n if (type.qname.startsWith('&')) {\n return data\n }\n switch (type.qname) {\n case 'signer': // TODO check this\n case 'address':\n case '0x1::string::String':\n case 'bool':\n case 'u8':\n case 'u16':\n case 'u32':\n return data\n case 'u64':\n case 'u128':\n return BigInt(data)\n }\n\n // process vector\n if (type.qname === VECTOR_STR) {\n // vector<u8> as hex string\n if (type.typeArgs[0].qname === 'u8') {\n return data\n }\n\n const res = []\n for (const entry of data) {\n res.push(this.decode(entry, type.typeArgs[0]))\n }\n return res\n }\n\n // Process complex type\n const struct = this.getMoveStruct(type.qname)\n\n const typeCtx = new Map<string, TypeDescriptor>()\n for (const [idx, typeArg] of type.typeArgs.entries()) {\n typeCtx.set('T' + idx, typeArg)\n }\n\n const typedData: any = {}\n\n for (const field of struct.fields) {\n let filedType = parseMoveType(field.type)\n filedType = filedType.applyTypeArgs(typeCtx)\n const value = this.decode(data[field.name], filedType)\n typedData[field.name] = value\n }\n return typedData\n }\n\n decodeEvent<T>(event: Event): TypedEventInstance<T> | undefined {\n return this.decodedInternal<T>(event) as TypedEventInstance<T>\n }\n filterAndDecodeEvents<T>(typeQname: string, resources: Event[]): TypedEventInstance<T>[] {\n return this.filterAndDecodeInternal(typeQname, resources) as TypedEventInstance<T>[]\n }\n decodeResource<T>(res: MoveResource): TypedMoveResource<T> | undefined {\n return this.decodedInternal<T>(res)\n }\n filterAndDecodeResources<T>(typeQname: string, resources: MoveResource[]): TypedMoveResource<T>[] {\n return this.filterAndDecodeInternal(typeQname, resources)\n }\n\n private filterAndDecodeInternal<T>(typeQname: string, structs: StructWithTag[]): StructWithType<T>[] {\n if (!structs) {\n return []\n }\n const results: StructWithType<T>[] = []\n for (const resource of structs) {\n if (resource.type.split('<')[0] !== typeQname) {\n continue\n }\n const result = this.decodedInternal(resource)\n if (result) {\n results.push(result as StructWithType<T>)\n }\n }\n return results\n }\n\n private decodedInternal<T>(typeStruct: StructWithTag): StructWithType<T> | undefined {\n const registry = TYPE_REGISTRY\n // this.loadTypes(registry)\n // TODO check if module is not loaded\n\n const typeDescriptor = parseMoveType(typeStruct.type)\n const typeArguments = typeDescriptor.typeArgs.map((t) => t.getSignature())\n\n let dataTyped = undefined\n try {\n dataTyped = registry.decode(typeStruct.data, typeDescriptor)\n } catch (e) {\n console.error('Decoding error for ', JSON.stringify(typeStruct), e)\n return undefined\n }\n return { ...typeStruct, data_typed: dataTyped, type_arguments: typeArguments } as StructWithType<T>\n }\n\n decodeFunctionPayload(payload: TransactionPayload_EntryFunctionPayload): TransactionPayload_EntryFunctionPayload {\n const registry = TYPE_REGISTRY\n // this.loadTypes(registry)\n const argumentsTyped: any[] = []\n\n try {\n const func = registry.getMoveFunction(payload.function)\n const params = getMeaningfulFunctionParams(func)\n for (const [idx, arg] of payload.arguments.entries()) {\n // TODO consider apply payload.type_arguments, but this might be hard since we don't code gen for them\n const argType = parseMoveType(params[idx])\n argumentsTyped.push(registry.decode(arg, argType))\n }\n } catch (e) {\n console.error('Decoding error for ', JSON.stringify(payload), e)\n return payload\n }\n\n return { ...payload, arguments_typed: argumentsTyped } as TypedEntryFunctionPayload<any>\n }\n}\n\nexport const TYPE_REGISTRY = new TypeRegistry()\n"]}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export declare class TypeDescriptor {
|
|
2
|
+
qname: string;
|
|
3
|
+
typeArgs: TypeDescriptor[];
|
|
4
|
+
constructor(symbol: string, typeParams?: TypeDescriptor[]);
|
|
5
|
+
getSignature(): string;
|
|
6
|
+
applyTypeArgs(ctx: Map<string, TypeDescriptor>): TypeDescriptor;
|
|
7
|
+
dependedTypes(): string[];
|
|
8
|
+
}
|
|
9
|
+
export declare function parseMoveType(type: string): TypeDescriptor;
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parseMoveType = exports.TypeDescriptor = void 0;
|
|
4
|
+
const utils_1 = require("./utils");
|
|
5
|
+
class TypeDescriptor {
|
|
6
|
+
// type: string
|
|
7
|
+
// qualified name without type parameters
|
|
8
|
+
qname;
|
|
9
|
+
// account?: string
|
|
10
|
+
// module?: string
|
|
11
|
+
typeArgs;
|
|
12
|
+
constructor(symbol, typeParams) {
|
|
13
|
+
this.qname = symbol;
|
|
14
|
+
this.typeArgs = typeParams || [];
|
|
15
|
+
}
|
|
16
|
+
getSignature() {
|
|
17
|
+
if (this.typeArgs.length > 0) {
|
|
18
|
+
return this.qname + '<' + this.typeArgs.map((t) => t.getSignature()).join(', ') + '>';
|
|
19
|
+
}
|
|
20
|
+
return this.qname;
|
|
21
|
+
}
|
|
22
|
+
// Replace T0, T1 with more concrete type
|
|
23
|
+
applyTypeArgs(ctx) {
|
|
24
|
+
const replace = ctx.get(this.qname);
|
|
25
|
+
if (replace) {
|
|
26
|
+
return replace;
|
|
27
|
+
}
|
|
28
|
+
if (ctx.size === 0 || this.typeArgs.length === 0) {
|
|
29
|
+
return this;
|
|
30
|
+
}
|
|
31
|
+
const typeArgs = [];
|
|
32
|
+
for (const arg of this.typeArgs) {
|
|
33
|
+
const replace = ctx.get(arg.qname);
|
|
34
|
+
if (replace) {
|
|
35
|
+
typeArgs.push(replace);
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
typeArgs.push(arg.applyTypeArgs(ctx));
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
return new TypeDescriptor(this.qname, typeArgs);
|
|
42
|
+
}
|
|
43
|
+
// all depended types including itself, not include system type
|
|
44
|
+
dependedTypes() {
|
|
45
|
+
if (this.qname.startsWith('&')) {
|
|
46
|
+
return [];
|
|
47
|
+
}
|
|
48
|
+
switch (this.qname) {
|
|
49
|
+
case 'signer':
|
|
50
|
+
case 'address':
|
|
51
|
+
case '0x1::string::String':
|
|
52
|
+
case 'bool':
|
|
53
|
+
case 'u8':
|
|
54
|
+
case 'u16':
|
|
55
|
+
case 'u32':
|
|
56
|
+
case 'u64':
|
|
57
|
+
case 'u128':
|
|
58
|
+
return [];
|
|
59
|
+
}
|
|
60
|
+
// Type parameters are not depended
|
|
61
|
+
if (this.qname.indexOf(utils_1.SPLITTER) == -1) {
|
|
62
|
+
if (this.qname.startsWith('T')) {
|
|
63
|
+
return [];
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
const types = new Set();
|
|
67
|
+
for (const param of this.typeArgs) {
|
|
68
|
+
param.dependedTypes().forEach((t) => types.add(t));
|
|
69
|
+
}
|
|
70
|
+
if (this.qname !== utils_1.VECTOR_STR) {
|
|
71
|
+
types.add(this.qname);
|
|
72
|
+
}
|
|
73
|
+
return Array.from(types);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
exports.TypeDescriptor = TypeDescriptor;
|
|
77
|
+
function parseMoveType(type) {
|
|
78
|
+
// type = type.replace('&', '')
|
|
79
|
+
type = type.replaceAll('&mut ', '&');
|
|
80
|
+
type = type.replaceAll('mut ', '');
|
|
81
|
+
// TODO replace ' ' is not exactly safe, need to double check this
|
|
82
|
+
type = type.replaceAll(' ', '');
|
|
83
|
+
const stack = [new TypeDescriptor('')];
|
|
84
|
+
let buffer = [];
|
|
85
|
+
// xxx:asdf<g1<a,<c,d>>, b, g2<a,b>, e>
|
|
86
|
+
for (let i = 0; i < type.length; i++) {
|
|
87
|
+
const ch = type[i];
|
|
88
|
+
if (ch === '<') {
|
|
89
|
+
// const symbol = type.slice(symbolStart, i)
|
|
90
|
+
// symbolStart =
|
|
91
|
+
const symbol = buffer.join('');
|
|
92
|
+
buffer = [];
|
|
93
|
+
stack[stack.length - 1].qname = symbol;
|
|
94
|
+
stack.push(new TypeDescriptor(''));
|
|
95
|
+
continue;
|
|
96
|
+
}
|
|
97
|
+
if (ch === '>') {
|
|
98
|
+
const typeParam = stack.pop();
|
|
99
|
+
if (!typeParam) {
|
|
100
|
+
throw Error('Uxpectecd stack size');
|
|
101
|
+
}
|
|
102
|
+
if (buffer.length > 0) {
|
|
103
|
+
typeParam.qname = buffer.join('');
|
|
104
|
+
buffer = [];
|
|
105
|
+
}
|
|
106
|
+
stack[stack.length - 1].typeArgs.push(typeParam);
|
|
107
|
+
continue;
|
|
108
|
+
}
|
|
109
|
+
if (ch === ',') {
|
|
110
|
+
const typeParam = stack.pop();
|
|
111
|
+
if (!typeParam) {
|
|
112
|
+
throw Error('Uxpectecd stack size');
|
|
113
|
+
}
|
|
114
|
+
if (buffer.length > 0) {
|
|
115
|
+
typeParam.qname = buffer.join('');
|
|
116
|
+
buffer = [];
|
|
117
|
+
}
|
|
118
|
+
stack[stack.length - 1].typeArgs.push(typeParam);
|
|
119
|
+
// continue parse next param
|
|
120
|
+
stack.push(new TypeDescriptor(''));
|
|
121
|
+
continue;
|
|
122
|
+
}
|
|
123
|
+
buffer.push(ch);
|
|
124
|
+
}
|
|
125
|
+
if (buffer.length > 0) {
|
|
126
|
+
stack[stack.length - 1].qname = buffer.join('');
|
|
127
|
+
}
|
|
128
|
+
const res = stack.pop();
|
|
129
|
+
if (!res || stack.length > 0) {
|
|
130
|
+
throw Error('Uxpectecd stack size');
|
|
131
|
+
}
|
|
132
|
+
return res;
|
|
133
|
+
}
|
|
134
|
+
exports.parseMoveType = parseMoveType;
|
|
135
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/aptos/types.ts"],"names":[],"mappings":";;;AAAA,mCAA8C;AAE9C,MAAa,cAAc;IACzB,eAAe;IAEf,yCAAyC;IACzC,KAAK,CAAQ;IACb,mBAAmB;IACnB,kBAAkB;IAElB,QAAQ,CAAkB;IAE1B,YAAY,MAAc,EAAE,UAA6B;QACvD,IAAI,CAAC,KAAK,GAAG,MAAM,CAAA;QACnB,IAAI,CAAC,QAAQ,GAAG,UAAU,IAAI,EAAE,CAAA;IAClC,CAAC;IAED,YAAY;QACV,IAAI,IAAI,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE;YAC5B,OAAO,IAAI,CAAC,KAAK,GAAG,GAAG,GAAG,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,YAAY,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,GAAG,CAAA;SACtF;QACD,OAAO,IAAI,CAAC,KAAK,CAAA;IACnB,CAAC;IAED,yCAAyC;IACzC,aAAa,CAAC,GAAgC;QAC5C,MAAM,OAAO,GAAG,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;QACnC,IAAI,OAAO,EAAE;YACX,OAAO,OAAO,CAAA;SACf;QACD,IAAI,GAAG,CAAC,IA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GAAG,EAAE,CAAA;IACvB,IAAI,CAAC,GAAG,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE;QAC5B,MAAM,KAAK,CAAC,sBAAsB,CAAC,CAAA;KACpC;IACD,OAAO,GAAG,CAAA;AACZ,CAAC;AAhED,sCAgEC","sourcesContent":["import { SPLITTER, VECTOR_STR } from './utils'\n\nexport class TypeDescriptor {\n // type: string\n\n // qualified name without type parameters\n qname: string\n // account?: string\n // module?: string\n\n typeArgs: TypeDescriptor[]\n\n constructor(symbol: string, typeParams?: TypeDescriptor[]) {\n this.qname = symbol\n this.typeArgs = typeParams || []\n }\n\n getSignature(): string {\n if (this.typeArgs.length > 0) {\n return this.qname + '<' + this.typeArgs.map((t) => t.getSignature()).join(', ') + '>'\n }\n return this.qname\n }\n\n // Replace T0, T1 with more concrete type\n applyTypeArgs(ctx: Map<string, TypeDescriptor>): TypeDescriptor {\n const replace = ctx.get(this.qname)\n if (replace) {\n return replace\n }\n if (ctx.size === 0 || this.typeArgs.length === 0) {\n return this\n }\n\n const typeArgs: TypeDescriptor[] = []\n for (const arg of this.typeArgs) {\n const replace = ctx.get(arg.qname)\n if (replace) {\n typeArgs.push(replace)\n } else {\n typeArgs.push(arg.applyTypeArgs(ctx))\n }\n }\n return new TypeDescriptor(this.qname, typeArgs)\n }\n\n // all depended types including itself, not include system type\n dependedTypes(): string[] {\n if (this.qname.startsWith('&')) {\n return []\n }\n switch (this.qname) {\n case 'signer':\n case 'address':\n case '0x1::string::String':\n case 'bool':\n case 'u8':\n case 'u16':\n case 'u32':\n case 'u64':\n case 'u128':\n return []\n }\n\n // Type parameters are not depended\n if (this.qname.indexOf(SPLITTER) == -1) {\n if (this.qname.startsWith('T')) {\n return []\n }\n }\n\n const types = new Set<string>()\n for (const param of this.typeArgs) {\n param.dependedTypes().forEach((t) => types.add(t))\n }\n\n if (this.qname !== VECTOR_STR) {\n types.add(this.qname)\n }\n\n return Array.from(types)\n }\n}\n\nexport function parseMoveType(type: string): TypeDescriptor {\n // type = type.replace('&', '')\n\n type = type.replaceAll('&mut ', '&')\n type = type.replaceAll('mut ', '')\n\n // TODO replace ' ' is not exactly safe, need to double check this\n type = type.replaceAll(' ', '')\n\n const stack: TypeDescriptor[] = [new TypeDescriptor('')]\n let buffer = []\n\n // xxx:asdf<g1<a,<c,d>>, b, g2<a,b>, e>\n for (let i = 0; i < type.length; i++) {\n const ch = type[i]\n if (ch === '<') {\n // const symbol = type.slice(symbolStart, i)\n // symbolStart =\n const symbol = buffer.join('')\n buffer = []\n stack[stack.length - 1].qname = symbol\n stack.push(new TypeDescriptor(''))\n continue\n }\n if (ch === '>') {\n const typeParam = stack.pop()\n if (!typeParam) {\n throw Error('Uxpectecd stack size')\n }\n if (buffer.length > 0) {\n typeParam.qname = buffer.join('')\n buffer = []\n }\n stack[stack.length - 1].typeArgs.push(typeParam)\n continue\n }\n if (ch === ',') {\n const typeParam = stack.pop()\n if (!typeParam) {\n throw Error('Uxpectecd stack size')\n }\n if (buffer.length > 0) {\n typeParam.qname = buffer.join('')\n buffer = []\n }\n\n stack[stack.length - 1].typeArgs.push(typeParam)\n // continue parse next param\n stack.push(new TypeDescriptor(''))\n continue\n }\n\n buffer.push(ch)\n }\n\n if (buffer.length > 0) {\n stack[stack.length - 1].qname = buffer.join('')\n }\n\n const res = stack.pop()\n if (!res || stack.length > 0) {\n throw Error('Uxpectecd stack size')\n }\n return res\n}\n"]}
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.test.js","sourceRoot":"","sources":["../../src/aptos/types.test.ts"],"names":[],"mappings":";;AAAA,mDAA+C;AAC/C,+CAAoD;AAEpD,QAAQ,CAAC,aAAa,EAAE,GAAG,EAAE;IAC3B,oBAAa,CAAC,SAAS,CAAC,6BAAa,CAAC,CAAA;IACtC,IAAI,CAAC,yBAAyB,EAAE,KAAK,IAAI,EAAE;QACzC,MAAM,OAAO,GAAG,6BAAa,CAAC,qBAAqB,CAAC,IAAI,CAAC,CAAA;QACzD,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAA;IACtB,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA;AAEF,MAAM,IAAI,GAAG;IACX,IAAI,EAAE,wBAAwB;IAC9B,cAAc,EAAE,EAAE;IAClB,SAAS,EAAE,CAAC,oEAAoE,CAAC;IACjF,IAAI,EAAE,EAAE,QAAQ,EAAE,EAAE,EAAE;IACtB,QAAQ,EAAE,oCAAoC;CAC/C,CAAA","sourcesContent":["import { TYPE_REGISTRY } from './type-registry'\nimport { aptos_account } from '../builtin/aptos/0x1'\n\ndescribe('type decode', () => {\n aptos_account.loadTypes(TYPE_REGISTRY)\n test('decode function payload', async () => {\n const decoded = TYPE_REGISTRY.decodeFunctionPayload(data)\n console.log(decoded)\n })\n})\n\nconst data = {\n type: 'entry_function_payload',\n type_arguments: [],\n arguments: ['0xaaaf981fec16d967eb79bb51b4c6d39e75acb3482c6dabddb19ca9adbfceee80'],\n code: { bytecode: '' },\n function: '0x1::aptos_account::create_account',\n}\n"]}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { MoveFunction, MoveModule } from 'aptos-sdk/src/generated';
|
|
2
|
+
export declare const SPLITTER = "::";
|
|
3
|
+
export declare const VECTOR_STR = "vector";
|
|
4
|
+
export declare function isFrameworkAccount(account: string): boolean;
|
|
5
|
+
export declare function moduleQname(module: MoveModule): string;
|
|
6
|
+
export declare function moduleQnameForType(type: string): [string, string];
|
|
7
|
+
export declare function getMeaningfulFunctionParams(func: MoveFunction): string[];
|