mirror of
https://github.com/0glabs/0g-chain.git
synced 2024-12-25 07:45:18 +00:00
R4R: bep3 msgs [HOTFIX] (#406)
* implement hotfix * add interface compliance check
This commit is contained in:
parent
82f637649c
commit
2721ba3889
@ -1,7 +1,6 @@
|
||||
package types
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
@ -25,24 +24,28 @@ const (
|
||||
MaxExpectedIncomeLength = 64
|
||||
)
|
||||
|
||||
// ensure Msg interface compliance at compile time
|
||||
var (
|
||||
_ sdk.Msg = &MsgCreateAtomicSwap{}
|
||||
_ sdk.Msg = &MsgClaimAtomicSwap{}
|
||||
_ sdk.Msg = &MsgRefundAtomicSwap{}
|
||||
AtomicSwapCoinsAccAddr = sdk.AccAddress(crypto.AddressHash([]byte("KavaAtomicSwapCoins")))
|
||||
// kava prefix address: [INSERT BEP3-DEPUTY ADDRESS]
|
||||
// tkava prefix address: [INSERT BEP3-DEPUTY ADDRESS]
|
||||
AtomicSwapCoinsAccAddr = sdk.AccAddress(crypto.AddressHash([]byte("KavaAtomicSwapCoins")))
|
||||
)
|
||||
|
||||
// MsgCreateAtomicSwap contains an AtomicSwap struct
|
||||
type MsgCreateAtomicSwap struct {
|
||||
From sdk.AccAddress `json:"from"`
|
||||
To sdk.AccAddress `json:"to"`
|
||||
RecipientOtherChain string `json:"recipient_other_chain"`
|
||||
SenderOtherChain string `json:"sender_other_chain"`
|
||||
RandomNumberHash cmn.HexBytes `json:"random_number_hash"`
|
||||
Timestamp int64 `json:"timestamp"`
|
||||
Amount sdk.Coins `json:"amount"`
|
||||
ExpectedIncome string `json:"expected_income"`
|
||||
HeightSpan int64 `json:"height_span"`
|
||||
CrossChain bool `json:"cross_chain"`
|
||||
From sdk.AccAddress `json:"from" yaml:"from"`
|
||||
To sdk.AccAddress `json:"to" yaml:"to"`
|
||||
RecipientOtherChain string `json:"recipient_other_chain" yaml:"recipient_other_chain"`
|
||||
SenderOtherChain string `json:"sender_other_chain" yaml:"sender_other_chain"`
|
||||
RandomNumberHash cmn.HexBytes `json:"random_number_hash" yaml:"random_number_hash"`
|
||||
Timestamp int64 `json:"timestamp" yaml:"timestamp"`
|
||||
Amount sdk.Coins `json:"amount" yaml:"amount"`
|
||||
ExpectedIncome string `json:"expected_income" yaml:"expected_income"`
|
||||
HeightSpan int64 `json:"height_span" yaml:"height_span"`
|
||||
CrossChain bool `json:"cross_chain" yaml:"cross_chain"`
|
||||
}
|
||||
|
||||
// NewMsgCreateAtomicSwap initializes a new MsgCreateAtomicSwap
|
||||
@ -137,18 +140,15 @@ func (msg MsgCreateAtomicSwap) ValidateBasic() sdk.Error {
|
||||
|
||||
// GetSignBytes gets the sign bytes of a MsgCreateAtomicSwap
|
||||
func (msg MsgCreateAtomicSwap) GetSignBytes() []byte {
|
||||
b, err := json.Marshal(msg)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return b
|
||||
bz := ModuleCdc.MustMarshalJSON(msg)
|
||||
return sdk.MustSortJSON(bz)
|
||||
}
|
||||
|
||||
// MsgClaimAtomicSwap defines a AtomicSwap claim
|
||||
type MsgClaimAtomicSwap struct {
|
||||
From sdk.AccAddress `json:"from"`
|
||||
SwapID cmn.HexBytes `json:"swap_id"`
|
||||
RandomNumber cmn.HexBytes `json:"random_number"`
|
||||
From sdk.AccAddress `json:"from" yaml:"from"`
|
||||
SwapID cmn.HexBytes `json:"swap_id" yaml:"swap_id"`
|
||||
RandomNumber cmn.HexBytes `json:"random_number" yaml:"random_number"`
|
||||
}
|
||||
|
||||
// NewMsgClaimAtomicSwap initializes a new MsgClaimAtomicSwap
|
||||
@ -197,17 +197,14 @@ func (msg MsgClaimAtomicSwap) ValidateBasic() sdk.Error {
|
||||
|
||||
// GetSignBytes gets the sign bytes of a MsgClaimAtomicSwap
|
||||
func (msg MsgClaimAtomicSwap) GetSignBytes() []byte {
|
||||
b, err := json.Marshal(msg)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return b
|
||||
bz := ModuleCdc.MustMarshalJSON(msg)
|
||||
return sdk.MustSortJSON(bz)
|
||||
}
|
||||
|
||||
// MsgRefundAtomicSwap defines a refund msg
|
||||
type MsgRefundAtomicSwap struct {
|
||||
From sdk.AccAddress `json:"from"`
|
||||
SwapID cmn.HexBytes `json:"swap_id"`
|
||||
From sdk.AccAddress `json:"from" yaml:"from"`
|
||||
SwapID cmn.HexBytes `json:"swap_id" yaml:"swap_id"`
|
||||
}
|
||||
|
||||
// NewMsgRefundAtomicSwap initializes a new MsgRefundAtomicSwap
|
||||
@ -252,9 +249,6 @@ func (msg MsgRefundAtomicSwap) ValidateBasic() sdk.Error {
|
||||
|
||||
// GetSignBytes gets the sign bytes of a MsgRefundAtomicSwap
|
||||
func (msg MsgRefundAtomicSwap) GetSignBytes() []byte {
|
||||
b, err := json.Marshal(msg)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return b
|
||||
bz := ModuleCdc.MustMarshalJSON(msg)
|
||||
return sdk.MustSortJSON(bz)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user