Add service provider auctions #59
@ -13,7 +13,7 @@ On having some change in the GQL schema (for example: adding a new query) update
|
|||||||
go get github.com/99designs/gqlgen@v0.17.22
|
go get github.com/99designs/gqlgen@v0.17.22
|
||||||
|
|
||||||
# Generate bindings
|
# Generate bindings
|
||||||
# In gql
|
cd gql
|
||||||
go run github.com/99designs/gqlgen generate
|
go run github.com/99designs/gqlgen generate
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -168,13 +168,13 @@ type Auction {
|
|||||||
commitFee: Coin! # Fee required to bid/participate in the auction.
|
commitFee: Coin! # Fee required to bid/participate in the auction.
|
||||||
revealFee: Coin! # Reveal fee (paid back to bidders only if they unseal/reveal the bid).
|
revealFee: Coin! # Reveal fee (paid back to bidders only if they unseal/reveal the bid).
|
||||||
minimumBid: Coin! # Minimum bid amount.
|
minimumBid: Coin! # Minimum bid amount.
|
||||||
winnerAddresses: [String]! # Winner address.
|
winnerAddresses: [String!]! # Winner address.
|
||||||
winnerBids: [Coin]! # The winning bid amount.
|
winnerBids: [Coin!]! # The winning bid amount.
|
||||||
winnerPrice: Coin! # The price that the winner actually pays (2nd highest bid).
|
winnerPrice: Coin! # The price that the winner actually pays (2nd highest bid).
|
||||||
maxPrice: Coin! # Max bid amount for service provider auction.
|
maxPrice: Coin! # Max bid amount for service provider auction.
|
||||||
kind: String! # Auction kind.
|
kind: String! # Auction kind.
|
||||||
numProviders: Int # Number of service providers
|
numProviders: Int # Number of service providers
|
||||||
bids: [AuctionBid] # Bids make in the auction.
|
bids: [AuctionBid!]! # Bids made in the auction.
|
||||||
}
|
}
|
||||||
|
|
||||||
# Record defines the basic properties of an entity in the graph database.
|
# Record defines the basic properties of an entity in the graph database.
|
||||||
|
149
gql/generated.go
149
gql/generated.go
@ -2197,9 +2197,9 @@ func (ec *executionContext) _Auction_winnerAddresses(ctx context.Context, field
|
|||||||
}
|
}
|
||||||
return graphql.Null
|
return graphql.Null
|
||||||
}
|
}
|
||||||
res := resTmp.([]*string)
|
res := resTmp.([]string)
|
||||||
fc.Result = res
|
fc.Result = res
|
||||||
return ec.marshalNString2ᚕᚖstring(ctx, field.Selections, res)
|
return ec.marshalNString2ᚕstringᚄ(ctx, field.Selections, res)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ec *executionContext) fieldContext_Auction_winnerAddresses(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) {
|
func (ec *executionContext) fieldContext_Auction_winnerAddresses(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) {
|
||||||
@ -2243,7 +2243,7 @@ func (ec *executionContext) _Auction_winnerBids(ctx context.Context, field graph
|
|||||||
}
|
}
|
||||||
res := resTmp.([]*Coin)
|
res := resTmp.([]*Coin)
|
||||||
fc.Result = res
|
fc.Result = res
|
||||||
return ec.marshalNCoin2ᚕᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚐCoin(ctx, field.Selections, res)
|
return ec.marshalNCoin2ᚕᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚐCoinᚄ(ctx, field.Selections, res)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ec *executionContext) fieldContext_Auction_winnerBids(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) {
|
func (ec *executionContext) fieldContext_Auction_winnerBids(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) {
|
||||||
@ -2471,11 +2471,14 @@ func (ec *executionContext) _Auction_bids(ctx context.Context, field graphql.Col
|
|||||||
return graphql.Null
|
return graphql.Null
|
||||||
}
|
}
|
||||||
if resTmp == nil {
|
if resTmp == nil {
|
||||||
|
if !graphql.HasFieldError(ctx, fc) {
|
||||||
|
ec.Errorf(ctx, "must not be null")
|
||||||
|
}
|
||||||
return graphql.Null
|
return graphql.Null
|
||||||
}
|
}
|
||||||
res := resTmp.([]*AuctionBid)
|
res := resTmp.([]*AuctionBid)
|
||||||
fc.Result = res
|
fc.Result = res
|
||||||
return ec.marshalOAuctionBid2ᚕᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚐAuctionBid(ctx, field.Selections, res)
|
return ec.marshalNAuctionBid2ᚕᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚐAuctionBidᚄ(ctx, field.Selections, res)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ec *executionContext) fieldContext_Auction_bids(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) {
|
func (ec *executionContext) fieldContext_Auction_bids(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) {
|
||||||
@ -8924,6 +8927,9 @@ func (ec *executionContext) _Auction(ctx context.Context, sel ast.SelectionSet,
|
|||||||
|
|
||||||
out.Values[i] = ec._Auction_bids(ctx, field, obj)
|
out.Values[i] = ec._Auction_bids(ctx, field, obj)
|
||||||
|
|
||||||
|
if out.Values[i] == graphql.Null {
|
||||||
|
invalids++
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
panic("unknown field " + strconv.Quote(field.Name))
|
panic("unknown field " + strconv.Quote(field.Name))
|
||||||
}
|
}
|
||||||
@ -10578,6 +10584,60 @@ func (ec *executionContext) marshalNAttribute2ᚖgitᚗvdbᚗtoᚋcercᚑioᚋla
|
|||||||
return ec._Attribute(ctx, sel, v)
|
return ec._Attribute(ctx, sel, v)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (ec *executionContext) marshalNAuctionBid2ᚕᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚐAuctionBidᚄ(ctx context.Context, sel ast.SelectionSet, v []*AuctionBid) graphql.Marshaler {
|
||||||
|
ret := make(graphql.Array, len(v))
|
||||||
|
var wg sync.WaitGroup
|
||||||
|
isLen1 := len(v) == 1
|
||||||
|
if !isLen1 {
|
||||||
|
wg.Add(len(v))
|
||||||
|
}
|
||||||
|
for i := range v {
|
||||||
|
i := i
|
||||||
|
fc := &graphql.FieldContext{
|
||||||
|
Index: &i,
|
||||||
|
Result: &v[i],
|
||||||
|
}
|
||||||
|
ctx := graphql.WithFieldContext(ctx, fc)
|
||||||
|
f := func(i int) {
|
||||||
|
defer func() {
|
||||||
|
if r := recover(); r != nil {
|
||||||
|
ec.Error(ctx, ec.Recover(ctx, r))
|
||||||
|
ret = nil
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
if !isLen1 {
|
||||||
|
defer wg.Done()
|
||||||
|
}
|
||||||
|
ret[i] = ec.marshalNAuctionBid2ᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚐAuctionBid(ctx, sel, v[i])
|
||||||
|
}
|
||||||
|
if isLen1 {
|
||||||
|
f(i)
|
||||||
|
} else {
|
||||||
|
go f(i)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
wg.Wait()
|
||||||
|
|
||||||
|
for _, e := range ret {
|
||||||
|
if e == graphql.Null {
|
||||||
|
return graphql.Null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret
|
||||||
|
}
|
||||||
|
|
||||||
|
func (ec *executionContext) marshalNAuctionBid2ᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚐAuctionBid(ctx context.Context, sel ast.SelectionSet, v *AuctionBid) graphql.Marshaler {
|
||||||
|
if v == nil {
|
||||||
|
if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
|
||||||
|
ec.Errorf(ctx, "the requested element is null which the schema does not allow")
|
||||||
|
}
|
||||||
|
return graphql.Null
|
||||||
|
}
|
||||||
|
return ec._AuctionBid(ctx, sel, v)
|
||||||
|
}
|
||||||
|
|
||||||
func (ec *executionContext) marshalNAuthority2ᚕᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚐAuthority(ctx context.Context, sel ast.SelectionSet, v []*Authority) graphql.Marshaler {
|
func (ec *executionContext) marshalNAuthority2ᚕᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚐAuthority(ctx context.Context, sel ast.SelectionSet, v []*Authority) graphql.Marshaler {
|
||||||
ret := make(graphql.Array, len(v))
|
ret := make(graphql.Array, len(v))
|
||||||
var wg sync.WaitGroup
|
var wg sync.WaitGroup
|
||||||
@ -10689,7 +10749,7 @@ func (ec *executionContext) marshalNBoolean2bool(ctx context.Context, sel ast.Se
|
|||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ec *executionContext) marshalNCoin2ᚕᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚐCoin(ctx context.Context, sel ast.SelectionSet, v []*Coin) graphql.Marshaler {
|
func (ec *executionContext) marshalNCoin2ᚕᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚐCoinᚄ(ctx context.Context, sel ast.SelectionSet, v []*Coin) graphql.Marshaler {
|
||||||
ret := make(graphql.Array, len(v))
|
ret := make(graphql.Array, len(v))
|
||||||
var wg sync.WaitGroup
|
var wg sync.WaitGroup
|
||||||
isLen1 := len(v) == 1
|
isLen1 := len(v) == 1
|
||||||
@ -10713,7 +10773,7 @@ func (ec *executionContext) marshalNCoin2ᚕᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaco
|
|||||||
if !isLen1 {
|
if !isLen1 {
|
||||||
defer wg.Done()
|
defer wg.Done()
|
||||||
}
|
}
|
||||||
ret[i] = ec.marshalOCoin2ᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚐCoin(ctx, sel, v[i])
|
ret[i] = ec.marshalNCoin2ᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚐCoin(ctx, sel, v[i])
|
||||||
}
|
}
|
||||||
if isLen1 {
|
if isLen1 {
|
||||||
f(i)
|
f(i)
|
||||||
@ -10724,6 +10784,12 @@ func (ec *executionContext) marshalNCoin2ᚕᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaco
|
|||||||
}
|
}
|
||||||
wg.Wait()
|
wg.Wait()
|
||||||
|
|
||||||
|
for _, e := range ret {
|
||||||
|
if e == graphql.Null {
|
||||||
|
return graphql.Null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return ret
|
return ret
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -10959,16 +11025,16 @@ func (ec *executionContext) marshalNString2string(ctx context.Context, sel ast.S
|
|||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ec *executionContext) unmarshalNString2ᚕᚖstring(ctx context.Context, v interface{}) ([]*string, error) {
|
func (ec *executionContext) unmarshalNString2ᚕstringᚄ(ctx context.Context, v interface{}) ([]string, error) {
|
||||||
var vSlice []interface{}
|
var vSlice []interface{}
|
||||||
if v != nil {
|
if v != nil {
|
||||||
vSlice = graphql.CoerceList(v)
|
vSlice = graphql.CoerceList(v)
|
||||||
}
|
}
|
||||||
var err error
|
var err error
|
||||||
res := make([]*string, len(vSlice))
|
res := make([]string, len(vSlice))
|
||||||
for i := range vSlice {
|
for i := range vSlice {
|
||||||
ctx := graphql.WithPathContext(ctx, graphql.NewPathWithIndex(i))
|
ctx := graphql.WithPathContext(ctx, graphql.NewPathWithIndex(i))
|
||||||
res[i], err = ec.unmarshalOString2ᚖstring(ctx, vSlice[i])
|
res[i], err = ec.unmarshalNString2string(ctx, vSlice[i])
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -10976,10 +11042,16 @@ func (ec *executionContext) unmarshalNString2ᚕᚖstring(ctx context.Context, v
|
|||||||
return res, nil
|
return res, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ec *executionContext) marshalNString2ᚕᚖstring(ctx context.Context, sel ast.SelectionSet, v []*string) graphql.Marshaler {
|
func (ec *executionContext) marshalNString2ᚕstringᚄ(ctx context.Context, sel ast.SelectionSet, v []string) graphql.Marshaler {
|
||||||
ret := make(graphql.Array, len(v))
|
ret := make(graphql.Array, len(v))
|
||||||
for i := range v {
|
for i := range v {
|
||||||
ret[i] = ec.marshalOString2ᚖstring(ctx, sel, v[i])
|
ret[i] = ec.marshalNString2string(ctx, sel, v[i])
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, e := range ret {
|
||||||
|
if e == graphql.Null {
|
||||||
|
return graphql.Null
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret
|
return ret
|
||||||
@ -11467,54 +11539,6 @@ func (ec *executionContext) marshalOAuction2ᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaco
|
|||||||
return ec._Auction(ctx, sel, v)
|
return ec._Auction(ctx, sel, v)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ec *executionContext) marshalOAuctionBid2ᚕᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚐAuctionBid(ctx context.Context, sel ast.SelectionSet, v []*AuctionBid) graphql.Marshaler {
|
|
||||||
if v == nil {
|
|
||||||
return graphql.Null
|
|
||||||
}
|
|
||||||
ret := make(graphql.Array, len(v))
|
|
||||||
var wg sync.WaitGroup
|
|
||||||
isLen1 := len(v) == 1
|
|
||||||
if !isLen1 {
|
|
||||||
wg.Add(len(v))
|
|
||||||
}
|
|
||||||
for i := range v {
|
|
||||||
i := i
|
|
||||||
fc := &graphql.FieldContext{
|
|
||||||
Index: &i,
|
|
||||||
Result: &v[i],
|
|
||||||
}
|
|
||||||
ctx := graphql.WithFieldContext(ctx, fc)
|
|
||||||
f := func(i int) {
|
|
||||||
defer func() {
|
|
||||||
if r := recover(); r != nil {
|
|
||||||
ec.Error(ctx, ec.Recover(ctx, r))
|
|
||||||
ret = nil
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
if !isLen1 {
|
|
||||||
defer wg.Done()
|
|
||||||
}
|
|
||||||
ret[i] = ec.marshalOAuctionBid2ᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚐAuctionBid(ctx, sel, v[i])
|
|
||||||
}
|
|
||||||
if isLen1 {
|
|
||||||
f(i)
|
|
||||||
} else {
|
|
||||||
go f(i)
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
wg.Wait()
|
|
||||||
|
|
||||||
return ret
|
|
||||||
}
|
|
||||||
|
|
||||||
func (ec *executionContext) marshalOAuctionBid2ᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚐAuctionBid(ctx context.Context, sel ast.SelectionSet, v *AuctionBid) graphql.Marshaler {
|
|
||||||
if v == nil {
|
|
||||||
return graphql.Null
|
|
||||||
}
|
|
||||||
return ec._AuctionBid(ctx, sel, v)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (ec *executionContext) marshalOAuthority2ᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚐAuthority(ctx context.Context, sel ast.SelectionSet, v *Authority) graphql.Marshaler {
|
func (ec *executionContext) marshalOAuthority2ᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚐAuthority(ctx context.Context, sel ast.SelectionSet, v *Authority) graphql.Marshaler {
|
||||||
if v == nil {
|
if v == nil {
|
||||||
return graphql.Null
|
return graphql.Null
|
||||||
@ -11697,13 +11721,6 @@ func (ec *executionContext) marshalOCoin2ᚕᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaco
|
|||||||
return ret
|
return ret
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ec *executionContext) marshalOCoin2ᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚐCoin(ctx context.Context, sel ast.SelectionSet, v *Coin) graphql.Marshaler {
|
|
||||||
if v == nil {
|
|
||||||
return graphql.Null
|
|
||||||
}
|
|
||||||
return ec._Coin(ctx, sel, v)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (ec *executionContext) unmarshalOFloat2ᚖfloat64(ctx context.Context, v interface{}) (*float64, error) {
|
func (ec *executionContext) unmarshalOFloat2ᚖfloat64(ctx context.Context, v interface{}) (*float64, error) {
|
||||||
if v == nil {
|
if v == nil {
|
||||||
return nil, nil
|
return nil, nil
|
||||||
|
@ -35,7 +35,7 @@ type Auction struct {
|
|||||||
CommitFee *Coin `json:"commitFee"`
|
CommitFee *Coin `json:"commitFee"`
|
||||||
RevealFee *Coin `json:"revealFee"`
|
RevealFee *Coin `json:"revealFee"`
|
||||||
MinimumBid *Coin `json:"minimumBid"`
|
MinimumBid *Coin `json:"minimumBid"`
|
||||||
WinnerAddresses []*string `json:"winnerAddresses"`
|
WinnerAddresses []string `json:"winnerAddresses"`
|
||||||
WinnerBids []*Coin `json:"winnerBids"`
|
WinnerBids []*Coin `json:"winnerBids"`
|
||||||
WinnerPrice *Coin `json:"winnerPrice"`
|
WinnerPrice *Coin `json:"winnerPrice"`
|
||||||
MaxPrice *Coin `json:"maxPrice"`
|
MaxPrice *Coin `json:"maxPrice"`
|
||||||
|
@ -232,12 +232,6 @@ func GetGQLAuction(auction *auctiontypes.Auction, bids []*auctiontypes.Bid) (*Au
|
|||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
winnerAddresses := make([]*string, len(auction.WinnerAddresses))
|
|
||||||
for i, winnerAddress := range auction.WinnerAddresses {
|
|
||||||
address := winnerAddress
|
|
||||||
winnerAddresses[i] = &address
|
|
||||||
}
|
|
||||||
|
|
||||||
numProviders := int(auction.NumProviders)
|
numProviders := int(auction.NumProviders)
|
||||||
|
|
||||||
gqlAuction := Auction{
|
gqlAuction := Auction{
|
||||||
@ -250,7 +244,7 @@ func GetGQLAuction(auction *auctiontypes.Auction, bids []*auctiontypes.Bid) (*Au
|
|||||||
CommitFee: getGQLCoin(auction.CommitFee),
|
CommitFee: getGQLCoin(auction.CommitFee),
|
||||||
RevealFee: getGQLCoin(auction.RevealFee),
|
RevealFee: getGQLCoin(auction.RevealFee),
|
||||||
MinimumBid: getGQLCoin(auction.MinimumBid),
|
MinimumBid: getGQLCoin(auction.MinimumBid),
|
||||||
WinnerAddresses: winnerAddresses,
|
WinnerAddresses: auction.WinnerAddresses,
|
||||||
WinnerBids: getGQLCoins(auction.WinningBids),
|
WinnerBids: getGQLCoins(auction.WinningBids),
|
||||||
WinnerPrice: getGQLCoin(auction.WinningPrice),
|
WinnerPrice: getGQLCoin(auction.WinningPrice),
|
||||||
MaxPrice: getGQLCoin(auction.MaxPrice),
|
MaxPrice: getGQLCoin(auction.MaxPrice),
|
||||||
|
Loading…
Reference in New Issue
Block a user