Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
3 changes: 2 additions & 1 deletion app/apptesting/test_suite.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"time"

bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper"
"github.com/dymensionxyz/sdk-utils/utils/uptr"

"github.com/dymensionxyz/dymension/v3/app/params"
dymnstypes "github.com/dymensionxyz/dymension/v3/x/dymns/types"
Expand Down Expand Up @@ -59,7 +60,7 @@ func (s *KeeperTestHelper) CreateRollappByName(name string) {
GenesisInfo: rollapptypes.GenesisInfo{
Bech32Prefix: strings.ToLower(rand.Str(3)),
GenesisChecksum: "1234567890abcdefg",
InitialSupply: sdk.NewInt(1000),
InitialSupply: uptr.To(sdk.NewInt(1000)),
NativeDenom: &rollapptypes.DenomMetadata{
Display: "DEN",
Base: "aden",
Expand Down
3 changes: 2 additions & 1 deletion app/upgrades/v4/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package v4
import (
"github.com/cometbft/cometbft/crypto"
"github.com/cosmos/cosmos-sdk/baseapp"
"github.com/dymensionxyz/sdk-utils/utils/uptr"
epochskeeper "github.com/osmosis-labs/osmosis/v15/x/epochs/keeper"

sdk "github.com/cosmos/cosmos-sdk/types"
Expand Down Expand Up @@ -231,7 +232,7 @@ func ConvertOldRollappToNew(oldRollapp rollapptypes.Rollapp) rollapptypes.Rollap
Base: "aden", // placeholder data
Exponent: 6, // placeholder data
},
InitialSupply: sdk.NewInt(100000), // placeholder data
InitialSupply: uptr.To(sdk.NewInt(100000)), // placeholder data
Sealed: true,
},
InitialSequencer: "*",
Expand Down
2 changes: 1 addition & 1 deletion proto/dymensionxyz/dymension/rollapp/rollapp.proto
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ message GenesisInfo {
// initial_supply is the initial supply of the native token
string initial_supply = 4 [
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int",
(gogoproto.nullable) = false
(gogoproto.nullable) = true
Copy link
Contributor

Choose a reason for hiding this comment

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

isn't this field mandatory? not sure why u made it nullable

];
// sealed indicates if the fields in this object are no longer updatable
bool sealed = 5;
Expand Down
4 changes: 2 additions & 2 deletions x/rollapp/client/cli/tx_create_rollapp.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ func parseGenesisInfo(cmd *cobra.Command) (types.GenesisInfo, error) {
var (
genesisInfo types.GenesisInfo
err error
ok bool
)

genesisInfo.GenesisChecksum, err = cmd.Flags().GetString(FlagGenesisChecksum)
Expand Down Expand Up @@ -104,10 +103,11 @@ func parseGenesisInfo(cmd *cobra.Command) (types.GenesisInfo, error) {
}

if initialSupplyFlag != "" {
genesisInfo.InitialSupply, ok = sdk.NewIntFromString(initialSupplyFlag)
initialSupply, ok := sdk.NewIntFromString(initialSupplyFlag)
if !ok {
return types.GenesisInfo{}, fmt.Errorf("invalid initial supply: %s", initialSupplyFlag)
}
genesisInfo.InitialSupply = &initialSupply
}

return genesisInfo, nil
Expand Down
5 changes: 3 additions & 2 deletions x/rollapp/genesis_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"testing"

sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/dymensionxyz/sdk-utils/utils/uptr"
"github.com/stretchr/testify/require"

keepertest "github.com/dymensionxyz/dymension/v3/testutil/keeper"
Expand All @@ -27,13 +28,13 @@ func TestInitExportGenesis(t *testing.T) {
{
RollappId: rollappID1,
GenesisInfo: types.GenesisInfo{
InitialSupply: sdk.NewInt(1000),
InitialSupply: uptr.To(sdk.NewInt(1000)),
},
},
{
RollappId: rollappID2,
GenesisInfo: types.GenesisInfo{
InitialSupply: sdk.NewInt(1001),
InitialSupply: uptr.To(sdk.NewInt(1001)),
},
},
},
Expand Down
3 changes: 2 additions & 1 deletion x/rollapp/keeper/msg_server_create_rollapp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"strings"

sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
"github.com/dymensionxyz/sdk-utils/utils/uptr"

"github.com/cometbft/cometbft/libs/rand"
sdk "github.com/cosmos/cosmos-sdk/types"
Expand Down Expand Up @@ -391,5 +392,5 @@ var mockGenesisInfo = types.GenesisInfo{
Base: "aden",
Exponent: 18,
},
InitialSupply: sdk.NewInt(100000000),
InitialSupply: uptr.To(sdk.NewInt(100000000)),
}
71 changes: 65 additions & 6 deletions x/rollapp/keeper/msg_server_update_rollapp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func (suite *RollappTestSuite) TestUpdateRollapp() {
GenesisInfo: types.GenesisInfo{
Bech32Prefix: "new",
GenesisChecksum: "new_checksum",
InitialSupply: sdk.NewInt(1000),
InitialSupply: uptr.To(sdk.NewInt(1000)),
NativeDenom: &types.DenomMetadata{
Display: "DEN",
Base: "aden",
Expand All @@ -54,7 +54,7 @@ func (suite *RollappTestSuite) TestUpdateRollapp() {
GenesisInfo: types.GenesisInfo{
Bech32Prefix: "new",
GenesisChecksum: "new_checksum",
InitialSupply: sdk.NewInt(1000),
InitialSupply: uptr.To(sdk.NewInt(1000)),
NativeDenom: &types.DenomMetadata{
Display: "DEN",
Base: "aden",
Expand Down Expand Up @@ -141,11 +141,70 @@ func (suite *RollappTestSuite) TestUpdateRollapp() {
Owner: alice,
RollappId: rollappId,
GenesisInfo: types.GenesisInfo{
InitialSupply: sdk.NewInt(1000),
InitialSupply: uptr.To(sdk.NewInt(1000)),
},
},
genInfoSealed: true,
expError: types.ErrGenesisInfoSealed,
}, {
name: "Update rollapp: success - no genesis info, genesis info sealed",
update: &types.MsgUpdateRollappInformation{
Owner: alice,
RollappId: rollappId,
},
genInfoSealed: true,
expError: nil,
expRollapp: types.Rollapp{
RollappId: rollappId,
Owner: alice,
VmType: types.Rollapp_EVM,
Metadata: &types.RollappMetadata{},
GenesisInfo: types.GenesisInfo{
Bech32Prefix: "old",
GenesisChecksum: "old",
InitialSupply: uptr.To(sdk.NewInt(1000)),
NativeDenom: &types.DenomMetadata{
Display: "OLD",
Base: "aold",
Exponent: 18,
},
Sealed: true,
},
},
}, {
name: "Update rollapp: success - no initial supply, genesis info not sealed",
update: &types.MsgUpdateRollappInformation{
Owner: alice,
RollappId: rollappId,
GenesisInfo: types.GenesisInfo{
Bech32Prefix: "old",
GenesisChecksum: "old",
InitialSupply: nil,
NativeDenom: &types.DenomMetadata{
Display: "OLD",
Base: "aold",
Exponent: 18,
},
},
},
genInfoSealed: false,
expError: nil,
expRollapp: types.Rollapp{
RollappId: rollappId,
Owner: alice,
VmType: types.Rollapp_EVM,
Metadata: &types.RollappMetadata{},
GenesisInfo: types.GenesisInfo{
Bech32Prefix: "old",
GenesisChecksum: "old",
InitialSupply: uptr.To(sdk.NewInt(1000)),
NativeDenom: &types.DenomMetadata{
Display: "OLD",
Base: "aold",
Exponent: 18,
},
},
},
}, {
name: "Update rollapp: success - update metadata when sealed",
update: &types.MsgUpdateRollappInformation{
Expand All @@ -168,7 +227,7 @@ func (suite *RollappTestSuite) TestUpdateRollapp() {
GenesisInfo: types.GenesisInfo{
Bech32Prefix: "old",
GenesisChecksum: "old",
InitialSupply: sdk.NewInt(1000),
InitialSupply: uptr.To(sdk.NewInt(1000)),
NativeDenom: &types.DenomMetadata{
Display: "OLD",
Base: "aold",
Expand Down Expand Up @@ -201,7 +260,7 @@ func (suite *RollappTestSuite) TestUpdateRollapp() {
GenesisInfo: types.GenesisInfo{
Bech32Prefix: "old",
GenesisChecksum: "old",
InitialSupply: sdk.NewInt(1000),
InitialSupply: uptr.To(sdk.NewInt(1000)),
NativeDenom: &types.DenomMetadata{
Display: "OLD",
Base: "aold",
Expand Down Expand Up @@ -239,7 +298,7 @@ func (suite *RollappTestSuite) TestCreateAndUpdateRollapp() {
GenesisInfo: types.GenesisInfo{
Bech32Prefix: "rol",
GenesisChecksum: "checksum",
InitialSupply: sdk.NewInt(1000),
InitialSupply: uptr.To(sdk.NewInt(1000)),
NativeDenom: &types.DenomMetadata{
Display: "DEN",
Base: "aden",
Expand Down
2 changes: 1 addition & 1 deletion x/rollapp/keeper/rollapp.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ func (k Keeper) CheckAndUpdateRollappFields(ctx sdk.Context, update *types.MsgUp
current.GenesisInfo.NativeDenom = update.GenesisInfo.NativeDenom
}

if !update.GenesisInfo.InitialSupply.IsNil() {
if update.GenesisInfo.InitialSupply != nil && !update.GenesisInfo.InitialSupply.IsNil() {
current.GenesisInfo.InitialSupply = update.GenesisInfo.InitialSupply
}

Expand Down
3 changes: 2 additions & 1 deletion x/rollapp/simulation/create_rollapp.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"github.com/cosmos/cosmos-sdk/baseapp"
sdk "github.com/cosmos/cosmos-sdk/types"
simtypes "github.com/cosmos/cosmos-sdk/types/simulation"
"github.com/dymensionxyz/sdk-utils/utils/uptr"

"github.com/dymensionxyz/dymension/v3/simulation"
simulationtypes "github.com/dymensionxyz/dymension/v3/simulation/types"
Expand Down Expand Up @@ -49,7 +50,7 @@ func SimulateMsgCreateRollapp(ak simulationtypes.AccountKeeper, bk simulationtyp
Base: "udym",
Exponent: 6,
},
InitialSupply: sdk.NewInt(1000000000),
InitialSupply: uptr.To(sdk.NewInt(1000000000)),
},
}

Expand Down
Loading
Loading