@sentio/sdk 2.0.0-rc.19 → 2.0.0-rc.20
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/codegen/codegen.d.ts +1 -3
- package/lib/aptos/codegen/codegen.js +12 -16
- package/lib/aptos/codegen/codegen.js.map +1 -1
- package/lib/aptos/network.js +1 -1
- package/lib/aptos/network.js.map +1 -1
- package/lib/aptos/run-codegen.js +2 -2
- package/lib/aptos/run-codegen.js.map +1 -1
- 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/{chain.d.ts → core/chain.d.ts} +0 -0
- package/lib/{chain.js → 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 +5 -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 +5 -5
- package/lib/eth/base-processor.js +1 -1
- 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 +0 -0
- 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 +0 -0
- 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 +0 -0
- 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 +0 -0
- 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 +0 -0
- 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 +0 -0
- 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 +0 -0
- 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 +1 -1
- package/lib/{builtin → eth/builtin}/internal/eacaggregatorproxy_processor.js +1 -1
- package/lib/eth/builtin/internal/eacaggregatorproxy_processor.js.map +1 -0
- package/lib/{builtin → eth/builtin}/internal/erc1155_processor.d.ts +1 -1
- package/lib/{builtin → eth/builtin}/internal/erc1155_processor.js +1 -1
- package/lib/eth/builtin/internal/erc1155_processor.js.map +1 -0
- package/lib/{builtin → eth/builtin}/internal/erc20_processor.d.ts +1 -1
- package/lib/{builtin → eth/builtin}/internal/erc20_processor.js +1 -1
- package/lib/eth/builtin/internal/erc20_processor.js.map +1 -0
- package/lib/{builtin → eth/builtin}/internal/erc20bytes_processor.d.ts +1 -1
- package/lib/{builtin → eth/builtin}/internal/erc20bytes_processor.js +1 -1
- package/lib/eth/builtin/internal/erc20bytes_processor.js.map +1 -0
- package/lib/{builtin → eth/builtin}/internal/erc721_processor.d.ts +1 -1
- package/lib/{builtin → eth/builtin}/internal/erc721_processor.js +1 -1
- package/lib/eth/builtin/internal/erc721_processor.js.map +1 -0
- package/lib/{builtin → eth/builtin}/internal/factories/EACAggregatorProxy__factory.d.ts +0 -0
- 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 +0 -0
- 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 +0 -0
- 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 +0 -0
- 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 +0 -0
- 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 +0 -0
- 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 +1 -1
- package/lib/{builtin → eth/builtin}/internal/weth9_processor.js +1 -1
- 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} +27 -34
- 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/{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/{target-ethers-sentio/view-function.cjs → eth/codegen/view-function.js} +13 -20
- package/lib/eth/codegen/view-function.js.map +1 -0
- package/lib/{core → eth}/context.d.ts +3 -3
- package/lib/{core → eth}/context.js +3 -3
- 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 +10 -2
- package/lib/eth/eth.js +43 -1
- package/lib/eth/eth.js.map +1 -1
- package/lib/eth/generic-processor.d.ts +2 -2
- package/lib/eth/generic-processor.js +1 -1
- 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 +4 -1
- package/lib/eth/index.js +4 -1
- package/lib/eth/index.js.map +1 -1
- package/lib/eth/run-codegen.d.ts +2 -0
- package/lib/eth/run-codegen.js +12 -0
- package/lib/eth/run-codegen.js.map +1 -0
- package/lib/index.d.ts +1 -3
- package/lib/index.js +1 -5
- package/lib/index.js.map +1 -1
- package/lib/solana/codegen/codegen.d.ts +1 -1
- package/lib/solana/codegen/codegen.js +1 -1
- package/lib/solana/codegen/codegen.js.map +1 -1
- package/lib/solana/run-codegen.js +2 -2
- package/lib/solana/run-codegen.js.map +1 -1
- 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/dex-price.js +2 -2
- package/lib/utils/dex-price.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 +22 -21
- package/src/aptos/codegen/codegen.ts +13 -22
- package/src/aptos/codegen/tsconfig.json +1 -1
- package/src/aptos/network.ts +1 -1
- package/src/aptos/run-codegen.ts +2 -2
- package/src/core/big-decimal.ts +11 -0
- package/src/{chain.ts → 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 -5
- package/src/eth/base-processor.ts +6 -6
- 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 +0 -0
- package/src/{builtin → eth/builtin}/internal/ERC1155.ts +0 -0
- package/src/{builtin → eth/builtin}/internal/ERC20.ts +0 -0
- package/src/{builtin → eth/builtin}/internal/ERC20Bytes.ts +0 -0
- package/src/{builtin → eth/builtin}/internal/ERC721.ts +0 -0
- package/src/{builtin → eth/builtin}/internal/WETH9.ts +0 -0
- package/src/{builtin → eth/builtin}/internal/common.ts +0 -0
- package/src/{builtin → eth/builtin}/internal/eacaggregatorproxy_processor.ts +1 -1
- package/src/{builtin → eth/builtin}/internal/erc1155_processor.ts +1 -1
- package/src/{builtin → eth/builtin}/internal/erc20_processor.ts +1 -1
- package/src/{builtin → eth/builtin}/internal/erc20bytes_processor.ts +1 -1
- package/src/{builtin → eth/builtin}/internal/erc721_processor.ts +1 -1
- package/src/{builtin → eth/builtin}/internal/factories/EACAggregatorProxy__factory.ts +0 -0
- package/src/{builtin → eth/builtin}/internal/factories/ERC1155__factory.ts +0 -0
- package/src/{builtin → eth/builtin}/internal/factories/ERC20Bytes__factory.ts +0 -0
- package/src/{builtin → eth/builtin}/internal/factories/ERC20__factory.ts +0 -0
- package/src/{builtin → eth/builtin}/internal/factories/ERC721__factory.ts +0 -0
- package/src/{builtin → eth/builtin}/internal/factories/WETH9__factory.ts +0 -0
- 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 +1 -1
- 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} +6 -6
- 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/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} +5 -3
- package/src/{core → eth}/context.ts +4 -4
- package/src/eth/error.ts +4 -0
- package/src/eth/eth.ts +53 -3
- package/src/eth/generic-processor.ts +2 -2
- package/src/eth/index.ts +5 -3
- package/src/eth/run-codegen.ts +12 -0
- package/src/index.ts +1 -6
- package/src/solana/codegen/codegen.ts +1 -1
- package/src/solana/codegen/tsconfig.json +1 -1
- package/src/solana/run-codegen.ts +2 -2
- 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/dex-price.ts +2 -2
- 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/chain.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 +0 -36
- 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.map +0 -1
- package/src/error.ts +0 -43
- package/src/target-ethers-sentio/.eslintrc.json +0 -14
- package/src/target-ethers-sentio/tsconfig.json +0 -9
package/lib/utils/dex-price.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { getEACAggregatorProxyContract } from '../builtin/internal/eacaggregatorproxy_processor.js';
|
|
1
|
+
import { getEACAggregatorProxyContract } from '../eth/builtin/internal/eacaggregatorproxy_processor.js';
|
|
2
2
|
import fs from 'fs';
|
|
3
3
|
import { parse } from 'csv-parse/sync';
|
|
4
|
-
import { scaleDown } from './token.js';
|
|
5
4
|
import url from 'url';
|
|
5
|
+
import { scaleDown } from '../core/big-decimal.js';
|
|
6
6
|
export var PriceUnit;
|
|
7
7
|
(function (PriceUnit) {
|
|
8
8
|
PriceUnit[PriceUnit["USD"] = 0] = "USD";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dex-price.js","sourceRoot":"","sources":["../../src/utils/dex-price.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,6BAA6B,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"dex-price.js","sourceRoot":"","sources":["../../src/utils/dex-price.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,6BAA6B,EAAE,MAAM,yDAAyD,CAAA;AACvG,OAAO,EAAE,MAAM,IAAI,CAAA;AACnB,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAA;AAEtC,OAAO,GAAG,MAAM,KAAK,CAAA;AACrB,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAA;AASlD,MAAM,CAAN,IAAY,SAIX;AAJD,WAAY,SAAS;IACnB,uCAAO,CAAA;IACP,uCAAO,CAAA;IACP,uCAAO,CAAA;AACT,CAAC,EAJW,SAAS,KAAT,SAAS,QAIpB;AAOD,uGAAuG;AACvG,wDAAwD;AACxD,MAAM,QAAQ;IACZ,cAAc,GAAG,IAAI,GAAG,EAAkB,CAAA;IAC1C,cAAc,GAAG,IAAI,GAAG,EAAkB,CAAA;IAC1C,cAAc,GAAG,IAAI,GAAG,EAAkB,CAAA;IAC1C,YAAY,GAAG,IAAI,GAAG,EAAkB,CAAA;IAE/B,OAAO,CAAQ;IAExB,YAAY,WAAmB,EAAE,OAAe;QAC9C,IAAI,CAAC,OAAO,GAAG,OAAO,CAAA;QACtB,MAAM,WAAW,GAAG,GA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ACtC;YAED,OAAO;gBACL,KAAK,EAAE,SAAS,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC,QAAQ,EAAE;aAC5C,CAAA;SACF;QAAC,OAAO,CAAC,EAAE;YACV,OAAO;gBACL,KAAK,EACH,wBAAwB;oBACxB,KAAK;oBACL,aAAa;oBACb,IAAI;oBACJ,YAAY;oBACZ,IAAI,CAAC,OAAO;oBACZ,aAAa;oBACb,CAAC,CAAC,QAAQ,EAAE;aACf,CAAA;SACF;IACH,CAAC;CACF;AAED,MAAM,CAAC,MAAM,gBAAgB,GAAG,IAAI,QAAQ,CAAC,uBAAuB,EAAE,CAAC,CAAC,CAAA;AACxE,MAAM,CAAC,MAAM,cAAc,GAAG,IAAI,QAAQ,CAAC,8BAA8B,EAAE,CAAC,CAAC,CAAA","sourcesContent":["import { getEACAggregatorProxyContract } from '../eth/builtin/internal/eacaggregatorproxy_processor.js'\nimport fs from 'fs'\nimport { parse } from 'csv-parse/sync'\nimport { BlockTag } from 'ethers/providers'\nimport url from 'url'\nimport { scaleDown } from '../core/big-decimal.js'\n\ntype OralceRecord = {\n Pair: string\n Asset: string\n Type: string\n Address: string\n}\n\nexport enum PriceUnit {\n USD = 0,\n ETH = 1,\n BTC = 2,\n}\n\nexport interface DexPriceResult {\n price?: number\n error?: string\n}\n\n// Load price feed from https://docs.chain.link/docs/data-feeds/price-feeds/addresses/?network=ethereum\n// and then use EACAggregatorProxy contract to get price\nclass DexPrice {\n USD_ORACLE_MAP = new Map<string, string>()\n ETH_ORACLE_MAP = new Map<string, string>()\n BTC_ORACLE_MAP = new Map<string, string>()\n ASSETS_INFOS = new Map<string, number>()\n\n readonly chainId: number\n\n constructor(csvFileName: string, chainId: number) {\n this.chainId = chainId\n const csvFilePath = url.fileURLToPath(new URL('./' + csvFileName, import.meta.url))\n const fileContent = fs.readFileSync(csvFilePath, { encoding: 'utf-8' })\n const headers = ['Pair', 'Asset', 'Type', 'Address']\n\n const records: OralceRecord[] = parse(fileContent, {\n delimiter: ',',\n columns: headers,\n skip_empty_lines: true,\n })\n\n for (const record of records) {\n const pair = record.Pair.split('/')\n const asset = pair[0].trim().toLowerCase()\n const target = pair[1].trim().toLowerCase()\n const address = record.Address.toLowerCase()\n if (target === 'usd') {\n this.USD_ORACLE_MAP.set(asset, address)\n } else if (target === 'eth') {\n this.ETH_ORACLE_MAP.set(asset, address)\n } else if (target == 'btc') {\n this.BTC_ORACLE_MAP.set(asset, address)\n } else {\n console.error('wrong asset record:' + JSON.stringify(record))\n }\n\n // console.log(asset, target, address)\n }\n }\n\n // asset: symbol of the asset\n // unit: usd, eth or btc\n // blockTag: blockNumber of block symbol like \"latest\"\n // returns the asset price,\n // throw exception if calling to price feed failed, e.g. due to a invalid block number\n async getPrice(\n asset: string,\n blockTag: BlockTag = 'latest',\n unit: PriceUnit = PriceUnit.USD\n ): Promise<DexPriceResult> {\n // if (chainId !== 1 && chainId !== 5) {\n // return {\n // error: \"current dex price only support chain 1 (mainnet) or 5 (goerli)\"\n // }\n // }\n\n let oracleMap = this.USD_ORACLE_MAP\n switch (unit) {\n case PriceUnit.ETH:\n oracleMap = this.ETH_ORACLE_MAP\n break\n case PriceUnit.BTC:\n oracleMap = this.BTC_ORACLE_MAP\n break\n default:\n }\n\n asset = asset.trim().toLowerCase()\n\n const addr = oracleMap.get(asset)\n if (!addr) {\n return {\n error: 'No price feed found for asset',\n }\n }\n\n const contract = getEACAggregatorProxyContract(addr, this.chainId)\n try {\n const price = await contract.latestAnswer({\n blockTag: blockTag,\n })\n\n let decimal = this.ASSETS_INFOS.get(asset)\n if (!decimal) {\n decimal = Number(await contract.decimals())\n this.ASSETS_INFOS.set(asset, decimal)\n }\n\n return {\n price: scaleDown(price, decimal).toNumber(),\n }\n } catch (e) {\n return {\n error:\n 'Price query error for ' +\n asset +\n ' failed at ' +\n addr +\n ' at chain ' +\n this.chainId +\n '. Details: ' +\n e.toString(),\n }\n }\n }\n}\n\nexport const EthereumDexPrice = new DexPrice('chainlink-oracles.csv', 1)\nexport const GoerliDexPrice = new DexPrice('chainlink-oracles-goerli.csv', 5)\n"]}
|
package/lib/utils/token.d.ts
CHANGED
|
@@ -11,4 +11,3 @@ export declare const NATIVE_ETH: {
|
|
|
11
11
|
};
|
|
12
12
|
export declare function getERC20TokenInfo(tokenAddress: string, chainId?: number): Promise<TokenInfo>;
|
|
13
13
|
export declare function getER20NormalizedAmount(tokenAddress: string, amount: bigint, chainId: number): Promise<BigDecimal>;
|
|
14
|
-
export declare function scaleDown(amount: bigint, decimal: number | bigint): BigDecimal;
|
package/lib/utils/token.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { BigDecimal } from '../core/big-decimal.js';
|
|
1
|
+
import { getERC20Contract } from '../eth/builtin/erc20/index.js';
|
|
2
|
+
import { getERC20BytesContract } from '../eth/builtin/internal/erc20bytes_processor.js';
|
|
3
|
+
import { scaleDown } from '../core/big-decimal.js';
|
|
5
4
|
import { decodeBytes32String } from 'ethers';
|
|
6
5
|
export const NATIVE_ETH = {
|
|
7
6
|
symbol: 'ETH',
|
|
@@ -24,37 +23,27 @@ export async function getERC20TokenInfo(tokenAddress, chainId = 1) {
|
|
|
24
23
|
}
|
|
25
24
|
const contract = getERC20Contract(tokenAddress, chainId);
|
|
26
25
|
const bytesContract = getERC20BytesContract(tokenAddress, chainId);
|
|
26
|
+
let name = '';
|
|
27
27
|
try {
|
|
28
|
-
|
|
29
|
-
let name = '';
|
|
30
|
-
try {
|
|
31
|
-
name = await contract.name();
|
|
32
|
-
}
|
|
33
|
-
catch (e) {
|
|
34
|
-
name = decodeBytes32String(await bytesContract.name());
|
|
35
|
-
}
|
|
36
|
-
let symbol = '';
|
|
37
|
-
try {
|
|
38
|
-
symbol = await contract.symbol();
|
|
39
|
-
}
|
|
40
|
-
catch (e) {
|
|
41
|
-
symbol = decodeBytes32String(await bytesContract.symbol());
|
|
42
|
-
}
|
|
43
|
-
const decimal = await contract.decimals();
|
|
44
|
-
const info = getTokenInfoPromise(symbol, name, decimal);
|
|
45
|
-
TOKEN_INFOS.set(key, info);
|
|
46
|
-
return info;
|
|
28
|
+
name = await contract.name();
|
|
47
29
|
}
|
|
48
30
|
catch (e) {
|
|
49
|
-
|
|
31
|
+
name = decodeBytes32String(await bytesContract.name());
|
|
50
32
|
}
|
|
33
|
+
let symbol = '';
|
|
34
|
+
try {
|
|
35
|
+
symbol = await contract.symbol();
|
|
36
|
+
}
|
|
37
|
+
catch (e) {
|
|
38
|
+
symbol = decodeBytes32String(await bytesContract.symbol());
|
|
39
|
+
}
|
|
40
|
+
const decimal = await contract.decimals();
|
|
41
|
+
const info = getTokenInfoPromise(symbol, name, decimal);
|
|
42
|
+
TOKEN_INFOS.set(key, info);
|
|
43
|
+
return info;
|
|
51
44
|
}
|
|
52
45
|
export async function getER20NormalizedAmount(tokenAddress, amount, chainId) {
|
|
53
46
|
const tokenInfo = await getERC20TokenInfo(tokenAddress, chainId);
|
|
54
47
|
return scaleDown(amount, tokenInfo.decimal);
|
|
55
48
|
}
|
|
56
|
-
export function scaleDown(amount, decimal) {
|
|
57
|
-
const divider = new BigDecimal(10).pow(Number(decimal));
|
|
58
|
-
return amount.asBigDecimal().dividedBy(divider);
|
|
59
|
-
}
|
|
60
49
|
//# sourceMappingURL=token.js.map
|
package/lib/utils/token.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"token.js","sourceRoot":"","sources":["../../src/utils/token.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"token.js","sourceRoot":"","sources":["../../src/utils/token.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAA;AAChE,OAAO,EAAE,qBAAqB,EAAE,MAAM,iDAAiD,CAAA;AACvF,OAAO,EAAc,SAAS,EAAE,MAAM,wBAAwB,CAAA;AAI9D,OAAO,EAAE,mBAAmB,E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,QAAQ,CAAC,QAAQ,EAAE,CAAA;IACzC,MAAM,IAAI,GAAG,mBAAmB,CAAC,MAAM,EAAE,IAAI,EAAE,OAAO,CAAC,CAAA;IAEvD,WAAW,CAAC,GAAG,CAAC,GAAG,EAAE,IAAI,CAAC,CAAA;IAC1B,OAAO,IAAI,CAAA;AACb,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,uBAAuB,CAC3C,YAAoB,EACpB,MAAc,EACd,OAAe;IAEf,MAAM,SAAS,GAAG,MAAM,iBAAiB,CAAC,YAAY,EAAE,OAAO,CAAC,CAAA;IAChE,OAAO,SAAS,CAAC,MAAM,EAAE,SAAS,CAAC,OAAO,CAAC,CAAA;AAC7C,CAAC","sourcesContent":["import { getERC20Contract } from '../eth/builtin/erc20/index.js'\nimport { getERC20BytesContract } from '../eth/builtin/internal/erc20bytes_processor.js'\nimport { BigDecimal, scaleDown } from '../core/big-decimal.js'\n// import { toBigDecimal } from './conversion'\n// import { utils } from 'ethers'\nimport { PromiseOrValue } from '../eth/builtin/internal/common.js'\nimport { decodeBytes32String } from 'ethers'\n\nexport interface TokenInfo {\n symbol: string\n name: string\n decimal: number\n}\n\nexport const NATIVE_ETH = {\n symbol: 'ETH',\n decimal: 18,\n name: 'Native ETH',\n}\n\nconst TOKEN_INFOS = new Map<string, Promise<TokenInfo>>()\n\nasync function getTokenInfoPromise(\n symbol: PromiseOrValue<string> | string,\n name: PromiseOrValue<string> | string,\n decimal: PromiseOrValue<bigint>\n): Promise<TokenInfo> {\n return {\n symbol: await symbol,\n name: await name,\n decimal: Number(await decimal),\n }\n}\n\nexport async function getERC20TokenInfo(tokenAddress: string, chainId = 1): Promise<TokenInfo> {\n const key = chainId + tokenAddress\n const res = TOKEN_INFOS.get(key)\n if (res) {\n return res\n }\n const contract = getERC20Contract(tokenAddress, chainId)\n const bytesContract = getERC20BytesContract(tokenAddress, chainId)\n\n let name = ''\n try {\n name = await contract.name()\n } catch (e) {\n name = decodeBytes32String(await bytesContract.name())\n }\n\n let symbol = ''\n try {\n symbol = await contract.symbol()\n } catch (e) {\n symbol = decodeBytes32String(await bytesContract.symbol())\n }\n\n const decimal = await contract.decimals()\n const info = getTokenInfoPromise(symbol, name, decimal)\n\n TOKEN_INFOS.set(key, info)\n return info\n}\n\nexport async function getER20NormalizedAmount(\n tokenAddress: string,\n amount: bigint,\n chainId: number\n): Promise<BigDecimal> {\n const tokenInfo = await getERC20TokenInfo(tokenAddress, chainId)\n return scaleDown(amount, tokenInfo.decimal)\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,35 +1,35 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sentio/sdk",
|
|
3
3
|
"license": "Apache-2.0",
|
|
4
|
-
"version": "2.0.0-rc.
|
|
4
|
+
"version": "2.0.0-rc.20",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"scripts": {
|
|
7
|
-
"compile_typechain_target": "yarn tsc -b src/target-ethers-sentio/tsconfig.json",
|
|
8
7
|
"compile": "tsc -p . && cp src/utils/*.csv lib/utils && cp src/tsup.config.ts lib",
|
|
9
|
-
"build": "yarn gen && yarn aptos
|
|
8
|
+
"build": "yarn gen:eth && yarn gen:aptos && yarn gen:solana && yarn compile",
|
|
10
9
|
"build_all": "yarn lerna run --scope=@sentio/sdk build --include-dependencies",
|
|
11
10
|
"test": "NODE_OPTIONS=--experimental-vm-modules yarn jest",
|
|
12
|
-
"gen": "
|
|
13
|
-
"
|
|
14
|
-
"aptos
|
|
15
|
-
"
|
|
16
|
-
"solana
|
|
11
|
+
"gen:eth": "ts-node-esm ./src/eth/run-codegen.ts src/eth/abis src/eth/builtin && yarn gen:eth_test",
|
|
12
|
+
"gen:eth_test": "ts-node-esm ./src/eth/run-codegen.ts src/tests/abis/eth ./src/tests/types/eth",
|
|
13
|
+
"gen:aptos": "ts-node-esm ./src/aptos/run-codegen.ts src/aptos/abis src/aptos/builtin && yarn gen:aptos_test",
|
|
14
|
+
"gen:aptos_test": "ts-node-esm ./src/aptos/run-codegen.ts src/aptos/tests/abis src/aptos/tests/types",
|
|
15
|
+
"gen:solana": "ts-node-esm ./src/solana/run-codegen.ts src/solana/tests/abis src/solana/tests/types"
|
|
17
16
|
},
|
|
18
17
|
"dependencies": {
|
|
19
18
|
"@project-serum/anchor": "^0.26.0",
|
|
20
19
|
"@sentio/bigdecimal": "^9.1.1-patch.3",
|
|
21
20
|
"@sentio/ethers-v6": "^1.0.24",
|
|
22
|
-
"@sentio/protos": "^2.0.0-rc.
|
|
23
|
-
"@sentio/runtime": "^2.0.0-rc.
|
|
24
|
-
"@sentio/sdk": "^2.0.0-rc.
|
|
21
|
+
"@sentio/protos": "^2.0.0-rc.20",
|
|
22
|
+
"@sentio/runtime": "^2.0.0-rc.20",
|
|
23
|
+
"@sentio/sdk": "^2.0.0-rc.20",
|
|
25
24
|
"@solana/web3.js": "^1.47.3",
|
|
26
25
|
"@types/prettier": "^2.7.2",
|
|
27
26
|
"aptos-sdk": "npm:@sentio/aptos@^1.6.0",
|
|
28
27
|
"bs58": "^5.0.0",
|
|
29
28
|
"chalk": "^5.2.0",
|
|
30
29
|
"csv-parse": "^5.3.0",
|
|
31
|
-
"ethers": "npm:@sentio/ethers@^6.0.0-patch.
|
|
30
|
+
"ethers": "npm:@sentio/ethers@^6.0.0-patch.3",
|
|
32
31
|
"google-protobuf": "^3.15.8",
|
|
32
|
+
"mkdirp": "^2.1.3",
|
|
33
33
|
"nice-grpc": "^2.0.0",
|
|
34
34
|
"p-queue": "^7.3.0",
|
|
35
35
|
"prettier": "^2.8.1",
|
|
@@ -43,20 +43,21 @@
|
|
|
43
43
|
},
|
|
44
44
|
"exports": {
|
|
45
45
|
".": "./lib/index.js",
|
|
46
|
-
"./eth": "./lib/eth/index.js",
|
|
47
46
|
"./testing": "./lib/testing/index.js",
|
|
48
|
-
"./builtin": "./lib/builtin/index.js",
|
|
49
|
-
"./builtin/erc20": "./lib/builtin/erc20/index.js",
|
|
50
|
-
"./builtin/erc721": "./lib/builtin/erc721/index.js",
|
|
51
|
-
"./builtin/erc1155": "./lib/builtin/erc1155/index.js",
|
|
52
|
-
"./builtin/eacaggregatorproxy": "./lib/builtin/eacaggregatorproxy/index.js",
|
|
53
|
-
"./builtin/weth9": "./lib/builtin/weth9/index.js",
|
|
54
47
|
"./utils": "./lib/utils/index.js",
|
|
48
|
+
"./eth": "./lib/eth/index.js",
|
|
49
|
+
"./eth/codegen": "./lib/eth/codegen/index.js",
|
|
50
|
+
"./eth/builtin": "./lib/eth/builtin/index.js",
|
|
51
|
+
"./eth/builtin/erc20": "./lib/eth/builtin/erc20/index.js",
|
|
52
|
+
"./eth/builtin/erc721": "./lib/eth/builtin/erc721/index.js",
|
|
53
|
+
"./eth/builtin/erc1155": "./lib/eth/builtin/erc1155/index.js",
|
|
54
|
+
"./eth/builtin/eacaggregatorproxy": "./lib/eth/builtin/eacaggregatorproxy/index.js",
|
|
55
|
+
"./eth/builtin/weth9": "./lib/eth/builtin/weth9/index.js",
|
|
55
56
|
"./aptos": "./lib/aptos/index.js",
|
|
57
|
+
"./aptos/codegen": "./lib/aptos/codegen/index.js",
|
|
56
58
|
"./aptos/builtin": "./lib/aptos/builtin/index.js",
|
|
57
59
|
"./aptos/builtin/0x1": "./lib/aptos/builtin/0x1.js",
|
|
58
60
|
"./aptos/builtin/0x3": "./lib/aptos/builtin/0x3.js",
|
|
59
|
-
"./aptos/codegen": "./lib/aptos/codegen/index.js",
|
|
60
61
|
"./solana": "./lib/solana/index.js",
|
|
61
62
|
"./solana/builtin": "./lib/solana/builtin/index.js",
|
|
62
63
|
"./solana/codegen": "./lib/solana/codegen/index.js"
|
|
@@ -72,5 +73,5 @@
|
|
|
72
73
|
"typedoc": {
|
|
73
74
|
"entryPoint": "./src/index.ts"
|
|
74
75
|
},
|
|
75
|
-
"gitHead": "
|
|
76
|
+
"gitHead": "6e809c147d767c9652954a5547c239ab3963615e"
|
|
76
77
|
}
|
|
@@ -8,6 +8,15 @@ import chalk from 'chalk'
|
|
|
8
8
|
import { AptosNetwork, getAptosChainName } from '../network.js'
|
|
9
9
|
import { parseMoveType } from '../types.js'
|
|
10
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
|
+
}
|
|
11
20
|
|
|
12
21
|
function getRpcEndpoint(network: AptosNetwork): string {
|
|
13
22
|
switch (network) {
|
|
@@ -21,20 +30,12 @@ function getRpcClient(network: AptosNetwork): AptosClient {
|
|
|
21
30
|
return new AptosClient(getRpcEndpoint(network))
|
|
22
31
|
}
|
|
23
32
|
|
|
24
|
-
|
|
25
|
-
if (!fs.existsSync(abisDir)) {
|
|
26
|
-
return
|
|
27
|
-
}
|
|
28
|
-
console.log(chalk.green('Generated Types for Aptos'))
|
|
29
|
-
await generate(abisDir, outDir)
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
export async function generate(srcDir: string, outputDir: string) {
|
|
33
|
+
async function generate(srcDir: string, outputDir: string) {
|
|
33
34
|
await generateForNetwork(srcDir, outputDir, AptosNetwork.MAIN_NET)
|
|
34
35
|
await generateForNetwork(path.join(srcDir, 'testnet'), path.join(outputDir, 'testnet'), AptosNetwork.TEST_NET)
|
|
35
36
|
}
|
|
36
37
|
|
|
37
|
-
|
|
38
|
+
async function generateForNetwork(srcDir: string, outputDir: string, network: AptosNetwork) {
|
|
38
39
|
if (!fs.existsSync(srcDir)) {
|
|
39
40
|
return
|
|
40
41
|
}
|
|
@@ -366,7 +367,7 @@ function generateCallArgsStructs(module: MoveModule, func: MoveFunction) {
|
|
|
366
367
|
return `${generateType(param, module.address)}`
|
|
367
368
|
})
|
|
368
369
|
|
|
369
|
-
const camelFuncName = capitalizeFirstChar(
|
|
370
|
+
const camelFuncName = capitalizeFirstChar(camelCase(func.name))
|
|
370
371
|
|
|
371
372
|
const genericString = generateFunctionTypeParameters(func)
|
|
372
373
|
return `
|
|
@@ -386,7 +387,7 @@ function generateOnEntryFunctions(module: MoveModule, func: MoveFunction) {
|
|
|
386
387
|
// const genericString = generateFunctionTypeParameters(func)
|
|
387
388
|
const moduleName = normalizeToJSName(module.name)
|
|
388
389
|
|
|
389
|
-
const camelFuncName = capitalizeFirstChar(
|
|
390
|
+
const camelFuncName = capitalizeFirstChar(camelCase(func.name))
|
|
390
391
|
const source = `
|
|
391
392
|
onEntry${camelFuncName}(func: (call: ${moduleName}.${camelFuncName}Payload, ctx: AptosContext) => void, filter?: CallFilter, fetchConfig?: AptosFetchConfig): ${moduleName} {
|
|
392
393
|
this.onEntryFunctionCall(func, {
|
|
@@ -448,16 +449,6 @@ function generateOnEvents(module: MoveModule, struct: MoveStruct): string {
|
|
|
448
449
|
return source
|
|
449
450
|
}
|
|
450
451
|
|
|
451
|
-
function camelize(input: string): string {
|
|
452
|
-
return input
|
|
453
|
-
.split('_')
|
|
454
|
-
.reduce(
|
|
455
|
-
(res, word, i) =>
|
|
456
|
-
i === 0 ? word.toLowerCase() : `${res}${word.charAt(0).toUpperCase()}${word.slice(1).toLowerCase()}`,
|
|
457
|
-
''
|
|
458
|
-
)
|
|
459
|
-
}
|
|
460
|
-
|
|
461
452
|
function capitalizeFirstChar(input: string): string {
|
|
462
453
|
if (!input) {
|
|
463
454
|
return input
|
package/src/aptos/network.ts
CHANGED
package/src/aptos/run-codegen.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
// #!/usr/bin/env node
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import { codegen } from './codegen/codegen.js'
|
|
4
4
|
|
|
5
5
|
if (process.argv.length > 3) {
|
|
6
6
|
const abisDir = process.argv[2]
|
|
7
7
|
const targetDir = process.argv[3]
|
|
8
8
|
|
|
9
|
-
await
|
|
9
|
+
await codegen(abisDir, targetDir)
|
|
10
10
|
} else {
|
|
11
11
|
console.error('Not enough argument')
|
|
12
12
|
process.exit(1)
|
package/src/core/big-decimal.ts
CHANGED
|
@@ -5,8 +5,19 @@ export { BigDecimal } from '@sentio/bigdecimal'
|
|
|
5
5
|
declare global {
|
|
6
6
|
interface BigInt {
|
|
7
7
|
asBigDecimal(): BigDecimal
|
|
8
|
+
scaleDown(decimal: number | bigint): BigDecimal
|
|
8
9
|
}
|
|
9
10
|
}
|
|
10
11
|
BigInt.prototype.asBigDecimal = function () {
|
|
11
12
|
return new BigDecimal(this.toString())
|
|
12
13
|
}
|
|
14
|
+
|
|
15
|
+
BigInt.prototype.scaleDown = function (decimal: number | bigint) {
|
|
16
|
+
// @ts-ignore this is fine
|
|
17
|
+
return scaleDown(this, decimal)
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export function scaleDown(amount: bigint, decimal: number | bigint): BigDecimal {
|
|
21
|
+
const divider = new BigDecimal(10).pow(Number(decimal))
|
|
22
|
+
return amount.asBigDecimal().dividedBy(divider)
|
|
23
|
+
}
|
|
File without changes
|
package/src/core/index.ts
CHANGED
|
@@ -1,13 +1,10 @@
|
|
|
1
|
-
export { BigDecimal } from './big-decimal.js'
|
|
1
|
+
export { BigDecimal, scaleDown } from './big-decimal.js'
|
|
2
2
|
export { BaseContext } from './base-context.js'
|
|
3
3
|
export { type Labels, normalizeLabels } from './metadata.js'
|
|
4
|
-
export { ContractContext, ContractView, BoundContractView } from './context.js'
|
|
5
4
|
export { CounterBinding, Meter, GaugeBinding, Counter, Gauge, MetricOptions } from './meter.js'
|
|
6
5
|
export { EventTracker, AccountEventTracker } from './event-tracker.js'
|
|
7
6
|
export { Exporter } from './exporter.js'
|
|
8
|
-
export { type Numberish, toBigInteger, toMetricValue
|
|
9
|
-
|
|
10
|
-
export { BindOptions } from './bind-options.js'
|
|
7
|
+
export { type Numberish, toBigInteger, toMetricValue } from './numberish.js'
|
|
11
8
|
|
|
12
9
|
export { SuiBaseProcessor, SuiBindOptions } from './sui-processor.js'
|
|
13
10
|
|
package/src/core/numberish.ts
CHANGED
|
@@ -1,19 +1,8 @@
|
|
|
1
1
|
import { BigInteger, MetricValue } from '@sentio/protos'
|
|
2
2
|
import { BigDecimal } from './big-decimal.js'
|
|
3
|
-
import { BlockTag } from 'ethers/providers'
|
|
4
3
|
|
|
5
4
|
export type Numberish = number | bigint | BigDecimal | string
|
|
6
5
|
|
|
7
|
-
export function toBlockTag(a: number | bigint): BlockTag {
|
|
8
|
-
if (typeof a === 'number') {
|
|
9
|
-
return a
|
|
10
|
-
}
|
|
11
|
-
if (a > Number.MAX_SAFE_INTEGER) {
|
|
12
|
-
return '0x' + a.toString(16)
|
|
13
|
-
}
|
|
14
|
-
return Number(a)
|
|
15
|
-
}
|
|
16
|
-
|
|
17
6
|
export function toMetricValue(value: Numberish): MetricValue {
|
|
18
7
|
if (typeof value === 'number') {
|
|
19
8
|
if (Number.isNaN(value)) {
|
package/src/core/sui-plugin.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { ContractConfig, DataBinding, HandlerType, ProcessConfigResponse, Proces
|
|
|
3
3
|
|
|
4
4
|
import { ServerError, Status } from 'nice-grpc'
|
|
5
5
|
|
|
6
|
-
import { CHAIN_IDS } from '
|
|
6
|
+
import { CHAIN_IDS } from './chain.js'
|
|
7
7
|
import { SuiProcessorState } from './sui-processor.js'
|
|
8
8
|
|
|
9
9
|
export class SuiPlugin extends Plugin {
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import { ERC20__factory, ERC721__factory } from '
|
|
1
|
+
import { ERC20__factory, ERC721__factory } from './builtin/internal/index.js'
|
|
2
2
|
import { AddressType, EthFetchConfig, ProcessResult } from '@sentio/protos'
|
|
3
|
-
import { AccountBindOptions } from '
|
|
3
|
+
import { AccountBindOptions } from './bind-options.js'
|
|
4
4
|
|
|
5
5
|
import { Network, LogParams } from 'ethers/providers'
|
|
6
6
|
|
|
7
|
-
import { TransferEvent as ERC20TransferEvent } from '
|
|
8
|
-
import { TransferEvent as ERC721TransferEvent } from '
|
|
7
|
+
import { TransferEvent as ERC20TransferEvent } from './builtin/internal/ERC20.js'
|
|
8
|
+
import { TransferEvent as ERC721TransferEvent } from './builtin/internal/ERC721.js'
|
|
9
9
|
|
|
10
|
-
import { ERC20Processor } from '
|
|
11
|
-
import { ERC721Processor } from '
|
|
10
|
+
import { ERC20Processor } from './builtin/internal/erc20_processor.js'
|
|
11
|
+
import { ERC721Processor } from './builtin/internal/erc721_processor.js'
|
|
12
12
|
|
|
13
|
-
import { AccountContext } from '
|
|
13
|
+
import { AccountContext } from './context.js'
|
|
14
14
|
import { PromiseOrVoid } from '../promise-or-void.js'
|
|
15
15
|
import { AddressOrTypeEventFilter, EventsHandler } from './base-processor.js'
|
|
16
16
|
import { Transaction, Block, TransactionReceipt, LogDescription } from 'ethers'
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { BoundContractView, ContractContext, ContractView } from '
|
|
1
|
+
import { BoundContractView, ContractContext, ContractView } from './context.js'
|
|
2
2
|
import { BaseContract, ContractEvent, Block, LogDescription } from 'ethers'
|
|
3
3
|
import { AddressOrTypeEventFilter, BaseProcessor } from './base-processor.js'
|
|
4
|
-
import { BindOptions, getOptionsSignature } from '
|
|
4
|
+
import { BindOptions, getOptionsSignature } from './bind-options.js'
|
|
5
5
|
import { EthFetchConfig, HandleInterval, TemplateInstance } from '@sentio/protos'
|
|
6
6
|
import { PromiseOrVoid } from '../promise-or-void.js'
|
|
7
7
|
import { Trace } from './trace.js'
|
|
8
8
|
import { ListStateStorage } from '@sentio/runtime'
|
|
9
9
|
import { EventFilter, LogParams, Network } from 'ethers/providers'
|
|
10
10
|
import { DeferredTopicFilter } from 'ethers/contract'
|
|
11
|
-
import {
|
|
11
|
+
import { EthLog } from './eth.js'
|
|
12
12
|
|
|
13
13
|
export class ProcessorTemplateProcessorState extends ListStateStorage<
|
|
14
14
|
BaseProcessorTemplate<BaseContract, BoundContractView<BaseContract, any>>
|
|
@@ -37,7 +37,7 @@ export abstract class BaseProcessorTemplate<
|
|
|
37
37
|
fetchConfig?: EthFetchConfig
|
|
38
38
|
}[] = []
|
|
39
39
|
eventHandlers: {
|
|
40
|
-
handler: (event:
|
|
40
|
+
handler: (event: EthLog, ctx: ContractContext<TContract, TBoundContractView>) => PromiseOrVoid
|
|
41
41
|
filter: DeferredTopicFilter | DeferredTopicFilter[]
|
|
42
42
|
fetchConfig?: EthFetchConfig
|
|
43
43
|
}[] = []
|
|
@@ -88,7 +88,7 @@ export abstract class BaseProcessorTemplate<
|
|
|
88
88
|
}
|
|
89
89
|
|
|
90
90
|
public onEvent(
|
|
91
|
-
handler: (event:
|
|
91
|
+
handler: (event: EthLog, ctx: ContractContext<TContract, TBoundContractView>) => PromiseOrVoid,
|
|
92
92
|
filter: DeferredTopicFilter | DeferredTopicFilter[],
|
|
93
93
|
fetchConfig?: EthFetchConfig
|
|
94
94
|
) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Block, TransactionReceipt, BaseContract, Transaction, DeferredTopicFilter } from 'ethers'
|
|
2
2
|
import { LogParams, Network } from 'ethers/providers'
|
|
3
3
|
|
|
4
|
-
import { BoundContractView, ContractContext, ContractView } from '
|
|
4
|
+
import { BoundContractView, ContractContext, ContractView } from './context.js'
|
|
5
5
|
import {
|
|
6
6
|
AddressType,
|
|
7
7
|
Data_EthBlock,
|
|
@@ -11,11 +11,11 @@ import {
|
|
|
11
11
|
HandleInterval,
|
|
12
12
|
ProcessResult,
|
|
13
13
|
} from '@sentio/protos'
|
|
14
|
-
import { BindInternalOptions, BindOptions } from '
|
|
14
|
+
import { BindInternalOptions, BindOptions } from './bind-options.js'
|
|
15
15
|
import { PromiseOrVoid } from '../promise-or-void.js'
|
|
16
16
|
import { Trace } from './trace.js'
|
|
17
17
|
import { ServerError, Status } from 'nice-grpc'
|
|
18
|
-
import {
|
|
18
|
+
import { EthLog } from './eth.js'
|
|
19
19
|
|
|
20
20
|
export interface AddressOrTypeEventFilter extends DeferredTopicFilter {
|
|
21
21
|
addressType?: AddressType
|
|
@@ -78,7 +78,7 @@ export abstract class BaseProcessor<
|
|
|
78
78
|
}
|
|
79
79
|
|
|
80
80
|
public onEvent(
|
|
81
|
-
handler: (event:
|
|
81
|
+
handler: (event: EthLog, ctx: ContractContext<TContract, TBoundContractView>) => PromiseOrVoid,
|
|
82
82
|
filter: DeferredTopicFilter | DeferredTopicFilter[],
|
|
83
83
|
fetchConfig?: EthFetchConfig
|
|
84
84
|
) {
|
|
@@ -120,7 +120,7 @@ export abstract class BaseProcessor<
|
|
|
120
120
|
const parsed = contractView.rawContract.interface.parseLog(logParam)
|
|
121
121
|
|
|
122
122
|
if (parsed) {
|
|
123
|
-
const event:
|
|
123
|
+
const event: EthLog = { ...log, args: parsed.args }
|
|
124
124
|
await handler(event, ctx)
|
|
125
125
|
return ctx.getProcessResult()
|
|
126
126
|
}
|
|
@@ -189,7 +189,7 @@ export abstract class BaseProcessor<
|
|
|
189
189
|
return this
|
|
190
190
|
}
|
|
191
191
|
|
|
192
|
-
public onAllEvents(handler: (event:
|
|
192
|
+
public onAllEvents(handler: (event: EthLog, ctx: ContractContext<TContract, TBoundContractView>) => PromiseOrVoid) {
|
|
193
193
|
const _filters: DeferredTopicFilter[] = []
|
|
194
194
|
const tmpContract = this.CreateBoundContractView()
|
|
195
195
|
|
|
File without changes
|
package/src/eth/binds.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { BindOptions, getOptionsSignature } from '
|
|
2
|
-
import { ContractView } from '
|
|
1
|
+
import { BindOptions, getOptionsSignature } from './bind-options.js'
|
|
2
|
+
import { ContractView } from './context.js'
|
|
3
3
|
import { BaseProcessor } from './base-processor.js'
|
|
4
4
|
import { Networkish, Network } from 'ethers/providers'
|
|
5
5
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|