@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,298 @@
|
|
|
1
|
+
import { SolanaBaseProcessor, SolanaContext, SolanaBindOptions } from '@sentio/sdk/solana'
|
|
2
|
+
import { Instruction } from '@project-serum/anchor'
|
|
3
|
+
import { AmountToUiAmount, Approve, ApproveChecked, Burn, BurnChecked, CloseAccount, CreateNativeMint, DefaultAccountStateExtension, FreezeAccount, GetAccountDataSize, InitializeAccount, InitializeAccount2, InitializeAccount3, InitializeImmutableOwner, InitializeMint, InitializeMintCloseAuthority, InitializeMultisig, MemoTransferExtension, MintTo, MintToChecked, Reallocate, Revoke, SyncNative, ThawAccount, Transfer, TransferChecked, TransferFeeExtension, UiAmountToAmount } from './types.js';
|
|
4
|
+
|
|
5
|
+
export class SPLTokenProcessor extends SolanaBaseProcessor {
|
|
6
|
+
static bind(options: SolanaBindOptions): SPLTokenProcessor {
|
|
7
|
+
if (options && !options.name) {
|
|
8
|
+
options.name = 'SPL Token Program'
|
|
9
|
+
}
|
|
10
|
+
return new SPLTokenProcessor(options)
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
fromParsedInstruction: (instruction: { type: string, info: any }) => Instruction | null = (instruction: { type: string, info: any }) => {
|
|
14
|
+
const instructionType = instruction.type
|
|
15
|
+
if (!instructionType) {
|
|
16
|
+
return null
|
|
17
|
+
}
|
|
18
|
+
return {
|
|
19
|
+
name: instruction.type,
|
|
20
|
+
data: {
|
|
21
|
+
...instruction.info,
|
|
22
|
+
},
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
public onInitializeMint(
|
|
27
|
+
handler: (data: InitializeMint, ctx: SolanaContext) => void
|
|
28
|
+
): SPLTokenProcessor {
|
|
29
|
+
this.onInstruction('initializeMint', (ins: Instruction, ctx) => {
|
|
30
|
+
if (ins) {
|
|
31
|
+
handler(ins.data as InitializeMint, ctx)
|
|
32
|
+
}
|
|
33
|
+
})
|
|
34
|
+
return this
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
public onInitializeAccount(
|
|
38
|
+
hanlder: (data: InitializeAccount, ctx: SolanaContext) => void
|
|
39
|
+
): SPLTokenProcessor {
|
|
40
|
+
this.onInstruction('initializeAccount', (ins: Instruction, ctx) => {
|
|
41
|
+
if (ins) {
|
|
42
|
+
hanlder(ins.data as InitializeAccount, ctx)
|
|
43
|
+
}
|
|
44
|
+
})
|
|
45
|
+
return this
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
public onInitializeAccount2(
|
|
49
|
+
hanlder: (data: InitializeAccount2, ctx: SolanaContext) => void
|
|
50
|
+
): SPLTokenProcessor {
|
|
51
|
+
this.onInstruction('initializeAccount2', (ins: Instruction, ctx) => {
|
|
52
|
+
if (ins) {
|
|
53
|
+
hanlder(ins.data as InitializeAccount2, ctx)
|
|
54
|
+
}
|
|
55
|
+
})
|
|
56
|
+
return this
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
public onInitializeAccount3(
|
|
60
|
+
hanlder: (data: InitializeAccount3, ctx: SolanaContext) => void
|
|
61
|
+
): SPLTokenProcessor {
|
|
62
|
+
this.onInstruction('initializeAccount3', (ins: Instruction, ctx) => {
|
|
63
|
+
if (ins) {
|
|
64
|
+
hanlder(ins.data as InitializeAccount3, ctx)
|
|
65
|
+
}
|
|
66
|
+
})
|
|
67
|
+
return this
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
public onInitializeMultisig(
|
|
71
|
+
handler: (data: InitializeMultisig, ctx: SolanaContext) => void
|
|
72
|
+
): SPLTokenProcessor {
|
|
73
|
+
this.onInstruction('initializeMultisig', (ins: Instruction, ctx) => {
|
|
74
|
+
if (ins) {
|
|
75
|
+
handler(ins.data as InitializeMultisig, ctx)
|
|
76
|
+
}
|
|
77
|
+
})
|
|
78
|
+
return this
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
public onTransfer(handler: (data: Transfer, ctx: SolanaContext) => void): SPLTokenProcessor {
|
|
82
|
+
this.onInstruction('transfer', (ins: Instruction, ctx) => {
|
|
83
|
+
if (ins) {
|
|
84
|
+
handler(ins.data as Transfer, ctx)
|
|
85
|
+
}
|
|
86
|
+
})
|
|
87
|
+
return this
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
public onApprovend(handler: (data: Approve, ctx: SolanaContext) => void): SPLTokenProcessor {
|
|
91
|
+
this.onInstruction('approve', (ins: Instruction, ctx) => {
|
|
92
|
+
if (ins) {
|
|
93
|
+
handler(ins.data as Approve, ctx)
|
|
94
|
+
}
|
|
95
|
+
})
|
|
96
|
+
return this
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
public onRevoke(handler: (data: Revoke, ctx: SolanaContext) => void): SPLTokenProcessor {
|
|
100
|
+
this.onInstruction('revoke', (ins: Instruction, ctx) => {
|
|
101
|
+
if (ins) {
|
|
102
|
+
handler(ins.data as Revoke, ctx)
|
|
103
|
+
}
|
|
104
|
+
})
|
|
105
|
+
return this
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
public onSetAuthority(handler: (data: any, ctx: SolanaContext) => void): SPLTokenProcessor {
|
|
109
|
+
this.onInstruction('setAuthority', (ins: Instruction, ctx) => {
|
|
110
|
+
if (ins) {
|
|
111
|
+
handler(ins.data as any, ctx)
|
|
112
|
+
}
|
|
113
|
+
})
|
|
114
|
+
return this
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
public onMintTo(handler: (data: MintTo, ctx: SolanaContext) => void): SPLTokenProcessor {
|
|
118
|
+
this.onInstruction('mintTo', (ins: Instruction, ctx) => {
|
|
119
|
+
if (ins) {
|
|
120
|
+
handler(ins.data as MintTo, ctx)
|
|
121
|
+
}
|
|
122
|
+
})
|
|
123
|
+
return this
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
public onBurn(handler: (data: Burn, ctx: SolanaContext) => void): SPLTokenProcessor {
|
|
127
|
+
this.onInstruction('burn', (ins: Instruction, ctx) => {
|
|
128
|
+
if (ins) {
|
|
129
|
+
handler(ins.data as Burn, ctx)
|
|
130
|
+
}
|
|
131
|
+
})
|
|
132
|
+
return this
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
public onCloseAccount(handler: (data: CloseAccount, ctx: SolanaContext) => void): SPLTokenProcessor {
|
|
136
|
+
this.onInstruction('closeAccount', (ins: Instruction, ctx) => {
|
|
137
|
+
if (ins) {
|
|
138
|
+
handler(ins.data as CloseAccount, ctx)
|
|
139
|
+
}
|
|
140
|
+
})
|
|
141
|
+
return this
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
public onFreezeAccount(handler: (data: FreezeAccount, ctx: SolanaContext) => void): SPLTokenProcessor {
|
|
145
|
+
this.onInstruction('freezeAccount', (ins: Instruction, ctx) => {
|
|
146
|
+
if (ins) {
|
|
147
|
+
handler(ins.data as FreezeAccount, ctx)
|
|
148
|
+
}
|
|
149
|
+
})
|
|
150
|
+
return this
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
public onThawAccount(handler: (data: ThawAccount, ctx: SolanaContext) => void): SPLTokenProcessor {
|
|
154
|
+
this.onInstruction('thawAccount', (ins: Instruction, ctx) => {
|
|
155
|
+
if (ins) {
|
|
156
|
+
handler(ins.data as ThawAccount, ctx)
|
|
157
|
+
}
|
|
158
|
+
})
|
|
159
|
+
return this
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
public onTransferChecked(handler: (data: TransferChecked, ctx: SolanaContext) => void): SPLTokenProcessor {
|
|
163
|
+
this.onInstruction('transferChecked', (ins: Instruction, ctx) => {
|
|
164
|
+
if (ins) {
|
|
165
|
+
handler(ins.data as TransferChecked, ctx)
|
|
166
|
+
}
|
|
167
|
+
})
|
|
168
|
+
return this
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
public onApproveChecked(handler: (data: ApproveChecked, ctx: SolanaContext) => void): SPLTokenProcessor {
|
|
172
|
+
this.onInstruction('approveChecked', (ins: Instruction, ctx) => {
|
|
173
|
+
if (ins) {
|
|
174
|
+
handler(ins.data as ApproveChecked, ctx)
|
|
175
|
+
}
|
|
176
|
+
})
|
|
177
|
+
return this
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
public onMintToChecked(handler: (data: MintToChecked, ctx: SolanaContext) => void): SPLTokenProcessor {
|
|
181
|
+
this.onInstruction('mintToChecked', (ins: Instruction, ctx) => {
|
|
182
|
+
if (ins) {
|
|
183
|
+
handler(ins.data as MintToChecked, ctx)
|
|
184
|
+
}
|
|
185
|
+
})
|
|
186
|
+
return this
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
public onBurnChecked(handler: (data: BurnChecked, ctx: SolanaContext) => void): SPLTokenProcessor {
|
|
190
|
+
this.onInstruction('burnChecked', (ins: Instruction, ctx) => {
|
|
191
|
+
if (ins) {
|
|
192
|
+
handler(ins.data as BurnChecked, ctx)
|
|
193
|
+
}
|
|
194
|
+
})
|
|
195
|
+
return this
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
public onSyncNative(handler: (data: SyncNative, ctx: SolanaContext) => void): SPLTokenProcessor {
|
|
199
|
+
this.onInstruction('syncNative', (ins: Instruction, ctx) => {
|
|
200
|
+
if (ins) {
|
|
201
|
+
handler(ins.data as SyncNative, ctx)
|
|
202
|
+
}
|
|
203
|
+
})
|
|
204
|
+
return this
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
public onGetAccountDataSize(handler: (data: GetAccountDataSize, ctx: SolanaContext) => void): SPLTokenProcessor {
|
|
208
|
+
this.onInstruction('getAccountDataSize', (ins: Instruction, ctx) => {
|
|
209
|
+
if (ins) {
|
|
210
|
+
handler(ins.data as GetAccountDataSize, ctx)
|
|
211
|
+
}
|
|
212
|
+
})
|
|
213
|
+
return this
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
public onInitializeImmutableOwner(handler: (data: InitializeImmutableOwner, ctx: SolanaContext) => void): SPLTokenProcessor {
|
|
217
|
+
this.onInstruction('initializeImmutableOwner', (ins: Instruction, ctx) => {
|
|
218
|
+
if (ins) {
|
|
219
|
+
handler(ins.data as InitializeImmutableOwner, ctx)
|
|
220
|
+
}
|
|
221
|
+
})
|
|
222
|
+
return this
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
public onAmountToUiAmount(handler: (data: AmountToUiAmount, ctx: SolanaContext) => void): SPLTokenProcessor {
|
|
226
|
+
this.onInstruction('amountToUiAmount', (ins: Instruction, ctx) => {
|
|
227
|
+
if (ins) {
|
|
228
|
+
handler(ins.data as AmountToUiAmount, ctx)
|
|
229
|
+
}
|
|
230
|
+
})
|
|
231
|
+
return this
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
public onUiAmountToAmount(handler: (data: UiAmountToAmount, ctx: SolanaContext) => void): SPLTokenProcessor {
|
|
235
|
+
this.onInstruction('uiAmountToAmount', (ins: Instruction, ctx) => {
|
|
236
|
+
if (ins) {
|
|
237
|
+
handler(ins.data as UiAmountToAmount, ctx)
|
|
238
|
+
}
|
|
239
|
+
})
|
|
240
|
+
return this
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
public onInitializeMintCloseAuthority(handler: (data: InitializeMintCloseAuthority, ctx: SolanaContext) => void): SPLTokenProcessor {
|
|
244
|
+
this.onInstruction('initializeMintCloseAuthority', (ins: Instruction, ctx) => {
|
|
245
|
+
if (ins) {
|
|
246
|
+
handler(ins.data as InitializeMintCloseAuthority, ctx)
|
|
247
|
+
}
|
|
248
|
+
})
|
|
249
|
+
return this
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
public onTransferFeeExtension(handler: (data: TransferFeeExtension, ctx: SolanaContext) => void): SPLTokenProcessor {
|
|
253
|
+
this.onInstruction('transferFeeExtension', (ins: Instruction, ctx) => {
|
|
254
|
+
if (ins) {
|
|
255
|
+
handler(ins.data as TransferFeeExtension, ctx)
|
|
256
|
+
}
|
|
257
|
+
})
|
|
258
|
+
return this
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
public onDefaultAccountStateExtension(handler: (data: DefaultAccountStateExtension, ctx: SolanaContext) => void): SPLTokenProcessor {
|
|
262
|
+
this.onInstruction('defaultAccountStateExtension', (ins: Instruction, ctx) => {
|
|
263
|
+
if (ins) {
|
|
264
|
+
handler(ins.data as DefaultAccountStateExtension, ctx)
|
|
265
|
+
}
|
|
266
|
+
})
|
|
267
|
+
return this
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
public onReallocate(handler: (data: Reallocate, ctx: SolanaContext) => void): SPLTokenProcessor {
|
|
271
|
+
this.onInstruction('reallocate', (ins: Instruction, ctx) => {
|
|
272
|
+
if (ins) {
|
|
273
|
+
handler(ins.data as Reallocate, ctx)
|
|
274
|
+
}
|
|
275
|
+
})
|
|
276
|
+
return this
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
public onMemoTransferExtension(handler: (data: MemoTransferExtension, ctx: SolanaContext) => void): SPLTokenProcessor {
|
|
280
|
+
this.onInstruction('memoTransferExtension', (ins: Instruction, ctx) => {
|
|
281
|
+
if (ins) {
|
|
282
|
+
handler(ins.data as MemoTransferExtension, ctx)
|
|
283
|
+
}
|
|
284
|
+
})
|
|
285
|
+
return this
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
public onCreateNativeMint(handler: (data: CreateNativeMint, ctx: SolanaContext) => void): SPLTokenProcessor {
|
|
289
|
+
this.onInstruction('createNativeMint', (ins: Instruction, ctx) => {
|
|
290
|
+
if (ins) {
|
|
291
|
+
handler(ins.data as CreateNativeMint, ctx)
|
|
292
|
+
}
|
|
293
|
+
})
|
|
294
|
+
return this
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
// Todo(pcxu): auto gen this file
|
|
298
|
+
}
|
|
@@ -0,0 +1,279 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-redeclare */
|
|
2
|
+
// copy from https://github.com/solana-labs/solana/blob/master/explorer/src/components/instruction/token/types.ts
|
|
3
|
+
|
|
4
|
+
import {
|
|
5
|
+
enums,
|
|
6
|
+
type,
|
|
7
|
+
Infer,
|
|
8
|
+
number,
|
|
9
|
+
string,
|
|
10
|
+
optional,
|
|
11
|
+
array,
|
|
12
|
+
nullable,
|
|
13
|
+
union,
|
|
14
|
+
coerce,
|
|
15
|
+
instance,
|
|
16
|
+
} from "superstruct";
|
|
17
|
+
|
|
18
|
+
// Replace with string
|
|
19
|
+
export const PublicKeyFromString = coerce(
|
|
20
|
+
instance(String),
|
|
21
|
+
string(),
|
|
22
|
+
(value) => (value)
|
|
23
|
+
);
|
|
24
|
+
|
|
25
|
+
export type TokenAmountUi = Infer<typeof TokenAmountUi>;
|
|
26
|
+
export type MintTo = Infer<typeof MintTo>;
|
|
27
|
+
export type Burn = Infer<typeof Burn>;
|
|
28
|
+
export type InitializeMint = Infer<typeof InitializeMint>;
|
|
29
|
+
export type InitializeAccount = Infer<typeof InitializeAccount>;
|
|
30
|
+
export type InitializeAccount2 = Infer<typeof InitializeAccount2>;
|
|
31
|
+
export type InitializeAccount3 = Infer<typeof InitializeAccount3>;
|
|
32
|
+
export type InitializeMultisig = Infer<typeof InitializeMultisig>;
|
|
33
|
+
|
|
34
|
+
export const TokenAmountUi = type({
|
|
35
|
+
amount: string(),
|
|
36
|
+
decimals: number(),
|
|
37
|
+
uiAmountString: string(),
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
const InitializeMint = type({
|
|
41
|
+
mint: PublicKeyFromString,
|
|
42
|
+
decimals: number(),
|
|
43
|
+
mintAuthority: PublicKeyFromString,
|
|
44
|
+
rentSysvar: PublicKeyFromString,
|
|
45
|
+
freezeAuthority: optional(PublicKeyFromString),
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
const InitializeAccount = type({
|
|
49
|
+
account: PublicKeyFromString,
|
|
50
|
+
mint: PublicKeyFromString,
|
|
51
|
+
owner: PublicKeyFromString,
|
|
52
|
+
rentSysvar: PublicKeyFromString,
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
const InitializeAccount2 = type({
|
|
56
|
+
account: PublicKeyFromString,
|
|
57
|
+
mint: PublicKeyFromString,
|
|
58
|
+
rentSysvar: PublicKeyFromString,
|
|
59
|
+
owner: PublicKeyFromString,
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
const InitializeAccount3 = type({
|
|
63
|
+
account: PublicKeyFromString,
|
|
64
|
+
mint: PublicKeyFromString,
|
|
65
|
+
owner: PublicKeyFromString,
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
const InitializeMultisig = type({
|
|
69
|
+
multisig: PublicKeyFromString,
|
|
70
|
+
rentSysvar: PublicKeyFromString,
|
|
71
|
+
signers: array(PublicKeyFromString),
|
|
72
|
+
m: number(),
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
export type Transfer = Infer<typeof Transfer>;
|
|
76
|
+
export const Transfer = type({
|
|
77
|
+
source: PublicKeyFromString,
|
|
78
|
+
destination: PublicKeyFromString,
|
|
79
|
+
amount: union([string(), number()]),
|
|
80
|
+
authority: optional(PublicKeyFromString),
|
|
81
|
+
multisigAuthority: optional(PublicKeyFromString),
|
|
82
|
+
signers: optional(array(PublicKeyFromString)),
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
export type Approve = Infer<typeof Approve>;
|
|
86
|
+
const Approve = type({
|
|
87
|
+
source: PublicKeyFromString,
|
|
88
|
+
delegate: PublicKeyFromString,
|
|
89
|
+
amount: union([string(), number()]),
|
|
90
|
+
owner: optional(PublicKeyFromString),
|
|
91
|
+
multisigOwner: optional(PublicKeyFromString),
|
|
92
|
+
signers: optional(array(PublicKeyFromString)),
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
export type Revoke = Infer<typeof Revoke>;
|
|
96
|
+
const Revoke = type({
|
|
97
|
+
source: PublicKeyFromString,
|
|
98
|
+
owner: optional(PublicKeyFromString),
|
|
99
|
+
multisigOwner: optional(PublicKeyFromString),
|
|
100
|
+
signers: optional(array(PublicKeyFromString)),
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
const AuthorityType = enums([
|
|
104
|
+
"mintTokens",
|
|
105
|
+
"freezeAccount",
|
|
106
|
+
"accountOwner",
|
|
107
|
+
"closeAccount",
|
|
108
|
+
]);
|
|
109
|
+
|
|
110
|
+
export type SetAuthority = Infer<typeof SetAuthority>;
|
|
111
|
+
const SetAuthority = type({
|
|
112
|
+
mint: optional(PublicKeyFromString),
|
|
113
|
+
account: optional(PublicKeyFromString),
|
|
114
|
+
authorityType: AuthorityType,
|
|
115
|
+
newAuthority: nullable(PublicKeyFromString),
|
|
116
|
+
authority: optional(PublicKeyFromString),
|
|
117
|
+
multisigAuthority: optional(PublicKeyFromString),
|
|
118
|
+
signers: optional(array(PublicKeyFromString)),
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
const MintTo = type({
|
|
122
|
+
mint: PublicKeyFromString,
|
|
123
|
+
account: PublicKeyFromString,
|
|
124
|
+
amount: union([string(), number()]),
|
|
125
|
+
mintAuthority: optional(PublicKeyFromString),
|
|
126
|
+
multisigMintAuthority: optional(PublicKeyFromString),
|
|
127
|
+
signers: optional(array(PublicKeyFromString)),
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
const Burn = type({
|
|
131
|
+
account: PublicKeyFromString,
|
|
132
|
+
mint: PublicKeyFromString,
|
|
133
|
+
amount: union([string(), number()]),
|
|
134
|
+
authority: optional(PublicKeyFromString),
|
|
135
|
+
multisigAuthority: optional(PublicKeyFromString),
|
|
136
|
+
signers: optional(array(PublicKeyFromString)),
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
const CloseAccount = type({
|
|
140
|
+
account: PublicKeyFromString,
|
|
141
|
+
destination: PublicKeyFromString,
|
|
142
|
+
owner: optional(PublicKeyFromString),
|
|
143
|
+
multisigOwner: optional(PublicKeyFromString),
|
|
144
|
+
signers: optional(array(PublicKeyFromString)),
|
|
145
|
+
});
|
|
146
|
+
export type CloseAccount = Infer<typeof CloseAccount>;
|
|
147
|
+
|
|
148
|
+
export type FreezeAccount = Infer<typeof FreezeAccount>;
|
|
149
|
+
const FreezeAccount = type({
|
|
150
|
+
account: PublicKeyFromString,
|
|
151
|
+
mint: PublicKeyFromString,
|
|
152
|
+
freezeAuthority: optional(PublicKeyFromString),
|
|
153
|
+
multisigFreezeAuthority: optional(PublicKeyFromString),
|
|
154
|
+
signers: optional(array(PublicKeyFromString)),
|
|
155
|
+
});
|
|
156
|
+
|
|
157
|
+
export type ThawAccount = Infer<typeof ThawAccount>;
|
|
158
|
+
const ThawAccount = type({
|
|
159
|
+
account: PublicKeyFromString,
|
|
160
|
+
mint: PublicKeyFromString,
|
|
161
|
+
freezeAuthority: optional(PublicKeyFromString),
|
|
162
|
+
multisigFreezeAuthority: optional(PublicKeyFromString),
|
|
163
|
+
signers: optional(array(PublicKeyFromString)),
|
|
164
|
+
});
|
|
165
|
+
|
|
166
|
+
export type TransferChecked = Infer<typeof TransferChecked>;
|
|
167
|
+
export const TransferChecked = type({
|
|
168
|
+
source: PublicKeyFromString,
|
|
169
|
+
mint: PublicKeyFromString,
|
|
170
|
+
destination: PublicKeyFromString,
|
|
171
|
+
authority: optional(PublicKeyFromString),
|
|
172
|
+
multisigAuthority: optional(PublicKeyFromString),
|
|
173
|
+
signers: optional(array(PublicKeyFromString)),
|
|
174
|
+
tokenAmount: TokenAmountUi,
|
|
175
|
+
});
|
|
176
|
+
|
|
177
|
+
export type ApproveChecked = Infer<typeof ApproveChecked>;
|
|
178
|
+
const ApproveChecked = type({
|
|
179
|
+
source: PublicKeyFromString,
|
|
180
|
+
mint: PublicKeyFromString,
|
|
181
|
+
delegate: PublicKeyFromString,
|
|
182
|
+
owner: optional(PublicKeyFromString),
|
|
183
|
+
multisigOwner: optional(PublicKeyFromString),
|
|
184
|
+
signers: optional(array(PublicKeyFromString)),
|
|
185
|
+
tokenAmount: TokenAmountUi,
|
|
186
|
+
});
|
|
187
|
+
|
|
188
|
+
export type MintToChecked = Infer<typeof MintToChecked>;
|
|
189
|
+
const MintToChecked = type({
|
|
190
|
+
account: PublicKeyFromString,
|
|
191
|
+
mint: PublicKeyFromString,
|
|
192
|
+
mintAuthority: optional(PublicKeyFromString),
|
|
193
|
+
multisigMintAuthority: optional(PublicKeyFromString),
|
|
194
|
+
signers: optional(array(PublicKeyFromString)),
|
|
195
|
+
tokenAmount: TokenAmountUi,
|
|
196
|
+
});
|
|
197
|
+
|
|
198
|
+
export type BurnChecked = Infer<typeof BurnChecked>;
|
|
199
|
+
const BurnChecked = type({
|
|
200
|
+
account: PublicKeyFromString,
|
|
201
|
+
mint: PublicKeyFromString,
|
|
202
|
+
authority: optional(PublicKeyFromString),
|
|
203
|
+
multisigAuthority: optional(PublicKeyFromString),
|
|
204
|
+
signers: optional(array(PublicKeyFromString)),
|
|
205
|
+
tokenAmount: TokenAmountUi,
|
|
206
|
+
});
|
|
207
|
+
|
|
208
|
+
export type SyncNative = Infer<typeof BurnChecked>;
|
|
209
|
+
const SyncNative = type({
|
|
210
|
+
account: PublicKeyFromString,
|
|
211
|
+
});
|
|
212
|
+
|
|
213
|
+
export type GetAccountDataSize = Infer<typeof GetAccountDataSize>;
|
|
214
|
+
const GetAccountDataSize = type({
|
|
215
|
+
mint: PublicKeyFromString,
|
|
216
|
+
extensionTypes: optional(array(string())),
|
|
217
|
+
});
|
|
218
|
+
|
|
219
|
+
export type InitializeImmutableOwner = Infer<typeof InitializeImmutableOwner>;
|
|
220
|
+
const InitializeImmutableOwner = type({
|
|
221
|
+
account: PublicKeyFromString,
|
|
222
|
+
});
|
|
223
|
+
|
|
224
|
+
export type AmountToUiAmount = Infer<typeof AmountToUiAmount>;
|
|
225
|
+
const AmountToUiAmount = type({
|
|
226
|
+
mint: PublicKeyFromString,
|
|
227
|
+
amount: union([string(), number()]),
|
|
228
|
+
});
|
|
229
|
+
|
|
230
|
+
export type UiAmountToAmount = Infer<typeof UiAmountToAmount>;
|
|
231
|
+
const UiAmountToAmount = type({
|
|
232
|
+
mint: PublicKeyFromString,
|
|
233
|
+
uiAmount: string(),
|
|
234
|
+
});
|
|
235
|
+
|
|
236
|
+
export type InitializeMintCloseAuthority = Infer<typeof InitializeMintCloseAuthority>;
|
|
237
|
+
const InitializeMintCloseAuthority = type({
|
|
238
|
+
mint: PublicKeyFromString,
|
|
239
|
+
newAuthority: PublicKeyFromString,
|
|
240
|
+
});
|
|
241
|
+
|
|
242
|
+
export type TransferFeeExtension = Infer<typeof TransferFeeExtension>;
|
|
243
|
+
const TransferFeeExtension = type({
|
|
244
|
+
mint: PublicKeyFromString,
|
|
245
|
+
transferFeeConfigAuthority: PublicKeyFromString,
|
|
246
|
+
withdrawWitheldAuthority: PublicKeyFromString,
|
|
247
|
+
transferFeeBasisPoints: number(),
|
|
248
|
+
maximumFee: number(),
|
|
249
|
+
});
|
|
250
|
+
|
|
251
|
+
export type DefaultAccountStateExtension = Infer<typeof DefaultAccountStateExtension>;
|
|
252
|
+
const DefaultAccountStateExtension = type({
|
|
253
|
+
mint: PublicKeyFromString,
|
|
254
|
+
accountState: string(),
|
|
255
|
+
freezeAuthority: optional(PublicKeyFromString),
|
|
256
|
+
});
|
|
257
|
+
|
|
258
|
+
export type Reallocate = Infer<typeof Reallocate>;
|
|
259
|
+
const Reallocate = type({
|
|
260
|
+
account: PublicKeyFromString,
|
|
261
|
+
payer: PublicKeyFromString,
|
|
262
|
+
systemProgram: PublicKeyFromString,
|
|
263
|
+
extensionTypes: array(string()),
|
|
264
|
+
});
|
|
265
|
+
|
|
266
|
+
export type MemoTransferExtension = Infer<typeof MemoTransferExtension>;
|
|
267
|
+
const MemoTransferExtension = type({
|
|
268
|
+
account: PublicKeyFromString,
|
|
269
|
+
owner: optional(PublicKeyFromString),
|
|
270
|
+
multisigOwner: optional(PublicKeyFromString),
|
|
271
|
+
signers: optional(array(PublicKeyFromString)),
|
|
272
|
+
});
|
|
273
|
+
|
|
274
|
+
export type CreateNativeMint = Infer<typeof CreateNativeMint>;
|
|
275
|
+
const CreateNativeMint = type({
|
|
276
|
+
payer: PublicKeyFromString,
|
|
277
|
+
nativeMint: PublicKeyFromString,
|
|
278
|
+
systemProgram: PublicKeyFromString,
|
|
279
|
+
});
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import path from 'path'
|
|
2
|
+
import fs from 'fs'
|
|
3
|
+
import chalk from 'chalk'
|
|
4
|
+
import { Idl } from '@project-serum/anchor'
|
|
5
|
+
import { IdlAccountItem, IdlField, IdlInstruction, IdlType } from '@project-serum/anchor/dist/cjs/idl.js'
|
|
6
|
+
|
|
7
|
+
export function codegen(abisDir: string, targetPath = path.join('src', 'types', 'solana')) {
|
|
8
|
+
if (!fs.existsSync(abisDir)) {
|
|
9
|
+
return
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
const abisFiles = fs.readdirSync(abisDir)
|
|
13
|
+
|
|
14
|
+
if (abisFiles.length > 0) {
|
|
15
|
+
console.log(chalk.green('Generated Types for Solana'))
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
for (const file of abisFiles) {
|
|
19
|
+
if (path.extname(file) === '.json') {
|
|
20
|
+
if (!fs.existsSync(targetPath)) {
|
|
21
|
+
fs.mkdirSync(targetPath, { recursive: true })
|
|
22
|
+
}
|
|
23
|
+
const idlContent = fs.readFileSync(path.join(abisDir, file), 'utf-8')
|
|
24
|
+
const idlObj = JSON.parse(idlContent)
|
|
25
|
+
const idlName = idlObj.name
|
|
26
|
+
const idlFile = path.join(targetPath, idlName + '.ts')
|
|
27
|
+
fs.writeFileSync(idlFile, `export const ${idlName}_idl = ${idlContent}`)
|
|
28
|
+
fs.writeFileSync(path.join(targetPath, `${idlName}_processor.ts`), codeGenSolanaIdlProcessor(idlObj))
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function codeGenSolanaIdlProcessor(idlObj: Idl): string {
|
|
34
|
+
const idlName = idlObj.name
|
|
35
|
+
const idlNamePascalCase = toPascalCase(idlName)
|
|
36
|
+
const instructions: any[] = idlObj.instructions
|
|
37
|
+
return `import { BorshInstructionCoder, Instruction, Idl } from '@project-serum/anchor'
|
|
38
|
+
import { SolanaBaseProcessor, SolanaContext, SolanaBindOptions } from "@sentio/sdk/solana"
|
|
39
|
+
import { ${idlName}_idl } from "./${idlName}.js"
|
|
40
|
+
import { PublicKey } from '@solana/web3.js'
|
|
41
|
+
|
|
42
|
+
export class ${idlNamePascalCase}Processor extends SolanaBaseProcessor {
|
|
43
|
+
static DEFAULT_OPTIONS = {
|
|
44
|
+
name: '${idlNamePascalCase}',
|
|
45
|
+
instructionCoder: new BorshInstructionCoder(${idlName}_idl as Idl)
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
static bind(options: SolanaBindOptions): ${idlNamePascalCase}Processor {
|
|
49
|
+
return new ${idlNamePascalCase}Processor( { ...${idlNamePascalCase}Processor.DEFAULT_OPTIONS, ...options })
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
${instructions.map((ins) => codeGenSolanaInstruction(idlNamePascalCase, ins)).join('')}
|
|
53
|
+
}
|
|
54
|
+
`
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function codeGenSolanaInstruction(idlName: string, ins: IdlInstruction): string {
|
|
58
|
+
const instructionName = ins.name
|
|
59
|
+
|
|
60
|
+
const argsType = codeGenInstructionArgsType(ins.args)
|
|
61
|
+
const accountType = codeGenAccountType(ins.accounts)
|
|
62
|
+
|
|
63
|
+
return `
|
|
64
|
+
on${
|
|
65
|
+
instructionName.charAt(0).toUpperCase() + instructionName.slice(1)
|
|
66
|
+
}(handler: (args: ${argsType}, accounts: ${accountType}, ctx: SolanaContext) => void): ${idlName}Processor {
|
|
67
|
+
this.onInstruction('${instructionName}', (ins: Instruction, ctx, accounts: string[]) => {
|
|
68
|
+
const origin = ins.data as any
|
|
69
|
+
if (origin) {
|
|
70
|
+
const data = ${codeGenInstructionArgs(ins.args)}
|
|
71
|
+
const accountData = ${codeGenAccountTypeArgs(ins.accounts)}
|
|
72
|
+
handler(data, accountData, ctx)
|
|
73
|
+
}
|
|
74
|
+
})
|
|
75
|
+
return this
|
|
76
|
+
}
|
|
77
|
+
`
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
function codeGenInstructionArgs(args: IdlField[]): string {
|
|
81
|
+
return `{ ${args.map((arg) => codeGenInstructionArg(arg.name, arg.type)).join(', ')} }`
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
function codeGenInstructionArg(name: string, type: IdlType): string {
|
|
85
|
+
const mType = mapType(type)
|
|
86
|
+
if (mType === 'bigint') {
|
|
87
|
+
return `${name}: BigInt(origin.${name}.toString())`
|
|
88
|
+
}
|
|
89
|
+
return `${name}: origin.${name} as ${mType}`
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
function codeGenInstructionArgsType(args: IdlField[]): string {
|
|
93
|
+
return `{ ${args.map((arg) => arg.name + ': ' + mapType(arg.type)).join(', ')} }`
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
function codeGenAccountType(args: IdlAccountItem[]): string {
|
|
97
|
+
return `{ ${args.map((arg) => arg.name + ': string').join(', ')} }`
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
function codeGenAccountTypeArgs(args: IdlAccountItem[]): string {
|
|
101
|
+
return `{ ${args.map((arg, idx) => `${arg.name}: accounts[${idx}]`).join(', ')} }`
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
// Reference: https://github.com/coral-xyz/anchor/blob/93332766f13e86efbe77c9986722731742317ede/ts/src/program/namespace/types.ts#L104
|
|
105
|
+
function mapType(tpe: IdlType): string {
|
|
106
|
+
// TODO handle complex type
|
|
107
|
+
switch (tpe) {
|
|
108
|
+
case 'publicKey':
|
|
109
|
+
return 'PublicKey'
|
|
110
|
+
case 'bool':
|
|
111
|
+
return 'boolean'
|
|
112
|
+
case 'string':
|
|
113
|
+
return 'string'
|
|
114
|
+
case 'u8':
|
|
115
|
+
case 'i8':
|
|
116
|
+
case 'u16':
|
|
117
|
+
case 'i16':
|
|
118
|
+
case 'u32':
|
|
119
|
+
case 'i32':
|
|
120
|
+
case 'f32':
|
|
121
|
+
case 'f64':
|
|
122
|
+
return 'number'
|
|
123
|
+
case 'u64':
|
|
124
|
+
case 'i64':
|
|
125
|
+
case 'u128':
|
|
126
|
+
case 'i128':
|
|
127
|
+
return 'bigint'
|
|
128
|
+
default:
|
|
129
|
+
return 'any'
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
function toPascalCase(str: string) {
|
|
134
|
+
return `${str}`
|
|
135
|
+
.toLowerCase()
|
|
136
|
+
.replace(new RegExp(/[-_]+/, 'g'), ' ')
|
|
137
|
+
.replace(new RegExp(/[^\w\s]/, 'g'), '')
|
|
138
|
+
.replace(new RegExp(/\s+(.)(\w*)/, 'g'), ($1, $2, $3) => `${$2.toUpperCase() + $3}`)
|
|
139
|
+
.replace(new RegExp(/\w/), (s) => s.toUpperCase())
|
|
140
|
+
}
|