code.vegaprotocol.io/vega@v0.79.0/datanode/gateway/graphql/epoch_timestamps_resolver.go (about) 1 // Copyright (C) 2023 Gobalsky Labs Limited 2 // 3 // This program is free software: you can redistribute it and/or modify 4 // it under the terms of the GNU Affero General Public License as 5 // published by the Free Software Foundation, either version 3 of the 6 // License, or (at your option) any later version. 7 // 8 // This program is distributed in the hope that it will be useful, 9 // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 // GNU Affero General Public License for more details. 12 // 13 // You should have received a copy of the GNU Affero General Public License 14 // along with this program. If not, see <http://www.gnu.org/licenses/>. 15 16 package gql 17 18 import ( 19 "context" 20 "strconv" 21 22 "code.vegaprotocol.io/vega/libs/ptr" 23 proto "code.vegaprotocol.io/vega/protos/vega" 24 ) 25 26 type epochTimestampsResolver VegaResolverRoot 27 28 func (r *epochTimestampsResolver) Start(ctx context.Context, obj *proto.EpochTimestamps) (*int64, error) { 29 var t *int64 30 if obj.StartTime > 0 { 31 t = ptr.From(obj.StartTime) 32 } 33 return t, nil 34 } 35 36 func (r *epochTimestampsResolver) End(ctx context.Context, obj *proto.EpochTimestamps) (*int64, error) { 37 var t *int64 38 if obj.EndTime > 0 { 39 t = ptr.From(obj.EndTime) 40 } 41 return t, nil 42 } 43 44 func (r *epochTimestampsResolver) Expiry(ctx context.Context, obj *proto.EpochTimestamps) (*int64, error) { 45 var t *int64 46 if obj.ExpiryTime > 0 { 47 t = ptr.From(obj.ExpiryTime) 48 } 49 return t, nil 50 } 51 52 func (r *epochTimestampsResolver) FirstBlock(_ context.Context, obj *proto.EpochTimestamps) (string, error) { 53 return strconv.FormatUint(obj.FirstBlock, 10), nil 54 } 55 56 func (r *epochTimestampsResolver) LastBlock(_ context.Context, obj *proto.EpochTimestamps) (*string, error) { 57 var ret *string 58 if obj.LastBlock > 0 { 59 lastBlock := strconv.FormatUint(obj.LastBlock, 10) 60 ret = &lastBlock 61 } 62 return ret, nil 63 }