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: enforce UTC where time.Time is used #1194

Merged
merged 2 commits into from
Jun 21, 2022
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 x/ecocredit/core/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,10 @@ func FormatBatchDenom(projectId string, batchSeqNo uint64, startDate, endDate *t
projectId,

// Start Date as YYYYMMDD
startDate.Format("20060102"),
startDate.UTC().Format("20060102"),

// End Date as YYYYMMDD
endDate.Format("20060102"),
endDate.UTC().Format("20060102"),

// Batch sequence number padded to at least three digits
batchSeqNo,
Expand Down
2 changes: 1 addition & 1 deletion x/ecocredit/server/core/create_batch.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ func (k Keeper) CreateBatch(ctx context.Context, req *core.MsgCreateBatch) (*cor
return nil, err
}

startDate, endDate := timestamppb.New(req.StartDate.UTC()), timestamppb.New(req.EndDate.UTC())
startDate, endDate := timestamppb.New(*req.StartDate), timestamppb.New(*req.EndDate)
issuanceDate := timestamppb.New(sdkCtx.BlockTime())
batchKey, err := k.stateStore.BatchTable().InsertReturningID(ctx, &api.Batch{
ProjectKey: projectInfo.Key,
Expand Down
2 changes: 1 addition & 1 deletion x/ecocredit/server/marketplace/msg_sell.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ func (k Keeper) Sell(ctx context.Context, req *marketplace.MsgSell) (*marketplac
}

// verify expiration is in the future
if order.Expiration != nil && !order.Expiration.After(sdkCtx.BlockTime()) {
if order.Expiration != nil && !order.Expiration.UTC().After(sdkCtx.BlockTime()) {
return nil, sdkerrors.ErrInvalidRequest.Wrapf(
"%s: expiration must be in the future: %s", orderIndex, order.Expiration,
)
Expand Down
4 changes: 4 additions & 0 deletions x/ecocredit/server/marketplace/msg_update_sell_orders.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,10 @@ func (k Keeper) applySellOrderUpdates(ctx context.Context, updateIndex string, o
}

if update.NewExpiration != nil {
// force to UTC
expirationUTC := update.NewExpiration.UTC()
update.NewExpiration = &expirationUTC

// verify expiration is in the future
if !update.NewExpiration.After(sdkCtx.BlockTime()) {
return sdkerrors.ErrInvalidRequest.Wrapf(
Expand Down