-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
748 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
package types | ||
|
||
import ( | ||
sdkerrors "cosmossdk.io/errors" | ||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
) | ||
|
||
const TypeMsgSubmitTransaction = "submit_transaction" | ||
|
||
func NewMsgSubmitTransactionRequest( | ||
sender string, | ||
transaction string, | ||
proof string, | ||
) *MsgSubmitTransactionRequest { | ||
return &MsgSubmitTransactionRequest{ | ||
Sender: sender, | ||
Tx: transaction, | ||
Proof: proof, | ||
} | ||
} | ||
|
||
func (msg *MsgSubmitTransactionRequest) Route() string { | ||
return RouterKey | ||
} | ||
|
||
func (msg *MsgSubmitTransactionRequest) Type() string { | ||
return TypeMsgSubmitTransaction | ||
} | ||
|
||
func (msg *MsgSubmitTransactionRequest) GetSigners() []sdk.AccAddress { | ||
Sender, err := sdk.AccAddressFromBech32(msg.Sender) | ||
if err != nil { | ||
panic(err) | ||
} | ||
return []sdk.AccAddress{Sender} | ||
} | ||
|
||
func (msg *MsgSubmitTransactionRequest) GetSignBytes() []byte { | ||
bz := ModuleCdc.MustMarshalJSON(msg) | ||
return sdk.MustSortJSON(bz) | ||
} | ||
|
||
func (msg *MsgSubmitTransactionRequest) ValidateBasic() error { | ||
_, err := sdk.AccAddressFromBech32(msg.Sender) | ||
if err != nil { | ||
return sdkerrors.Wrapf(err, "invalid Sender address (%s)", err) | ||
} | ||
|
||
if len(msg.Tx) == 0 { | ||
return sdkerrors.Wrap(ErrInvalidBtcTransaction, "transaction cannot be empty") | ||
} | ||
|
||
if len(msg.Proof) == 0 { | ||
return sdkerrors.Wrap(ErrInvalidBtcTransaction, "proof cannot be empty") | ||
} | ||
|
||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.