@sentio/sdk 2.0.0-rc.9 → 2.0.1-rc.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/aptos/api.d.ts +5 -0
- package/lib/aptos/api.js +21 -0
- package/lib/aptos/api.js.map +1 -0
- package/lib/aptos/aptos-plugin.d.ts +14 -0
- package/lib/aptos/aptos-plugin.js +146 -0
- package/lib/aptos/aptos-plugin.js.map +1 -0
- package/lib/aptos/aptos-processor.d.ts +72 -0
- package/lib/aptos/aptos-processor.js +201 -0
- package/lib/aptos/aptos-processor.js.map +1 -0
- package/lib/aptos/builtin/0x1.d.ts +1914 -0
- package/lib/aptos/builtin/0x1.js +2727 -0
- package/lib/aptos/builtin/0x1.js.map +1 -0
- package/lib/aptos/builtin/0x3.d.ts +491 -0
- package/lib/aptos/builtin/0x3.js +496 -0
- package/lib/aptos/builtin/0x3.js.map +1 -0
- package/lib/aptos/builtin/index.d.ts +2 -0
- package/lib/aptos/builtin/index.js +6 -0
- package/lib/aptos/builtin/index.js.map +1 -0
- package/lib/aptos/codegen/codegen.d.ts +21 -0
- package/lib/aptos/codegen/codegen.js +384 -0
- package/lib/aptos/codegen/codegen.js.map +1 -0
- package/lib/aptos/codegen/index.d.ts +1 -0
- package/lib/aptos/codegen/index.js +2 -0
- package/lib/aptos/codegen/index.js.map +1 -0
- package/lib/aptos/codegen/run.d.ts +1 -0
- package/lib/aptos/codegen/run.js +12 -0
- package/lib/aptos/codegen/run.js.map +1 -0
- package/lib/aptos/codegen/typegen.d.ts +18 -0
- package/lib/aptos/codegen/typegen.js +145 -0
- package/lib/aptos/codegen/typegen.js.map +1 -0
- package/lib/aptos/codegen/typegen.test.d.ts +1 -0
- package/lib/aptos/codegen/typegen.test.js.map +1 -0
- package/lib/aptos/context.d.ts +21 -0
- package/lib/aptos/context.js +59 -0
- package/lib/aptos/context.js.map +1 -0
- package/lib/aptos/index.d.ts +9 -0
- package/lib/aptos/index.js +8 -0
- package/lib/aptos/index.js.map +1 -0
- package/lib/aptos/models.d.ts +29 -0
- package/lib/aptos/models.js +2 -0
- package/lib/aptos/models.js.map +1 -0
- package/lib/aptos/move-coder.d.ts +22 -0
- package/lib/aptos/move-coder.js +162 -0
- package/lib/aptos/move-coder.js.map +1 -0
- package/lib/aptos/move-types.d.ts +10 -0
- package/lib/aptos/move-types.js +2 -0
- package/lib/aptos/move-types.js.map +1 -0
- package/lib/aptos/network.d.ts +11 -0
- package/lib/aptos/network.js +27 -0
- package/lib/aptos/network.js.map +1 -0
- package/lib/aptos/tests/aptos.test.d.ts +1 -0
- package/lib/aptos/tests/aptos.test.js.map +1 -0
- package/lib/aptos/tests/souffl3.d.ts +1 -0
- package/lib/aptos/tests/souffl3.js +44 -0
- package/lib/aptos/tests/souffl3.js.map +1 -0
- package/lib/aptos/tests/types/index.d.ts +3 -0
- package/lib/aptos/tests/types/index.js +7 -0
- package/lib/aptos/tests/types/index.js.map +1 -0
- package/lib/aptos/tests/types/reserved.d.ts +345 -0
- package/lib/aptos/tests/types/reserved.js +301 -0
- package/lib/aptos/tests/types/reserved.js.map +1 -0
- package/lib/aptos/tests/types/soffl3.d.ts +812 -0
- package/lib/aptos/tests/types/soffl3.js +548 -0
- package/lib/aptos/tests/types/soffl3.js.map +1 -0
- package/lib/aptos/tests/types/souffle.d.ts +340 -0
- package/lib/aptos/tests/types/souffle.js +295 -0
- package/lib/aptos/tests/types/souffle.js.map +1 -0
- package/lib/aptos/types.d.ts +9 -0
- package/lib/aptos/types.js +130 -0
- package/lib/aptos/types.js.map +1 -0
- package/lib/aptos/types.test.d.ts +1 -0
- package/lib/aptos/types.test.js.map +1 -0
- package/lib/aptos/utils.d.ts +7 -0
- package/lib/aptos/utils.js +20 -0
- package/lib/aptos/utils.js.map +1 -0
- package/lib/core/big-decimal.d.ts +2 -0
- package/lib/core/big-decimal.js +8 -0
- package/lib/core/big-decimal.js.map +1 -1
- package/lib/{utils → core}/chain.d.ts +0 -0
- package/lib/{utils → core}/chain.js +0 -0
- package/lib/core/chain.js.map +1 -0
- package/lib/core/index.d.ts +2 -4
- package/lib/core/index.js +2 -4
- package/lib/core/index.js.map +1 -1
- package/lib/core/numberish.d.ts +0 -2
- package/lib/core/numberish.js +0 -9
- package/lib/core/numberish.js.map +1 -1
- package/lib/core/sui-plugin.js +1 -1
- package/lib/core/sui-plugin.js.map +1 -1
- package/lib/core/sui-processor.d.ts +1 -1
- package/lib/core/sui-processor.js +1 -1
- package/lib/core/sui-processor.js.map +1 -1
- package/lib/eth/account-processor.d.ts +4 -4
- package/lib/eth/account-processor.js +4 -4
- package/lib/eth/account-processor.js.map +1 -1
- package/lib/eth/base-processor-template.d.ts +6 -5
- package/lib/eth/base-processor-template.js +1 -1
- package/lib/eth/base-processor-template.js.map +1 -1
- package/lib/eth/base-processor.d.ts +6 -5
- package/lib/eth/base-processor.js +3 -2
- package/lib/eth/base-processor.js.map +1 -1
- package/lib/{core → eth}/bind-options.d.ts +0 -0
- package/lib/{core → eth}/bind-options.js +0 -0
- package/lib/eth/bind-options.js.map +1 -0
- package/lib/eth/binds.d.ts +2 -2
- package/lib/eth/binds.js +1 -1
- package/lib/eth/binds.js.map +1 -1
- package/lib/{builtin → eth/builtin}/eacaggregatorproxy/index.d.ts +0 -0
- package/lib/{builtin → eth/builtin}/eacaggregatorproxy/index.js +0 -0
- package/lib/eth/builtin/eacaggregatorproxy/index.js.map +1 -0
- package/lib/{builtin → eth/builtin}/eacaggregatorproxy/test-utils.d.ts +0 -0
- package/lib/{builtin → eth/builtin}/eacaggregatorproxy/test-utils.js +0 -0
- package/lib/eth/builtin/eacaggregatorproxy/test-utils.js.map +1 -0
- package/lib/{builtin → eth/builtin}/erc1155/index.d.ts +0 -0
- package/lib/{builtin → eth/builtin}/erc1155/index.js +0 -0
- package/lib/eth/builtin/erc1155/index.js.map +1 -0
- package/lib/{builtin → eth/builtin}/erc1155/test-utils.d.ts +0 -0
- package/lib/{builtin → eth/builtin}/erc1155/test-utils.js +0 -0
- package/lib/eth/builtin/erc1155/test-utils.js.map +1 -0
- package/lib/{builtin → eth/builtin}/erc20/index.d.ts +0 -0
- package/lib/{builtin → eth/builtin}/erc20/index.js +0 -0
- package/lib/eth/builtin/erc20/index.js.map +1 -0
- package/lib/{builtin → eth/builtin}/erc20/test-utils.d.ts +0 -0
- package/lib/{builtin → eth/builtin}/erc20/test-utils.js +0 -0
- package/lib/eth/builtin/erc20/test-utils.js.map +1 -0
- package/lib/{builtin → eth/builtin}/erc20bytes/index.d.ts +0 -0
- package/lib/{builtin → eth/builtin}/erc20bytes/index.js +0 -0
- package/lib/eth/builtin/erc20bytes/index.js.map +1 -0
- package/lib/{builtin → eth/builtin}/erc20bytes/test-utils.d.ts +0 -0
- package/lib/{builtin → eth/builtin}/erc20bytes/test-utils.js +0 -0
- package/lib/eth/builtin/erc20bytes/test-utils.js.map +1 -0
- package/lib/{builtin → eth/builtin}/erc721/index.d.ts +0 -0
- package/lib/{builtin → eth/builtin}/erc721/index.js +0 -0
- package/lib/eth/builtin/erc721/index.js.map +1 -0
- package/lib/{builtin → eth/builtin}/erc721/test-utils.d.ts +0 -0
- package/lib/{builtin → eth/builtin}/erc721/test-utils.js +0 -0
- package/lib/eth/builtin/erc721/test-utils.js.map +1 -0
- package/lib/{builtin → eth/builtin}/index.d.ts +0 -0
- package/lib/{builtin → eth/builtin}/index.js +0 -0
- package/lib/eth/builtin/index.js.map +1 -0
- package/lib/{builtin → eth/builtin}/internal/EACAggregatorProxy.d.ts +5 -5
- package/lib/{builtin → eth/builtin}/internal/EACAggregatorProxy.js +0 -0
- package/lib/eth/builtin/internal/EACAggregatorProxy.js.map +1 -0
- package/lib/{builtin → eth/builtin}/internal/ERC1155.d.ts +5 -5
- package/lib/{builtin → eth/builtin}/internal/ERC1155.js +0 -0
- package/lib/eth/builtin/internal/ERC1155.js.map +1 -0
- package/lib/{builtin → eth/builtin}/internal/ERC20.d.ts +4 -4
- package/lib/{builtin → eth/builtin}/internal/ERC20.js +0 -0
- package/lib/eth/builtin/internal/ERC20.js.map +1 -0
- package/lib/{builtin → eth/builtin}/internal/ERC20Bytes.d.ts +3 -3
- package/lib/{builtin → eth/builtin}/internal/ERC20Bytes.js +0 -0
- package/lib/eth/builtin/internal/ERC20Bytes.js.map +1 -0
- package/lib/{builtin → eth/builtin}/internal/ERC721.d.ts +4 -4
- package/lib/{builtin → eth/builtin}/internal/ERC721.js +0 -0
- package/lib/eth/builtin/internal/ERC721.js.map +1 -0
- package/lib/{builtin → eth/builtin}/internal/WETH9.d.ts +5 -5
- package/lib/{builtin → eth/builtin}/internal/WETH9.js +0 -0
- package/lib/eth/builtin/internal/WETH9.js.map +1 -0
- package/lib/{builtin → eth/builtin}/internal/common.d.ts +4 -2
- package/lib/{builtin → eth/builtin}/internal/common.js +0 -0
- package/lib/eth/builtin/internal/common.js.map +1 -0
- package/lib/{builtin → eth/builtin}/internal/eacaggregatorproxy_processor.d.ts +5 -5
- package/lib/{builtin → eth/builtin}/internal/eacaggregatorproxy_processor.js +92 -182
- package/lib/eth/builtin/internal/eacaggregatorproxy_processor.js.map +1 -0
- package/lib/{builtin → eth/builtin}/internal/erc1155_processor.d.ts +5 -5
- package/lib/{builtin → eth/builtin}/internal/erc1155_processor.js +27 -52
- package/lib/eth/builtin/internal/erc1155_processor.js.map +1 -0
- package/lib/{builtin → eth/builtin}/internal/erc20_processor.d.ts +4 -4
- package/lib/{builtin → eth/builtin}/internal/erc20_processor.js +42 -82
- package/lib/eth/builtin/internal/erc20_processor.js.map +1 -0
- package/lib/{builtin → eth/builtin}/internal/erc20bytes_processor.d.ts +3 -3
- package/lib/{builtin → eth/builtin}/internal/erc20bytes_processor.js +32 -62
- package/lib/eth/builtin/internal/erc20bytes_processor.js.map +1 -0
- package/lib/{builtin → eth/builtin}/internal/erc721_processor.d.ts +4 -4
- package/lib/{builtin → eth/builtin}/internal/erc721_processor.js +47 -92
- package/lib/eth/builtin/internal/erc721_processor.js.map +1 -0
- package/lib/{builtin → eth/builtin}/internal/factories/EACAggregatorProxy__factory.d.ts +1 -1
- package/lib/{builtin → eth/builtin}/internal/factories/EACAggregatorProxy__factory.js +0 -0
- package/lib/eth/builtin/internal/factories/EACAggregatorProxy__factory.js.map +1 -0
- package/lib/{builtin → eth/builtin}/internal/factories/ERC1155__factory.d.ts +1 -1
- package/lib/{builtin → eth/builtin}/internal/factories/ERC1155__factory.js +0 -0
- package/lib/eth/builtin/internal/factories/ERC1155__factory.js.map +1 -0
- package/lib/{builtin → eth/builtin}/internal/factories/ERC20Bytes__factory.d.ts +1 -1
- package/lib/{builtin → eth/builtin}/internal/factories/ERC20Bytes__factory.js +0 -0
- package/lib/eth/builtin/internal/factories/ERC20Bytes__factory.js.map +1 -0
- package/lib/{builtin → eth/builtin}/internal/factories/ERC20__factory.d.ts +1 -1
- package/lib/{builtin → eth/builtin}/internal/factories/ERC20__factory.js +0 -0
- package/lib/eth/builtin/internal/factories/ERC20__factory.js.map +1 -0
- package/lib/{builtin → eth/builtin}/internal/factories/ERC721__factory.d.ts +1 -1
- package/lib/{builtin → eth/builtin}/internal/factories/ERC721__factory.js +0 -0
- package/lib/eth/builtin/internal/factories/ERC721__factory.js.map +1 -0
- package/lib/{builtin → eth/builtin}/internal/factories/WETH9__factory.d.ts +1 -1
- package/lib/{builtin → eth/builtin}/internal/factories/WETH9__factory.js +0 -0
- package/lib/eth/builtin/internal/factories/WETH9__factory.js.map +1 -0
- package/lib/{builtin → eth/builtin}/internal/factories/index.d.ts +0 -0
- package/lib/{builtin → eth/builtin}/internal/factories/index.js +0 -0
- package/lib/eth/builtin/internal/factories/index.js.map +1 -0
- package/lib/{builtin → eth/builtin}/internal/index.d.ts +0 -0
- package/lib/{builtin → eth/builtin}/internal/index.js +0 -0
- package/lib/eth/builtin/internal/index.js.map +1 -0
- package/lib/{builtin → eth/builtin}/internal/weth9_processor.d.ts +5 -5
- package/lib/{builtin → eth/builtin}/internal/weth9_processor.js +32 -62
- package/lib/eth/builtin/internal/weth9_processor.js.map +1 -0
- package/lib/{builtin → eth/builtin}/weth9/index.d.ts +0 -0
- package/lib/{builtin → eth/builtin}/weth9/index.js +0 -0
- package/lib/eth/builtin/weth9/index.js.map +1 -0
- package/lib/{builtin → eth/builtin}/weth9/test-utils.d.ts +0 -0
- package/lib/{builtin → eth/builtin}/weth9/test-utils.js +0 -0
- package/lib/eth/builtin/weth9/test-utils.js.map +1 -0
- package/lib/eth/codegen/codegen.d.ts +1 -0
- package/lib/eth/codegen/codegen.js +53 -0
- package/lib/eth/codegen/codegen.js.map +1 -0
- package/lib/{target-ethers-sentio/index.d.cts → eth/codegen/ethers-sentio.d.ts} +1 -1
- package/lib/eth/codegen/ethers-sentio.js +57 -0
- package/lib/eth/codegen/ethers-sentio.js.map +1 -0
- package/lib/{target-ethers-sentio/event-handler.d.cts → eth/codegen/event-handler.d.ts} +0 -0
- package/lib/eth/codegen/event-handler.js +46 -0
- package/lib/eth/codegen/event-handler.js.map +1 -0
- package/lib/{target-ethers-sentio/file.d.cts → eth/codegen/file.d.ts} +0 -0
- package/lib/{target-ethers-sentio/file.cjs → eth/codegen/file.js} +28 -35
- package/lib/eth/codegen/file.js.map +1 -0
- package/lib/{target-ethers-sentio/functions-handler.d.cts → eth/codegen/functions-handler.d.ts} +0 -0
- package/lib/{target-ethers-sentio/functions-handler.cjs → eth/codegen/functions-handler.js} +13 -18
- package/lib/eth/codegen/functions-handler.js.map +1 -0
- package/lib/eth/codegen/index.d.ts +1 -0
- package/lib/eth/codegen/index.js +2 -0
- package/lib/eth/codegen/index.js.map +1 -0
- package/lib/eth/codegen/run.d.ts +2 -0
- package/lib/eth/codegen/run.js +12 -0
- package/lib/eth/codegen/run.js.map +1 -0
- package/lib/{target-ethers-sentio/types.d.cts → eth/codegen/types.d.ts} +0 -0
- package/lib/{target-ethers-sentio/types.cjs → eth/codegen/types.js} +4 -10
- package/lib/eth/codegen/types.js.map +1 -0
- package/lib/{target-ethers-sentio/view-function.d.cts → eth/codegen/view-function.d.ts} +0 -0
- package/lib/eth/codegen/view-function.js +62 -0
- package/lib/eth/codegen/view-function.js.map +1 -0
- package/lib/{core → eth}/context.d.ts +5 -4
- package/lib/{core → eth}/context.js +7 -8
- package/lib/eth/context.js.map +1 -0
- package/lib/eth/error.d.ts +1 -0
- package/lib/eth/error.js +3 -0
- package/lib/eth/error.js.map +1 -0
- package/lib/eth/eth.d.ts +13 -0
- package/lib/{error.js → eth/eth.js} +20 -14
- package/lib/eth/eth.js.map +1 -0
- package/lib/eth/generic-processor.d.ts +2 -2
- package/lib/eth/generic-processor.js +2 -2
- package/lib/eth/generic-processor.js.map +1 -1
- package/lib/eth/generic-processor.test.js.map +1 -1
- package/lib/eth/index.d.ts +5 -1
- package/lib/eth/index.js +5 -1
- package/lib/eth/index.js.map +1 -1
- package/lib/eth/provider.js +3 -2
- package/lib/eth/provider.js.map +1 -1
- package/lib/index.d.ts +1 -3
- package/lib/index.js +1 -5
- package/lib/index.js.map +1 -1
- package/lib/jest.config.d.ts +9 -0
- package/lib/jest.config.js +9 -0
- package/lib/jest.config.js.map +1 -0
- package/lib/solana/builtin/index.d.ts +1 -0
- package/lib/solana/builtin/index.js +2 -0
- package/lib/solana/builtin/index.js.map +1 -0
- package/lib/solana/builtin/spl-token-processor.d.ts +39 -0
- package/lib/solana/builtin/spl-token-processor.js +254 -0
- package/lib/solana/builtin/spl-token-processor.js.map +1 -0
- package/lib/solana/builtin/types.d.ts +427 -0
- package/lib/solana/builtin/types.js +200 -0
- package/lib/solana/builtin/types.js.map +1 -0
- package/lib/solana/codegen/codegen.d.ts +1 -0
- package/lib/solana/codegen/codegen.js +122 -0
- package/lib/solana/codegen/codegen.js.map +1 -0
- package/lib/solana/codegen/index.d.ts +1 -0
- package/lib/solana/codegen/index.js +2 -0
- package/lib/solana/codegen/index.js.map +1 -0
- package/lib/solana/codegen/run.d.ts +2 -0
- package/lib/solana/codegen/run.js +12 -0
- package/lib/solana/codegen/run.js.map +1 -0
- package/lib/solana/index.d.ts +4 -0
- package/lib/solana/index.js +5 -0
- package/lib/solana/index.js.map +1 -0
- package/lib/solana/solana-context.d.ts +9 -0
- package/lib/solana/solana-context.js +28 -0
- package/lib/solana/solana-context.js.map +1 -0
- package/lib/solana/solana-options.d.ts +10 -0
- package/lib/solana/solana-options.js +10 -0
- package/lib/solana/solana-options.js.map +1 -0
- package/lib/solana/solana-plugin.d.ts +9 -0
- package/lib/solana/solana-plugin.js +87 -0
- package/lib/solana/solana-plugin.js.map +1 -0
- package/lib/solana/solana-processor.d.ts +43 -0
- package/lib/solana/solana-processor.js +72 -0
- package/lib/solana/solana-processor.js.map +1 -0
- package/lib/solana/tests/solana.test.d.ts +1 -0
- package/lib/solana/tests/solana.test.js.map +1 -0
- package/lib/solana/tests/types/basic_1.d.ts +26 -0
- package/lib/solana/tests/types/basic_1.js +63 -0
- package/lib/solana/tests/types/basic_1.js.map +1 -0
- package/lib/solana/tests/types/basic_1_processor.d.ts +21 -0
- package/lib/solana/tests/types/basic_1_processor.js +35 -0
- package/lib/solana/tests/types/basic_1_processor.js.map +1 -0
- package/lib/solana/tests/types/token_bridge.d.ts +29 -0
- package/lib/solana/tests/types/token_bridge.js +938 -0
- package/lib/solana/tests/types/token_bridge.js.map +1 -0
- package/lib/solana/tests/types/token_bridge_processor.d.ts +212 -0
- package/lib/solana/tests/types/token_bridge_processor.js +134 -0
- package/lib/solana/tests/types/token_bridge_processor.js.map +1 -0
- package/lib/solana/tests/wormhole-token-bridge.d.ts +15 -0
- package/lib/solana/tests/wormhole-token-bridge.js +79 -0
- package/lib/solana/tests/wormhole-token-bridge.js.map +1 -0
- package/lib/testing/test-processor-server.js +1 -1
- package/lib/testing/test-processor-server.js.map +1 -1
- package/lib/testing/test-provider.js +1 -1
- package/lib/testing/test-provider.js.map +1 -1
- package/lib/tsup.config.ts +3 -0
- package/lib/utils/conversion.d.ts +0 -5
- package/lib/utils/conversion.js +21 -20
- package/lib/utils/conversion.js.map +1 -1
- package/lib/utils/dex-price.js +2 -2
- package/lib/utils/dex-price.js.map +1 -1
- package/lib/utils/index.d.ts +3 -3
- package/lib/utils/index.js +3 -3
- package/lib/utils/index.js.map +1 -1
- package/lib/utils/token.d.ts +0 -1
- package/lib/utils/token.js +17 -28
- package/lib/utils/token.js.map +1 -1
- package/package.json +42 -20
- package/src/aptos/abis/0x1.json +9205 -0
- package/src/aptos/abis/0x3.json +1515 -0
- package/src/aptos/api.ts +23 -0
- package/src/aptos/aptos-plugin.ts +183 -0
- package/src/aptos/aptos-processor.ts +331 -0
- package/src/aptos/builtin/0x1.ts +4685 -0
- package/src/aptos/builtin/0x3.ts +1010 -0
- package/src/aptos/builtin/index.ts +5 -0
- package/src/aptos/codegen/codegen.ts +461 -0
- package/src/aptos/codegen/index.ts +1 -0
- package/src/aptos/codegen/run.ts +13 -0
- package/src/aptos/codegen/tsconfig.json +8 -0
- package/src/aptos/codegen/typegen.ts +165 -0
- package/src/aptos/context.ts +72 -0
- package/src/aptos/index.ts +10 -0
- package/src/aptos/models.ts +37 -0
- package/src/aptos/move-coder.ts +199 -0
- package/src/aptos/move-types.ts +11 -0
- package/src/aptos/network.ts +29 -0
- package/src/aptos/tests/abis/reserved.json +402 -0
- package/src/aptos/tests/abis/soffl3.json +1411 -0
- package/src/aptos/tests/abis/souffle.json +389 -0
- package/src/aptos/tests/souffl3.ts +57 -0
- package/src/aptos/tests/types/index.ts +6 -0
- package/src/aptos/tests/types/reserved.ts +781 -0
- package/src/aptos/tests/types/soffl3.ts +1567 -0
- package/src/aptos/tests/types/souffle.ts +780 -0
- package/src/aptos/types.ts +149 -0
- package/src/aptos/utils.ts +26 -0
- package/src/core/big-decimal.ts +11 -0
- package/src/{utils → core}/chain.ts +0 -0
- package/src/core/index.ts +2 -5
- package/src/core/numberish.ts +0 -11
- package/src/core/sui-plugin.ts +1 -1
- package/src/core/sui-processor.ts +1 -1
- package/src/{abis → eth/abis}/EACAggregatorProxy.json +0 -0
- package/src/{abis → eth/abis}/ERC1155.json +0 -0
- package/src/{abis → eth/abis}/ERC20.json +0 -0
- package/src/{abis → eth/abis}/ERC20Bytes.json +0 -0
- package/src/{abis → eth/abis}/ERC721.json +0 -0
- package/src/{abis → eth/abis}/WETH9.json +0 -0
- package/src/eth/account-processor.ts +7 -7
- package/src/eth/base-processor-template.ts +5 -4
- package/src/eth/base-processor.ts +10 -20
- package/src/{core → eth}/bind-options.ts +0 -0
- package/src/eth/binds.ts +2 -2
- package/src/{builtin → eth/builtin}/eacaggregatorproxy/index.ts +0 -0
- package/src/{builtin → eth/builtin}/eacaggregatorproxy/test-utils.ts +0 -0
- package/src/{builtin → eth/builtin}/erc1155/index.ts +0 -0
- package/src/{builtin → eth/builtin}/erc1155/test-utils.ts +0 -0
- package/src/{builtin → eth/builtin}/erc20/index.ts +0 -0
- package/src/{builtin → eth/builtin}/erc20/test-utils.ts +0 -0
- package/src/{builtin → eth/builtin}/erc20bytes/index.ts +0 -0
- package/src/{builtin → eth/builtin}/erc20bytes/test-utils.ts +0 -0
- package/src/{builtin → eth/builtin}/erc721/index.ts +0 -0
- package/src/{builtin → eth/builtin}/erc721/test-utils.ts +0 -0
- package/src/{builtin → eth/builtin}/index.ts +0 -0
- package/src/{builtin → eth/builtin}/internal/EACAggregatorProxy.ts +5 -9
- package/src/{builtin → eth/builtin}/internal/ERC1155.ts +5 -9
- package/src/{builtin → eth/builtin}/internal/ERC20.ts +4 -7
- package/src/{builtin → eth/builtin}/internal/ERC20Bytes.ts +3 -5
- package/src/{builtin → eth/builtin}/internal/ERC721.ts +4 -7
- package/src/{builtin → eth/builtin}/internal/WETH9.ts +5 -9
- package/src/eth/builtin/internal/common.ts +22 -0
- package/src/{builtin → eth/builtin}/internal/eacaggregatorproxy_processor.ts +92 -164
- package/src/{builtin → eth/builtin}/internal/erc1155_processor.ts +27 -51
- package/src/{builtin → eth/builtin}/internal/erc20_processor.ts +42 -74
- package/src/{builtin → eth/builtin}/internal/erc20bytes_processor.ts +32 -56
- package/src/{builtin → eth/builtin}/internal/erc721_processor.ts +47 -83
- package/src/{builtin → eth/builtin}/internal/factories/EACAggregatorProxy__factory.ts +1 -1
- package/src/{builtin → eth/builtin}/internal/factories/ERC1155__factory.ts +1 -1
- package/src/{builtin → eth/builtin}/internal/factories/ERC20Bytes__factory.ts +1 -1
- package/src/{builtin → eth/builtin}/internal/factories/ERC20__factory.ts +1 -1
- package/src/{builtin → eth/builtin}/internal/factories/ERC721__factory.ts +1 -1
- package/src/{builtin → eth/builtin}/internal/factories/WETH9__factory.ts +1 -1
- package/src/{builtin → eth/builtin}/internal/factories/index.ts +0 -0
- package/src/{builtin → eth/builtin}/internal/index.ts +0 -0
- package/src/{builtin → eth/builtin}/internal/weth9_processor.ts +32 -56
- package/src/{builtin → eth/builtin}/weth9/index.ts +0 -0
- package/src/{builtin → eth/builtin}/weth9/test-utils.ts +0 -0
- package/src/eth/codegen/codegen.ts +62 -0
- package/src/{target-ethers-sentio/index.cts → eth/codegen/ethers-sentio.ts} +2 -2
- package/src/{target-ethers-sentio/event-handler.cts → eth/codegen/event-handler.ts} +2 -2
- package/src/{target-ethers-sentio/file.cts → eth/codegen/file.ts} +7 -7
- package/src/{target-ethers-sentio/functions-handler.cts → eth/codegen/functions-handler.ts} +4 -4
- package/src/eth/codegen/index.ts +1 -0
- package/src/eth/codegen/run.ts +12 -0
- package/src/eth/codegen/tsconfig.json +8 -0
- package/src/{target-ethers-sentio/types.cts → eth/codegen/types.ts} +1 -1
- package/src/{target-ethers-sentio/view-function.cts → eth/codegen/view-function.ts} +7 -12
- package/src/{core → eth}/context.ts +8 -9
- package/src/eth/error.ts +4 -0
- package/src/eth/eth.ts +56 -0
- package/src/eth/generic-processor.ts +3 -3
- package/src/eth/index.ts +6 -2
- package/src/eth/provider.ts +4 -3
- package/src/index.ts +1 -6
- package/src/jest.config.ts +8 -0
- package/src/solana/builtin/index.ts +1 -0
- package/src/solana/builtin/spl-token-processor.ts +298 -0
- package/src/solana/builtin/types.ts +279 -0
- package/src/solana/codegen/codegen.ts +140 -0
- package/src/solana/codegen/index.ts +1 -0
- package/src/solana/codegen/run.ts +12 -0
- package/src/solana/codegen/tsconfig.json +8 -0
- package/src/solana/index.ts +4 -0
- package/src/solana/solana-context.ts +30 -0
- package/src/solana/solana-options.ts +11 -0
- package/src/solana/solana-plugin.ts +103 -0
- package/src/solana/solana-processor.ts +102 -0
- package/src/solana/tests/abis/basic_1.json +62 -0
- package/src/solana/tests/abis/token_bridge.json +937 -0
- package/src/solana/tests/types/basic_1.ts +62 -0
- package/src/solana/tests/types/basic_1_processor.ts +42 -0
- package/src/solana/tests/types/token_bridge.ts +937 -0
- package/src/solana/tests/types/token_bridge_processor.ts +150 -0
- package/src/solana/tests/wormhole-token-bridge.ts +96 -0
- package/src/testing/test-processor-server.ts +1 -1
- package/src/testing/test-provider.ts +1 -1
- package/src/tsup.config.ts +3 -0
- package/src/utils/conversion.ts +21 -25
- package/src/utils/dex-price.ts +2 -3
- package/src/utils/index.ts +3 -3
- package/src/utils/token.ts +19 -30
- package/lib/builtin/eacaggregatorproxy/index.js.map +0 -1
- package/lib/builtin/eacaggregatorproxy/test-utils.js.map +0 -1
- package/lib/builtin/erc1155/index.js.map +0 -1
- package/lib/builtin/erc1155/test-utils.js.map +0 -1
- package/lib/builtin/erc20/index.js.map +0 -1
- package/lib/builtin/erc20/test-utils.js.map +0 -1
- package/lib/builtin/erc20bytes/index.js.map +0 -1
- package/lib/builtin/erc20bytes/test-utils.js.map +0 -1
- package/lib/builtin/erc721/index.js.map +0 -1
- package/lib/builtin/erc721/test-utils.js.map +0 -1
- package/lib/builtin/index.js.map +0 -1
- package/lib/builtin/internal/EACAggregatorProxy.js.map +0 -1
- package/lib/builtin/internal/ERC1155.js.map +0 -1
- package/lib/builtin/internal/ERC20.js.map +0 -1
- package/lib/builtin/internal/ERC20Bytes.js.map +0 -1
- package/lib/builtin/internal/ERC721.js.map +0 -1
- package/lib/builtin/internal/WETH9.js.map +0 -1
- package/lib/builtin/internal/common.js.map +0 -1
- package/lib/builtin/internal/eacaggregatorproxy_processor.js.map +0 -1
- package/lib/builtin/internal/erc1155_processor.js.map +0 -1
- package/lib/builtin/internal/erc20_processor.js.map +0 -1
- package/lib/builtin/internal/erc20bytes_processor.js.map +0 -1
- package/lib/builtin/internal/erc721_processor.js.map +0 -1
- package/lib/builtin/internal/factories/EACAggregatorProxy__factory.js.map +0 -1
- package/lib/builtin/internal/factories/ERC1155__factory.js.map +0 -1
- package/lib/builtin/internal/factories/ERC20Bytes__factory.js.map +0 -1
- package/lib/builtin/internal/factories/ERC20__factory.js.map +0 -1
- package/lib/builtin/internal/factories/ERC721__factory.js.map +0 -1
- package/lib/builtin/internal/factories/WETH9__factory.js.map +0 -1
- package/lib/builtin/internal/factories/index.js.map +0 -1
- package/lib/builtin/internal/index.js.map +0 -1
- package/lib/builtin/internal/weth9_processor.js.map +0 -1
- package/lib/builtin/weth9/index.js.map +0 -1
- package/lib/builtin/weth9/test-utils.js.map +0 -1
- package/lib/core/bind-options.js.map +0 -1
- package/lib/core/context.js.map +0 -1
- package/lib/error.d.ts +0 -7
- package/lib/error.js.map +0 -1
- package/lib/target-ethers-sentio/event-handler.cjs +0 -52
- package/lib/target-ethers-sentio/event-handler.cjs.map +0 -1
- package/lib/target-ethers-sentio/file.cjs.map +0 -1
- package/lib/target-ethers-sentio/functions-handler.cjs.map +0 -1
- package/lib/target-ethers-sentio/index.cjs +0 -61
- package/lib/target-ethers-sentio/index.cjs.map +0 -1
- package/lib/target-ethers-sentio/types.cjs.map +0 -1
- package/lib/target-ethers-sentio/view-function.cjs +0 -74
- package/lib/target-ethers-sentio/view-function.cjs.map +0 -1
- package/lib/utils/chain.js.map +0 -1
- package/src/builtin/internal/common.ts +0 -46
- package/src/error.ts +0 -45
- package/src/target-ethers-sentio/.eslintrc.json +0 -14
- package/src/target-ethers-sentio/tsconfig.json +0 -9
|
@@ -0,0 +1,461 @@
|
|
|
1
|
+
import * as fs from 'fs'
|
|
2
|
+
import * as path from 'path'
|
|
3
|
+
import { format } from 'prettier'
|
|
4
|
+
import { MoveFunction, MoveModule, MoveModuleBytecode, MoveStruct } from '../move-types.js'
|
|
5
|
+
import { AccountModulesImportInfo, AccountRegister, generateType, normalizeToJSName } from './typegen.js'
|
|
6
|
+
import { getMeaningfulFunctionParams, isFrameworkAccount, moduleQname, SPLITTER } from '../utils.js'
|
|
7
|
+
import chalk from 'chalk'
|
|
8
|
+
import { AptosNetwork, getAptosChainName } from '../network.js'
|
|
9
|
+
import { parseMoveType } from '../types.js'
|
|
10
|
+
import { AptosClient } from 'aptos-sdk'
|
|
11
|
+
import { camelCase } from 'lodash-es'
|
|
12
|
+
|
|
13
|
+
export async function codegen(abisDir: string, outDir = 'src/types/aptos') {
|
|
14
|
+
if (!fs.existsSync(abisDir)) {
|
|
15
|
+
return
|
|
16
|
+
}
|
|
17
|
+
console.log(chalk.green('Generated Types for Aptos'))
|
|
18
|
+
await generate(abisDir, outDir)
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function getRpcEndpoint(network: AptosNetwork): string {
|
|
22
|
+
switch (network) {
|
|
23
|
+
case AptosNetwork.TEST_NET:
|
|
24
|
+
return 'https://testnet.aptoslabs.com/'
|
|
25
|
+
}
|
|
26
|
+
return 'https://mainnet.aptoslabs.com/'
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function getRpcClient(network: AptosNetwork): AptosClient {
|
|
30
|
+
return new AptosClient(getRpcEndpoint(network))
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
async function generate(srcDir: string, outputDir: string) {
|
|
34
|
+
await generateForNetwork(srcDir, outputDir, AptosNetwork.MAIN_NET)
|
|
35
|
+
await generateForNetwork(path.join(srcDir, 'testnet'), path.join(outputDir, 'testnet'), AptosNetwork.TEST_NET)
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
async function generateForNetwork(srcDir: string, outputDir: string, network: AptosNetwork) {
|
|
39
|
+
if (!fs.existsSync(srcDir)) {
|
|
40
|
+
return
|
|
41
|
+
}
|
|
42
|
+
if (network === AptosNetwork.TEST_NET) {
|
|
43
|
+
console.log('Found testnet directory, generate code for testnet modules')
|
|
44
|
+
}
|
|
45
|
+
const files = fs.readdirSync(srcDir)
|
|
46
|
+
outputDir = path.resolve(outputDir)
|
|
47
|
+
const outputs: OutputFile[] = []
|
|
48
|
+
|
|
49
|
+
fs.mkdirSync(outputDir, { recursive: true })
|
|
50
|
+
|
|
51
|
+
const loader = new AccountRegister()
|
|
52
|
+
|
|
53
|
+
// when generating user code, don't need to generate framework account
|
|
54
|
+
loader.accountImports.set('0x1', new AccountModulesImportInfo('0x1', '0x1'))
|
|
55
|
+
loader.accountImports.set('0x2', new AccountModulesImportInfo('0x2', '0x2'))
|
|
56
|
+
loader.accountImports.set('0x3', new AccountModulesImportInfo('0x3', '0x3'))
|
|
57
|
+
const client = getRpcClient(network)
|
|
58
|
+
|
|
59
|
+
for (const file of files) {
|
|
60
|
+
if (!file.endsWith('.json')) {
|
|
61
|
+
continue
|
|
62
|
+
}
|
|
63
|
+
const fullPath = path.resolve(srcDir, file)
|
|
64
|
+
const modules = JSON.parse(fs.readFileSync(fullPath, 'utf-8'))
|
|
65
|
+
|
|
66
|
+
for (const module of modules) {
|
|
67
|
+
if (module.abi) {
|
|
68
|
+
loader.register(module.abi, path.basename(file, '.json'))
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
const codeGen = new AccountCodegen(loader, modules, {
|
|
72
|
+
fileName: path.basename(file, '.json'),
|
|
73
|
+
outputDir: outputDir,
|
|
74
|
+
network,
|
|
75
|
+
})
|
|
76
|
+
|
|
77
|
+
outputs.push(...codeGen.generate())
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
while (loader.pendingAccounts.size > 0) {
|
|
81
|
+
for (const account of loader.pendingAccounts) {
|
|
82
|
+
console.log(`download dependent module for account ${account} at ${getAptosChainName(network)}`)
|
|
83
|
+
|
|
84
|
+
try {
|
|
85
|
+
const modules = await client.getAccountModules(account)
|
|
86
|
+
fs.writeFileSync(path.resolve(srcDir, account + '.json'), JSON.stringify(modules, null, '\t'))
|
|
87
|
+
|
|
88
|
+
for (const module of modules) {
|
|
89
|
+
if (module.abi) {
|
|
90
|
+
loader.register(module.abi, account)
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
const codeGen = new AccountCodegen(loader, modules, {
|
|
94
|
+
fileName: account,
|
|
95
|
+
outputDir: outputDir,
|
|
96
|
+
network,
|
|
97
|
+
})
|
|
98
|
+
|
|
99
|
+
outputs.push(...codeGen.generate())
|
|
100
|
+
} catch (e) {
|
|
101
|
+
console.error(
|
|
102
|
+
chalk.red(
|
|
103
|
+
'Error downloading account module, check if you choose the right network,or download account modules manually into your director'
|
|
104
|
+
)
|
|
105
|
+
)
|
|
106
|
+
console.error(e)
|
|
107
|
+
process.exit(1)
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
for (const output of outputs) {
|
|
113
|
+
const content = format(output.fileContent, { parser: 'typescript' })
|
|
114
|
+
fs.writeFileSync(path.join(outputDir, output.fileName), content)
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
const rootFile = path.join(outputDir, 'index.ts')
|
|
118
|
+
fs.writeFileSync(
|
|
119
|
+
rootFile,
|
|
120
|
+
`/* Autogenerated file. Do not edit manually. */
|
|
121
|
+
/* tslint:disable */
|
|
122
|
+
/* eslint-disable */
|
|
123
|
+
`
|
|
124
|
+
)
|
|
125
|
+
for (const output of outputs) {
|
|
126
|
+
const parsed = path.parse(output.fileName)
|
|
127
|
+
const content = `export * as _${parsed.name} from './${parsed.name}.js'\n`
|
|
128
|
+
fs.appendFileSync(rootFile, content)
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
interface OutputFile {
|
|
133
|
+
fileName: string
|
|
134
|
+
fileContent: string
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
interface Config {
|
|
138
|
+
fileName: string
|
|
139
|
+
outputDir: string
|
|
140
|
+
network: AptosNetwork
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
export class AccountCodegen {
|
|
144
|
+
modules: MoveModuleBytecode[]
|
|
145
|
+
config: Config
|
|
146
|
+
loader: AccountRegister
|
|
147
|
+
|
|
148
|
+
constructor(loader: AccountRegister, modules: MoveModuleBytecode[], config: Config) {
|
|
149
|
+
// const json = fs.readFileSync(config.srcFile, 'utf-8')
|
|
150
|
+
this.modules = modules
|
|
151
|
+
this.config = config
|
|
152
|
+
this.loader = loader
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
generate(): OutputFile[] {
|
|
156
|
+
if (!this.modules) {
|
|
157
|
+
return []
|
|
158
|
+
}
|
|
159
|
+
// const baseName = path.basename(this.config.fileName, '.json')
|
|
160
|
+
|
|
161
|
+
let address: string | undefined
|
|
162
|
+
for (const module of this.modules) {
|
|
163
|
+
if (module.abi && module.abi.address) {
|
|
164
|
+
address = module.abi.address
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
if (!address) {
|
|
168
|
+
return []
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
const imports = `
|
|
172
|
+
import {
|
|
173
|
+
MoveCoder, AptosBindOptions, AptosBaseProcessor,
|
|
174
|
+
TypedEventInstance, AptosNetwork, TypedEntryFunctionPayload,
|
|
175
|
+
AptosContext, CallFilter
|
|
176
|
+
} from "@sentio/sdk/aptos"
|
|
177
|
+
import { AptosFetchConfig } from "@sentio/protos"
|
|
178
|
+
import { Address, MoveModule } from "@sentio/sdk/aptos"
|
|
179
|
+
`
|
|
180
|
+
|
|
181
|
+
const dependedAccounts: string[] = []
|
|
182
|
+
|
|
183
|
+
const moduleImports: string[] = []
|
|
184
|
+
|
|
185
|
+
const info = this.loader.accountImports.get(address)
|
|
186
|
+
|
|
187
|
+
if (info) {
|
|
188
|
+
for (const [account] of info.imports.entries()) {
|
|
189
|
+
// Remap to user's filename if possible, TODO codepath not well tested
|
|
190
|
+
const tsAccountModule = './' + (this.loader.accountImports.get(account)?.moduleName || account)
|
|
191
|
+
if (isFrameworkAccount(account) && !isFrameworkAccount(address)) {
|
|
192
|
+
// Decide where to find runtime library
|
|
193
|
+
moduleImports.push(`import { _${account} } from "@sentio/sdk/aptos/builtin"`)
|
|
194
|
+
} else {
|
|
195
|
+
moduleImports.push(`import * as _${account} from "${tsAccountModule}.js"`)
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
dependedAccounts.push(account)
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
const source = `
|
|
203
|
+
/* Autogenerated file. Do not edit manually. */
|
|
204
|
+
/* tslint:disable */
|
|
205
|
+
/* eslint-disable */
|
|
206
|
+
|
|
207
|
+
/* Generated modules for account ${address} */
|
|
208
|
+
|
|
209
|
+
${imports}
|
|
210
|
+
|
|
211
|
+
${moduleImports.join('\n')}
|
|
212
|
+
|
|
213
|
+
${this.modules.map((m) => generateModule(m, this.config.network)).join('\n')}
|
|
214
|
+
|
|
215
|
+
export function loadAllTypes(_r: MoveCoder) {
|
|
216
|
+
${dependedAccounts.map((a) => `_${a}.loadAllTypes(_r)`).join('\n')}
|
|
217
|
+
|
|
218
|
+
${this.modules
|
|
219
|
+
.map((m) => {
|
|
220
|
+
if (m.abi) {
|
|
221
|
+
return `_r.load(${normalizeToJSName(m.abi.name)}.ABI)`
|
|
222
|
+
}
|
|
223
|
+
console.error('Find Module with empty ABI')
|
|
224
|
+
return ''
|
|
225
|
+
})
|
|
226
|
+
.join('\n')}
|
|
227
|
+
}
|
|
228
|
+
` // source
|
|
229
|
+
|
|
230
|
+
return [
|
|
231
|
+
{
|
|
232
|
+
fileName: this.config.fileName + '.ts',
|
|
233
|
+
fileContent: source,
|
|
234
|
+
},
|
|
235
|
+
]
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
function generateNetworkOption(network: AptosNetwork) {
|
|
240
|
+
switch (network) {
|
|
241
|
+
case AptosNetwork.TEST_NET:
|
|
242
|
+
return 'TEST_NET'
|
|
243
|
+
}
|
|
244
|
+
return 'MAIN_NET'
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
function generateModule(moduleByteCode: MoveModuleBytecode, network: AptosNetwork) {
|
|
248
|
+
if (!moduleByteCode.abi) {
|
|
249
|
+
return ''
|
|
250
|
+
}
|
|
251
|
+
const module = moduleByteCode.abi
|
|
252
|
+
|
|
253
|
+
const functions = module.exposed_functions.map((f) => generateOnEntryFunctions(module, f)).filter((s) => s !== '')
|
|
254
|
+
|
|
255
|
+
const eventStructs = getEventStructs(module)
|
|
256
|
+
const eventTypes = new Set(eventStructs.keys())
|
|
257
|
+
const events = Array.from(eventStructs.values())
|
|
258
|
+
.map((e) => generateOnEvents(module, e))
|
|
259
|
+
.filter((s) => s !== '')
|
|
260
|
+
const structs = module.structs.map((s) => generateStructs(module, s, eventTypes))
|
|
261
|
+
const callArgs = module.exposed_functions.map((f) => generateCallArgsStructs(module, f))
|
|
262
|
+
|
|
263
|
+
const moduleName = normalizeToJSName(module.name)
|
|
264
|
+
let processor = ''
|
|
265
|
+
if (functions.length > 0 || events.length > 0) {
|
|
266
|
+
processor = `export class ${moduleName} extends AptosBaseProcessor {
|
|
267
|
+
|
|
268
|
+
constructor(options: AptosBindOptions) {
|
|
269
|
+
super("${module.name}", options)
|
|
270
|
+
}
|
|
271
|
+
static DEFAULT_OPTIONS: AptosBindOptions = {
|
|
272
|
+
address: "${module.address}",
|
|
273
|
+
network: AptosNetwork.${generateNetworkOption(network)}
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
static bind(options: Partial<AptosBindOptions> = {}): ${moduleName} {
|
|
277
|
+
return new ${moduleName}({ ...${moduleName}.DEFAULT_OPTIONS, ...options })
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
${functions.join('\n')}
|
|
281
|
+
|
|
282
|
+
${events.join('\n')}
|
|
283
|
+
|
|
284
|
+
loadTypesInternal(registry: MoveCoder) {
|
|
285
|
+
loadAllTypes(registry)
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
`
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
return `
|
|
292
|
+
${processor}
|
|
293
|
+
|
|
294
|
+
export namespace ${moduleName} {
|
|
295
|
+
${structs.join('\n')}
|
|
296
|
+
|
|
297
|
+
${callArgs.join('\n')}
|
|
298
|
+
|
|
299
|
+
export function loadTypes(_r: MoveCoder) {
|
|
300
|
+
loadAllTypes(_r)
|
|
301
|
+
}
|
|
302
|
+
export const ABI: MoveModule = JSON.parse('${JSON.stringify(module)}')
|
|
303
|
+
}
|
|
304
|
+
`
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
function generateStructs(module: MoveModule, struct: MoveStruct, events: Set<string>) {
|
|
308
|
+
const genericString = generateStructTypeParameters(struct)
|
|
309
|
+
const genericStringAny = generateStructTypeParameters(struct, true)
|
|
310
|
+
|
|
311
|
+
const structName = normalizeToJSName(struct.name)
|
|
312
|
+
|
|
313
|
+
const fields = struct.fields.map((field) => {
|
|
314
|
+
return `${field.name}: ${generateType(field.type, module.address)}`
|
|
315
|
+
})
|
|
316
|
+
|
|
317
|
+
let eventPayload = ''
|
|
318
|
+
if (events.has(moduleQname(module) + SPLITTER + struct.name)) {
|
|
319
|
+
eventPayload = `
|
|
320
|
+
export interface ${structName}Instance extends
|
|
321
|
+
TypedEventInstance<${structName}${genericStringAny}> {
|
|
322
|
+
data_decoded: ${structName}${genericStringAny}
|
|
323
|
+
type_arguments: [${struct.generic_type_params.map((_) => 'string').join(', ')}]
|
|
324
|
+
}
|
|
325
|
+
`
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
return `
|
|
329
|
+
export class ${structName}${genericString} {
|
|
330
|
+
static TYPE_QNAME = '${module.address}::${module.name}::${struct.name}'
|
|
331
|
+
${fields.join('\n')}
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
${eventPayload}
|
|
335
|
+
`
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
function generateFunctionTypeParameters(func: MoveFunction) {
|
|
339
|
+
let genericString = ''
|
|
340
|
+
if (func.generic_type_params && func.generic_type_params.length > 0) {
|
|
341
|
+
const params = func.generic_type_params
|
|
342
|
+
.map((v, idx) => {
|
|
343
|
+
return `T${idx}=any`
|
|
344
|
+
})
|
|
345
|
+
.join(',')
|
|
346
|
+
genericString = `<${params}>`
|
|
347
|
+
}
|
|
348
|
+
return genericString
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
function generateStructTypeParameters(struct: MoveStruct, useAny = false) {
|
|
352
|
+
let genericString = ''
|
|
353
|
+
|
|
354
|
+
if (struct.generic_type_params && struct.generic_type_params.length > 0) {
|
|
355
|
+
const params = struct.generic_type_params
|
|
356
|
+
.map((v, idx) => {
|
|
357
|
+
return useAny ? 'any' : 'T' + idx
|
|
358
|
+
})
|
|
359
|
+
.join(',')
|
|
360
|
+
genericString = `<${params}>`
|
|
361
|
+
}
|
|
362
|
+
return genericString
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
function generateCallArgsStructs(module: MoveModule, func: MoveFunction) {
|
|
366
|
+
if (!func.is_entry) {
|
|
367
|
+
return
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
const fields = getMeaningfulFunctionParams(func).map((param) => {
|
|
371
|
+
return `${generateType(param, module.address)}`
|
|
372
|
+
})
|
|
373
|
+
|
|
374
|
+
const camelFuncName = capitalizeFirstChar(camelCase(func.name))
|
|
375
|
+
|
|
376
|
+
const genericString = generateFunctionTypeParameters(func)
|
|
377
|
+
return `
|
|
378
|
+
export interface ${camelFuncName}Payload${genericString}
|
|
379
|
+
extends TypedEntryFunctionPayload<[${fields.join(',')}]> {
|
|
380
|
+
arguments_decoded: [${fields.join(',')}],
|
|
381
|
+
type_arguments: [${func.generic_type_params.map((_) => 'string').join(', ')}]
|
|
382
|
+
}
|
|
383
|
+
`
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
function generateOnEntryFunctions(module: MoveModule, func: MoveFunction) {
|
|
387
|
+
if (!func.is_entry) {
|
|
388
|
+
return ''
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
// const genericString = generateFunctionTypeParameters(func)
|
|
392
|
+
const moduleName = normalizeToJSName(module.name)
|
|
393
|
+
|
|
394
|
+
const camelFuncName = capitalizeFirstChar(camelCase(func.name))
|
|
395
|
+
const source = `
|
|
396
|
+
onEntry${camelFuncName}(func: (call: ${moduleName}.${camelFuncName}Payload, ctx: AptosContext) => void, filter?: CallFilter, fetchConfig?: AptosFetchConfig): ${moduleName} {
|
|
397
|
+
this.onEntryFunctionCall(func, {
|
|
398
|
+
...filter,
|
|
399
|
+
function: '${module.name}::${func.name}'
|
|
400
|
+
},
|
|
401
|
+
fetchConfig)
|
|
402
|
+
return this
|
|
403
|
+
}`
|
|
404
|
+
|
|
405
|
+
return source
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
function getEventStructs(module: MoveModule) {
|
|
409
|
+
const qname = moduleQname(module)
|
|
410
|
+
const structMap = new Map<string, MoveStruct>()
|
|
411
|
+
const eventMap = new Map<string, MoveStruct>()
|
|
412
|
+
|
|
413
|
+
for (const struct of module.structs) {
|
|
414
|
+
structMap.set(qname + SPLITTER + struct.name, struct)
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
for (const struct of module.structs) {
|
|
418
|
+
for (const field of struct.fields) {
|
|
419
|
+
const t = parseMoveType(field.type)
|
|
420
|
+
if (t.qname === '0x1::event::EventHandle') {
|
|
421
|
+
const event = t.typeArgs[0].qname
|
|
422
|
+
const eventStruct = structMap.get(event)
|
|
423
|
+
if (eventStruct) {
|
|
424
|
+
eventMap.set(event, eventStruct)
|
|
425
|
+
}
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
return eventMap
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
function generateOnEvents(module: MoveModule, struct: MoveStruct): string {
|
|
434
|
+
// for struct that has drop + store
|
|
435
|
+
// if (!isEvent(struct, module)) {
|
|
436
|
+
// return ''
|
|
437
|
+
// }
|
|
438
|
+
|
|
439
|
+
// const genericString = generateStructTypeParameters(struct)
|
|
440
|
+
|
|
441
|
+
const moduleName = normalizeToJSName(module.name)
|
|
442
|
+
const source = `
|
|
443
|
+
onEvent${struct.name}(func: (event: ${moduleName}.${normalizeToJSName(
|
|
444
|
+
struct.name
|
|
445
|
+
)}Instance, ctx: AptosContext) => void, fetchConfig?: AptosFetchConfig): ${moduleName} {
|
|
446
|
+
this.onEvent(func, {
|
|
447
|
+
type: '${module.name}::${struct.name}'
|
|
448
|
+
},
|
|
449
|
+
fetchConfig)
|
|
450
|
+
return this
|
|
451
|
+
}
|
|
452
|
+
`
|
|
453
|
+
return source
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
function capitalizeFirstChar(input: string): string {
|
|
457
|
+
if (!input) {
|
|
458
|
+
return input
|
|
459
|
+
}
|
|
460
|
+
return input[0].toUpperCase() + (input.length > 1 ? input.substring(1) : '')
|
|
461
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './codegen.js'
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
// #!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import { codegen } from './codegen.js'
|
|
4
|
+
|
|
5
|
+
if (process.argv.length > 3) {
|
|
6
|
+
const abisDir = process.argv[2]
|
|
7
|
+
const targetDir = process.argv[3]
|
|
8
|
+
|
|
9
|
+
await codegen(abisDir, targetDir)
|
|
10
|
+
} else {
|
|
11
|
+
console.error('Not enough argument')
|
|
12
|
+
process.exit(1)
|
|
13
|
+
}
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
import { MoveModule } from '../move-types.js'
|
|
2
|
+
import { parseMoveType, TypeDescriptor } from '../types.js'
|
|
3
|
+
import { moduleQname, moduleQnameForType, SPLITTER, VECTOR_STR } from '../utils.js'
|
|
4
|
+
|
|
5
|
+
function generateTypeForDescriptor(type: TypeDescriptor, currentAddress: string): string {
|
|
6
|
+
// TODO &signer is defintely an address, but what if &OTHER_TYPE?
|
|
7
|
+
if (type.qname.startsWith('&')) {
|
|
8
|
+
return 'Address'
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
switch (type.qname) {
|
|
12
|
+
case 'signer': // TODO check this
|
|
13
|
+
case 'address':
|
|
14
|
+
return 'Address'
|
|
15
|
+
case '0x1::string::String':
|
|
16
|
+
return 'string'
|
|
17
|
+
case 'bool':
|
|
18
|
+
return 'Boolean'
|
|
19
|
+
case 'u8':
|
|
20
|
+
case 'u16':
|
|
21
|
+
case 'u32':
|
|
22
|
+
return 'number'
|
|
23
|
+
case 'u64':
|
|
24
|
+
case 'u128':
|
|
25
|
+
return 'bigint'
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
if (type.qname === VECTOR_STR) {
|
|
29
|
+
// vector<u8> as hex string
|
|
30
|
+
const elementTypeQname = type.typeArgs[0].qname
|
|
31
|
+
if (elementTypeQname === 'u8') {
|
|
32
|
+
return 'string'
|
|
33
|
+
}
|
|
34
|
+
if (elementTypeQname.startsWith('T') && !elementTypeQname.includes(SPLITTER)) {
|
|
35
|
+
return `${elementTypeQname}[] | string`
|
|
36
|
+
}
|
|
37
|
+
return generateTypeForDescriptor(type.typeArgs[0], currentAddress) + '[]'
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const simpleName = generateSimpleType(type.qname, currentAddress)
|
|
41
|
+
if (simpleName.length === 0) {
|
|
42
|
+
console.error('unexpected error')
|
|
43
|
+
}
|
|
44
|
+
if (simpleName.includes('vector')) {
|
|
45
|
+
console.error('unexpected error')
|
|
46
|
+
}
|
|
47
|
+
if (type.typeArgs.length > 0) {
|
|
48
|
+
// return simpleName
|
|
49
|
+
return simpleName + '<' + type.typeArgs.map((t) => generateTypeForDescriptor(t, currentAddress)).join(',') + '>'
|
|
50
|
+
}
|
|
51
|
+
return simpleName
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
function generateSimpleType(type: string, currentAddress: string): string {
|
|
55
|
+
const parts = type.split(SPLITTER)
|
|
56
|
+
|
|
57
|
+
for (let i = 0; i < parts.length; i++) {
|
|
58
|
+
parts[i] = normalizeToJSName(parts[i])
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
if (parts.length < 2) {
|
|
62
|
+
return parts[0]
|
|
63
|
+
}
|
|
64
|
+
if (parts[0] === currentAddress) {
|
|
65
|
+
return parts.slice(1).join('.')
|
|
66
|
+
}
|
|
67
|
+
return '_' + parts.join('.')
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
// TODO ctx need to have type parameters
|
|
71
|
+
export function generateType(type: string, currentAddress: string): string {
|
|
72
|
+
return generateTypeForDescriptor(parseMoveType(type), currentAddress)
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export class AccountModulesImportInfo {
|
|
76
|
+
// account to module
|
|
77
|
+
imports: Map<string, Set<string>>
|
|
78
|
+
account: string
|
|
79
|
+
moduleName: string
|
|
80
|
+
|
|
81
|
+
constructor(account: string, tsModuleName: string) {
|
|
82
|
+
this.account = account
|
|
83
|
+
this.moduleName = tsModuleName
|
|
84
|
+
this.imports = new Map<string, Set<string>>()
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
addImport(account: string, module: string) {
|
|
88
|
+
if (account === this.account) {
|
|
89
|
+
return
|
|
90
|
+
}
|
|
91
|
+
let accountModules = this.imports.get(account)
|
|
92
|
+
if (!accountModules) {
|
|
93
|
+
accountModules = new Set<string>()
|
|
94
|
+
this.imports.set(account, accountModules)
|
|
95
|
+
}
|
|
96
|
+
accountModules.add(module)
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
export class AccountRegister {
|
|
101
|
+
accountImports = new Map<string, AccountModulesImportInfo>()
|
|
102
|
+
pendingAccounts = new Set<string>()
|
|
103
|
+
|
|
104
|
+
// loadedAccount = new Set<string>()
|
|
105
|
+
typeDescriptors = new Map<string, TypeDescriptor>()
|
|
106
|
+
|
|
107
|
+
private loadTypeDescriptor(type: string) {
|
|
108
|
+
let descriptor = this.typeDescriptors.get(type)
|
|
109
|
+
|
|
110
|
+
// const descriptparseMoveType(type)
|
|
111
|
+
if (!descriptor) {
|
|
112
|
+
descriptor = parseMoveType(type)
|
|
113
|
+
this.typeDescriptors.set(type, descriptor)
|
|
114
|
+
}
|
|
115
|
+
return descriptor
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
register(module: MoveModule, tsModuleName: string): AccountModulesImportInfo {
|
|
119
|
+
const currentModuleFqn = moduleQname(module)
|
|
120
|
+
|
|
121
|
+
let accountModuleImports = this.accountImports.get(module.address)
|
|
122
|
+
if (!accountModuleImports) {
|
|
123
|
+
accountModuleImports = new AccountModulesImportInfo(module.address, tsModuleName)
|
|
124
|
+
this.accountImports.set(module.address, accountModuleImports)
|
|
125
|
+
// the account has already be processed, delete pending task
|
|
126
|
+
this.pendingAccounts.delete(module.address)
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
for (const struct of module.structs) {
|
|
130
|
+
for (const field of struct.fields) {
|
|
131
|
+
for (const type of this.loadTypeDescriptor(field.type).dependedTypes()) {
|
|
132
|
+
const [account, module] = moduleQnameForType(type)
|
|
133
|
+
accountModuleImports.addImport(account, module)
|
|
134
|
+
if (!this.accountImports.has(account)) {
|
|
135
|
+
this.pendingAccounts.add(account)
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
for (const func of module.exposed_functions) {
|
|
142
|
+
if (!func.is_entry) {
|
|
143
|
+
continue
|
|
144
|
+
}
|
|
145
|
+
for (const param of func.params) {
|
|
146
|
+
for (const type of this.loadTypeDescriptor(param).dependedTypes()) {
|
|
147
|
+
const [account, module] = moduleQnameForType(type)
|
|
148
|
+
accountModuleImports.addImport(account, module)
|
|
149
|
+
if (!this.accountImports.has(account)) {
|
|
150
|
+
this.pendingAccounts.add(account)
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
this.accountImports.set(currentModuleFqn, accountModuleImports)
|
|
156
|
+
return accountModuleImports
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
export function normalizeToJSName(name: string) {
|
|
161
|
+
if (name === 'package' || name === 'volatile') {
|
|
162
|
+
return name + '_'
|
|
163
|
+
}
|
|
164
|
+
return name
|
|
165
|
+
}
|