Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(x/accounts): lockup account document, Tx and InitGenesis #23397

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion simapp/v2/app_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,12 +151,12 @@ var (
// NOTE: The genutils module must also occur after auth so that it can access the params from auth.
InitGenesis: []string{
consensustypes.ModuleName,
accounts.ModuleName,
authtypes.ModuleName,
banktypes.ModuleName,
// bankv2types.ModuleName,
distrtypes.ModuleName,
stakingtypes.ModuleName,
accounts.ModuleName,
slashingtypes.ModuleName,
govtypes.ModuleName,
minttypes.ModuleName,
Expand Down
8 changes: 4 additions & 4 deletions x/accounts/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -545,12 +545,12 @@ For example, given the following `genesis.json` file:
"init_account_msgs": [
{
"sender": "account_creator_address",
"account_type": "lockup",
"account_type": "lockup_account_type",
"message": {
"@type": "cosmos.accounts.defaults.lockup.MsgInitLockupAccount",
"@type": "/cosmos.accounts.defaults.lockup.v1.MsgInitLockupAccount",
"owner": "some_owner",
"end_time": "..",
"start_time": ".."
"end_time": "2026-01-01T00:00:00Z",
"start_time": "2025-01-01T00:00:00Z"
},
"funds": [
{
Expand Down
10 changes: 8 additions & 2 deletions x/accounts/cli/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
"github.com/cosmos/cosmos-sdk/client/flags"
"github.com/cosmos/cosmos-sdk/client/tx"
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
sdk "github.com/cosmos/cosmos-sdk/types"
)

func TxCmd(name string) *cobra.Command {
Expand All @@ -41,9 +42,9 @@ func QueryCmd(name string) *cobra.Command {

func GetTxInitCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "init <account-type> <json-message>",
Use: "init <account-type> <json-message> <fund>[,<fund>...]",
Short: "Initialize a new account",
Args: cobra.ExactArgs(2),
Args: cobra.ExactArgs(3),
RunE: func(cmd *cobra.Command, args []string) error {
clientCtx, err := client.GetClientTxContext(cmd)
if err != nil {
Expand All @@ -69,10 +70,15 @@ func GetTxInitCmd() *cobra.Command {
if err != nil {
return err
}
funds, err := sdk.ParseCoinsNormalized(args[2])
if err != nil {
return err
}
msg := v1.MsgInit{
Sender: sender,
AccountType: args[0],
Message: msgBytes,
Funds: funds,
}

isGenesis, err := cmd.Flags().GetBool("genesis")
Expand Down
14 changes: 7 additions & 7 deletions x/accounts/defaults/lockup/TUTORIAL.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ Whereas `execute-msg-type-url` and `msgcontents` corresponds to lockup account

### Delegate

The execute message type url for this execution is `cosmos.accounts.defaults.lockup.MsgDelegate`.
The execute message type url for this execution is `cosmos.accounts.defaults.lockup.v1.MsgDelegate`.

Example of json file:

Expand All @@ -125,7 +125,7 @@ The `sender` field are the address of the owner of the lockup account. If the se

### Undelegate

The execute message type url for this execution is `cosmos.accounts.defaults.lockup.MsgUndelegate`.
The execute message type url for this execution is `cosmos.accounts.defaults.lockup.v1.MsgUndelegate`.

Example of json file:

Expand All @@ -146,7 +146,7 @@ The `sender` field are the address of the owner of the lockup account. If the se

### Withdraw reward

The execute message type url for this execution is `cosmos.accounts.defaults.lockup.MsgWithdrawReward`.
The execute message type url for this execution is `cosmos.accounts.defaults.lockup.v1.MsgWithdrawReward`.

Example of json file:

Expand All @@ -163,7 +163,7 @@ The `sender` field are the address of the owner of the lockup account. If the se

### Withdraw unlocked token

The execute message type url for this execution is `cosmos.accounts.defaults.lockup.MsgWithdraw`.
The execute message type url for this execution is `cosmos.accounts.defaults.lockup.v1.MsgWithdraw`.

Example of json file:

Expand All @@ -183,7 +183,7 @@ The `withdrawer` field are the address of the owner of the lockup account. If th

### Send coins

The execute message type url for this execution is `cosmos.accounts.defaults.lockup.MsgSend`.
The execute message type url for this execution is `cosmos.accounts.defaults.lockup.v1.MsgSend`.

Example of json file:

Expand Down Expand Up @@ -213,7 +213,7 @@ simd tx accounts query <account_address> <query-request-type-url> $querycontents

### Query account info

The query request type url for this query is `cosmos.accounts.defaults.lockup.QueryLockupAccountInfoRequest`. And query json file can be an empty object since `QueryLockupAccountInfoRequest` does not required an input.
The query request type url for this query is `cosmos.accounts.defaults.lockup.v1.QueryLockupAccountInfoRequest`. And query json file can be an empty object since `QueryLockupAccountInfoRequest` does not required an input.

Account information including:

Expand All @@ -235,7 +235,7 @@ Account information including:
Note, can only be queried from a periodic lockup account
:::

The query request type url for this query is `cosmos.accounts.defaults.lockup.QueryLockingPeriodsRequest`. And query json file can be an empty object since `QueryLockingPeriodsRequest` does not required an input.
The query request type url for this query is `cosmos.accounts.defaults.lockup.v1.QueryLockingPeriodsRequest`. And query json file can be an empty object since `QueryLockingPeriodsRequest` does not required an input.

Locking periods including:

Expand Down
11 changes: 6 additions & 5 deletions x/accounts/go.mod
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
module cosmossdk.io/x/accounts

go 1.23.3
go 1.23.4
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Invalid Go version specified.

The Go version 1.23.4 is incorrect as it does not exist. The latest stable version of Go is 1.22.x.

-go 1.23.4
+go 1.22.1
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
go 1.23.4
go 1.22.1


require (
cosmossdk.io/api v0.8.1
cosmossdk.io/collections v1.0.0
cosmossdk.io/core v1.0.0
cosmossdk.io/core/testing v0.0.1
cosmossdk.io/depinject v1.1.0
cosmossdk.io/x/bank v0.0.0-20240226161501-23359a0b6d91
cosmossdk.io/x/bank v0.0.0-20241218110910-47409028a73d
cosmossdk.io/x/tx v1.0.0
github.com/cosmos/cosmos-sdk v0.53.0
github.com/cosmos/gogoproto v1.7.0
Expand Down Expand Up @@ -40,8 +40,9 @@ require (
cosmossdk.io/log v1.5.0 // indirect
cosmossdk.io/math v1.5.0
cosmossdk.io/schema v1.0.0
cosmossdk.io/store v1.10.0-rc.1 // indirect
cosmossdk.io/x/staking v0.0.0-00010101000000-000000000000 // indirect
cosmossdk.io/store v1.10.0-rc.1.0.20241218084712-ca559989da43 // indirect
cosmossdk.io/x/accounts/defaults/lockup v0.2.0-rc.1
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

any chance we can avoid this import?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Msgs for lockup account were added in v0.2.0.
I think this code is needed to import the type from cosmossdk.io.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you can register the type in another way, you may replace it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can register them in the app.go directly maybe. Could be something we add to the x/accounts documentation.

cosmossdk.io/x/staking v0.0.0-20241218110910-47409028a73d // indirect
filippo.io/edwards25519 v1.1.0 // indirect
github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4 // indirect
github.com/99designs/keyring v1.2.2 // indirect
Expand Down Expand Up @@ -142,7 +143,7 @@ require (
github.com/zondax/ledger-go v0.14.3 // indirect
gitlab.com/yawning/secp256k1-voi v0.0.0-20230925100816-f2616030848b // indirect
gitlab.com/yawning/tuplehash v0.0.0-20230713102510-df83abbf9a02 // indirect
go.etcd.io/bbolt v1.4.0-alpha.0.0.20240404170359-43604f3112c5 // indirect
go.etcd.io/bbolt v1.4.0-alpha.1 // indirect
go.opencensus.io v0.24.0 // indirect
go.uber.org/mock v0.5.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
Expand Down
6 changes: 6 additions & 0 deletions x/accounts/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ cosmossdk.io/schema v1.0.0 h1:/diH4XJjpV1JQwuIozwr+A4uFuuwanFdnw2kKeiXwwQ=
cosmossdk.io/schema v1.0.0/go.mod h1:RDAhxIeNB4bYqAlF4NBJwRrgtnciMcyyg0DOKnhNZQQ=
cosmossdk.io/store v1.10.0-rc.1 h1:/YVPJLre7lt/QDbl90k95TLt+IvafF1sHaU6WHd/rpc=
cosmossdk.io/store v1.10.0-rc.1/go.mod h1:eZNgZKvZRlDUk8CE3LTDVMAcSM7zLOet2S8fByQkF3s=
cosmossdk.io/store v1.10.0-rc.1.0.20241218084712-ca559989da43 h1:glZ6MpmD+5AhwJYV4jzx+rn7cgUB2owHgk9o+93luz0=
cosmossdk.io/store v1.10.0-rc.1.0.20241218084712-ca559989da43/go.mod h1:XCWpgfueHSBY+B7Cf2Aq/CcsU+6XoFH+EmseCKglFrU=
cosmossdk.io/x/accounts/defaults/lockup v0.2.0-rc.1 h1:sA1DfJUgEH6Pkeub7Wt9jXxe7IVeXder/vIrr0F8qMY=
cosmossdk.io/x/accounts/defaults/lockup v0.2.0-rc.1/go.mod h1:izqe1W1exX452AlezXCQt1Hyd3nU2vLYLU/Cftx/Lx4=
cosmossdk.io/x/tx v1.0.0 h1:pUUKRvHiMUZC/MnO8v747k1lUEA1DfAq0j0y0Mqrz/o=
cosmossdk.io/x/tx v1.0.0/go.mod h1:AXYJ47btzkcWuT1OtA3M44dv1iiYbKomtopHEbQGgH4=
filippo.io/edwards25519 v1.1.0 h1:FNf4tywRC1HmFuKW5xopWpigGjJKiJSV0Cqo0cJWDaA=
Expand Down Expand Up @@ -480,6 +484,8 @@ gitlab.com/yawning/tuplehash v0.0.0-20230713102510-df83abbf9a02 h1:qwDnMxjkyLmAF
gitlab.com/yawning/tuplehash v0.0.0-20230713102510-df83abbf9a02/go.mod h1:JTnUj0mpYiAsuZLmKjTx/ex3AtMowcCgnE7YNyCEP0I=
go.etcd.io/bbolt v1.4.0-alpha.0.0.20240404170359-43604f3112c5 h1:qxen9oVGzDdIRP6ejyAJc760RwW4SnVDiTYTzwnXuxo=
go.etcd.io/bbolt v1.4.0-alpha.0.0.20240404170359-43604f3112c5/go.mod h1:eW0HG9/oHQhvRCvb1/pIXW4cOvtDqeQK+XSi3TnwaXY=
go.etcd.io/bbolt v1.4.0-alpha.1 h1:3yrqQzbRRPFPdOMWS/QQIVxVnzSkAZQYeWlZFv1kbj4=
go.etcd.io/bbolt v1.4.0-alpha.1/go.mod h1:S/Z/Nm3iuOnyO1W4XuFfPci51Gj6F1Hv0z8hisyYYOw=
go.opencensus.io v0.24.0 h1:y73uSU6J157QMP2kn2r30vwW1A2W2WFwSCGnAVxeaD0=
go.opencensus.io v0.24.0/go.mod h1:vNK8G9p7aAivkbmorf4v+7Hgx+Zs0yY+0fOtgBfjQKo=
go.opentelemetry.io/otel v1.31.0 h1:NsJcKPIW0D0H3NgzPDHmo0WW6SptzPdqg/L1zsIm2hY=
Expand Down
9 changes: 9 additions & 0 deletions x/accounts/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@ import (
"cosmossdk.io/core/registry"
"cosmossdk.io/schema"
"cosmossdk.io/x/accounts/cli"
lockuptypes "cosmossdk.io/x/accounts/defaults/lockup/v1"
v1 "cosmossdk.io/x/accounts/v1"

sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/address"
"github.com/cosmos/cosmos-sdk/types/msgservice"
)
Expand Down Expand Up @@ -51,6 +53,13 @@ func (AppModule) IsAppModule() {}
func (am AppModule) Name() string { return ModuleName }

func (AppModule) RegisterInterfaces(registrar registry.InterfaceRegistrar) {
registrar.RegisterImplementations((*sdk.Msg)(nil),
&lockuptypes.MsgDelegate{},
&lockuptypes.MsgUndelegate{},
&lockuptypes.MsgWithdrawReward{},
&lockuptypes.MsgSend{},
)

msgservice.RegisterMsgServiceDesc(registrar, v1.MsgServiceDesc())
}

Expand Down
Loading