From a0b19e72b37749e990e9d4b1e29a09ccd8b48a2c Mon Sep 17 00:00:00 2001 From: Milos Zivkovic Date: Thu, 11 Apr 2024 14:43:45 +0200 Subject: [PATCH 1/6] Expose additional tx fields --- serve/graph/generated.go | 311 ++++++++++++++++++- serve/graph/model/transaction.go | 20 ++ serve/graph/schema/types/transaction.graphql | 20 ++ serve/graph/transaction.resolvers.go | 21 ++ 4 files changed, 356 insertions(+), 16 deletions(-) create mode 100644 serve/graph/transaction.resolvers.go diff --git a/serve/graph/generated.go b/serve/graph/generated.go index a72f4ee6..0cef0f95 100644 --- a/serve/graph/generated.go +++ b/serve/graph/generated.go @@ -43,6 +43,7 @@ type Config struct { type ResolverRoot interface { Query() QueryResolver Subscription() SubscriptionResolver + Transaction() TransactionResolver } type DirectiveRoot struct { @@ -106,14 +107,18 @@ type ComplexityRoot struct { } Transaction struct { - BlockHeight func(childComplexity int) int - ContentRaw func(childComplexity int) int - GasUsed func(childComplexity int) int - GasWanted func(childComplexity int) int - Hash func(childComplexity int) int - Index func(childComplexity int) int - Memo func(childComplexity int) int - Messages func(childComplexity int) int + BlockHeight func(childComplexity int) int + ContentRaw func(childComplexity int) int + GasUsed func(childComplexity int) int + GasWanted func(childComplexity int) int + Hash func(childComplexity int) int + Index func(childComplexity int) int + Memo func(childComplexity int) int + Messages func(childComplexity int) int + ResponseData func(childComplexity int) int + ResponseError func(childComplexity int) int + ResponseInfo func(childComplexity int) int + ResponseLog func(childComplexity int) int } TransactionMessage struct { @@ -141,6 +146,9 @@ type SubscriptionResolver interface { Transactions(ctx context.Context, filter model.TransactionFilter) (<-chan *model.Transaction, error) Blocks(ctx context.Context, filter model.BlockFilter) (<-chan *model.Block, error) } +type TransactionResolver interface { + ResponseData(ctx context.Context, obj *model.Transaction) (string, error) +} type executableSchema struct { schema *ast.Schema @@ -440,6 +448,34 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Transaction.Messages(childComplexity), true + case "Transaction.response_data": + if e.complexity.Transaction.ResponseData == nil { + break + } + + return e.complexity.Transaction.ResponseData(childComplexity), true + + case "Transaction.response_error": + if e.complexity.Transaction.ResponseError == nil { + break + } + + return e.complexity.Transaction.ResponseError(childComplexity), true + + case "Transaction.response_info": + if e.complexity.Transaction.ResponseInfo == nil { + break + } + + return e.complexity.Transaction.ResponseInfo(childComplexity), true + + case "Transaction.response_log": + if e.complexity.Transaction.ResponseLog == nil { + break + } + + return e.complexity.Transaction.ResponseLog(childComplexity), true + case "TransactionMessage.route": if e.complexity.TransactionMessage.Route == nil { break @@ -1853,6 +1889,14 @@ func (ec *executionContext) fieldContext_Query_transactions(ctx context.Context, return ec.fieldContext_Transaction_hash(ctx, field) case "block_height": return ec.fieldContext_Transaction_block_height(ctx, field) + case "response_error": + return ec.fieldContext_Transaction_response_error(ctx, field) + case "response_log": + return ec.fieldContext_Transaction_response_log(ctx, field) + case "response_info": + return ec.fieldContext_Transaction_response_info(ctx, field) + case "response_data": + return ec.fieldContext_Transaction_response_data(ctx, field) case "gas_wanted": return ec.fieldContext_Transaction_gas_wanted(ctx, field) case "gas_used": @@ -2177,6 +2221,14 @@ func (ec *executionContext) fieldContext_Subscription_transactions(ctx context.C return ec.fieldContext_Transaction_hash(ctx, field) case "block_height": return ec.fieldContext_Transaction_block_height(ctx, field) + case "response_error": + return ec.fieldContext_Transaction_response_error(ctx, field) + case "response_log": + return ec.fieldContext_Transaction_response_log(ctx, field) + case "response_info": + return ec.fieldContext_Transaction_response_info(ctx, field) + case "response_data": + return ec.fieldContext_Transaction_response_data(ctx, field) case "gas_wanted": return ec.fieldContext_Transaction_gas_wanted(ctx, field) case "gas_used": @@ -2418,6 +2470,182 @@ func (ec *executionContext) fieldContext_Transaction_block_height(ctx context.Co return fc, nil } +func (ec *executionContext) _Transaction_response_error(ctx context.Context, field graphql.CollectedField, obj *model.Transaction) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Transaction_response_error(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.ResponseError(), 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_Transaction_response_error(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Transaction", + Field: field, + IsMethod: true, + 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) _Transaction_response_log(ctx context.Context, field graphql.CollectedField, obj *model.Transaction) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Transaction_response_log(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.ResponseLog(), 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_Transaction_response_log(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Transaction", + Field: field, + IsMethod: true, + 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) _Transaction_response_info(ctx context.Context, field graphql.CollectedField, obj *model.Transaction) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Transaction_response_info(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.ResponseInfo(), 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_Transaction_response_info(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Transaction", + Field: field, + IsMethod: true, + 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) _Transaction_response_data(ctx context.Context, field graphql.CollectedField, obj *model.Transaction) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Transaction_response_data(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 ec.resolvers.Transaction().ResponseData(rctx, obj) + }) + 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_Transaction_response_data(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Transaction", + Field: field, + IsMethod: true, + IsResolver: true, + 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) _Transaction_gas_wanted(ctx context.Context, field graphql.CollectedField, obj *model.Transaction) (ret graphql.Marshaler) { fc, err := ec.fieldContext_Transaction_gas_wanted(ctx, field) if err != nil { @@ -5788,42 +6016,93 @@ func (ec *executionContext) _Transaction(ctx context.Context, sel ast.SelectionS case "index": out.Values[i] = ec._Transaction_index(ctx, field, obj) if out.Values[i] == graphql.Null { - out.Invalids++ + atomic.AddUint32(&out.Invalids, 1) } case "hash": out.Values[i] = ec._Transaction_hash(ctx, field, obj) if out.Values[i] == graphql.Null { - out.Invalids++ + atomic.AddUint32(&out.Invalids, 1) } case "block_height": out.Values[i] = ec._Transaction_block_height(ctx, field, obj) if out.Values[i] == graphql.Null { - out.Invalids++ + atomic.AddUint32(&out.Invalids, 1) + } + case "response_error": + out.Values[i] = ec._Transaction_response_error(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } + case "response_log": + out.Values[i] = ec._Transaction_response_log(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) } + case "response_info": + out.Values[i] = ec._Transaction_response_info(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } + case "response_data": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._Transaction_response_data(ctx, field, obj) + if res == graphql.Null { + atomic.AddUint32(&fs.Invalids, 1) + } + return res + } + + if field.Deferrable != nil { + dfs, ok := deferred[field.Deferrable.Label] + di := 0 + if ok { + dfs.AddField(field) + di = len(dfs.Values) - 1 + } else { + dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) + deferred[field.Deferrable.Label] = dfs + } + dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { + return innerFunc(ctx, dfs) + }) + + // don't run the out.Concurrently() call below + out.Values[i] = graphql.Null + continue + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) case "gas_wanted": out.Values[i] = ec._Transaction_gas_wanted(ctx, field, obj) if out.Values[i] == graphql.Null { - out.Invalids++ + atomic.AddUint32(&out.Invalids, 1) } case "gas_used": out.Values[i] = ec._Transaction_gas_used(ctx, field, obj) if out.Values[i] == graphql.Null { - out.Invalids++ + atomic.AddUint32(&out.Invalids, 1) } case "content_raw": out.Values[i] = ec._Transaction_content_raw(ctx, field, obj) if out.Values[i] == graphql.Null { - out.Invalids++ + atomic.AddUint32(&out.Invalids, 1) } case "messages": out.Values[i] = ec._Transaction_messages(ctx, field, obj) if out.Values[i] == graphql.Null { - out.Invalids++ + atomic.AddUint32(&out.Invalids, 1) } case "memo": out.Values[i] = ec._Transaction_memo(ctx, field, obj) if out.Values[i] == graphql.Null { - out.Invalids++ + atomic.AddUint32(&out.Invalids, 1) } default: panic("unknown field " + strconv.Quote(field.Name)) diff --git a/serve/graph/model/transaction.go b/serve/graph/model/transaction.go index 77e80aff..94707c69 100644 --- a/serve/graph/model/transaction.go +++ b/serve/graph/model/transaction.go @@ -47,6 +47,26 @@ func (t *Transaction) BlockHeight() int { return int(t.txResult.Height) } +func (t *Transaction) ResponseError() string { + if t.txResult.Response.Error == nil { + return "" + } + + return t.txResult.Response.Error.Error() +} + +func (t *Transaction) ResponseLog() string { + return t.txResult.Response.Log +} + +func (t *Transaction) ResponseInfo() string { + return t.txResult.Response.Info +} + +func (t *Transaction) ResponseData() []byte { + return t.txResult.Response.Data +} + func (t *Transaction) GasWanted() int { return int(t.txResult.Response.GasWanted) } diff --git a/serve/graph/schema/types/transaction.graphql b/serve/graph/schema/types/transaction.graphql index 7dc2f291..40b77345 100644 --- a/serve/graph/schema/types/transaction.graphql +++ b/serve/graph/schema/types/transaction.graphql @@ -17,6 +17,26 @@ type Transaction { """ block_height: Int! + """ + The error value associated with the Transaction execution, if any. + """ + response_error: String! + + """ + The log value associated with the Transaction execution, if any. + """ + response_log: String! + + """ + The Info associated with the Transaction execution, if any. + """ + response_info: String! + + """ + The response data associated with the Transaction execution, if any. + """ + response_data: String! + """ The declared amount of computational effort the sender is willing to pay for executing this Transaction. """ diff --git a/serve/graph/transaction.resolvers.go b/serve/graph/transaction.resolvers.go new file mode 100644 index 00000000..4ee99848 --- /dev/null +++ b/serve/graph/transaction.resolvers.go @@ -0,0 +1,21 @@ +package graph + +// This file will be automatically regenerated based on the schema, any resolver implementations +// will be copied through when generating and any unknown code will be moved to the end. +// Code generated by github.com/99designs/gqlgen version v0.17.45 + +import ( + "context" + + "github.com/gnolang/tx-indexer/serve/graph/model" +) + +// ResponseData is the resolver for the response_data field. +func (r *transactionResolver) ResponseData(ctx context.Context, obj *model.Transaction) (string, error) { + return string(obj.ResponseData()), nil +} + +// Transaction returns TransactionResolver implementation. +func (r *Resolver) Transaction() TransactionResolver { return &transactionResolver{r} } + +type transactionResolver struct{ *Resolver } From 8cf8f5ccae08afa56bbde31f570356ff3b4a23cb Mon Sep 17 00:00:00 2001 From: jinoosss Date: Wed, 17 Apr 2024 10:52:41 +0900 Subject: [PATCH 2/6] fix: Remove the automatically created reslover file --- serve/graph/transaction.resolvers.go | 21 --------------------- 1 file changed, 21 deletions(-) delete mode 100644 serve/graph/transaction.resolvers.go diff --git a/serve/graph/transaction.resolvers.go b/serve/graph/transaction.resolvers.go deleted file mode 100644 index 4ee99848..00000000 --- a/serve/graph/transaction.resolvers.go +++ /dev/null @@ -1,21 +0,0 @@ -package graph - -// This file will be automatically regenerated based on the schema, any resolver implementations -// will be copied through when generating and any unknown code will be moved to the end. -// Code generated by github.com/99designs/gqlgen version v0.17.45 - -import ( - "context" - - "github.com/gnolang/tx-indexer/serve/graph/model" -) - -// ResponseData is the resolver for the response_data field. -func (r *transactionResolver) ResponseData(ctx context.Context, obj *model.Transaction) (string, error) { - return string(obj.ResponseData()), nil -} - -// Transaction returns TransactionResolver implementation. -func (r *Resolver) Transaction() TransactionResolver { return &transactionResolver{r} } - -type transactionResolver struct{ *Resolver } From c0f0cf3c964a4e1bcd0738cfd7254a010329a9cc Mon Sep 17 00:00:00 2001 From: jinoosss Date: Wed, 17 Apr 2024 12:05:42 +0900 Subject: [PATCH 3/6] feat: Add Transaction Response object --- gqlgen.yml | 3 + serve/graph/generated.go | 461 +++++++++++-------- serve/graph/model/transaction.go | 47 +- serve/graph/schema/types/transaction.graphql | 52 ++- 4 files changed, 325 insertions(+), 238 deletions(-) diff --git a/gqlgen.yml b/gqlgen.yml index af53e13f..c35bc233 100644 --- a/gqlgen.yml +++ b/gqlgen.yml @@ -90,3 +90,6 @@ models: TransactionMessage: model: - github.com/gnolang/tx-indexer/serve/graph/model.TransactionMessage + TransactionResponse: + model: + - github.com/gnolang/tx-indexer/serve/graph/model.TransactionResponse diff --git a/serve/graph/generated.go b/serve/graph/generated.go index 0cef0f95..01a161f1 100644 --- a/serve/graph/generated.go +++ b/serve/graph/generated.go @@ -43,7 +43,6 @@ type Config struct { type ResolverRoot interface { Query() QueryResolver Subscription() SubscriptionResolver - Transaction() TransactionResolver } type DirectiveRoot struct { @@ -107,18 +106,15 @@ type ComplexityRoot struct { } Transaction struct { - BlockHeight func(childComplexity int) int - ContentRaw func(childComplexity int) int - GasUsed func(childComplexity int) int - GasWanted func(childComplexity int) int - Hash func(childComplexity int) int - Index func(childComplexity int) int - Memo func(childComplexity int) int - Messages func(childComplexity int) int - ResponseData func(childComplexity int) int - ResponseError func(childComplexity int) int - ResponseInfo func(childComplexity int) int - ResponseLog func(childComplexity int) int + BlockHeight func(childComplexity int) int + ContentRaw func(childComplexity int) int + GasUsed func(childComplexity int) int + GasWanted func(childComplexity int) int + Hash func(childComplexity int) int + Index func(childComplexity int) int + Memo func(childComplexity int) int + Messages func(childComplexity int) int + Response func(childComplexity int) int } TransactionMessage struct { @@ -127,6 +123,13 @@ type ComplexityRoot struct { Value func(childComplexity int) int } + TransactionResponse struct { + Data func(childComplexity int) int + Error func(childComplexity int) int + Info func(childComplexity int) int + Log func(childComplexity int) int + } + TxFee struct { GasFee func(childComplexity int) int GasWanted func(childComplexity int) int @@ -146,9 +149,6 @@ type SubscriptionResolver interface { Transactions(ctx context.Context, filter model.TransactionFilter) (<-chan *model.Transaction, error) Blocks(ctx context.Context, filter model.BlockFilter) (<-chan *model.Block, error) } -type TransactionResolver interface { - ResponseData(ctx context.Context, obj *model.Transaction) (string, error) -} type executableSchema struct { schema *ast.Schema @@ -448,54 +448,61 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Transaction.Messages(childComplexity), true - case "Transaction.response_data": - if e.complexity.Transaction.ResponseData == nil { + case "Transaction.response": + if e.complexity.Transaction.Response == nil { break } - return e.complexity.Transaction.ResponseData(childComplexity), true + return e.complexity.Transaction.Response(childComplexity), true - case "Transaction.response_error": - if e.complexity.Transaction.ResponseError == nil { + case "TransactionMessage.route": + if e.complexity.TransactionMessage.Route == nil { break } - return e.complexity.Transaction.ResponseError(childComplexity), true + return e.complexity.TransactionMessage.Route(childComplexity), true - case "Transaction.response_info": - if e.complexity.Transaction.ResponseInfo == nil { + case "TransactionMessage.typeUrl": + if e.complexity.TransactionMessage.TypeURL == nil { break } - return e.complexity.Transaction.ResponseInfo(childComplexity), true + return e.complexity.TransactionMessage.TypeURL(childComplexity), true - case "Transaction.response_log": - if e.complexity.Transaction.ResponseLog == nil { + case "TransactionMessage.value": + if e.complexity.TransactionMessage.Value == nil { break } - return e.complexity.Transaction.ResponseLog(childComplexity), true + return e.complexity.TransactionMessage.Value(childComplexity), true - case "TransactionMessage.route": - if e.complexity.TransactionMessage.Route == nil { + case "TransactionResponse.data": + if e.complexity.TransactionResponse.Data == nil { break } - return e.complexity.TransactionMessage.Route(childComplexity), true + return e.complexity.TransactionResponse.Data(childComplexity), true - case "TransactionMessage.typeUrl": - if e.complexity.TransactionMessage.TypeURL == nil { + case "TransactionResponse.error": + if e.complexity.TransactionResponse.Error == nil { break } - return e.complexity.TransactionMessage.TypeURL(childComplexity), true + return e.complexity.TransactionResponse.Error(childComplexity), true - case "TransactionMessage.value": - if e.complexity.TransactionMessage.Value == nil { + case "TransactionResponse.info": + if e.complexity.TransactionResponse.Info == nil { break } - return e.complexity.TransactionMessage.Value(childComplexity), true + return e.complexity.TransactionResponse.Info(childComplexity), true + + case "TransactionResponse.log": + if e.complexity.TransactionResponse.Log == nil { + break + } + + return e.complexity.TransactionResponse.Log(childComplexity), true case "TxFee.gas_fee": if e.complexity.TxFee.GasFee == nil { @@ -1889,14 +1896,6 @@ func (ec *executionContext) fieldContext_Query_transactions(ctx context.Context, return ec.fieldContext_Transaction_hash(ctx, field) case "block_height": return ec.fieldContext_Transaction_block_height(ctx, field) - case "response_error": - return ec.fieldContext_Transaction_response_error(ctx, field) - case "response_log": - return ec.fieldContext_Transaction_response_log(ctx, field) - case "response_info": - return ec.fieldContext_Transaction_response_info(ctx, field) - case "response_data": - return ec.fieldContext_Transaction_response_data(ctx, field) case "gas_wanted": return ec.fieldContext_Transaction_gas_wanted(ctx, field) case "gas_used": @@ -1907,6 +1906,8 @@ func (ec *executionContext) fieldContext_Query_transactions(ctx context.Context, return ec.fieldContext_Transaction_messages(ctx, field) case "memo": return ec.fieldContext_Transaction_memo(ctx, field) + case "response": + return ec.fieldContext_Transaction_response(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type Transaction", field.Name) }, @@ -2221,14 +2222,6 @@ func (ec *executionContext) fieldContext_Subscription_transactions(ctx context.C return ec.fieldContext_Transaction_hash(ctx, field) case "block_height": return ec.fieldContext_Transaction_block_height(ctx, field) - case "response_error": - return ec.fieldContext_Transaction_response_error(ctx, field) - case "response_log": - return ec.fieldContext_Transaction_response_log(ctx, field) - case "response_info": - return ec.fieldContext_Transaction_response_info(ctx, field) - case "response_data": - return ec.fieldContext_Transaction_response_data(ctx, field) case "gas_wanted": return ec.fieldContext_Transaction_gas_wanted(ctx, field) case "gas_used": @@ -2239,6 +2232,8 @@ func (ec *executionContext) fieldContext_Subscription_transactions(ctx context.C return ec.fieldContext_Transaction_messages(ctx, field) case "memo": return ec.fieldContext_Transaction_memo(ctx, field) + case "response": + return ec.fieldContext_Transaction_response(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type Transaction", field.Name) }, @@ -2470,8 +2465,8 @@ func (ec *executionContext) fieldContext_Transaction_block_height(ctx context.Co return fc, nil } -func (ec *executionContext) _Transaction_response_error(ctx context.Context, field graphql.CollectedField, obj *model.Transaction) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Transaction_response_error(ctx, field) +func (ec *executionContext) _Transaction_gas_wanted(ctx context.Context, field graphql.CollectedField, obj *model.Transaction) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Transaction_gas_wanted(ctx, field) if err != nil { return graphql.Null } @@ -2484,7 +2479,7 @@ func (ec *executionContext) _Transaction_response_error(ctx context.Context, fie }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.ResponseError(), nil + return obj.GasWanted(), nil }) if err != nil { ec.Error(ctx, err) @@ -2496,26 +2491,26 @@ func (ec *executionContext) _Transaction_response_error(ctx context.Context, fie } return graphql.Null } - res := resTmp.(string) + res := resTmp.(int) fc.Result = res - return ec.marshalNString2string(ctx, field.Selections, res) + return ec.marshalNInt2int(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Transaction_response_error(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Transaction_gas_wanted(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Transaction", Field: field, IsMethod: true, 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 nil, errors.New("field of type Int does not have child fields") }, } return fc, nil } -func (ec *executionContext) _Transaction_response_log(ctx context.Context, field graphql.CollectedField, obj *model.Transaction) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Transaction_response_log(ctx, field) +func (ec *executionContext) _Transaction_gas_used(ctx context.Context, field graphql.CollectedField, obj *model.Transaction) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Transaction_gas_used(ctx, field) if err != nil { return graphql.Null } @@ -2528,7 +2523,7 @@ func (ec *executionContext) _Transaction_response_log(ctx context.Context, field }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.ResponseLog(), nil + return obj.GasUsed(), nil }) if err != nil { ec.Error(ctx, err) @@ -2540,26 +2535,26 @@ func (ec *executionContext) _Transaction_response_log(ctx context.Context, field } return graphql.Null } - res := resTmp.(string) + res := resTmp.(int) fc.Result = res - return ec.marshalNString2string(ctx, field.Selections, res) + return ec.marshalNInt2int(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Transaction_response_log(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Transaction_gas_used(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Transaction", Field: field, IsMethod: true, 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 nil, errors.New("field of type Int does not have child fields") }, } return fc, nil } -func (ec *executionContext) _Transaction_response_info(ctx context.Context, field graphql.CollectedField, obj *model.Transaction) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Transaction_response_info(ctx, field) +func (ec *executionContext) _Transaction_content_raw(ctx context.Context, field graphql.CollectedField, obj *model.Transaction) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Transaction_content_raw(ctx, field) if err != nil { return graphql.Null } @@ -2572,7 +2567,7 @@ func (ec *executionContext) _Transaction_response_info(ctx context.Context, fiel }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.ResponseInfo(), nil + return obj.ContentRaw(), nil }) if err != nil { ec.Error(ctx, err) @@ -2589,7 +2584,7 @@ func (ec *executionContext) _Transaction_response_info(ctx context.Context, fiel return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Transaction_response_info(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Transaction_content_raw(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Transaction", Field: field, @@ -2602,8 +2597,60 @@ func (ec *executionContext) fieldContext_Transaction_response_info(ctx context.C return fc, nil } -func (ec *executionContext) _Transaction_response_data(ctx context.Context, field graphql.CollectedField, obj *model.Transaction) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Transaction_response_data(ctx, field) +func (ec *executionContext) _Transaction_messages(ctx context.Context, field graphql.CollectedField, obj *model.Transaction) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Transaction_messages(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.Messages(), 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.([]*model.TransactionMessage) + fc.Result = res + return ec.marshalNTransactionMessage2ᚕᚖgithub.comᚋgnolangᚋtxᚑindexerᚋserveᚋgraphᚋmodelᚐTransactionMessage(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Transaction_messages(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Transaction", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "typeUrl": + return ec.fieldContext_TransactionMessage_typeUrl(ctx, field) + case "route": + return ec.fieldContext_TransactionMessage_route(ctx, field) + case "value": + return ec.fieldContext_TransactionMessage_value(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type TransactionMessage", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _Transaction_memo(ctx context.Context, field graphql.CollectedField, obj *model.Transaction) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Transaction_memo(ctx, field) if err != nil { return graphql.Null } @@ -2616,7 +2663,7 @@ func (ec *executionContext) _Transaction_response_data(ctx context.Context, fiel }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.Transaction().ResponseData(rctx, obj) + return obj.Memo(), nil }) if err != nil { ec.Error(ctx, err) @@ -2633,12 +2680,12 @@ func (ec *executionContext) _Transaction_response_data(ctx context.Context, fiel return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Transaction_response_data(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Transaction_memo(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Transaction", Field: field, IsMethod: true, - IsResolver: true, + 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") }, @@ -2646,8 +2693,8 @@ func (ec *executionContext) fieldContext_Transaction_response_data(ctx context.C return fc, nil } -func (ec *executionContext) _Transaction_gas_wanted(ctx context.Context, field graphql.CollectedField, obj *model.Transaction) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Transaction_gas_wanted(ctx, field) +func (ec *executionContext) _Transaction_response(ctx context.Context, field graphql.CollectedField, obj *model.Transaction) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Transaction_response(ctx, field) if err != nil { return graphql.Null } @@ -2660,7 +2707,7 @@ func (ec *executionContext) _Transaction_gas_wanted(ctx context.Context, field g }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.GasWanted(), nil + return obj.Response(), nil }) if err != nil { ec.Error(ctx, err) @@ -2672,26 +2719,36 @@ func (ec *executionContext) _Transaction_gas_wanted(ctx context.Context, field g } return graphql.Null } - res := resTmp.(int) + res := resTmp.(model.TransactionResponse) fc.Result = res - return ec.marshalNInt2int(ctx, field.Selections, res) + return ec.marshalNTransactionResponse2githubᚗcomᚋgnolangᚋtxᚑindexerᚋserveᚋgraphᚋmodelᚐTransactionResponse(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Transaction_gas_wanted(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Transaction_response(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Transaction", Field: field, IsMethod: true, 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") + switch field.Name { + case "log": + return ec.fieldContext_TransactionResponse_log(ctx, field) + case "info": + return ec.fieldContext_TransactionResponse_info(ctx, field) + case "error": + return ec.fieldContext_TransactionResponse_error(ctx, field) + case "data": + return ec.fieldContext_TransactionResponse_data(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type TransactionResponse", field.Name) }, } return fc, nil } -func (ec *executionContext) _Transaction_gas_used(ctx context.Context, field graphql.CollectedField, obj *model.Transaction) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Transaction_gas_used(ctx, field) +func (ec *executionContext) _TransactionMessage_typeUrl(ctx context.Context, field graphql.CollectedField, obj *model.TransactionMessage) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_TransactionMessage_typeUrl(ctx, field) if err != nil { return graphql.Null } @@ -2704,7 +2761,7 @@ func (ec *executionContext) _Transaction_gas_used(ctx context.Context, field gra }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.GasUsed(), nil + return obj.TypeURL, nil }) if err != nil { ec.Error(ctx, err) @@ -2716,26 +2773,26 @@ func (ec *executionContext) _Transaction_gas_used(ctx context.Context, field gra } return graphql.Null } - res := resTmp.(int) + res := resTmp.(string) fc.Result = res - return ec.marshalNInt2int(ctx, field.Selections, res) + return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Transaction_gas_used(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_TransactionMessage_typeUrl(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Transaction", + Object: "TransactionMessage", Field: field, - IsMethod: true, + 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 nil, errors.New("field of type String does not have child fields") }, } return fc, nil } -func (ec *executionContext) _Transaction_content_raw(ctx context.Context, field graphql.CollectedField, obj *model.Transaction) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Transaction_content_raw(ctx, field) +func (ec *executionContext) _TransactionMessage_route(ctx context.Context, field graphql.CollectedField, obj *model.TransactionMessage) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_TransactionMessage_route(ctx, field) if err != nil { return graphql.Null } @@ -2748,7 +2805,7 @@ func (ec *executionContext) _Transaction_content_raw(ctx context.Context, field }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.ContentRaw(), nil + return obj.Route, nil }) if err != nil { ec.Error(ctx, err) @@ -2765,11 +2822,11 @@ func (ec *executionContext) _Transaction_content_raw(ctx context.Context, field return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Transaction_content_raw(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_TransactionMessage_route(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Transaction", + Object: "TransactionMessage", Field: field, - IsMethod: true, + 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") @@ -2778,8 +2835,8 @@ func (ec *executionContext) fieldContext_Transaction_content_raw(ctx context.Con return fc, nil } -func (ec *executionContext) _Transaction_messages(ctx context.Context, field graphql.CollectedField, obj *model.Transaction) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Transaction_messages(ctx, field) +func (ec *executionContext) _TransactionMessage_value(ctx context.Context, field graphql.CollectedField, obj *model.TransactionMessage) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_TransactionMessage_value(ctx, field) if err != nil { return graphql.Null } @@ -2792,7 +2849,7 @@ func (ec *executionContext) _Transaction_messages(ctx context.Context, field gra }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Messages(), nil + return obj.Value, nil }) if err != nil { ec.Error(ctx, err) @@ -2804,34 +2861,26 @@ func (ec *executionContext) _Transaction_messages(ctx context.Context, field gra } return graphql.Null } - res := resTmp.([]*model.TransactionMessage) + res := resTmp.(model.MessageValue) fc.Result = res - return ec.marshalNTransactionMessage2ᚕᚖgithub.comᚋgnolangᚋtxᚑindexerᚋserveᚋgraphᚋmodelᚐTransactionMessage(ctx, field.Selections, res) + return ec.marshalNMessageValue2githubᚗcomᚋgnolangᚋtxᚑindexerᚋserveᚋgraphᚋmodelᚐMessageValue(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Transaction_messages(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_TransactionMessage_value(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Transaction", + Object: "TransactionMessage", Field: field, - IsMethod: true, + IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "typeUrl": - return ec.fieldContext_TransactionMessage_typeUrl(ctx, field) - case "route": - return ec.fieldContext_TransactionMessage_route(ctx, field) - case "value": - return ec.fieldContext_TransactionMessage_value(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type TransactionMessage", field.Name) + return nil, errors.New("field of type MessageValue does not have child fields") }, } return fc, nil } -func (ec *executionContext) _Transaction_memo(ctx context.Context, field graphql.CollectedField, obj *model.Transaction) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Transaction_memo(ctx, field) +func (ec *executionContext) _TransactionResponse_log(ctx context.Context, field graphql.CollectedField, obj *model.TransactionResponse) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_TransactionResponse_log(ctx, field) if err != nil { return graphql.Null } @@ -2844,7 +2893,7 @@ func (ec *executionContext) _Transaction_memo(ctx context.Context, field graphql }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Memo(), nil + return obj.Log(), nil }) if err != nil { ec.Error(ctx, err) @@ -2861,9 +2910,9 @@ func (ec *executionContext) _Transaction_memo(ctx context.Context, field graphql return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Transaction_memo(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_TransactionResponse_log(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Transaction", + Object: "TransactionResponse", Field: field, IsMethod: true, IsResolver: false, @@ -2874,8 +2923,8 @@ func (ec *executionContext) fieldContext_Transaction_memo(ctx context.Context, f return fc, nil } -func (ec *executionContext) _TransactionMessage_typeUrl(ctx context.Context, field graphql.CollectedField, obj *model.TransactionMessage) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_TransactionMessage_typeUrl(ctx, field) +func (ec *executionContext) _TransactionResponse_info(ctx context.Context, field graphql.CollectedField, obj *model.TransactionResponse) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_TransactionResponse_info(ctx, field) if err != nil { return graphql.Null } @@ -2888,7 +2937,7 @@ func (ec *executionContext) _TransactionMessage_typeUrl(ctx context.Context, fie }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.TypeURL, nil + return obj.Info(), nil }) if err != nil { ec.Error(ctx, err) @@ -2905,11 +2954,11 @@ func (ec *executionContext) _TransactionMessage_typeUrl(ctx context.Context, fie return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_TransactionMessage_typeUrl(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_TransactionResponse_info(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "TransactionMessage", + Object: "TransactionResponse", Field: field, - IsMethod: false, + IsMethod: true, 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") @@ -2918,8 +2967,8 @@ func (ec *executionContext) fieldContext_TransactionMessage_typeUrl(ctx context. return fc, nil } -func (ec *executionContext) _TransactionMessage_route(ctx context.Context, field graphql.CollectedField, obj *model.TransactionMessage) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_TransactionMessage_route(ctx, field) +func (ec *executionContext) _TransactionResponse_error(ctx context.Context, field graphql.CollectedField, obj *model.TransactionResponse) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_TransactionResponse_error(ctx, field) if err != nil { return graphql.Null } @@ -2932,7 +2981,7 @@ func (ec *executionContext) _TransactionMessage_route(ctx context.Context, field }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Route, nil + return obj.Error(), nil }) if err != nil { ec.Error(ctx, err) @@ -2949,11 +2998,11 @@ func (ec *executionContext) _TransactionMessage_route(ctx context.Context, field return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_TransactionMessage_route(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_TransactionResponse_error(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "TransactionMessage", + Object: "TransactionResponse", Field: field, - IsMethod: false, + IsMethod: true, 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") @@ -2962,8 +3011,8 @@ func (ec *executionContext) fieldContext_TransactionMessage_route(ctx context.Co return fc, nil } -func (ec *executionContext) _TransactionMessage_value(ctx context.Context, field graphql.CollectedField, obj *model.TransactionMessage) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_TransactionMessage_value(ctx, field) +func (ec *executionContext) _TransactionResponse_data(ctx context.Context, field graphql.CollectedField, obj *model.TransactionResponse) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_TransactionResponse_data(ctx, field) if err != nil { return graphql.Null } @@ -2976,7 +3025,7 @@ func (ec *executionContext) _TransactionMessage_value(ctx context.Context, field }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Value, nil + return obj.Data(), nil }) if err != nil { ec.Error(ctx, err) @@ -2988,19 +3037,19 @@ func (ec *executionContext) _TransactionMessage_value(ctx context.Context, field } return graphql.Null } - res := resTmp.(model.MessageValue) + res := resTmp.(string) fc.Result = res - return ec.marshalNMessageValue2githubᚗcomᚋgnolangᚋtxᚑindexerᚋserveᚋgraphᚋmodelᚐMessageValue(ctx, field.Selections, res) + return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_TransactionMessage_value(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_TransactionResponse_data(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "TransactionMessage", + Object: "TransactionResponse", Field: field, - IsMethod: false, + IsMethod: true, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type MessageValue does not have child fields") + return nil, errors.New("field of type String does not have child fields") }, } return fc, nil @@ -6016,93 +6065,47 @@ func (ec *executionContext) _Transaction(ctx context.Context, sel ast.SelectionS case "index": out.Values[i] = ec._Transaction_index(ctx, field, obj) if out.Values[i] == graphql.Null { - atomic.AddUint32(&out.Invalids, 1) + out.Invalids++ } case "hash": out.Values[i] = ec._Transaction_hash(ctx, field, obj) if out.Values[i] == graphql.Null { - atomic.AddUint32(&out.Invalids, 1) + out.Invalids++ } case "block_height": out.Values[i] = ec._Transaction_block_height(ctx, field, obj) if out.Values[i] == graphql.Null { - atomic.AddUint32(&out.Invalids, 1) - } - case "response_error": - out.Values[i] = ec._Transaction_response_error(ctx, field, obj) - if out.Values[i] == graphql.Null { - atomic.AddUint32(&out.Invalids, 1) - } - case "response_log": - out.Values[i] = ec._Transaction_response_log(ctx, field, obj) - if out.Values[i] == graphql.Null { - atomic.AddUint32(&out.Invalids, 1) - } - case "response_info": - out.Values[i] = ec._Transaction_response_info(ctx, field, obj) - if out.Values[i] == graphql.Null { - atomic.AddUint32(&out.Invalids, 1) - } - case "response_data": - field := field - - innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - } - }() - res = ec._Transaction_response_data(ctx, field, obj) - if res == graphql.Null { - atomic.AddUint32(&fs.Invalids, 1) - } - return res - } - - if field.Deferrable != nil { - dfs, ok := deferred[field.Deferrable.Label] - di := 0 - if ok { - dfs.AddField(field) - di = len(dfs.Values) - 1 - } else { - dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) - deferred[field.Deferrable.Label] = dfs - } - dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { - return innerFunc(ctx, dfs) - }) - - // don't run the out.Concurrently() call below - out.Values[i] = graphql.Null - continue + out.Invalids++ } - - out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) case "gas_wanted": out.Values[i] = ec._Transaction_gas_wanted(ctx, field, obj) if out.Values[i] == graphql.Null { - atomic.AddUint32(&out.Invalids, 1) + out.Invalids++ } case "gas_used": out.Values[i] = ec._Transaction_gas_used(ctx, field, obj) if out.Values[i] == graphql.Null { - atomic.AddUint32(&out.Invalids, 1) + out.Invalids++ } case "content_raw": out.Values[i] = ec._Transaction_content_raw(ctx, field, obj) if out.Values[i] == graphql.Null { - atomic.AddUint32(&out.Invalids, 1) + out.Invalids++ } case "messages": out.Values[i] = ec._Transaction_messages(ctx, field, obj) if out.Values[i] == graphql.Null { - atomic.AddUint32(&out.Invalids, 1) + out.Invalids++ } case "memo": out.Values[i] = ec._Transaction_memo(ctx, field, obj) if out.Values[i] == graphql.Null { - atomic.AddUint32(&out.Invalids, 1) + out.Invalids++ + } + case "response": + out.Values[i] = ec._Transaction_response(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ } default: panic("unknown field " + strconv.Quote(field.Name)) @@ -6176,6 +6179,60 @@ func (ec *executionContext) _TransactionMessage(ctx context.Context, sel ast.Sel return out } +var transactionResponseImplementors = []string{"TransactionResponse"} + +func (ec *executionContext) _TransactionResponse(ctx context.Context, sel ast.SelectionSet, obj *model.TransactionResponse) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, transactionResponseImplementors) + + out := graphql.NewFieldSet(fields) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("TransactionResponse") + case "log": + out.Values[i] = ec._TransactionResponse_log(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "info": + out.Values[i] = ec._TransactionResponse_info(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "error": + out.Values[i] = ec._TransactionResponse_error(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "data": + out.Values[i] = ec._TransactionResponse_data(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + var txFeeImplementors = []string{"TxFee"} func (ec *executionContext) _TxFee(ctx context.Context, sel ast.SelectionSet, obj *model.TxFee) graphql.Marshaler { @@ -6766,6 +6823,10 @@ func (ec *executionContext) marshalNTransactionMessage2ᚕᚖgithub.comᚋgnol return ret } +func (ec *executionContext) marshalNTransactionResponse2githubᚗcomᚋgnolangᚋtxᚑindexerᚋserveᚋgraphᚋmodelᚐTransactionResponse(ctx context.Context, sel ast.SelectionSet, v model.TransactionResponse) graphql.Marshaler { + return ec._TransactionResponse(ctx, sel, &v) +} + func (ec *executionContext) marshalN__Directive2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirective(ctx context.Context, sel ast.SelectionSet, v introspection.Directive) graphql.Marshaler { return ec.___Directive(ctx, sel, &v) } diff --git a/serve/graph/model/transaction.go b/serve/graph/model/transaction.go index 94707c69..ab313f48 100644 --- a/serve/graph/model/transaction.go +++ b/serve/graph/model/transaction.go @@ -8,6 +8,7 @@ import ( "github.com/gnolang/gno/gno.land/pkg/sdk/vm" "github.com/gnolang/gno/tm2/pkg/amino" + abci "github.com/gnolang/gno/tm2/pkg/bft/abci/types" "github.com/gnolang/gno/tm2/pkg/bft/types" "github.com/gnolang/gno/tm2/pkg/sdk/bank" "github.com/gnolang/gno/tm2/pkg/std" @@ -27,7 +28,6 @@ func NewTransaction(txResult *types.TxResult) *Transaction { return &Transaction{ txResult: txResult, messages: make([]*TransactionMessage, 0), - stdTx: nil, } } @@ -47,24 +47,10 @@ func (t *Transaction) BlockHeight() int { return int(t.txResult.Height) } -func (t *Transaction) ResponseError() string { - if t.txResult.Response.Error == nil { - return "" +func (t *Transaction) Response() TransactionResponse { + return TransactionResponse{ + response: t.txResult.Response, } - - return t.txResult.Response.Error.Error() -} - -func (t *Transaction) ResponseLog() string { - return t.txResult.Response.Log -} - -func (t *Transaction) ResponseInfo() string { - return t.txResult.Response.Info -} - -func (t *Transaction) ResponseData() []byte { - return t.txResult.Response.Data } func (t *Transaction) GasWanted() int { @@ -136,6 +122,31 @@ func (t *Transaction) getMessages() []*TransactionMessage { return t.messages } +//nolint:errname // Provide a field named `error` as the GraphQL response value +type TransactionResponse struct { + response abci.ResponseDeliverTx +} + +func (tr *TransactionResponse) Log() string { + return tr.response.Log +} + +func (tr *TransactionResponse) Info() string { + return tr.response.Info +} + +func (tr *TransactionResponse) Error() string { + if tr.response.IsErr() { + return tr.response.Error.Error() + } + + return "" +} + +func (tr *TransactionResponse) Data() string { + return string(tr.response.Data) +} + type TransactionMessage struct { Value MessageValue Route string diff --git a/serve/graph/schema/types/transaction.graphql b/serve/graph/schema/types/transaction.graphql index 40b77345..45235a05 100644 --- a/serve/graph/schema/types/transaction.graphql +++ b/serve/graph/schema/types/transaction.graphql @@ -17,26 +17,6 @@ type Transaction { """ block_height: Int! - """ - The error value associated with the Transaction execution, if any. - """ - response_error: String! - - """ - The log value associated with the Transaction execution, if any. - """ - response_log: String! - - """ - The Info associated with the Transaction execution, if any. - """ - response_info: String! - - """ - The response data associated with the Transaction execution, if any. - """ - response_data: String! - """ The declared amount of computational effort the sender is willing to pay for executing this Transaction. """ @@ -64,6 +44,12 @@ type Transaction { For example, when trading a specific exchange, you would utilize the memo field of the transaction. """ memo: String! + + """ + `response` is the processing result of the transaction. + It has `log`, `info`, `error`, and `data`. + """ + response: TransactionResponse! } """ @@ -283,3 +269,29 @@ type TxFee { """ gas_fee: Int! } + +""" +`TransactionResponse` is the processing result of the transaction. +It has `log`, `info`, `error`, and `data`. +""" +type TransactionResponse { + """ + The log value associated with the Transaction execution, if any. + """ + log: String! + + """ + The Info associated with the Transaction execution, if any. + """ + info: String! + + """ + The error value associated with the Transaction execution, if any. + """ + error: String! + + """ + The response data associated with the Transaction execution, if any. + """ + data: String! +} From a0ae65d1ec131e28f2a418a8a9736003a20455ba Mon Sep 17 00:00:00 2001 From: jinoosss Date: Tue, 23 Apr 2024 02:31:32 +0900 Subject: [PATCH 4/6] fix: Fix transaction response --- serve/graph/generated.go | 77 ++++++---------------------- serve/graph/model/transaction.go | 4 ++ serve/graph/transaction.resolvers.go | 22 -------- 3 files changed, 20 insertions(+), 83 deletions(-) delete mode 100644 serve/graph/transaction.resolvers.go diff --git a/serve/graph/generated.go b/serve/graph/generated.go index 23a2817c..6504d702 100644 --- a/serve/graph/generated.go +++ b/serve/graph/generated.go @@ -43,7 +43,6 @@ type Config struct { type ResolverRoot interface { Query() QueryResolver Subscription() SubscriptionResolver - Transaction() TransactionResolver } type DirectiveRoot struct { @@ -151,9 +150,6 @@ type SubscriptionResolver interface { Transactions(ctx context.Context, filter model.TransactionFilter) (<-chan *model.Transaction, error) Blocks(ctx context.Context, filter model.BlockFilter) (<-chan *model.Block, error) } -type TransactionResolver interface { - Response(ctx context.Context, obj *model.Transaction) (*model.TransactionResponse, error) -} type executableSchema struct { schema *ast.Schema @@ -2767,7 +2763,7 @@ func (ec *executionContext) _Transaction_response(ctx context.Context, field gra }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.Transaction().Response(rctx, obj) + return obj.Response(), nil }) if err != nil { ec.Error(ctx, err) @@ -2779,9 +2775,9 @@ func (ec *executionContext) _Transaction_response(ctx context.Context, field gra } return graphql.Null } - res := resTmp.(*model.TransactionResponse) + res := resTmp.(model.TransactionResponse) fc.Result = res - return ec.marshalNTransactionResponse2ᚖgithub.comᚋgnolangᚋtxᚑindexerᚋserveᚋgraphᚋmodelᚐTransactionResponse(ctx, field.Selections, res) + return ec.marshalNTransactionResponse2githubᚗcomᚋgnolangᚋtxᚑindexerᚋserveᚋgraphᚋmodelᚐTransactionResponse(ctx, field.Selections, res) } func (ec *executionContext) fieldContext_Transaction_response(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { @@ -2789,7 +2785,7 @@ func (ec *executionContext) fieldContext_Transaction_response(ctx context.Contex Object: "Transaction", Field: field, IsMethod: true, - IsResolver: true, + IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "log": @@ -6132,84 +6128,53 @@ func (ec *executionContext) _Transaction(ctx context.Context, sel ast.SelectionS case "index": out.Values[i] = ec._Transaction_index(ctx, field, obj) if out.Values[i] == graphql.Null { - atomic.AddUint32(&out.Invalids, 1) + out.Invalids++ } case "hash": out.Values[i] = ec._Transaction_hash(ctx, field, obj) if out.Values[i] == graphql.Null { - atomic.AddUint32(&out.Invalids, 1) + out.Invalids++ } case "success": out.Values[i] = ec._Transaction_success(ctx, field, obj) if out.Values[i] == graphql.Null { - atomic.AddUint32(&out.Invalids, 1) + out.Invalids++ } case "block_height": out.Values[i] = ec._Transaction_block_height(ctx, field, obj) if out.Values[i] == graphql.Null { - atomic.AddUint32(&out.Invalids, 1) + out.Invalids++ } case "gas_wanted": out.Values[i] = ec._Transaction_gas_wanted(ctx, field, obj) if out.Values[i] == graphql.Null { - atomic.AddUint32(&out.Invalids, 1) + out.Invalids++ } case "gas_used": out.Values[i] = ec._Transaction_gas_used(ctx, field, obj) if out.Values[i] == graphql.Null { - atomic.AddUint32(&out.Invalids, 1) + out.Invalids++ } case "content_raw": out.Values[i] = ec._Transaction_content_raw(ctx, field, obj) if out.Values[i] == graphql.Null { - atomic.AddUint32(&out.Invalids, 1) + out.Invalids++ } case "messages": out.Values[i] = ec._Transaction_messages(ctx, field, obj) if out.Values[i] == graphql.Null { - atomic.AddUint32(&out.Invalids, 1) + out.Invalids++ } case "memo": out.Values[i] = ec._Transaction_memo(ctx, field, obj) if out.Values[i] == graphql.Null { - atomic.AddUint32(&out.Invalids, 1) + out.Invalids++ } case "response": - field := field - - innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - } - }() - res = ec._Transaction_response(ctx, field, obj) - if res == graphql.Null { - atomic.AddUint32(&fs.Invalids, 1) - } - return res - } - - if field.Deferrable != nil { - dfs, ok := deferred[field.Deferrable.Label] - di := 0 - if ok { - dfs.AddField(field) - di = len(dfs.Values) - 1 - } else { - dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) - deferred[field.Deferrable.Label] = dfs - } - dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { - return innerFunc(ctx, dfs) - }) - - // don't run the out.Concurrently() call below - out.Values[i] = graphql.Null - continue + out.Values[i] = ec._Transaction_response(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ } - - out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) default: panic("unknown field " + strconv.Quote(field.Name)) } @@ -6930,16 +6895,6 @@ func (ec *executionContext) marshalNTransactionResponse2githubᚗcomᚋgnolang return ec._TransactionResponse(ctx, sel, &v) } -func (ec *executionContext) marshalNTransactionResponse2ᚖgithub.comᚋgnolangᚋtxᚑindexerᚋserveᚋgraphᚋmodelᚐTransactionResponse(ctx context.Context, sel ast.SelectionSet, v *model.TransactionResponse) 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._TransactionResponse(ctx, sel, v) -} - func (ec *executionContext) marshalN__Directive2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirective(ctx context.Context, sel ast.SelectionSet, v introspection.Directive) graphql.Marshaler { return ec.___Directive(ctx, sel, &v) } diff --git a/serve/graph/model/transaction.go b/serve/graph/model/transaction.go index 6819bcd4..d494d699 100644 --- a/serve/graph/model/transaction.go +++ b/serve/graph/model/transaction.go @@ -51,6 +51,10 @@ func (t *Transaction) Success() bool { return t.txResult.Response.IsOK() } +func (t *Transaction) Response() TransactionResponse { + return TransactionResponse{response: t.txResult.Response} +} + func (t *Transaction) GasWanted() int { return int(t.txResult.Response.GasWanted) } diff --git a/serve/graph/transaction.resolvers.go b/serve/graph/transaction.resolvers.go deleted file mode 100644 index 0513b4bb..00000000 --- a/serve/graph/transaction.resolvers.go +++ /dev/null @@ -1,22 +0,0 @@ -package graph - -// This file will be automatically regenerated based on the schema, any resolver implementations -// will be copied through when generating and any unknown code will be moved to the end. -// Code generated by github.com/99designs/gqlgen version v0.17.45 - -import ( - "context" - "fmt" - - "github.com/gnolang/tx-indexer/serve/graph/model" -) - -// Response is the resolver for the response field. -func (r *transactionResolver) Response(ctx context.Context, obj *model.Transaction) (*model.TransactionResponse, error) { - panic(fmt.Errorf("not implemented: Response - response")) -} - -// Transaction returns TransactionResolver implementation. -func (r *Resolver) Transaction() TransactionResolver { return &transactionResolver{r} } - -type transactionResolver struct{ *Resolver } From 04254562fff098eb11110aca22c61050f79d4f84 Mon Sep 17 00:00:00 2001 From: jinoosss <112360739+jinoosss@users.noreply.github.com> Date: Tue, 23 Apr 2024 19:31:00 +0900 Subject: [PATCH 5/6] Update serve/graph/model/transaction.go Co-authored-by: Antonio Navarro Perez --- serve/graph/model/transaction.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/serve/graph/model/transaction.go b/serve/graph/model/transaction.go index d494d699..55f03c93 100644 --- a/serve/graph/model/transaction.go +++ b/serve/graph/model/transaction.go @@ -51,8 +51,8 @@ func (t *Transaction) Success() bool { return t.txResult.Response.IsOK() } -func (t *Transaction) Response() TransactionResponse { - return TransactionResponse{response: t.txResult.Response} +func (t *Transaction) Response() *TransactionResponse { + return &TransactionResponse{response: t.txResult.Response} } func (t *Transaction) GasWanted() int { From 035b818d39a5a1ba7708e5d56ae6b77a388986f7 Mon Sep 17 00:00:00 2001 From: jinoosss Date: Tue, 23 Apr 2024 19:32:11 +0900 Subject: [PATCH 6/6] chore: Update generated --- serve/graph/generated.go | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/serve/graph/generated.go b/serve/graph/generated.go index 6504d702..681de29d 100644 --- a/serve/graph/generated.go +++ b/serve/graph/generated.go @@ -2775,9 +2775,9 @@ func (ec *executionContext) _Transaction_response(ctx context.Context, field gra } return graphql.Null } - res := resTmp.(model.TransactionResponse) + res := resTmp.(*model.TransactionResponse) fc.Result = res - return ec.marshalNTransactionResponse2githubᚗcomᚋgnolangᚋtxᚑindexerᚋserveᚋgraphᚋmodelᚐTransactionResponse(ctx, field.Selections, res) + return ec.marshalNTransactionResponse2ᚖgithub.comᚋgnolangᚋtxᚑindexerᚋserveᚋgraphᚋmodelᚐTransactionResponse(ctx, field.Selections, res) } func (ec *executionContext) fieldContext_Transaction_response(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { @@ -6891,8 +6891,14 @@ func (ec *executionContext) marshalNTransactionMessage2ᚕᚖgithub.comᚋgnol return ret } -func (ec *executionContext) marshalNTransactionResponse2githubᚗcomᚋgnolangᚋtxᚑindexerᚋserveᚋgraphᚋmodelᚐTransactionResponse(ctx context.Context, sel ast.SelectionSet, v model.TransactionResponse) graphql.Marshaler { - return ec._TransactionResponse(ctx, sel, &v) +func (ec *executionContext) marshalNTransactionResponse2ᚖgithub.comᚋgnolangᚋtxᚑindexerᚋserveᚋgraphᚋmodelᚐTransactionResponse(ctx context.Context, sel ast.SelectionSet, v *model.TransactionResponse) 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._TransactionResponse(ctx, sel, v) } func (ec *executionContext) marshalN__Directive2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirective(ctx context.Context, sel ast.SelectionSet, v introspection.Directive) graphql.Marshaler {