@sentio/sdk 2.3.6-rc.1 → 2.4.0
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/tests/aptos.test.js.map +1 -1
- package/lib/eth/account-processor.d.ts +2 -2
- package/lib/eth/account-processor.js +2 -2
- package/lib/eth/account-processor.js.map +1 -1
- package/lib/eth/builtin/eacaggregatorproxy.d.ts +2 -2
- package/lib/eth/builtin/eacaggregatorproxy.js +2 -2
- package/lib/eth/builtin/eacaggregatorproxy.js.map +1 -1
- package/lib/eth/builtin/erc1155.d.ts +2 -2
- package/lib/eth/builtin/erc1155.js +2 -2
- package/lib/eth/builtin/erc1155.js.map +1 -1
- package/lib/eth/builtin/erc20.d.ts +2 -2
- package/lib/eth/builtin/erc20.js +2 -2
- package/lib/eth/builtin/erc20.js.map +1 -1
- package/lib/eth/builtin/erc20bytes.d.ts +2 -2
- package/lib/eth/builtin/erc20bytes.js +2 -2
- package/lib/eth/builtin/erc20bytes.js.map +1 -1
- package/lib/eth/builtin/erc721.d.ts +2 -2
- package/lib/eth/builtin/erc721.js +2 -2
- package/lib/eth/builtin/erc721.js.map +1 -1
- package/lib/eth/builtin/internal/{eacaggregatorproxy_processor.d.ts → eacaggregatorproxy-processor.d.ts} +0 -0
- package/lib/eth/builtin/internal/{eacaggregatorproxy_processor.js → eacaggregatorproxy-processor.js} +1 -1
- package/lib/eth/builtin/internal/{eacaggregatorproxy_processor.js.map → eacaggregatorproxy-processor.js.map} +1 -1
- package/lib/eth/builtin/internal/{eacaggregatorproxy_test-utils.d.ts → eacaggregatorproxy-test-utils.d.ts} +0 -0
- package/lib/eth/builtin/internal/{eacaggregatorproxy_test-utils.js → eacaggregatorproxy-test-utils.js} +2 -2
- package/lib/eth/builtin/internal/{eacaggregatorproxy_test-utils.js.map → eacaggregatorproxy-test-utils.js.map} +1 -1
- package/lib/eth/builtin/internal/{erc1155_processor.d.ts → erc1155-processor.d.ts} +0 -0
- package/lib/eth/builtin/internal/{erc1155_processor.js → erc1155-processor.js} +1 -1
- package/lib/eth/builtin/internal/{erc1155_processor.js.map → erc1155-processor.js.map} +1 -1
- package/lib/eth/builtin/internal/{erc1155_test-utils.d.ts → erc1155-test-utils.d.ts} +0 -0
- package/lib/eth/builtin/internal/{erc1155_test-utils.js → erc1155-test-utils.js} +2 -2
- package/lib/eth/builtin/internal/{erc1155_test-utils.js.map → erc1155-test-utils.js.map} +1 -1
- package/lib/eth/builtin/internal/{erc20_processor.d.ts → erc20-processor.d.ts} +0 -0
- package/lib/eth/builtin/internal/{erc20_processor.js → erc20-processor.js} +1 -1
- package/lib/eth/builtin/internal/{erc20_processor.js.map → erc20-processor.js.map} +1 -1
- package/lib/eth/builtin/internal/{erc20_test-utils.d.ts → erc20-test-utils.d.ts} +0 -0
- package/lib/eth/builtin/internal/{erc20_test-utils.js → erc20-test-utils.js} +2 -2
- package/lib/eth/builtin/internal/{erc20_test-utils.js.map → erc20-test-utils.js.map} +1 -1
- package/lib/eth/builtin/internal/{erc20bytes_processor.d.ts → erc20bytes-processor.d.ts} +0 -0
- package/lib/eth/builtin/internal/{erc20bytes_processor.js → erc20bytes-processor.js} +1 -1
- package/lib/eth/builtin/internal/{erc20bytes_processor.js.map → erc20bytes-processor.js.map} +1 -1
- package/lib/eth/builtin/internal/{erc20bytes_test-utils.d.ts → erc20bytes-test-utils.d.ts} +0 -0
- package/lib/eth/builtin/internal/{erc20bytes_test-utils.js → erc20bytes-test-utils.js} +2 -2
- package/lib/eth/builtin/internal/{erc20bytes_test-utils.js.map → erc20bytes-test-utils.js.map} +1 -1
- package/lib/eth/builtin/internal/{erc721_processor.d.ts → erc721-processor.d.ts} +0 -0
- package/lib/eth/builtin/internal/{erc721_processor.js → erc721-processor.js} +1 -1
- package/lib/eth/builtin/internal/{erc721_processor.js.map → erc721-processor.js.map} +1 -1
- package/lib/eth/builtin/internal/{erc721_test-utils.d.ts → erc721-test-utils.d.ts} +0 -0
- package/lib/eth/builtin/internal/{erc721_test-utils.js → erc721-test-utils.js} +2 -2
- package/lib/eth/builtin/internal/{erc721_test-utils.js.map → erc721-test-utils.js.map} +1 -1
- package/lib/eth/builtin/internal/{weth9_processor.d.ts → weth9-processor.d.ts} +0 -0
- package/lib/eth/builtin/internal/{weth9_processor.js → weth9-processor.js} +1 -1
- package/lib/eth/builtin/internal/{weth9_processor.js.map → weth9-processor.js.map} +1 -1
- package/lib/eth/builtin/internal/{weth9_test-utils.d.ts → weth9-test-utils.d.ts} +0 -0
- package/lib/eth/builtin/internal/{weth9_test-utils.js → weth9-test-utils.js} +2 -2
- package/lib/eth/builtin/internal/{weth9_test-utils.js.map → weth9-test-utils.js.map} +1 -1
- package/lib/eth/builtin/weth9.d.ts +2 -2
- package/lib/eth/builtin/weth9.js +2 -2
- package/lib/eth/builtin/weth9.js.map +1 -1
- package/lib/eth/codegen/ethers-sentio.js +2 -2
- package/lib/eth/codegen/ethers-sentio.js.map +1 -1
- package/lib/eth/codegen/file.js +3 -3
- package/lib/eth/codegen/file.js.map +1 -1
- package/lib/eth/generic-processor.test.js.map +1 -1
- package/lib/eth/tests/account.test.d.ts +1 -0
- package/lib/eth/tests/account.test.js.map +1 -0
- package/lib/eth/tests/codegen.test.d.ts +1 -0
- package/lib/eth/tests/codegen.test.js.map +1 -0
- package/lib/eth/tests/erc20-template.test.d.ts +1 -0
- package/lib/eth/tests/erc20-template.test.js.map +1 -0
- package/lib/eth/tests/erc20.d.ts +1 -0
- package/lib/eth/tests/erc20.js +52 -0
- package/lib/eth/tests/erc20.js.map +1 -0
- package/lib/eth/tests/erc20.test.d.ts +1 -0
- package/lib/eth/tests/erc20.test.js.map +1 -0
- package/lib/eth/tests/error-capture.test.d.ts +1 -0
- package/lib/eth/tests/error-capture.test.js.map +1 -0
- package/lib/eth/tests/logger.test.d.ts +1 -0
- package/lib/eth/tests/logger.test.js.map +1 -0
- package/lib/eth/tests/types/anyswaprouter.d.ts +3 -0
- package/lib/eth/tests/types/anyswaprouter.js +7 -0
- package/lib/eth/tests/types/anyswaprouter.js.map +1 -0
- package/lib/eth/tests/types/commitmentpool.d.ts +3 -0
- package/lib/eth/tests/types/commitmentpool.js +7 -0
- package/lib/eth/tests/types/commitmentpool.js.map +1 -0
- package/lib/eth/tests/types/index.d.ts +12 -0
- package/lib/eth/tests/types/index.js +16 -0
- package/lib/eth/tests/types/index.js.map +1 -0
- package/lib/eth/tests/types/internal/AnyswapRouter.d.ts +122 -0
- package/lib/eth/tests/types/internal/AnyswapRouter.js +2 -0
- package/lib/eth/tests/types/internal/AnyswapRouter.js.map +1 -0
- package/lib/eth/tests/types/internal/CommitmentPool.d.ts +176 -0
- package/lib/eth/tests/types/internal/CommitmentPool.js +2 -0
- package/lib/eth/tests/types/internal/CommitmentPool.js.map +1 -0
- package/lib/eth/tests/types/internal/MembershipStakerV3.d.ts +81 -0
- package/lib/eth/tests/types/internal/MembershipStakerV3.js +2 -0
- package/lib/eth/tests/types/internal/MembershipStakerV3.js.map +1 -0
- package/lib/eth/tests/types/internal/Pyth.d.ts +204 -0
- package/lib/eth/tests/types/internal/Pyth.js +2 -0
- package/lib/eth/tests/types/internal/Pyth.js.map +1 -0
- package/lib/eth/tests/types/internal/Seaport.d.ts +350 -0
- package/lib/eth/tests/types/internal/Seaport.js +2 -0
- package/lib/eth/tests/types/internal/Seaport.js.map +1 -0
- package/lib/eth/tests/types/internal/TokenExchange.d.ts +128 -0
- package/lib/eth/tests/types/internal/TokenExchange.js +2 -0
- package/lib/eth/tests/types/internal/TokenExchange.js.map +1 -0
- package/lib/eth/tests/types/internal/anyswaprouter-processor.d.ts +463 -0
- package/lib/eth/tests/types/internal/anyswaprouter-processor.js +425 -0
- package/lib/eth/tests/types/internal/anyswaprouter-processor.js.map +1 -0
- package/lib/eth/tests/types/internal/anyswaprouter-test-utils.d.ts +9 -0
- package/lib/eth/tests/types/internal/anyswaprouter-test-utils.js +124 -0
- package/lib/eth/tests/types/internal/anyswaprouter-test-utils.js.map +1 -0
- package/lib/eth/tests/types/internal/commitmentpool-processor.d.ts +348 -0
- package/lib/eth/tests/types/internal/commitmentpool-processor.js +607 -0
- package/lib/eth/tests/types/internal/commitmentpool-processor.js.map +1 -0
- package/lib/eth/tests/types/internal/commitmentpool-test-utils.d.ts +9 -0
- package/lib/eth/tests/types/internal/commitmentpool-test-utils.js +87 -0
- package/lib/eth/tests/types/internal/commitmentpool-test-utils.js.map +1 -0
- package/lib/eth/tests/types/internal/common.d.ts +10 -0
- package/lib/eth/tests/types/internal/common.js +8 -0
- package/lib/eth/tests/types/internal/common.js.map +1 -0
- package/lib/eth/tests/types/internal/factories/AnyswapRouter__factory.d.ts +988 -0
- package/lib/eth/tests/types/internal/factories/AnyswapRouter__factory.js +1269 -0
- package/lib/eth/tests/types/internal/factories/AnyswapRouter__factory.js.map +1 -0
- package/lib/eth/tests/types/internal/factories/CommitmentPool__factory.d.ts +792 -0
- package/lib/eth/tests/types/internal/factories/CommitmentPool__factory.js +1040 -0
- package/lib/eth/tests/types/internal/factories/CommitmentPool__factory.js.map +1 -0
- package/lib/eth/tests/types/internal/factories/MembershipStakerV3__factory.d.ts +549 -0
- package/lib/eth/tests/types/internal/factories/MembershipStakerV3__factory.js +721 -0
- package/lib/eth/tests/types/internal/factories/MembershipStakerV3__factory.js.map +1 -0
- package/lib/eth/tests/types/internal/factories/Pyth__factory.d.ts +1130 -0
- package/lib/eth/tests/types/internal/factories/Pyth__factory.js +1486 -0
- package/lib/eth/tests/types/internal/factories/Pyth__factory.js.map +1 -0
- package/lib/eth/tests/types/internal/factories/Seaport__factory.d.ts +2018 -0
- package/lib/eth/tests/types/internal/factories/Seaport__factory.js +2610 -0
- package/lib/eth/tests/types/internal/factories/Seaport__factory.js.map +1 -0
- package/lib/eth/tests/types/internal/factories/TokenExchange__factory.d.ts +651 -0
- package/lib/eth/tests/types/internal/factories/TokenExchange__factory.js +853 -0
- package/lib/eth/tests/types/internal/factories/TokenExchange__factory.js.map +1 -0
- package/lib/eth/tests/types/internal/factories/index.d.ts +6 -0
- package/lib/eth/tests/types/internal/factories/index.js +10 -0
- package/lib/eth/tests/types/internal/factories/index.js.map +1 -0
- package/lib/eth/tests/types/internal/index.d.ts +13 -0
- package/lib/eth/tests/types/internal/index.js +8 -0
- package/lib/eth/tests/types/internal/index.js.map +1 -0
- package/lib/eth/tests/types/internal/membershipstakerv3-processor.d.ts +287 -0
- package/lib/eth/tests/types/internal/membershipstakerv3-processor.js +596 -0
- package/lib/eth/tests/types/internal/membershipstakerv3-processor.js.map +1 -0
- package/lib/eth/tests/types/internal/membershipstakerv3-test-utils.d.ts +11 -0
- package/lib/eth/tests/types/internal/membershipstakerv3-test-utils.js +109 -0
- package/lib/eth/tests/types/internal/membershipstakerv3-test-utils.js.map +1 -0
- package/lib/eth/tests/types/internal/pyth-processor.d.ts +422 -0
- package/lib/eth/tests/types/internal/pyth-processor.js +890 -0
- package/lib/eth/tests/types/internal/pyth-processor.js.map +1 -0
- package/lib/eth/tests/types/internal/pyth-test-utils.d.ts +13 -0
- package/lib/eth/tests/types/internal/pyth-test-utils.js +131 -0
- package/lib/eth/tests/types/internal/pyth-test-utils.js.map +1 -0
- package/lib/eth/tests/types/internal/seaport-processor.d.ts +211 -0
- package/lib/eth/tests/types/internal/seaport-processor.js +237 -0
- package/lib/eth/tests/types/internal/seaport-processor.js.map +1 -0
- package/lib/eth/tests/types/internal/seaport-test-utils.d.ts +6 -0
- package/lib/eth/tests/types/internal/seaport-test-utils.js +61 -0
- package/lib/eth/tests/types/internal/seaport-test-utils.js.map +1 -0
- package/lib/eth/tests/types/internal/tokenexchange-processor.d.ts +334 -0
- package/lib/eth/tests/types/internal/tokenexchange-processor.js +667 -0
- package/lib/eth/tests/types/internal/tokenexchange-processor.js.map +1 -0
- package/lib/eth/tests/types/internal/tokenexchange-test-utils.d.ts +13 -0
- package/lib/eth/tests/types/internal/tokenexchange-test-utils.js +149 -0
- package/lib/eth/tests/types/internal/tokenexchange-test-utils.js.map +1 -0
- package/lib/eth/tests/types/membershipstakerv3.d.ts +3 -0
- package/lib/eth/tests/types/membershipstakerv3.js +7 -0
- package/lib/eth/tests/types/membershipstakerv3.js.map +1 -0
- package/lib/eth/tests/types/pyth.d.ts +3 -0
- package/lib/eth/tests/types/pyth.js +7 -0
- package/lib/eth/tests/types/pyth.js.map +1 -0
- package/lib/eth/tests/types/seaport.d.ts +3 -0
- package/lib/eth/tests/types/seaport.js +7 -0
- package/lib/eth/tests/types/seaport.js.map +1 -0
- package/lib/eth/tests/types/tokenexchange.d.ts +3 -0
- package/lib/eth/tests/types/tokenexchange.js +7 -0
- package/lib/eth/tests/types/tokenexchange.js.map +1 -0
- package/lib/solana/builtin/types.d.ts +8 -8
- package/lib/solana/tests/solana.test.js.map +1 -1
- package/lib/sui/sui-processor.js +2 -8
- package/lib/sui/sui-processor.js.map +1 -1
- package/lib/sui/tests/sui.test.js.map +1 -1
- package/lib/sui/utils.d.ts +2 -0
- package/lib/sui/utils.js +11 -0
- package/lib/sui/utils.js.map +1 -0
- package/lib/testing/aptos-facet.d.ts +12 -0
- package/lib/testing/aptos-facet.js +91 -0
- package/lib/testing/aptos-facet.js.map +1 -0
- package/lib/testing/eth-facet.d.ts +27 -0
- package/lib/testing/eth-facet.js +211 -0
- package/lib/testing/eth-facet.js.map +1 -0
- package/lib/testing/solana-facet.d.ts +7 -0
- package/lib/testing/solana-facet.js +22 -0
- package/lib/testing/solana-facet.js.map +1 -0
- package/lib/testing/sui-facet.d.ts +12 -0
- package/lib/testing/sui-facet.js +103 -0
- package/lib/testing/sui-facet.js.map +1 -0
- package/lib/testing/test-processor-server.d.ts +9 -23
- package/lib/testing/test-processor-server.js +13 -227
- package/lib/testing/test-processor-server.js.map +1 -1
- package/lib/utils/dex-price.js +1 -1
- package/lib/utils/dex-price.js.map +1 -1
- package/lib/utils/token.js +1 -1
- package/lib/utils/token.js.map +1 -1
- package/package.json +5 -5
- package/src/eth/account-processor.ts +2 -5
- package/src/eth/builtin/eacaggregatorproxy.ts +2 -2
- package/src/eth/builtin/erc1155.ts +2 -2
- package/src/eth/builtin/erc20.ts +2 -2
- package/src/eth/builtin/erc20bytes.ts +2 -2
- package/src/eth/builtin/erc721.ts +2 -2
- package/src/eth/builtin/internal/{eacaggregatorproxy_processor.ts → eacaggregatorproxy-processor.ts} +0 -0
- package/src/eth/builtin/internal/{eacaggregatorproxy_test-utils.ts → eacaggregatorproxy-test-utils.ts} +1 -1
- package/src/eth/builtin/internal/{erc1155_processor.ts → erc1155-processor.ts} +0 -0
- package/src/eth/builtin/internal/{erc1155_test-utils.ts → erc1155-test-utils.ts} +1 -1
- package/src/eth/builtin/internal/{erc20_processor.ts → erc20-processor.ts} +0 -0
- package/src/eth/builtin/internal/{erc20_test-utils.ts → erc20-test-utils.ts} +1 -1
- package/src/eth/builtin/internal/{erc20bytes_processor.ts → erc20bytes-processor.ts} +0 -0
- package/src/eth/builtin/internal/{erc20bytes_test-utils.ts → erc20bytes-test-utils.ts} +1 -1
- package/src/eth/builtin/internal/{erc721_processor.ts → erc721-processor.ts} +0 -0
- package/src/eth/builtin/internal/{erc721_test-utils.ts → erc721-test-utils.ts} +1 -1
- package/src/eth/builtin/internal/{weth9_processor.ts → weth9-processor.ts} +0 -0
- package/src/eth/builtin/internal/{weth9_test-utils.ts → weth9-test-utils.ts} +1 -1
- package/src/eth/builtin/weth9.ts +2 -2
- package/src/eth/codegen/ethers-sentio.ts +2 -2
- package/src/eth/codegen/file.ts +3 -3
- package/src/eth/tests/abis/eth/CommitmentPool.json +1034 -0
- package/src/eth/tests/abis/eth/MembershipStakerV3.json +706 -0
- package/src/eth/tests/abis/eth/Pyth.json +1471 -0
- package/src/eth/tests/abis/eth/Seaport.json +2595 -0
- package/src/eth/tests/abis/eth/TokenExchange.json +838 -0
- package/src/eth/tests/abis/eth/anyswapRouter.json +490 -0
- package/src/eth/tests/erc20.ts +63 -0
- package/src/eth/tests/types/anyswaprouter.ts +7 -0
- package/src/eth/tests/types/commitmentpool.ts +7 -0
- package/src/eth/tests/types/index.ts +33 -0
- package/src/eth/tests/types/internal/AnyswapRouter.ts +122 -0
- package/src/eth/tests/types/internal/CommitmentPool.ts +208 -0
- package/src/eth/tests/types/internal/MembershipStakerV3.ts +108 -0
- package/src/eth/tests/types/internal/Pyth.ts +246 -0
- package/src/eth/tests/types/internal/Seaport.ts +389 -0
- package/src/eth/tests/types/internal/TokenExchange.ts +142 -0
- package/src/eth/tests/types/internal/anyswaprouter-processor.ts +1396 -0
- package/src/eth/tests/types/internal/anyswaprouter-test-utils.ts +187 -0
- package/src/eth/tests/types/internal/commitmentpool-processor.ts +1575 -0
- package/src/eth/tests/types/internal/commitmentpool-test-utils.ts +150 -0
- package/src/eth/tests/types/internal/common.ts +23 -0
- package/src/eth/tests/types/internal/factories/AnyswapRouter__factory.ts +1278 -0
- package/src/eth/tests/types/internal/factories/CommitmentPool__factory.ts +1049 -0
- package/src/eth/tests/types/internal/factories/MembershipStakerV3__factory.ts +730 -0
- package/src/eth/tests/types/internal/factories/Pyth__factory.ts +1492 -0
- package/src/eth/tests/types/internal/factories/Seaport__factory.ts +2616 -0
- package/src/eth/tests/types/internal/factories/TokenExchange__factory.ts +862 -0
- package/src/eth/tests/types/internal/factories/index.ts +9 -0
- package/src/eth/tests/types/internal/index.ts +16 -0
- package/src/eth/tests/types/internal/membershipstakerv3-processor.ts +1399 -0
- package/src/eth/tests/types/internal/membershipstakerv3-test-utils.ts +188 -0
- package/src/eth/tests/types/internal/pyth-processor.ts +2043 -0
- package/src/eth/tests/types/internal/pyth-test-utils.ts +226 -0
- package/src/eth/tests/types/internal/seaport-processor.ts +678 -0
- package/src/eth/tests/types/internal/seaport-test-utils.ts +100 -0
- package/src/eth/tests/types/internal/tokenexchange-processor.ts +1570 -0
- package/src/eth/tests/types/internal/tokenexchange-test-utils.ts +244 -0
- package/src/eth/tests/types/membershipstakerv3.ts +7 -0
- package/src/eth/tests/types/pyth.ts +7 -0
- package/src/eth/tests/types/seaport.ts +7 -0
- package/src/eth/tests/types/tokenexchange.ts +7 -0
- package/src/sui/sui-processor.ts +2 -7
- package/src/sui/utils.ts +11 -0
- package/src/testing/aptos-facet.ts +111 -0
- package/src/testing/eth-facet.ts +233 -0
- package/src/testing/solana-facet.ts +25 -0
- package/src/testing/sui-facet.ts +119 -0
- package/src/testing/test-processor-server.ts +15 -252
- package/src/utils/dex-price.ts +1 -1
- package/src/utils/token.ts +1 -3
|
@@ -0,0 +1,244 @@
|
|
|
1
|
+
/* Autogenerated file. Do not edit manually. */
|
|
2
|
+
/* tslint:disable */
|
|
3
|
+
/* eslint-disable */
|
|
4
|
+
import { LogParams } from "ethers/providers";
|
|
5
|
+
import {
|
|
6
|
+
TokenExchangeEventObject,
|
|
7
|
+
AddLiquidityEventObject,
|
|
8
|
+
RemoveLiquidityEventObject,
|
|
9
|
+
RemoveLiquidityOneEventObject,
|
|
10
|
+
RemoveLiquidityImbalanceEventObject,
|
|
11
|
+
CommitNewAdminEventObject,
|
|
12
|
+
NewAdminEventObject,
|
|
13
|
+
CommitNewFeeEventObject,
|
|
14
|
+
NewFeeEventObject,
|
|
15
|
+
RampAEventObject,
|
|
16
|
+
StopRampAEventObject,
|
|
17
|
+
} from "./TokenExchange.js";
|
|
18
|
+
import { getTokenExchangeContract } from "./tokenexchange-processor.js";
|
|
19
|
+
const mockField = {
|
|
20
|
+
blockHash:
|
|
21
|
+
"0x0000000000000000000000000000000000000000000000000000000000000000",
|
|
22
|
+
blockNumber: 0,
|
|
23
|
+
logIndex: 0,
|
|
24
|
+
removed: false,
|
|
25
|
+
transactionHash:
|
|
26
|
+
"0x0000000000000000000000000000000000000000000000000000000000000000",
|
|
27
|
+
transactionIndex: 0,
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
export function mockTokenExchangeLog(
|
|
31
|
+
contractAddress: string,
|
|
32
|
+
event: TokenExchangeEventObject
|
|
33
|
+
): LogParams {
|
|
34
|
+
const contract = getTokenExchangeContract(contractAddress);
|
|
35
|
+
const encodedLog = contract.rawContract.interface.encodeEventLog(
|
|
36
|
+
"TokenExchange(address,int128,uint256,int128,uint256)",
|
|
37
|
+
[
|
|
38
|
+
event.buyer,
|
|
39
|
+
event.sold_id,
|
|
40
|
+
event.tokens_sold,
|
|
41
|
+
event.bought_id,
|
|
42
|
+
event.tokens_bought,
|
|
43
|
+
]
|
|
44
|
+
);
|
|
45
|
+
return {
|
|
46
|
+
...mockField,
|
|
47
|
+
index: 0,
|
|
48
|
+
address: contractAddress,
|
|
49
|
+
data: encodedLog.data,
|
|
50
|
+
topics: encodedLog.topics,
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export function mockAddLiquidityLog(
|
|
55
|
+
contractAddress: string,
|
|
56
|
+
event: AddLiquidityEventObject
|
|
57
|
+
): LogParams {
|
|
58
|
+
const contract = getTokenExchangeContract(contractAddress);
|
|
59
|
+
const encodedLog = contract.rawContract.interface.encodeEventLog(
|
|
60
|
+
"AddLiquidity(address,uint256[3],uint256[3],uint256,uint256)",
|
|
61
|
+
[
|
|
62
|
+
event.provider,
|
|
63
|
+
event.token_amounts,
|
|
64
|
+
event.fees,
|
|
65
|
+
event.invariant,
|
|
66
|
+
event.token_supply,
|
|
67
|
+
]
|
|
68
|
+
);
|
|
69
|
+
return {
|
|
70
|
+
...mockField,
|
|
71
|
+
index: 0,
|
|
72
|
+
address: contractAddress,
|
|
73
|
+
data: encodedLog.data,
|
|
74
|
+
topics: encodedLog.topics,
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export function mockRemoveLiquidityLog(
|
|
79
|
+
contractAddress: string,
|
|
80
|
+
event: RemoveLiquidityEventObject
|
|
81
|
+
): LogParams {
|
|
82
|
+
const contract = getTokenExchangeContract(contractAddress);
|
|
83
|
+
const encodedLog = contract.rawContract.interface.encodeEventLog(
|
|
84
|
+
"RemoveLiquidity(address,uint256[3],uint256[3],uint256)",
|
|
85
|
+
[event.provider, event.token_amounts, event.fees, event.token_supply]
|
|
86
|
+
);
|
|
87
|
+
return {
|
|
88
|
+
...mockField,
|
|
89
|
+
index: 0,
|
|
90
|
+
address: contractAddress,
|
|
91
|
+
data: encodedLog.data,
|
|
92
|
+
topics: encodedLog.topics,
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
export function mockRemoveLiquidityOneLog(
|
|
97
|
+
contractAddress: string,
|
|
98
|
+
event: RemoveLiquidityOneEventObject
|
|
99
|
+
): LogParams {
|
|
100
|
+
const contract = getTokenExchangeContract(contractAddress);
|
|
101
|
+
const encodedLog = contract.rawContract.interface.encodeEventLog(
|
|
102
|
+
"RemoveLiquidityOne(address,uint256,uint256)",
|
|
103
|
+
[event.provider, event.token_amount, event.coin_amount]
|
|
104
|
+
);
|
|
105
|
+
return {
|
|
106
|
+
...mockField,
|
|
107
|
+
index: 0,
|
|
108
|
+
address: contractAddress,
|
|
109
|
+
data: encodedLog.data,
|
|
110
|
+
topics: encodedLog.topics,
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
export function mockRemoveLiquidityImbalanceLog(
|
|
115
|
+
contractAddress: string,
|
|
116
|
+
event: RemoveLiquidityImbalanceEventObject
|
|
117
|
+
): LogParams {
|
|
118
|
+
const contract = getTokenExchangeContract(contractAddress);
|
|
119
|
+
const encodedLog = contract.rawContract.interface.encodeEventLog(
|
|
120
|
+
"RemoveLiquidityImbalance(address,uint256[3],uint256[3],uint256,uint256)",
|
|
121
|
+
[
|
|
122
|
+
event.provider,
|
|
123
|
+
event.token_amounts,
|
|
124
|
+
event.fees,
|
|
125
|
+
event.invariant,
|
|
126
|
+
event.token_supply,
|
|
127
|
+
]
|
|
128
|
+
);
|
|
129
|
+
return {
|
|
130
|
+
...mockField,
|
|
131
|
+
index: 0,
|
|
132
|
+
address: contractAddress,
|
|
133
|
+
data: encodedLog.data,
|
|
134
|
+
topics: encodedLog.topics,
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
export function mockCommitNewAdminLog(
|
|
139
|
+
contractAddress: string,
|
|
140
|
+
event: CommitNewAdminEventObject
|
|
141
|
+
): LogParams {
|
|
142
|
+
const contract = getTokenExchangeContract(contractAddress);
|
|
143
|
+
const encodedLog = contract.rawContract.interface.encodeEventLog(
|
|
144
|
+
"CommitNewAdmin(uint256,address)",
|
|
145
|
+
[event.deadline, event.admin]
|
|
146
|
+
);
|
|
147
|
+
return {
|
|
148
|
+
...mockField,
|
|
149
|
+
index: 0,
|
|
150
|
+
address: contractAddress,
|
|
151
|
+
data: encodedLog.data,
|
|
152
|
+
topics: encodedLog.topics,
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
export function mockNewAdminLog(
|
|
157
|
+
contractAddress: string,
|
|
158
|
+
event: NewAdminEventObject
|
|
159
|
+
): LogParams {
|
|
160
|
+
const contract = getTokenExchangeContract(contractAddress);
|
|
161
|
+
const encodedLog = contract.rawContract.interface.encodeEventLog(
|
|
162
|
+
"NewAdmin(address)",
|
|
163
|
+
[event.admin]
|
|
164
|
+
);
|
|
165
|
+
return {
|
|
166
|
+
...mockField,
|
|
167
|
+
index: 0,
|
|
168
|
+
address: contractAddress,
|
|
169
|
+
data: encodedLog.data,
|
|
170
|
+
topics: encodedLog.topics,
|
|
171
|
+
};
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
export function mockCommitNewFeeLog(
|
|
175
|
+
contractAddress: string,
|
|
176
|
+
event: CommitNewFeeEventObject
|
|
177
|
+
): LogParams {
|
|
178
|
+
const contract = getTokenExchangeContract(contractAddress);
|
|
179
|
+
const encodedLog = contract.rawContract.interface.encodeEventLog(
|
|
180
|
+
"CommitNewFee(uint256,uint256,uint256)",
|
|
181
|
+
[event.deadline, event.fee, event.admin_fee]
|
|
182
|
+
);
|
|
183
|
+
return {
|
|
184
|
+
...mockField,
|
|
185
|
+
index: 0,
|
|
186
|
+
address: contractAddress,
|
|
187
|
+
data: encodedLog.data,
|
|
188
|
+
topics: encodedLog.topics,
|
|
189
|
+
};
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
export function mockNewFeeLog(
|
|
193
|
+
contractAddress: string,
|
|
194
|
+
event: NewFeeEventObject
|
|
195
|
+
): LogParams {
|
|
196
|
+
const contract = getTokenExchangeContract(contractAddress);
|
|
197
|
+
const encodedLog = contract.rawContract.interface.encodeEventLog(
|
|
198
|
+
"NewFee(uint256,uint256)",
|
|
199
|
+
[event.fee, event.admin_fee]
|
|
200
|
+
);
|
|
201
|
+
return {
|
|
202
|
+
...mockField,
|
|
203
|
+
index: 0,
|
|
204
|
+
address: contractAddress,
|
|
205
|
+
data: encodedLog.data,
|
|
206
|
+
topics: encodedLog.topics,
|
|
207
|
+
};
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
export function mockRampALog(
|
|
211
|
+
contractAddress: string,
|
|
212
|
+
event: RampAEventObject
|
|
213
|
+
): LogParams {
|
|
214
|
+
const contract = getTokenExchangeContract(contractAddress);
|
|
215
|
+
const encodedLog = contract.rawContract.interface.encodeEventLog(
|
|
216
|
+
"RampA(uint256,uint256,uint256,uint256)",
|
|
217
|
+
[event.old_A, event.new_A, event.initial_time, event.future_time]
|
|
218
|
+
);
|
|
219
|
+
return {
|
|
220
|
+
...mockField,
|
|
221
|
+
index: 0,
|
|
222
|
+
address: contractAddress,
|
|
223
|
+
data: encodedLog.data,
|
|
224
|
+
topics: encodedLog.topics,
|
|
225
|
+
};
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
export function mockStopRampALog(
|
|
229
|
+
contractAddress: string,
|
|
230
|
+
event: StopRampAEventObject
|
|
231
|
+
): LogParams {
|
|
232
|
+
const contract = getTokenExchangeContract(contractAddress);
|
|
233
|
+
const encodedLog = contract.rawContract.interface.encodeEventLog(
|
|
234
|
+
"StopRampA(uint256,uint256)",
|
|
235
|
+
[event.A, event.t]
|
|
236
|
+
);
|
|
237
|
+
return {
|
|
238
|
+
...mockField,
|
|
239
|
+
index: 0,
|
|
240
|
+
address: contractAddress,
|
|
241
|
+
data: encodedLog.data,
|
|
242
|
+
topics: encodedLog.topics,
|
|
243
|
+
};
|
|
244
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/* Autogenerated file. Do not edit manually. */
|
|
2
|
+
/* tslint:disable */
|
|
3
|
+
/* eslint-disable */
|
|
4
|
+
|
|
5
|
+
export * from "./internal/membershipstakerv3-processor.js";
|
|
6
|
+
export * from "./internal/MembershipStakerV3.js";
|
|
7
|
+
export * from "./internal/membershipstakerv3-test-utils.js";
|
package/src/sui/sui-processor.ts
CHANGED
|
@@ -5,6 +5,7 @@ import { ServerError, Status } from 'nice-grpc'
|
|
|
5
5
|
import { SuiContext } from './context.js'
|
|
6
6
|
import { MoveEvent, SuiTransactionResponse, getMoveCallTransaction, MoveCall } from '@mysten/sui.js'
|
|
7
7
|
import { CallHandler, EventFilter, EventHandler, FunctionNameAndCallFilter } from '../move/index.js'
|
|
8
|
+
import { getMoveCalls } from './utils.js'
|
|
8
9
|
|
|
9
10
|
class IndexConfigure {
|
|
10
11
|
address: string
|
|
@@ -129,13 +130,7 @@ export class SuiBaseProcessor {
|
|
|
129
130
|
tx
|
|
130
131
|
)
|
|
131
132
|
if (tx) {
|
|
132
|
-
const calls: MoveCall[] =
|
|
133
|
-
const call = getMoveCallTransaction(tx)
|
|
134
|
-
if (call) {
|
|
135
|
-
return [call]
|
|
136
|
-
}
|
|
137
|
-
return []
|
|
138
|
-
})
|
|
133
|
+
const calls: MoveCall[] = getMoveCalls(tx)
|
|
139
134
|
if (calls.length !== 1) {
|
|
140
135
|
throw new ServerError(Status.INVALID_ARGUMENT, 'Unexpected number of call transactions ' + calls.length)
|
|
141
136
|
}
|
package/src/sui/utils.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { SuiTransactionResponse, getMoveCallTransaction, MoveCall } from '@mysten/sui.js'
|
|
2
|
+
|
|
3
|
+
export function getMoveCalls(tx: SuiTransactionResponse) {
|
|
4
|
+
return tx.certificate.data.transactions.flatMap((tx) => {
|
|
5
|
+
const call = getMoveCallTransaction(tx)
|
|
6
|
+
if (call) {
|
|
7
|
+
return [call]
|
|
8
|
+
}
|
|
9
|
+
return []
|
|
10
|
+
})
|
|
11
|
+
}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { Transaction_UserTransaction, TransactionPayload_EntryFunctionPayload } from '../aptos/index.js'
|
|
2
|
+
import { DataBinding, HandlerType } from '@sentio/protos'
|
|
3
|
+
import { getChainId } from '../aptos/network.js'
|
|
4
|
+
import { TestProcessorServer } from './test-processor-server.js'
|
|
5
|
+
import { AptosNetwork, Event } from '@sentio/sdk/aptos'
|
|
6
|
+
import { parseMoveType } from '../aptos/types.js'
|
|
7
|
+
|
|
8
|
+
export class AptosFacet {
|
|
9
|
+
server: TestProcessorServer
|
|
10
|
+
constructor(server: TestProcessorServer) {
|
|
11
|
+
this.server = server
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
testEntryFunctionCall(transaction: Transaction_UserTransaction, network: AptosNetwork = AptosNetwork.MAIN_NET) {
|
|
15
|
+
return this.testEntryFunctionCalls([transaction], network)
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
testEntryFunctionCalls(transactions: Transaction_UserTransaction[], network: AptosNetwork = AptosNetwork.MAIN_NET) {
|
|
19
|
+
const bindings = []
|
|
20
|
+
for (const trans of transactions) {
|
|
21
|
+
const binding = this.buildEntryFunctionCallBinding(trans, network)
|
|
22
|
+
if (!binding) {
|
|
23
|
+
throw Error('Invalid test transaction: ' + JSON.stringify(trans))
|
|
24
|
+
}
|
|
25
|
+
bindings.push(binding)
|
|
26
|
+
}
|
|
27
|
+
return this.server.processBindings({
|
|
28
|
+
bindings: bindings,
|
|
29
|
+
})
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
private buildEntryFunctionCallBinding(
|
|
33
|
+
transaction: Transaction_UserTransaction,
|
|
34
|
+
network: AptosNetwork = AptosNetwork.MAIN_NET
|
|
35
|
+
): DataBinding | undefined {
|
|
36
|
+
const payload = transaction.payload as TransactionPayload_EntryFunctionPayload
|
|
37
|
+
for (const config of this.server.contractConfigs) {
|
|
38
|
+
if (config.contract?.chainId !== getChainId(network)) {
|
|
39
|
+
continue
|
|
40
|
+
}
|
|
41
|
+
for (const callConfig of config.moveCallConfigs) {
|
|
42
|
+
for (const callFilter of callConfig.filters) {
|
|
43
|
+
if (config.contract.address + '::' + callFilter.function === payload.function) {
|
|
44
|
+
return {
|
|
45
|
+
data: {
|
|
46
|
+
aptCall: {
|
|
47
|
+
transaction,
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
handlerIds: [callConfig.handlerId],
|
|
51
|
+
handlerType: HandlerType.APT_CALL,
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
return undefined
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
testEvent(
|
|
61
|
+
transaction: Transaction_UserTransaction,
|
|
62
|
+
event: number | Event,
|
|
63
|
+
network: AptosNetwork = AptosNetwork.MAIN_NET
|
|
64
|
+
) {
|
|
65
|
+
if (typeof event !== 'number') {
|
|
66
|
+
const transaction2: Transaction_UserTransaction = {} as any
|
|
67
|
+
Object.assign(transaction2, transaction)
|
|
68
|
+
transaction = transaction2
|
|
69
|
+
transaction.events = [event]
|
|
70
|
+
event = 0
|
|
71
|
+
}
|
|
72
|
+
const binding = this.buildEventBinding(transaction, event, network)
|
|
73
|
+
if (!binding) {
|
|
74
|
+
throw Error('Invalid test event: ' + JSON.stringify(transaction))
|
|
75
|
+
}
|
|
76
|
+
return this.server.processBinding(binding)
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
private buildEventBinding(
|
|
80
|
+
transaction: Transaction_UserTransaction,
|
|
81
|
+
eventIdx: number,
|
|
82
|
+
network: AptosNetwork = AptosNetwork.MAIN_NET
|
|
83
|
+
): DataBinding | undefined {
|
|
84
|
+
// const allEvents = new Set(transaction.events.map(e => e.type))
|
|
85
|
+
for (const config of this.server.contractConfigs) {
|
|
86
|
+
if (config.contract?.chainId !== getChainId(network)) {
|
|
87
|
+
continue
|
|
88
|
+
}
|
|
89
|
+
for (const eventConfig of config.moveEventConfigs) {
|
|
90
|
+
for (const eventFilter of eventConfig.filters) {
|
|
91
|
+
if (
|
|
92
|
+
config.contract.address + '::' + eventFilter.type ===
|
|
93
|
+
parseMoveType(transaction.events[eventIdx].type).qname
|
|
94
|
+
) {
|
|
95
|
+
transaction.events = [transaction.events[eventIdx]]
|
|
96
|
+
return {
|
|
97
|
+
data: {
|
|
98
|
+
aptEvent: {
|
|
99
|
+
transaction,
|
|
100
|
+
},
|
|
101
|
+
},
|
|
102
|
+
handlerIds: [eventConfig.handlerId],
|
|
103
|
+
handlerType: HandlerType.APT_EVENT,
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
return undefined
|
|
110
|
+
}
|
|
111
|
+
}
|
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
import { TestProcessorServer } from './test-processor-server.js'
|
|
2
|
+
import { DataBinding, HandlerType, ProcessBindingResponse } from '@sentio/protos'
|
|
3
|
+
import { Trace } from '../eth/trace.js'
|
|
4
|
+
import { BlockParams, LogParams, Network, Networkish } from 'ethers/providers'
|
|
5
|
+
import { Block } from 'ethers'
|
|
6
|
+
|
|
7
|
+
export class EthFacet {
|
|
8
|
+
server: TestProcessorServer
|
|
9
|
+
|
|
10
|
+
constructor(server: TestProcessorServer) {
|
|
11
|
+
this.server = server
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
testTrace(trace: Trace, network: Networkish = 1): Promise<ProcessBindingResponse> {
|
|
15
|
+
return this.testTraces([trace], network)
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
testTraces(traces: Trace[], network: Networkish = 1): Promise<ProcessBindingResponse> {
|
|
19
|
+
const bindings = []
|
|
20
|
+
for (const trace of traces) {
|
|
21
|
+
const binding = this.buildTraceBinding(trace, network)
|
|
22
|
+
if (!binding) {
|
|
23
|
+
throw Error('Invalid test trace: ' + JSON.stringify(trace))
|
|
24
|
+
}
|
|
25
|
+
bindings.push(binding)
|
|
26
|
+
}
|
|
27
|
+
return this.server.processBindings({
|
|
28
|
+
bindings: bindings,
|
|
29
|
+
})
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
buildTraceBinding(trace: Trace, network: Networkish = 1): DataBinding | undefined {
|
|
33
|
+
if (trace.type !== 'call' || !trace.action.input) {
|
|
34
|
+
throw Error('Invalid test trace: ' + JSON.stringify(trace))
|
|
35
|
+
}
|
|
36
|
+
const signature = trace.action.input.slice(0, 10)
|
|
37
|
+
|
|
38
|
+
for (const contract of this.server.contractConfigs) {
|
|
39
|
+
if (contract.contract?.chainId !== Network.from(network).chainId.toString()) {
|
|
40
|
+
continue
|
|
41
|
+
}
|
|
42
|
+
if (trace.action.to?.toLowerCase() !== contract.contract?.address.toLowerCase()) {
|
|
43
|
+
continue
|
|
44
|
+
}
|
|
45
|
+
for (const config of contract.traceConfigs) {
|
|
46
|
+
if (config.signature == signature) {
|
|
47
|
+
return {
|
|
48
|
+
data: {
|
|
49
|
+
ethTrace: {
|
|
50
|
+
trace,
|
|
51
|
+
timestamp: new Date(),
|
|
52
|
+
},
|
|
53
|
+
},
|
|
54
|
+
handlerIds: [config.handlerId],
|
|
55
|
+
handlerType: HandlerType.ETH_TRACE,
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
return undefined
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
testLog(log: LogParams, network: Networkish = 1): Promise<ProcessBindingResponse> {
|
|
64
|
+
return this.testLogs([log], network)
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
testLogs(logs: LogParams[], network: Networkish = 1): Promise<ProcessBindingResponse> {
|
|
68
|
+
const bindings = []
|
|
69
|
+
for (const log of logs) {
|
|
70
|
+
const binding = this.buildLogBinding(log, network)
|
|
71
|
+
if (!binding) {
|
|
72
|
+
throw Error('Invalid test log: ' + JSON.stringify(log))
|
|
73
|
+
}
|
|
74
|
+
bindings.push(binding)
|
|
75
|
+
}
|
|
76
|
+
return this.server.processBindings({
|
|
77
|
+
bindings: bindings,
|
|
78
|
+
})
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
buildLogBinding(log: LogParams, network: Networkish = 1): DataBinding | undefined {
|
|
82
|
+
for (const contract of this.server.contractConfigs) {
|
|
83
|
+
if (contract.contract?.chainId !== Network.from(network).chainId.toString()) {
|
|
84
|
+
continue
|
|
85
|
+
}
|
|
86
|
+
if (log.address.toLowerCase() !== contract.contract?.address.toLowerCase()) {
|
|
87
|
+
continue
|
|
88
|
+
}
|
|
89
|
+
for (const config of contract.logConfigs) {
|
|
90
|
+
for (const filter of config.filters) {
|
|
91
|
+
// if (filter.topics.length != log.topics.length) {
|
|
92
|
+
// continue
|
|
93
|
+
// }
|
|
94
|
+
|
|
95
|
+
let match = true
|
|
96
|
+
for (const topicIdx in filter.topics) {
|
|
97
|
+
const logTopic = log.topics[topicIdx]
|
|
98
|
+
const possibleTopic = filter.topics[topicIdx].hashes
|
|
99
|
+
if (possibleTopic.length === 0) {
|
|
100
|
+
// match all
|
|
101
|
+
continue
|
|
102
|
+
}
|
|
103
|
+
if (possibleTopic.find((e) => e.toLowerCase() === logTopic.toLowerCase())) {
|
|
104
|
+
// find one
|
|
105
|
+
continue
|
|
106
|
+
}
|
|
107
|
+
match = false
|
|
108
|
+
break
|
|
109
|
+
}
|
|
110
|
+
if (match) {
|
|
111
|
+
return {
|
|
112
|
+
data: {
|
|
113
|
+
ethLog: { log, timestamp: new Date() },
|
|
114
|
+
},
|
|
115
|
+
handlerIds: [config.handlerId],
|
|
116
|
+
handlerType: HandlerType.ETH_LOG,
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
return undefined
|
|
123
|
+
}
|
|
124
|
+
testAccountLog(address: string, log: LogParams, network: Networkish = 1): Promise<ProcessBindingResponse> {
|
|
125
|
+
return this.testAccountLogs(address, [log], network)
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
testAccountLogs(address: string, logs: LogParams[], network: Networkish = 1): Promise<ProcessBindingResponse> {
|
|
129
|
+
const bindings = []
|
|
130
|
+
for (const log of logs) {
|
|
131
|
+
const binding = this.buildAccountLogBinding(address, log, network)
|
|
132
|
+
if (!binding) {
|
|
133
|
+
throw Error('Invalid test log: ' + JSON.stringify(log))
|
|
134
|
+
}
|
|
135
|
+
bindings.push(binding)
|
|
136
|
+
}
|
|
137
|
+
return this.server.processBindings({
|
|
138
|
+
bindings: bindings,
|
|
139
|
+
})
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
buildAccountLogBinding(address: string, log: LogParams, network: Networkish = 1): DataBinding | undefined {
|
|
143
|
+
for (const account of this.server.accountConfigs) {
|
|
144
|
+
if (account.chainId !== Network.from(network).chainId.toString()) {
|
|
145
|
+
continue
|
|
146
|
+
}
|
|
147
|
+
if (address.toLowerCase() !== account.address.toLowerCase()) {
|
|
148
|
+
continue
|
|
149
|
+
}
|
|
150
|
+
for (const config of account.logConfigs) {
|
|
151
|
+
for (const filter of config.filters) {
|
|
152
|
+
// if (filter.topics.length != log.topics.length) {
|
|
153
|
+
// continue
|
|
154
|
+
// }
|
|
155
|
+
|
|
156
|
+
let match = true
|
|
157
|
+
for (const topicIdx in filter.topics) {
|
|
158
|
+
const logTopic = log.topics[topicIdx]
|
|
159
|
+
const possibleTopic = filter.topics[topicIdx].hashes
|
|
160
|
+
if (possibleTopic.length === 0) {
|
|
161
|
+
// match all
|
|
162
|
+
continue
|
|
163
|
+
}
|
|
164
|
+
if (possibleTopic.find((e) => e.toLowerCase() === logTopic.toLowerCase())) {
|
|
165
|
+
// find one
|
|
166
|
+
continue
|
|
167
|
+
}
|
|
168
|
+
match = false
|
|
169
|
+
break
|
|
170
|
+
}
|
|
171
|
+
if (match) {
|
|
172
|
+
return {
|
|
173
|
+
data: {
|
|
174
|
+
ethLog: { log, timestamp: new Date() },
|
|
175
|
+
},
|
|
176
|
+
handlerIds: [config.handlerId],
|
|
177
|
+
handlerType: HandlerType.ETH_LOG,
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
return undefined
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
testBlock(
|
|
187
|
+
block: Partial<BlockParams> & { number: number },
|
|
188
|
+
network: Networkish = 1
|
|
189
|
+
): Promise<ProcessBindingResponse> {
|
|
190
|
+
return this.testBlocks([block], network)
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
testBlocks(blocks: Partial<BlockParams> & { number: number }[], network: Networkish = 1) {
|
|
194
|
+
const bindings = []
|
|
195
|
+
for (const block of blocks) {
|
|
196
|
+
const binding = this.buildBlockBinding(block, network)
|
|
197
|
+
if (!binding) {
|
|
198
|
+
throw Error('Invalid test block: ' + JSON.stringify(block))
|
|
199
|
+
}
|
|
200
|
+
bindings.push(binding)
|
|
201
|
+
}
|
|
202
|
+
return this.server.processBindings({
|
|
203
|
+
bindings: bindings,
|
|
204
|
+
})
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
buildBlockBinding(block: Partial<Block> & { number: number }, network: Networkish = 1): DataBinding {
|
|
208
|
+
const binding: DataBinding = {
|
|
209
|
+
data: {
|
|
210
|
+
ethBlock: { block },
|
|
211
|
+
},
|
|
212
|
+
handlerType: HandlerType.ETH_BLOCK,
|
|
213
|
+
handlerIds: [],
|
|
214
|
+
}
|
|
215
|
+
for (const contract of this.server.contractConfigs) {
|
|
216
|
+
if (contract.contract?.chainId !== Network.from(network).chainId.toString()) {
|
|
217
|
+
continue
|
|
218
|
+
}
|
|
219
|
+
const longBlockNumber = block.number
|
|
220
|
+
if (longBlockNumber < contract.startBlock) {
|
|
221
|
+
continue
|
|
222
|
+
}
|
|
223
|
+
if (contract.endBlock !== 0n && longBlockNumber >= contract.endBlock) {
|
|
224
|
+
continue
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
for (const config of contract.intervalConfigs) {
|
|
228
|
+
binding.handlerIds.push(config.handlerId)
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
return binding
|
|
232
|
+
}
|
|
233
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { TestProcessorServer } from './test-processor-server.js'
|
|
2
|
+
import { Data_SolInstruction, HandlerType, ProcessBindingResponse } from '@sentio/protos'
|
|
3
|
+
|
|
4
|
+
export class SolanaFacet {
|
|
5
|
+
server: TestProcessorServer
|
|
6
|
+
|
|
7
|
+
constructor(server: TestProcessorServer) {
|
|
8
|
+
this.server = server
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
testInstructions(instructions: Data_SolInstruction[]): Promise<ProcessBindingResponse> {
|
|
12
|
+
return this.server.processBindings({
|
|
13
|
+
bindings: instructions.map((instruction) => {
|
|
14
|
+
return {
|
|
15
|
+
data: {
|
|
16
|
+
raw: new Uint8Array(),
|
|
17
|
+
solInstruction: instruction,
|
|
18
|
+
},
|
|
19
|
+
handlerIds: [],
|
|
20
|
+
handlerType: HandlerType.SOL_INSTRUCTION,
|
|
21
|
+
}
|
|
22
|
+
}),
|
|
23
|
+
})
|
|
24
|
+
}
|
|
25
|
+
}
|