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(rollapp): field image and app_creation_cost renaming #1177

Merged
Merged
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
4 changes: 2 additions & 2 deletions proto/dymensionxyz/dymension/rollapp/app.proto
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ message App {
string rollapp_id = 2;
// description is the description of the App
string description = 3;
// image is the relative path to the App image
string image = 4;
// image_url is the URL to the App's image
string image_url = 4;
// url is the URL to the App's website
string url = 5;
// order is the order of the App in the Rollapp
Expand Down
6 changes: 3 additions & 3 deletions proto/dymensionxyz/dymension/rollapp/params.proto
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ message Params {
uint64 liveness_slash_interval = 5 [(gogoproto.moretags) = "yaml:\"liveness_slash_interval\""];
// The time (num hub blocks) a sequencer can be down after which he will be jailed rather than slashed
uint64 liveness_jail_blocks = 6 [(gogoproto.moretags) = "yaml:\"liveness_jail_blocks\""];
// app_creation_cost is the cost for registering the App
cosmos.base.v1beta1.Coin app_creation_cost = 7 [
// app_registration_fee is the fee for registering an App
cosmos.base.v1beta1.Coin app_registration_fee = 7 [
(gogoproto.nullable) = false,
(gogoproto.moretags) = "yaml:\"app_creation_cost\""
(gogoproto.moretags) = "yaml:\"app_registration_fee\""
];
}
12 changes: 6 additions & 6 deletions x/rollapp/keeper/msg_server_app.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,16 @@ func (k msgServer) AddApp(goCtx context.Context, msg *types.MsgAddApp) (*types.M
msg.Order = -1
}

// charge the app creation fee
// charge the app registration fee
creator := sdk.MustAccAddressFromBech32(msg.Creator)
appCost := sdk.NewCoins(k.AppCreationCost(ctx))
appFee := sdk.NewCoins(k.AppRegistrationFee(ctx))

if err := k.bankKeeper.SendCoinsFromAccountToModule(ctx, creator, types.ModuleName, appCost); err != nil {
return nil, types.ErrAppCreationCostPayment
if err := k.bankKeeper.SendCoinsFromAccountToModule(ctx, creator, types.ModuleName, appFee); err != nil {
return nil, types.ErrAppRegistrationFeePayment
}

if err := k.bankKeeper.BurnCoins(ctx, types.ModuleName, appCost); err != nil {
return nil, types.ErrAppCreationCostPayment
if err := k.bankKeeper.BurnCoins(ctx, types.ModuleName, appFee); err != nil {
return nil, types.ErrAppRegistrationFeePayment
}

app := msg.GetApp()
Expand Down
8 changes: 4 additions & 4 deletions x/rollapp/keeper/msg_server_app_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func (suite *RollappTestSuite) createRollappWithApp() types.RollappSummary {
Name: req.GetName(),
RollappId: req.GetRollappId(),
Description: req.GetDescription(),
Image: req.GetImage(),
ImageUrl: req.GetImage(),
Url: req.GetUrl(),
Order: req.GetOrder(),
}
Expand Down Expand Up @@ -206,10 +206,10 @@ func (suite *RollappTestSuite) Test_msgServer_AddApp() {
},
malleate: func() {
params := suite.App.RollappKeeper.GetParams(suite.Ctx)
params.AppCreationCost = sdk.NewInt64Coin("arax", 1)
params.AppRegistrationFee = sdk.NewInt64Coin("arax", 1)
suite.App.RollappKeeper.SetParams(suite.Ctx, params)
},
wantErr: types.ErrAppCreationCostPayment,
wantErr: types.ErrAppRegistrationFeePayment,
},
}
for _, tt := range tests {
Expand Down Expand Up @@ -400,7 +400,7 @@ func (suite *RollappTestSuite) Test_msgServer_UpdateApp() {
for i, app := range rollapp.Apps {
suite.Require().Equal(tt.msgs[i].Order, app.Order)
suite.Require().Equal(tt.msgs[i].Description, app.Description)
suite.Require().Equal(tt.msgs[i].Image, app.Image)
suite.Require().Equal(tt.msgs[i].Image, app.ImageUrl)
suite.Require().Equal(tt.msgs[i].Url, app.Url)
}
})
Expand Down
8 changes: 4 additions & 4 deletions x/rollapp/keeper/params.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ func (k Keeper) GetParams(ctx sdk.Context) types.Params {
k.LivenessSlashBlocks(ctx),
k.LivenessSlashInterval(ctx),
k.LivenessJailBlocks(ctx),
k.AppCreationCost(ctx),
k.AppRegistrationFee(ctx),
)
}

Expand Down Expand Up @@ -43,8 +43,8 @@ func (k Keeper) LivenessJailBlocks(ctx sdk.Context) (res uint64) {
return
}

// AppCreationCost returns the cost of adding an app
func (k Keeper) AppCreationCost(ctx sdk.Context) (res sdk.Coin) {
k.paramstore.Get(ctx, types.KeyAppCreationCost, &res)
// AppRegistrationFee returns the cost of adding an app
func (k Keeper) AppRegistrationFee(ctx sdk.Context) (res sdk.Coin) {
k.paramstore.Get(ctx, types.KeyAppRegistrationFee, &res)
return
}
4 changes: 2 additions & 2 deletions x/rollapp/types/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ func NewApp(name, rollappId, description, image, url string, order int32) App {
Name: name,
RollappId: rollappId,
Description: description,
Image: image,
ImageUrl: image,
Url: url,
Order: order,
}
Expand Down Expand Up @@ -50,7 +50,7 @@ func (r App) ValidateBasic() error {
return ErrInvalidDescription
}

if err := validateURL(r.Image); err != nil {
if err := validateURL(r.ImageUrl); err != nil {
return errorsmod.Wrap(ErrInvalidAppImage, err.Error())
}

Expand Down
43 changes: 22 additions & 21 deletions x/rollapp/types/app.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion x/rollapp/types/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ var (
ErrWrongBlockHeight = errorsmod.Register(ModuleName, 1009, "start-height does not match rollapps state")
ErrInvalidGenesisChecksum = errorsmod.Register(ModuleName, 1010, "invalid genesis checksum")
ErrInvalidStateRoot = errorsmod.Register(ModuleName, 1011, "invalid blocks state root")
ErrAppCreationCostPayment = errorsmod.Register(ModuleName, 1013, "app creation cost payment error")
ErrAppRegistrationFeePayment = errorsmod.Register(ModuleName, 1013, "app registration fee payment error")
ErrStateNotExists = errorsmod.Register(ModuleName, 1017, "state of this height doesn't exist")
ErrInvalidHeight = errorsmod.Register(ModuleName, 1018, "invalid rollapp height")
ErrInvalidRollappID = errorsmod.Register(ModuleName, 1020, "invalid rollapp-id")
Expand Down
22 changes: 11 additions & 11 deletions x/rollapp/types/params.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ var (
KeyLivenessSlashInterval = []byte("LivenessSlashInterval")
KeyLivenessJailBlocks = []byte("LivenessJailBlocks")

// KeyAppCreationCost defines the key to store the cost of the app
KeyAppCreationCost = []byte("KeyAppCreationCost")
// KeyAppRegistrationFee defines the key to store the cost of the app
KeyAppRegistrationFee = []byte("KeyAppRegistrationFee")

// DYM is 1dym
DYM = sdk.NewIntFromBigInt(new(big.Int).Exp(big.NewInt(10), big.NewInt(18), nil))
DefaultAppCreationCost = sdk.NewCoin(params.BaseDenom, DYM)
DYM = sdk.NewIntFromBigInt(new(big.Int).Exp(big.NewInt(10), big.NewInt(18), nil))
DefaultAppRegistrationFee = sdk.NewCoin(params.BaseDenom, DYM)
)

const (
Expand All @@ -53,14 +53,14 @@ func NewParams(
livenessSlashBlocks uint64,
livenessSlashInterval uint64,
livenessJailBlocks uint64,
appCreationCost sdk.Coin,
appRegistrationFee sdk.Coin,
) Params {
return Params{
DisputePeriodInBlocks: disputePeriodInBlocks,
LivenessSlashBlocks: livenessSlashBlocks,
LivenessSlashInterval: livenessSlashInterval,
LivenessJailBlocks: livenessJailBlocks,
AppCreationCost: appCreationCost,
AppRegistrationFee: appRegistrationFee,
}
}

Expand All @@ -70,7 +70,7 @@ func DefaultParams() Params {
DefaultLivenessSlashBlocks,
DefaultLivenessSlashInterval,
DefaultLivenessJailBlocks,
DefaultAppCreationCost,
DefaultAppRegistrationFee,
)
}

Expand All @@ -81,7 +81,7 @@ func (p *Params) ParamSetPairs() paramtypes.ParamSetPairs {
paramtypes.NewParamSetPair(KeyLivenessSlashBlocks, &p.LivenessSlashBlocks, validateLivenessSlashBlocks),
paramtypes.NewParamSetPair(KeyLivenessSlashInterval, &p.LivenessSlashInterval, validateLivenessSlashInterval),
paramtypes.NewParamSetPair(KeyLivenessJailBlocks, &p.LivenessJailBlocks, validateLivenessJailBlocks),
paramtypes.NewParamSetPair(KeyAppCreationCost, &p.AppCreationCost, validateAppCreationCost),
paramtypes.NewParamSetPair(KeyAppRegistrationFee, &p.AppRegistrationFee, validateAppRegistrationFee),
}
}

Expand Down Expand Up @@ -121,8 +121,8 @@ func (p Params) Validate() error {
return errorsmod.Wrap(err, "liveness jail blocks")
}

if err := validateAppCreationCost(p.AppCreationCost); err != nil {
return errorsmod.Wrap(err, "app creation cost")
if err := validateAppRegistrationFee(p.AppRegistrationFee); err != nil {
return errorsmod.Wrap(err, "app registration fee")
}
return nil
}
Expand Down Expand Up @@ -159,7 +159,7 @@ func validateDisputePeriodInBlocks(v interface{}) error {
return nil
}

func validateAppCreationCost(i interface{}) error {
func validateAppRegistrationFee(i interface{}) error {
v, ok := i.(sdk.Coin)
if !ok {
return fmt.Errorf("invalid parameter type: %T", i)
Expand Down
Loading
Loading