Skip to content

Commit

Permalink
fix(all): enforce UTC where time.Time is used (#1194)
Browse files Browse the repository at this point in the history
Co-authored-by: tyler <{ID}+{username}@users.noreply.github.com>
Co-authored-by: Ryan Christoffersen <[email protected]>
  • Loading branch information
3 people authored Jun 21, 2022
1 parent 22622fb commit 22d6564
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 4 deletions.
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

0 comments on commit 22d6564

Please sign in to comment.