Skip to content

Commit

Permalink
feat(auth): allow BaseAccounts to be migrated to x/accounts (backport #…
Browse files Browse the repository at this point in the history
…21820) (#21863)

Co-authored-by: testinginprod <[email protected]>
Co-authored-by: Julien Robert <[email protected]>
  • Loading branch information
3 people authored Sep 24, 2024
1 parent 0255823 commit 72f1c12
Show file tree
Hide file tree
Showing 67 changed files with 924 additions and 140 deletions.
2 changes: 1 addition & 1 deletion client/v2/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ replace github.com/cosmos/cosmos-sdk => ./../../
// TODO remove post spinning out all modules
replace (
// pseudo version lower than the latest tag
cosmossdk.io/api => cosmossdk.io/api v0.7.3-0.20240923144907-a7a0daf704cc // main
cosmossdk.io/api => cosmossdk.io/api v0.7.3-0.20240924065902-eb7653cfecdf // main
// pseudo version lower than the latest tag
cosmossdk.io/store => cosmossdk.io/store v1.0.0-rc.0.0.20240913190136-3bc707a5a214 // main
cosmossdk.io/x/bank => ./../../x/bank
Expand Down
4 changes: 2 additions & 2 deletions client/v2/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.34.2-20240130113600-88e
buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.34.2-20240130113600-88ef6483f90f.2/go.mod h1:HqcXMSa5qnNuakaMUo+hWhF51mKbcrZxGl9Vp5EeJXc=
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
cosmossdk.io/api v0.7.3-0.20240923144907-a7a0daf704cc h1:K5PhEYqcivMxbboZkdIcWuBlujg6KqK+1VehqMF8ZKM=
cosmossdk.io/api v0.7.3-0.20240923144907-a7a0daf704cc/go.mod h1:YMfx2ATpgITsoydD3hIBa8IkDHtyXp/14rmG0d3sEew=
cosmossdk.io/api v0.7.3-0.20240924065902-eb7653cfecdf h1:CttA/mEIxGm4E7vwrjUpju7/Iespns08d9bOza70cIc=
cosmossdk.io/api v0.7.3-0.20240924065902-eb7653cfecdf/go.mod h1:YMfx2ATpgITsoydD3hIBa8IkDHtyXp/14rmG0d3sEew=
cosmossdk.io/collections v0.4.1-0.20240802064046-23fac2f1b8ab h1:E/IWad76v1Nc4Atswaccpt7twJ0VwHkbY94/PhmZfTo=
cosmossdk.io/collections v0.4.1-0.20240802064046-23fac2f1b8ab/go.mod h1:Or+5eVAo1aiS1DnPK90eQykGc59LGBWtqwBoJcxXTmw=
cosmossdk.io/core v1.0.0-alpha.3 h1:pnxaYAas7llXgVz1lM7X6De74nWrhNKnB3yMKe4OUUA=
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ require (
// TODO remove after all modules have their own go.mods
replace (
// pseudo version lower than the latest tag
cosmossdk.io/api => cosmossdk.io/api v0.7.3-0.20240923144907-a7a0daf704cc // main
cosmossdk.io/api => cosmossdk.io/api v0.7.3-0.20240924065902-eb7653cfecdf // main
// pseudo version lower than the latest tag
cosmossdk.io/store => cosmossdk.io/store v1.0.0-rc.0.0.20240913190136-3bc707a5a214 // main
cosmossdk.io/x/bank => ./x/bank
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.34.2-20240130113600-88e
buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.34.2-20240130113600-88ef6483f90f.2/go.mod h1:HqcXMSa5qnNuakaMUo+hWhF51mKbcrZxGl9Vp5EeJXc=
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
cosmossdk.io/api v0.7.3-0.20240923144907-a7a0daf704cc h1:K5PhEYqcivMxbboZkdIcWuBlujg6KqK+1VehqMF8ZKM=
cosmossdk.io/api v0.7.3-0.20240923144907-a7a0daf704cc/go.mod h1:YMfx2ATpgITsoydD3hIBa8IkDHtyXp/14rmG0d3sEew=
cosmossdk.io/api v0.7.3-0.20240924065902-eb7653cfecdf h1:CttA/mEIxGm4E7vwrjUpju7/Iespns08d9bOza70cIc=
cosmossdk.io/api v0.7.3-0.20240924065902-eb7653cfecdf/go.mod h1:YMfx2ATpgITsoydD3hIBa8IkDHtyXp/14rmG0d3sEew=
cosmossdk.io/collections v0.4.1-0.20240802064046-23fac2f1b8ab h1:E/IWad76v1Nc4Atswaccpt7twJ0VwHkbY94/PhmZfTo=
cosmossdk.io/collections v0.4.1-0.20240802064046-23fac2f1b8ab/go.mod h1:Or+5eVAo1aiS1DnPK90eQykGc59LGBWtqwBoJcxXTmw=
cosmossdk.io/core v1.0.0-alpha.3 h1:pnxaYAas7llXgVz1lM7X6De74nWrhNKnB3yMKe4OUUA=
Expand Down
2 changes: 1 addition & 1 deletion proto/cosmos/auth/v1beta1/accounts.proto
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
22 changes: 22 additions & 0 deletions proto/cosmos/auth/v1beta1/tx.proto
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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;
}
2 changes: 1 addition & 1 deletion server/v2/cometbft/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ go 1.23.1

replace (
// pseudo version lower than the latest tag
cosmossdk.io/api => cosmossdk.io/api v0.7.3-0.20240923144907-a7a0daf704cc // main
cosmossdk.io/api => cosmossdk.io/api v0.7.3-0.20240924065902-eb7653cfecdf // main
// pseudo version lower than the latest tag
cosmossdk.io/core => cosmossdk.io/core v1.0.0-alpha.3 // main
// pseudo version lower than the latest tag
Expand Down
4 changes: 2 additions & 2 deletions server/v2/cometbft/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.34.2-20240130113600-88e
buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.34.2-20240130113600-88ef6483f90f.2/go.mod h1:HqcXMSa5qnNuakaMUo+hWhF51mKbcrZxGl9Vp5EeJXc=
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
cosmossdk.io/api v0.7.3-0.20240923144907-a7a0daf704cc h1:K5PhEYqcivMxbboZkdIcWuBlujg6KqK+1VehqMF8ZKM=
cosmossdk.io/api v0.7.3-0.20240923144907-a7a0daf704cc/go.mod h1:YMfx2ATpgITsoydD3hIBa8IkDHtyXp/14rmG0d3sEew=
cosmossdk.io/api v0.7.3-0.20240924065902-eb7653cfecdf h1:CttA/mEIxGm4E7vwrjUpju7/Iespns08d9bOza70cIc=
cosmossdk.io/api v0.7.3-0.20240924065902-eb7653cfecdf/go.mod h1:YMfx2ATpgITsoydD3hIBa8IkDHtyXp/14rmG0d3sEew=
cosmossdk.io/collections v0.4.1-0.20240802064046-23fac2f1b8ab h1:E/IWad76v1Nc4Atswaccpt7twJ0VwHkbY94/PhmZfTo=
cosmossdk.io/collections v0.4.1-0.20240802064046-23fac2f1b8ab/go.mod h1:Or+5eVAo1aiS1DnPK90eQykGc59LGBWtqwBoJcxXTmw=
cosmossdk.io/core v1.0.0-alpha.3 h1:pnxaYAas7llXgVz1lM7X6De74nWrhNKnB3yMKe4OUUA=
Expand Down
2 changes: 1 addition & 1 deletion simapp/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ require (
// SimApp on main always tests the latest extracted SDK modules importing the sdk
replace (
// pseudo version lower than the latest tag
cosmossdk.io/api => cosmossdk.io/api v0.7.3-0.20240923144907-a7a0daf704cc // main
cosmossdk.io/api => cosmossdk.io/api v0.7.3-0.20240924065902-eb7653cfecdf // main
cosmossdk.io/client/v2 => ../client/v2
// pseudo version lower than the latest tag
cosmossdk.io/store => cosmossdk.io/store v1.0.0-rc.0.0.20240913190136-3bc707a5a214 // main
Expand Down
4 changes: 2 additions & 2 deletions simapp/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -192,8 +192,8 @@ cloud.google.com/go/webrisk v1.4.0/go.mod h1:Hn8X6Zr+ziE2aNd8SliSDWpEnSS1u4R9+xX
cloud.google.com/go/webrisk v1.5.0/go.mod h1:iPG6fr52Tv7sGk0H6qUFzmL3HHZev1htXuWDEEsqMTg=
cloud.google.com/go/workflows v1.6.0/go.mod h1:6t9F5h/unJz41YqfBmqSASJSXccBLtD1Vwf+KmJENM0=
cloud.google.com/go/workflows v1.7.0/go.mod h1:JhSrZuVZWuiDfKEFxU0/F1PQjmpnpcoISEXH2bcHC3M=
cosmossdk.io/api v0.7.3-0.20240923144907-a7a0daf704cc h1:K5PhEYqcivMxbboZkdIcWuBlujg6KqK+1VehqMF8ZKM=
cosmossdk.io/api v0.7.3-0.20240923144907-a7a0daf704cc/go.mod h1:YMfx2ATpgITsoydD3hIBa8IkDHtyXp/14rmG0d3sEew=
cosmossdk.io/api v0.7.3-0.20240924065902-eb7653cfecdf h1:CttA/mEIxGm4E7vwrjUpju7/Iespns08d9bOza70cIc=
cosmossdk.io/api v0.7.3-0.20240924065902-eb7653cfecdf/go.mod h1:YMfx2ATpgITsoydD3hIBa8IkDHtyXp/14rmG0d3sEew=
cosmossdk.io/collections v0.4.1-0.20240802064046-23fac2f1b8ab h1:E/IWad76v1Nc4Atswaccpt7twJ0VwHkbY94/PhmZfTo=
cosmossdk.io/collections v0.4.1-0.20240802064046-23fac2f1b8ab/go.mod h1:Or+5eVAo1aiS1DnPK90eQykGc59LGBWtqwBoJcxXTmw=
cosmossdk.io/core v1.0.0-alpha.3 h1:pnxaYAas7llXgVz1lM7X6De74nWrhNKnB3yMKe4OUUA=
Expand Down
2 changes: 1 addition & 1 deletion simapp/v2/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ require (
// SimApp on main always tests the latest extracted SDK modules importing the sdk
replace (
// pseudo version lower than the latest tag
cosmossdk.io/api => cosmossdk.io/api v0.7.3-0.20240923144907-a7a0daf704cc // main
cosmossdk.io/api => cosmossdk.io/api v0.7.3-0.20240924065902-eb7653cfecdf // main
cosmossdk.io/client/v2 => ../../client/v2
// pseudo version lower than the latest tag
cosmossdk.io/core => cosmossdk.io/core v1.0.0-alpha.3.0.20240920095614-aa90bb43d8f8 // main
Expand Down
4 changes: 2 additions & 2 deletions simapp/v2/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -192,8 +192,8 @@ cloud.google.com/go/webrisk v1.4.0/go.mod h1:Hn8X6Zr+ziE2aNd8SliSDWpEnSS1u4R9+xX
cloud.google.com/go/webrisk v1.5.0/go.mod h1:iPG6fr52Tv7sGk0H6qUFzmL3HHZev1htXuWDEEsqMTg=
cloud.google.com/go/workflows v1.6.0/go.mod h1:6t9F5h/unJz41YqfBmqSASJSXccBLtD1Vwf+KmJENM0=
cloud.google.com/go/workflows v1.7.0/go.mod h1:JhSrZuVZWuiDfKEFxU0/F1PQjmpnpcoISEXH2bcHC3M=
cosmossdk.io/api v0.7.3-0.20240923144907-a7a0daf704cc h1:K5PhEYqcivMxbboZkdIcWuBlujg6KqK+1VehqMF8ZKM=
cosmossdk.io/api v0.7.3-0.20240923144907-a7a0daf704cc/go.mod h1:YMfx2ATpgITsoydD3hIBa8IkDHtyXp/14rmG0d3sEew=
cosmossdk.io/api v0.7.3-0.20240924065902-eb7653cfecdf h1:CttA/mEIxGm4E7vwrjUpju7/Iespns08d9bOza70cIc=
cosmossdk.io/api v0.7.3-0.20240924065902-eb7653cfecdf/go.mod h1:YMfx2ATpgITsoydD3hIBa8IkDHtyXp/14rmG0d3sEew=
cosmossdk.io/collections v0.4.1-0.20240802064046-23fac2f1b8ab h1:E/IWad76v1Nc4Atswaccpt7twJ0VwHkbY94/PhmZfTo=
cosmossdk.io/collections v0.4.1-0.20240802064046-23fac2f1b8ab/go.mod h1:Or+5eVAo1aiS1DnPK90eQykGc59LGBWtqwBoJcxXTmw=
cosmossdk.io/core v1.0.0-alpha.3.0.20240920095614-aa90bb43d8f8 h1:kBXv2cxy3M6nGQozQBAg6fmzeLT839GRuOy3CuITDbY=
Expand Down
2 changes: 1 addition & 1 deletion tests/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ require (
// SimApp on main always tests the latest extracted SDK modules importing the sdk
replace (
// pseudo version lower than the latest tag
cosmossdk.io/api => cosmossdk.io/api v0.7.3-0.20240923144907-a7a0daf704cc // main
cosmossdk.io/api => cosmossdk.io/api v0.7.3-0.20240924065902-eb7653cfecdf // main
cosmossdk.io/client/v2 => ../client/v2
// pseudo version lower than the latest tag
cosmossdk.io/store => cosmossdk.io/store v1.0.0-rc.0.0.20240913190136-3bc707a5a214 // main
Expand Down
4 changes: 2 additions & 2 deletions tests/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -192,8 +192,8 @@ cloud.google.com/go/webrisk v1.4.0/go.mod h1:Hn8X6Zr+ziE2aNd8SliSDWpEnSS1u4R9+xX
cloud.google.com/go/webrisk v1.5.0/go.mod h1:iPG6fr52Tv7sGk0H6qUFzmL3HHZev1htXuWDEEsqMTg=
cloud.google.com/go/workflows v1.6.0/go.mod h1:6t9F5h/unJz41YqfBmqSASJSXccBLtD1Vwf+KmJENM0=
cloud.google.com/go/workflows v1.7.0/go.mod h1:JhSrZuVZWuiDfKEFxU0/F1PQjmpnpcoISEXH2bcHC3M=
cosmossdk.io/api v0.7.3-0.20240923144907-a7a0daf704cc h1:K5PhEYqcivMxbboZkdIcWuBlujg6KqK+1VehqMF8ZKM=
cosmossdk.io/api v0.7.3-0.20240923144907-a7a0daf704cc/go.mod h1:YMfx2ATpgITsoydD3hIBa8IkDHtyXp/14rmG0d3sEew=
cosmossdk.io/api v0.7.3-0.20240924065902-eb7653cfecdf h1:CttA/mEIxGm4E7vwrjUpju7/Iespns08d9bOza70cIc=
cosmossdk.io/api v0.7.3-0.20240924065902-eb7653cfecdf/go.mod h1:YMfx2ATpgITsoydD3hIBa8IkDHtyXp/14rmG0d3sEew=
cosmossdk.io/collections v0.4.1-0.20240802064046-23fac2f1b8ab h1:E/IWad76v1Nc4Atswaccpt7twJ0VwHkbY94/PhmZfTo=
cosmossdk.io/collections v0.4.1-0.20240802064046-23fac2f1b8ab/go.mod h1:Or+5eVAo1aiS1DnPK90eQykGc59LGBWtqwBoJcxXTmw=
cosmossdk.io/core v1.0.0-alpha.3 h1:pnxaYAas7llXgVz1lM7X6De74nWrhNKnB3yMKe4OUUA=
Expand Down
100 changes: 100 additions & 0 deletions tests/integration/auth/keeper/migrate_x_accounts_test.go
Original file line number Diff line number Diff line change
@@ -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)
})
}
19 changes: 19 additions & 0 deletions x/accounts/defaults/base/account.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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)
}
2 changes: 1 addition & 1 deletion x/accounts/defaults/base/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ replace github.com/cosmos/cosmos-sdk => ../../../../.

replace (
// pseudo version lower than the latest tag
cosmossdk.io/api => cosmossdk.io/api v0.7.3-0.20240923144907-a7a0daf704cc // main
cosmossdk.io/api => cosmossdk.io/api v0.7.3-0.20240924065902-eb7653cfecdf // main
// pseudo version lower than the latest tag
cosmossdk.io/store => cosmossdk.io/store v1.0.0-rc.0.0.20240913190136-3bc707a5a214 // main
cosmossdk.io/x/accounts => ../../.
Expand Down
4 changes: 2 additions & 2 deletions x/accounts/defaults/base/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.34.2-20240130113600-88e
buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.34.2-20240130113600-88ef6483f90f.2/go.mod h1:HqcXMSa5qnNuakaMUo+hWhF51mKbcrZxGl9Vp5EeJXc=
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
cosmossdk.io/api v0.7.3-0.20240923144907-a7a0daf704cc h1:K5PhEYqcivMxbboZkdIcWuBlujg6KqK+1VehqMF8ZKM=
cosmossdk.io/api v0.7.3-0.20240923144907-a7a0daf704cc/go.mod h1:YMfx2ATpgITsoydD3hIBa8IkDHtyXp/14rmG0d3sEew=
cosmossdk.io/api v0.7.3-0.20240924065902-eb7653cfecdf h1:CttA/mEIxGm4E7vwrjUpju7/Iespns08d9bOza70cIc=
cosmossdk.io/api v0.7.3-0.20240924065902-eb7653cfecdf/go.mod h1:YMfx2ATpgITsoydD3hIBa8IkDHtyXp/14rmG0d3sEew=
cosmossdk.io/collections v0.4.1-0.20240802064046-23fac2f1b8ab h1:E/IWad76v1Nc4Atswaccpt7twJ0VwHkbY94/PhmZfTo=
cosmossdk.io/collections v0.4.1-0.20240802064046-23fac2f1b8ab/go.mod h1:Or+5eVAo1aiS1DnPK90eQykGc59LGBWtqwBoJcxXTmw=
cosmossdk.io/core v1.0.0-alpha.3 h1:pnxaYAas7llXgVz1lM7X6De74nWrhNKnB3yMKe4OUUA=
Expand Down
Loading

0 comments on commit 72f1c12

Please sign in to comment.