Skip to content

Commit

Permalink
fix: referral api timestamp consistency
Browse files Browse the repository at this point in the history
  • Loading branch information
ettec committed Oct 16, 2023
1 parent a32e296 commit d3c3abc
Show file tree
Hide file tree
Showing 7 changed files with 76 additions and 33 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@
- [8729](https://github.com/vegaprotocol/vega/issues/8729) - Stop order direction not set in datanode
- [8545](https://github.com/vegaprotocol/vega/issues/8545) - Block Explorer pagination does not order correctly.
- [8748](https://github.com/vegaprotocol/vega/issues/8748) - `ListSuccessorMarkets` does not return results.
- [9784](https://github.com/vegaprotocol/vega/issues/9784) - Referral timestamp consistency
- [8749](https://github.com/vegaprotocol/vega/issues/8749) - Ensure stop order expiry is in the future
- [9337](https://github.com/vegaprotocol/vega/issues/9337) - Non deterministic ordering of vesting ledger events
- [8773](https://github.com/vegaprotocol/vega/issues/8773) - Fix panic with stop orders
Expand Down
76 changes: 52 additions & 24 deletions datanode/gateway/graphql/generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions datanode/gateway/graphql/referral_program_resolver.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,3 +66,8 @@ func (r *currentReferralProgramResolver) WindowLength(ctx context.Context, obj *

return int(obj.WindowLength), nil
}

func (r currentReferralProgramResolver) EndOfProgramTimestamp(_ context.Context, obj *v2.ReferralProgram) (string, error) {
endTime := time.Unix(obj.EndOfProgramTimestamp/1e9, 0)
return endTime.Format(time.RFC3339), nil
}
12 changes: 6 additions & 6 deletions datanode/gateway/graphql/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -4360,8 +4360,8 @@ type StakingTier {
type UpdateVolumeDiscountProgram {
"The benefit tiers for the program"
benefitTiers: [VolumeBenefitTier!]!
"The end time of the program"
endOfProgramTimestamp: Timestamp!
"Timestamp as RFC3339, after which program ends."
endOfProgramTimestamp: String!
"The window length to consider for the volume discount program"
windowLength: Int!
}
Expand Down Expand Up @@ -6004,8 +6004,8 @@ type CurrentReferralProgram {
version: Int!
"Defined tiers in increasing order. First element will give Tier 1, second element will give Tier 2, etc."
benefitTiers: [BenefitTier!]!
"Timestamp as RFC3339Nano, after which when the current epoch ends, the program will end and benefits will be disabled."
endOfProgramTimestamp: Timestamp!
"Timestamp as RFC3339, after which when the current epoch ends, the programs will end and benefits will be disabled."
endOfProgramTimestamp: String!
"Number of epochs over which to evaluate a referral set's running volume."
windowLength: Int!
"""
Expand Down Expand Up @@ -6257,8 +6257,8 @@ type VolumeDiscountProgram {
version: Int!
"Defined tiers in increasing order. First element will give Tier 1, second element will give Tier 2, etc."
benefitTiers: [VolumeBenefitTier!]!
"Timestamp as Unix time in nanoseconds, after which when the current epoch ends, the programs will end and benefits will be disabled."
endOfProgramTimestamp: Timestamp!
"Timestamp as RFC3339, after which when the current epoch ends, the programs will end and benefits will be disabled."
endOfProgramTimestamp: String!
"Number of epochs over which to evaluate parties' running volume."
windowLength: Int!
"Timestamp as RFC3339Nano when the program ended. If present, the current program has ended and no program is currently running."
Expand Down
3 changes: 2 additions & 1 deletion datanode/gateway/graphql/update_referral_program_resolver.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ func (u updateReferralProgramResolver) BenefitTiers(_ context.Context, obj *vega
}

func (u updateReferralProgramResolver) EndOfProgramTimestamp(_ context.Context, obj *vega.UpdateReferralProgram) (string, error) {
return time.Unix(obj.Changes.EndOfProgramTimestamp, 0).String(), nil
endTime := time.Unix(obj.Changes.EndOfProgramTimestamp, 0)
return endTime.Format(time.RFC3339), nil
}

func (u updateReferralProgramResolver) WindowLength(_ context.Context, obj *vega.UpdateReferralProgram) (int, error) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ package gql

import (
"context"
"time"

"code.vegaprotocol.io/vega/protos/vega"
)
Expand All @@ -31,8 +32,9 @@ func (r *updateVolumeDiscountProgramResolver) BenefitTiers(

func (r *updateVolumeDiscountProgramResolver) EndOfProgramTimestamp(
_ context.Context, obj *vega.UpdateVolumeDiscountProgram,
) (int64, error) {
return obj.Changes.EndOfProgramTimestamp, nil
) (string, error) {
endTime := time.Unix(obj.Changes.EndOfProgramTimestamp, 0)
return endTime.Format(time.RFC3339), nil
}

func (r *updateVolumeDiscountProgramResolver) WindowLength(
Expand Down
6 changes: 6 additions & 0 deletions datanode/gateway/graphql/volume_discount_program_resolver.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
"context"
"errors"
"math"
"time"

v2 "code.vegaprotocol.io/vega/protos/data-node/api/v2"
)
Expand All @@ -40,3 +41,8 @@ func (r *volumeDiscountProgramResolver) WindowLength(_ context.Context, obj *v2.

return int(obj.WindowLength), nil
}

func (r volumeDiscountProgramResolver) EndOfProgramTimestamp(_ context.Context, obj *v2.VolumeDiscountProgram) (string, error) {
endTime := time.Unix(obj.EndOfProgramTimestamp/1e9, 0)
return endTime.Format(time.RFC3339), nil
}

0 comments on commit d3c3abc

Please sign in to comment.