github.com/InjectiveLabs/sdk-go@v1.53.0/chain/peggy/types/msgs.go (about) 1 package types 2 3 import ( 4 "encoding/hex" 5 "fmt" 6 7 "cosmossdk.io/errors" 8 "github.com/cometbft/cometbft/crypto/tmhash" 9 sdk "github.com/cosmos/cosmos-sdk/types" 10 sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" 11 "github.com/ethereum/go-ethereum/common" 12 ) 13 14 var ( 15 _ sdk.Msg = &MsgValsetConfirm{} 16 _ sdk.Msg = &MsgSendToEth{} 17 _ sdk.Msg = &MsgRequestBatch{} 18 _ sdk.Msg = &MsgConfirmBatch{} 19 _ sdk.Msg = &MsgSetOrchestratorAddresses{} 20 _ sdk.Msg = &MsgERC20DeployedClaim{} 21 _ sdk.Msg = &MsgDepositClaim{} 22 _ sdk.Msg = &MsgWithdrawClaim{} 23 _ sdk.Msg = &MsgCancelSendToEth{} 24 _ sdk.Msg = &MsgValsetUpdatedClaim{} 25 _ sdk.Msg = &MsgSubmitBadSignatureEvidence{} 26 _ sdk.Msg = &MsgUpdateParams{} 27 _ sdk.Msg = &MsgBlacklistEthereumAddresses{} 28 _ sdk.Msg = &MsgRevokeEthereumBlacklist{} 29 ) 30 31 func (m *MsgUpdateParams) Route() string { return RouterKey } 32 33 func (m *MsgUpdateParams) Type() string { return "update_params" } 34 35 func (m *MsgUpdateParams) ValidateBasic() error { 36 if _, err := sdk.AccAddressFromBech32(m.Authority); err != nil { 37 return errors.Wrap(err, "invalid authority address") 38 } 39 40 if err := m.Params.ValidateBasic(); err != nil { 41 return errors.Wrap(err, "invalid params") 42 } 43 44 return nil 45 } 46 47 func (m *MsgUpdateParams) GetSignBytes() []byte { 48 return sdk.MustSortJSON(ModuleCdc.MustMarshal(m)) 49 } 50 51 func (m *MsgUpdateParams) GetSigners() []sdk.AccAddress { 52 addr, _ := sdk.AccAddressFromBech32(m.Authority) 53 return []sdk.AccAddress{addr} 54 } 55 56 // NewMsgSetOrchestratorAddress returns a new MsgSetOrchestratorAddresses 57 func NewMsgSetOrchestratorAddress(sender, orchestrator sdk.AccAddress, ethAddr common.Address) *MsgSetOrchestratorAddresses { 58 return &MsgSetOrchestratorAddresses{ 59 Sender: sender.String(), 60 Orchestrator: orchestrator.String(), 61 EthAddress: ethAddr.Hex(), 62 } 63 } 64 65 // Route should return the name of the module 66 func (msg *MsgSetOrchestratorAddresses) Route() string { return RouterKey } 67 68 // Type should return the action 69 func (msg *MsgSetOrchestratorAddresses) Type() string { return "set_operator_address" } 70 71 // ValidateBasic performs stateless checks 72 func (msg *MsgSetOrchestratorAddresses) ValidateBasic() (err error) { 73 if _, err = sdk.AccAddressFromBech32(msg.Sender); err != nil { 74 return errors.Wrap(sdkerrors.ErrInvalidAddress, msg.Sender) 75 } 76 if _, err = sdk.AccAddressFromBech32(msg.Orchestrator); err != nil { 77 return errors.Wrap(sdkerrors.ErrInvalidAddress, msg.Orchestrator) 78 } 79 if err := ValidateEthAddress(msg.EthAddress); err != nil { 80 return errors.Wrap(err, "ethereum address") 81 } 82 return nil 83 } 84 85 // GetSignBytes encodes the message for signing 86 func (msg *MsgSetOrchestratorAddresses) GetSignBytes() []byte { 87 return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(msg)) 88 } 89 90 // GetSigners defines whose signature is required 91 func (msg *MsgSetOrchestratorAddresses) GetSigners() []sdk.AccAddress { 92 acc, err := sdk.AccAddressFromBech32(msg.Sender) 93 if err != nil { 94 panic(err) 95 } 96 97 return []sdk.AccAddress{acc} 98 } 99 100 // NewMsgValsetConfirm returns a new msgValsetConfirm 101 func NewMsgValsetConfirm(nonce uint64, ethAddress string, validator sdk.AccAddress, signature string) *MsgValsetConfirm { 102 return &MsgValsetConfirm{ 103 Nonce: nonce, 104 Orchestrator: validator.String(), 105 EthAddress: ethAddress, 106 Signature: signature, 107 } 108 } 109 110 // Route should return the name of the module 111 func (msg *MsgValsetConfirm) Route() string { return RouterKey } 112 113 // Type should return the action 114 func (msg *MsgValsetConfirm) Type() string { return "valset_confirm" } 115 116 // ValidateBasic performs stateless checks 117 func (msg *MsgValsetConfirm) ValidateBasic() (err error) { 118 if _, err = sdk.AccAddressFromBech32(msg.Orchestrator); err != nil { 119 return errors.Wrap(sdkerrors.ErrInvalidAddress, msg.Orchestrator) 120 } 121 if err := ValidateEthAddress(msg.EthAddress); err != nil { 122 return errors.Wrap(err, "ethereum address") 123 } 124 return nil 125 } 126 127 // GetSignBytes encodes the message for signing 128 func (msg *MsgValsetConfirm) GetSignBytes() []byte { 129 return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(msg)) 130 } 131 132 // GetSigners defines whose signature is required 133 func (msg *MsgValsetConfirm) GetSigners() []sdk.AccAddress { 134 acc, err := sdk.AccAddressFromBech32(msg.Orchestrator) 135 if err != nil { 136 panic(err) 137 } 138 return []sdk.AccAddress{acc} 139 } 140 141 // NewMsgSendToEth returns a new msgSendToEth 142 func NewMsgSendToEth(sender sdk.AccAddress, destAddress string, send, bridgeFee sdk.Coin) *MsgSendToEth { 143 return &MsgSendToEth{ 144 Sender: sender.String(), 145 EthDest: destAddress, 146 Amount: send, 147 BridgeFee: bridgeFee, 148 } 149 } 150 151 // Route should return the name of the module 152 func (msg MsgSendToEth) Route() string { return RouterKey } 153 154 // Type should return the action 155 func (msg MsgSendToEth) Type() string { return "send_to_eth" } 156 157 // ValidateBasic runs stateless checks on the message 158 // Checks if the Eth address is valid 159 func (msg MsgSendToEth) ValidateBasic() error { 160 if _, err := sdk.AccAddressFromBech32(msg.Sender); err != nil { 161 return errors.Wrap(sdkerrors.ErrInvalidAddress, msg.Sender) 162 } 163 164 // fee and send must be of the same denom 165 if msg.Amount.Denom != msg.BridgeFee.Denom { 166 return errors.Wrap(sdkerrors.ErrInvalidCoins, fmt.Sprintf("fee and amount must be the same type %s != %s", msg.Amount.Denom, msg.BridgeFee.Denom)) 167 } 168 169 if !msg.Amount.IsValid() || msg.Amount.IsZero() { 170 return errors.Wrap(sdkerrors.ErrInvalidCoins, "amount") 171 } 172 if !msg.BridgeFee.IsValid() || msg.BridgeFee.IsZero() { 173 return errors.Wrap(sdkerrors.ErrInvalidCoins, "fee") 174 } 175 if err := ValidateEthAddress(msg.EthDest); err != nil { 176 return errors.Wrap(err, "ethereum address") 177 } 178 return nil 179 } 180 181 // GetSignBytes encodes the message for signing 182 func (msg MsgSendToEth) GetSignBytes() []byte { 183 return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(msg)) 184 } 185 186 // GetSigners defines whose signature is required 187 func (msg MsgSendToEth) GetSigners() []sdk.AccAddress { 188 acc, err := sdk.AccAddressFromBech32(msg.Sender) 189 if err != nil { 190 panic(err) 191 } 192 193 return []sdk.AccAddress{acc} 194 } 195 196 // NewMsgRequestBatch returns a new msgRequestBatch 197 func NewMsgRequestBatch(orchestrator sdk.AccAddress) *MsgRequestBatch { 198 return &MsgRequestBatch{ 199 Orchestrator: orchestrator.String(), 200 } 201 } 202 203 // Route should return the name of the module 204 func (msg MsgRequestBatch) Route() string { return RouterKey } 205 206 // Type should return the action 207 func (msg MsgRequestBatch) Type() string { return "request_batch" } 208 209 // ValidateBasic performs stateless checks 210 func (msg MsgRequestBatch) ValidateBasic() error { 211 if _, err := sdk.AccAddressFromBech32(msg.Orchestrator); err != nil { 212 return errors.Wrap(sdkerrors.ErrInvalidAddress, msg.Orchestrator) 213 } 214 return nil 215 } 216 217 // GetSignBytes encodes the message for signing 218 func (msg MsgRequestBatch) GetSignBytes() []byte { 219 return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(msg)) 220 } 221 222 // GetSigners defines whose signature is required 223 func (msg MsgRequestBatch) GetSigners() []sdk.AccAddress { 224 acc, err := sdk.AccAddressFromBech32(msg.Orchestrator) 225 if err != nil { 226 panic(err) 227 } 228 229 return []sdk.AccAddress{acc} 230 } 231 232 // Route should return the name of the module 233 func (msg MsgConfirmBatch) Route() string { return RouterKey } 234 235 // Type should return the action 236 func (msg MsgConfirmBatch) Type() string { return "confirm_batch" } 237 238 // ValidateBasic performs stateless checks 239 func (msg MsgConfirmBatch) ValidateBasic() error { 240 if _, err := sdk.AccAddressFromBech32(msg.Orchestrator); err != nil { 241 return errors.Wrap(sdkerrors.ErrInvalidAddress, msg.Orchestrator) 242 } 243 if err := ValidateEthAddress(msg.EthSigner); err != nil { 244 return errors.Wrap(err, "eth signer") 245 } 246 if err := ValidateEthAddress(msg.TokenContract); err != nil { 247 return errors.Wrap(err, "token contract") 248 } 249 _, err := hex.DecodeString(msg.Signature) 250 if err != nil { 251 return errors.Wrapf(sdkerrors.ErrUnknownRequest, "Could not decode hex string %s", msg.Signature) 252 } 253 return nil 254 } 255 256 // GetSignBytes encodes the message for signing 257 func (msg MsgConfirmBatch) GetSignBytes() []byte { 258 return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(msg)) 259 } 260 261 // GetSigners defines whose signature is required 262 func (msg MsgConfirmBatch) GetSigners() []sdk.AccAddress { 263 acc, err := sdk.AccAddressFromBech32(msg.Orchestrator) 264 if err != nil { 265 panic(err) 266 } 267 return []sdk.AccAddress{acc} 268 } 269 270 // EthereumClaim represents a claim on ethereum state 271 type EthereumClaim interface { 272 // All Ethereum claims that we relay from the Peggy contract and into the module 273 // have a nonce that is monotonically increasing and unique, since this nonce is 274 // issued by the Ethereum contract it is immutable and must be agreed on by all validators 275 // any disagreement on what claim goes to what nonce means someone is lying. 276 GetEventNonce() uint64 277 // The block height that the claimed event occurred on. This EventNonce provides sufficient 278 // ordering for the execution of all claims. The block height is used only for batchTimeouts 279 // when we go to create a new batch we set the timeout some number of batches out from the last 280 // known height plus projected block progress since then. 281 GetBlockHeight() uint64 282 // the delegate address of the claimer, for MsgDepositClaim and MsgWithdrawClaim 283 // this is sent in as the sdk.AccAddress of the delegated key. it is up to the user 284 // to disambiguate this into a sdk.ValAddress 285 GetClaimer() sdk.AccAddress 286 // Which type of claim this is 287 GetType() ClaimType 288 ValidateBasic() error 289 // The claim hash of this claim. This is used to store these claims and also used to check if two different 290 // validators claims agree. Therefore it's extremely important that this include all elements of the claim 291 // with the exception of the orchestrator who sent it in, which will be used as a different part of the index 292 ClaimHash() []byte 293 } 294 295 var ( 296 _ EthereumClaim = &MsgDepositClaim{} 297 _ EthereumClaim = &MsgWithdrawClaim{} 298 _ EthereumClaim = &MsgERC20DeployedClaim{} 299 ) 300 301 // GetType returns the type of the claim 302 func (msg *MsgDepositClaim) GetType() ClaimType { 303 return CLAIM_TYPE_DEPOSIT 304 } 305 306 // ValidateBasic performs stateless checks 307 func (msg *MsgDepositClaim) ValidateBasic() error { 308 if _, err := sdk.AccAddressFromBech32(msg.CosmosReceiver); err != nil { 309 return errors.Wrap(sdkerrors.ErrInvalidAddress, msg.CosmosReceiver) 310 } 311 if err := ValidateEthAddress(msg.EthereumSender); err != nil { 312 return errors.Wrap(err, "eth sender") 313 } 314 if err := ValidateEthAddress(msg.TokenContract); err != nil { 315 return errors.Wrap(err, "erc20 token") 316 } 317 if _, err := sdk.AccAddressFromBech32(msg.Orchestrator); err != nil { 318 return errors.Wrap(sdkerrors.ErrInvalidAddress, msg.Orchestrator) 319 } 320 if msg.EventNonce == 0 { 321 return fmt.Errorf("nonce == 0") 322 } 323 return nil 324 } 325 326 // GetSignBytes encodes the message for signing 327 func (msg MsgDepositClaim) GetSignBytes() []byte { 328 return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(msg)) 329 } 330 331 func (msg MsgDepositClaim) GetClaimer() sdk.AccAddress { 332 err := msg.ValidateBasic() 333 if err != nil { 334 panic("MsgDepositClaim failed ValidateBasic! Should have been handled earlier") 335 } 336 337 val, _ := sdk.AccAddressFromBech32(msg.Orchestrator) 338 return val 339 } 340 341 // GetSigners defines whose signature is required 342 func (msg MsgDepositClaim) GetSigners() []sdk.AccAddress { 343 acc, err := sdk.AccAddressFromBech32(msg.Orchestrator) 344 if err != nil { 345 panic(err) 346 } 347 348 return []sdk.AccAddress{acc} 349 } 350 351 // Type should return the action 352 func (msg MsgDepositClaim) Type() string { return "deposit_claim" } 353 354 // Route should return the name of the module 355 func (msg MsgDepositClaim) Route() string { return RouterKey } 356 357 const ( 358 TypeMsgWithdrawClaim = "withdraw_claim" 359 ) 360 361 // Hash implements BridgeDeposit.Hash 362 // modify this with care as it is security sensitive. If an element of the claim is not in this hash a single hostile validator 363 // could engineer a hash collision and execute a version of the claim with any unhashed data changed to benefit them. 364 // note that the Orchestrator is the only field excluded from this hash, this is because that value is used higher up in the store 365 // structure for who has made what claim and is verified by the msg ante-handler for signatures 366 func (msg *MsgDepositClaim) ClaimHash() []byte { 367 path := fmt.Sprintf("%d/%d/%s/%s/%s/%s/%s", msg.EventNonce, msg.BlockHeight, msg.TokenContract, msg.Amount.String(), msg.EthereumSender, msg.CosmosReceiver, msg.Data) 368 return tmhash.Sum([]byte(path)) 369 } 370 371 // GetType returns the claim type 372 func (msg *MsgWithdrawClaim) GetType() ClaimType { 373 return CLAIM_TYPE_WITHDRAW 374 } 375 376 // ValidateBasic performs stateless checks 377 func (msg *MsgWithdrawClaim) ValidateBasic() error { 378 if msg.EventNonce == 0 { 379 return fmt.Errorf("event_nonce == 0") 380 } 381 if msg.BatchNonce == 0 { 382 return fmt.Errorf("batch_nonce == 0") 383 } 384 if err := ValidateEthAddress(msg.TokenContract); err != nil { 385 return errors.Wrap(err, "erc20 token") 386 } 387 if _, err := sdk.AccAddressFromBech32(msg.Orchestrator); err != nil { 388 return errors.Wrap(sdkerrors.ErrInvalidAddress, msg.Orchestrator) 389 } 390 return nil 391 } 392 393 // Hash implements WithdrawBatch.Hash 394 func (msg *MsgWithdrawClaim) ClaimHash() []byte { 395 path := fmt.Sprintf("%s/%d/%d/%s", msg.TokenContract, msg.BatchNonce, msg.EventNonce, msg.TokenContract) 396 return tmhash.Sum([]byte(path)) 397 } 398 399 // GetSignBytes encodes the message for signing 400 func (msg MsgWithdrawClaim) GetSignBytes() []byte { 401 return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(msg)) 402 } 403 404 func (msg MsgWithdrawClaim) GetClaimer() sdk.AccAddress { 405 err := msg.ValidateBasic() 406 if err != nil { 407 panic("MsgWithdrawClaim failed ValidateBasic! Should have been handled earlier") 408 } 409 val, _ := sdk.AccAddressFromBech32(msg.Orchestrator) 410 return val 411 } 412 413 // GetSigners defines whose signature is required 414 func (msg MsgWithdrawClaim) GetSigners() []sdk.AccAddress { 415 acc, err := sdk.AccAddressFromBech32(msg.Orchestrator) 416 if err != nil { 417 panic(err) 418 } 419 420 return []sdk.AccAddress{acc} 421 } 422 423 // Route should return the name of the module 424 func (msg MsgWithdrawClaim) Route() string { return RouterKey } 425 426 // Type should return the action 427 func (msg MsgWithdrawClaim) Type() string { return "withdraw_claim" } 428 429 const ( 430 TypeMsgDepositClaim = "deposit_claim" 431 ) 432 433 // EthereumClaim implementation for MsgERC20DeployedClaim 434 // ====================================================== 435 436 // GetType returns the type of the claim 437 func (e *MsgERC20DeployedClaim) GetType() ClaimType { 438 return CLAIM_TYPE_ERC20_DEPLOYED 439 } 440 441 // ValidateBasic performs stateless checks 442 func (e *MsgERC20DeployedClaim) ValidateBasic() error { 443 if err := ValidateEthAddress(e.TokenContract); err != nil { 444 return errors.Wrap(err, "erc20 token") 445 } 446 if _, err := sdk.AccAddressFromBech32(e.Orchestrator); err != nil { 447 return errors.Wrap(sdkerrors.ErrInvalidAddress, e.Orchestrator) 448 } 449 if e.EventNonce == 0 { 450 return fmt.Errorf("nonce == 0") 451 } 452 return nil 453 } 454 455 // GetSignBytes encodes the message for signing 456 func (msg MsgERC20DeployedClaim) GetSignBytes() []byte { 457 return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(msg)) 458 } 459 460 func (msg MsgERC20DeployedClaim) GetClaimer() sdk.AccAddress { 461 err := msg.ValidateBasic() 462 if err != nil { 463 panic("MsgERC20DeployedClaim failed ValidateBasic! Should have been handled earlier") 464 } 465 466 val, _ := sdk.AccAddressFromBech32(msg.Orchestrator) 467 return val 468 } 469 470 // GetSigners defines whose signature is required 471 func (msg MsgERC20DeployedClaim) GetSigners() []sdk.AccAddress { 472 acc, err := sdk.AccAddressFromBech32(msg.Orchestrator) 473 if err != nil { 474 panic(err) 475 } 476 477 return []sdk.AccAddress{acc} 478 } 479 480 // Type should return the action 481 func (msg MsgERC20DeployedClaim) Type() string { return "ERC20_deployed_claim" } 482 483 // Route should return the name of the module 484 func (msg MsgERC20DeployedClaim) Route() string { return RouterKey } 485 486 // Hash implements BridgeDeposit.Hash 487 // modify this with care as it is security sensitive. If an element of the claim is not in this hash a single hostile validator 488 // could engineer a hash collision and execute a version of the claim with any unhashed data changed to benefit them. 489 // note that the Orchestrator is the only field excluded from this hash, this is because that value is used higher up in the store 490 // structure for who has made what claim and is verified by the msg ante-handler for signatures 491 func (b *MsgERC20DeployedClaim) ClaimHash() []byte { 492 path := fmt.Sprintf("%d/%d/%s/%s/%s/%s/%d", b.EventNonce, b.BlockHeight, b.CosmosDenom, b.TokenContract, b.Name, b.Symbol, b.Decimals) 493 return tmhash.Sum([]byte(path)) 494 } 495 496 // GetType returns the type of the claim 497 func (e *MsgValsetUpdatedClaim) GetType() ClaimType { 498 return CLAIM_TYPE_VALSET_UPDATED 499 } 500 501 // ValidateBasic performs stateless checks 502 func (e *MsgValsetUpdatedClaim) ValidateBasic() error { 503 if _, err := sdk.AccAddressFromBech32(e.Orchestrator); err != nil { 504 return errors.Wrap(sdkerrors.ErrInvalidAddress, e.Orchestrator) 505 } 506 if e.EventNonce == 0 { 507 return fmt.Errorf("nonce == 0") 508 } 509 err := ValidateEthAddress(e.RewardToken) 510 if err != nil { 511 return err 512 } 513 514 for _, member := range e.Members { 515 err := ValidateEthAddress(member.EthereumAddress) 516 if err != nil { 517 return err 518 } 519 } 520 return nil 521 } 522 523 // GetSignBytes encodes the message for signing 524 func (msg MsgValsetUpdatedClaim) GetSignBytes() []byte { 525 return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(msg)) 526 } 527 528 func (msg MsgValsetUpdatedClaim) GetClaimer() sdk.AccAddress { 529 err := msg.ValidateBasic() 530 if err != nil { 531 panic("MsgERC20DeployedClaim failed ValidateBasic! Should have been handled earlier") 532 } 533 534 val, _ := sdk.AccAddressFromBech32(msg.Orchestrator) 535 return val 536 } 537 538 // GetSigners defines whose signature is required 539 func (msg MsgValsetUpdatedClaim) GetSigners() []sdk.AccAddress { 540 acc, err := sdk.AccAddressFromBech32(msg.Orchestrator) 541 if err != nil { 542 panic(err) 543 } 544 545 return []sdk.AccAddress{acc} 546 } 547 548 // Type should return the action 549 func (msg MsgValsetUpdatedClaim) Type() string { return "Valset_Updated_Claim" } 550 551 // Route should return the name of the module 552 func (msg MsgValsetUpdatedClaim) Route() string { return RouterKey } 553 554 // Hash implements BridgeDeposit.Hash 555 func (b *MsgValsetUpdatedClaim) ClaimHash() []byte { 556 path := fmt.Sprintf("%d/%d/%d/%s/", b.ValsetNonce, b.EventNonce, b.BlockHeight, b.Members) 557 return tmhash.Sum([]byte(path)) 558 } 559 560 // NewMsgCancelSendToEth returns a new msgMsgCancelSendToEth 561 func NewMsgCancelSendToEth(sender sdk.AccAddress, id uint64) *MsgCancelSendToEth { 562 return &MsgCancelSendToEth{ 563 TransactionId: id, 564 Sender: sender.String(), 565 } 566 } 567 568 // Route should return the name of the module 569 func (msg *MsgCancelSendToEth) Route() string { return RouterKey } 570 571 // Type should return the action 572 func (msg *MsgCancelSendToEth) Type() string { return "cancel_send_to_eth" } 573 574 // ValidateBasic performs stateless checks 575 func (msg *MsgCancelSendToEth) ValidateBasic() (err error) { 576 if _, err := sdk.AccAddressFromBech32(msg.Sender); err != nil { 577 return errors.Wrap(sdkerrors.ErrInvalidAddress, msg.Sender) 578 } 579 return nil 580 } 581 582 // GetSignBytes encodes the message for signing 583 func (msg *MsgCancelSendToEth) GetSignBytes() []byte { 584 return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(msg)) 585 } 586 587 // GetSigners defines whose signature is required 588 func (msg *MsgCancelSendToEth) GetSigners() []sdk.AccAddress { 589 acc, err := sdk.AccAddressFromBech32(msg.Sender) 590 if err != nil { 591 panic(err) 592 } 593 return []sdk.AccAddress{acc} 594 } 595 596 // MsgSubmitBadSignatureEvidence 597 // ====================================================== 598 599 // ValidateBasic performs stateless checks 600 func (e *MsgSubmitBadSignatureEvidence) ValidateBasic() error { 601 return nil 602 } 603 604 // GetSignBytes encodes the message for signing 605 func (msg MsgSubmitBadSignatureEvidence) GetSignBytes() []byte { 606 return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(msg)) 607 } 608 609 // GetSigners defines whose signature is required 610 func (msg MsgSubmitBadSignatureEvidence) GetSigners() []sdk.AccAddress { 611 acc, err := sdk.AccAddressFromBech32(msg.Sender) 612 if err != nil { 613 panic(err) 614 } 615 return []sdk.AccAddress{acc} 616 } 617 618 // Type should return the action 619 func (msg MsgSubmitBadSignatureEvidence) Type() string { return "Submit_Bad_Signature_Evidence" } 620 621 // Route should return the name of the module 622 func (msg MsgSubmitBadSignatureEvidence) Route() string { return RouterKey } 623 624 func (m *MsgBlacklistEthereumAddresses) Route() string { return RouterKey } 625 626 func (m *MsgBlacklistEthereumAddresses) Type() string { return "blacklist_ethereum_addresses" } 627 628 func (m *MsgBlacklistEthereumAddresses) ValidateBasic() error { 629 if _, err := sdk.AccAddressFromBech32(m.Signer); err != nil { 630 return errors.Wrap(err, "invalid signer address") 631 } 632 633 for _, blacklistAddress := range m.BlacklistAddresses { 634 635 _, err := NewEthAddress(blacklistAddress) 636 if err != nil { 637 return errors.Wrapf(err, "invalid blacklist address %s", blacklistAddress) 638 } 639 } 640 641 return nil 642 } 643 644 func (m *MsgBlacklistEthereumAddresses) GetSignBytes() []byte { 645 return sdk.MustSortJSON(ModuleCdc.MustMarshal(m)) 646 } 647 648 func (m *MsgBlacklistEthereumAddresses) GetSigners() []sdk.AccAddress { 649 addr, _ := sdk.AccAddressFromBech32(m.Signer) 650 return []sdk.AccAddress{addr} 651 } 652 653 func (m *MsgRevokeEthereumBlacklist) Route() string { return RouterKey } 654 655 func (m *MsgRevokeEthereumBlacklist) Type() string { return "revoke_ethereum_blacklist" } 656 657 func (m *MsgRevokeEthereumBlacklist) ValidateBasic() error { 658 if _, err := sdk.AccAddressFromBech32(m.Signer); err != nil { 659 return errors.Wrap(err, "invalid signer address") 660 } 661 662 for _, blacklistAddress := range m.BlacklistAddresses { 663 664 _, err := NewEthAddress(blacklistAddress) 665 if err != nil { 666 return errors.Wrapf(err, "invalid blacklist address %s", blacklistAddress) 667 } 668 } 669 670 return nil 671 } 672 673 func (m *MsgRevokeEthereumBlacklist) GetSignBytes() []byte { 674 return sdk.MustSortJSON(ModuleCdc.MustMarshal(m)) 675 } 676 677 func (m *MsgRevokeEthereumBlacklist) GetSigners() []sdk.AccAddress { 678 addr, _ := sdk.AccAddressFromBech32(m.Signer) 679 return []sdk.AccAddress{addr} 680 }