Take lockup distribution file in command args
Some checks failed
Protobuf / lint (pull_request) Successful in 7s
Integration Tests / test-integration (pull_request) Failing after 1m12s
E2E Tests / test-e2e (pull_request) Failing after 1m28s
Unit Tests / test-unit (pull_request) Successful in 59s
SDK Tests / sdk_tests_nameservice_expiry (pull_request) Successful in 5m28s
SDK Tests / sdk_tests_authority_auctions (pull_request) Successful in 11m1s
SDK Tests / sdk_tests (pull_request) Successful in 14m50s

This commit is contained in:
Prathamesh Musale 2025-05-16 12:22:53 +05:30
parent 3d87a74557
commit 541024fbfa

View File

@ -3,6 +3,7 @@ package cmd
import (
"encoding/json"
"fmt"
"os"
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/codec"
@ -25,9 +26,9 @@ const (
// AddGenesisLockupAccountCmd returns add-genesis-lockup-account cobra Command.
func AddGenesisLockupAccountCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "add-genesis-lockup-account <account_name> <coin>[,<coin>...]",
Use: "add-genesis-lockup-account <account_name> <distribution-json-file> <coin>[,<coin>...]",
Short: "Add genesis lockup account with give name",
Args: cobra.ExactArgs(2),
Args: cobra.ExactArgs(3),
RunE: func(cmd *cobra.Command, args []string) error {
clientCtx := client.GetClientContextFromCmd(cmd)
serverCtx := server.GetServerContextFromCmd(cmd)
@ -36,9 +37,20 @@ func AddGenesisLockupAccountCmd() *cobra.Command {
config.SetRoot(clientCtx.HomeDir)
moduleName := args[0]
distributionFilePath := args[1]
var distribution map[string]interface{}
distributionBytes, err := os.ReadFile(distributionFilePath)
if err != nil {
return fmt.Errorf("failed to read %s file: %w", distributionFilePath, err)
}
if err = json.Unmarshal(distributionBytes, &distribution); err != nil {
return fmt.Errorf("distribution is invalid json: %v", err)
}
appendflag, _ := cmd.Flags().GetBool(flagAppendMode)
return AddGenesisAccount(clientCtx.Codec, moduleName, appendflag, config.GenesisFile(), args[1])
return AddGenesisLockupAccount(clientCtx.Codec, moduleName, string(distributionBytes), appendflag, config.GenesisFile(), args[2])
},
}
@ -47,9 +59,10 @@ func AddGenesisLockupAccountCmd() *cobra.Command {
return cmd
}
func AddGenesisAccount(
func AddGenesisLockupAccount(
cdc codec.Codec,
moduleName string,
distribution string,
appendAcct bool,
genesisFileURL, amountStr string,
) error {
@ -66,7 +79,7 @@ func AddGenesisAccount(
genAccount := &types.LockupAccount{
BaseAccount: moduleAccount.BaseAccount,
Name: moduleAccount.Name,
Distribution: "",
Distribution: distribution,
}
if err := genAccount.Validate(); err != nil {