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