Skip to content

Commit

Permalink
rename refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronc committed May 28, 2024
1 parent 65f60c7 commit 356a2ff
Show file tree
Hide file tree
Showing 9 changed files with 12 additions and 10 deletions.
2 changes: 1 addition & 1 deletion x/ecocredit/base/keeper/msg_cancel.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func (k Keeper) Cancel(ctx context.Context, req *types.MsgCancel) (*types.MsgCan
if err != nil {
return nil, sdkerrors.ErrInvalidRequest.Wrapf("could not get batch with denom %s: %s", credit.BatchDenom, err.Error())
}
creditType, err := utils.GetCreditTypeFromBatchDenom(ctx, k.stateStore, batch)
creditType, err := utils.GetCreditTypeFromBatch(ctx, k.stateStore, batch)
if err != nil {
return nil, err
}
Expand Down
2 changes: 1 addition & 1 deletion x/ecocredit/base/keeper/msg_mint_batch_credits.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func (k Keeper) MintBatchCredits(ctx context.Context, req *types.MsgMintBatchCre
return nil, err
}

ct, err := utils.GetCreditTypeFromBatchDenom(ctx, k.stateStore, batch)
ct, err := utils.GetCreditTypeFromBatch(ctx, k.stateStore, batch)
if err != nil {
return nil, err
}
Expand Down
2 changes: 1 addition & 1 deletion x/ecocredit/base/keeper/msg_retire.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func (k Keeper) Retire(ctx context.Context, req *types.MsgRetire) (*types.MsgRet
if err != nil {
return nil, sdkerrors.ErrInvalidRequest.Wrapf("could not get batch with denom %s: %s", credit.BatchDenom, err.Error())
}
creditType, err := utils.GetCreditTypeFromBatchDenom(ctx, k.stateStore, batch)
creditType, err := utils.GetCreditTypeFromBatch(ctx, k.stateStore, batch)
if err != nil {
return nil, err
}
Expand Down
2 changes: 1 addition & 1 deletion x/ecocredit/base/keeper/msg_send.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func (k Keeper) Send(ctx context.Context, req *types.MsgSend) (*types.MsgSendRes
}

// get credit type precision
creditType, err := utils.GetCreditTypeFromBatchDenom(ctx, k.stateStore, batch)
creditType, err := utils.GetCreditTypeFromBatch(ctx, k.stateStore, batch)
if err != nil {
return nil, err
}
Expand Down
2 changes: 1 addition & 1 deletion x/ecocredit/marketplace/keeper/msg_buy_direct.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ func (k Keeper) BuyDirect(ctx context.Context, req *types.MsgBuyDirect) (*types.
if err != nil {
return nil, err
}
ct, err := utils.GetCreditTypeFromBatchDenom(ctx, k.baseStore, batch)
ct, err := utils.GetCreditTypeFromBatch(ctx, k.baseStore, batch)
if err != nil {
return nil, err
}
Expand Down
2 changes: 1 addition & 1 deletion x/ecocredit/marketplace/keeper/msg_sell.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func (k Keeper) Sell(ctx context.Context, req *types.MsgSell) (*types.MsgSellRes
)
}

creditType, err := utils.GetCreditTypeFromBatchDenom(ctx, k.baseStore, batch)
creditType, err := utils.GetCreditTypeFromBatch(ctx, k.baseStore, batch)
if err != nil {
return nil, err
}
Expand Down
2 changes: 1 addition & 1 deletion x/ecocredit/marketplace/keeper/msg_update_sell_orders.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ func (k Keeper) getCreditTypeFromBatchKey(ctx context.Context, key uint64) (*bas
if err != nil {
return nil, err
}
creditType, err := utils.GetCreditTypeFromBatchDenom(ctx, k.baseStore, batch)
creditType, err := utils.GetCreditTypeFromBatch(ctx, k.baseStore, batch)
if err != nil {
return nil, err
}
Expand Down
6 changes: 4 additions & 2 deletions x/ecocredit/server/utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@ import (
"github.com/regen-network/regen-ledger/types/v2/math"
)

// GetCreditTypeFromBatchDenom extracts the classID from a batch denom string, then retrieves it from the params.
func GetCreditTypeFromBatchDenom(ctx context.Context, store api.StateStore, batch *api.Batch) (*api.CreditType, error) {
// GetCreditTypeFromBatch extracts the credit type from a batch by querying the class table for the class key, and then
// querying the credit type table for the credit type abbreviation. This is a convenience function for use in message
// handlers, where the credit type is needed to perform further operations on the batch.
func GetCreditTypeFromBatch(ctx context.Context, store api.StateStore, batch *api.Batch) (*api.CreditType, error) {
cls, err := store.ClassTable().Get(ctx, batch.ClassKey)
if err != nil {
return nil, err
Expand Down
2 changes: 1 addition & 1 deletion x/ecocredit/server/utils/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ func TestUtils_GetCreditTypeFromBatchDenom(t *testing.T) {
ClassKey: clsKey,
}
assert.NilError(t, s.stateStore.BatchTable().Insert(s.ctx, batch))
ct, err := GetCreditTypeFromBatchDenom(s.ctx, s.stateStore, batch)
ct, err := GetCreditTypeFromBatch(s.ctx, s.stateStore, batch)
assert.NilError(t, err)
assert.DeepEqual(t, ct, creditType, cmpopts.IgnoreUnexported(api.CreditType{}))
}

0 comments on commit 356a2ff

Please sign in to comment.