@@ -10,6 +10,7 @@ import (
1010 cmn "github.com/cosmos/evm/precompiles/common"
1111 "github.com/cosmos/evm/utils"
1212
13+ "cosmossdk.io/core/address"
1314 "cosmossdk.io/math"
1415
1516 sdk "github.com/cosmos/cosmos-sdk/types"
@@ -77,7 +78,7 @@ func parseClaimRewardsArgs(args []interface{}) (common.Address, uint32, error) {
7778}
7879
7980// NewMsgSetWithdrawAddress creates a new MsgSetWithdrawAddress instance.
80- func NewMsgSetWithdrawAddress (args []interface {}) (* distributiontypes.MsgSetWithdrawAddress , common.Address , error ) {
81+ func NewMsgSetWithdrawAddress (args []interface {}, addrCdc address. Codec ) (* distributiontypes.MsgSetWithdrawAddress , common.Address , error ) {
8182 if len (args ) != 2 {
8283 return nil , common.Address {}, fmt .Errorf (cmn .ErrInvalidNumberOfArgs , 2 , len (args ))
8384 }
@@ -98,16 +99,20 @@ func NewMsgSetWithdrawAddress(args []interface{}) (*distributiontypes.MsgSetWith
9899 }
99100 }
100101
102+ delAddr , err := addrCdc .BytesToString (delegatorAddress .Bytes ())
103+ if err != nil {
104+ return nil , common.Address {}, fmt .Errorf ("failed to decode delegator address: %w" , err )
105+ }
101106 msg := & distributiontypes.MsgSetWithdrawAddress {
102- DelegatorAddress : sdk . AccAddress ( delegatorAddress . Bytes ()). String () ,
107+ DelegatorAddress : delAddr ,
103108 WithdrawAddress : withdrawerAddress ,
104109 }
105110
106111 return msg , delegatorAddress , nil
107112}
108113
109114// NewMsgWithdrawDelegatorReward creates a new MsgWithdrawDelegatorReward instance.
110- func NewMsgWithdrawDelegatorReward (args []interface {}) (* distributiontypes.MsgWithdrawDelegatorReward , common.Address , error ) {
115+ func NewMsgWithdrawDelegatorReward (args []interface {}, addrCdc address. Codec ) (* distributiontypes.MsgWithdrawDelegatorReward , common.Address , error ) {
111116 if len (args ) != 2 {
112117 return nil , common.Address {}, fmt .Errorf (cmn .ErrInvalidNumberOfArgs , 2 , len (args ))
113118 }
@@ -119,8 +124,12 @@ func NewMsgWithdrawDelegatorReward(args []interface{}) (*distributiontypes.MsgWi
119124
120125 validatorAddress , _ := args [1 ].(string )
121126
127+ delAddr , err := addrCdc .BytesToString (delegatorAddress .Bytes ())
128+ if err != nil {
129+ return nil , common.Address {}, fmt .Errorf ("failed to decode delegator address: %w" , err )
130+ }
122131 msg := & distributiontypes.MsgWithdrawDelegatorReward {
123- DelegatorAddress : sdk . AccAddress ( delegatorAddress . Bytes ()). String () ,
132+ DelegatorAddress : delAddr ,
124133 ValidatorAddress : validatorAddress ,
125134 }
126135
@@ -148,7 +157,7 @@ func NewMsgWithdrawValidatorCommission(args []interface{}) (*distributiontypes.M
148157}
149158
150159// NewMsgFundCommunityPool creates a new NewMsgFundCommunityPool message.
151- func NewMsgFundCommunityPool (args []interface {}) (* distributiontypes.MsgFundCommunityPool , common.Address , error ) {
160+ func NewMsgFundCommunityPool (args []interface {}, addrCdc address. Codec ) (* distributiontypes.MsgFundCommunityPool , common.Address , error ) {
152161 emptyAddr := common.Address {}
153162 if len (args ) != 2 {
154163 return nil , emptyAddr , fmt .Errorf (cmn .ErrInvalidNumberOfArgs , 2 , len (args ))
@@ -169,16 +178,20 @@ func NewMsgFundCommunityPool(args []interface{}) (*distributiontypes.MsgFundComm
169178 return nil , emptyAddr , fmt .Errorf (ErrInvalidAmount , "amount arg" )
170179 }
171180
181+ depAddr , err := addrCdc .BytesToString (depositorAddress .Bytes ())
182+ if err != nil {
183+ return nil , common.Address {}, fmt .Errorf ("failed to decode depositor address: %w" , err )
184+ }
172185 msg := & distributiontypes.MsgFundCommunityPool {
173- Depositor : sdk . AccAddress ( depositorAddress . Bytes ()). String () ,
186+ Depositor : depAddr ,
174187 Amount : amt ,
175188 }
176189
177190 return msg , depositorAddress , nil
178191}
179192
180193// NewMsgDepositValidatorRewardsPool creates a new MsgDepositValidatorRewardsPool message.
181- func NewMsgDepositValidatorRewardsPool (args []interface {}) (* distributiontypes.MsgDepositValidatorRewardsPool , common.Address , error ) {
194+ func NewMsgDepositValidatorRewardsPool (args []interface {}, addrCdc address. Codec ) (* distributiontypes.MsgDepositValidatorRewardsPool , common.Address , error ) {
182195 if len (args ) != 3 {
183196 return nil , common.Address {}, fmt .Errorf (cmn .ErrInvalidNumberOfArgs , 3 , len (args ))
184197 }
@@ -200,8 +213,13 @@ func NewMsgDepositValidatorRewardsPool(args []interface{}) (*distributiontypes.M
200213 return nil , common.Address {}, fmt .Errorf (cmn .ErrInvalidAmount , err .Error ())
201214 }
202215
216+ depAddr , err := addrCdc .BytesToString (depositorAddress .Bytes ())
217+ if err != nil {
218+ return nil , common.Address {}, fmt .Errorf ("failed to decode depositor address: %w" , err )
219+ }
220+
203221 msg := & distributiontypes.MsgDepositValidatorRewardsPool {
204- Depositor : sdk . AccAddress ( depositorAddress . Bytes ()). String () ,
222+ Depositor : depAddr ,
205223 ValidatorAddress : validatorAddress ,
206224 Amount : amount ,
207225 }
@@ -280,7 +298,7 @@ func NewValidatorSlashesRequest(method *abi.Method, args []interface{}) (*distri
280298
281299// NewDelegationRewardsRequest creates a new QueryDelegationRewardsRequest instance and does sanity
282300// checks on the provided arguments.
283- func NewDelegationRewardsRequest (args []interface {}) (* distributiontypes.QueryDelegationRewardsRequest , error ) {
301+ func NewDelegationRewardsRequest (args []interface {}, addrCdc address. Codec ) (* distributiontypes.QueryDelegationRewardsRequest , error ) {
284302 if len (args ) != 2 {
285303 return nil , fmt .Errorf (cmn .ErrInvalidNumberOfArgs , 2 , len (args ))
286304 }
@@ -292,15 +310,19 @@ func NewDelegationRewardsRequest(args []interface{}) (*distributiontypes.QueryDe
292310
293311 validatorAddress , _ := args [1 ].(string )
294312
313+ delAddr , err := addrCdc .BytesToString (delegatorAddress .Bytes ())
314+ if err != nil {
315+ return nil , fmt .Errorf ("failed to decode delegator address: %w" , err )
316+ }
295317 return & distributiontypes.QueryDelegationRewardsRequest {
296- DelegatorAddress : sdk . AccAddress ( delegatorAddress . Bytes ()). String () ,
318+ DelegatorAddress : delAddr ,
297319 ValidatorAddress : validatorAddress ,
298320 }, nil
299321}
300322
301323// NewDelegationTotalRewardsRequest creates a new QueryDelegationTotalRewardsRequest instance and does sanity
302324// checks on the provided arguments.
303- func NewDelegationTotalRewardsRequest (args []interface {}) (* distributiontypes.QueryDelegationTotalRewardsRequest , error ) {
325+ func NewDelegationTotalRewardsRequest (args []interface {}, addrCdc address. Codec ) (* distributiontypes.QueryDelegationTotalRewardsRequest , error ) {
304326 if len (args ) != 1 {
305327 return nil , fmt .Errorf (cmn .ErrInvalidNumberOfArgs , 1 , len (args ))
306328 }
@@ -310,14 +332,18 @@ func NewDelegationTotalRewardsRequest(args []interface{}) (*distributiontypes.Qu
310332 return nil , fmt .Errorf (cmn .ErrInvalidDelegator , args [0 ])
311333 }
312334
335+ delAddr , err := addrCdc .BytesToString (delegatorAddress .Bytes ())
336+ if err != nil {
337+ return nil , fmt .Errorf ("failed to decode delegator address: %w" , err )
338+ }
313339 return & distributiontypes.QueryDelegationTotalRewardsRequest {
314- DelegatorAddress : sdk . AccAddress ( delegatorAddress . Bytes ()). String () ,
340+ DelegatorAddress : delAddr ,
315341 }, nil
316342}
317343
318344// NewDelegatorValidatorsRequest creates a new QueryDelegatorValidatorsRequest instance and does sanity
319345// checks on the provided arguments.
320- func NewDelegatorValidatorsRequest (args []interface {}) (* distributiontypes.QueryDelegatorValidatorsRequest , error ) {
346+ func NewDelegatorValidatorsRequest (args []interface {}, addrCdc address. Codec ) (* distributiontypes.QueryDelegatorValidatorsRequest , error ) {
321347 if len (args ) != 1 {
322348 return nil , fmt .Errorf (cmn .ErrInvalidNumberOfArgs , 1 , len (args ))
323349 }
@@ -327,14 +353,18 @@ func NewDelegatorValidatorsRequest(args []interface{}) (*distributiontypes.Query
327353 return nil , fmt .Errorf (cmn .ErrInvalidDelegator , args [0 ])
328354 }
329355
356+ delAddr , err := addrCdc .BytesToString (delegatorAddress .Bytes ())
357+ if err != nil {
358+ return nil , fmt .Errorf ("failed to decode delegator address: %w" , err )
359+ }
330360 return & distributiontypes.QueryDelegatorValidatorsRequest {
331- DelegatorAddress : sdk . AccAddress ( delegatorAddress . Bytes ()). String () ,
361+ DelegatorAddress : delAddr ,
332362 }, nil
333363}
334364
335365// NewDelegatorWithdrawAddressRequest creates a new QueryDelegatorWithdrawAddressRequest instance and does sanity
336366// checks on the provided arguments.
337- func NewDelegatorWithdrawAddressRequest (args []interface {}) (* distributiontypes.QueryDelegatorWithdrawAddressRequest , error ) {
367+ func NewDelegatorWithdrawAddressRequest (args []interface {}, addrCdc address. Codec ) (* distributiontypes.QueryDelegatorWithdrawAddressRequest , error ) {
338368 if len (args ) != 1 {
339369 return nil , fmt .Errorf (cmn .ErrInvalidNumberOfArgs , 1 , len (args ))
340370 }
@@ -344,8 +374,12 @@ func NewDelegatorWithdrawAddressRequest(args []interface{}) (*distributiontypes.
344374 return nil , fmt .Errorf (cmn .ErrInvalidDelegator , args [0 ])
345375 }
346376
377+ delAddr , err := addrCdc .BytesToString (delegatorAddress .Bytes ())
378+ if err != nil {
379+ return nil , fmt .Errorf ("failed to decode delegator address: %w" , err )
380+ }
347381 return & distributiontypes.QueryDelegatorWithdrawAddressRequest {
348- DelegatorAddress : sdk . AccAddress ( delegatorAddress . Bytes ()). String () ,
382+ DelegatorAddress : delAddr ,
349383 }, nil
350384}
351385
0 commit comments