feat(auth): allow BaseAccounts to be migrated to x/accounts (#21820)

Co-authored-by: Akhil Kumar P <36399231+akhilkumarpilli@users.noreply.github.com>
This commit is contained in:
testinginprod 2024-09-23 23:22:01 +02:00 committed by GitHub
parent 0202d71f70
commit ebbaa0e92e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
18 changed files with 2229 additions and 149 deletions

View File

@ -946,6 +946,55 @@ To find out more please read the [signer field](https://github.com/cosmos/cosmos
For ante handler construction via `ante.NewAnteHandler`, the field `ante.HandlerOptions.SignModeHandler` has been updated to `x/tx/signing/HandlerMap` from `x/auth/signing/SignModeHandler`. Callers typically fetch this value from `client.TxConfig.SignModeHandler()` (which is also changed) so this change should be transparent to most users.
##### Account Migration Guide: x/auth to x/accounts
Users can now migrate accounts from `x/auth` to `x/accounts` using the `auth.MsgMigrateAccount` message. Currently, this migration is only supported for `BaseAccount` due to security considerations.
###### Migration Process
The migration process allows an auth BaseAccount to migrate to any kind of x/accounts supported account type, here we will show how to migrate from a legacy x/auth `BaseAccount` to a `x/accounts` `BaseAccount`
####### Migrating to x/accounts/defaults/base
To migrate to the `BaseAccount` in `x/accounts`, follow these steps:
1. Send a `basev1.MsgInit` message.
2. This process allows you to:
- Switch to a new public key
- Reset your sequence number
> **Important**: If you intend to keep the same public key, ensure you use your current sequence number.
###### Example: x/auth.MsgMigrateAccount
Here's an example of the `x/auth.MsgMigrateAccount` message structure:
```json
{
"signer": "cosmos1w43tr39v3lzvxz969e4ty9a74rq9nw7563tqvy",
"account_type": "base",
"account_init_msg": {
"@type": "/cosmos.accounts.defaults.base.v1.MsgInit",
"pub_key": {
"@type": "/cosmos.crypto.secp256k1.PubKey",
"key": "AkeoE1z32tlQyE7xpx3v+JE9XJL0trVQBFoDCn0pGl3w"
},
"init_sequence": "100"
}
}
```
**Field Descriptions**
- `signer`: The address of the account you want to migrate from.
- `account_type`: The new account type you want to migrate to (depends on what's installed on the chain).
- `account_init_msg`: The custom initialization message for the new account.
- `@type`: Specifies the type of account (in this case, x/accounts base account).
- `pub_key`: The public key for the account. You can migrate to a different public key if desired.
- `init_sequence`: The new sequence number for the account.
> **Warning**: If you're keeping the same public key, make sure to use your current sequence number to prevent potential replay attacks.
#### `x/capability`
Capability has been moved to [IBC Go](https://github.com/cosmos/ibc-go). IBC v8 will contain the necessary changes to incorporate the new module location.

View File

@ -14,14 +14,16 @@ import (
)
var (
md_MsgInit protoreflect.MessageDescriptor
fd_MsgInit_pub_key protoreflect.FieldDescriptor
md_MsgInit protoreflect.MessageDescriptor
fd_MsgInit_pub_key protoreflect.FieldDescriptor
fd_MsgInit_init_sequence protoreflect.FieldDescriptor
)
func init() {
file_cosmos_accounts_defaults_base_v1_base_proto_init()
md_MsgInit = File_cosmos_accounts_defaults_base_v1_base_proto.Messages().ByName("MsgInit")
fd_MsgInit_pub_key = md_MsgInit.Fields().ByName("pub_key")
fd_MsgInit_init_sequence = md_MsgInit.Fields().ByName("init_sequence")
}
var _ protoreflect.Message = (*fastReflection_MsgInit)(nil)
@ -95,6 +97,12 @@ func (x *fastReflection_MsgInit) Range(f func(protoreflect.FieldDescriptor, prot
return
}
}
if x.InitSequence != uint64(0) {
value := protoreflect.ValueOfUint64(x.InitSequence)
if !f(fd_MsgInit_init_sequence, value) {
return
}
}
}
// Has reports whether a field is populated.
@ -112,6 +120,8 @@ func (x *fastReflection_MsgInit) Has(fd protoreflect.FieldDescriptor) bool {
switch fd.FullName() {
case "cosmos.accounts.defaults.base.v1.MsgInit.pub_key":
return x.PubKey != nil
case "cosmos.accounts.defaults.base.v1.MsgInit.init_sequence":
return x.InitSequence != uint64(0)
default:
if fd.IsExtension() {
panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.accounts.defaults.base.v1.MsgInit"))
@ -130,6 +140,8 @@ func (x *fastReflection_MsgInit) Clear(fd protoreflect.FieldDescriptor) {
switch fd.FullName() {
case "cosmos.accounts.defaults.base.v1.MsgInit.pub_key":
x.PubKey = nil
case "cosmos.accounts.defaults.base.v1.MsgInit.init_sequence":
x.InitSequence = uint64(0)
default:
if fd.IsExtension() {
panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.accounts.defaults.base.v1.MsgInit"))
@ -149,6 +161,9 @@ func (x *fastReflection_MsgInit) Get(descriptor protoreflect.FieldDescriptor) pr
case "cosmos.accounts.defaults.base.v1.MsgInit.pub_key":
value := x.PubKey
return protoreflect.ValueOfMessage(value.ProtoReflect())
case "cosmos.accounts.defaults.base.v1.MsgInit.init_sequence":
value := x.InitSequence
return protoreflect.ValueOfUint64(value)
default:
if descriptor.IsExtension() {
panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.accounts.defaults.base.v1.MsgInit"))
@ -171,6 +186,8 @@ func (x *fastReflection_MsgInit) Set(fd protoreflect.FieldDescriptor, value prot
switch fd.FullName() {
case "cosmos.accounts.defaults.base.v1.MsgInit.pub_key":
x.PubKey = value.Message().Interface().(*anypb.Any)
case "cosmos.accounts.defaults.base.v1.MsgInit.init_sequence":
x.InitSequence = value.Uint()
default:
if fd.IsExtension() {
panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.accounts.defaults.base.v1.MsgInit"))
@ -196,6 +213,8 @@ func (x *fastReflection_MsgInit) Mutable(fd protoreflect.FieldDescriptor) protor
x.PubKey = new(anypb.Any)
}
return protoreflect.ValueOfMessage(x.PubKey.ProtoReflect())
case "cosmos.accounts.defaults.base.v1.MsgInit.init_sequence":
panic(fmt.Errorf("field init_sequence of message cosmos.accounts.defaults.base.v1.MsgInit is not mutable"))
default:
if fd.IsExtension() {
panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.accounts.defaults.base.v1.MsgInit"))
@ -212,6 +231,8 @@ func (x *fastReflection_MsgInit) NewField(fd protoreflect.FieldDescriptor) proto
case "cosmos.accounts.defaults.base.v1.MsgInit.pub_key":
m := new(anypb.Any)
return protoreflect.ValueOfMessage(m.ProtoReflect())
case "cosmos.accounts.defaults.base.v1.MsgInit.init_sequence":
return protoreflect.ValueOfUint64(uint64(0))
default:
if fd.IsExtension() {
panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.accounts.defaults.base.v1.MsgInit"))
@ -285,6 +306,9 @@ func (x *fastReflection_MsgInit) ProtoMethods() *protoiface.Methods {
l = options.Size(x.PubKey)
n += 1 + l + runtime.Sov(uint64(l))
}
if x.InitSequence != 0 {
n += 1 + runtime.Sov(uint64(x.InitSequence))
}
if x.unknownFields != nil {
n += len(x.unknownFields)
}
@ -314,6 +338,11 @@ func (x *fastReflection_MsgInit) ProtoMethods() *protoiface.Methods {
i -= len(x.unknownFields)
copy(dAtA[i:], x.unknownFields)
}
if x.InitSequence != 0 {
i = runtime.EncodeVarint(dAtA, i, uint64(x.InitSequence))
i--
dAtA[i] = 0x10
}
if x.PubKey != nil {
encoded, err := options.Marshal(x.PubKey)
if err != nil {
@ -413,6 +442,25 @@ func (x *fastReflection_MsgInit) ProtoMethods() *protoiface.Methods {
return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, err
}
iNdEx = postIndex
case 2:
if wireType != 0 {
return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field InitSequence", wireType)
}
x.InitSequence = 0
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow
}
if iNdEx >= l {
return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
x.InitSequence |= uint64(b&0x7F) << shift
if b < 0x80 {
break
}
}
default:
iNdEx = preIndex
skippy, err := runtime.Skip(dAtA[iNdEx:])
@ -3167,6 +3215,9 @@ type MsgInit struct {
// pub_key defines a pubkey for the account arbitrary encapsulated.
PubKey *anypb.Any `protobuf:"bytes,1,opt,name=pub_key,json=pubKey,proto3" json:"pub_key,omitempty"`
// init_sequence defines the initial sequence of the account.
// Defaults to zero if not set.
InitSequence uint64 `protobuf:"varint,2,opt,name=init_sequence,json=initSequence,proto3" json:"init_sequence,omitempty"`
}
func (x *MsgInit) Reset() {
@ -3196,6 +3247,13 @@ func (x *MsgInit) GetPubKey() *anypb.Any {
return nil
}
func (x *MsgInit) GetInitSequence() uint64 {
if x != nil {
return x.InitSequence
}
return 0
}
// MsgInitResponse is the response returned after base account initialization.
// This is empty.
type MsgInitResponse struct {
@ -3425,45 +3483,48 @@ var file_cosmos_accounts_defaults_base_v1_base_proto_rawDesc = []byte{
0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x2e, 0x64,
0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x73, 0x2e, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x1a,
0x19, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66,
0x2f, 0x61, 0x6e, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x38, 0x0a, 0x07, 0x4d, 0x73,
0x2f, 0x61, 0x6e, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x5d, 0x0a, 0x07, 0x4d, 0x73,
0x67, 0x49, 0x6e, 0x69, 0x74, 0x12, 0x2d, 0x0a, 0x07, 0x70, 0x75, 0x62, 0x5f, 0x6b, 0x65, 0x79,
0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e,
0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x41, 0x6e, 0x79, 0x52, 0x06, 0x70, 0x75,
0x62, 0x4b, 0x65, 0x79, 0x22, 0x11, 0x0a, 0x0f, 0x4d, 0x73, 0x67, 0x49, 0x6e, 0x69, 0x74, 0x52,
0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x45, 0x0a, 0x0d, 0x4d, 0x73, 0x67, 0x53, 0x77,
0x61, 0x70, 0x50, 0x75, 0x62, 0x4b, 0x65, 0x79, 0x12, 0x34, 0x0a, 0x0b, 0x6e, 0x65, 0x77, 0x5f,
0x70, 0x75, 0x62, 0x5f, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e,
0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e,
0x41, 0x6e, 0x79, 0x52, 0x09, 0x6e, 0x65, 0x77, 0x50, 0x75, 0x62, 0x4b, 0x65, 0x79, 0x22, 0x17,
0x0a, 0x15, 0x4d, 0x73, 0x67, 0x53, 0x77, 0x61, 0x70, 0x50, 0x75, 0x62, 0x4b, 0x65, 0x79, 0x52,
0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x0f, 0x0a, 0x0d, 0x51, 0x75, 0x65, 0x72, 0x79,
0x53, 0x65, 0x71, 0x75, 0x65, 0x6e, 0x63, 0x65, 0x22, 0x33, 0x0a, 0x15, 0x51, 0x75, 0x65, 0x72,
0x79, 0x53, 0x65, 0x71, 0x75, 0x65, 0x6e, 0x63, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73,
0x65, 0x12, 0x1a, 0x0a, 0x08, 0x73, 0x65, 0x71, 0x75, 0x65, 0x6e, 0x63, 0x65, 0x18, 0x01, 0x20,
0x01, 0x28, 0x04, 0x52, 0x08, 0x73, 0x65, 0x71, 0x75, 0x65, 0x6e, 0x63, 0x65, 0x22, 0x0d, 0x0a,
0x0b, 0x51, 0x75, 0x65, 0x72, 0x79, 0x50, 0x75, 0x62, 0x4b, 0x65, 0x79, 0x22, 0x44, 0x0a, 0x13,
0x51, 0x75, 0x65, 0x72, 0x79, 0x50, 0x75, 0x62, 0x4b, 0x65, 0x79, 0x52, 0x65, 0x73, 0x70, 0x6f,
0x6e, 0x73, 0x65, 0x12, 0x2d, 0x0a, 0x07, 0x70, 0x75, 0x62, 0x5f, 0x6b, 0x65, 0x79, 0x18, 0x01,
0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72,
0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x41, 0x6e, 0x79, 0x52, 0x06, 0x70, 0x75, 0x62, 0x4b,
0x65, 0x79, 0x42, 0x90, 0x02, 0x0a, 0x24, 0x63, 0x6f, 0x6d, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f,
0x73, 0x2e, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x2e, 0x64, 0x65, 0x66, 0x61, 0x75,
0x6c, 0x74, 0x73, 0x2e, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x42, 0x09, 0x42, 0x61, 0x73,
0x65, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x38, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73,
0x73, 0x64, 0x6b, 0x2e, 0x69, 0x6f, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f,
0x73, 0x2f, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x2f, 0x64, 0x65, 0x66, 0x61, 0x75,
0x6c, 0x74, 0x73, 0x2f, 0x62, 0x61, 0x73, 0x65, 0x2f, 0x76, 0x31, 0x3b, 0x62, 0x61, 0x73, 0x65,
0x76, 0x31, 0xa2, 0x02, 0x04, 0x43, 0x41, 0x44, 0x42, 0xaa, 0x02, 0x20, 0x43, 0x6f, 0x73, 0x6d,
0x6f, 0x73, 0x2e, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x2e, 0x44, 0x65, 0x66, 0x61,
0x75, 0x6c, 0x74, 0x73, 0x2e, 0x42, 0x61, 0x73, 0x65, 0x2e, 0x56, 0x31, 0xca, 0x02, 0x20, 0x43,
0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x5c, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x5c, 0x44,
0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x73, 0x5c, 0x42, 0x61, 0x73, 0x65, 0x5c, 0x56, 0x31, 0xe2,
0x02, 0x2c, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x5c, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74,
0x73, 0x5c, 0x44, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x73, 0x5c, 0x42, 0x61, 0x73, 0x65, 0x5c,
0x56, 0x31, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02,
0x24, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x3a, 0x3a, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74,
0x73, 0x3a, 0x3a, 0x44, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x73, 0x3a, 0x3a, 0x42, 0x61, 0x73,
0x65, 0x3a, 0x3a, 0x56, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
0x62, 0x4b, 0x65, 0x79, 0x12, 0x23, 0x0a, 0x0d, 0x69, 0x6e, 0x69, 0x74, 0x5f, 0x73, 0x65, 0x71,
0x75, 0x65, 0x6e, 0x63, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x52, 0x0c, 0x69, 0x6e, 0x69,
0x74, 0x53, 0x65, 0x71, 0x75, 0x65, 0x6e, 0x63, 0x65, 0x22, 0x11, 0x0a, 0x0f, 0x4d, 0x73, 0x67,
0x49, 0x6e, 0x69, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x45, 0x0a, 0x0d,
0x4d, 0x73, 0x67, 0x53, 0x77, 0x61, 0x70, 0x50, 0x75, 0x62, 0x4b, 0x65, 0x79, 0x12, 0x34, 0x0a,
0x0b, 0x6e, 0x65, 0x77, 0x5f, 0x70, 0x75, 0x62, 0x5f, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01,
0x28, 0x0b, 0x32, 0x14, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74,
0x6f, 0x62, 0x75, 0x66, 0x2e, 0x41, 0x6e, 0x79, 0x52, 0x09, 0x6e, 0x65, 0x77, 0x50, 0x75, 0x62,
0x4b, 0x65, 0x79, 0x22, 0x17, 0x0a, 0x15, 0x4d, 0x73, 0x67, 0x53, 0x77, 0x61, 0x70, 0x50, 0x75,
0x62, 0x4b, 0x65, 0x79, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x0f, 0x0a, 0x0d,
0x51, 0x75, 0x65, 0x72, 0x79, 0x53, 0x65, 0x71, 0x75, 0x65, 0x6e, 0x63, 0x65, 0x22, 0x33, 0x0a,
0x15, 0x51, 0x75, 0x65, 0x72, 0x79, 0x53, 0x65, 0x71, 0x75, 0x65, 0x6e, 0x63, 0x65, 0x52, 0x65,
0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x73, 0x65, 0x71, 0x75, 0x65, 0x6e,
0x63, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x08, 0x73, 0x65, 0x71, 0x75, 0x65, 0x6e,
0x63, 0x65, 0x22, 0x0d, 0x0a, 0x0b, 0x51, 0x75, 0x65, 0x72, 0x79, 0x50, 0x75, 0x62, 0x4b, 0x65,
0x79, 0x22, 0x44, 0x0a, 0x13, 0x51, 0x75, 0x65, 0x72, 0x79, 0x50, 0x75, 0x62, 0x4b, 0x65, 0x79,
0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x2d, 0x0a, 0x07, 0x70, 0x75, 0x62, 0x5f,
0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x67, 0x6f, 0x6f, 0x67,
0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x41, 0x6e, 0x79, 0x52,
0x06, 0x70, 0x75, 0x62, 0x4b, 0x65, 0x79, 0x42, 0x90, 0x02, 0x0a, 0x24, 0x63, 0x6f, 0x6d, 0x2e,
0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x2e,
0x64, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x73, 0x2e, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31,
0x42, 0x09, 0x42, 0x61, 0x73, 0x65, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x38, 0x63,
0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x73, 0x64, 0x6b, 0x2e, 0x69, 0x6f, 0x2f, 0x61, 0x70, 0x69, 0x2f,
0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x2f,
0x64, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x73, 0x2f, 0x62, 0x61, 0x73, 0x65, 0x2f, 0x76, 0x31,
0x3b, 0x62, 0x61, 0x73, 0x65, 0x76, 0x31, 0xa2, 0x02, 0x04, 0x43, 0x41, 0x44, 0x42, 0xaa, 0x02,
0x20, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73,
0x2e, 0x44, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x73, 0x2e, 0x42, 0x61, 0x73, 0x65, 0x2e, 0x56,
0x31, 0xca, 0x02, 0x20, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x5c, 0x41, 0x63, 0x63, 0x6f, 0x75,
0x6e, 0x74, 0x73, 0x5c, 0x44, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x73, 0x5c, 0x42, 0x61, 0x73,
0x65, 0x5c, 0x56, 0x31, 0xe2, 0x02, 0x2c, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x5c, 0x41, 0x63,
0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x5c, 0x44, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x73, 0x5c,
0x42, 0x61, 0x73, 0x65, 0x5c, 0x56, 0x31, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64,
0x61, 0x74, 0x61, 0xea, 0x02, 0x24, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x3a, 0x3a, 0x41, 0x63,
0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x3a, 0x3a, 0x44, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x73,
0x3a, 0x3a, 0x42, 0x61, 0x73, 0x65, 0x3a, 0x3a, 0x56, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74,
0x6f, 0x33,
}
var (

View File

@ -937,7 +937,7 @@ type QueryLegacyAccountResponse struct {
// the type wrapped by the any does not need to comply with the
// sdk.AccountI interface.
Account *anypb.Any `protobuf:"bytes,1,opt,name=account,proto3" json:"account,omitempty"`
// info represents the account as a BaseAccount, this can return
// base represents the account as a BaseAccount, this can return
// nil if the account cannot be represented as a BaseAccount.
// This is used in the gRPC QueryAccountInfo method.
Base *BaseAccount `protobuf:"bytes,2,opt,name=base,proto3" json:"base,omitempty"`

File diff suppressed because it is too large Load Diff

View File

@ -19,8 +19,9 @@ import (
const _ = grpc.SupportPackageIsVersion9
const (
Msg_UpdateParams_FullMethodName = "/cosmos.auth.v1beta1.Msg/UpdateParams"
Msg_NonAtomicExec_FullMethodName = "/cosmos.auth.v1beta1.Msg/NonAtomicExec"
Msg_UpdateParams_FullMethodName = "/cosmos.auth.v1beta1.Msg/UpdateParams"
Msg_NonAtomicExec_FullMethodName = "/cosmos.auth.v1beta1.Msg/NonAtomicExec"
Msg_MigrateAccount_FullMethodName = "/cosmos.auth.v1beta1.Msg/MigrateAccount"
)
// MsgClient is the client API for Msg service.
@ -34,6 +35,8 @@ type MsgClient interface {
UpdateParams(ctx context.Context, in *MsgUpdateParams, opts ...grpc.CallOption) (*MsgUpdateParamsResponse, error)
// NonAtomicExec allows users to submit multiple messages for non-atomic execution.
NonAtomicExec(ctx context.Context, in *MsgNonAtomicExec, opts ...grpc.CallOption) (*MsgNonAtomicExecResponse, error)
// MigrateAccount migrates the account to x/accounts.
MigrateAccount(ctx context.Context, in *MsgMigrateAccount, opts ...grpc.CallOption) (*MsgMigrateAccountResponse, error)
}
type msgClient struct {
@ -64,6 +67,16 @@ func (c *msgClient) NonAtomicExec(ctx context.Context, in *MsgNonAtomicExec, opt
return out, nil
}
func (c *msgClient) MigrateAccount(ctx context.Context, in *MsgMigrateAccount, opts ...grpc.CallOption) (*MsgMigrateAccountResponse, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(MsgMigrateAccountResponse)
err := c.cc.Invoke(ctx, Msg_MigrateAccount_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
}
return out, nil
}
// MsgServer is the server API for Msg service.
// All implementations must embed UnimplementedMsgServer
// for forward compatibility.
@ -75,6 +88,8 @@ type MsgServer interface {
UpdateParams(context.Context, *MsgUpdateParams) (*MsgUpdateParamsResponse, error)
// NonAtomicExec allows users to submit multiple messages for non-atomic execution.
NonAtomicExec(context.Context, *MsgNonAtomicExec) (*MsgNonAtomicExecResponse, error)
// MigrateAccount migrates the account to x/accounts.
MigrateAccount(context.Context, *MsgMigrateAccount) (*MsgMigrateAccountResponse, error)
mustEmbedUnimplementedMsgServer()
}
@ -91,6 +106,9 @@ func (UnimplementedMsgServer) UpdateParams(context.Context, *MsgUpdateParams) (*
func (UnimplementedMsgServer) NonAtomicExec(context.Context, *MsgNonAtomicExec) (*MsgNonAtomicExecResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method NonAtomicExec not implemented")
}
func (UnimplementedMsgServer) MigrateAccount(context.Context, *MsgMigrateAccount) (*MsgMigrateAccountResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method MigrateAccount not implemented")
}
func (UnimplementedMsgServer) mustEmbedUnimplementedMsgServer() {}
func (UnimplementedMsgServer) testEmbeddedByValue() {}
@ -148,6 +166,24 @@ func _Msg_NonAtomicExec_Handler(srv interface{}, ctx context.Context, dec func(i
return interceptor(ctx, in, info, handler)
}
func _Msg_MigrateAccount_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(MsgMigrateAccount)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(MsgServer).MigrateAccount(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: Msg_MigrateAccount_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(MsgServer).MigrateAccount(ctx, req.(*MsgMigrateAccount))
}
return interceptor(ctx, in, info, handler)
}
// Msg_ServiceDesc is the grpc.ServiceDesc for Msg service.
// It's only intended for direct use with grpc.RegisterService,
// and not to be introspected or modified (even as a copy)
@ -163,6 +199,10 @@ var Msg_ServiceDesc = grpc.ServiceDesc{
MethodName: "NonAtomicExec",
Handler: _Msg_NonAtomicExec_Handler,
},
{
MethodName: "MigrateAccount",
Handler: _Msg_MigrateAccount_Handler,
},
},
Streams: []grpc.StreamDesc{},
Metadata: "cosmos/auth/v1beta1/tx.proto",

View File

@ -20,7 +20,7 @@ message QueryLegacyAccountResponse {
// the type wrapped by the any does not need to comply with the
// sdk.AccountI interface.
google.protobuf.Any account = 1;
// info represents the account as a BaseAccount, this can return
// base represents the account as a BaseAccount, this can return
// nil if the account cannot be represented as a BaseAccount.
// This is used in the gRPC QueryAccountInfo method.
BaseAccount base = 2;

View File

@ -22,6 +22,9 @@ service Msg {
// NonAtomicExec allows users to submit multiple messages for non-atomic execution.
rpc NonAtomicExec(MsgNonAtomicExec) returns (MsgNonAtomicExecResponse);
// MigrateAccount migrates the account to x/accounts.
rpc MigrateAccount(MsgMigrateAccount) returns (MsgMigrateAccountResponse);
}
// MsgUpdateParams is the Msg/UpdateParams request type.
@ -64,3 +67,22 @@ message NonAtomicExecResult {
message MsgNonAtomicExecResponse {
repeated NonAtomicExecResult results = 1;
}
// MsgMigrateAccount defines a message which allows users to migrate from BaseAccount
// to other x/accounts types.
message MsgMigrateAccount {
option (amino.name) = "cosmos-sdk/x/auth/MsgMigrateAccount";
option (cosmos.msg.v1.signer) = "signer";
string signer = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
string account_type = 2;
google.protobuf.Any account_init_msg = 3;
}
// MsgMigrateAccountResponse defines the response given when migrating to
// an x/accounts account.
message MsgMigrateAccountResponse {
// init_response defines the response returned by the x/account account
// initialization.
google.protobuf.Any init_response = 1;
}

View File

@ -0,0 +1,100 @@
package keeper_test
import (
"testing"
"github.com/stretchr/testify/require"
basev1 "cosmossdk.io/x/accounts/defaults/base/v1"
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
"github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1"
sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
authkeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
)
func TestMigrateToAccounts(t *testing.T) {
f := initFixture(t, nil)
// create a module account
modAcc := &authtypes.ModuleAccount{
BaseAccount: &authtypes.BaseAccount{
Address: f.mustAddr([]byte("cookies")),
PubKey: nil,
AccountNumber: 0,
Sequence: 0,
},
Name: "cookies",
Permissions: nil,
}
updatedMod := f.authKeeper.NewAccount(f.ctx, modAcc)
f.authKeeper.SetAccount(f.ctx, updatedMod)
// create account
msgSrv := authkeeper.NewMsgServerImpl(f.authKeeper)
privKey := secp256k1.GenPrivKey()
addr := sdk.AccAddress(privKey.PubKey().Address())
acc := f.authKeeper.NewAccountWithAddress(f.ctx, addr)
require.NoError(t, acc.SetPubKey(privKey.PubKey()))
f.authKeeper.SetAccount(f.ctx, acc)
t.Run("account does not exist", func(t *testing.T) {
resp, err := msgSrv.MigrateAccount(f.ctx, &authtypes.MsgMigrateAccount{
Signer: f.mustAddr([]byte("notexist")),
AccountType: "base",
AccountInitMsg: nil,
})
require.Nil(t, resp)
require.ErrorIs(t, err, sdkerrors.ErrUnknownAddress)
})
t.Run("invalid account type", func(t *testing.T) {
resp, err := msgSrv.MigrateAccount(f.ctx, &authtypes.MsgMigrateAccount{
Signer: f.mustAddr(updatedMod.GetAddress()),
AccountType: "base",
AccountInitMsg: nil,
})
require.Nil(t, resp)
require.ErrorContains(t, err, "only BaseAccount can be migrated")
})
t.Run("success", func(t *testing.T) {
pk, err := codectypes.NewAnyWithValue(privKey.PubKey())
require.NoError(t, err)
migrateMsg := &basev1.MsgInit{
PubKey: pk,
InitSequence: 100,
}
initMsgAny, err := codectypes.NewAnyWithValue(migrateMsg)
require.NoError(t, err)
resp, err := msgSrv.MigrateAccount(f.ctx, &authtypes.MsgMigrateAccount{
Signer: f.mustAddr(addr),
AccountType: "base",
AccountInitMsg: initMsgAny,
})
require.NoError(t, err)
// check response semantics.
require.Equal(t, resp.InitResponse.TypeUrl, "/cosmos.accounts.defaults.base.v1.MsgInitResponse")
require.NotNil(t, resp.InitResponse.Value)
// check the account was removed from x/auth and added to x/accounts
require.Nil(t, f.authKeeper.GetAccount(f.ctx, addr))
require.True(t, f.accountsKeeper.IsAccountsModuleAccount(f.ctx, addr))
// check the init information is correctly propagated.
seq, err := f.accountsKeeper.Query(f.ctx, addr, &basev1.QuerySequence{})
require.NoError(t, err)
require.Equal(t, migrateMsg.InitSequence, seq.(*basev1.QuerySequenceResponse).Sequence)
pkResp, err := f.accountsKeeper.Query(f.ctx, addr, &basev1.QueryPubKey{})
require.NoError(t, err)
require.Equal(t, migrateMsg.PubKey, pkResp.(*basev1.QueryPubKeyResponse).PubKey)
})
}

View File

@ -70,6 +70,12 @@ type Account struct {
}
func (a Account) Init(ctx context.Context, msg *v1.MsgInit) (*v1.MsgInitResponse, error) {
if msg.InitSequence != 0 {
err := a.Sequence.Set(ctx, msg.InitSequence)
if err != nil {
return nil, err
}
}
return &v1.MsgInitResponse{}, a.savePubKey(ctx, msg.PubKey)
}
@ -258,6 +264,18 @@ func (a Account) QuerySequence(ctx context.Context, _ *v1.QuerySequence) (*v1.Qu
return &v1.QuerySequenceResponse{Sequence: seq}, nil
}
func (a Account) QueryPubKey(ctx context.Context, _ *v1.QueryPubKey) (*v1.QueryPubKeyResponse, error) {
pubKey, err := a.loadPubKey(ctx)
if err != nil {
return nil, err
}
anyPubKey, err := codectypes.NewAnyWithValue(pubKey)
if err != nil {
return nil, err
}
return &v1.QueryPubKeyResponse{PubKey: anyPubKey}, nil
}
func (a Account) AuthRetroCompatibility(ctx context.Context, _ *authtypes.QueryLegacyAccount) (*authtypes.QueryLegacyAccountResponse, error) {
addr, err := a.addrCodec.BytesToString(accountstd.Whoami(ctx))
if err != nil {
@ -311,5 +329,6 @@ func (a Account) RegisterExecuteHandlers(builder *accountstd.ExecuteBuilder) {
func (a Account) RegisterQueryHandlers(builder *accountstd.QueryBuilder) {
accountstd.RegisterQueryHandler(builder, a.QuerySequence)
accountstd.RegisterQueryHandler(builder, a.QueryPubKey)
accountstd.RegisterQueryHandler(builder, a.AuthRetroCompatibility)
}

View File

@ -27,6 +27,9 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package
type MsgInit struct {
// pub_key defines a pubkey for the account arbitrary encapsulated.
PubKey *any.Any `protobuf:"bytes,1,opt,name=pub_key,json=pubKey,proto3" json:"pub_key,omitempty"`
// init_sequence defines the initial sequence of the account.
// Defaults to zero if not set.
InitSequence uint64 `protobuf:"varint,2,opt,name=init_sequence,json=initSequence,proto3" json:"init_sequence,omitempty"`
}
func (m *MsgInit) Reset() { *m = MsgInit{} }
@ -69,6 +72,13 @@ func (m *MsgInit) GetPubKey() *any.Any {
return nil
}
func (m *MsgInit) GetInitSequence() uint64 {
if m != nil {
return m.InitSequence
}
return 0
}
// MsgInitResponse is the response returned after base account initialization.
// This is empty.
type MsgInitResponse struct {
@ -372,26 +382,28 @@ func init() {
}
var fileDescriptor_7c860870b5ed6dc2 = []byte{
// 303 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x91, 0xcf, 0x4a, 0xc3, 0x40,
0x10, 0xc6, 0x1b, 0x90, 0x56, 0xa7, 0x94, 0x62, 0xb4, 0xa8, 0x3d, 0x2c, 0x65, 0x4f, 0x05, 0x71,
0x97, 0x5a, 0x0f, 0x5e, 0x2d, 0x7a, 0x10, 0x29, 0x68, 0x7a, 0xf3, 0x52, 0x92, 0x74, 0x1a, 0x4a,
0xeb, 0x6e, 0xec, 0x66, 0x1b, 0xf3, 0x16, 0x3e, 0x96, 0xc7, 0x1e, 0x3d, 0x4a, 0xf2, 0x22, 0xc2,
0xe6, 0x0f, 0xf6, 0x20, 0xe8, 0x69, 0x99, 0xe1, 0xf7, 0xfb,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 0x4a, 0x89, 0xf5, 0x9e, 0x91, 0xda, 0x36, 0x23, 0xb5, 0xcf, 0x8c, 0xd4,
0x9e, 0xfb, 0x79, 0x3d, 0x6a, 0xb6, 0x64, 0x0b, 0xc9, 0xdf, 0x7e, 0xef, 0xd4, 0xab, 0x9b, 0xe4,
0xe1, 0x77, 0x00, 0x00, 0x00, 0xff, 0xff, 0x8f, 0xe1, 0xb2, 0xd8, 0xfe, 0x01, 0x00, 0x00,
// 323 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x91, 0xc1, 0x4a, 0xf3, 0x40,
0x10, 0xc7, 0xbb, 0x1f, 0x1f, 0xad, 0x4e, 0x0d, 0xc5, 0x68, 0xb1, 0xf6, 0x10, 0x4a, 0xbc, 0x14,
0xc4, 0x5d, 0x6a, 0x7d, 0x01, 0x8b, 0x1e, 0x44, 0x0a, 0xda, 0xde, 0x04, 0x29, 0x49, 0x3a, 0x0d,
0xa1, 0x75, 0x37, 0x76, 0xb3, 0xad, 0x79, 0x0b, 0x1f, 0xcb, 0x63, 0x8f, 0x1e, 0xa5, 0x7d, 0x11,
0x71, 0x37, 0x09, 0xf6, 0x20, 0xe8, 0x69, 0x99, 0xe1, 0xf7, 0xff, 0xcd, 0xb0, 0x03, 0xa7, 0x81,
0x90, 0x4f, 0x42, 0x32, 0x2f, 0x08, 0x84, 0xe2, 0x89, 0x64, 0x63, 0x9c, 0x78, 0x6a, 0x96, 0x48,
0xe6, 0x7b, 0x12, 0xd9, 0xa2, 0xa3, 0x5f, 0x1a, 0xcf, 0x45, 0x22, 0xec, 0x96, 0x81, 0x69, 0x0e,
0xd3, 0x1c, 0xa6, 0x1a, 0x5a, 0x74, 0x9a, 0xc7, 0xa1, 0x10, 0xe1, 0x0c, 0x99, 0xe6, 0x7d, 0x35,
0x61, 0x1e, 0x4f, 0x4d, 0xd8, 0x7d, 0x84, 0x4a, 0x5f, 0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00, 0x00,
}
func (m *MsgInit) Marshal() (dAtA []byte, err error) {
@ -414,6 +426,11 @@ func (m *MsgInit) MarshalToSizedBuffer(dAtA []byte) (int, error) {
_ = i
var l int
_ = l
if m.InitSequence != 0 {
i = encodeVarintBase(dAtA, i, uint64(m.InitSequence))
i--
dAtA[i] = 0x10
}
if m.PubKey != nil {
{
size, err := m.PubKey.MarshalToSizedBuffer(dAtA[:i])
@ -640,6 +657,9 @@ func (m *MsgInit) Size() (n int) {
l = m.PubKey.Size()
n += 1 + l + sovBase(uint64(l))
}
if m.InitSequence != 0 {
n += 1 + sovBase(uint64(m.InitSequence))
}
return n
}
@ -788,6 +808,25 @@ func (m *MsgInit) Unmarshal(dAtA []byte) error {
return err
}
iNdEx = postIndex
case 2:
if wireType != 0 {
return fmt.Errorf("proto: wrong wireType = %d for field InitSequence", wireType)
}
m.InitSequence = 0
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowBase
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
m.InitSequence |= uint64(b&0x7F) << shift
if b < 0x80 {
break
}
}
default:
iNdEx = preIndex
skippy, err := skipBase(dAtA[iNdEx:])

View File

@ -10,6 +10,9 @@ import "google/protobuf/any.proto";
message MsgInit {
// pub_key defines a pubkey for the account arbitrary encapsulated.
google.protobuf.Any pub_key = 1;
// init_sequence defines the initial sequence of the account.
// Defaults to zero if not set.
uint64 init_sequence = 2;
}
// MsgInitResponse is the response returned after base account initialization.

View File

@ -61,7 +61,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
* [#19093](https://github.com/cosmos/cosmos-sdk/pull/19093) SetPubKeyDecorator was merged into SigVerification, gas consumption is almost halved for a simple tx.
* [#19535](https://github.com/cosmos/cosmos-sdk/pull/19535) Remove vesting account creation when the chain is running. The accounts module is required for creating [#vesting accounts](../accounts/defaults/lockup/README.md) on a running chain.
* [#21688](https://github.com/cosmos/cosmos-sdk/pull/21688) Allow x/accounts to be queriable from the `AccountInfo` and `Account` gRPC endpoints
* [#21820](https://github.com/cosmos/cosmos-sdk/pull/21820) Allow x/auth `BaseAccount` to migrate to a `x/accounts` via the new `MsgMigrateAccount`.
### Bug Fixes
* [#19148](https://github.com/cosmos/cosmos-sdk/pull/19148) Checks the consumed gas for verifying a multisig pubKey signature during simulation.

View File

@ -4,7 +4,14 @@ import (
"context"
"errors"
"fmt"
"reflect"
"strings"
gogoproto "github.com/cosmos/gogoproto/proto"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
"github.com/cosmos/cosmos-sdk/x/auth/types"
)
@ -68,3 +75,61 @@ func (ms msgServer) UpdateParams(ctx context.Context, msg *types.MsgUpdateParams
return &types.MsgUpdateParamsResponse{}, nil
}
func (ms msgServer) MigrateAccount(ctx context.Context, msg *types.MsgMigrateAccount) (*types.MsgMigrateAccountResponse, error) {
signer, err := ms.ak.AddressCodec().StringToBytes(msg.Signer)
if err != nil {
return nil, sdkerrors.ErrInvalidAddress.Wrapf("invalid signer address: %s", err)
}
acc := ms.ak.GetAccount(ctx, signer)
if acc == nil {
return nil, sdkerrors.ErrUnknownAddress.Wrapf("account %s does not exist", signer)
}
// check if account type is valid or not
_, isBaseAccount := (acc).(*types.BaseAccount)
if !isBaseAccount {
return nil, status.Error(codes.InvalidArgument, "only BaseAccount can be migrated")
}
// unwrap any msg
initMsg, err := unpackAnyRaw(msg.AccountInitMsg)
if err != nil {
return nil, err
}
initResp, err := ms.ak.AccountsModKeeper.MigrateLegacyAccount(ctx, signer, acc.GetAccountNumber(), msg.AccountType, initMsg)
if err != nil {
return nil, err
}
// account is then removed from state
ms.ak.RemoveAccount(ctx, acc)
initRespAny, err := codectypes.NewAnyWithValue(initResp)
if err != nil {
return nil, err
}
return &types.MsgMigrateAccountResponse{InitResponse: initRespAny}, nil
}
func unpackAnyRaw(m *codectypes.Any) (gogoproto.Message, error) {
if m == nil {
return nil, fmt.Errorf("cannot unpack nil any")
}
split := strings.Split(m.TypeUrl, "/")
name := split[len(split)-1]
typ := gogoproto.MessageType(name)
if typ == nil {
return nil, fmt.Errorf("no message type found for %s", name)
}
concreteMsg := reflect.New(typ.Elem()).Interface().(gogoproto.Message)
err := gogoproto.Unmarshal(m.Value, concreteMsg)
if err != nil {
return nil, err
}
return concreteMsg, nil
}

View File

@ -134,6 +134,21 @@ func (mr *MockAccountsModKeeperMockRecorder) IsAccountsModuleAccount(ctx, accoun
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "IsAccountsModuleAccount", reflect.TypeOf((*MockAccountsModKeeper)(nil).IsAccountsModuleAccount), ctx, accountAddr)
}
// MigrateLegacyAccount mocks base method.
func (m *MockAccountsModKeeper) MigrateLegacyAccount(ctx context.Context, addr []byte, accNum uint64, accType string, msg transaction.Msg) (transaction.Msg, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "MigrateLegacyAccount", ctx, addr, accNum, accType, msg)
ret0, _ := ret[0].(transaction.Msg)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// MigrateLegacyAccount indicates an expected call of MigrateLegacyAccount.
func (mr *MockAccountsModKeeperMockRecorder) MigrateLegacyAccount(ctx, addr, accNum, accType, msg interface{}) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "MigrateLegacyAccount", reflect.TypeOf((*MockAccountsModKeeper)(nil).MigrateLegacyAccount), ctx, addr, accNum, accType, msg)
}
// NextAccountNumber mocks base method.
func (m *MockAccountsModKeeper) NextAccountNumber(ctx context.Context) (uint64, error) {
m.ctrl.T.Helper()

View File

@ -70,7 +70,7 @@ type QueryLegacyAccountResponse struct {
// the type wrapped by the any does not need to comply with the
// sdk.AccountI interface.
Account *any.Any `protobuf:"bytes,1,opt,name=account,proto3" json:"account,omitempty"`
// info represents the account as a BaseAccount, this can return
// base represents the account as a BaseAccount, this can return
// nil if the account cannot be represented as a BaseAccount.
// This is used in the gRPC QueryAccountInfo method.
Base *BaseAccount `protobuf:"bytes,2,opt,name=base,proto3" json:"base,omitempty"`

View File

@ -59,5 +59,6 @@ func RegisterInterfaces(registrar registry.InterfaceRegistrar) {
registrar.RegisterImplementations((*coretransaction.Msg)(nil),
&MsgUpdateParams{},
&MsgNonAtomicExec{},
&MsgMigrateAccount{},
)
}

View File

@ -31,4 +31,13 @@ type AccountsModKeeper interface {
// InitAccountNumberSeqUnsafe is use to set accounts module account number with value
// of auth module current account number
InitAccountNumberSeqUnsafe(ctx context.Context, currentAccNum uint64) error
// MigrateLegacyAccount migrates the given account to an x/accounts' account.
MigrateLegacyAccount(
ctx context.Context,
addr []byte, // The current address of the account
accNum uint64, // The current account number
accType string, // The account type to migrate to
msg transaction.Msg, // The init msg of the account type we're migrating to
) (transaction.Msg, error)
}

View File

@ -279,53 +279,172 @@ func (m *MsgNonAtomicExecResponse) GetResults() []*NonAtomicExecResult {
return nil
}
// MsgMigrateAccount defines a message which allows users to migrate from BaseAccount
// to other x/accounts types.
type MsgMigrateAccount struct {
Signer string `protobuf:"bytes,1,opt,name=signer,proto3" json:"signer,omitempty"`
AccountType string `protobuf:"bytes,2,opt,name=account_type,json=accountType,proto3" json:"account_type,omitempty"`
AccountInitMsg *any.Any `protobuf:"bytes,3,opt,name=account_init_msg,json=accountInitMsg,proto3" json:"account_init_msg,omitempty"`
}
func (m *MsgMigrateAccount) Reset() { *m = MsgMigrateAccount{} }
func (m *MsgMigrateAccount) String() string { return proto.CompactTextString(m) }
func (*MsgMigrateAccount) ProtoMessage() {}
func (*MsgMigrateAccount) Descriptor() ([]byte, []int) {
return fileDescriptor_c2d62bd9c4c212e5, []int{5}
}
func (m *MsgMigrateAccount) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
}
func (m *MsgMigrateAccount) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
if deterministic {
return xxx_messageInfo_MsgMigrateAccount.Marshal(b, m, deterministic)
} else {
b = b[:cap(b)]
n, err := m.MarshalToSizedBuffer(b)
if err != nil {
return nil, err
}
return b[:n], nil
}
}
func (m *MsgMigrateAccount) XXX_Merge(src proto.Message) {
xxx_messageInfo_MsgMigrateAccount.Merge(m, src)
}
func (m *MsgMigrateAccount) XXX_Size() int {
return m.Size()
}
func (m *MsgMigrateAccount) XXX_DiscardUnknown() {
xxx_messageInfo_MsgMigrateAccount.DiscardUnknown(m)
}
var xxx_messageInfo_MsgMigrateAccount proto.InternalMessageInfo
func (m *MsgMigrateAccount) GetSigner() string {
if m != nil {
return m.Signer
}
return ""
}
func (m *MsgMigrateAccount) GetAccountType() string {
if m != nil {
return m.AccountType
}
return ""
}
func (m *MsgMigrateAccount) GetAccountInitMsg() *any.Any {
if m != nil {
return m.AccountInitMsg
}
return nil
}
// MsgMigrateAccountResponse defines the response given when migrating to
// an x/accounts account.
type MsgMigrateAccountResponse struct {
// init_response defines the response returned by the x/account account
// initialization.
InitResponse *any.Any `protobuf:"bytes,1,opt,name=init_response,json=initResponse,proto3" json:"init_response,omitempty"`
}
func (m *MsgMigrateAccountResponse) Reset() { *m = MsgMigrateAccountResponse{} }
func (m *MsgMigrateAccountResponse) String() string { return proto.CompactTextString(m) }
func (*MsgMigrateAccountResponse) ProtoMessage() {}
func (*MsgMigrateAccountResponse) Descriptor() ([]byte, []int) {
return fileDescriptor_c2d62bd9c4c212e5, []int{6}
}
func (m *MsgMigrateAccountResponse) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
}
func (m *MsgMigrateAccountResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
if deterministic {
return xxx_messageInfo_MsgMigrateAccountResponse.Marshal(b, m, deterministic)
} else {
b = b[:cap(b)]
n, err := m.MarshalToSizedBuffer(b)
if err != nil {
return nil, err
}
return b[:n], nil
}
}
func (m *MsgMigrateAccountResponse) XXX_Merge(src proto.Message) {
xxx_messageInfo_MsgMigrateAccountResponse.Merge(m, src)
}
func (m *MsgMigrateAccountResponse) XXX_Size() int {
return m.Size()
}
func (m *MsgMigrateAccountResponse) XXX_DiscardUnknown() {
xxx_messageInfo_MsgMigrateAccountResponse.DiscardUnknown(m)
}
var xxx_messageInfo_MsgMigrateAccountResponse proto.InternalMessageInfo
func (m *MsgMigrateAccountResponse) GetInitResponse() *any.Any {
if m != nil {
return m.InitResponse
}
return nil
}
func init() {
proto.RegisterType((*MsgUpdateParams)(nil), "cosmos.auth.v1beta1.MsgUpdateParams")
proto.RegisterType((*MsgUpdateParamsResponse)(nil), "cosmos.auth.v1beta1.MsgUpdateParamsResponse")
proto.RegisterType((*MsgNonAtomicExec)(nil), "cosmos.auth.v1beta1.MsgNonAtomicExec")
proto.RegisterType((*NonAtomicExecResult)(nil), "cosmos.auth.v1beta1.NonAtomicExecResult")
proto.RegisterType((*MsgNonAtomicExecResponse)(nil), "cosmos.auth.v1beta1.MsgNonAtomicExecResponse")
proto.RegisterType((*MsgMigrateAccount)(nil), "cosmos.auth.v1beta1.MsgMigrateAccount")
proto.RegisterType((*MsgMigrateAccountResponse)(nil), "cosmos.auth.v1beta1.MsgMigrateAccountResponse")
}
func init() { proto.RegisterFile("cosmos/auth/v1beta1/tx.proto", fileDescriptor_c2d62bd9c4c212e5) }
var fileDescriptor_c2d62bd9c4c212e5 = []byte{
// 548 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x53, 0xcf, 0x8f, 0xd2, 0x40,
0x14, 0x66, 0xdc, 0x1f, 0x86, 0x41, 0xb3, 0x5a, 0x48, 0x16, 0x59, 0x53, 0xb1, 0xd1, 0x04, 0x89,
0x4c, 0x17, 0x34, 0x9a, 0x70, 0x30, 0x01, 0xb3, 0xf1, 0x84, 0x31, 0x35, 0x7b, 0xf1, 0xa0, 0x29,
0x30, 0xce, 0x36, 0x6e, 0x3b, 0x4d, 0xdf, 0xb0, 0xc2, 0xcd, 0x78, 0xf4, 0xe4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 0x7d,
0x4c, 0x91, 0xe5, 0x24, 0x81, 0x8d, 0xdf, 0x08, 0x6f, 0x74, 0x80, 0x19, 0x1f, 0xf1, 0xb5, 0x95,
0xd5, 0xba, 0x97, 0x9a, 0x6a, 0xcd, 0xac, 0xd2, 0xc3, 0xcb, 0xb0, 0x12, 0xbd, 0x56, 0xfe, 0xec,
0xa2, 0xa5, 0x06, 0xc5, 0xd7, 0x57, 0xed, 0xbc, 0xff, 0xaf, 0x9c, 0x2b, 0xb4, 0x52, 0xed, 0x52,
0xb4, 0xa4, 0x76, 0x69, 0xeb, 0x53, 0xbc, 0xc1, 0xed, 0xe7, 0xa7, 0x33, 0x13, 0x9d, 0xcf, 0x4c,
0xf4, 0x6b, 0x66, 0xa2, 0xaf, 0x73, 0x33, 0x73, 0x3e, 0x37, 0x33, 0x3f, 0xe6, 0x66, 0xe6, 0xcd,
0x03, 0xe6, 0x89, 0xa3, 0x41, 0x97, 0xf4, 0xb8, 0xaf, 0x7f, 0x62, 0xfb, 0xe2, 0xfe, 0x8a, 0x51,
0x48, 0xa1, 0xbb, 0x2d, 0x7d, 0x7a, 0xf4, 0x27, 0x00, 0x00, 0xff, 0xff, 0x4a, 0xdf, 0x75, 0x60,
0x5e, 0x04, 0x00, 0x00,
// 667 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x54, 0xcb, 0x6e, 0xd3, 0x40,
0x14, 0x8d, 0xfb, 0x42, 0x99, 0xf4, 0xe9, 0x44, 0xaa, 0xeb, 0x22, 0xd3, 0x9a, 0x87, 0x42, 0x45,
0xc6, 0x7d, 0x20, 0x10, 0x59, 0x54, 0x4a, 0x50, 0x85, 0x58, 0x18, 0x21, 0x43, 0x59, 0xb0, 0xa0,
0x72, 0x9c, 0x61, 0x6a, 0x51, 0x7b, 0xac, 0x99, 0x49, 0x69, 0x76, 0x88, 0x25, 0x2b, 0x96, 0x7c,
0x02, 0xcb, 0x2e, 0xfa, 0x11, 0x55, 0x57, 0x55, 0x17, 0x88, 0x0d, 0x08, 0xb5, 0x8b, 0xfe, 0x06,
0xf2, 0x78, 0xdc, 0xe2, 0xd4, 0x81, 0x88, 0x4d, 0x62, 0xcf, 0x3d, 0xf7, 0xde, 0x73, 0xce, 0xbd,
0x63, 0x70, 0xdd, 0x23, 0x2c, 0x20, 0xcc, 0x72, 0x3b, 0x7c, 0xdb, 0xda, 0x5d, 0x69, 0x21, 0xee,
0xae, 0x58, 0x7c, 0x0f, 0x46, 0x94, 0x70, 0xa2, 0x96, 0x93, 0x28, 0x8c, 0xa3, 0x50, 0x46, 0xf5,
0x0a, 0x26, 0x98, 0x88, 0xb8, 0x15, 0x3f, 0x25, 0x50, 0x7d, 0x0e, 0x13, 0x82, 0x77, 0x90, 0x25,
0xde, 0x5a, 0x9d, 0xb7, 0x96, 0x1b, 0x76, 0xd3, 0x50, 0x52, 0x65, 0x2b, 0xc9, 0x91, 0x25, 0x93,
0xd0, 0xac, 0x6c, 0x1f, 0x30, 0x6c, 0xed, 0xae, 0xc4, 0x7f, 0x32, 0x30, 0xe3, 0x06, 0x7e, 0x48,
0x2c, 0xf1, 0x2b, 0x8f, 0x8c, 0x3c, 0xaa, 0x82, 0x99, 0x88, 0x9b, 0x27, 0x0a, 0x98, 0xb2, 0x19,
0xde, 0x8c, 0xda, 0x2e, 0x47, 0xcf, 0x5d, 0xea, 0x06, 0x4c, 0x7d, 0x00, 0x8a, 0x31, 0x82, 0x50,
0x9f, 0x77, 0x35, 0x65, 0x41, 0xa9, 0x16, 0x9b, 0xda, 0xc9, 0x41, 0xad, 0x22, 0x49, 0x34, 0xda,
0x6d, 0x8a, 0x18, 0x7b, 0xc1, 0xa9, 0x1f, 0x62, 0xe7, 0x12, 0xaa, 0xae, 0x83, 0xb1, 0x48, 0x54,
0xd0, 0x86, 0x16, 0x94, 0x6a, 0x69, 0x75, 0x1e, 0xe6, 0x38, 0x01, 0x93, 0x26, 0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, 0xa3, 0x70, 0x7c,
0x66, 0x14, 0xbe, 0x9f, 0x19, 0x85, 0xd7, 0x77, 0xb1, 0xcf, 0xb7, 0x3b, 0x2d, 0xe8, 0x91, 0x40,
0x7e, 0x66, 0xad, 0xab, 0x1b, 0x10, 0x2f, 0x1f, 0x6b, 0x8d, 0x89, 0xc9, 0xad, 0xfd, 0x0e, 0x00,
0x00, 0xff, 0xff, 0xc2, 0x24, 0xb6, 0x0e, 0x00, 0x06, 0x00, 0x00,
}
// Reference imports to suppress errors if they are not otherwise used.
@ -345,6 +464,8 @@ type MsgClient interface {
UpdateParams(ctx context.Context, in *MsgUpdateParams, opts ...grpc.CallOption) (*MsgUpdateParamsResponse, error)
// NonAtomicExec allows users to submit multiple messages for non-atomic execution.
NonAtomicExec(ctx context.Context, in *MsgNonAtomicExec, opts ...grpc.CallOption) (*MsgNonAtomicExecResponse, error)
// MigrateAccount migrates the account to x/accounts.
MigrateAccount(ctx context.Context, in *MsgMigrateAccount, opts ...grpc.CallOption) (*MsgMigrateAccountResponse, error)
}
type msgClient struct {
@ -373,6 +494,15 @@ func (c *msgClient) NonAtomicExec(ctx context.Context, in *MsgNonAtomicExec, opt
return out, nil
}
func (c *msgClient) MigrateAccount(ctx context.Context, in *MsgMigrateAccount, opts ...grpc.CallOption) (*MsgMigrateAccountResponse, error) {
out := new(MsgMigrateAccountResponse)
err := c.cc.Invoke(ctx, "/cosmos.auth.v1beta1.Msg/MigrateAccount", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
// MsgServer is the server API for Msg service.
type MsgServer interface {
// UpdateParams defines a (governance) operation for updating the x/auth module
@ -380,6 +510,8 @@ type MsgServer interface {
UpdateParams(context.Context, *MsgUpdateParams) (*MsgUpdateParamsResponse, error)
// NonAtomicExec allows users to submit multiple messages for non-atomic execution.
NonAtomicExec(context.Context, *MsgNonAtomicExec) (*MsgNonAtomicExecResponse, error)
// MigrateAccount migrates the account to x/accounts.
MigrateAccount(context.Context, *MsgMigrateAccount) (*MsgMigrateAccountResponse, error)
}
// UnimplementedMsgServer can be embedded to have forward compatible implementations.
@ -392,6 +524,9 @@ func (*UnimplementedMsgServer) UpdateParams(ctx context.Context, req *MsgUpdateP
func (*UnimplementedMsgServer) NonAtomicExec(ctx context.Context, req *MsgNonAtomicExec) (*MsgNonAtomicExecResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method NonAtomicExec not implemented")
}
func (*UnimplementedMsgServer) MigrateAccount(ctx context.Context, req *MsgMigrateAccount) (*MsgMigrateAccountResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method MigrateAccount not implemented")
}
func RegisterMsgServer(s grpc1.Server, srv MsgServer) {
s.RegisterService(&_Msg_serviceDesc, srv)
@ -433,6 +568,24 @@ func _Msg_NonAtomicExec_Handler(srv interface{}, ctx context.Context, dec func(i
return interceptor(ctx, in, info, handler)
}
func _Msg_MigrateAccount_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(MsgMigrateAccount)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(MsgServer).MigrateAccount(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/cosmos.auth.v1beta1.Msg/MigrateAccount",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(MsgServer).MigrateAccount(ctx, req.(*MsgMigrateAccount))
}
return interceptor(ctx, in, info, handler)
}
var Msg_serviceDesc = _Msg_serviceDesc
var _Msg_serviceDesc = grpc.ServiceDesc{
ServiceName: "cosmos.auth.v1beta1.Msg",
@ -446,6 +599,10 @@ var _Msg_serviceDesc = grpc.ServiceDesc{
MethodName: "NonAtomicExec",
Handler: _Msg_NonAtomicExec_Handler,
},
{
MethodName: "MigrateAccount",
Handler: _Msg_MigrateAccount_Handler,
},
},
Streams: []grpc.StreamDesc{},
Metadata: "cosmos/auth/v1beta1/tx.proto",
@ -637,6 +794,90 @@ func (m *MsgNonAtomicExecResponse) MarshalToSizedBuffer(dAtA []byte) (int, error
return len(dAtA) - i, nil
}
func (m *MsgMigrateAccount) Marshal() (dAtA []byte, err error) {
size := m.Size()
dAtA = make([]byte, size)
n, err := m.MarshalToSizedBuffer(dAtA[:size])
if err != nil {
return nil, err
}
return dAtA[:n], nil
}
func (m *MsgMigrateAccount) MarshalTo(dAtA []byte) (int, error) {
size := m.Size()
return m.MarshalToSizedBuffer(dAtA[:size])
}
func (m *MsgMigrateAccount) MarshalToSizedBuffer(dAtA []byte) (int, error) {
i := len(dAtA)
_ = i
var l int
_ = l
if m.AccountInitMsg != nil {
{
size, err := m.AccountInitMsg.MarshalToSizedBuffer(dAtA[:i])
if err != nil {
return 0, err
}
i -= size
i = encodeVarintTx(dAtA, i, uint64(size))
}
i--
dAtA[i] = 0x1a
}
if len(m.AccountType) > 0 {
i -= len(m.AccountType)
copy(dAtA[i:], m.AccountType)
i = encodeVarintTx(dAtA, i, uint64(len(m.AccountType)))
i--
dAtA[i] = 0x12
}
if len(m.Signer) > 0 {
i -= len(m.Signer)
copy(dAtA[i:], m.Signer)
i = encodeVarintTx(dAtA, i, uint64(len(m.Signer)))
i--
dAtA[i] = 0xa
}
return len(dAtA) - i, nil
}
func (m *MsgMigrateAccountResponse) Marshal() (dAtA []byte, err error) {
size := m.Size()
dAtA = make([]byte, size)
n, err := m.MarshalToSizedBuffer(dAtA[:size])
if err != nil {
return nil, err
}
return dAtA[:n], nil
}
func (m *MsgMigrateAccountResponse) MarshalTo(dAtA []byte) (int, error) {
size := m.Size()
return m.MarshalToSizedBuffer(dAtA[:size])
}
func (m *MsgMigrateAccountResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) {
i := len(dAtA)
_ = i
var l int
_ = l
if m.InitResponse != nil {
{
size, err := m.InitResponse.MarshalToSizedBuffer(dAtA[:i])
if err != nil {
return 0, err
}
i -= size
i = encodeVarintTx(dAtA, i, uint64(size))
}
i--
dAtA[i] = 0xa
}
return len(dAtA) - i, nil
}
func encodeVarintTx(dAtA []byte, offset int, v uint64) int {
offset -= sovTx(v)
base := offset
@ -723,6 +964,40 @@ func (m *MsgNonAtomicExecResponse) Size() (n int) {
return n
}
func (m *MsgMigrateAccount) Size() (n int) {
if m == nil {
return 0
}
var l int
_ = l
l = len(m.Signer)
if l > 0 {
n += 1 + l + sovTx(uint64(l))
}
l = len(m.AccountType)
if l > 0 {
n += 1 + l + sovTx(uint64(l))
}
if m.AccountInitMsg != nil {
l = m.AccountInitMsg.Size()
n += 1 + l + sovTx(uint64(l))
}
return n
}
func (m *MsgMigrateAccountResponse) Size() (n int) {
if m == nil {
return 0
}
var l int
_ = l
if m.InitResponse != nil {
l = m.InitResponse.Size()
n += 1 + l + sovTx(uint64(l))
}
return n
}
func sovTx(x uint64) (n int) {
return (math_bits.Len64(x|1) + 6) / 7
}
@ -1212,6 +1487,242 @@ func (m *MsgNonAtomicExecResponse) Unmarshal(dAtA []byte) error {
}
return nil
}
func (m *MsgMigrateAccount) Unmarshal(dAtA []byte) error {
l := len(dAtA)
iNdEx := 0
for iNdEx < l {
preIndex := iNdEx
var wire uint64
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowTx
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
wire |= uint64(b&0x7F) << shift
if b < 0x80 {
break
}
}
fieldNum := int32(wire >> 3)
wireType := int(wire & 0x7)
if wireType == 4 {
return fmt.Errorf("proto: MsgMigrateAccount: wiretype end group for non-group")
}
if fieldNum <= 0 {
return fmt.Errorf("proto: MsgMigrateAccount: illegal tag %d (wire type %d)", fieldNum, wire)
}
switch fieldNum {
case 1:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field Signer", wireType)
}
var stringLen uint64
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowTx
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
stringLen |= uint64(b&0x7F) << shift
if b < 0x80 {
break
}
}
intStringLen := int(stringLen)
if intStringLen < 0 {
return ErrInvalidLengthTx
}
postIndex := iNdEx + intStringLen
if postIndex < 0 {
return ErrInvalidLengthTx
}
if postIndex > l {
return io.ErrUnexpectedEOF
}
m.Signer = string(dAtA[iNdEx:postIndex])
iNdEx = postIndex
case 2:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field AccountType", wireType)
}
var stringLen uint64
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowTx
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
stringLen |= uint64(b&0x7F) << shift
if b < 0x80 {
break
}
}
intStringLen := int(stringLen)
if intStringLen < 0 {
return ErrInvalidLengthTx
}
postIndex := iNdEx + intStringLen
if postIndex < 0 {
return ErrInvalidLengthTx
}
if postIndex > l {
return io.ErrUnexpectedEOF
}
m.AccountType = string(dAtA[iNdEx:postIndex])
iNdEx = postIndex
case 3:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field AccountInitMsg", wireType)
}
var msglen int
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowTx
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
msglen |= int(b&0x7F) << shift
if b < 0x80 {
break
}
}
if msglen < 0 {
return ErrInvalidLengthTx
}
postIndex := iNdEx + msglen
if postIndex < 0 {
return ErrInvalidLengthTx
}
if postIndex > l {
return io.ErrUnexpectedEOF
}
if m.AccountInitMsg == nil {
m.AccountInitMsg = &any.Any{}
}
if err := m.AccountInitMsg.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
return err
}
iNdEx = postIndex
default:
iNdEx = preIndex
skippy, err := skipTx(dAtA[iNdEx:])
if err != nil {
return err
}
if (skippy < 0) || (iNdEx+skippy) < 0 {
return ErrInvalidLengthTx
}
if (iNdEx + skippy) > l {
return io.ErrUnexpectedEOF
}
iNdEx += skippy
}
}
if iNdEx > l {
return io.ErrUnexpectedEOF
}
return nil
}
func (m *MsgMigrateAccountResponse) Unmarshal(dAtA []byte) error {
l := len(dAtA)
iNdEx := 0
for iNdEx < l {
preIndex := iNdEx
var wire uint64
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowTx
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
wire |= uint64(b&0x7F) << shift
if b < 0x80 {
break
}
}
fieldNum := int32(wire >> 3)
wireType := int(wire & 0x7)
if wireType == 4 {
return fmt.Errorf("proto: MsgMigrateAccountResponse: wiretype end group for non-group")
}
if fieldNum <= 0 {
return fmt.Errorf("proto: MsgMigrateAccountResponse: illegal tag %d (wire type %d)", fieldNum, wire)
}
switch fieldNum {
case 1:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field InitResponse", wireType)
}
var msglen int
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowTx
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
msglen |= int(b&0x7F) << shift
if b < 0x80 {
break
}
}
if msglen < 0 {
return ErrInvalidLengthTx
}
postIndex := iNdEx + msglen
if postIndex < 0 {
return ErrInvalidLengthTx
}
if postIndex > l {
return io.ErrUnexpectedEOF
}
if m.InitResponse == nil {
m.InitResponse = &any.Any{}
}
if err := m.InitResponse.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
return err
}
iNdEx = postIndex
default:
iNdEx = preIndex
skippy, err := skipTx(dAtA[iNdEx:])
if err != nil {
return err
}
if (skippy < 0) || (iNdEx+skippy) < 0 {
return ErrInvalidLengthTx
}
if (iNdEx + skippy) > l {
return io.ErrUnexpectedEOF
}
iNdEx += skippy
}
}
if iNdEx > l {
return io.ErrUnexpectedEOF
}
return nil
}
func skipTx(dAtA []byte) (n int, err error) {
l := len(dAtA)
iNdEx := 0