x/ibc-transfer: move ICS20 out from x/ibc (#6222)
* x/transfer: move ICS20 out from x/ibc * rename to ibc-transfer
This commit is contained in:
parent
86a9750508
commit
3dcdc582af
|
@ -218,25 +218,25 @@ func (m *PubKeyMultisigThreshold) GetPubKeys() []*PublicKey {
|
|||
return nil
|
||||
}
|
||||
|
||||
// Multisignature wraps the signatures from a PubKeyMultisigThreshold.
|
||||
// MultiSignature wraps the signatures from a PubKeyMultisigThreshold.
|
||||
// See cosmos_sdk.tx.v1.ModeInfo.Multi for how to specify which signers signed
|
||||
// and with which modes
|
||||
type Multisignature struct {
|
||||
type MultiSignature struct {
|
||||
Sigs [][]byte `protobuf:"bytes,1,rep,name=sigs,proto3" json:"sigs,omitempty"`
|
||||
}
|
||||
|
||||
func (m *Multisignature) Reset() { *m = Multisignature{} }
|
||||
func (m *Multisignature) String() string { return proto.CompactTextString(m) }
|
||||
func (*Multisignature) ProtoMessage() {}
|
||||
func (*Multisignature) Descriptor() ([]byte, []int) {
|
||||
func (m *MultiSignature) Reset() { *m = MultiSignature{} }
|
||||
func (m *MultiSignature) String() string { return proto.CompactTextString(m) }
|
||||
func (*MultiSignature) ProtoMessage() {}
|
||||
func (*MultiSignature) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_2165b2a1badb1b0c, []int{2}
|
||||
}
|
||||
func (m *Multisignature) XXX_Unmarshal(b []byte) error {
|
||||
func (m *MultiSignature) XXX_Unmarshal(b []byte) error {
|
||||
return m.Unmarshal(b)
|
||||
}
|
||||
func (m *Multisignature) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
func (m *MultiSignature) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
if deterministic {
|
||||
return xxx_messageInfo_Multisignature.Marshal(b, m, deterministic)
|
||||
return xxx_messageInfo_MultiSignature.Marshal(b, m, deterministic)
|
||||
} else {
|
||||
b = b[:cap(b)]
|
||||
n, err := m.MarshalToSizedBuffer(b)
|
||||
|
@ -246,19 +246,19 @@ func (m *Multisignature) XXX_Marshal(b []byte, deterministic bool) ([]byte, erro
|
|||
return b[:n], nil
|
||||
}
|
||||
}
|
||||
func (m *Multisignature) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_Multisignature.Merge(m, src)
|
||||
func (m *MultiSignature) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_MultiSignature.Merge(m, src)
|
||||
}
|
||||
func (m *Multisignature) XXX_Size() int {
|
||||
func (m *MultiSignature) XXX_Size() int {
|
||||
return m.Size()
|
||||
}
|
||||
func (m *Multisignature) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_Multisignature.DiscardUnknown(m)
|
||||
func (m *MultiSignature) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_MultiSignature.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_Multisignature proto.InternalMessageInfo
|
||||
var xxx_messageInfo_MultiSignature proto.InternalMessageInfo
|
||||
|
||||
func (m *Multisignature) GetSigs() [][]byte {
|
||||
func (m *MultiSignature) GetSigs() [][]byte {
|
||||
if m != nil {
|
||||
return m.Sigs
|
||||
}
|
||||
|
@ -324,45 +324,45 @@ func (m *CompactBitArray) GetElems() []byte {
|
|||
func init() {
|
||||
proto.RegisterType((*PublicKey)(nil), "cosmos_sdk.crypto.v1.PublicKey")
|
||||
proto.RegisterType((*PubKeyMultisigThreshold)(nil), "cosmos_sdk.crypto.v1.PubKeyMultisigThreshold")
|
||||
proto.RegisterType((*Multisignature)(nil), "cosmos_sdk.crypto.v1.Multisignature")
|
||||
proto.RegisterType((*MultiSignature)(nil), "cosmos_sdk.crypto.v1.MultiSignature")
|
||||
proto.RegisterType((*CompactBitArray)(nil), "cosmos_sdk.crypto.v1.CompactBitArray")
|
||||
}
|
||||
|
||||
func init() { proto.RegisterFile("crypto/types/types.proto", fileDescriptor_2165b2a1badb1b0c) }
|
||||
|
||||
var fileDescriptor_2165b2a1badb1b0c = []byte{
|
||||
// 486 bytes of a gzipped FileDescriptorProto
|
||||
// 488 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x74, 0x52, 0xdd, 0x8a, 0xd3, 0x40,
|
||||
0x14, 0x6e, 0xda, 0xad, 0xb5, 0xb3, 0xeb, 0x56, 0x87, 0x82, 0xd9, 0x82, 0x49, 0x09, 0x22, 0x55,
|
||||
0xd8, 0x84, 0x54, 0xaa, 0xe8, 0xdd, 0x66, 0x6f, 0x16, 0x8a, 0x50, 0xb2, 0x5e, 0x88, 0x37, 0x21,
|
||||
0x3f, 0x63, 0x1a, 0x9a, 0x64, 0xc2, 0x9c, 0x89, 0x38, 0x2f, 0x21, 0x3e, 0x88, 0x0f, 0xe2, 0xe5,
|
||||
0x5e, 0x7a, 0x55, 0x24, 0x7d, 0x83, 0x7d, 0x02, 0xd9, 0x4c, 0xb2, 0x5d, 0xc4, 0xbd, 0x49, 0x66,
|
||||
0xce, 0xf7, 0x9d, 0x2f, 0xdf, 0x77, 0x4e, 0x90, 0x1a, 0x32, 0x51, 0x70, 0x6a, 0x71, 0x51, 0x10,
|
||||
0x90, 0x4f, 0xb3, 0x60, 0x94, 0x53, 0x3c, 0x0e, 0x29, 0x64, 0x14, 0x3c, 0x88, 0x36, 0xa6, 0x24,
|
||||
0x99, 0x5f, 0xed, 0xc9, 0x0b, 0xbe, 0x4e, 0x58, 0xe4, 0x15, 0x3e, 0xe3, 0xc2, 0xaa, 0x89, 0x56,
|
||||
0x4c, 0x63, 0xba, 0x3f, 0xc9, 0xee, 0xc9, 0x49, 0x4c, 0x69, 0x9c, 0x12, 0x49, 0x09, 0xca, 0x2f,
|
||||
0x96, 0x9f, 0x0b, 0x09, 0x19, 0xdf, 0xbb, 0x68, 0xb8, 0x2a, 0x83, 0x34, 0x09, 0x97, 0x44, 0x60,
|
||||
0x0d, 0x0d, 0x81, 0x84, 0xc5, 0x7c, 0xf1, 0x66, 0x63, 0xab, 0xca, 0x54, 0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, 0x6f, 0x44, 0x0c, 0xb7, 0x95,
|
||||
0x33, 0x9e, 0xa3, 0xe3, 0xd6, 0x67, 0xee, 0xf3, 0x92, 0x11, 0x8c, 0xd1, 0x01, 0x24, 0x31, 0xa8,
|
||||
0xca, 0xb4, 0x37, 0x3b, 0x72, 0xeb, 0xb3, 0x71, 0x89, 0x46, 0xe7, 0x34, 0x2b, 0xfc, 0x90, 0x3b,
|
||||
0x09, 0x3f, 0x63, 0xcc, 0x17, 0xf8, 0x15, 0x7a, 0x42, 0xbe, 0x71, 0xe6, 0x7b, 0x41, 0xc2, 0xc1,
|
||||
0x03, 0x4e, 0x19, 0x69, 0x32, 0xb9, 0xa3, 0x1a, 0x70, 0x12, 0x0e, 0x97, 0x75, 0x19, 0x8f, 0x51,
|
||||
0x9f, 0xa4, 0x24, 0x03, 0xb9, 0x74, 0x57, 0x5e, 0x9c, 0xf3, 0x5f, 0x95, 0xa6, 0x5c, 0x55, 0x9a,
|
||||
0xf2, 0xa7, 0xd2, 0x94, 0x1f, 0x3b, 0xad, 0x73, 0xb5, 0xd3, 0x3a, 0xbf, 0x77, 0x5a, 0xe7, 0xf3,
|
||||
0xcb, 0x38, 0xe1, 0xeb, 0x32, 0x30, 0x43, 0x9a, 0x59, 0x32, 0x67, 0xf3, 0x3a, 0x85, 0x68, 0x63,
|
||||
0xdd, 0xfd, 0xc9, 0x83, 0x07, 0xf5, 0x42, 0x5e, 0xff, 0x0d, 0x00, 0x00, 0xff, 0xff, 0x57, 0x64,
|
||||
0xcc, 0x04, 0xfb, 0x02, 0x00, 0x00,
|
||||
0x18, 0x4d, 0xda, 0xad, 0xb5, 0xb3, 0xeb, 0x56, 0x87, 0x82, 0xd9, 0x82, 0x49, 0x09, 0x22, 0x55,
|
||||
0xd8, 0x84, 0x54, 0xaa, 0xe8, 0xdd, 0x66, 0x6f, 0x16, 0x8a, 0x50, 0x52, 0x2f, 0xc4, 0x9b, 0x90,
|
||||
0x9f, 0x31, 0x1d, 0x9a, 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xcc, 0x99, 0xcf, 0x38, 0xa1, 0xa8, 0xc9, 0xe4, 0x0d, 0x6b, 0xc0, 0xc5, 0x9c, 0xad, 0xea, 0x32,
|
||||
0x1c, 0x81, 0x1e, 0x4a, 0x51, 0xc6, 0xe4, 0xd2, 0x3d, 0x79, 0x71, 0x2f, 0x7f, 0x55, 0xba, 0x7a,
|
||||
0x5d, 0xe9, 0xea, 0x9f, 0x4a, 0x57, 0x7f, 0xec, 0x74, 0xe5, 0x7a, 0xa7, 0x2b, 0xbf, 0x77, 0xba,
|
||||
0xf2, 0xf9, 0x65, 0x82, 0xf9, 0xba, 0x0c, 0xad, 0x88, 0x64, 0xb6, 0xcc, 0xd9, 0xbc, 0xce, 0x59,
|
||||
0xbc, 0xb1, 0xef, 0xff, 0xe4, 0xe1, 0x83, 0x7a, 0x21, 0xaf, 0xff, 0x06, 0x00, 0x00, 0xff, 0xff,
|
||||
0x82, 0xd0, 0x7b, 0xf3, 0xfb, 0x02, 0x00, 0x00,
|
||||
}
|
||||
|
||||
func (m *PublicKey) Marshal() (dAtA []byte, err error) {
|
||||
|
@ -545,7 +545,7 @@ func (m *PubKeyMultisigThreshold) MarshalToSizedBuffer(dAtA []byte) (int, error)
|
|||
return len(dAtA) - i, nil
|
||||
}
|
||||
|
||||
func (m *Multisignature) Marshal() (dAtA []byte, err error) {
|
||||
func (m *MultiSignature) Marshal() (dAtA []byte, err error) {
|
||||
size := m.Size()
|
||||
dAtA = make([]byte, size)
|
||||
n, err := m.MarshalToSizedBuffer(dAtA[:size])
|
||||
|
@ -555,12 +555,12 @@ func (m *Multisignature) Marshal() (dAtA []byte, err error) {
|
|||
return dAtA[:n], nil
|
||||
}
|
||||
|
||||
func (m *Multisignature) MarshalTo(dAtA []byte) (int, error) {
|
||||
func (m *MultiSignature) MarshalTo(dAtA []byte) (int, error) {
|
||||
size := m.Size()
|
||||
return m.MarshalToSizedBuffer(dAtA[:size])
|
||||
}
|
||||
|
||||
func (m *Multisignature) MarshalToSizedBuffer(dAtA []byte) (int, error) {
|
||||
func (m *MultiSignature) MarshalToSizedBuffer(dAtA []byte) (int, error) {
|
||||
i := len(dAtA)
|
||||
_ = i
|
||||
var l int
|
||||
|
@ -725,7 +725,7 @@ func (m *PubKeyMultisigThreshold) Size() (n int) {
|
|||
return n
|
||||
}
|
||||
|
||||
func (m *Multisignature) Size() (n int) {
|
||||
func (m *MultiSignature) Size() (n int) {
|
||||
if m == nil {
|
||||
return 0
|
||||
}
|
||||
|
@ -1123,7 +1123,7 @@ func (m *PubKeyMultisigThreshold) Unmarshal(dAtA []byte) error {
|
|||
}
|
||||
return nil
|
||||
}
|
||||
func (m *Multisignature) Unmarshal(dAtA []byte) error {
|
||||
func (m *MultiSignature) Unmarshal(dAtA []byte) error {
|
||||
l := len(dAtA)
|
||||
iNdEx := 0
|
||||
for iNdEx < l {
|
||||
|
@ -1146,10 +1146,10 @@ func (m *Multisignature) Unmarshal(dAtA []byte) error {
|
|||
fieldNum := int32(wire >> 3)
|
||||
wireType := int(wire & 0x7)
|
||||
if wireType == 4 {
|
||||
return fmt.Errorf("proto: Multisignature: wiretype end group for non-group")
|
||||
return fmt.Errorf("proto: MultiSignature: wiretype end group for non-group")
|
||||
}
|
||||
if fieldNum <= 0 {
|
||||
return fmt.Errorf("proto: Multisignature: illegal tag %d (wire type %d)", fieldNum, wire)
|
||||
return fmt.Errorf("proto: MultiSignature: illegal tag %d (wire type %d)", fieldNum, wire)
|
||||
}
|
||||
switch fieldNum {
|
||||
case 1:
|
||||
|
|
|
@ -27,9 +27,9 @@ import (
|
|||
"github.com/cosmos/cosmos-sdk/x/genutil"
|
||||
"github.com/cosmos/cosmos-sdk/x/gov"
|
||||
"github.com/cosmos/cosmos-sdk/x/ibc"
|
||||
transfer "github.com/cosmos/cosmos-sdk/x/ibc-transfer"
|
||||
ibcclient "github.com/cosmos/cosmos-sdk/x/ibc/02-client"
|
||||
port "github.com/cosmos/cosmos-sdk/x/ibc/05-port"
|
||||
transfer "github.com/cosmos/cosmos-sdk/x/ibc/20-transfer"
|
||||
"github.com/cosmos/cosmos-sdk/x/mint"
|
||||
"github.com/cosmos/cosmos-sdk/x/params"
|
||||
paramsclient "github.com/cosmos/cosmos-sdk/x/params/client"
|
||||
|
@ -74,13 +74,13 @@ var (
|
|||
|
||||
// module account permissions
|
||||
maccPerms = map[string][]string{
|
||||
auth.FeeCollectorName: nil,
|
||||
distr.ModuleName: nil,
|
||||
mint.ModuleName: {auth.Minter},
|
||||
staking.BondedPoolName: {auth.Burner, auth.Staking},
|
||||
staking.NotBondedPoolName: {auth.Burner, auth.Staking},
|
||||
gov.ModuleName: {auth.Burner},
|
||||
transfer.GetModuleAccountName(): {auth.Minter, auth.Burner},
|
||||
auth.FeeCollectorName: nil,
|
||||
distr.ModuleName: nil,
|
||||
mint.ModuleName: {auth.Minter},
|
||||
staking.BondedPoolName: {auth.Burner, auth.Staking},
|
||||
staking.NotBondedPoolName: {auth.Burner, auth.Staking},
|
||||
gov.ModuleName: {auth.Burner},
|
||||
transfer.ModuleName: {auth.Minter, auth.Burner},
|
||||
}
|
||||
|
||||
// module accounts that are allowed to receive tokens
|
||||
|
|
|
@ -24,7 +24,7 @@ import (
|
|||
"github.com/cosmos/cosmos-sdk/x/evidence"
|
||||
"github.com/cosmos/cosmos-sdk/x/gov"
|
||||
"github.com/cosmos/cosmos-sdk/x/ibc"
|
||||
transfer "github.com/cosmos/cosmos-sdk/x/ibc/20-transfer"
|
||||
transfer "github.com/cosmos/cosmos-sdk/x/ibc-transfer"
|
||||
"github.com/cosmos/cosmos-sdk/x/mint"
|
||||
paramtypes "github.com/cosmos/cosmos-sdk/x/params/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/simulation"
|
||||
|
|
|
@ -2,12 +2,12 @@ package transfer
|
|||
|
||||
// autogenerated code using github.com/rigelrozanski/multitool
|
||||
// aliases generated for the following subdirectories:
|
||||
// ALIASGEN: github.com/cosmos/cosmos-sdk/x/ibc/20-transfer/keeper
|
||||
// ALIASGEN: github.com/cosmos/cosmos-sdk/x/ibc/20-transfer/types
|
||||
// ALIASGEN: github.com/cosmos/cosmos-sdk/x/ibc-transfer/keeper
|
||||
// ALIASGEN: github.com/cosmos/cosmos-sdk/x/ibc-transfer/types
|
||||
|
||||
import (
|
||||
"github.com/cosmos/cosmos-sdk/x/ibc/20-transfer/keeper"
|
||||
"github.com/cosmos/cosmos-sdk/x/ibc/20-transfer/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/ibc-transfer/keeper"
|
||||
"github.com/cosmos/cosmos-sdk/x/ibc-transfer/types"
|
||||
)
|
||||
|
||||
const (
|
||||
|
@ -30,13 +30,12 @@ const (
|
|||
|
||||
var (
|
||||
// functions aliases
|
||||
NewKeeper = keeper.NewKeeper
|
||||
RegisterCodec = types.RegisterCodec
|
||||
GetEscrowAddress = types.GetEscrowAddress
|
||||
GetDenomPrefix = types.GetDenomPrefix
|
||||
GetModuleAccountName = types.GetModuleAccountName
|
||||
NewMsgTransfer = types.NewMsgTransfer
|
||||
RegisterInterfaces = types.RegisterInterfaces
|
||||
NewKeeper = keeper.NewKeeper
|
||||
RegisterCodec = types.RegisterCodec
|
||||
GetEscrowAddress = types.GetEscrowAddress
|
||||
GetDenomPrefix = types.GetDenomPrefix
|
||||
NewMsgTransfer = types.NewMsgTransfer
|
||||
RegisterInterfaces = types.RegisterInterfaces
|
||||
|
||||
// variable aliases
|
||||
ModuleCdc = types.ModuleCdc
|
|
@ -11,7 +11,7 @@ import (
|
|||
"github.com/cosmos/cosmos-sdk/client/flags"
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
"github.com/cosmos/cosmos-sdk/version"
|
||||
"github.com/cosmos/cosmos-sdk/x/ibc/20-transfer/client/utils"
|
||||
"github.com/cosmos/cosmos-sdk/x/ibc-transfer/client/utils"
|
||||
)
|
||||
|
||||
// GetCmdQueryNextSequence defines the command to query a next receive sequence
|
|
@ -12,7 +12,7 @@ import (
|
|||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
authclient "github.com/cosmos/cosmos-sdk/x/auth/client"
|
||||
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/ibc/20-transfer/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/ibc-transfer/types"
|
||||
)
|
||||
|
||||
// IBC transfer flags
|
|
@ -9,7 +9,7 @@ import (
|
|||
"github.com/cosmos/cosmos-sdk/client/context"
|
||||
"github.com/cosmos/cosmos-sdk/client/flags"
|
||||
"github.com/cosmos/cosmos-sdk/types/rest"
|
||||
"github.com/cosmos/cosmos-sdk/x/ibc/20-transfer/client/utils"
|
||||
"github.com/cosmos/cosmos-sdk/x/ibc-transfer/client/utils"
|
||||
)
|
||||
|
||||
func registerQueryRoutes(cliCtx context.CLIContext, r *mux.Router) {
|
|
@ -10,7 +10,7 @@ import (
|
|||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/types/rest"
|
||||
authclient "github.com/cosmos/cosmos-sdk/x/auth/client"
|
||||
"github.com/cosmos/cosmos-sdk/x/ibc/20-transfer/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/ibc-transfer/types"
|
||||
)
|
||||
|
||||
func registerTxRoutes(cliCtx context.CLIContext, r *mux.Router) {
|
|
@ -4,7 +4,7 @@ import (
|
|||
"fmt"
|
||||
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/ibc/20-transfer/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/ibc-transfer/types"
|
||||
)
|
||||
|
||||
// InitGenesis binds to portid from genesis state
|
||||
|
@ -25,7 +25,7 @@ func InitGenesis(ctx sdk.Context, keeper Keeper, state types.GenesisState) {
|
|||
// check if the module account exists
|
||||
moduleAcc := keeper.GetTransferAccount(ctx)
|
||||
if moduleAcc == nil {
|
||||
panic(fmt.Sprintf("%s module account has not been set", types.GetModuleAccountName()))
|
||||
panic(fmt.Sprintf("%s module account has not been set", ModuleName))
|
||||
}
|
||||
}
|
||||
|
|
@ -15,11 +15,11 @@ import (
|
|||
"github.com/cosmos/cosmos-sdk/simapp"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/bank"
|
||||
transfer "github.com/cosmos/cosmos-sdk/x/ibc-transfer"
|
||||
"github.com/cosmos/cosmos-sdk/x/ibc-transfer/types"
|
||||
connectiontypes "github.com/cosmos/cosmos-sdk/x/ibc/03-connection/types"
|
||||
channeltypes "github.com/cosmos/cosmos-sdk/x/ibc/04-channel/types"
|
||||
ibctmtypes "github.com/cosmos/cosmos-sdk/x/ibc/07-tendermint/types"
|
||||
transfer "github.com/cosmos/cosmos-sdk/x/ibc/20-transfer"
|
||||
"github.com/cosmos/cosmos-sdk/x/ibc/20-transfer/types"
|
||||
commitmenttypes "github.com/cosmos/cosmos-sdk/x/ibc/23-commitment/types"
|
||||
host "github.com/cosmos/cosmos-sdk/x/ibc/24-host"
|
||||
|
|
@ -10,9 +10,9 @@ import (
|
|||
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
|
||||
authexported "github.com/cosmos/cosmos-sdk/x/auth/exported"
|
||||
"github.com/cosmos/cosmos-sdk/x/capability"
|
||||
"github.com/cosmos/cosmos-sdk/x/ibc-transfer/types"
|
||||
channel "github.com/cosmos/cosmos-sdk/x/ibc/04-channel"
|
||||
channelexported "github.com/cosmos/cosmos-sdk/x/ibc/04-channel/exported"
|
||||
"github.com/cosmos/cosmos-sdk/x/ibc/20-transfer/types"
|
||||
host "github.com/cosmos/cosmos-sdk/x/ibc/24-host"
|
||||
)
|
||||
|
||||
|
@ -46,7 +46,7 @@ func NewKeeper(
|
|||
) Keeper {
|
||||
|
||||
// ensure ibc transfer module account is set
|
||||
if addr := authKeeper.GetModuleAddress(types.GetModuleAccountName()); addr == nil {
|
||||
if addr := authKeeper.GetModuleAddress(types.ModuleName); addr == nil {
|
||||
panic("the IBC transfer module account has not been set")
|
||||
}
|
||||
|
||||
|
@ -68,7 +68,7 @@ func (k Keeper) Logger(ctx sdk.Context) log.Logger {
|
|||
|
||||
// GetTransferAccount returns the ICS20 - transfers ModuleAccount
|
||||
func (k Keeper) GetTransferAccount(ctx sdk.Context) authexported.ModuleAccountI {
|
||||
return k.authKeeper.GetModuleAccount(ctx, types.GetModuleAccountName())
|
||||
return k.authKeeper.GetModuleAccount(ctx, types.ModuleName)
|
||||
}
|
||||
|
||||
// PacketExecuted defines a wrapper function for the channel Keeper's function
|
|
@ -14,10 +14,10 @@ import (
|
|||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
"github.com/cosmos/cosmos-sdk/simapp"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/ibc-transfer/types"
|
||||
connectiontypes "github.com/cosmos/cosmos-sdk/x/ibc/03-connection/types"
|
||||
channeltypes "github.com/cosmos/cosmos-sdk/x/ibc/04-channel/types"
|
||||
ibctmtypes "github.com/cosmos/cosmos-sdk/x/ibc/07-tendermint/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/ibc/20-transfer/types"
|
||||
commitmenttypes "github.com/cosmos/cosmos-sdk/x/ibc/23-commitment/types"
|
||||
host "github.com/cosmos/cosmos-sdk/x/ibc/24-host"
|
||||
|
||||
|
@ -87,13 +87,12 @@ func (suite *KeeperTestSuite) queryProof(key []byte) (proof commitmenttypes.Merk
|
|||
}
|
||||
|
||||
func (suite *KeeperTestSuite) TestGetTransferAccount() {
|
||||
expectedMaccName := types.GetModuleAccountName()
|
||||
expectedMaccAddr := sdk.AccAddress(crypto.AddressHash([]byte(expectedMaccName)))
|
||||
expectedMaccAddr := sdk.AccAddress(crypto.AddressHash([]byte(types.ModuleName)))
|
||||
|
||||
macc := suite.chainA.App.TransferKeeper.GetTransferAccount(suite.chainA.GetContext())
|
||||
|
||||
suite.NotNil(macc)
|
||||
suite.Equal(expectedMaccName, macc.GetName())
|
||||
suite.Equal(types.ModuleName, macc.GetName())
|
||||
suite.Equal(expectedMaccAddr, macc.GetAddress())
|
||||
}
|
||||
|
|
@ -5,8 +5,8 @@ import (
|
|||
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
|
||||
"github.com/cosmos/cosmos-sdk/x/ibc-transfer/types"
|
||||
channeltypes "github.com/cosmos/cosmos-sdk/x/ibc/04-channel/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/ibc/20-transfer/types"
|
||||
host "github.com/cosmos/cosmos-sdk/x/ibc/24-host"
|
||||
)
|
||||
|
||||
|
@ -107,14 +107,14 @@ func (k Keeper) createOutgoingPacket(
|
|||
|
||||
// transfer the coins to the module account and burn them
|
||||
if err := k.bankKeeper.SendCoinsFromAccountToModule(
|
||||
ctx, sender, types.GetModuleAccountName(), amount,
|
||||
ctx, sender, types.ModuleName, amount,
|
||||
); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// burn vouchers from the sender's balance if the source is from another chain
|
||||
if err := k.bankKeeper.BurnCoins(
|
||||
ctx, types.GetModuleAccountName(), amount,
|
||||
ctx, types.ModuleName, amount,
|
||||
); err != nil {
|
||||
// NOTE: should not happen as the module account was
|
||||
// retrieved on the step above and it has enough balace
|
||||
|
@ -161,14 +161,14 @@ func (k Keeper) OnRecvPacket(ctx sdk.Context, packet channeltypes.Packet, data t
|
|||
|
||||
// mint new tokens if the source of the transfer is the same chain
|
||||
if err := k.bankKeeper.MintCoins(
|
||||
ctx, types.GetModuleAccountName(), data.Amount,
|
||||
ctx, types.ModuleName, data.Amount,
|
||||
); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// send to receiver
|
||||
return k.bankKeeper.SendCoinsFromModuleToAccount(
|
||||
ctx, types.GetModuleAccountName(), receiver, data.Amount,
|
||||
ctx, types.ModuleName, receiver, data.Amount,
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -235,10 +235,10 @@ func (k Keeper) refundPacketAmount(ctx sdk.Context, packet channeltypes.Packet,
|
|||
|
||||
// mint vouchers back to sender
|
||||
if err := k.bankKeeper.MintCoins(
|
||||
ctx, types.GetModuleAccountName(), data.Amount,
|
||||
ctx, types.ModuleName, data.Amount,
|
||||
); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return k.bankKeeper.SendCoinsFromModuleToAccount(ctx, types.GetModuleAccountName(), sender, data.Amount)
|
||||
return k.bankKeeper.SendCoinsFromModuleToAccount(ctx, types.ModuleName, sender, data.Amount)
|
||||
}
|
|
@ -5,9 +5,9 @@ import (
|
|||
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/bank"
|
||||
"github.com/cosmos/cosmos-sdk/x/ibc-transfer/types"
|
||||
connection "github.com/cosmos/cosmos-sdk/x/ibc/03-connection"
|
||||
channeltypes "github.com/cosmos/cosmos-sdk/x/ibc/04-channel/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/ibc/20-transfer/types"
|
||||
host "github.com/cosmos/cosmos-sdk/x/ibc/24-host"
|
||||
)
|
||||
|
|
@ -18,14 +18,14 @@ import (
|
|||
"github.com/cosmos/cosmos-sdk/types/module"
|
||||
simtypes "github.com/cosmos/cosmos-sdk/types/simulation"
|
||||
"github.com/cosmos/cosmos-sdk/x/capability"
|
||||
"github.com/cosmos/cosmos-sdk/x/ibc-transfer/client/cli"
|
||||
"github.com/cosmos/cosmos-sdk/x/ibc-transfer/client/rest"
|
||||
"github.com/cosmos/cosmos-sdk/x/ibc-transfer/simulation"
|
||||
"github.com/cosmos/cosmos-sdk/x/ibc-transfer/types"
|
||||
channel "github.com/cosmos/cosmos-sdk/x/ibc/04-channel"
|
||||
channeltypes "github.com/cosmos/cosmos-sdk/x/ibc/04-channel/types"
|
||||
port "github.com/cosmos/cosmos-sdk/x/ibc/05-port"
|
||||
porttypes "github.com/cosmos/cosmos-sdk/x/ibc/05-port/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/ibc/20-transfer/client/cli"
|
||||
"github.com/cosmos/cosmos-sdk/x/ibc/20-transfer/client/rest"
|
||||
"github.com/cosmos/cosmos-sdk/x/ibc/20-transfer/simulation"
|
||||
"github.com/cosmos/cosmos-sdk/x/ibc/20-transfer/types"
|
||||
host "github.com/cosmos/cosmos-sdk/x/ibc/24-host"
|
||||
)
|
||||
|
|
@ -8,7 +8,7 @@ import (
|
|||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
"github.com/cosmos/cosmos-sdk/types/module"
|
||||
simtypes "github.com/cosmos/cosmos-sdk/types/simulation"
|
||||
"github.com/cosmos/cosmos-sdk/x/ibc/20-transfer/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/ibc-transfer/types"
|
||||
)
|
||||
|
||||
// Simulation parameter constants
|
|
@ -10,8 +10,8 @@ import (
|
|||
|
||||
// RegisterCodec registers the IBC transfer types
|
||||
func RegisterCodec(cdc *codec.Codec) {
|
||||
cdc.RegisterConcrete(MsgTransfer{}, "ibc/transfer/MsgTransfer", nil)
|
||||
cdc.RegisterConcrete(FungibleTokenPacketData{}, "ibc/transfer/PacketDataTransfer", nil)
|
||||
cdc.RegisterConcrete(MsgTransfer{}, "cosmos-sdk/MsgTransfer", nil)
|
||||
cdc.RegisterConcrete(FungibleTokenPacketData{}, "cosmos-sdk/PacketDataTransfer", nil)
|
||||
}
|
||||
|
||||
// RegisterInterfaces register the ibc transfer module interfaces to protobuf
|
||||
|
@ -23,11 +23,11 @@ func RegisterInterfaces(registry cdctypes.InterfaceRegistry) {
|
|||
var (
|
||||
amino = codec.New()
|
||||
|
||||
// ModuleCdc references the global x/ibc/20-transfer module codec. Note, the codec
|
||||
// ModuleCdc references the global x/transfer module codec. Note, the codec
|
||||
// should ONLY be used in certain instances of tests and for JSON encoding as Amino
|
||||
// is still used for that purpose.
|
||||
//
|
||||
// The actual codec used for serialization should be provided to x/ibc/20-transfer and
|
||||
// The actual codec used for serialization should be provided to x/transfer and
|
||||
// defined at the application level.
|
||||
ModuleCdc = codec.NewHybridCodec(amino, cdctypes.NewInterfaceRegistry())
|
||||
)
|
|
@ -5,7 +5,7 @@ import (
|
|||
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/x/ibc/20-transfer/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/ibc-transfer/types"
|
||||
)
|
||||
|
||||
func TestValidateGenesis(t *testing.T) {
|
|
@ -6,7 +6,6 @@ import (
|
|||
"github.com/tendermint/tendermint/crypto"
|
||||
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
host "github.com/cosmos/cosmos-sdk/x/ibc/24-host"
|
||||
)
|
||||
|
||||
const (
|
||||
|
@ -46,8 +45,3 @@ func GetEscrowAddress(portID, channelID string) sdk.AccAddress {
|
|||
func GetDenomPrefix(portID, channelID string) string {
|
||||
return fmt.Sprintf("%s/%s/", portID, channelID)
|
||||
}
|
||||
|
||||
// GetModuleAccountName returns the IBC transfer module account name for supply
|
||||
func GetModuleAccountName() string {
|
||||
return fmt.Sprintf("%s/%s", host.ModuleName, ModuleName)
|
||||
}
|
|
@ -96,7 +96,7 @@ func TestMsgTransferGetSignBytes(t *testing.T) {
|
|||
msg := NewMsgTransfer(validPort, validChannel, 10, coins, addr1, addr2)
|
||||
res := msg.GetSignBytes()
|
||||
|
||||
expected := `{"type":"ibc/transfer/MsgTransfer","value":{"amount":[{"amount":"100","denom":"atom"}],"destination_height":"10","receiver":"cosmos1w3jhxarpv3j8yvs7f9y7g","sender":"cosmos1w3jhxarpv3j8yvg4ufs4x","source_channel":"testchannel","source_port":"testportid"}}`
|
||||
expected := `{"type":"cosmos-sdk/MsgTransfer","value":{"amount":[{"amount":"100","denom":"atom"}],"destination_height":"10","receiver":"cosmos1w3jhxarpv3j8yvs7f9y7g","sender":"cosmos1w3jhxarpv3j8yvg4ufs4x","source_channel":"testchannel","source_port":"testportid"}}`
|
||||
require.Equal(t, expected, string(res))
|
||||
}
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
// Code generated by protoc-gen-gogo. DO NOT EDIT.
|
||||
// source: x/ibc/20-transfer/types/types.proto
|
||||
// source: x/ibc-transfer/types/types.proto
|
||||
|
||||
package types
|
||||
|
||||
|
@ -46,7 +46,7 @@ func (m *MsgTransfer) Reset() { *m = MsgTransfer{} }
|
|||
func (m *MsgTransfer) String() string { return proto.CompactTextString(m) }
|
||||
func (*MsgTransfer) ProtoMessage() {}
|
||||
func (*MsgTransfer) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_2979e3085e18bdce, []int{0}
|
||||
return fileDescriptor_36db19b72d57f809, []int{0}
|
||||
}
|
||||
func (m *MsgTransfer) XXX_Unmarshal(b []byte) error {
|
||||
return m.Unmarshal(b)
|
||||
|
@ -132,7 +132,7 @@ func (m *FungibleTokenPacketData) Reset() { *m = FungibleTokenPacketData
|
|||
func (m *FungibleTokenPacketData) String() string { return proto.CompactTextString(m) }
|
||||
func (*FungibleTokenPacketData) ProtoMessage() {}
|
||||
func (*FungibleTokenPacketData) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_2979e3085e18bdce, []int{1}
|
||||
return fileDescriptor_36db19b72d57f809, []int{1}
|
||||
}
|
||||
func (m *FungibleTokenPacketData) XXX_Unmarshal(b []byte) error {
|
||||
return m.Unmarshal(b)
|
||||
|
@ -194,7 +194,7 @@ func (m *FungibleTokenPacketAcknowledgement) Reset() { *m = FungibleToke
|
|||
func (m *FungibleTokenPacketAcknowledgement) String() string { return proto.CompactTextString(m) }
|
||||
func (*FungibleTokenPacketAcknowledgement) ProtoMessage() {}
|
||||
func (*FungibleTokenPacketAcknowledgement) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_2979e3085e18bdce, []int{2}
|
||||
return fileDescriptor_36db19b72d57f809, []int{2}
|
||||
}
|
||||
func (m *FungibleTokenPacketAcknowledgement) XXX_Unmarshal(b []byte) error {
|
||||
return m.Unmarshal(b)
|
||||
|
@ -238,48 +238,45 @@ func (m *FungibleTokenPacketAcknowledgement) GetError() string {
|
|||
}
|
||||
|
||||
func init() {
|
||||
proto.RegisterType((*MsgTransfer)(nil), "cosmos_sdk.x.ibc.transfer.v1.MsgTransfer")
|
||||
proto.RegisterType((*FungibleTokenPacketData)(nil), "cosmos_sdk.x.ibc.transfer.v1.FungibleTokenPacketData")
|
||||
proto.RegisterType((*FungibleTokenPacketAcknowledgement)(nil), "cosmos_sdk.x.ibc.transfer.v1.FungibleTokenPacketAcknowledgement")
|
||||
proto.RegisterType((*MsgTransfer)(nil), "cosmos_sdk.x.transfer.v1.MsgTransfer")
|
||||
proto.RegisterType((*FungibleTokenPacketData)(nil), "cosmos_sdk.x.transfer.v1.FungibleTokenPacketData")
|
||||
proto.RegisterType((*FungibleTokenPacketAcknowledgement)(nil), "cosmos_sdk.x.transfer.v1.FungibleTokenPacketAcknowledgement")
|
||||
}
|
||||
|
||||
func init() {
|
||||
proto.RegisterFile("x/ibc/20-transfer/types/types.proto", fileDescriptor_2979e3085e18bdce)
|
||||
}
|
||||
func init() { proto.RegisterFile("x/ibc-transfer/types/types.proto", fileDescriptor_36db19b72d57f809) }
|
||||
|
||||
var fileDescriptor_2979e3085e18bdce = []byte{
|
||||
// 487 bytes of a gzipped FileDescriptorProto
|
||||
var fileDescriptor_36db19b72d57f809 = []byte{
|
||||
// 480 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x53, 0xc1, 0x6e, 0xd3, 0x40,
|
||||
0x10, 0x8d, 0x49, 0x1b, 0xca, 0x06, 0x90, 0xba, 0x40, 0x71, 0x23, 0xb0, 0x23, 0x23, 0x21, 0x5f,
|
||||
0x62, 0x37, 0x05, 0x09, 0x89, 0x13, 0x71, 0x11, 0x02, 0x09, 0x50, 0x65, 0xe5, 0x84, 0x84, 0x22,
|
||||
0x7b, 0x3d, 0xd8, 0x2b, 0xc7, 0xbb, 0xd1, 0xee, 0x3a, 0x34, 0x7f, 0xc1, 0x07, 0xf0, 0x05, 0x88,
|
||||
0x0f, 0xe9, 0xb1, 0x47, 0x4e, 0x06, 0x25, 0x7f, 0x90, 0x23, 0x27, 0x54, 0xdb, 0x29, 0x81, 0x16,
|
||||
0xc4, 0x85, 0x8b, 0xed, 0x37, 0x33, 0xef, 0x79, 0xde, 0xec, 0x2c, 0xba, 0x77, 0xe4, 0xd2, 0x90,
|
||||
0xb8, 0xfb, 0x7b, 0x3d, 0x25, 0x02, 0x26, 0xdf, 0x81, 0x70, 0xd5, 0x6c, 0x02, 0xb2, 0x7a, 0x3a,
|
||||
0x13, 0xc1, 0x15, 0xc7, 0x77, 0x08, 0x97, 0x19, 0x97, 0x23, 0x19, 0xa5, 0xce, 0x91, 0x43, 0x43,
|
||||
0xe2, 0xac, 0x8a, 0x9d, 0x69, 0xbf, 0x73, 0x5f, 0x25, 0x54, 0x44, 0xa3, 0x49, 0x20, 0xd4, 0xcc,
|
||||
0x2d, 0x09, 0x6e, 0xcc, 0x63, 0xfe, 0xf3, 0xab, 0x52, 0xe9, 0x6c, 0x9f, 0x13, 0xb6, 0x3e, 0x36,
|
||||
0x51, 0xfb, 0x95, 0x8c, 0x87, 0xb5, 0x1a, 0x7e, 0x84, 0xda, 0x92, 0xe7, 0x82, 0xc0, 0x68, 0xc2,
|
||||
0x85, 0xd2, 0xb5, 0xae, 0x66, 0x5f, 0xf1, 0x76, 0x96, 0x85, 0x89, 0x67, 0x41, 0x36, 0x7e, 0x6c,
|
||||
0xad, 0x25, 0x2d, 0x1f, 0x55, 0xe8, 0x90, 0x0b, 0x85, 0x9f, 0xa0, 0xeb, 0x75, 0x8e, 0x24, 0x01,
|
||||
0x63, 0x30, 0xd6, 0x2f, 0x95, 0xdc, 0xdd, 0x65, 0x61, 0xde, 0xfa, 0x85, 0x5b, 0xe7, 0x2d, 0xff,
|
||||
0x5a, 0x15, 0x38, 0xa8, 0x30, 0x7e, 0x89, 0x70, 0x04, 0x52, 0x51, 0x16, 0x28, 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 0x90, 0x01, 0x53, 0x58,
|
||||
0x47, 0x97, 0x65, 0x4e, 0x08, 0x48, 0x59, 0xee, 0xd7, 0x96, 0xbf, 0x82, 0xf8, 0x26, 0xda, 0x04,
|
||||
0x21, 0xf8, 0xea, 0x97, 0x15, 0xf0, 0x5e, 0x1f, 0xcf, 0x0d, 0xed, 0x64, 0x6e, 0x68, 0xdf, 0xe6,
|
||||
0x86, 0xf6, 0x61, 0x61, 0x34, 0x4e, 0x16, 0x46, 0xe3, 0xcb, 0xc2, 0x68, 0xbc, 0x79, 0xf8, 0x57,
|
||||
0x57, 0x7f, 0xb8, 0x58, 0x61, 0xab, 0x5c, 0xfd, 0x07, 0x3f, 0x02, 0x00, 0x00, 0xff, 0xff, 0x05,
|
||||
0x59, 0xe4, 0x6c, 0x7a, 0x03, 0x00, 0x00,
|
||||
0x10, 0x8d, 0x49, 0x1b, 0xca, 0x06, 0x90, 0xba, 0x40, 0x71, 0x23, 0x61, 0x47, 0x3e, 0x20, 0x5f,
|
||||
0x62, 0x13, 0x38, 0x20, 0x71, 0x22, 0x2e, 0x42, 0x20, 0x40, 0xaa, 0xac, 0x9c, 0x90, 0x50, 0xb4,
|
||||
0x59, 0x0f, 0xf6, 0xca, 0xf1, 0x6e, 0xb4, 0xbb, 0x0e, 0xcd, 0x5f, 0xf0, 0x01, 0x7c, 0x01, 0xe2,
|
||||
0x43, 0x7a, 0xec, 0x91, 0x93, 0x41, 0xc9, 0x1f, 0xe4, 0xc8, 0x09, 0xd5, 0x76, 0x4a, 0xa0, 0x11,
|
||||
0xe2, 0xc2, 0xc5, 0xf6, 0x9b, 0x79, 0xf3, 0x3c, 0x6f, 0x76, 0x16, 0x75, 0x4f, 0x7c, 0x36, 0xa6,
|
||||
0x3d, 0x2d, 0x09, 0x57, 0xef, 0x41, 0xfa, 0x7a, 0x3e, 0x05, 0x55, 0x3d, 0xbd, 0xa9, 0x14, 0x5a,
|
||||
0x60, 0x93, 0x0a, 0x95, 0x09, 0x35, 0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0xf9, 0xd8, 0xa3, 0x22, 0xf3, 0x2b, 0x5a, 0xfd, 0xea, 0xa9, 0x28,
|
||||
0xad, 0xe7, 0x75, 0x5e, 0xa0, 0xc2, 0x5a, 0x14, 0xbf, 0x44, 0x2d, 0x05, 0x3c, 0x02, 0x69, 0xee,
|
||||
0x76, 0x0d, 0xf7, 0x7a, 0xd0, 0xff, 0x51, 0xd8, 0xbd, 0x7f, 0x50, 0x19, 0x50, 0x3a, 0x88, 0x22,
|
||||
0x09, 0x4a, 0x85, 0xb5, 0x00, 0xee, 0xa0, 0x3d, 0x09, 0x14, 0xd8, 0x0c, 0xa4, 0xd9, 0x3a, 0x9f,
|
||||
0x59, 0x78, 0x81, 0x9d, 0x2f, 0x06, 0xba, 0xfb, 0x3c, 0xe7, 0x31, 0x1b, 0x4f, 0x60, 0x28, 0x52,
|
||||
0xe0, 0xc7, 0x84, 0xa6, 0xa0, 0x9f, 0x11, 0x4d, 0x36, 0x1c, 0x1a, 0xff, 0xc3, 0xe1, 0xc1, 0x85,
|
||||
0xc3, 0xf2, 0x20, 0xb7, 0xb6, 0xdb, 0xfc, 0xa3, 0xdd, 0x21, 0x72, 0xb6, 0x74, 0x3b, 0xa0, 0x29,
|
||||
0x17, 0x1f, 0x26, 0x10, 0xc5, 0x90, 0x01, 0xd7, 0xd8, 0x44, 0x57, 0x55, 0x4e, 0x29, 0x28, 0x55,
|
||||
0xee, 0xd7, 0x5e, 0xb8, 0x86, 0xf8, 0x36, 0xda, 0x05, 0x29, 0xc5, 0xfa, 0x97, 0x15, 0x08, 0x5e,
|
||||
0x9d, 0x2e, 0x2c, 0xe3, 0x6c, 0x61, 0x19, 0xdf, 0x17, 0x96, 0xf1, 0x71, 0x69, 0x35, 0xce, 0x96,
|
||||
0x56, 0xe3, 0xeb, 0xd2, 0x6a, 0xbc, 0xed, 0xff, 0xd5, 0xd5, 0xb6, 0x1b, 0x35, 0x6e, 0x95, 0x7b,
|
||||
0xff, 0xe8, 0x67, 0x00, 0x00, 0x00, 0xff, 0xff, 0x39, 0x62, 0x70, 0xeb, 0x70, 0x03, 0x00, 0x00,
|
||||
}
|
||||
|
||||
func (m *MsgTransfer) Marshal() (dAtA []byte, err error) {
|
|
@ -1,7 +1,7 @@
|
|||
syntax = "proto3";
|
||||
package cosmos_sdk.x.ibc.transfer.v1;
|
||||
package cosmos_sdk.x.transfer.v1;
|
||||
|
||||
option go_package = "github.com/cosmos/cosmos-sdk/x/ibc/20-transfer/types";
|
||||
option go_package = "github.com/cosmos/cosmos-sdk/x/ibc-transfer/types";
|
||||
|
||||
import "third_party/proto/gogoproto/gogo.proto";
|
||||
import "types/types.proto";
|
|
@ -4,10 +4,10 @@ import (
|
|||
"fmt"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/x/capability"
|
||||
transfertypes "github.com/cosmos/cosmos-sdk/x/ibc-transfer/types"
|
||||
connection "github.com/cosmos/cosmos-sdk/x/ibc/03-connection"
|
||||
"github.com/cosmos/cosmos-sdk/x/ibc/04-channel/exported"
|
||||
"github.com/cosmos/cosmos-sdk/x/ibc/04-channel/types"
|
||||
transfertypes "github.com/cosmos/cosmos-sdk/x/ibc/20-transfer/types"
|
||||
host "github.com/cosmos/cosmos-sdk/x/ibc/24-host"
|
||||
)
|
||||
|
||||
|
|
|
@ -44,7 +44,7 @@ in the SDK's `x/ibc` module:
|
|||
* [ICS 007 - Tendermint Client](https://github.com/cosmos/ics/blob/master/spec/ics-007-tendermint-client): Implemented in [`x/ibc/07-tendermint`](https://github.com/cosmos/x/ibc/07-tendermint)
|
||||
* [ICS 009 - Loopback Client](https://github.com/cosmos/ics/blob/master/spec/ics-009-loopback-client): To be implemented in [`x/ibc/09-loopback`](https://github.com/cosmos/x/ibc/09-loopback)
|
||||
* [ICS 018- Relayer Algorithms](https://github.com/cosmos/ics/tree/master/spec/ics-018-relayer-algorithms): Implemented in it's own [relayer repository](https://github.com/cosmos/relayer)
|
||||
* [ICS 020 - Fungible Token Transfer](https://github.com/cosmos/ics/tree/master/spec/ics-020-fungible-token-transfer): Implemented in [`x/ibc/20-transfer`](https://github.com/cosmos/x/ibc/20-transfer)
|
||||
* [ICS 020 - Fungible Token Transfer](https://github.com/cosmos/ics/tree/master/spec/ics-020-fungible-token-transfer): Implemented in [`x/transfer`](https://github.com/cosmos/x/transfer)
|
||||
* [ICS 023 - Vector Commitments](https://github.com/cosmos/ics/tree/master/spec/ics-023-vector-commitments): Implemented in [`x/ibc/23-commitment`](https://github.com/cosmos/x/ibc/23-commitment)
|
||||
* [ICS 024 - Host Requirements](https://github.com/cosmos/ics/tree/master/spec/ics-024-host-requirements): Implemented in [`x/ibc/24-host`](https://github.com/cosmos/x/ibc/24-host)
|
||||
* [ICS 025 - Handler Interface](https://github.com/cosmos/ics/tree/master/spec/ics-025-handler-interface): Handler interfaces are implemented at the top level in `x/ibc/handler.go`,
|
||||
|
|
|
@ -0,0 +1,311 @@
|
|||
package transfer_test
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/stretchr/testify/suite"
|
||||
|
||||
abci "github.com/tendermint/tendermint/abci/types"
|
||||
lite "github.com/tendermint/tendermint/lite2"
|
||||
tmtypes "github.com/tendermint/tendermint/types"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
"github.com/cosmos/cosmos-sdk/simapp"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/bank"
|
||||
transfer "github.com/cosmos/cosmos-sdk/x/ibc-transfer"
|
||||
"github.com/cosmos/cosmos-sdk/x/ibc-transfer/types"
|
||||
connectiontypes "github.com/cosmos/cosmos-sdk/x/ibc/03-connection/types"
|
||||
channeltypes "github.com/cosmos/cosmos-sdk/x/ibc/04-channel/types"
|
||||
ibctmtypes "github.com/cosmos/cosmos-sdk/x/ibc/07-tendermint/types"
|
||||
commitmenttypes "github.com/cosmos/cosmos-sdk/x/ibc/23-commitment/types"
|
||||
host "github.com/cosmos/cosmos-sdk/x/ibc/24-host"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/x/staking"
|
||||
)
|
||||
|
||||
// define constants used for testing
|
||||
const (
|
||||
testClientIDA = "testclientida"
|
||||
testClientIDB = "testclientidb"
|
||||
|
||||
testConnection = "testconnection"
|
||||
testPort1 = "bank"
|
||||
testPort2 = "testportid"
|
||||
testChannel1 = "firstchannel"
|
||||
testChannel2 = "secondchannel"
|
||||
|
||||
trustingPeriod time.Duration = time.Hour * 24 * 7 * 2
|
||||
ubdPeriod time.Duration = time.Hour * 24 * 7 * 3
|
||||
maxClockDrift time.Duration = time.Second * 10
|
||||
)
|
||||
|
||||
// define variables used for testing
|
||||
var (
|
||||
testAddr1 = sdk.AccAddress([]byte("testaddr1"))
|
||||
testAddr2 = sdk.AccAddress([]byte("testaddr2"))
|
||||
|
||||
testCoins, _ = sdk.ParseCoins("100atom")
|
||||
testPrefixedCoins1, _ = sdk.ParseCoins(fmt.Sprintf("100%satom", types.GetDenomPrefix(testPort1, testChannel1)))
|
||||
testPrefixedCoins2, _ = sdk.ParseCoins(fmt.Sprintf("100%satom", types.GetDenomPrefix(testPort2, testChannel2)))
|
||||
)
|
||||
|
||||
type HandlerTestSuite struct {
|
||||
suite.Suite
|
||||
|
||||
cdc *codec.Codec
|
||||
|
||||
chainA *TestChain
|
||||
chainB *TestChain
|
||||
}
|
||||
|
||||
func (suite *HandlerTestSuite) SetupTest() {
|
||||
suite.chainA = NewTestChain(testClientIDA)
|
||||
suite.chainB = NewTestChain(testClientIDB)
|
||||
|
||||
suite.cdc = suite.chainA.App.Codec()
|
||||
}
|
||||
|
||||
func (suite *HandlerTestSuite) TestHandleMsgTransfer() {
|
||||
handler := transfer.NewHandler(suite.chainA.App.TransferKeeper)
|
||||
|
||||
// create channel capability from ibc scoped keeper and claim with transfer scoped keeper
|
||||
capName := host.ChannelCapabilityPath(testPort1, testChannel1)
|
||||
cap, err := suite.chainA.App.ScopedIBCKeeper.NewCapability(suite.chainA.GetContext(), capName)
|
||||
suite.Require().Nil(err, "could not create capability")
|
||||
err = suite.chainA.App.ScopedTransferKeeper.ClaimCapability(suite.chainA.GetContext(), cap, capName)
|
||||
suite.Require().Nil(err, "transfer module could not claim capability")
|
||||
|
||||
ctx := suite.chainA.GetContext()
|
||||
msg := transfer.NewMsgTransfer(testPort1, testChannel1, 10, testPrefixedCoins2, testAddr1, testAddr2.String())
|
||||
res, err := handler(ctx, msg)
|
||||
suite.Require().Error(err)
|
||||
suite.Require().Nil(res, "%+v", res) // channel does not exist
|
||||
|
||||
// Setup channel from A to B
|
||||
suite.chainA.CreateClient(suite.chainB)
|
||||
suite.chainA.createConnection(testConnection, testConnection, testClientIDB, testClientIDA, connectiontypes.OPEN)
|
||||
suite.chainA.createChannel(testPort1, testChannel1, testPort2, testChannel2, channeltypes.OPEN, channeltypes.ORDERED, testConnection)
|
||||
|
||||
res, err = handler(ctx, msg)
|
||||
suite.Require().Error(err)
|
||||
suite.Require().Nil(res, "%+v", res) // next send sequence not found
|
||||
|
||||
nextSeqSend := uint64(1)
|
||||
suite.chainA.App.IBCKeeper.ChannelKeeper.SetNextSequenceSend(ctx, testPort1, testChannel1, nextSeqSend)
|
||||
res, err = handler(ctx, msg)
|
||||
suite.Require().Error(err)
|
||||
suite.Require().Nil(res, "%+v", res) // sender has insufficient coins
|
||||
|
||||
_ = suite.chainA.App.BankKeeper.SetBalances(ctx, testAddr1, testCoins)
|
||||
res, err = handler(ctx, msg)
|
||||
suite.Require().NoError(err)
|
||||
suite.Require().NotNil(res, "%+v", res) // successfully executed
|
||||
|
||||
// test when the source is false
|
||||
msg = transfer.NewMsgTransfer(testPort1, testChannel1, 10, testPrefixedCoins2, testAddr1, testAddr2.String())
|
||||
_ = suite.chainA.App.BankKeeper.SetBalances(ctx, testAddr1, testPrefixedCoins2)
|
||||
|
||||
res, err = handler(ctx, msg)
|
||||
suite.Require().Error(err)
|
||||
suite.Require().Nil(res, "%+v", res) // incorrect denom prefix
|
||||
|
||||
msg = transfer.NewMsgTransfer(testPort1, testChannel1, 10, testPrefixedCoins1, testAddr1, testAddr2.String())
|
||||
suite.chainA.App.BankKeeper.SetSupply(ctx, bank.NewSupply(testPrefixedCoins1))
|
||||
_ = suite.chainA.App.BankKeeper.SetBalances(ctx, testAddr1, testPrefixedCoins1)
|
||||
|
||||
res, err = handler(ctx, msg)
|
||||
suite.Require().NoError(err)
|
||||
suite.Require().NotNil(res, "%+v", res) // successfully executed
|
||||
}
|
||||
|
||||
func TestHandlerTestSuite(t *testing.T) {
|
||||
suite.Run(t, new(HandlerTestSuite))
|
||||
}
|
||||
|
||||
type TestChain struct {
|
||||
ClientID string
|
||||
App *simapp.SimApp
|
||||
Header ibctmtypes.Header
|
||||
Vals *tmtypes.ValidatorSet
|
||||
Signers []tmtypes.PrivValidator
|
||||
}
|
||||
|
||||
func NewTestChain(clientID string) *TestChain {
|
||||
privVal := tmtypes.NewMockPV()
|
||||
|
||||
pubKey, err := privVal.GetPubKey()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
validator := tmtypes.NewValidator(pubKey, 1)
|
||||
valSet := tmtypes.NewValidatorSet([]*tmtypes.Validator{validator})
|
||||
signers := []tmtypes.PrivValidator{privVal}
|
||||
now := time.Date(2020, 1, 2, 0, 0, 0, 0, time.UTC)
|
||||
|
||||
header := ibctmtypes.CreateTestHeader(clientID, 1, now, valSet, signers)
|
||||
|
||||
return &TestChain{
|
||||
ClientID: clientID,
|
||||
App: simapp.Setup(false),
|
||||
Header: header,
|
||||
Vals: valSet,
|
||||
Signers: signers,
|
||||
}
|
||||
}
|
||||
|
||||
// Creates simple context for testing purposes
|
||||
func (chain *TestChain) GetContext() sdk.Context {
|
||||
return chain.App.BaseApp.NewContext(false, abci.Header{ChainID: chain.Header.SignedHeader.Header.ChainID, Height: chain.Header.SignedHeader.Header.Height})
|
||||
}
|
||||
|
||||
// createClient will create a client for clientChain on targetChain
|
||||
func (chain *TestChain) CreateClient(client *TestChain) error {
|
||||
client.Header = nextHeader(client)
|
||||
// Commit and create a new block on appTarget to get a fresh CommitID
|
||||
client.App.Commit()
|
||||
commitID := client.App.LastCommitID()
|
||||
client.App.BeginBlock(abci.RequestBeginBlock{Header: abci.Header{Height: client.Header.SignedHeader.Header.Height, Time: client.Header.Time}})
|
||||
|
||||
// Set HistoricalInfo on client chain after Commit
|
||||
ctxClient := client.GetContext()
|
||||
validator := staking.NewValidator(
|
||||
sdk.ValAddress(client.Vals.Validators[0].Address), client.Vals.Validators[0].PubKey, staking.Description{},
|
||||
)
|
||||
validator.Status = sdk.Bonded
|
||||
validator.Tokens = sdk.NewInt(1000000) // get one voting power
|
||||
validators := []staking.Validator{validator}
|
||||
histInfo := staking.HistoricalInfo{
|
||||
Header: abci.Header{
|
||||
AppHash: commitID.Hash,
|
||||
},
|
||||
Valset: validators,
|
||||
}
|
||||
client.App.StakingKeeper.SetHistoricalInfo(ctxClient, client.Header.SignedHeader.Header.Height, histInfo)
|
||||
|
||||
// Create target ctx
|
||||
ctxTarget := chain.GetContext()
|
||||
|
||||
// create client
|
||||
clientState, err := ibctmtypes.Initialize(client.ClientID, lite.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, client.Header)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
_, err = chain.App.IBCKeeper.ClientKeeper.CreateClient(ctxTarget, clientState, client.Header.ConsensusState())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
|
||||
// _, _, err := simapp.SignCheckDeliver(
|
||||
// suite.T(),
|
||||
// suite.cdc,
|
||||
// suite.app.BaseApp,
|
||||
// ctx.BlockHeader(),
|
||||
// []sdk.Msg{clienttypes.NewMsgCreateClient(clientID, clientexported.ClientTypeTendermint, consState, accountAddress)},
|
||||
// []uint64{baseAccount.GetAccountNumber()},
|
||||
// []uint64{baseAccount.GetSequence()},
|
||||
// true, true, accountPrivKey,
|
||||
// )
|
||||
}
|
||||
|
||||
// nolint: unused
|
||||
func (chain *TestChain) updateClient(client *TestChain) {
|
||||
// Create target ctx
|
||||
ctxTarget := chain.GetContext()
|
||||
|
||||
// if clientState does not already exist, return without updating
|
||||
_, found := chain.App.IBCKeeper.ClientKeeper.GetClientState(
|
||||
ctxTarget, client.ClientID,
|
||||
)
|
||||
if !found {
|
||||
return
|
||||
}
|
||||
|
||||
// always commit when updateClient and begin a new block
|
||||
client.App.Commit()
|
||||
commitID := client.App.LastCommitID()
|
||||
|
||||
client.Header = nextHeader(client)
|
||||
client.App.BeginBlock(abci.RequestBeginBlock{Header: abci.Header{Height: client.Header.SignedHeader.Header.Height, Time: client.Header.Time}})
|
||||
|
||||
// Set HistoricalInfo on client chain after Commit
|
||||
ctxClient := client.GetContext()
|
||||
validator := staking.NewValidator(
|
||||
sdk.ValAddress(client.Vals.Validators[0].Address), client.Vals.Validators[0].PubKey, staking.Description{},
|
||||
)
|
||||
validator.Status = sdk.Bonded
|
||||
validator.Tokens = sdk.NewInt(1000000)
|
||||
validators := []staking.Validator{validator}
|
||||
histInfo := staking.HistoricalInfo{
|
||||
Header: abci.Header{
|
||||
AppHash: commitID.Hash,
|
||||
},
|
||||
Valset: validators,
|
||||
}
|
||||
client.App.StakingKeeper.SetHistoricalInfo(ctxClient, client.Header.SignedHeader.Header.Height, histInfo)
|
||||
|
||||
consensusState := ibctmtypes.ConsensusState{
|
||||
Height: uint64(client.Header.SignedHeader.Header.Height),
|
||||
Timestamp: client.Header.Time,
|
||||
Root: commitmenttypes.NewMerkleRoot(commitID.Hash),
|
||||
ValidatorSet: client.Vals,
|
||||
}
|
||||
|
||||
chain.App.IBCKeeper.ClientKeeper.SetClientConsensusState(
|
||||
ctxTarget, client.ClientID, uint64(client.Header.SignedHeader.Header.Height), consensusState,
|
||||
)
|
||||
chain.App.IBCKeeper.ClientKeeper.SetClientState(
|
||||
ctxTarget, ibctmtypes.NewClientState(client.ClientID, lite.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, client.Header),
|
||||
)
|
||||
|
||||
// _, _, err := simapp.SignCheckDeliver(
|
||||
// suite.T(),
|
||||
// suite.cdc,
|
||||
// suite.app.BaseApp,
|
||||
// ctx.BlockHeader(),
|
||||
// []sdk.Msg{clienttypes.NewMsgUpdateClient(clientID, suite.header, accountAddress)},
|
||||
// []uint64{baseAccount.GetAccountNumber()},
|
||||
// []uint64{baseAccount.GetSequence()},
|
||||
// true, true, accountPrivKey,
|
||||
// )
|
||||
// suite.Require().NoError(err)
|
||||
}
|
||||
|
||||
func (chain *TestChain) createConnection(
|
||||
connID, counterpartyConnID, clientID, counterpartyClientID string,
|
||||
state connectiontypes.State,
|
||||
) connectiontypes.ConnectionEnd {
|
||||
counterparty := connectiontypes.NewCounterparty(counterpartyClientID, counterpartyConnID, commitmenttypes.NewMerklePrefix(chain.App.IBCKeeper.ConnectionKeeper.GetCommitmentPrefix().Bytes()))
|
||||
connection := connectiontypes.ConnectionEnd{
|
||||
State: state,
|
||||
ClientID: clientID,
|
||||
Counterparty: counterparty,
|
||||
Versions: connectiontypes.GetCompatibleVersions(),
|
||||
}
|
||||
ctx := chain.GetContext()
|
||||
chain.App.IBCKeeper.ConnectionKeeper.SetConnection(ctx, connID, connection)
|
||||
return connection
|
||||
}
|
||||
|
||||
// nolint: unused
|
||||
func (chain *TestChain) createChannel(
|
||||
portID, channelID, counterpartyPortID, counterpartyChannelID string,
|
||||
state channeltypes.State, order channeltypes.Order, connectionID string,
|
||||
) channeltypes.Channel {
|
||||
counterparty := channeltypes.NewCounterparty(counterpartyPortID, counterpartyChannelID)
|
||||
channel := channeltypes.NewChannel(state, order, counterparty,
|
||||
[]string{connectionID}, "1.0",
|
||||
)
|
||||
ctx := chain.GetContext()
|
||||
chain.App.IBCKeeper.ChannelKeeper.SetChannel(ctx, portID, channelID, channel)
|
||||
return channel
|
||||
}
|
||||
|
||||
func nextHeader(chain *TestChain) ibctmtypes.Header {
|
||||
return ibctmtypes.CreateTestHeader(chain.Header.SignedHeader.Header.ChainID, chain.Header.SignedHeader.Header.Height+1,
|
||||
chain.Header.Time.Add(time.Minute), chain.Vals, chain.Signers)
|
||||
}
|
Loading…
Reference in New Issue