@@ -4,13 +4,13 @@ import (
4
4
"fmt"
5
5
"time"
6
6
7
+ "github.com/ethereum/go-ethereum/accounts/abi"
7
8
"github.com/ethereum/go-ethereum/common"
8
9
9
10
cmn "github.com/cosmos/evm/precompiles/common"
10
11
11
12
evidencetypes "cosmossdk.io/x/evidence/types"
12
13
13
- sdk "github.com/cosmos/cosmos-sdk/types"
14
14
"github.com/cosmos/cosmos-sdk/types/query"
15
15
)
16
16
@@ -59,8 +59,12 @@ func (e EquivocationData) ToEquivocation() *evidencetypes.Equivocation {
59
59
}
60
60
}
61
61
62
+ type SubmitEquivocationInput struct {
63
+ Equivocation EquivocationData
64
+ }
65
+
62
66
// NewMsgSubmitEvidence creates a new MsgSubmitEvidence instance.
63
- func NewMsgSubmitEvidence (args []interface {}) (* evidencetypes.MsgSubmitEvidence , common.Address , error ) {
67
+ func NewMsgSubmitEvidence (method * abi. Method , args []interface {}) (* evidencetypes.MsgSubmitEvidence , common.Address , error ) {
64
68
emptyAddr := common.Address {}
65
69
if len (args ) != 2 {
66
70
return nil , emptyAddr , fmt .Errorf (cmn .ErrInvalidNumberOfArgs , 2 , len (args ))
@@ -71,18 +75,21 @@ func NewMsgSubmitEvidence(args []interface{}) (*evidencetypes.MsgSubmitEvidence,
71
75
return nil , emptyAddr , fmt .Errorf ("invalid submitter address" )
72
76
}
73
77
74
- equivocation , ok := args [1 ].(EquivocationData )
75
- if ! ok {
76
- return nil , emptyAddr , fmt .Errorf ("invalid equivocation evidence" )
78
+ inputs := method .Inputs [1 :] // Skip the first input which is the submitter address
79
+ args = args [1 :]
80
+ var input SubmitEquivocationInput
81
+ if err := inputs .Copy (& input , args ); err != nil {
82
+ return nil , emptyAddr , fmt .Errorf ("failed to copy inputs: %w" , err )
77
83
}
78
84
79
- // Convert the EquivocationData to a types.Equivocation
80
- evidence := equivocation .ToEquivocation ()
85
+ equivocation := input .Equivocation .ToEquivocation ()
86
+ if equivocation == nil {
87
+ return nil , emptyAddr , fmt .Errorf ("invalid equivocation evidence" )
88
+ }
81
89
82
- // Create the MsgSubmitEvidence using the SDK msg builder
83
90
msg , err := evidencetypes .NewMsgSubmitEvidence (
84
- sdk . AccAddress ( submitterAddress .Bytes () ),
85
- evidence ,
91
+ submitterAddress .Bytes (),
92
+ equivocation ,
86
93
)
87
94
if err != nil {
88
95
return nil , emptyAddr , fmt .Errorf ("failed to create evidence message: %w" , err )
0 commit comments