Add service provider auctions (#59)

Part of [Service provider auctions](https://www.notion.so/Service-provider-auctions-a7b63697d818479493ec145ea6ea3c1c)

- Add a new type of auction for service providers
  - Add a command to release provider auction funds
- Remove unused auction module params

Co-authored-by: IshaVenikar <ishavenikar7@gmail.com>
Co-authored-by: Isha Venikar <ishavenikar@Ishas-MacBook-Air.local>
Reviewed-on: cerc-io/laconicd#59
Co-authored-by: Prathamesh Musale <prathamesh.musale0@gmail.com>
Co-committed-by: Prathamesh Musale <prathamesh.musale0@gmail.com>
This commit is contained in:
2024-09-25 12:38:49 +00:00
committed by nabarun
co-authored by IshaVenikar Isha Venikar
parent df43322ef3
commit 52e8d322fa
29 changed files with 4285 additions and 1854 deletions
+3 -3
View File
@@ -1,6 +1,6 @@
# cerc-io laconic gql
> Browser : http://localhost:9473 for gql
> Browser : <http://localhost:9473> for gql
## Run gqlgen
@@ -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
# Generate bindings
# In gql
cd gql
go run github.com/99designs/gqlgen generate
```
@@ -385,4 +385,4 @@ Query participants:
nitroAddress
}
}
```
```
+7 -3
View File
@@ -168,10 +168,14 @@ type 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).
minimumBid: Coin! # Minimum bid amount.
winnerAddress: String! # Winner address.
winnerBid: Coin! # The winning bid amount.
winnerAddresses: [String!]! # Winner address.
winnerBids: [Coin!]! # The winning bid amount.
winnerPrice: Coin! # The price that the winner actually pays (2nd highest bid).
bids: [AuctionBid] # Bids make in the auction.
maxPrice: Coin! # Max bid amount for service provider auction.
kind: String! # Auction kind.
numProviders: Int # Number of service providers
fundsReleased: Boolean! # Whether funds have been released to providers
bids: [AuctionBid!]! # Bids made in the auction.
}
# Record defines the basic properties of an entity in the graph database.
+432 -92
View File
@@ -61,19 +61,23 @@ type ComplexityRoot struct {
}
Auction struct {
Bids func(childComplexity int) int
CommitFee func(childComplexity int) int
CommitsEndTime func(childComplexity int) int
CreateTime func(childComplexity int) int
ID func(childComplexity int) int
MinimumBid func(childComplexity int) int
OwnerAddress func(childComplexity int) int
RevealFee func(childComplexity int) int
RevealsEndTime func(childComplexity int) int
Status func(childComplexity int) int
WinnerAddress func(childComplexity int) int
WinnerBid func(childComplexity int) int
WinnerPrice func(childComplexity int) int
Bids func(childComplexity int) int
CommitFee func(childComplexity int) int
CommitsEndTime func(childComplexity int) int
CreateTime func(childComplexity int) int
FundsReleased func(childComplexity int) int
ID func(childComplexity int) int
Kind func(childComplexity int) int
MaxPrice func(childComplexity int) int
MinimumBid func(childComplexity int) int
NumProviders func(childComplexity int) int
OwnerAddress func(childComplexity int) int
RevealFee func(childComplexity int) int
RevealsEndTime func(childComplexity int) int
Status func(childComplexity int) int
WinnerAddresses func(childComplexity int) int
WinnerBids func(childComplexity int) int
WinnerPrice func(childComplexity int) int
}
AuctionBid struct {
@@ -346,6 +350,13 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in
return e.complexity.Auction.CreateTime(childComplexity), true
case "Auction.fundsReleased":
if e.complexity.Auction.FundsReleased == nil {
break
}
return e.complexity.Auction.FundsReleased(childComplexity), true
case "Auction.id":
if e.complexity.Auction.ID == nil {
break
@@ -353,6 +364,20 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in
return e.complexity.Auction.ID(childComplexity), true
case "Auction.kind":
if e.complexity.Auction.Kind == nil {
break
}
return e.complexity.Auction.Kind(childComplexity), true
case "Auction.maxPrice":
if e.complexity.Auction.MaxPrice == nil {
break
}
return e.complexity.Auction.MaxPrice(childComplexity), true
case "Auction.minimumBid":
if e.complexity.Auction.MinimumBid == nil {
break
@@ -360,6 +385,13 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in
return e.complexity.Auction.MinimumBid(childComplexity), true
case "Auction.numProviders":
if e.complexity.Auction.NumProviders == nil {
break
}
return e.complexity.Auction.NumProviders(childComplexity), true
case "Auction.ownerAddress":
if e.complexity.Auction.OwnerAddress == nil {
break
@@ -388,19 +420,19 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in
return e.complexity.Auction.Status(childComplexity), true
case "Auction.winnerAddress":
if e.complexity.Auction.WinnerAddress == nil {
case "Auction.winnerAddresses":
if e.complexity.Auction.WinnerAddresses == nil {
break
}
return e.complexity.Auction.WinnerAddress(childComplexity), true
return e.complexity.Auction.WinnerAddresses(childComplexity), true
case "Auction.winnerBid":
if e.complexity.Auction.WinnerBid == nil {
case "Auction.winnerBids":
if e.complexity.Auction.WinnerBids == nil {
break
}
return e.complexity.Auction.WinnerBid(childComplexity), true
return e.complexity.Auction.WinnerBids(childComplexity), true
case "Auction.winnerPrice":
if e.complexity.Auction.WinnerPrice == nil {
@@ -2147,8 +2179,8 @@ func (ec *executionContext) fieldContext_Auction_minimumBid(ctx context.Context,
return fc, nil
}
func (ec *executionContext) _Auction_winnerAddress(ctx context.Context, field graphql.CollectedField, obj *Auction) (ret graphql.Marshaler) {
fc, err := ec.fieldContext_Auction_winnerAddress(ctx, field)
func (ec *executionContext) _Auction_winnerAddresses(ctx context.Context, field graphql.CollectedField, obj *Auction) (ret graphql.Marshaler) {
fc, err := ec.fieldContext_Auction_winnerAddresses(ctx, field)
if err != nil {
return graphql.Null
}
@@ -2161,7 +2193,7 @@ func (ec *executionContext) _Auction_winnerAddress(ctx context.Context, field gr
}()
resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) {
ctx = rctx // use context from middleware stack in children
return obj.WinnerAddress, nil
return obj.WinnerAddresses, nil
})
if err != nil {
ec.Error(ctx, err)
@@ -2173,12 +2205,12 @@ func (ec *executionContext) _Auction_winnerAddress(ctx context.Context, field gr
}
return graphql.Null
}
res := resTmp.(string)
res := resTmp.([]string)
fc.Result = res
return ec.marshalNString2string(ctx, field.Selections, res)
return ec.marshalNString2ᚕstringᚄ(ctx, field.Selections, res)
}
func (ec *executionContext) fieldContext_Auction_winnerAddress(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) {
fc = &graphql.FieldContext{
Object: "Auction",
Field: field,
@@ -2191,8 +2223,8 @@ func (ec *executionContext) fieldContext_Auction_winnerAddress(ctx context.Conte
return fc, nil
}
func (ec *executionContext) _Auction_winnerBid(ctx context.Context, field graphql.CollectedField, obj *Auction) (ret graphql.Marshaler) {
fc, err := ec.fieldContext_Auction_winnerBid(ctx, field)
func (ec *executionContext) _Auction_winnerBids(ctx context.Context, field graphql.CollectedField, obj *Auction) (ret graphql.Marshaler) {
fc, err := ec.fieldContext_Auction_winnerBids(ctx, field)
if err != nil {
return graphql.Null
}
@@ -2205,7 +2237,7 @@ func (ec *executionContext) _Auction_winnerBid(ctx context.Context, field graphq
}()
resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) {
ctx = rctx // use context from middleware stack in children
return obj.WinnerBid, nil
return obj.WinnerBids, nil
})
if err != nil {
ec.Error(ctx, err)
@@ -2217,12 +2249,12 @@ func (ec *executionContext) _Auction_winnerBid(ctx context.Context, field graphq
}
return graphql.Null
}
res := resTmp.(*Coin)
res := resTmp.([]*Coin)
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_winnerBid(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) {
fc = &graphql.FieldContext{
Object: "Auction",
Field: field,
@@ -2291,6 +2323,185 @@ func (ec *executionContext) fieldContext_Auction_winnerPrice(ctx context.Context
return fc, nil
}
func (ec *executionContext) _Auction_maxPrice(ctx context.Context, field graphql.CollectedField, obj *Auction) (ret graphql.Marshaler) {
fc, err := ec.fieldContext_Auction_maxPrice(ctx, field)
if err != nil {
return graphql.Null
}
ctx = graphql.WithFieldContext(ctx, fc)
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
ret = graphql.Null
}
}()
resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) {
ctx = rctx // use context from middleware stack in children
return obj.MaxPrice, nil
})
if err != nil {
ec.Error(ctx, err)
return graphql.Null
}
if resTmp == nil {
if !graphql.HasFieldError(ctx, fc) {
ec.Errorf(ctx, "must not be null")
}
return graphql.Null
}
res := resTmp.(*Coin)
fc.Result = res
return ec.marshalNCoin2ᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚐCoin(ctx, field.Selections, res)
}
func (ec *executionContext) fieldContext_Auction_maxPrice(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) {
fc = &graphql.FieldContext{
Object: "Auction",
Field: field,
IsMethod: false,
IsResolver: false,
Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
switch field.Name {
case "type":
return ec.fieldContext_Coin_type(ctx, field)
case "quantity":
return ec.fieldContext_Coin_quantity(ctx, field)
}
return nil, fmt.Errorf("no field named %q was found under type Coin", field.Name)
},
}
return fc, nil
}
func (ec *executionContext) _Auction_kind(ctx context.Context, field graphql.CollectedField, obj *Auction) (ret graphql.Marshaler) {
fc, err := ec.fieldContext_Auction_kind(ctx, field)
if err != nil {
return graphql.Null
}
ctx = graphql.WithFieldContext(ctx, fc)
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
ret = graphql.Null
}
}()
resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) {
ctx = rctx // use context from middleware stack in children
return obj.Kind, nil
})
if err != nil {
ec.Error(ctx, err)
return graphql.Null
}
if resTmp == nil {
if !graphql.HasFieldError(ctx, fc) {
ec.Errorf(ctx, "must not be null")
}
return graphql.Null
}
res := resTmp.(string)
fc.Result = res
return ec.marshalNString2string(ctx, field.Selections, res)
}
func (ec *executionContext) fieldContext_Auction_kind(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) {
fc = &graphql.FieldContext{
Object: "Auction",
Field: field,
IsMethod: false,
IsResolver: false,
Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
return nil, errors.New("field of type String does not have child fields")
},
}
return fc, nil
}
func (ec *executionContext) _Auction_numProviders(ctx context.Context, field graphql.CollectedField, obj *Auction) (ret graphql.Marshaler) {
fc, err := ec.fieldContext_Auction_numProviders(ctx, field)
if err != nil {
return graphql.Null
}
ctx = graphql.WithFieldContext(ctx, fc)
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
ret = graphql.Null
}
}()
resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) {
ctx = rctx // use context from middleware stack in children
return obj.NumProviders, nil
})
if err != nil {
ec.Error(ctx, err)
return graphql.Null
}
if resTmp == nil {
return graphql.Null
}
res := resTmp.(*int)
fc.Result = res
return ec.marshalOInt2ᚖint(ctx, field.Selections, res)
}
func (ec *executionContext) fieldContext_Auction_numProviders(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) {
fc = &graphql.FieldContext{
Object: "Auction",
Field: field,
IsMethod: false,
IsResolver: false,
Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
return nil, errors.New("field of type Int does not have child fields")
},
}
return fc, nil
}
func (ec *executionContext) _Auction_fundsReleased(ctx context.Context, field graphql.CollectedField, obj *Auction) (ret graphql.Marshaler) {
fc, err := ec.fieldContext_Auction_fundsReleased(ctx, field)
if err != nil {
return graphql.Null
}
ctx = graphql.WithFieldContext(ctx, fc)
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
ret = graphql.Null
}
}()
resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) {
ctx = rctx // use context from middleware stack in children
return obj.FundsReleased, nil
})
if err != nil {
ec.Error(ctx, err)
return graphql.Null
}
if resTmp == nil {
if !graphql.HasFieldError(ctx, fc) {
ec.Errorf(ctx, "must not be null")
}
return graphql.Null
}
res := resTmp.(bool)
fc.Result = res
return ec.marshalNBoolean2bool(ctx, field.Selections, res)
}
func (ec *executionContext) fieldContext_Auction_fundsReleased(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) {
fc = &graphql.FieldContext{
Object: "Auction",
Field: field,
IsMethod: false,
IsResolver: false,
Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
return nil, errors.New("field of type Boolean does not have child fields")
},
}
return fc, nil
}
func (ec *executionContext) _Auction_bids(ctx context.Context, field graphql.CollectedField, obj *Auction) (ret graphql.Marshaler) {
fc, err := ec.fieldContext_Auction_bids(ctx, field)
if err != nil {
@@ -2312,11 +2523,14 @@ func (ec *executionContext) _Auction_bids(ctx context.Context, field graphql.Col
return graphql.Null
}
if resTmp == nil {
if !graphql.HasFieldError(ctx, fc) {
ec.Errorf(ctx, "must not be null")
}
return graphql.Null
}
res := resTmp.([]*AuctionBid)
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) {
@@ -3142,12 +3356,20 @@ func (ec *executionContext) fieldContext_AuthorityRecord_auction(ctx context.Con
return ec.fieldContext_Auction_revealFee(ctx, field)
case "minimumBid":
return ec.fieldContext_Auction_minimumBid(ctx, field)
case "winnerAddress":
return ec.fieldContext_Auction_winnerAddress(ctx, field)
case "winnerBid":
return ec.fieldContext_Auction_winnerBid(ctx, field)
case "winnerAddresses":
return ec.fieldContext_Auction_winnerAddresses(ctx, field)
case "winnerBids":
return ec.fieldContext_Auction_winnerBids(ctx, field)
case "winnerPrice":
return ec.fieldContext_Auction_winnerPrice(ctx, field)
case "maxPrice":
return ec.fieldContext_Auction_maxPrice(ctx, field)
case "kind":
return ec.fieldContext_Auction_kind(ctx, field)
case "numProviders":
return ec.fieldContext_Auction_numProviders(ctx, field)
case "fundsReleased":
return ec.fieldContext_Auction_fundsReleased(ctx, field)
case "bids":
return ec.fieldContext_Auction_bids(ctx, field)
}
@@ -5129,12 +5351,20 @@ func (ec *executionContext) fieldContext_Query_getAuctionsByIds(ctx context.Cont
return ec.fieldContext_Auction_revealFee(ctx, field)
case "minimumBid":
return ec.fieldContext_Auction_minimumBid(ctx, field)
case "winnerAddress":
return ec.fieldContext_Auction_winnerAddress(ctx, field)
case "winnerBid":
return ec.fieldContext_Auction_winnerBid(ctx, field)
case "winnerAddresses":
return ec.fieldContext_Auction_winnerAddresses(ctx, field)
case "winnerBids":
return ec.fieldContext_Auction_winnerBids(ctx, field)
case "winnerPrice":
return ec.fieldContext_Auction_winnerPrice(ctx, field)
case "maxPrice":
return ec.fieldContext_Auction_maxPrice(ctx, field)
case "kind":
return ec.fieldContext_Auction_kind(ctx, field)
case "numProviders":
return ec.fieldContext_Auction_numProviders(ctx, field)
case "fundsReleased":
return ec.fieldContext_Auction_fundsReleased(ctx, field)
case "bids":
return ec.fieldContext_Auction_bids(ctx, field)
}
@@ -8710,16 +8940,16 @@ func (ec *executionContext) _Auction(ctx context.Context, sel ast.SelectionSet,
if out.Values[i] == graphql.Null {
invalids++
}
case "winnerAddress":
case "winnerAddresses":
out.Values[i] = ec._Auction_winnerAddress(ctx, field, obj)
out.Values[i] = ec._Auction_winnerAddresses(ctx, field, obj)
if out.Values[i] == graphql.Null {
invalids++
}
case "winnerBid":
case "winnerBids":
out.Values[i] = ec._Auction_winnerBid(ctx, field, obj)
out.Values[i] = ec._Auction_winnerBids(ctx, field, obj)
if out.Values[i] == graphql.Null {
invalids++
@@ -8728,6 +8958,31 @@ func (ec *executionContext) _Auction(ctx context.Context, sel ast.SelectionSet,
out.Values[i] = ec._Auction_winnerPrice(ctx, field, obj)
if out.Values[i] == graphql.Null {
invalids++
}
case "maxPrice":
out.Values[i] = ec._Auction_maxPrice(ctx, field, obj)
if out.Values[i] == graphql.Null {
invalids++
}
case "kind":
out.Values[i] = ec._Auction_kind(ctx, field, obj)
if out.Values[i] == graphql.Null {
invalids++
}
case "numProviders":
out.Values[i] = ec._Auction_numProviders(ctx, field, obj)
case "fundsReleased":
out.Values[i] = ec._Auction_fundsReleased(ctx, field, obj)
if out.Values[i] == graphql.Null {
invalids++
}
@@ -8735,6 +8990,9 @@ func (ec *executionContext) _Auction(ctx context.Context, sel ast.SelectionSet,
out.Values[i] = ec._Auction_bids(ctx, field, obj)
if out.Values[i] == graphql.Null {
invalids++
}
default:
panic("unknown field " + strconv.Quote(field.Name))
}
@@ -10389,6 +10647,60 @@ func (ec *executionContext) marshalNAttribute2ᚖgitᚗvdbᚗtoᚋcercᚑioᚋla
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 {
ret := make(graphql.Array, len(v))
var wg sync.WaitGroup
@@ -10500,6 +10812,50 @@ func (ec *executionContext) marshalNBoolean2bool(ctx context.Context, sel ast.Se
return res
}
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))
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.marshalNCoin2ᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚐCoin(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) marshalNCoin2ᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚐCoin(ctx context.Context, sel ast.SelectionSet, v *Coin) graphql.Marshaler {
if v == nil {
if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
@@ -10732,6 +11088,38 @@ func (ec *executionContext) marshalNString2string(ctx context.Context, sel ast.S
return res
}
func (ec *executionContext) unmarshalNString2ᚕstringᚄ(ctx context.Context, v interface{}) ([]string, error) {
var vSlice []interface{}
if v != nil {
vSlice = graphql.CoerceList(v)
}
var err error
res := make([]string, len(vSlice))
for i := range vSlice {
ctx := graphql.WithPathContext(ctx, graphql.NewPathWithIndex(i))
res[i], err = ec.unmarshalNString2string(ctx, vSlice[i])
if err != nil {
return nil, err
}
}
return res, nil
}
func (ec *executionContext) marshalNString2ᚕstringᚄ(ctx context.Context, sel ast.SelectionSet, v []string) graphql.Marshaler {
ret := make(graphql.Array, len(v))
for i := range v {
ret[i] = ec.marshalNString2string(ctx, sel, v[i])
}
for _, e := range ret {
if e == graphql.Null {
return graphql.Null
}
}
return ret
}
func (ec *executionContext) marshalNSyncInfo2ᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚐSyncInfo(ctx context.Context, sel ast.SelectionSet, v *SyncInfo) graphql.Marshaler {
if v == nil {
if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
@@ -11214,54 +11602,6 @@ func (ec *executionContext) marshalOAuction2ᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaco
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 {
if v == nil {
return graphql.Null
+17 -13
View File
@@ -26,19 +26,23 @@ type Attribute struct {
}
type Auction struct {
ID string `json:"id"`
Status string `json:"status"`
OwnerAddress string `json:"ownerAddress"`
CreateTime string `json:"createTime"`
CommitsEndTime string `json:"commitsEndTime"`
RevealsEndTime string `json:"revealsEndTime"`
CommitFee *Coin `json:"commitFee"`
RevealFee *Coin `json:"revealFee"`
MinimumBid *Coin `json:"minimumBid"`
WinnerAddress string `json:"winnerAddress"`
WinnerBid *Coin `json:"winnerBid"`
WinnerPrice *Coin `json:"winnerPrice"`
Bids []*AuctionBid `json:"bids"`
ID string `json:"id"`
Status string `json:"status"`
OwnerAddress string `json:"ownerAddress"`
CreateTime string `json:"createTime"`
CommitsEndTime string `json:"commitsEndTime"`
RevealsEndTime string `json:"revealsEndTime"`
CommitFee *Coin `json:"commitFee"`
RevealFee *Coin `json:"revealFee"`
MinimumBid *Coin `json:"minimumBid"`
WinnerAddresses []string `json:"winnerAddresses"`
WinnerBids []*Coin `json:"winnerBids"`
WinnerPrice *Coin `json:"winnerPrice"`
MaxPrice *Coin `json:"maxPrice"`
Kind string `json:"kind"`
NumProviders *int `json:"numProviders"`
FundsReleased bool `json:"fundsReleased"`
Bids []*AuctionBid `json:"bids"`
}
type AuctionBid struct {
+18 -12
View File
@@ -232,19 +232,25 @@ func GetGQLAuction(auction *auctiontypes.Auction, bids []*auctiontypes.Bid) (*Au
return nil, nil
}
numProviders := int(auction.NumProviders)
gqlAuction := Auction{
ID: auction.Id,
Status: auction.Status,
OwnerAddress: auction.OwnerAddress,
CreateTime: auction.GetCreateTime(),
CommitsEndTime: auction.GetCommitsEndTime(),
RevealsEndTime: auction.GetRevealsEndTime(),
CommitFee: getGQLCoin(auction.CommitFee),
RevealFee: getGQLCoin(auction.RevealFee),
MinimumBid: getGQLCoin(auction.MinimumBid),
WinnerAddress: auction.WinnerAddress,
WinnerBid: getGQLCoin(auction.WinningBid),
WinnerPrice: getGQLCoin(auction.WinningPrice),
ID: auction.Id,
Status: auction.Status,
OwnerAddress: auction.OwnerAddress,
CreateTime: auction.GetCreateTime(),
CommitsEndTime: auction.GetCommitsEndTime(),
RevealsEndTime: auction.GetRevealsEndTime(),
CommitFee: getGQLCoin(auction.CommitFee),
RevealFee: getGQLCoin(auction.RevealFee),
MinimumBid: getGQLCoin(auction.MinimumBid),
WinnerAddresses: auction.WinnerAddresses,
WinnerBids: getGQLCoins(auction.WinningBids),
WinnerPrice: getGQLCoin(auction.WinningPrice),
MaxPrice: getGQLCoin(auction.MaxPrice),
Kind: auction.Kind,
NumProviders: &numProviders,
FundsReleased: auction.FundsReleased,
}
auctionBids := make([]*AuctionBid, len(bids))