@@ -4,13 +4,13 @@ import (
44 "fmt"
55 "time"
66
7+ "github.com/ethereum/go-ethereum/accounts/abi"
78 "github.com/ethereum/go-ethereum/common"
89
910 cmn "github.com/cosmos/evm/precompiles/common"
1011
1112 evidencetypes "cosmossdk.io/x/evidence/types"
1213
13- sdk "github.com/cosmos/cosmos-sdk/types"
1414 "github.com/cosmos/cosmos-sdk/types/query"
1515)
1616
@@ -59,8 +59,12 @@ func (e EquivocationData) ToEquivocation() *evidencetypes.Equivocation {
5959 }
6060}
6161
62+ type SubmitEquivocationInput struct {
63+ Equivocation EquivocationData
64+ }
65+
6266// 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 ) {
6468 emptyAddr := common.Address {}
6569 if len (args ) != 2 {
6670 return nil , emptyAddr , fmt .Errorf (cmn .ErrInvalidNumberOfArgs , 2 , len (args ))
@@ -71,18 +75,21 @@ func NewMsgSubmitEvidence(args []interface{}) (*evidencetypes.MsgSubmitEvidence,
7175 return nil , emptyAddr , fmt .Errorf ("invalid submitter address" )
7276 }
7377
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 )
7783 }
7884
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+ }
8189
82- // Create the MsgSubmitEvidence using the SDK msg builder
8390 msg , err := evidencetypes .NewMsgSubmitEvidence (
84- sdk . AccAddress ( submitterAddress .Bytes () ),
85- evidence ,
91+ submitterAddress .Bytes (),
92+ equivocation ,
8693 )
8794 if err != nil {
8895 return nil , emptyAddr , fmt .Errorf ("failed to create evidence message: %w" , err )
0 commit comments