Use custom KV store gas config for set record operation

This commit is contained in:
Prathamesh Musale 2024-04-03 10:09:02 +05:30
parent 1ea6d6b647
commit 4531d9238f

View File

@ -3,6 +3,8 @@ package keeper
import (
"context"
storetypes "github.com/cosmos/cosmos-sdk/store/types"
"github.com/cerc-io/laconicd/x/registry/types"
sdk "github.com/cosmos/cosmos-sdk/types"
)
@ -20,6 +22,8 @@ var _ types.MsgServer = msgServer{}
func (m msgServer) SetRecord(c context.Context, msg *types.MsgSetRecord) (*types.MsgSetRecordResponse, error) {
ctx := sdk.UnwrapSDKContext(c)
ctx = *m.ctxWithCustomKVGasConfig(&ctx)
_, err := sdk.AccAddressFromBech32(msg.Signer)
if err != nil {
return nil, err
@ -284,3 +288,16 @@ func (m msgServer) ReAssociateRecords(c context.Context, msg *types.MsgReAssocia
})
return &types.MsgReAssociateRecordsResponse{}, nil
}
func (m msgServer) ctxWithCustomKVGasConfig(ctx *sdk.Context) *sdk.Context {
updatedCtx := ctx.WithKVGasConfig(storetypes.GasConfig{
HasCost: 0,
DeleteCost: 0,
ReadCostFlat: 0,
ReadCostPerByte: 0,
WriteCostFlat: 0,
WriteCostPerByte: 0,
IterNextCostFlat: 0,
})
return &updatedCtx
}