|
1 | 1 | package utils |
2 | 2 |
|
3 | 3 | import ( |
4 | | - "fmt" |
5 | | - "slices" |
6 | | - |
7 | 4 | abcitypes "github.com/cometbft/cometbft/abci/types" |
8 | 5 |
|
9 | | - testutiltypes "github.com/cosmos/evm/testutil/types" |
10 | 6 | evmtypes "github.com/cosmos/evm/x/vm/types" |
11 | 7 | ) |
12 | 8 |
|
13 | | -// CheckTxTopics checks if all expected topics are present in the transaction response |
14 | | -func CheckTxTopics(res abcitypes.ExecTxResult, expectedTopics []string) error { |
15 | | - msgEthResponse, err := DecodeExecTxResult(res) |
16 | | - if err != nil { |
17 | | - return err |
18 | | - } |
19 | | - |
20 | | - // Collect all topics within the transaction |
21 | | - availableLogs := make([]string, 0, len(msgEthResponse.Logs)) |
22 | | - for _, log := range msgEthResponse.Logs { |
23 | | - availableLogs = append(availableLogs, log.Topics...) |
24 | | - } |
25 | | - |
26 | | - // Check if all expected topics are present |
27 | | - for _, expectedTopic := range expectedTopics { |
28 | | - if !slices.Contains(availableLogs, expectedTopic) { |
29 | | - return fmt.Errorf("expected topic %s not found in tx response", expectedTopic) |
30 | | - } |
31 | | - } |
32 | | - return nil |
33 | | -} |
34 | | - |
35 | | -// DecodeContractCallResponse decodes the response of a contract call query |
36 | | -func DecodeContractCallResponse(response interface{}, callArgs testutiltypes.CallArgs, res abcitypes.ExecTxResult) error { |
37 | | - msgEthResponse, err := DecodeExecTxResult(res) |
38 | | - if err != nil { |
39 | | - return err |
40 | | - } |
41 | | - |
42 | | - err = callArgs.ContractABI.UnpackIntoInterface(response, callArgs.MethodName, msgEthResponse.Ret) |
43 | | - if err != nil { |
44 | | - return err |
45 | | - } |
46 | | - return nil |
47 | | -} |
48 | | - |
49 | 9 | func DecodeExecTxResult(res abcitypes.ExecTxResult) (*evmtypes.MsgEthereumTxResponse, error) { |
50 | 10 | msgEthResponse, err := evmtypes.DecodeTxResponse(res.Data) |
51 | 11 | if err != nil { |
|
0 commit comments